Henrywood and Agarwal, Equation (12)

Percentage Accurate: 66.2% → 74.7%
Time: 8.2s
Alternatives: 13
Speedup: 2.0×

Specification

?
\[\begin{array}{l} \\ \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (*
  (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
  (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
	return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
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 13 alternatives:

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

Initial Program: 66.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (*
  (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
  (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
	return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
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: 74.7% accurate, 1.2× speedup?

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

\mathbf{elif}\;d \leq -2.35 \cdot 10^{-187}:\\
\;\;\;\;\left({\left(h \cdot \ell\right)}^{-0.5} \cdot \left(-d\right)\right) \cdot \left(1 - \left(0.5 \cdot t\_0\right) \cdot \frac{h}{\ell}\right)\\

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

\mathbf{else}:\\
\;\;\;\;\left(\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 t\_0\right) \cdot \frac{h}{\ell}\right)\\


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

    1. Initial program 76.9%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
      15. pow1/2N/A

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

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6476.9

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites76.9%

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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) \]
      6. lift-*.f64N/A

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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) \]
      7. lift-/.f64N/A

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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) \]
      8. lift-/.f64N/A

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

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

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

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

    if -3.2000000000000001e-52 < d < -2.3500000000000001e-187

    1. Initial program 63.8%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
      15. pow1/2N/A

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

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6463.8

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites63.8%

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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-prodN/A

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

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{d}{\ell} \cdot \frac{d}{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) \]
      10. lift-sqrt.f6452.1

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

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

      \[\leadsto \color{blue}{\left(-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right)} \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. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)\right) \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. inv-powN/A

        \[\leadsto \left(\mathsf{neg}\left(d \cdot \sqrt{{\left(h \cdot \ell\right)}^{-1}}\right)\right) \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. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d\right)\right) \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. distribute-rgt-neg-inN/A

        \[\leadsto \left(\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot \color{blue}{\left(\mathsf{neg}\left(d\right)\right)}\right) \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. inv-powN/A

        \[\leadsto \left(\sqrt{\frac{1}{h \cdot \ell}} \cdot \left(\mathsf{neg}\left(d\right)\right)\right) \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. lower-*.f64N/A

        \[\leadsto \left(\sqrt{\frac{1}{h \cdot \ell}} \cdot \color{blue}{\left(\mathsf{neg}\left(d\right)\right)}\right) \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. inv-powN/A

        \[\leadsto \left(\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot \left(\mathsf{neg}\left(d\right)\right)\right) \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. sqrt-pow1N/A

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

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

        \[\leadsto \left({\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)} \cdot \left(\mathsf{neg}\left(d\right)\right)\right) \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 \left({\left(h \cdot \ell\right)}^{\frac{-1}{2}} \cdot \left(\mathsf{neg}\left(d\right)\right)\right) \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.f6469.6

        \[\leadsto \left({\left(h \cdot \ell\right)}^{-0.5} \cdot \left(-d\right)\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    10. Applied rewrites69.6%

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

    if -2.3500000000000001e-187 < d < 5.7999999999999999e-208

    1. Initial program 39.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left({\left(\frac{h}{\ell}\right)}^{\frac{3}{2}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right) \cdot \frac{-1}{8}}{h} \]
      13. lift-/.f6458.9

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

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

    if 5.7999999999999999e-208 < d

    1. Initial program 71.3%

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

        \[\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) \]
      7. lower-/.f64N/A

        \[\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) \]
      8. lower-sqrt.f64N/A

        \[\leadsto \left(\frac{\color{blue}{\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) \]
      9. lower-sqrt.f6479.7

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

      \[\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) \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 2: 59.3% accurate, 0.3× speedup?

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

\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left(-{\left(h \cdot \ell\right)}^{-0.5}\right) \cdot d\\

\mathbf{elif}\;t\_0 \leq 10^{+246}:\\
\;\;\;\;t\_1 \cdot 1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 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)))) < -1.99999999999999986e-39

    1. Initial program 85.7%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
      15. pow1/2N/A

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

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6485.7

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites85.7%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \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 M around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999986e-39 < (*.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)))) < 0.0

    1. Initial program 47.9%

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

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

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

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

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

        \[\leadsto \sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
      5. lower-pow.f64N/A

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

        \[\leadsto \sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d \]
      7. lower-*.f6446.3

        \[\leadsto \sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d \]
    4. Applied rewrites46.3%

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

      \[\leadsto \left(\sqrt{\frac{1}{h \cdot \ell}} \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot d \]
    6. Step-by-step derivation
      1. sqrt-pow2N/A

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

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

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

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

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

        \[\leadsto \left(-\sqrt{\frac{1}{h \cdot \ell}}\right) \cdot d \]
      7. inv-powN/A

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

        \[\leadsto \left(-\sqrt{{\left(\ell \cdot h\right)}^{-1}}\right) \cdot d \]
      9. sqrt-pow1N/A

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

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

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

        \[\leadsto \left(-{\left(h \cdot \ell\right)}^{\left(\frac{-1}{2}\right)}\right) \cdot d \]
      13. metadata-eval47.9

        \[\leadsto \left(-{\left(h \cdot \ell\right)}^{-0.5}\right) \cdot d \]
    7. Applied rewrites47.9%

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

    if 0.0 < (*.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.00000000000000007e246

    1. Initial program 98.5%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
      15. pow1/2N/A

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

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6498.5

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites98.5%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \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 d around inf

      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \color{blue}{1} \]
    5. Step-by-step derivation
      1. Applied rewrites97.6%

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

      if 1.00000000000000007e246 < (*.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 22.7%

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

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

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

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

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

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

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

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

          \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
        15. pow1/2N/A

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

          \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6422.7

          \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites22.7%

        \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \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. Applied rewrites20.2%

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

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

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

            \[\leadsto -\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
          2. lift-pow.f64N/A

            \[\leadsto -\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
          3. inv-powN/A

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

            \[\leadsto -\sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
          5. lift-*.f6427.4

            \[\leadsto -\sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
        3. Applied rewrites27.4%

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

      Alternative 3: 58.9% accurate, 0.3× speedup?

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

        1. Initial program 85.9%

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

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

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

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

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

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

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

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

            \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
          15. pow1/2N/A

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

            \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6485.9

            \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites85.9%

          \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \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 M around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if -2.00000000000000014e-189 < (*.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)))) < 0.0 or 1.00000000000000007e246 < (*.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 25.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)}^{\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) \]
          5. 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) \]
          6. 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) \]
          7. lift-/.f64N/A

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

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

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

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

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

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

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

            \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
          15. pow1/2N/A

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

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

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

          \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \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. Applied rewrites22.5%

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

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

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

              \[\leadsto -\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
            2. lift-pow.f64N/A

              \[\leadsto -\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
            3. inv-powN/A

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

              \[\leadsto -\sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
            5. lift-*.f6431.8

              \[\leadsto -\sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
          3. Applied rewrites31.8%

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

          if 0.0 < (*.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.00000000000000007e246

          1. Initial program 98.5%

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

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

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

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

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

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

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

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

              \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
            15. pow1/2N/A

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

              \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6498.5

              \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites98.5%

            \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \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 d around inf

            \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \color{blue}{1} \]
          5. Step-by-step derivation
            1. Applied rewrites97.6%

              \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \color{blue}{1} \]
          6. Recombined 3 regimes into one program.
          7. Add Preprocessing

          Alternative 4: 46.8% accurate, 0.3× speedup?

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

            1. Initial program 85.9%

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

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

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

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

              \[\leadsto \frac{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{h}{\ell}}}{h} \]
            6. Step-by-step derivation
              1. sqrt-pow2N/A

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

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

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

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

                \[\leadsto \frac{d \cdot \left(-1 \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
              6. mul-1-negN/A

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

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

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

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

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

            if -2.00000000000000014e-189 < (*.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)))) < 0.0 or 1.00000000000000007e246 < (*.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 25.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)}^{\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) \]
              5. 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) \]
              6. 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) \]
              7. lift-/.f64N/A

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

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

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

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

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

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

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

                \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
              15. pow1/2N/A

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

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

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

              \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \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. Applied rewrites22.5%

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

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

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

                  \[\leadsto -\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
                2. lift-pow.f64N/A

                  \[\leadsto -\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
                3. inv-powN/A

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

                  \[\leadsto -\sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                5. lift-*.f6431.8

                  \[\leadsto -\sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
              3. Applied rewrites31.8%

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

              if 0.0 < (*.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.00000000000000007e246

              1. Initial program 98.5%

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

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

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

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

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

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

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

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

                  \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
                15. pow1/2N/A

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

                  \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6498.5

                  \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites98.5%

                \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \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 d around inf

                \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \color{blue}{1} \]
              5. Step-by-step derivation
                1. Applied rewrites97.6%

                  \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \color{blue}{1} \]
              6. Recombined 3 regimes into one program.
              7. Add Preprocessing

              Alternative 5: 42.7% accurate, 0.5× speedup?

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

                1. Initial program 85.9%

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

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

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

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

                  \[\leadsto \frac{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{h}{\ell}}}{h} \]
                6. Step-by-step derivation
                  1. sqrt-pow2N/A

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

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

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

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

                    \[\leadsto \frac{d \cdot \left(-1 \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
                  6. mul-1-negN/A

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

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

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

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

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

                if -2.00000000000000014e-189 < (*.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.00000000000000007e246

                1. Initial program 88.3%

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

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

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

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

                  \[\leadsto \frac{d \cdot \sqrt{\frac{h}{\ell}}}{h} \]
                6. Step-by-step derivation
                  1. *-commutativeN/A

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

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

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

                    \[\leadsto \frac{\sqrt{\frac{h}{\ell}} \cdot d}{h} \]
                7. Applied rewrites78.1%

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

                if 1.00000000000000007e246 < (*.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 22.7%

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

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

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

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

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

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

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

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

                    \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
                  15. pow1/2N/A

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

                    \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6422.7

                    \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites22.7%

                  \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \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. Applied rewrites20.2%

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

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

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

                      \[\leadsto -\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
                    2. lift-pow.f64N/A

                      \[\leadsto -\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
                    3. inv-powN/A

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

                      \[\leadsto -\sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                    5. lift-*.f6427.4

                      \[\leadsto -\sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                  3. Applied rewrites27.4%

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

                Alternative 6: 73.7% accurate, 0.6× speedup?

                \[\begin{array}{l} [d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\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) \leq \infty:\\ \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M \cdot D}{d + d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left({\left(\frac{h}{\ell}\right)}^{1.5} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right) \cdot -0.125}{h}\\ \end{array} \end{array} \]
                NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
                (FPCore (d h l M D)
                 :precision binary64
                 (if (<=
                      (*
                       (* (pow (/ d h) (/ 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))))
                      INFINITY)
                   (*
                    (* (sqrt (/ d l)) (sqrt (/ d h)))
                    (- 1.0 (* (* 0.5 (pow (/ (* M D) (+ d d)) 2.0)) (/ h l))))
                   (/ (* (* (pow (/ h l) 1.5) (/ (pow (* D M) 2.0) d)) -0.125) h)))
                assert(d < h && h < l && l < M && M < D);
                double code(double d, double h, double l, double M, double D) {
                	double tmp;
                	if (((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) INFINITY)) {
                		tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((0.5 * pow(((M * D) / (d + d)), 2.0)) * (h / l)));
                	} else {
                		tmp = ((pow((h / l), 1.5) * (pow((D * M), 2.0) / d)) * -0.125) / h;
                	}
                	return tmp;
                }
                
                assert d < h && h < l && l < M && M < D;
                public static double code(double d, double h, double l, double M, double D) {
                	double tmp;
                	if (((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)))) <= Double.POSITIVE_INFINITY) {
                		tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - ((0.5 * Math.pow(((M * D) / (d + d)), 2.0)) * (h / l)));
                	} else {
                		tmp = ((Math.pow((h / l), 1.5) * (Math.pow((D * M), 2.0) / d)) * -0.125) / h;
                	}
                	return tmp;
                }
                
                [d, h, l, M, D] = sort([d, h, l, M, D])
                def code(d, h, l, M, D):
                	tmp = 0
                	if ((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)))) <= math.inf:
                		tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - ((0.5 * math.pow(((M * D) / (d + d)), 2.0)) * (h / l)))
                	else:
                		tmp = ((math.pow((h / l), 1.5) * (math.pow((D * M), 2.0) / d)) * -0.125) / h
                	return tmp
                
                d, h, l, M, D = sort([d, h, l, M, D])
                function code(d, h, l, M, D)
                	tmp = 0.0
                	if (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)))) <= Inf)
                		tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(0.5 * (Float64(Float64(M * D) / Float64(d + d)) ^ 2.0)) * Float64(h / l))));
                	else
                		tmp = Float64(Float64(Float64((Float64(h / l) ^ 1.5) * Float64((Float64(D * M) ^ 2.0) / d)) * -0.125) / h);
                	end
                	return tmp
                end
                
                d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
                function tmp_2 = code(d, h, l, M, D)
                	tmp = 0.0;
                	if (((((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)))) <= Inf)
                		tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((0.5 * (((M * D) / (d + d)) ^ 2.0)) * (h / l)));
                	else
                		tmp = ((((h / l) ^ 1.5) * (((D * M) ^ 2.0) / d)) * -0.125) / h;
                	end
                	tmp_2 = tmp;
                end
                
                NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
                code[d_, h_, l_, M_, D_] := If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], 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], Infinity], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(0.5 * N[Power[N[(N[(M * D), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] * N[(N[Power[N[(D * M), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] / h), $MachinePrecision]]
                
                \begin{array}{l}
                [d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
                \\
                \begin{array}{l}
                \mathbf{if}\;\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) \leq \infty:\\
                \;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M \cdot D}{d + d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;\frac{\left({\left(\frac{h}{\ell}\right)}^{1.5} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right) \cdot -0.125}{h}\\
                
                
                \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)))) < +inf.0

                  1. Initial program 81.5%

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

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

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

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

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

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

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

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

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
                    15. pow1/2N/A

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

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6481.5

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites81.5%

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

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

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

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

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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) \]
                    2. count-2-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \frac{\left({\left(\frac{h}{\ell}\right)}^{\frac{3}{2}} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right) \cdot \frac{-1}{8}}{h} \]
                    13. lift-/.f6440.0

                      \[\leadsto \frac{\left({\left(\frac{h}{\ell}\right)}^{1.5} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right) \cdot -0.125}{h} \]
                  7. Applied rewrites40.0%

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

                Alternative 7: 70.0% accurate, 0.7× speedup?

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

                  1. Initial program 81.5%

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

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

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

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

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

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

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

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

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
                    15. pow1/2N/A

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

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6481.5

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites81.5%

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

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

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

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

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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) \]
                    2. count-2-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

                Alternative 8: 70.0% accurate, 0.7× speedup?

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

                  1. Initial program 81.5%

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

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

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

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

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

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

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

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

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
                    15. pow1/2N/A

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

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6481.5

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites81.5%

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

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

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

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

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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) \]
                    2. count-2-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                Alternative 9: 67.3% accurate, 0.7× speedup?

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

                  1. Initial program 87.1%

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

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

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

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

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

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

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

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

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
                    15. pow1/2N/A

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

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

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites87.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  if 1.00000000000000007e246 < (*.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 22.7%

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

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

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

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

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

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

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

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

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
                    15. pow1/2N/A

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

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6422.7

                      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites22.7%

                    \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \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. Applied rewrites20.2%

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

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

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

                        \[\leadsto -\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
                      2. lift-pow.f64N/A

                        \[\leadsto -\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
                      3. inv-powN/A

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

                        \[\leadsto -\sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                      5. lift-*.f6427.4

                        \[\leadsto -\sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                    3. Applied rewrites27.4%

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

                  Alternative 10: 66.6% accurate, 2.0× speedup?

                  \[\begin{array}{l} [d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\ \\ \begin{array}{l} t_0 := \frac{D}{d} \cdot \frac{M}{2}\\ t_1 := \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \left(0.5 \cdot \left(t\_0 \cdot t\_0\right)\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{if}\;d \leq -7.8 \cdot 10^{-110}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq 1.3 \cdot 10^{-157}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{d}, \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
                  NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
                  (FPCore (d h l M D)
                   :precision binary64
                   (let* ((t_0 (* (/ D d) (/ M 2.0)))
                          (t_1
                           (*
                            (* (sqrt (/ d l)) (sqrt (/ d h)))
                            (- 1.0 (* (* 0.5 (* t_0 t_0)) (/ h l))))))
                     (if (<= d -7.8e-110)
                       t_1
                       (if (<= d 1.3e-157)
                         (/
                          (fma
                           (* -0.125 (/ (* (* D M) (* D M)) d))
                           (sqrt (pow (/ h l) 3.0))
                           (* (sqrt (/ h l)) d))
                          h)
                         t_1))))
                  assert(d < h && h < l && l < M && M < D);
                  double code(double d, double h, double l, double M, double D) {
                  	double t_0 = (D / d) * (M / 2.0);
                  	double t_1 = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((0.5 * (t_0 * t_0)) * (h / l)));
                  	double tmp;
                  	if (d <= -7.8e-110) {
                  		tmp = t_1;
                  	} else if (d <= 1.3e-157) {
                  		tmp = fma((-0.125 * (((D * M) * (D * M)) / d)), sqrt(pow((h / l), 3.0)), (sqrt((h / l)) * d)) / h;
                  	} else {
                  		tmp = t_1;
                  	}
                  	return tmp;
                  }
                  
                  d, h, l, M, D = sort([d, h, l, M, D])
                  function code(d, h, l, M, D)
                  	t_0 = Float64(Float64(D / d) * Float64(M / 2.0))
                  	t_1 = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(0.5 * Float64(t_0 * t_0)) * Float64(h / l))))
                  	tmp = 0.0
                  	if (d <= -7.8e-110)
                  		tmp = t_1;
                  	elseif (d <= 1.3e-157)
                  		tmp = Float64(fma(Float64(-0.125 * Float64(Float64(Float64(D * M) * Float64(D * M)) / d)), sqrt((Float64(h / l) ^ 3.0)), Float64(sqrt(Float64(h / l)) * d)) / h);
                  	else
                  		tmp = t_1;
                  	end
                  	return tmp
                  end
                  
                  NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
                  code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(0.5 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.8e-110], t$95$1, If[LessEqual[d, 1.3e-157], N[(N[(N[(-0.125 * N[(N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[Power[N[(h / l), $MachinePrecision], 3.0], $MachinePrecision]], $MachinePrecision] + N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], t$95$1]]]]
                  
                  \begin{array}{l}
                  [d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
                  \\
                  \begin{array}{l}
                  t_0 := \frac{D}{d} \cdot \frac{M}{2}\\
                  t_1 := \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \left(0.5 \cdot \left(t\_0 \cdot t\_0\right)\right) \cdot \frac{h}{\ell}\right)\\
                  \mathbf{if}\;d \leq -7.8 \cdot 10^{-110}:\\
                  \;\;\;\;t\_1\\
                  
                  \mathbf{elif}\;d \leq 1.3 \cdot 10^{-157}:\\
                  \;\;\;\;\frac{\mathsf{fma}\left(-0.125 \cdot \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{d}, \sqrt{{\left(\frac{h}{\ell}\right)}^{3}}, \sqrt{\frac{h}{\ell}} \cdot d\right)}{h}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_1\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if d < -7.8e-110 or 1.29999999999999994e-157 < d

                    1. Initial program 74.6%

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

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

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

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

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

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

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

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

                        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
                      15. pow1/2N/A

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

                        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6474.6

                        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites74.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    if -7.8e-110 < d < 1.29999999999999994e-157

                    1. Initial program 45.4%

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 11: 45.8% accurate, 7.7× speedup?

                  \[\begin{array}{l} [d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\ \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2 \cdot 10^{-105}:\\ \;\;\;\;-\sqrt{\frac{1}{h \cdot \ell}} \cdot d\\ \mathbf{elif}\;\ell \leq 10^{-306}:\\ \;\;\;\;\frac{d \cdot \left(-\sqrt{\frac{h}{\ell}}\right)}{h}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{h} \cdot \sqrt{\ell}} \cdot d\\ \end{array} \end{array} \]
                  NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
                  (FPCore (d h l M D)
                   :precision binary64
                   (if (<= l -2e-105)
                     (- (* (sqrt (/ 1.0 (* h l))) d))
                     (if (<= l 1e-306)
                       (/ (* d (- (sqrt (/ h l)))) h)
                       (* (/ 1.0 (* (sqrt h) (sqrt l))) d))))
                  assert(d < h && h < l && l < M && M < D);
                  double code(double d, double h, double l, double M, double D) {
                  	double tmp;
                  	if (l <= -2e-105) {
                  		tmp = -(sqrt((1.0 / (h * l))) * d);
                  	} else if (l <= 1e-306) {
                  		tmp = (d * -sqrt((h / l))) / h;
                  	} else {
                  		tmp = (1.0 / (sqrt(h) * sqrt(l))) * d;
                  	}
                  	return tmp;
                  }
                  
                  NOTE: d, h, l, M, and D 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, 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
                      real(8) :: tmp
                      if (l <= (-2d-105)) then
                          tmp = -(sqrt((1.0d0 / (h * l))) * d)
                      else if (l <= 1d-306) then
                          tmp = (d * -sqrt((h / l))) / h
                      else
                          tmp = (1.0d0 / (sqrt(h) * sqrt(l))) * d
                      end if
                      code = tmp
                  end function
                  
                  assert d < h && h < l && l < M && M < D;
                  public static double code(double d, double h, double l, double M, double D) {
                  	double tmp;
                  	if (l <= -2e-105) {
                  		tmp = -(Math.sqrt((1.0 / (h * l))) * d);
                  	} else if (l <= 1e-306) {
                  		tmp = (d * -Math.sqrt((h / l))) / h;
                  	} else {
                  		tmp = (1.0 / (Math.sqrt(h) * Math.sqrt(l))) * d;
                  	}
                  	return tmp;
                  }
                  
                  [d, h, l, M, D] = sort([d, h, l, M, D])
                  def code(d, h, l, M, D):
                  	tmp = 0
                  	if l <= -2e-105:
                  		tmp = -(math.sqrt((1.0 / (h * l))) * d)
                  	elif l <= 1e-306:
                  		tmp = (d * -math.sqrt((h / l))) / h
                  	else:
                  		tmp = (1.0 / (math.sqrt(h) * math.sqrt(l))) * d
                  	return tmp
                  
                  d, h, l, M, D = sort([d, h, l, M, D])
                  function code(d, h, l, M, D)
                  	tmp = 0.0
                  	if (l <= -2e-105)
                  		tmp = Float64(-Float64(sqrt(Float64(1.0 / Float64(h * l))) * d));
                  	elseif (l <= 1e-306)
                  		tmp = Float64(Float64(d * Float64(-sqrt(Float64(h / l)))) / h);
                  	else
                  		tmp = Float64(Float64(1.0 / Float64(sqrt(h) * sqrt(l))) * d);
                  	end
                  	return tmp
                  end
                  
                  d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
                  function tmp_2 = code(d, h, l, M, D)
                  	tmp = 0.0;
                  	if (l <= -2e-105)
                  		tmp = -(sqrt((1.0 / (h * l))) * d);
                  	elseif (l <= 1e-306)
                  		tmp = (d * -sqrt((h / l))) / h;
                  	else
                  		tmp = (1.0 / (sqrt(h) * sqrt(l))) * d;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
                  code[d_, h_, l_, M_, D_] := If[LessEqual[l, -2e-105], (-N[(N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]), If[LessEqual[l, 1e-306], N[(N[(d * (-N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] / h), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[h], $MachinePrecision] * N[Sqrt[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]]
                  
                  \begin{array}{l}
                  [d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;\ell \leq -2 \cdot 10^{-105}:\\
                  \;\;\;\;-\sqrt{\frac{1}{h \cdot \ell}} \cdot d\\
                  
                  \mathbf{elif}\;\ell \leq 10^{-306}:\\
                  \;\;\;\;\frac{d \cdot \left(-\sqrt{\frac{h}{\ell}}\right)}{h}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{1}{\sqrt{h} \cdot \sqrt{\ell}} \cdot d\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if l < -1.99999999999999993e-105

                    1. Initial program 63.7%

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

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

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

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

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

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

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

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

                        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
                      15. pow1/2N/A

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

                        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \color{blue}{\sqrt{\frac{d}{h}}}\right) \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. lift-/.f6463.7

                        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\color{blue}{\frac{d}{h}}}\right) \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 rewrites63.7%

                      \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \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. Applied rewrites49.7%

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

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

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

                          \[\leadsto -\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
                        2. lift-pow.f64N/A

                          \[\leadsto -\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
                        3. inv-powN/A

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

                          \[\leadsto -\sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                        5. lift-*.f6449.6

                          \[\leadsto -\sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                      3. Applied rewrites49.6%

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

                      if -1.99999999999999993e-105 < l < 1.00000000000000003e-306

                      1. Initial program 72.5%

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

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

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

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

                        \[\leadsto \frac{\left(d \cdot {\left(\sqrt{-1}\right)}^{2}\right) \cdot \sqrt{\frac{h}{\ell}}}{h} \]
                      6. Step-by-step derivation
                        1. sqrt-pow2N/A

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

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

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

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

                          \[\leadsto \frac{d \cdot \left(-1 \cdot \sqrt{\frac{h}{\ell}}\right)}{h} \]
                        6. mul-1-negN/A

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

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

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

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

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

                      if 1.00000000000000003e-306 < l

                      1. Initial program 65.7%

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

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

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

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

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

                          \[\leadsto \sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
                        5. lower-pow.f64N/A

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

                          \[\leadsto \sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d \]
                        7. lower-*.f6442.7

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

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

                          \[\leadsto \sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d \]
                        2. lift-pow.f64N/A

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

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

                          \[\leadsto \sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
                        5. inv-powN/A

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

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

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

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

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

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

                          \[\leadsto \frac{1}{\sqrt{h \cdot \ell}} \cdot d \]
                        12. lower-*.f6442.9

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

                        \[\leadsto \frac{1}{\sqrt{h \cdot \ell}} \cdot d \]
                      7. Step-by-step derivation
                        1. lift-*.f64N/A

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

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

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

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

                          \[\leadsto \frac{1}{\sqrt{h} \cdot \sqrt{\ell}} \cdot d \]
                        6. lower-sqrt.f6450.4

                          \[\leadsto \frac{1}{\sqrt{h} \cdot \sqrt{\ell}} \cdot d \]
                      8. Applied rewrites50.4%

                        \[\leadsto \frac{1}{\sqrt{h} \cdot \sqrt{\ell}} \cdot d \]
                    7. Recombined 3 regimes into one program.
                    8. Add Preprocessing

                    Alternative 12: 41.4% accurate, 10.3× speedup?

                    \[\begin{array}{l} [d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\ \\ \begin{array}{l} t_0 := \sqrt{\frac{1}{h \cdot \ell}} \cdot d\\ \mathbf{if}\;\ell \leq -9 \cdot 10^{-126}:\\ \;\;\;\;-t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                    NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
                    (FPCore (d h l M D)
                     :precision binary64
                     (let* ((t_0 (* (sqrt (/ 1.0 (* h l))) d))) (if (<= l -9e-126) (- t_0) t_0)))
                    assert(d < h && h < l && l < M && M < D);
                    double code(double d, double h, double l, double M, double D) {
                    	double t_0 = sqrt((1.0 / (h * l))) * d;
                    	double tmp;
                    	if (l <= -9e-126) {
                    		tmp = -t_0;
                    	} else {
                    		tmp = t_0;
                    	}
                    	return tmp;
                    }
                    
                    NOTE: d, h, l, M, and D 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, 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
                        real(8) :: t_0
                        real(8) :: tmp
                        t_0 = sqrt((1.0d0 / (h * l))) * d
                        if (l <= (-9d-126)) then
                            tmp = -t_0
                        else
                            tmp = t_0
                        end if
                        code = tmp
                    end function
                    
                    assert d < h && h < l && l < M && M < D;
                    public static double code(double d, double h, double l, double M, double D) {
                    	double t_0 = Math.sqrt((1.0 / (h * l))) * d;
                    	double tmp;
                    	if (l <= -9e-126) {
                    		tmp = -t_0;
                    	} else {
                    		tmp = t_0;
                    	}
                    	return tmp;
                    }
                    
                    [d, h, l, M, D] = sort([d, h, l, M, D])
                    def code(d, h, l, M, D):
                    	t_0 = math.sqrt((1.0 / (h * l))) * d
                    	tmp = 0
                    	if l <= -9e-126:
                    		tmp = -t_0
                    	else:
                    		tmp = t_0
                    	return tmp
                    
                    d, h, l, M, D = sort([d, h, l, M, D])
                    function code(d, h, l, M, D)
                    	t_0 = Float64(sqrt(Float64(1.0 / Float64(h * l))) * d)
                    	tmp = 0.0
                    	if (l <= -9e-126)
                    		tmp = Float64(-t_0);
                    	else
                    		tmp = t_0;
                    	end
                    	return tmp
                    end
                    
                    d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
                    function tmp_2 = code(d, h, l, M, D)
                    	t_0 = sqrt((1.0 / (h * l))) * d;
                    	tmp = 0.0;
                    	if (l <= -9e-126)
                    		tmp = -t_0;
                    	else
                    		tmp = t_0;
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
                    code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]}, If[LessEqual[l, -9e-126], (-t$95$0), t$95$0]]
                    
                    \begin{array}{l}
                    [d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
                    \\
                    \begin{array}{l}
                    t_0 := \sqrt{\frac{1}{h \cdot \ell}} \cdot d\\
                    \mathbf{if}\;\ell \leq -9 \cdot 10^{-126}:\\
                    \;\;\;\;-t\_0\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;t\_0\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if l < -9.0000000000000005e-126

                      1. Initial program 64.2%

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

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

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

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

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

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

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

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

                          \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot {\left(\frac{d}{h}\right)}^{\color{blue}{\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) \]
                        15. pow1/2N/A

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

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

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

                        \[\leadsto \color{blue}{\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right)} \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. Applied rewrites50.3%

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

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

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

                            \[\leadsto -\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
                          2. lift-pow.f64N/A

                            \[\leadsto -\sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
                          3. inv-powN/A

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

                            \[\leadsto -\sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                          5. lift-*.f6449.1

                            \[\leadsto -\sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                        3. Applied rewrites49.1%

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

                        if -9.0000000000000005e-126 < l

                        1. Initial program 67.3%

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

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

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

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

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

                            \[\leadsto \sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
                          5. lower-pow.f64N/A

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

                            \[\leadsto \sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d \]
                          7. lower-*.f6437.3

                            \[\leadsto \sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d \]
                        4. Applied rewrites37.3%

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

                            \[\leadsto \sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d \]
                          2. lift-pow.f64N/A

                            \[\leadsto \sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d \]
                          3. unpow-1N/A

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

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

                            \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                          6. lower-*.f6437.3

                            \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                        6. Applied rewrites37.3%

                          \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                      7. Recombined 2 regimes into one program.
                      8. Add Preprocessing

                      Alternative 13: 26.7% accurate, 12.9× speedup?

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

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

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

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

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

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

                          \[\leadsto \sqrt{{\left(h \cdot \ell\right)}^{-1}} \cdot d \]
                        5. lower-pow.f64N/A

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

                          \[\leadsto \sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d \]
                        7. lower-*.f6426.7

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

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

                          \[\leadsto \sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d \]
                        2. lift-pow.f64N/A

                          \[\leadsto \sqrt{{\left(\ell \cdot h\right)}^{-1}} \cdot d \]
                        3. unpow-1N/A

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

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

                          \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                        6. lower-*.f6426.7

                          \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                      6. Applied rewrites26.7%

                        \[\leadsto \sqrt{\frac{1}{h \cdot \ell}} \cdot d \]
                      7. Add Preprocessing

                      Reproduce

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