Henrywood and Agarwal, Equation (12)

Percentage Accurate: 36.2% → 72.3%
Time: 10.7s
Alternatives: 14
Speedup: 10.2×

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)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
    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}

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 14 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: 36.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (*
  (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
  (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
	return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
    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: 72.3% accurate, 1.7× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ t_1 := \frac{D\_m}{d\_m + d\_m} \cdot M\_m\\ t_2 := \mathsf{fma}\left(\frac{\left(M\_m \cdot \left(M\_m \cdot h\right)\right) \cdot \left(D\_m \cdot D\_m\right)}{\left(t\_0 \cdot \ell\right) \cdot d\_m}, -0.125, \frac{d\_m}{t\_0}\right)\\ \mathbf{if}\;h \leq -5 \cdot 10^{+105}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;h \leq 5.7 \cdot 10^{+175}:\\ \;\;\;\;\frac{\left|d\_m\right|}{t\_0} \cdot \left(1 - \left(\left(0.5 \cdot t\_1\right) \cdot t\_1\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* l h)))
        (t_1 (* (/ D_m (+ d_m d_m)) M_m))
        (t_2
         (fma
          (/ (* (* M_m (* M_m h)) (* D_m D_m)) (* (* t_0 l) d_m))
          -0.125
          (/ d_m t_0))))
   (if (<= h -5e+105)
     t_2
     (if (<= h 5.7e+175)
       (* (/ (fabs d_m) t_0) (- 1.0 (* (* (* 0.5 t_1) t_1) (/ h l))))
       t_2))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((l * h));
	double t_1 = (D_m / (d_m + d_m)) * M_m;
	double t_2 = fma((((M_m * (M_m * h)) * (D_m * D_m)) / ((t_0 * l) * d_m)), -0.125, (d_m / t_0));
	double tmp;
	if (h <= -5e+105) {
		tmp = t_2;
	} else if (h <= 5.7e+175) {
		tmp = (fabs(d_m) / t_0) * (1.0 - (((0.5 * t_1) * t_1) * (h / l)));
	} else {
		tmp = t_2;
	}
	return tmp;
}
d_m = abs(d)
M_m = abs(M)
D_m = abs(D)
d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m])
function code(d_m, h, l, M_m, D_m)
	t_0 = sqrt(Float64(l * h))
	t_1 = Float64(Float64(D_m / Float64(d_m + d_m)) * M_m)
	t_2 = fma(Float64(Float64(Float64(M_m * Float64(M_m * h)) * Float64(D_m * D_m)) / Float64(Float64(t_0 * l) * d_m)), -0.125, Float64(d_m / t_0))
	tmp = 0.0
	if (h <= -5e+105)
		tmp = t_2;
	elseif (h <= 5.7e+175)
		tmp = Float64(Float64(abs(d_m) / t_0) * Float64(1.0 - Float64(Float64(Float64(0.5 * t_1) * t_1) * Float64(h / l))));
	else
		tmp = t_2;
	end
	return tmp
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(D$95$m / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision] * M$95$m), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(M$95$m * N[(M$95$m * h), $MachinePrecision]), $MachinePrecision] * N[(D$95$m * D$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(t$95$0 * l), $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision] * -0.125 + N[(d$95$m / t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -5e+105], t$95$2, If[LessEqual[h, 5.7e+175], N[(N[(N[Abs[d$95$m], $MachinePrecision] / t$95$0), $MachinePrecision] * N[(1.0 - N[(N[(N[(0.5 * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \frac{D\_m}{d\_m + d\_m} \cdot M\_m\\
t_2 := \mathsf{fma}\left(\frac{\left(M\_m \cdot \left(M\_m \cdot h\right)\right) \cdot \left(D\_m \cdot D\_m\right)}{\left(t\_0 \cdot \ell\right) \cdot d\_m}, -0.125, \frac{d\_m}{t\_0}\right)\\
\mathbf{if}\;h \leq -5 \cdot 10^{+105}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;h \leq 5.7 \cdot 10^{+175}:\\
\;\;\;\;\frac{\left|d\_m\right|}{t\_0} \cdot \left(1 - \left(\left(0.5 \cdot t\_1\right) \cdot t\_1\right) \cdot \frac{h}{\ell}\right)\\

\mathbf{else}:\\
\;\;\;\;t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if h < -5.00000000000000046e105 or 5.70000000000000024e175 < h

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

      \[\leadsto \mathsf{fma}\left(\frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(\sqrt{\ell \cdot h} \cdot \ell\right) \cdot d}, \color{blue}{-0.125}, \frac{d}{\sqrt{\ell \cdot h}}\right) \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(\sqrt{\ell \cdot h} \cdot \ell\right) \cdot d}, \frac{-1}{8}, \frac{d}{\sqrt{\ell \cdot h}}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(\sqrt{\ell \cdot h} \cdot \ell\right) \cdot d}, \frac{-1}{8}, \frac{d}{\sqrt{\ell \cdot h}}\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{fma}\left(\frac{\left(M \cdot \left(M \cdot h\right)\right) \cdot \left(D \cdot D\right)}{\left(\sqrt{\ell \cdot h} \cdot \ell\right) \cdot d}, \frac{-1}{8}, \frac{d}{\sqrt{\ell \cdot h}}\right) \]
      4. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\left(M \cdot \left(M \cdot h\right)\right) \cdot \left(D \cdot D\right)}{\left(\sqrt{\ell \cdot h} \cdot \ell\right) \cdot d}, \frac{-1}{8}, \frac{d}{\sqrt{\ell \cdot h}}\right) \]
      5. lower-*.f6452.4

        \[\leadsto \mathsf{fma}\left(\frac{\left(M \cdot \left(M \cdot h\right)\right) \cdot \left(D \cdot D\right)}{\left(\sqrt{\ell \cdot h} \cdot \ell\right) \cdot d}, -0.125, \frac{d}{\sqrt{\ell \cdot h}}\right) \]
    8. Applied rewrites52.4%

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

    if -5.00000000000000046e105 < h < 5.70000000000000024e175

    1. Initial program 36.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \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. lift-/.f64N/A

        \[\leadsto \left({\color{blue}{\left(\frac{d}{h}\right)}}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-pow.f64N/A

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\color{blue}{\left(\frac{d}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      5. lift-pow.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      6. pow-prod-downN/A

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      7. lift-/.f64N/A

        \[\leadsto {\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      8. metadata-evalN/A

        \[\leadsto {\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\color{blue}{\frac{1}{2}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      9. pow1/2N/A

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      10. lower-sqrt.f64N/A

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

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

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      13. lower-/.f64N/A

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

        \[\leadsto \sqrt{\frac{\color{blue}{d \cdot d}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      15. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{\color{blue}{d \cdot d}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      16. lower-*.f6443.0

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot d}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    4. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{\frac{d \cdot d}{h \cdot \ell}}} \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. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{d \cdot d}{\color{blue}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-/.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. lift-*.f64N/A

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      7. pow1/2N/A

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

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

        \[\leadsto \frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      10. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      11. metadata-evalN/A

        \[\leadsto \frac{{\left({d}^{2}\right)}^{\color{blue}{\frac{1}{2}}}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      12. pow1/2N/A

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

        \[\leadsto \frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      14. rem-sqrt-square-revN/A

        \[\leadsto \frac{\color{blue}{\left|d\right|}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      15. lower-fabs.f64N/A

        \[\leadsto \frac{\color{blue}{\left|d\right|}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      16. sqrt-unprodN/A

        \[\leadsto \frac{\left|d\right|}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      17. lower-sqrt.f64N/A

        \[\leadsto \frac{\left|d\right|}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      18. *-commutativeN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\color{blue}{\ell \cdot h}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      19. lower-*.f6469.9

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

      \[\leadsto \color{blue}{\frac{\left|d\right|}{\sqrt{\ell \cdot h}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    6. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right) \cdot \frac{h}{\ell}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{\color{blue}{2 \cdot d}}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      5. unpow2N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)}\right) \cdot \frac{h}{\ell}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)}\right) \cdot \frac{h}{\ell}\right) \]
      7. associate-/l*N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      9. lower-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \color{blue}{\frac{D}{2 \cdot d}}\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      10. count-2-revN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{\color{blue}{d + d}}\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      11. lower-+.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{\color{blue}{d + d}}\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      12. associate-/l*N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}\right)\right) \cdot \frac{h}{\ell}\right) \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}\right)\right) \cdot \frac{h}{\ell}\right) \]
      14. lower-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \color{blue}{\frac{D}{2 \cdot d}}\right)\right)\right) \cdot \frac{h}{\ell}\right) \]
      15. count-2-revN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{\color{blue}{d + d}}\right)\right)\right) \cdot \frac{h}{\ell}\right) \]
      16. lower-+.f6469.1

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

      \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \color{blue}{\left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right)}\right) \cdot \frac{h}{\ell}\right) \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \color{blue}{\left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right)\right)} \cdot \frac{h}{\ell}\right) \]
      2. lift-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\color{blue}{\frac{1}{2}} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right)\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-*.f64N/A

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

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \color{blue}{\left(\left(\frac{1}{2} \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right)} \cdot \frac{h}{\ell}\right) \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \color{blue}{\left(\left(\frac{1}{2} \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right)} \cdot \frac{h}{\ell}\right) \]
      6. lower-*.f64N/A

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

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(\color{blue}{0.5} \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      8. lift-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(\frac{1}{2} \cdot \color{blue}{\left(M \cdot \frac{D}{d + d}\right)}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      9. lift-+.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(\frac{1}{2} \cdot \left(M \cdot \frac{D}{\color{blue}{d + d}}\right)\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      10. lift-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(\frac{1}{2} \cdot \left(M \cdot \color{blue}{\frac{D}{d + d}}\right)\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      11. *-commutativeN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(\frac{1}{2} \cdot \color{blue}{\left(\frac{D}{d + d} \cdot M\right)}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      12. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(\frac{1}{2} \cdot \color{blue}{\left(\frac{D}{d + d} \cdot M\right)}\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      13. lift-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(\frac{1}{2} \cdot \left(\color{blue}{\frac{D}{d + d}} \cdot M\right)\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      14. lift-+.f6469.1

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(0.5 \cdot \left(\frac{D}{\color{blue}{d + d}} \cdot M\right)\right) \cdot \left(M \cdot \frac{D}{d + d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      15. lift-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(\frac{1}{2} \cdot \left(\frac{D}{d + d} \cdot M\right)\right) \cdot \color{blue}{\left(M \cdot \frac{D}{d + d}\right)}\right) \cdot \frac{h}{\ell}\right) \]
      16. lift-+.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(\frac{1}{2} \cdot \left(\frac{D}{d + d} \cdot M\right)\right) \cdot \left(M \cdot \frac{D}{\color{blue}{d + d}}\right)\right) \cdot \frac{h}{\ell}\right) \]
      17. lift-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(\frac{1}{2} \cdot \left(\frac{D}{d + d} \cdot M\right)\right) \cdot \left(M \cdot \color{blue}{\frac{D}{d + d}}\right)\right) \cdot \frac{h}{\ell}\right) \]
      18. *-commutativeN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(\frac{1}{2} \cdot \left(\frac{D}{d + d} \cdot M\right)\right) \cdot \color{blue}{\left(\frac{D}{d + d} \cdot M\right)}\right) \cdot \frac{h}{\ell}\right) \]
      19. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(\frac{1}{2} \cdot \left(\frac{D}{d + d} \cdot M\right)\right) \cdot \color{blue}{\left(\frac{D}{d + d} \cdot M\right)}\right) \cdot \frac{h}{\ell}\right) \]
      20. lift-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\left(\frac{1}{2} \cdot \left(\frac{D}{d + d} \cdot M\right)\right) \cdot \left(\color{blue}{\frac{D}{d + d}} \cdot M\right)\right) \cdot \frac{h}{\ell}\right) \]
      21. lift-+.f6469.1

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

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

Alternative 2: 71.9% accurate, 1.9× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;\ell \leq -5 \cdot 10^{-146}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\frac{\left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot D\_m\right) \cdot D\_m}{d\_m}}{\sqrt{h \cdot \ell} \cdot \ell}, -0.125, \frac{d\_m}{t\_0}\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{-115}:\\ \;\;\;\;\frac{\left|d\_m\right|}{t\_0} \cdot \mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{\left(d\_m \cdot d\_m\right) \cdot \ell} \cdot -0.125, h, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\frac{M\_m \cdot M\_m}{\left(\ell \cdot d\_m\right) \cdot \sqrt{\frac{1}{h} \cdot \ell}} \cdot -0.125\right) \cdot D\_m, D\_m, \frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}}\right)\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* l h))))
   (if (<= l -5e-146)
     (fma
      (/ (/ (* (* (* (* M_m M_m) h) D_m) D_m) d_m) (* (sqrt (* h l)) l))
      -0.125
      (/ d_m t_0))
     (if (<= l 6e-115)
       (*
        (/ (fabs d_m) t_0)
        (fma
         (* (/ (* (* D_m M_m) (* D_m M_m)) (* (* d_m d_m) l)) -0.125)
         h
         1.0))
       (fma
        (* (* (/ (* M_m M_m) (* (* l d_m) (sqrt (* (/ 1.0 h) l)))) -0.125) D_m)
        D_m
        (/ d_m (* (sqrt l) (sqrt h))))))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((l * h));
	double tmp;
	if (l <= -5e-146) {
		tmp = fma(((((((M_m * M_m) * h) * D_m) * D_m) / d_m) / (sqrt((h * l)) * l)), -0.125, (d_m / t_0));
	} else if (l <= 6e-115) {
		tmp = (fabs(d_m) / t_0) * fma(((((D_m * M_m) * (D_m * M_m)) / ((d_m * d_m) * l)) * -0.125), h, 1.0);
	} else {
		tmp = fma(((((M_m * M_m) / ((l * d_m) * sqrt(((1.0 / h) * l)))) * -0.125) * D_m), D_m, (d_m / (sqrt(l) * sqrt(h))));
	}
	return tmp;
}
d_m = abs(d)
M_m = abs(M)
D_m = abs(D)
d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m])
function code(d_m, h, l, M_m, D_m)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (l <= -5e-146)
		tmp = fma(Float64(Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) * D_m) * D_m) / d_m) / Float64(sqrt(Float64(h * l)) * l)), -0.125, Float64(d_m / t_0));
	elseif (l <= 6e-115)
		tmp = Float64(Float64(abs(d_m) / t_0) * fma(Float64(Float64(Float64(Float64(D_m * M_m) * Float64(D_m * M_m)) / Float64(Float64(d_m * d_m) * l)) * -0.125), h, 1.0));
	else
		tmp = fma(Float64(Float64(Float64(Float64(M_m * M_m) / Float64(Float64(l * d_m) * sqrt(Float64(Float64(1.0 / h) * l)))) * -0.125) * D_m), D_m, Float64(d_m / Float64(sqrt(l) * sqrt(h))));
	end
	return tmp
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -5e-146], N[(N[(N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / d$95$m), $MachinePrecision] / N[(N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125 + N[(d$95$m / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6e-115], N[(N[(N[Abs[d$95$m], $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / N[(N[(l * d$95$m), $MachinePrecision] * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m + N[(d$95$m / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-146}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{\left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot D\_m\right) \cdot D\_m}{d\_m}}{\sqrt{h \cdot \ell} \cdot \ell}, -0.125, \frac{d\_m}{t\_0}\right)\\

\mathbf{elif}\;\ell \leq 6 \cdot 10^{-115}:\\
\;\;\;\;\frac{\left|d\_m\right|}{t\_0} \cdot \mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{\left(d\_m \cdot d\_m\right) \cdot \ell} \cdot -0.125, h, 1\right)\\

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


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

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

      \[\leadsto \mathsf{fma}\left(\frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(\sqrt{\ell \cdot h} \cdot \ell\right) \cdot d}, \color{blue}{-0.125}, \frac{d}{\sqrt{\ell \cdot h}}\right) \]
    7. Applied rewrites59.9%

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

    if -4.99999999999999957e-146 < l < 6.0000000000000003e-115

    1. Initial program 36.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \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. lift-/.f64N/A

        \[\leadsto \left({\color{blue}{\left(\frac{d}{h}\right)}}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-pow.f64N/A

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\color{blue}{\left(\frac{d}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      5. lift-pow.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      6. pow-prod-downN/A

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      7. lift-/.f64N/A

        \[\leadsto {\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      8. metadata-evalN/A

        \[\leadsto {\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\color{blue}{\frac{1}{2}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      9. pow1/2N/A

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      10. lower-sqrt.f64N/A

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

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

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      13. lower-/.f64N/A

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

        \[\leadsto \sqrt{\frac{\color{blue}{d \cdot d}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      15. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{\color{blue}{d \cdot d}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      16. lower-*.f6443.0

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot d}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    4. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{\frac{d \cdot d}{h \cdot \ell}}} \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. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{d \cdot d}{\color{blue}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-/.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. lift-*.f64N/A

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      7. pow1/2N/A

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

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

        \[\leadsto \frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      10. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      11. metadata-evalN/A

        \[\leadsto \frac{{\left({d}^{2}\right)}^{\color{blue}{\frac{1}{2}}}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      12. pow1/2N/A

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

        \[\leadsto \frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      14. rem-sqrt-square-revN/A

        \[\leadsto \frac{\color{blue}{\left|d\right|}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      15. lower-fabs.f64N/A

        \[\leadsto \frac{\color{blue}{\left|d\right|}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      16. sqrt-unprodN/A

        \[\leadsto \frac{\left|d\right|}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      17. lower-sqrt.f64N/A

        \[\leadsto \frac{\left|d\right|}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      18. *-commutativeN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\color{blue}{\ell \cdot h}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      19. lower-*.f6469.9

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

      \[\leadsto \color{blue}{\frac{\left|d\right|}{\sqrt{\ell \cdot h}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    6. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right) \cdot \frac{h}{\ell}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{\color{blue}{2 \cdot d}}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      5. unpow2N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)}\right) \cdot \frac{h}{\ell}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)}\right) \cdot \frac{h}{\ell}\right) \]
      7. associate-/l*N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      9. lower-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \color{blue}{\frac{D}{2 \cdot d}}\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      10. count-2-revN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{\color{blue}{d + d}}\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      11. lower-+.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{\color{blue}{d + d}}\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      12. associate-/l*N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}\right)\right) \cdot \frac{h}{\ell}\right) \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}\right)\right) \cdot \frac{h}{\ell}\right) \]
      14. lower-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \color{blue}{\frac{D}{2 \cdot d}}\right)\right)\right) \cdot \frac{h}{\ell}\right) \]
      15. count-2-revN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{\color{blue}{d + d}}\right)\right)\right) \cdot \frac{h}{\ell}\right) \]
      16. lower-+.f6469.1

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

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

      \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \color{blue}{\left(h \cdot \left(\frac{1}{h} - \frac{1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)\right)} \]
    9. Step-by-step derivation
      1. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(h \cdot \left(\frac{1}{h} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{8}\right)\right) \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}}\right)\right) \]
      2. metadata-evalN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(h \cdot \left(\frac{1}{h} + \frac{-1}{8} \cdot \frac{\color{blue}{{D}^{2} \cdot {M}^{2}}}{{d}^{2} \cdot \ell}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(h \cdot \left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} + \color{blue}{\frac{1}{h}}\right)\right) \]
      4. distribute-rgt-inN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) \cdot h + \color{blue}{\frac{1}{h} \cdot h}\right) \]
      5. inv-powN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) \cdot h + {h}^{-1} \cdot h\right) \]
      6. pow-plusN/A

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

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) \cdot h + {h}^{0}\right) \]
      8. metadata-evalN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) \cdot h + 1\right) \]
      9. lower-fma.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, \color{blue}{h}, 1\right) \]
    10. Applied rewrites60.1%

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

    if 6.0000000000000003e-115 < l

    1. Initial program 36.2%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot h\right) \cdot M\right) \cdot M}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right)} \]
    4. Taylor expanded in h around inf

      \[\leadsto \mathsf{fma}\left(\left(\frac{{M}^{2}}{d \cdot \left(\ell \cdot \left(\sqrt{\ell} \cdot \sqrt{\frac{1}{h}}\right)\right)} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{{M}^{2}}{d \cdot \left(\ell \cdot \left(\sqrt{\ell} \cdot \sqrt{\frac{1}{h}}\right)\right)} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{d \cdot \left(\ell \cdot \left(\sqrt{\ell} \cdot \sqrt{\frac{1}{h}}\right)\right)} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      3. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{d \cdot \left(\ell \cdot \left(\sqrt{\ell} \cdot \sqrt{\frac{1}{h}}\right)\right)} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(d \cdot \ell\right) \cdot \left(\sqrt{\ell} \cdot \sqrt{\frac{1}{h}}\right)} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      5. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(d \cdot \ell\right) \cdot \left(\sqrt{\ell} \cdot \sqrt{\frac{1}{h}}\right)} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\ell \cdot d\right) \cdot \left(\sqrt{\ell} \cdot \sqrt{\frac{1}{h}}\right)} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      7. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\ell \cdot d\right) \cdot \left(\sqrt{\ell} \cdot \sqrt{\frac{1}{h}}\right)} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\ell \cdot d\right) \cdot \left(\sqrt{\frac{1}{h}} \cdot \sqrt{\ell}\right)} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      9. sqrt-unprodN/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\ell \cdot d\right) \cdot \sqrt{\frac{1}{h} \cdot \ell}} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      10. lower-sqrt.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\ell \cdot d\right) \cdot \sqrt{\frac{1}{h} \cdot \ell}} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      11. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\ell \cdot d\right) \cdot \sqrt{\frac{1}{h} \cdot \ell}} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      12. lower-/.f6438.1

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\ell \cdot d\right) \cdot \sqrt{\frac{1}{h} \cdot \ell}} \cdot -0.125\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites38.1%

      \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\ell \cdot d\right) \cdot \sqrt{\frac{1}{h} \cdot \ell}} \cdot -0.125\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 71.4% accurate, 2.0× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;\ell \leq -5 \cdot 10^{-146}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\frac{\left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot D\_m\right) \cdot D\_m}{d\_m}}{\sqrt{h \cdot \ell} \cdot \ell}, -0.125, \frac{d\_m}{t\_0}\right)\\ \mathbf{elif}\;\ell \leq 6 \cdot 10^{-115}:\\ \;\;\;\;\frac{\left|d\_m\right|}{t\_0} \cdot \mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{\left(d\_m \cdot d\_m\right) \cdot \ell} \cdot -0.125, h, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(\frac{M\_m \cdot M\_m}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d\_m} \cdot -0.125\right) \cdot D\_m, D\_m, \frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}}\right)\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* l h))))
   (if (<= l -5e-146)
     (fma
      (/ (/ (* (* (* (* M_m M_m) h) D_m) D_m) d_m) (* (sqrt (* h l)) l))
      -0.125
      (/ d_m t_0))
     (if (<= l 6e-115)
       (*
        (/ (fabs d_m) t_0)
        (fma
         (* (/ (* (* D_m M_m) (* D_m M_m)) (* (* d_m d_m) l)) -0.125)
         h
         1.0))
       (fma
        (* (* (/ (* M_m M_m) (* (* (sqrt (/ l h)) l) d_m)) -0.125) D_m)
        D_m
        (/ d_m (* (sqrt l) (sqrt h))))))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((l * h));
	double tmp;
	if (l <= -5e-146) {
		tmp = fma(((((((M_m * M_m) * h) * D_m) * D_m) / d_m) / (sqrt((h * l)) * l)), -0.125, (d_m / t_0));
	} else if (l <= 6e-115) {
		tmp = (fabs(d_m) / t_0) * fma(((((D_m * M_m) * (D_m * M_m)) / ((d_m * d_m) * l)) * -0.125), h, 1.0);
	} else {
		tmp = fma(((((M_m * M_m) / ((sqrt((l / h)) * l) * d_m)) * -0.125) * D_m), D_m, (d_m / (sqrt(l) * sqrt(h))));
	}
	return tmp;
}
d_m = abs(d)
M_m = abs(M)
D_m = abs(D)
d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m])
function code(d_m, h, l, M_m, D_m)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (l <= -5e-146)
		tmp = fma(Float64(Float64(Float64(Float64(Float64(Float64(M_m * M_m) * h) * D_m) * D_m) / d_m) / Float64(sqrt(Float64(h * l)) * l)), -0.125, Float64(d_m / t_0));
	elseif (l <= 6e-115)
		tmp = Float64(Float64(abs(d_m) / t_0) * fma(Float64(Float64(Float64(Float64(D_m * M_m) * Float64(D_m * M_m)) / Float64(Float64(d_m * d_m) * l)) * -0.125), h, 1.0));
	else
		tmp = fma(Float64(Float64(Float64(Float64(M_m * M_m) / Float64(Float64(sqrt(Float64(l / h)) * l) * d_m)) * -0.125) * D_m), D_m, Float64(d_m / Float64(sqrt(l) * sqrt(h))));
	end
	return tmp
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -5e-146], N[(N[(N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m), $MachinePrecision] / d$95$m), $MachinePrecision] / N[(N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125 + N[(d$95$m / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6e-115], N[(N[(N[Abs[d$95$m], $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] / N[(N[(N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D$95$m), $MachinePrecision] * D$95$m + N[(d$95$m / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{-146}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{\left(\left(\left(M\_m \cdot M\_m\right) \cdot h\right) \cdot D\_m\right) \cdot D\_m}{d\_m}}{\sqrt{h \cdot \ell} \cdot \ell}, -0.125, \frac{d\_m}{t\_0}\right)\\

\mathbf{elif}\;\ell \leq 6 \cdot 10^{-115}:\\
\;\;\;\;\frac{\left|d\_m\right|}{t\_0} \cdot \mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{\left(d\_m \cdot d\_m\right) \cdot \ell} \cdot -0.125, h, 1\right)\\

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


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

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

      \[\leadsto \mathsf{fma}\left(\frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(\sqrt{\ell \cdot h} \cdot \ell\right) \cdot d}, \color{blue}{-0.125}, \frac{d}{\sqrt{\ell \cdot h}}\right) \]
    7. Applied rewrites59.9%

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

    if -4.99999999999999957e-146 < l < 6.0000000000000003e-115

    1. Initial program 36.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \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. lift-/.f64N/A

        \[\leadsto \left({\color{blue}{\left(\frac{d}{h}\right)}}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-pow.f64N/A

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\color{blue}{\left(\frac{d}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      5. lift-pow.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      6. pow-prod-downN/A

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      7. lift-/.f64N/A

        \[\leadsto {\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      8. metadata-evalN/A

        \[\leadsto {\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\color{blue}{\frac{1}{2}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      9. pow1/2N/A

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      10. lower-sqrt.f64N/A

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

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

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      13. lower-/.f64N/A

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

        \[\leadsto \sqrt{\frac{\color{blue}{d \cdot d}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      15. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{\color{blue}{d \cdot d}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      16. lower-*.f6443.0

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot d}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    4. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{\frac{d \cdot d}{h \cdot \ell}}} \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. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{d \cdot d}{\color{blue}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-/.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. lift-*.f64N/A

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      7. pow1/2N/A

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

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

        \[\leadsto \frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      10. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      11. metadata-evalN/A

        \[\leadsto \frac{{\left({d}^{2}\right)}^{\color{blue}{\frac{1}{2}}}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      12. pow1/2N/A

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

        \[\leadsto \frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      14. rem-sqrt-square-revN/A

        \[\leadsto \frac{\color{blue}{\left|d\right|}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      15. lower-fabs.f64N/A

        \[\leadsto \frac{\color{blue}{\left|d\right|}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      16. sqrt-unprodN/A

        \[\leadsto \frac{\left|d\right|}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      17. lower-sqrt.f64N/A

        \[\leadsto \frac{\left|d\right|}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      18. *-commutativeN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\color{blue}{\ell \cdot h}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      19. lower-*.f6469.9

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

      \[\leadsto \color{blue}{\frac{\left|d\right|}{\sqrt{\ell \cdot h}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    6. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right) \cdot \frac{h}{\ell}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{\color{blue}{2 \cdot d}}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      5. unpow2N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)}\right) \cdot \frac{h}{\ell}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)}\right) \cdot \frac{h}{\ell}\right) \]
      7. associate-/l*N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      9. lower-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \color{blue}{\frac{D}{2 \cdot d}}\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      10. count-2-revN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{\color{blue}{d + d}}\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      11. lower-+.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{\color{blue}{d + d}}\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      12. associate-/l*N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}\right)\right) \cdot \frac{h}{\ell}\right) \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}\right)\right) \cdot \frac{h}{\ell}\right) \]
      14. lower-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \color{blue}{\frac{D}{2 \cdot d}}\right)\right)\right) \cdot \frac{h}{\ell}\right) \]
      15. count-2-revN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{\color{blue}{d + d}}\right)\right)\right) \cdot \frac{h}{\ell}\right) \]
      16. lower-+.f6469.1

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

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

      \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \color{blue}{\left(h \cdot \left(\frac{1}{h} - \frac{1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)\right)} \]
    9. Step-by-step derivation
      1. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(h \cdot \left(\frac{1}{h} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{8}\right)\right) \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}}\right)\right) \]
      2. metadata-evalN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(h \cdot \left(\frac{1}{h} + \frac{-1}{8} \cdot \frac{\color{blue}{{D}^{2} \cdot {M}^{2}}}{{d}^{2} \cdot \ell}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(h \cdot \left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} + \color{blue}{\frac{1}{h}}\right)\right) \]
      4. distribute-rgt-inN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) \cdot h + \color{blue}{\frac{1}{h} \cdot h}\right) \]
      5. inv-powN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) \cdot h + {h}^{-1} \cdot h\right) \]
      6. pow-plusN/A

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

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) \cdot h + {h}^{0}\right) \]
      8. metadata-evalN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) \cdot h + 1\right) \]
      9. lower-fma.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, \color{blue}{h}, 1\right) \]
    10. Applied rewrites60.1%

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

    if 6.0000000000000003e-115 < l

    1. Initial program 36.2%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot h\right) \cdot M\right) \cdot M}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right)} \]
    4. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot h\right) \cdot M\right) \cdot M}{\left(d \cdot d\right) \cdot \ell} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot h\right) \cdot M\right) \cdot M}{\left(d \cdot d\right) \cdot \ell} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot h\right) \cdot M\right) \cdot M}{\left(d \cdot d\right) \cdot \ell} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      4. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot h\right) \cdot M\right) \cdot M}{\left(d \cdot d\right) \cdot \ell} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      5. lift-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot h\right) \cdot M\right) \cdot M}{\left(d \cdot d\right) \cdot \ell} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot h\right) \cdot M\right) \cdot M}{\left(d \cdot d\right) \cdot \ell} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      7. lift-sqrt.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot h\right) \cdot M\right) \cdot M}{\left(d \cdot d\right) \cdot \ell} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      8. lift-sqrt.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot h\right) \cdot M\right) \cdot M}{\left(d \cdot d\right) \cdot \ell} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      9. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot h\right) \cdot M\right) \cdot \frac{M}{\left(d \cdot d\right) \cdot \ell}\right) \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      10. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\left(\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot h\right) \cdot M\right) \cdot \frac{M}{\left(d \cdot d\right) \cdot \ell}\right) \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    5. Applied rewrites27.8%

      \[\leadsto \mathsf{fma}\left(\left(\left(\left(\left(\frac{d}{\sqrt{\ell \cdot h}} \cdot h\right) \cdot M\right) \cdot \frac{M}{\left(d \cdot d\right) \cdot \ell}\right) \cdot -0.125\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Taylor expanded in h around inf

      \[\leadsto \mathsf{fma}\left(\left(\frac{{M}^{2}}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    7. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{{M}^{2}}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      2. pow2N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\ell \cdot \sqrt{\frac{\ell}{h}}\right) \cdot d} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      5. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\ell \cdot \sqrt{\frac{\ell}{h}}\right) \cdot d} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      7. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      8. lower-sqrt.f64N/A

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d} \cdot \frac{-1}{8}\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
      9. lower-/.f6436.9

        \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d} \cdot -0.125\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    8. Applied rewrites36.9%

      \[\leadsto \mathsf{fma}\left(\left(\frac{M \cdot M}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d} \cdot -0.125\right) \cdot D, D, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 70.0% accurate, 1.7× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{h \cdot \ell}\\ \mathbf{if}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-131}:\\ \;\;\;\;\frac{d\_m}{t\_0}\\ \mathbf{elif}\;M\_m \cdot D\_m \leq 2 \cdot 10^{+152}:\\ \;\;\;\;\frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{\left(d\_m \cdot d\_m\right) \cdot \ell} \cdot -0.125, h, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(D\_m \cdot \left(M\_m \cdot M\_m\right)\right) \cdot h\right) \cdot \frac{D\_m}{\left(\ell \cdot d\_m\right) \cdot t\_0}\right) \cdot -0.125\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* h l))))
   (if (<= (* M_m D_m) 2e-131)
     (/ d_m t_0)
     (if (<= (* M_m D_m) 2e+152)
       (*
        (/ (fabs d_m) (sqrt (* l h)))
        (fma
         (* (/ (* (* D_m M_m) (* D_m M_m)) (* (* d_m d_m) l)) -0.125)
         h
         1.0))
       (* (* (* (* D_m (* M_m M_m)) h) (/ D_m (* (* l d_m) t_0))) -0.125)))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((h * l));
	double tmp;
	if ((M_m * D_m) <= 2e-131) {
		tmp = d_m / t_0;
	} else if ((M_m * D_m) <= 2e+152) {
		tmp = (fabs(d_m) / sqrt((l * h))) * fma(((((D_m * M_m) * (D_m * M_m)) / ((d_m * d_m) * l)) * -0.125), h, 1.0);
	} else {
		tmp = (((D_m * (M_m * M_m)) * h) * (D_m / ((l * d_m) * t_0))) * -0.125;
	}
	return tmp;
}
d_m = abs(d)
M_m = abs(M)
D_m = abs(D)
d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m])
function code(d_m, h, l, M_m, D_m)
	t_0 = sqrt(Float64(h * l))
	tmp = 0.0
	if (Float64(M_m * D_m) <= 2e-131)
		tmp = Float64(d_m / t_0);
	elseif (Float64(M_m * D_m) <= 2e+152)
		tmp = Float64(Float64(abs(d_m) / sqrt(Float64(l * h))) * fma(Float64(Float64(Float64(Float64(D_m * M_m) * Float64(D_m * M_m)) / Float64(Float64(d_m * d_m) * l)) * -0.125), h, 1.0));
	else
		tmp = Float64(Float64(Float64(Float64(D_m * Float64(M_m * M_m)) * h) * Float64(D_m / Float64(Float64(l * d_m) * t_0))) * -0.125);
	end
	return tmp
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e-131], N[(d$95$m / t$95$0), $MachinePrecision], If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 2e+152], N[(N[(N[Abs[d$95$m], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(D$95$m * N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] * N[(D$95$m / N[(N[(l * d$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;M\_m \cdot D\_m \leq 2 \cdot 10^{-131}:\\
\;\;\;\;\frac{d\_m}{t\_0}\\

\mathbf{elif}\;M\_m \cdot D\_m \leq 2 \cdot 10^{+152}:\\
\;\;\;\;\frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left(\frac{\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{\left(d\_m \cdot d\_m\right) \cdot \ell} \cdot -0.125, h, 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 M D) < 2e-131

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

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

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    10. Step-by-step derivation
      1. sqrt-prodN/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      4. lift-*.f6443.0

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    11. Applied rewrites43.0%

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

    if 2e-131 < (*.f64 M D) < 2.0000000000000001e152

    1. Initial program 36.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \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. lift-/.f64N/A

        \[\leadsto \left({\color{blue}{\left(\frac{d}{h}\right)}}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-pow.f64N/A

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\color{blue}{\left(\frac{d}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      5. lift-pow.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      6. pow-prod-downN/A

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      7. lift-/.f64N/A

        \[\leadsto {\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      8. metadata-evalN/A

        \[\leadsto {\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\color{blue}{\frac{1}{2}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      9. pow1/2N/A

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      10. lower-sqrt.f64N/A

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

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

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      13. lower-/.f64N/A

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

        \[\leadsto \sqrt{\frac{\color{blue}{d \cdot d}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      15. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{\color{blue}{d \cdot d}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      16. lower-*.f6443.0

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

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot d}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    4. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{\frac{d \cdot d}{h \cdot \ell}}} \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. lift-*.f64N/A

        \[\leadsto \sqrt{\frac{d \cdot d}{\color{blue}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-/.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. lift-*.f64N/A

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      7. pow1/2N/A

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

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

        \[\leadsto \frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      10. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\sqrt{h} \cdot \sqrt{\ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      11. metadata-evalN/A

        \[\leadsto \frac{{\left({d}^{2}\right)}^{\color{blue}{\frac{1}{2}}}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      12. pow1/2N/A

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

        \[\leadsto \frac{\sqrt{\color{blue}{d \cdot d}}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      14. rem-sqrt-square-revN/A

        \[\leadsto \frac{\color{blue}{\left|d\right|}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      15. lower-fabs.f64N/A

        \[\leadsto \frac{\color{blue}{\left|d\right|}}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      16. sqrt-unprodN/A

        \[\leadsto \frac{\left|d\right|}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      17. lower-sqrt.f64N/A

        \[\leadsto \frac{\left|d\right|}{\color{blue}{\sqrt{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      18. *-commutativeN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\color{blue}{\ell \cdot h}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      19. lower-*.f6469.9

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

      \[\leadsto \color{blue}{\frac{\left|d\right|}{\sqrt{\ell \cdot h}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    6. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \color{blue}{{\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}}\right) \cdot \frac{h}{\ell}\right) \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{\color{blue}{M \cdot D}}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{\color{blue}{2 \cdot d}}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\color{blue}{\left(\frac{M \cdot D}{2 \cdot d}\right)}}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      5. unpow2N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)}\right) \cdot \frac{h}{\ell}\right) \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \color{blue}{\left(\frac{M \cdot D}{2 \cdot d} \cdot \frac{M \cdot D}{2 \cdot d}\right)}\right) \cdot \frac{h}{\ell}\right) \]
      7. associate-/l*N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      8. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)} \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      9. lower-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \color{blue}{\frac{D}{2 \cdot d}}\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      10. count-2-revN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{\color{blue}{d + d}}\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      11. lower-+.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{\color{blue}{d + d}}\right) \cdot \frac{M \cdot D}{2 \cdot d}\right)\right) \cdot \frac{h}{\ell}\right) \]
      12. associate-/l*N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}\right)\right) \cdot \frac{h}{\ell}\right) \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \color{blue}{\left(M \cdot \frac{D}{2 \cdot d}\right)}\right)\right) \cdot \frac{h}{\ell}\right) \]
      14. lower-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \color{blue}{\frac{D}{2 \cdot d}}\right)\right)\right) \cdot \frac{h}{\ell}\right) \]
      15. count-2-revN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(\left(M \cdot \frac{D}{d + d}\right) \cdot \left(M \cdot \frac{D}{\color{blue}{d + d}}\right)\right)\right) \cdot \frac{h}{\ell}\right) \]
      16. lower-+.f6469.1

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

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

      \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \color{blue}{\left(h \cdot \left(\frac{1}{h} - \frac{1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right)\right)} \]
    9. Step-by-step derivation
      1. fp-cancel-sub-sign-invN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(h \cdot \left(\frac{1}{h} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{8}\right)\right) \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}}\right)\right) \]
      2. metadata-evalN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(h \cdot \left(\frac{1}{h} + \frac{-1}{8} \cdot \frac{\color{blue}{{D}^{2} \cdot {M}^{2}}}{{d}^{2} \cdot \ell}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(h \cdot \left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell} + \color{blue}{\frac{1}{h}}\right)\right) \]
      4. distribute-rgt-inN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) \cdot h + \color{blue}{\frac{1}{h} \cdot h}\right) \]
      5. inv-powN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) \cdot h + {h}^{-1} \cdot h\right) \]
      6. pow-plusN/A

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

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) \cdot h + {h}^{0}\right) \]
      8. metadata-evalN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}\right) \cdot h + 1\right) \]
      9. lower-fma.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \mathsf{fma}\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, \color{blue}{h}, 1\right) \]
    10. Applied rewrites60.1%

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

    if 2.0000000000000001e152 < (*.f64 M D)

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

      \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \color{blue}{-0.125} \]
    9. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      6. lift-sqrt.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      7. associate-/l*N/A

        \[\leadsto \left(\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      8. lower-*.f64N/A

        \[\leadsto \left(\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      9. lift-*.f64N/A

        \[\leadsto \left(\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      10. *-commutativeN/A

        \[\leadsto \left(\left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      11. lift-*.f64N/A

        \[\leadsto \left(\left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      12. lift-*.f64N/A

        \[\leadsto \left(\left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      13. pow2N/A

        \[\leadsto \left(\left(D \cdot \left({M}^{2} \cdot h\right)\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      14. associate-*r*N/A

        \[\leadsto \left(\left(\left(D \cdot {M}^{2}\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      15. lower-*.f64N/A

        \[\leadsto \left(\left(\left(D \cdot {M}^{2}\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      16. lower-*.f64N/A

        \[\leadsto \left(\left(\left(D \cdot {M}^{2}\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      17. pow2N/A

        \[\leadsto \left(\left(\left(D \cdot \left(M \cdot M\right)\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      18. lift-*.f64N/A

        \[\leadsto \left(\left(\left(D \cdot \left(M \cdot M\right)\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      19. lower-/.f64N/A

        \[\leadsto \left(\left(\left(D \cdot \left(M \cdot M\right)\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      20. lift-*.f64N/A

        \[\leadsto \left(\left(\left(D \cdot \left(M \cdot M\right)\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      21. lift-sqrt.f64N/A

        \[\leadsto \left(\left(\left(D \cdot \left(M \cdot M\right)\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      22. lift-*.f64N/A

        \[\leadsto \left(\left(\left(D \cdot \left(M \cdot M\right)\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
    10. Applied rewrites33.0%

      \[\leadsto \left(\left(\left(D \cdot \left(M \cdot M\right)\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot -0.125 \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 61.7% accurate, 2.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{h \cdot \ell}\\ \mathbf{if}\;M\_m \cdot D\_m \leq 5 \cdot 10^{-61}:\\ \;\;\;\;\frac{d\_m}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)\right) \cdot h}{\left(\ell \cdot d\_m\right) \cdot t\_0} \cdot -0.125\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* h l))))
   (if (<= (* M_m D_m) 5e-61)
     (/ d_m t_0)
     (* (/ (* (* (* D_m M_m) (* D_m M_m)) h) (* (* l d_m) t_0)) -0.125))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((h * l));
	double tmp;
	if ((M_m * D_m) <= 5e-61) {
		tmp = d_m / t_0;
	} else {
		tmp = ((((D_m * M_m) * (D_m * M_m)) * h) / ((l * d_m) * t_0)) * -0.125;
	}
	return tmp;
}
d_m =     private
M_m =     private
D_m =     private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((h * l))
    if ((m_m * d_m_1) <= 5d-61) then
        tmp = d_m / t_0
    else
        tmp = ((((d_m_1 * m_m) * (d_m_1 * m_m)) * h) / ((l * d_m) * t_0)) * (-0.125d0)
    end if
    code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt((h * l));
	double tmp;
	if ((M_m * D_m) <= 5e-61) {
		tmp = d_m / t_0;
	} else {
		tmp = ((((D_m * M_m) * (D_m * M_m)) * h) / ((l * d_m) * t_0)) * -0.125;
	}
	return tmp;
}
d_m = math.fabs(d)
M_m = math.fabs(M)
D_m = math.fabs(D)
[d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m])
def code(d_m, h, l, M_m, D_m):
	t_0 = math.sqrt((h * l))
	tmp = 0
	if (M_m * D_m) <= 5e-61:
		tmp = d_m / t_0
	else:
		tmp = ((((D_m * M_m) * (D_m * M_m)) * h) / ((l * d_m) * t_0)) * -0.125
	return tmp
d_m = abs(d)
M_m = abs(M)
D_m = abs(D)
d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m])
function code(d_m, h, l, M_m, D_m)
	t_0 = sqrt(Float64(h * l))
	tmp = 0.0
	if (Float64(M_m * D_m) <= 5e-61)
		tmp = Float64(d_m / t_0);
	else
		tmp = Float64(Float64(Float64(Float64(Float64(D_m * M_m) * Float64(D_m * M_m)) * h) / Float64(Float64(l * d_m) * t_0)) * -0.125);
	end
	return tmp
end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
	t_0 = sqrt((h * l));
	tmp = 0.0;
	if ((M_m * D_m) <= 5e-61)
		tmp = d_m / t_0;
	else
		tmp = ((((D_m * M_m) * (D_m * M_m)) * h) / ((l * d_m) * t_0)) * -0.125;
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e-61], N[(d$95$m / t$95$0), $MachinePrecision], N[(N[(N[(N[(N[(D$95$m * M$95$m), $MachinePrecision] * N[(D$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / N[(N[(l * d$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;M\_m \cdot D\_m \leq 5 \cdot 10^{-61}:\\
\;\;\;\;\frac{d\_m}{t\_0}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M D) < 4.9999999999999999e-61

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

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

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    10. Step-by-step derivation
      1. sqrt-prodN/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      4. lift-*.f6443.0

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    11. Applied rewrites43.0%

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

    if 4.9999999999999999e-61 < (*.f64 M D)

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

      \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \color{blue}{-0.125} \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      3. associate-*l*N/A

        \[\leadsto \frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      4. pow2N/A

        \[\leadsto \frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot {D}^{2}}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot {D}^{2}}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot {D}^{2}}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      7. pow2N/A

        \[\leadsto \frac{\left({M}^{2} \cdot h\right) \cdot {D}^{2}}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      8. *-commutativeN/A

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      9. associate-*r*N/A

        \[\leadsto \frac{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      11. pow-prod-downN/A

        \[\leadsto \frac{{\left(D \cdot M\right)}^{2} \cdot h}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      12. unpow2N/A

        \[\leadsto \frac{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      14. lower-*.f64N/A

        \[\leadsto \frac{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      15. lower-*.f6438.0

        \[\leadsto \frac{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot -0.125 \]
    10. Applied rewrites38.0%

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

Alternative 6: 60.8% accurate, 2.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{h \cdot \ell}\\ \mathbf{if}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+67}:\\ \;\;\;\;\frac{d\_m}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(D\_m \cdot \left(M\_m \cdot M\_m\right)\right) \cdot h\right) \cdot \frac{D\_m}{\left(\ell \cdot d\_m\right) \cdot t\_0}\right) \cdot -0.125\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* h l))))
   (if (<= (* M_m D_m) 5e+67)
     (/ d_m t_0)
     (* (* (* (* D_m (* M_m M_m)) h) (/ D_m (* (* l d_m) t_0))) -0.125))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((h * l));
	double tmp;
	if ((M_m * D_m) <= 5e+67) {
		tmp = d_m / t_0;
	} else {
		tmp = (((D_m * (M_m * M_m)) * h) * (D_m / ((l * d_m) * t_0))) * -0.125;
	}
	return tmp;
}
d_m =     private
M_m =     private
D_m =     private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((h * l))
    if ((m_m * d_m_1) <= 5d+67) then
        tmp = d_m / t_0
    else
        tmp = (((d_m_1 * (m_m * m_m)) * h) * (d_m_1 / ((l * d_m) * t_0))) * (-0.125d0)
    end if
    code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt((h * l));
	double tmp;
	if ((M_m * D_m) <= 5e+67) {
		tmp = d_m / t_0;
	} else {
		tmp = (((D_m * (M_m * M_m)) * h) * (D_m / ((l * d_m) * t_0))) * -0.125;
	}
	return tmp;
}
d_m = math.fabs(d)
M_m = math.fabs(M)
D_m = math.fabs(D)
[d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m])
def code(d_m, h, l, M_m, D_m):
	t_0 = math.sqrt((h * l))
	tmp = 0
	if (M_m * D_m) <= 5e+67:
		tmp = d_m / t_0
	else:
		tmp = (((D_m * (M_m * M_m)) * h) * (D_m / ((l * d_m) * t_0))) * -0.125
	return tmp
d_m = abs(d)
M_m = abs(M)
D_m = abs(D)
d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m])
function code(d_m, h, l, M_m, D_m)
	t_0 = sqrt(Float64(h * l))
	tmp = 0.0
	if (Float64(M_m * D_m) <= 5e+67)
		tmp = Float64(d_m / t_0);
	else
		tmp = Float64(Float64(Float64(Float64(D_m * Float64(M_m * M_m)) * h) * Float64(D_m / Float64(Float64(l * d_m) * t_0))) * -0.125);
	end
	return tmp
end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
	t_0 = sqrt((h * l));
	tmp = 0.0;
	if ((M_m * D_m) <= 5e+67)
		tmp = d_m / t_0;
	else
		tmp = (((D_m * (M_m * M_m)) * h) * (D_m / ((l * d_m) * t_0))) * -0.125;
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 5e+67], N[(d$95$m / t$95$0), $MachinePrecision], N[(N[(N[(N[(D$95$m * N[(M$95$m * M$95$m), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] * N[(D$95$m / N[(N[(l * d$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;M\_m \cdot D\_m \leq 5 \cdot 10^{+67}:\\
\;\;\;\;\frac{d\_m}{t\_0}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M D) < 4.99999999999999976e67

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

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

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    10. Step-by-step derivation
      1. sqrt-prodN/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      4. lift-*.f6443.0

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    11. Applied rewrites43.0%

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

    if 4.99999999999999976e67 < (*.f64 M D)

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

      \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \color{blue}{-0.125} \]
    9. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      6. lift-sqrt.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      7. associate-/l*N/A

        \[\leadsto \left(\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      8. lower-*.f64N/A

        \[\leadsto \left(\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      9. lift-*.f64N/A

        \[\leadsto \left(\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      10. *-commutativeN/A

        \[\leadsto \left(\left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      11. lift-*.f64N/A

        \[\leadsto \left(\left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      12. lift-*.f64N/A

        \[\leadsto \left(\left(D \cdot \left(\left(M \cdot M\right) \cdot h\right)\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      13. pow2N/A

        \[\leadsto \left(\left(D \cdot \left({M}^{2} \cdot h\right)\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      14. associate-*r*N/A

        \[\leadsto \left(\left(\left(D \cdot {M}^{2}\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      15. lower-*.f64N/A

        \[\leadsto \left(\left(\left(D \cdot {M}^{2}\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      16. lower-*.f64N/A

        \[\leadsto \left(\left(\left(D \cdot {M}^{2}\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      17. pow2N/A

        \[\leadsto \left(\left(\left(D \cdot \left(M \cdot M\right)\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      18. lift-*.f64N/A

        \[\leadsto \left(\left(\left(D \cdot \left(M \cdot M\right)\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      19. lower-/.f64N/A

        \[\leadsto \left(\left(\left(D \cdot \left(M \cdot M\right)\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      20. lift-*.f64N/A

        \[\leadsto \left(\left(\left(D \cdot \left(M \cdot M\right)\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      21. lift-sqrt.f64N/A

        \[\leadsto \left(\left(\left(D \cdot \left(M \cdot M\right)\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
      22. lift-*.f64N/A

        \[\leadsto \left(\left(\left(D \cdot \left(M \cdot M\right)\right) \cdot h\right) \cdot \frac{D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}}\right) \cdot \frac{-1}{8} \]
    10. Applied rewrites33.0%

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

Alternative 7: 58.9% accurate, 2.8× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \sqrt{h \cdot \ell}\\ \mathbf{if}\;M\_m \leq 1.5 \cdot 10^{-89}:\\ \;\;\;\;\frac{d\_m}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(D\_m \cdot D\_m\right) \cdot \frac{\left(M\_m \cdot M\_m\right) \cdot h}{\left(\ell \cdot d\_m\right) \cdot t\_0}\right) \cdot -0.125\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
 :precision binary64
 (let* ((t_0 (sqrt (* h l))))
   (if (<= M_m 1.5e-89)
     (/ d_m t_0)
     (* (* (* D_m D_m) (/ (* (* M_m M_m) h) (* (* l d_m) t_0))) -0.125))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
	double t_0 = sqrt((h * l));
	double tmp;
	if (M_m <= 1.5e-89) {
		tmp = d_m / t_0;
	} else {
		tmp = ((D_m * D_m) * (((M_m * M_m) * h) / ((l * d_m) * t_0))) * -0.125;
	}
	return tmp;
}
d_m =     private
M_m =     private
D_m =     private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m_1
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((h * l))
    if (m_m <= 1.5d-89) then
        tmp = d_m / t_0
    else
        tmp = ((d_m_1 * d_m_1) * (((m_m * m_m) * h) / ((l * d_m) * t_0))) * (-0.125d0)
    end if
    code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
	double t_0 = Math.sqrt((h * l));
	double tmp;
	if (M_m <= 1.5e-89) {
		tmp = d_m / t_0;
	} else {
		tmp = ((D_m * D_m) * (((M_m * M_m) * h) / ((l * d_m) * t_0))) * -0.125;
	}
	return tmp;
}
d_m = math.fabs(d)
M_m = math.fabs(M)
D_m = math.fabs(D)
[d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m])
def code(d_m, h, l, M_m, D_m):
	t_0 = math.sqrt((h * l))
	tmp = 0
	if M_m <= 1.5e-89:
		tmp = d_m / t_0
	else:
		tmp = ((D_m * D_m) * (((M_m * M_m) * h) / ((l * d_m) * t_0))) * -0.125
	return tmp
d_m = abs(d)
M_m = abs(M)
D_m = abs(D)
d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m])
function code(d_m, h, l, M_m, D_m)
	t_0 = sqrt(Float64(h * l))
	tmp = 0.0
	if (M_m <= 1.5e-89)
		tmp = Float64(d_m / t_0);
	else
		tmp = Float64(Float64(Float64(D_m * D_m) * Float64(Float64(Float64(M_m * M_m) * h) / Float64(Float64(l * d_m) * t_0))) * -0.125);
	end
	return tmp
end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
	t_0 = sqrt((h * l));
	tmp = 0.0;
	if (M_m <= 1.5e-89)
		tmp = d_m / t_0;
	else
		tmp = ((D_m * D_m) * (((M_m * M_m) * h) / ((l * d_m) * t_0))) * -0.125;
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M$95$m, 1.5e-89], N[(d$95$m / t$95$0), $MachinePrecision], N[(N[(N[(D$95$m * D$95$m), $MachinePrecision] * N[(N[(N[(M$95$m * M$95$m), $MachinePrecision] * h), $MachinePrecision] / N[(N[(l * d$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
t_0 := \sqrt{h \cdot \ell}\\
\mathbf{if}\;M\_m \leq 1.5 \cdot 10^{-89}:\\
\;\;\;\;\frac{d\_m}{t\_0}\\

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


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

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

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

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    10. Step-by-step derivation
      1. sqrt-prodN/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      4. lift-*.f6443.0

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    11. Applied rewrites43.0%

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

    if 1.5e-89 < M

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

      \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \color{blue}{-0.125} \]
    9. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      6. lift-sqrt.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(\left(M \cdot M\right) \cdot h\right) \cdot D\right) \cdot D}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      8. associate-*l*N/A

        \[\leadsto \frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      9. pow2N/A

        \[\leadsto \frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot {D}^{2}}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot {D}^{2}}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      11. lift-*.f64N/A

        \[\leadsto \frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot {D}^{2}}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      12. pow2N/A

        \[\leadsto \frac{\left({M}^{2} \cdot h\right) \cdot {D}^{2}}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      13. *-commutativeN/A

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      14. *-commutativeN/A

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{\left(d \cdot \ell\right) \cdot \sqrt{h \cdot \ell}} \cdot \frac{-1}{8} \]
      15. associate-*r*N/A

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \sqrt{h \cdot \ell}\right)} \cdot \frac{-1}{8} \]
      16. associate-/l*N/A

        \[\leadsto \left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{d \cdot \left(\ell \cdot \sqrt{h \cdot \ell}\right)}\right) \cdot \frac{-1}{8} \]
      17. lower-*.f64N/A

        \[\leadsto \left({D}^{2} \cdot \frac{{M}^{2} \cdot h}{d \cdot \left(\ell \cdot \sqrt{h \cdot \ell}\right)}\right) \cdot \frac{-1}{8} \]
    10. Applied rewrites30.3%

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

Alternative 8: 58.8% accurate, 0.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{+77}:\\ \;\;\;\;\frac{\left(D\_m \cdot M\_m\right) \cdot \left(D\_m \cdot M\_m\right)}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d\_m} \cdot -0.125\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+221}:\\ \;\;\;\;\frac{\left|d\_m\right|}{\sqrt{\ell} \cdot \sqrt{h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
 :precision binary64
 (let* ((t_0
         (*
          (* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
          (-
           1.0
           (*
            (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))
            (/ h l))))))
   (if (<= t_0 -5e+77)
     (* (/ (* (* D_m M_m) (* D_m M_m)) (* (* (sqrt (/ l h)) l) d_m)) -0.125)
     (if (<= t_0 2e+221)
       (/ (fabs d_m) (* (sqrt l) (sqrt h)))
       (/ d_m (sqrt (* h l)))))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
	double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
	double tmp;
	if (t_0 <= -5e+77) {
		tmp = (((D_m * M_m) * (D_m * M_m)) / ((sqrt((l / h)) * l) * d_m)) * -0.125;
	} else if (t_0 <= 2e+221) {
		tmp = fabs(d_m) / (sqrt(l) * sqrt(h));
	} else {
		tmp = d_m / sqrt((h * l));
	}
	return tmp;
}
d_m =     private
M_m =     private
D_m =     private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+221}:\\
\;\;\;\;\frac{\left|d\_m\right|}{\sqrt{\ell} \cdot \sqrt{h}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.00000000000000004e77

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

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

      \[\leadsto \frac{{D}^{2} \cdot {M}^{2}}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
    10. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{{D}^{2} \cdot {M}^{2}}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      2. pow-prod-downN/A

        \[\leadsto \frac{{\left(D \cdot M\right)}^{2}}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      3. unpow2N/A

        \[\leadsto \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      7. *-commutativeN/A

        \[\leadsto \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\left(\ell \cdot \sqrt{\frac{\ell}{h}}\right) \cdot d} \cdot \frac{-1}{8} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\left(\ell \cdot \sqrt{\frac{\ell}{h}}\right) \cdot d} \cdot \frac{-1}{8} \]
      9. *-commutativeN/A

        \[\leadsto \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d} \cdot \frac{-1}{8} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d} \cdot \frac{-1}{8} \]
      11. lower-sqrt.f64N/A

        \[\leadsto \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d} \cdot \frac{-1}{8} \]
      12. lower-/.f6422.9

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

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

    if -5.00000000000000004e77 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.0000000000000001e221

    1. Initial program 36.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \left({\color{blue}{\left(\frac{d}{h}\right)}}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \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. lift-pow.f64N/A

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-/.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. metadata-evalN/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\color{blue}{\frac{1}{2}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      5. pow1/2N/A

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

        \[\leadsto \left(\sqrt{\color{blue}{\frac{\mathsf{neg}\left(d\right)}{\mathsf{neg}\left(h\right)}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      7. sqrt-divN/A

        \[\leadsto \left(\color{blue}{\frac{\sqrt{\mathsf{neg}\left(d\right)}}{\sqrt{\mathsf{neg}\left(h\right)}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      8. lower-/.f64N/A

        \[\leadsto \left(\color{blue}{\frac{\sqrt{\mathsf{neg}\left(d\right)}}{\sqrt{\mathsf{neg}\left(h\right)}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      9. lower-sqrt.f64N/A

        \[\leadsto \left(\frac{\color{blue}{\sqrt{\mathsf{neg}\left(d\right)}}}{\sqrt{\mathsf{neg}\left(h\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      10. lower-neg.f64N/A

        \[\leadsto \left(\frac{\sqrt{\color{blue}{-d}}}{\sqrt{\mathsf{neg}\left(h\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      11. lower-sqrt.f64N/A

        \[\leadsto \left(\frac{\sqrt{-d}}{\color{blue}{\sqrt{\mathsf{neg}\left(h\right)}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      12. lower-neg.f640.0

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{neg}\left(d\right)} \cdot \sqrt{\frac{d}{\ell}}}{\sqrt{-1 \cdot h}}} \]
    5. Applied rewrites43.0%

      \[\leadsto \color{blue}{\frac{\left|d\right|}{\sqrt{\ell \cdot h}}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      2. lift-sqrt.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      3. sqrt-prodN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell} \cdot \color{blue}{\sqrt{h}}} \]
      4. lift-sqrt.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. lift-*.f6425.3

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell} \cdot \color{blue}{\sqrt{h}}} \]
    7. Applied rewrites25.3%

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

    if 2.0000000000000001e221 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l))))

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

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

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    10. Step-by-step derivation
      1. sqrt-prodN/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      4. lift-*.f6443.0

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    11. Applied rewrites43.0%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 9: 56.8% accurate, 0.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{+77}:\\ \;\;\;\;\frac{\left(M\_m \cdot M\_m\right) \cdot \left(D\_m \cdot D\_m\right)}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d\_m} \cdot -0.125\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+221}:\\ \;\;\;\;\frac{\left|d\_m\right|}{\sqrt{\ell} \cdot \sqrt{h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
 :precision binary64
 (let* ((t_0
         (*
          (* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
          (-
           1.0
           (*
            (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))
            (/ h l))))))
   (if (<= t_0 -5e+77)
     (* (/ (* (* M_m M_m) (* D_m D_m)) (* (* (sqrt (/ l h)) l) d_m)) -0.125)
     (if (<= t_0 2e+221)
       (/ (fabs d_m) (* (sqrt l) (sqrt h)))
       (/ d_m (sqrt (* h l)))))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
	double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
	double tmp;
	if (t_0 <= -5e+77) {
		tmp = (((M_m * M_m) * (D_m * D_m)) / ((sqrt((l / h)) * l) * d_m)) * -0.125;
	} else if (t_0 <= 2e+221) {
		tmp = fabs(d_m) / (sqrt(l) * sqrt(h));
	} else {
		tmp = d_m / sqrt((h * l));
	}
	return tmp;
}
d_m =     private
M_m =     private
D_m =     private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+221}:\\
\;\;\;\;\frac{\left|d\_m\right|}{\sqrt{\ell} \cdot \sqrt{h}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.00000000000000004e77

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

      \[\leadsto \mathsf{fma}\left(\frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(\sqrt{\ell \cdot h} \cdot \ell\right) \cdot d}, \color{blue}{-0.125}, \frac{d}{\sqrt{\ell \cdot h}}\right) \]
    7. Taylor expanded in h around inf

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

        \[\leadsto \frac{{D}^{2} \cdot {M}^{2}}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{{D}^{2} \cdot {M}^{2}}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{{D}^{2} \cdot {M}^{2}}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      4. *-commutativeN/A

        \[\leadsto \frac{{M}^{2} \cdot {D}^{2}}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{{M}^{2} \cdot {D}^{2}}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      6. pow2N/A

        \[\leadsto \frac{\left(M \cdot M\right) \cdot {D}^{2}}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\left(M \cdot M\right) \cdot {D}^{2}}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      8. pow2N/A

        \[\leadsto \frac{\left(M \cdot M\right) \cdot \left(D \cdot D\right)}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      9. lift-*.f64N/A

        \[\leadsto \frac{\left(M \cdot M\right) \cdot \left(D \cdot D\right)}{d \cdot \left(\ell \cdot \sqrt{\frac{\ell}{h}}\right)} \cdot \frac{-1}{8} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\left(M \cdot M\right) \cdot \left(D \cdot D\right)}{\left(\ell \cdot \sqrt{\frac{\ell}{h}}\right) \cdot d} \cdot \frac{-1}{8} \]
      11. lower-*.f64N/A

        \[\leadsto \frac{\left(M \cdot M\right) \cdot \left(D \cdot D\right)}{\left(\ell \cdot \sqrt{\frac{\ell}{h}}\right) \cdot d} \cdot \frac{-1}{8} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\left(M \cdot M\right) \cdot \left(D \cdot D\right)}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d} \cdot \frac{-1}{8} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\left(M \cdot M\right) \cdot \left(D \cdot D\right)}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d} \cdot \frac{-1}{8} \]
      14. lower-sqrt.f64N/A

        \[\leadsto \frac{\left(M \cdot M\right) \cdot \left(D \cdot D\right)}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d} \cdot \frac{-1}{8} \]
      15. lower-/.f6418.7

        \[\leadsto \frac{\left(M \cdot M\right) \cdot \left(D \cdot D\right)}{\left(\sqrt{\frac{\ell}{h}} \cdot \ell\right) \cdot d} \cdot -0.125 \]
    9. Applied rewrites18.7%

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

    if -5.00000000000000004e77 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.0000000000000001e221

    1. Initial program 36.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \left({\color{blue}{\left(\frac{d}{h}\right)}}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \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. lift-pow.f64N/A

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-/.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. metadata-evalN/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\color{blue}{\frac{1}{2}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      5. pow1/2N/A

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

        \[\leadsto \left(\sqrt{\color{blue}{\frac{\mathsf{neg}\left(d\right)}{\mathsf{neg}\left(h\right)}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      7. sqrt-divN/A

        \[\leadsto \left(\color{blue}{\frac{\sqrt{\mathsf{neg}\left(d\right)}}{\sqrt{\mathsf{neg}\left(h\right)}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      8. lower-/.f64N/A

        \[\leadsto \left(\color{blue}{\frac{\sqrt{\mathsf{neg}\left(d\right)}}{\sqrt{\mathsf{neg}\left(h\right)}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      9. lower-sqrt.f64N/A

        \[\leadsto \left(\frac{\color{blue}{\sqrt{\mathsf{neg}\left(d\right)}}}{\sqrt{\mathsf{neg}\left(h\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      10. lower-neg.f64N/A

        \[\leadsto \left(\frac{\sqrt{\color{blue}{-d}}}{\sqrt{\mathsf{neg}\left(h\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      11. lower-sqrt.f64N/A

        \[\leadsto \left(\frac{\sqrt{-d}}{\color{blue}{\sqrt{\mathsf{neg}\left(h\right)}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      12. lower-neg.f640.0

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{neg}\left(d\right)} \cdot \sqrt{\frac{d}{\ell}}}{\sqrt{-1 \cdot h}}} \]
    5. Applied rewrites43.0%

      \[\leadsto \color{blue}{\frac{\left|d\right|}{\sqrt{\ell \cdot h}}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      2. lift-sqrt.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      3. sqrt-prodN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell} \cdot \color{blue}{\sqrt{h}}} \]
      4. lift-sqrt.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. lift-*.f6425.3

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell} \cdot \color{blue}{\sqrt{h}}} \]
    7. Applied rewrites25.3%

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

    if 2.0000000000000001e221 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l))))

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

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

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    10. Step-by-step derivation
      1. sqrt-prodN/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      4. lift-*.f6443.0

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    11. Applied rewrites43.0%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 49.2% accurate, 4.6× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \cdot D\_m \leq 7.5 \cdot 10^{+176}:\\ \;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{\frac{d\_m}{\ell} \cdot \frac{d\_m}{h}}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
 :precision binary64
 (if (<= (* M_m D_m) 7.5e+176)
   (/ d_m (sqrt (* h l)))
   (- (sqrt (* (/ d_m l) (/ d_m h))))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
	double tmp;
	if ((M_m * D_m) <= 7.5e+176) {
		tmp = d_m / sqrt((h * l));
	} else {
		tmp = -sqrt(((d_m / l) * (d_m / h)));
	}
	return tmp;
}
d_m =     private
M_m =     private
D_m =     private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m_1
    real(8) :: tmp
    if ((m_m * d_m_1) <= 7.5d+176) then
        tmp = d_m / sqrt((h * l))
    else
        tmp = -sqrt(((d_m / l) * (d_m / h)))
    end if
    code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
	double tmp;
	if ((M_m * D_m) <= 7.5e+176) {
		tmp = d_m / Math.sqrt((h * l));
	} else {
		tmp = -Math.sqrt(((d_m / l) * (d_m / h)));
	}
	return tmp;
}
d_m = math.fabs(d)
M_m = math.fabs(M)
D_m = math.fabs(D)
[d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m])
def code(d_m, h, l, M_m, D_m):
	tmp = 0
	if (M_m * D_m) <= 7.5e+176:
		tmp = d_m / math.sqrt((h * l))
	else:
		tmp = -math.sqrt(((d_m / l) * (d_m / h)))
	return tmp
d_m = abs(d)
M_m = abs(M)
D_m = abs(D)
d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m])
function code(d_m, h, l, M_m, D_m)
	tmp = 0.0
	if (Float64(M_m * D_m) <= 7.5e+176)
		tmp = Float64(d_m / sqrt(Float64(h * l)));
	else
		tmp = Float64(-sqrt(Float64(Float64(d_m / l) * Float64(d_m / h))));
	end
	return tmp
end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
	tmp = 0.0;
	if ((M_m * D_m) <= 7.5e+176)
		tmp = d_m / sqrt((h * l));
	else
		tmp = -sqrt(((d_m / l) * (d_m / h)));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 7.5e+176], N[(d$95$m / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[(N[(d$95$m / l), $MachinePrecision] * N[(d$95$m / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 7.5 \cdot 10^{+176}:\\
\;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M D) < 7.499999999999999e176

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

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

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    10. Step-by-step derivation
      1. sqrt-prodN/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      4. lift-*.f6443.0

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    11. Applied rewrites43.0%

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

    if 7.499999999999999e176 < (*.f64 M D)

    1. Initial program 36.2%

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

      \[\leadsto \color{blue}{\frac{\sqrt{d \cdot h} \cdot \sqrt{\frac{d}{\ell}}}{h}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sqrt{d \cdot h} \cdot \sqrt{\frac{d}{\ell}}}{\color{blue}{h}} \]
      2. sqrt-unprodN/A

        \[\leadsto \frac{\sqrt{\left(d \cdot h\right) \cdot \frac{d}{\ell}}}{h} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{\left(d \cdot h\right) \cdot \frac{d}{\ell}}}{h} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\sqrt{\left(d \cdot h\right) \cdot \frac{d}{\ell}}}{h} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h} \]
      7. lift-/.f6421.7

        \[\leadsto \frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h} \]
    4. Applied rewrites21.7%

      \[\leadsto \color{blue}{\frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h}} \]
    5. Taylor expanded in h around -inf

      \[\leadsto -1 \cdot \color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}} \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right) \]
      2. pow2N/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d \cdot d}{h \cdot \ell}}\right) \]
      3. times-fracN/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right) \]
      5. sqrt-unprodN/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      6. lift-/.f64N/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      7. lower-neg.f64N/A

        \[\leadsto -\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}} \]
      8. lift-/.f64N/A

        \[\leadsto -\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}} \]
      9. sqrt-unprodN/A

        \[\leadsto -\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \]
      10. lift-/.f64N/A

        \[\leadsto -\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \]
      11. times-fracN/A

        \[\leadsto -\sqrt{\frac{d \cdot d}{h \cdot \ell}} \]
      12. pow2N/A

        \[\leadsto -\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
      13. sqrt-divN/A

        \[\leadsto -\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}} \]
      14. pow1/2N/A

        \[\leadsto -\frac{{\left({d}^{2}\right)}^{\frac{1}{2}}}{\sqrt{h \cdot \ell}} \]
      15. metadata-evalN/A

        \[\leadsto -\frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\sqrt{h \cdot \ell}} \]
      16. sqrt-unprodN/A

        \[\leadsto -\frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Applied rewrites9.7%

      \[\leadsto -\frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
    8. Step-by-step derivation
      1. lift-fabs.f64N/A

        \[\leadsto -\frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      2. lift-/.f64N/A

        \[\leadsto -\frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      3. rem-sqrt-square-revN/A

        \[\leadsto -\frac{\sqrt{d \cdot d}}{\sqrt{\ell \cdot h}} \]
      4. sqrt-prodN/A

        \[\leadsto -\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell \cdot h}} \]
      5. lift-*.f64N/A

        \[\leadsto -\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell \cdot h}} \]
      6. lift-sqrt.f64N/A

        \[\leadsto -\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell \cdot h}} \]
      7. sqrt-prodN/A

        \[\leadsto -\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}} \]
      8. frac-timesN/A

        \[\leadsto -\frac{\sqrt{d}}{\sqrt{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}} \]
      9. sqrt-divN/A

        \[\leadsto -\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{d}}{\sqrt{h}} \]
      10. sqrt-divN/A

        \[\leadsto -\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}} \]
      11. sqrt-unprodN/A

        \[\leadsto -\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
      12. lower-sqrt.f64N/A

        \[\leadsto -\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
      13. lower-*.f64N/A

        \[\leadsto -\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
      14. lower-/.f64N/A

        \[\leadsto -\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
      15. lower-/.f6411.6

        \[\leadsto -\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
    9. Applied rewrites11.6%

      \[\leadsto -\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 47.0% accurate, 4.7× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;M\_m \cdot D\_m \leq 7.5 \cdot 10^{+176}:\\ \;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;-\sqrt{\frac{d\_m \cdot d\_m}{h \cdot \ell}}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
 :precision binary64
 (if (<= (* M_m D_m) 7.5e+176)
   (/ d_m (sqrt (* h l)))
   (- (sqrt (/ (* d_m d_m) (* h l))))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
	double tmp;
	if ((M_m * D_m) <= 7.5e+176) {
		tmp = d_m / sqrt((h * l));
	} else {
		tmp = -sqrt(((d_m * d_m) / (h * l)));
	}
	return tmp;
}
d_m =     private
M_m =     private
D_m =     private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m_1
    real(8) :: tmp
    if ((m_m * d_m_1) <= 7.5d+176) then
        tmp = d_m / sqrt((h * l))
    else
        tmp = -sqrt(((d_m * d_m) / (h * l)))
    end if
    code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
	double tmp;
	if ((M_m * D_m) <= 7.5e+176) {
		tmp = d_m / Math.sqrt((h * l));
	} else {
		tmp = -Math.sqrt(((d_m * d_m) / (h * l)));
	}
	return tmp;
}
d_m = math.fabs(d)
M_m = math.fabs(M)
D_m = math.fabs(D)
[d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m])
def code(d_m, h, l, M_m, D_m):
	tmp = 0
	if (M_m * D_m) <= 7.5e+176:
		tmp = d_m / math.sqrt((h * l))
	else:
		tmp = -math.sqrt(((d_m * d_m) / (h * l)))
	return tmp
d_m = abs(d)
M_m = abs(M)
D_m = abs(D)
d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m])
function code(d_m, h, l, M_m, D_m)
	tmp = 0.0
	if (Float64(M_m * D_m) <= 7.5e+176)
		tmp = Float64(d_m / sqrt(Float64(h * l)));
	else
		tmp = Float64(-sqrt(Float64(Float64(d_m * d_m) / Float64(h * l))));
	end
	return tmp
end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp_2 = code(d_m, h, l, M_m, D_m)
	tmp = 0.0;
	if ((M_m * D_m) <= 7.5e+176)
		tmp = d_m / sqrt((h * l));
	else
		tmp = -sqrt(((d_m * d_m) / (h * l)));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 7.5e+176], N[(d$95$m / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[(N[(d$95$m * d$95$m), $MachinePrecision] / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 7.5 \cdot 10^{+176}:\\
\;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M D) < 7.499999999999999e176

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

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

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    10. Step-by-step derivation
      1. sqrt-prodN/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      4. lift-*.f6443.0

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    11. Applied rewrites43.0%

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

    if 7.499999999999999e176 < (*.f64 M D)

    1. Initial program 36.2%

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

      \[\leadsto \color{blue}{\frac{\sqrt{d \cdot h} \cdot \sqrt{\frac{d}{\ell}}}{h}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sqrt{d \cdot h} \cdot \sqrt{\frac{d}{\ell}}}{\color{blue}{h}} \]
      2. sqrt-unprodN/A

        \[\leadsto \frac{\sqrt{\left(d \cdot h\right) \cdot \frac{d}{\ell}}}{h} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{\left(d \cdot h\right) \cdot \frac{d}{\ell}}}{h} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\sqrt{\left(d \cdot h\right) \cdot \frac{d}{\ell}}}{h} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h} \]
      7. lift-/.f6421.7

        \[\leadsto \frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h} \]
    4. Applied rewrites21.7%

      \[\leadsto \color{blue}{\frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h}} \]
    5. Taylor expanded in h around -inf

      \[\leadsto -1 \cdot \color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}} \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right) \]
      2. pow2N/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d \cdot d}{h \cdot \ell}}\right) \]
      3. times-fracN/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right) \]
      5. sqrt-unprodN/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      6. lift-/.f64N/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      7. lower-neg.f64N/A

        \[\leadsto -\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}} \]
      8. lift-/.f64N/A

        \[\leadsto -\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}} \]
      9. sqrt-unprodN/A

        \[\leadsto -\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \]
      10. lift-/.f64N/A

        \[\leadsto -\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \]
      11. times-fracN/A

        \[\leadsto -\sqrt{\frac{d \cdot d}{h \cdot \ell}} \]
      12. pow2N/A

        \[\leadsto -\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
      13. sqrt-divN/A

        \[\leadsto -\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}} \]
      14. pow1/2N/A

        \[\leadsto -\frac{{\left({d}^{2}\right)}^{\frac{1}{2}}}{\sqrt{h \cdot \ell}} \]
      15. metadata-evalN/A

        \[\leadsto -\frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\sqrt{h \cdot \ell}} \]
      16. sqrt-unprodN/A

        \[\leadsto -\frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Applied rewrites9.7%

      \[\leadsto -\frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
    8. Step-by-step derivation
      1. lift-fabs.f64N/A

        \[\leadsto -\frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      2. lift-/.f64N/A

        \[\leadsto -\frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      3. lift-*.f64N/A

        \[\leadsto -\frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      4. lift-sqrt.f64N/A

        \[\leadsto -\frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      5. rem-sqrt-square-revN/A

        \[\leadsto -\frac{\sqrt{d \cdot d}}{\sqrt{\ell \cdot h}} \]
      6. pow2N/A

        \[\leadsto -\frac{\sqrt{{d}^{2}}}{\sqrt{\ell \cdot h}} \]
      7. *-commutativeN/A

        \[\leadsto -\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}} \]
      8. sqrt-divN/A

        \[\leadsto -\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
      9. lower-sqrt.f64N/A

        \[\leadsto -\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
      10. lower-/.f64N/A

        \[\leadsto -\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
      11. pow2N/A

        \[\leadsto -\sqrt{\frac{d \cdot d}{h \cdot \ell}} \]
      12. lower-*.f64N/A

        \[\leadsto -\sqrt{\frac{d \cdot d}{h \cdot \ell}} \]
      13. lift-*.f6412.2

        \[\leadsto -\sqrt{\frac{d \cdot d}{h \cdot \ell}} \]
    9. Applied rewrites12.2%

      \[\leadsto -\sqrt{\frac{d \cdot d}{h \cdot \ell}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 46.5% accurate, 0.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\ \\ \begin{array}{l} t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{+77}:\\ \;\;\;\;-\frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+221}:\\ \;\;\;\;\frac{\left|d\_m\right|}{\sqrt{\ell} \cdot \sqrt{h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
 :precision binary64
 (let* ((t_0
         (*
          (* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
          (-
           1.0
           (*
            (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0))
            (/ h l))))))
   (if (<= t_0 -5e+77)
     (- (/ (fabs d_m) (sqrt (* l h))))
     (if (<= t_0 2e+221)
       (/ (fabs d_m) (* (sqrt l) (sqrt h)))
       (/ d_m (sqrt (* h l)))))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
	double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
	double tmp;
	if (t_0 <= -5e+77) {
		tmp = -(fabs(d_m) / sqrt((l * h)));
	} else if (t_0 <= 2e+221) {
		tmp = fabs(d_m) / (sqrt(l) * sqrt(h));
	} else {
		tmp = d_m / sqrt((h * l));
	}
	return tmp;
}
d_m =     private
M_m =     private
D_m =     private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+221}:\\
\;\;\;\;\frac{\left|d\_m\right|}{\sqrt{\ell} \cdot \sqrt{h}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.00000000000000004e77

    1. Initial program 36.2%

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

      \[\leadsto \color{blue}{\frac{\sqrt{d \cdot h} \cdot \sqrt{\frac{d}{\ell}}}{h}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sqrt{d \cdot h} \cdot \sqrt{\frac{d}{\ell}}}{\color{blue}{h}} \]
      2. sqrt-unprodN/A

        \[\leadsto \frac{\sqrt{\left(d \cdot h\right) \cdot \frac{d}{\ell}}}{h} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{\left(d \cdot h\right) \cdot \frac{d}{\ell}}}{h} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\sqrt{\left(d \cdot h\right) \cdot \frac{d}{\ell}}}{h} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h} \]
      7. lift-/.f6421.7

        \[\leadsto \frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h} \]
    4. Applied rewrites21.7%

      \[\leadsto \color{blue}{\frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h}} \]
    5. Taylor expanded in h around -inf

      \[\leadsto -1 \cdot \color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}} \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right) \]
      2. pow2N/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d \cdot d}{h \cdot \ell}}\right) \]
      3. times-fracN/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right) \]
      5. sqrt-unprodN/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      6. lift-/.f64N/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      7. lower-neg.f64N/A

        \[\leadsto -\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}} \]
      8. lift-/.f64N/A

        \[\leadsto -\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}} \]
      9. sqrt-unprodN/A

        \[\leadsto -\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \]
      10. lift-/.f64N/A

        \[\leadsto -\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \]
      11. times-fracN/A

        \[\leadsto -\sqrt{\frac{d \cdot d}{h \cdot \ell}} \]
      12. pow2N/A

        \[\leadsto -\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
      13. sqrt-divN/A

        \[\leadsto -\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}} \]
      14. pow1/2N/A

        \[\leadsto -\frac{{\left({d}^{2}\right)}^{\frac{1}{2}}}{\sqrt{h \cdot \ell}} \]
      15. metadata-evalN/A

        \[\leadsto -\frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\sqrt{h \cdot \ell}} \]
      16. sqrt-unprodN/A

        \[\leadsto -\frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Applied rewrites9.7%

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

    if -5.00000000000000004e77 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.0000000000000001e221

    1. Initial program 36.2%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \left({\color{blue}{\left(\frac{d}{h}\right)}}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \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. lift-pow.f64N/A

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-/.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. metadata-evalN/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\color{blue}{\frac{1}{2}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      5. pow1/2N/A

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

        \[\leadsto \left(\sqrt{\color{blue}{\frac{\mathsf{neg}\left(d\right)}{\mathsf{neg}\left(h\right)}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      7. sqrt-divN/A

        \[\leadsto \left(\color{blue}{\frac{\sqrt{\mathsf{neg}\left(d\right)}}{\sqrt{\mathsf{neg}\left(h\right)}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      8. lower-/.f64N/A

        \[\leadsto \left(\color{blue}{\frac{\sqrt{\mathsf{neg}\left(d\right)}}{\sqrt{\mathsf{neg}\left(h\right)}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      9. lower-sqrt.f64N/A

        \[\leadsto \left(\frac{\color{blue}{\sqrt{\mathsf{neg}\left(d\right)}}}{\sqrt{\mathsf{neg}\left(h\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      10. lower-neg.f64N/A

        \[\leadsto \left(\frac{\sqrt{\color{blue}{-d}}}{\sqrt{\mathsf{neg}\left(h\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      11. lower-sqrt.f64N/A

        \[\leadsto \left(\frac{\sqrt{-d}}{\color{blue}{\sqrt{\mathsf{neg}\left(h\right)}}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      12. lower-neg.f640.0

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{neg}\left(d\right)} \cdot \sqrt{\frac{d}{\ell}}}{\sqrt{-1 \cdot h}}} \]
    5. Applied rewrites43.0%

      \[\leadsto \color{blue}{\frac{\left|d\right|}{\sqrt{\ell \cdot h}}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      2. lift-sqrt.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      3. sqrt-prodN/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell} \cdot \color{blue}{\sqrt{h}}} \]
      4. lift-sqrt.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      5. lift-sqrt.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell} \cdot \sqrt{h}} \]
      6. lift-*.f6425.3

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell} \cdot \color{blue}{\sqrt{h}}} \]
    7. Applied rewrites25.3%

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

    if 2.0000000000000001e221 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l))))

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

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

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    10. Step-by-step derivation
      1. sqrt-prodN/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      4. lift-*.f6443.0

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    11. Applied rewrites43.0%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 13: 46.5% accurate, 0.9× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\ \\ \begin{array}{l} \mathbf{if}\;\left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -5 \cdot 10^{+77}:\\ \;\;\;\;-\frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m)
 :precision binary64
 (if (<=
      (*
       (* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
       (-
        1.0
        (* (* (/ 1.0 2.0) (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0)) (/ h l))))
      -5e+77)
   (- (/ (fabs d_m) (sqrt (* l h))))
   (/ d_m (sqrt (* h l)))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
	double tmp;
	if (((pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)))) <= -5e+77) {
		tmp = -(fabs(d_m) / sqrt((l * h)));
	} else {
		tmp = d_m / sqrt((h * l));
	}
	return tmp;
}
d_m =     private
M_m =     private
D_m =     private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -5.00000000000000004e77

    1. Initial program 36.2%

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

      \[\leadsto \color{blue}{\frac{\sqrt{d \cdot h} \cdot \sqrt{\frac{d}{\ell}}}{h}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\sqrt{d \cdot h} \cdot \sqrt{\frac{d}{\ell}}}{\color{blue}{h}} \]
      2. sqrt-unprodN/A

        \[\leadsto \frac{\sqrt{\left(d \cdot h\right) \cdot \frac{d}{\ell}}}{h} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{\left(d \cdot h\right) \cdot \frac{d}{\ell}}}{h} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\sqrt{\left(d \cdot h\right) \cdot \frac{d}{\ell}}}{h} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h} \]
      7. lift-/.f6421.7

        \[\leadsto \frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h} \]
    4. Applied rewrites21.7%

      \[\leadsto \color{blue}{\frac{\sqrt{\left(h \cdot d\right) \cdot \frac{d}{\ell}}}{h}} \]
    5. Taylor expanded in h around -inf

      \[\leadsto -1 \cdot \color{blue}{\sqrt{\frac{{d}^{2}}{h \cdot \ell}}} \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{{d}^{2}}{h \cdot \ell}}\right) \]
      2. pow2N/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d \cdot d}{h \cdot \ell}}\right) \]
      3. times-fracN/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}\right) \]
      5. sqrt-unprodN/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      6. lift-/.f64N/A

        \[\leadsto \mathsf{neg}\left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right) \]
      7. lower-neg.f64N/A

        \[\leadsto -\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}} \]
      8. lift-/.f64N/A

        \[\leadsto -\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}} \]
      9. sqrt-unprodN/A

        \[\leadsto -\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \]
      10. lift-/.f64N/A

        \[\leadsto -\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}} \]
      11. times-fracN/A

        \[\leadsto -\sqrt{\frac{d \cdot d}{h \cdot \ell}} \]
      12. pow2N/A

        \[\leadsto -\sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
      13. sqrt-divN/A

        \[\leadsto -\frac{\sqrt{{d}^{2}}}{\sqrt{h \cdot \ell}} \]
      14. pow1/2N/A

        \[\leadsto -\frac{{\left({d}^{2}\right)}^{\frac{1}{2}}}{\sqrt{h \cdot \ell}} \]
      15. metadata-evalN/A

        \[\leadsto -\frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\sqrt{h \cdot \ell}} \]
      16. sqrt-unprodN/A

        \[\leadsto -\frac{{\left({d}^{2}\right)}^{\left(\frac{1}{2}\right)}}{\sqrt{h} \cdot \sqrt{\ell}} \]
    7. Applied rewrites9.7%

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

    if -5.00000000000000004e77 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l))))

    1. Initial program 36.2%

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

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

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

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

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

        \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      3. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
    6. Applied rewrites50.2%

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

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

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

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    10. Step-by-step derivation
      1. sqrt-prodN/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      4. lift-*.f6443.0

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    11. Applied rewrites43.0%

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

Alternative 14: 43.0% accurate, 10.2× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ M_m = \left|M\right| \\ D_m = \left|D\right| \\ [d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\ \\ \frac{d\_m}{\sqrt{h \cdot \ell}} \end{array} \]
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
(FPCore (d_m h l M_m D_m) :precision binary64 (/ d_m (sqrt (* h l))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
assert(d_m < h && h < l && l < M_m && M_m < D_m);
double code(double d_m, double h, double l, double M_m, double D_m) {
	return d_m / sqrt((h * l));
}
d_m =     private
M_m =     private
D_m =     private
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(d_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m_m
    real(8), intent (in) :: d_m_1
    code = d_m / sqrt((h * l))
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
assert d_m < h && h < l && l < M_m && M_m < D_m;
public static double code(double d_m, double h, double l, double M_m, double D_m) {
	return d_m / Math.sqrt((h * l));
}
d_m = math.fabs(d)
M_m = math.fabs(M)
D_m = math.fabs(D)
[d_m, h, l, M_m, D_m] = sort([d_m, h, l, M_m, D_m])
def code(d_m, h, l, M_m, D_m):
	return d_m / math.sqrt((h * l))
d_m = abs(d)
M_m = abs(M)
D_m = abs(D)
d_m, h, l, M_m, D_m = sort([d_m, h, l, M_m, D_m])
function code(d_m, h, l, M_m, D_m)
	return Float64(d_m / sqrt(Float64(h * l)))
end
d_m = abs(d);
M_m = abs(M);
D_m = abs(D);
d_m, h, l, M_m, D_m = num2cell(sort([d_m, h, l, M_m, D_m])){:}
function tmp = code(d_m, h, l, M_m, D_m)
	tmp = d_m / sqrt((h * l));
end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
NOTE: d_m, h, l, M_m, and D_m should be sorted in increasing order before calling this function.
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := N[(d$95$m / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
[d_m, h, l, M_m, D_m] = \mathsf{sort}([d_m, h, l, M_m, D_m])\\
\\
\frac{d\_m}{\sqrt{h \cdot \ell}}
\end{array}
Derivation
  1. Initial program 36.2%

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

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

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

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

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

      \[\leadsto \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)} \cdot \frac{-1}{8} + \frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \]
    3. lower-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\ell}\right)\right)}, \frac{-1}{8}, \frac{d}{\sqrt{\ell} \cdot \sqrt{h}}\right) \]
  6. Applied rewrites50.2%

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

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

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

    \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
  10. Step-by-step derivation
    1. sqrt-prodN/A

      \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    2. lower-/.f64N/A

      \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    3. lift-sqrt.f64N/A

      \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    4. lift-*.f6443.0

      \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
  11. Applied rewrites43.0%

    \[\leadsto \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
  12. Add Preprocessing

Reproduce

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