Henrywood and Agarwal, Equation (12)

Percentage Accurate: 65.6% → 74.7%
Time: 10.0s
Alternatives: 12
Speedup: 1.5×

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

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

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{d + d}{D \cdot M}\\ \mathbf{if}\;h \leq -5 \cdot 10^{+235}:\\ \;\;\;\;-\frac{\sqrt{\frac{d}{h} \cdot \left(-d\right)}}{\sqrt{\frac{-1}{\ell}} \cdot \ell}\\ \mathbf{elif}\;h \leq 1.06 \cdot 10^{-299}:\\ \;\;\;\;\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot \left(1 - \left(0.5 \cdot \frac{1}{t\_0 \cdot t\_0}\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{d}{\sqrt{\ell} \cdot \sqrt{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)\\ \end{array} \end{array} \]
(FPCore (d h l M D)
 :precision binary64
 (let* ((t_0 (/ (+ d d) (* D M))))
   (if (<= h -5e+235)
     (- (/ (sqrt (* (/ d h) (- d))) (* (sqrt (/ -1.0 l)) l)))
     (if (<= h 1.06e-299)
       (*
        (/ (fabs d) (sqrt (* h l)))
        (- 1.0 (* (* 0.5 (/ 1.0 (* t_0 t_0))) (/ h l))))
       (*
        (/ d (* (sqrt l) (sqrt h)))
        (-
         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) {
	double t_0 = (d + d) / (D * M);
	double tmp;
	if (h <= -5e+235) {
		tmp = -(sqrt(((d / h) * -d)) / (sqrt((-1.0 / l)) * l));
	} else if (h <= 1.06e-299) {
		tmp = (fabs(d) / sqrt((h * l))) * (1.0 - ((0.5 * (1.0 / (t_0 * t_0))) * (h / l)));
	} else {
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
	}
	return tmp;
}
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 + d) / (d_1 * m)
    if (h <= (-5d+235)) then
        tmp = -(sqrt(((d / h) * -d)) / (sqrt(((-1.0d0) / l)) * l))
    else if (h <= 1.06d-299) then
        tmp = (abs(d) / sqrt((h * l))) * (1.0d0 - ((0.5d0 * (1.0d0 / (t_0 * t_0))) * (h / l)))
    else
        tmp = (d / (sqrt(l) * sqrt(h))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
    end if
    code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
	double t_0 = (d + d) / (D * M);
	double tmp;
	if (h <= -5e+235) {
		tmp = -(Math.sqrt(((d / h) * -d)) / (Math.sqrt((-1.0 / l)) * l));
	} else if (h <= 1.06e-299) {
		tmp = (Math.abs(d) / Math.sqrt((h * l))) * (1.0 - ((0.5 * (1.0 / (t_0 * t_0))) * (h / l)));
	} else {
		tmp = (d / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
	}
	return tmp;
}
def code(d, h, l, M, D):
	t_0 = (d + d) / (D * M)
	tmp = 0
	if h <= -5e+235:
		tmp = -(math.sqrt(((d / h) * -d)) / (math.sqrt((-1.0 / l)) * l))
	elif h <= 1.06e-299:
		tmp = (math.fabs(d) / math.sqrt((h * l))) * (1.0 - ((0.5 * (1.0 / (t_0 * t_0))) * (h / l)))
	else:
		tmp = (d / (math.sqrt(l) * math.sqrt(h))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
	return tmp
function code(d, h, l, M, D)
	t_0 = Float64(Float64(d + d) / Float64(D * M))
	tmp = 0.0
	if (h <= -5e+235)
		tmp = Float64(-Float64(sqrt(Float64(Float64(d / h) * Float64(-d))) / Float64(sqrt(Float64(-1.0 / l)) * l)));
	elseif (h <= 1.06e-299)
		tmp = Float64(Float64(abs(d) / sqrt(Float64(h * l))) * Float64(1.0 - Float64(Float64(0.5 * Float64(1.0 / Float64(t_0 * t_0))) * Float64(h / l))));
	else
		tmp = Float64(Float64(d / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))));
	end
	return tmp
end
function tmp_2 = code(d, h, l, M, D)
	t_0 = (d + d) / (D * M);
	tmp = 0.0;
	if (h <= -5e+235)
		tmp = -(sqrt(((d / h) * -d)) / (sqrt((-1.0 / l)) * l));
	elseif (h <= 1.06e-299)
		tmp = (abs(d) / sqrt((h * l))) * (1.0 - ((0.5 * (1.0 / (t_0 * t_0))) * (h / l)));
	else
		tmp = (d / (sqrt(l) * sqrt(h))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
	end
	tmp_2 = tmp;
end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(d + d), $MachinePrecision] / N[(D * M), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -5e+235], (-N[(N[Sqrt[N[(N[(d / h), $MachinePrecision] * (-d)), $MachinePrecision]], $MachinePrecision] / N[(N[Sqrt[N[(-1.0 / l), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), If[LessEqual[h, 1.06e-299], N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(0.5 * N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $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}

\\
\begin{array}{l}
t_0 := \frac{d + d}{D \cdot M}\\
\mathbf{if}\;h \leq -5 \cdot 10^{+235}:\\
\;\;\;\;-\frac{\sqrt{\frac{d}{h} \cdot \left(-d\right)}}{\sqrt{\frac{-1}{\ell}} \cdot \ell}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if h < -5.00000000000000027e235

    1. Initial program 65.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Step-by-step derivation
      1. 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) \]
      2. 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) \]
      3. 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) \]
      4. metadata-evalN/A

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

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

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

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

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

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

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

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \frac{\sqrt{-d}}{\color{blue}{\sqrt{\mathsf{neg}\left(\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) \]
      12. lower-neg.f6434.9

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

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

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

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

        \[\leadsto -1 \cdot \frac{\sqrt{\mathsf{neg}\left(d\right)} \cdot \sqrt{\frac{d}{h}}}{\ell \cdot \sqrt{\frac{-1}{\ell}}} \]
      3. pow1/2N/A

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

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

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

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

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

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

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

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

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

    if -5.00000000000000027e235 < h < 1.06e-299

    1. Initial program 65.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. 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. 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) \]
      10. 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) \]
      11. 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) \]
      12. 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) \]
      13. sqrt-unprodN/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) \]
      14. lower-sqrt.f64N/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) \]
      15. lower-*.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) \]
      16. 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) \]
      17. lift-/.f6455.0

        \[\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) \]
    3. Applied rewrites55.0%

      \[\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) \]
    4. Step-by-step derivation
      1. lift-sqrt.f64N/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) \]
      2. 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) \]
      3. 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) \]
      4. 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) \]
      5. frac-timesN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.06e-299 < h

    1. Initial program 65.6%

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

        \[\leadsto \left(\color{blue}{\frac{\sqrt{d}}{\sqrt{\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. pow1/2N/A

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

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

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

        \[\leadsto \left(\frac{{d}^{\left(\frac{1}{2}\right)}}{\sqrt{\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) \]
      16. pow1/2N/A

        \[\leadsto \left(\frac{{d}^{\left(\frac{1}{2}\right)}}{\sqrt{\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. sqrt-divN/A

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{d}{\sqrt{\ell} \cdot \sqrt{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) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 2: 74.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \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 := \frac{d + d}{D \cdot M}\\ t_2 := \frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot \left(1 - \left(0.5 \cdot \frac{1}{t\_1 \cdot t\_1}\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+152}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(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 (/ (+ d d) (* D M)))
        (t_2
         (*
          (/ (fabs d) (sqrt (* h l)))
          (- 1.0 (* (* 0.5 (/ 1.0 (* t_1 t_1))) (/ h l))))))
   (if (<= t_0 0.0)
     t_2
     (if (<= t_0 5e+152) (* (sqrt (/ d h)) (* (sqrt (/ d l)) 1.0)) t_2))))
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 = (d + d) / (D * M);
	double t_2 = (fabs(d) / sqrt((h * l))) * (1.0 - ((0.5 * (1.0 / (t_1 * t_1))) * (h / l)));
	double tmp;
	if (t_0 <= 0.0) {
		tmp = t_2;
	} else if (t_0 <= 5e+152) {
		tmp = sqrt((d / h)) * (sqrt((d / l)) * 1.0);
	} else {
		tmp = t_2;
	}
	return tmp;
}
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 = (d + d) / (d_1 * m)
    t_2 = (abs(d) / sqrt((h * l))) * (1.0d0 - ((0.5d0 * (1.0d0 / (t_1 * t_1))) * (h / l)))
    if (t_0 <= 0.0d0) then
        tmp = t_2
    else if (t_0 <= 5d+152) then
        tmp = sqrt((d / h)) * (sqrt((d / l)) * 1.0d0)
    else
        tmp = t_2
    end if
    code = tmp
end function
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 = (d + d) / (D * M);
	double t_2 = (Math.abs(d) / Math.sqrt((h * l))) * (1.0 - ((0.5 * (1.0 / (t_1 * t_1))) * (h / l)));
	double tmp;
	if (t_0 <= 0.0) {
		tmp = t_2;
	} else if (t_0 <= 5e+152) {
		tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * 1.0);
	} else {
		tmp = t_2;
	}
	return tmp;
}
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 = (d + d) / (D * M)
	t_2 = (math.fabs(d) / math.sqrt((h * l))) * (1.0 - ((0.5 * (1.0 / (t_1 * t_1))) * (h / l)))
	tmp = 0
	if t_0 <= 0.0:
		tmp = t_2
	elif t_0 <= 5e+152:
		tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * 1.0)
	else:
		tmp = t_2
	return tmp
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(d + d) / Float64(D * M))
	t_2 = Float64(Float64(abs(d) / sqrt(Float64(h * l))) * Float64(1.0 - Float64(Float64(0.5 * Float64(1.0 / Float64(t_1 * t_1))) * Float64(h / l))))
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = t_2;
	elseif (t_0 <= 5e+152)
		tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * 1.0));
	else
		tmp = t_2;
	end
	return tmp
end
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 = (d + d) / (D * M);
	t_2 = (abs(d) / sqrt((h * l))) * (1.0 - ((0.5 * (1.0 / (t_1 * t_1))) * (h / l)));
	tmp = 0.0;
	if (t_0 <= 0.0)
		tmp = t_2;
	elseif (t_0 <= 5e+152)
		tmp = sqrt((d / h)) * (sqrt((d / l)) * 1.0);
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
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[(d + d), $MachinePrecision] / N[(D * M), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(0.5 * N[(1.0 / N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], t$95$2, If[LessEqual[t$95$0, 5e+152], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}

\\
\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 := \frac{d + d}{D \cdot M}\\
t_2 := \frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot \left(1 - \left(0.5 \cdot \frac{1}{t\_1 \cdot t\_1}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+152}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\\

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


\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)))) < 0.0 or 5e152 < (*.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 65.6%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. 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. 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) \]
      10. 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) \]
      11. 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) \]
      12. 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) \]
      13. sqrt-unprodN/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) \]
      14. lower-sqrt.f64N/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) \]
      15. lower-*.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) \]
      16. 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) \]
      17. lift-/.f6455.0

        \[\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) \]
    3. Applied rewrites55.0%

      \[\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) \]
    4. Step-by-step derivation
      1. lift-sqrt.f64N/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) \]
      2. 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) \]
      3. 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) \]
      4. 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) \]
      5. frac-timesN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    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)))) < 5e152

    1. Initial program 65.6%

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

      \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \color{blue}{1} \]
    3. Step-by-step derivation
      1. Applied rewrites38.8%

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \color{blue}{1} \]
      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 1} \]
        2. 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 1 \]
        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 1 \]
        4. 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 1 \]
        5. 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 1 \]
        6. 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 1 \]
        7. 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 1 \]
        8. 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 1 \]
        9. associate-*l*N/A

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

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

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

    Alternative 3: 53.5% accurate, 2.0× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;M \leq 6.8 \cdot 10^{-102}:\\ \;\;\;\;\frac{\left|d\right|}{t\_0}\\ \mathbf{elif}\;M \leq 1.8 \cdot 10^{+34}:\\ \;\;\;\;\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot \mathsf{fma}\left(\frac{\left(M \cdot M\right) \cdot \left(D \cdot D\right)}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125, h, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(\left(\frac{1}{t\_0} \cdot h\right) \cdot \left(M \cdot M\right)\right) \cdot D\right) \cdot D}{\ell \cdot d} \cdot -0.125\\ \end{array} \end{array} \]
    (FPCore (d h l M D)
     :precision binary64
     (let* ((t_0 (sqrt (* l h))))
       (if (<= M 6.8e-102)
         (/ (fabs d) t_0)
         (if (<= M 1.8e+34)
           (*
            (/ (fabs d) (sqrt (* h l)))
            (fma (* (/ (* (* M M) (* D D)) (* (* d d) l)) -0.125) h 1.0))
           (* (/ (* (* (* (* (/ 1.0 t_0) h) (* M M)) D) D) (* l d)) -0.125)))))
    double code(double d, double h, double l, double M, double D) {
    	double t_0 = sqrt((l * h));
    	double tmp;
    	if (M <= 6.8e-102) {
    		tmp = fabs(d) / t_0;
    	} else if (M <= 1.8e+34) {
    		tmp = (fabs(d) / sqrt((h * l))) * fma(((((M * M) * (D * D)) / ((d * d) * l)) * -0.125), h, 1.0);
    	} else {
    		tmp = ((((((1.0 / t_0) * h) * (M * M)) * D) * D) / (l * d)) * -0.125;
    	}
    	return tmp;
    }
    
    function code(d, h, l, M, D)
    	t_0 = sqrt(Float64(l * h))
    	tmp = 0.0
    	if (M <= 6.8e-102)
    		tmp = Float64(abs(d) / t_0);
    	elseif (M <= 1.8e+34)
    		tmp = Float64(Float64(abs(d) / sqrt(Float64(h * l))) * fma(Float64(Float64(Float64(Float64(M * M) * Float64(D * D)) / Float64(Float64(d * d) * l)) * -0.125), h, 1.0));
    	else
    		tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(1.0 / t_0) * h) * Float64(M * M)) * D) * D) / Float64(l * d)) * -0.125);
    	end
    	return tmp
    end
    
    code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, 6.8e-102], N[(N[Abs[d], $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[M, 1.8e+34], N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(M * M), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(1.0 / t$95$0), $MachinePrecision] * h), $MachinePrecision] * N[(M * M), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision] * D), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \sqrt{\ell \cdot h}\\
    \mathbf{if}\;M \leq 6.8 \cdot 10^{-102}:\\
    \;\;\;\;\frac{\left|d\right|}{t\_0}\\
    
    \mathbf{elif}\;M \leq 1.8 \cdot 10^{+34}:\\
    \;\;\;\;\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot \mathsf{fma}\left(\frac{\left(M \cdot M\right) \cdot \left(D \cdot D\right)}{\left(d \cdot d\right) \cdot \ell} \cdot -0.125, h, 1\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\left(\left(\left(\frac{1}{t\_0} \cdot h\right) \cdot \left(M \cdot M\right)\right) \cdot D\right) \cdot D}{\ell \cdot d} \cdot -0.125\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if M < 6.80000000000000026e-102

      1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        15. lower-*.f649.6

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

        \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
      8. Taylor expanded in h around inf

        \[\leadsto \sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
      9. Step-by-step derivation
        1. sqrt-divN/A

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

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

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

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

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

          \[\leadsto \frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        7. lift-fabs.f6442.9

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

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

          \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
        10. lower-*.f6442.9

          \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      10. Applied rewrites42.9%

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

      if 6.80000000000000026e-102 < M < 1.8e34

      1. Initial program 65.6%

        \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      2. 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. 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) \]
        10. 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) \]
        11. 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) \]
        12. 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) \]
        13. sqrt-unprodN/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) \]
        14. lower-sqrt.f64N/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) \]
        15. lower-*.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) \]
        16. 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) \]
        17. lift-/.f6455.0

          \[\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) \]
      3. Applied rewrites55.0%

        \[\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) \]
      4. Step-by-step derivation
        1. lift-sqrt.f64N/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) \]
        2. 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) \]
        3. 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) \]
        4. 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) \]
        5. frac-timesN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 1.8e34 < M

      1. Initial program 65.6%

        \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      2. 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. 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) \]
        10. 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) \]
        11. 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) \]
        12. 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) \]
        13. sqrt-unprodN/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) \]
        14. lower-sqrt.f64N/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) \]
        15. lower-*.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) \]
        16. 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) \]
        17. lift-/.f6455.0

          \[\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) \]
      3. Applied rewrites55.0%

        \[\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) \]
      4. Taylor expanded in d around -inf

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 4: 50.9% accurate, 2.1× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 3.8 \cdot 10^{-115}:\\ \;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot \left(1 - \frac{\frac{\left(\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot \frac{h}{\ell}\right)\right) \cdot 0.125}{d}}{d}\right)\\ \end{array} \end{array} \]
    (FPCore (d h l M D)
     :precision binary64
     (if (<= M 3.8e-115)
       (/ (fabs d) (sqrt (* l h)))
       (*
        (/ (fabs d) (sqrt (* h l)))
        (- 1.0 (/ (/ (* (* (* D D) (* (* M M) (/ h l))) 0.125) d) d)))))
    double code(double d, double h, double l, double M, double D) {
    	double tmp;
    	if (M <= 3.8e-115) {
    		tmp = fabs(d) / sqrt((l * h));
    	} else {
    		tmp = (fabs(d) / sqrt((h * l))) * (1.0 - (((((D * D) * ((M * M) * (h / l))) * 0.125) / d) / d));
    	}
    	return tmp;
    }
    
    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 (m <= 3.8d-115) then
            tmp = abs(d) / sqrt((l * h))
        else
            tmp = (abs(d) / sqrt((h * l))) * (1.0d0 - (((((d_1 * d_1) * ((m * m) * (h / l))) * 0.125d0) / d) / d))
        end if
        code = tmp
    end function
    
    public static double code(double d, double h, double l, double M, double D) {
    	double tmp;
    	if (M <= 3.8e-115) {
    		tmp = Math.abs(d) / Math.sqrt((l * h));
    	} else {
    		tmp = (Math.abs(d) / Math.sqrt((h * l))) * (1.0 - (((((D * D) * ((M * M) * (h / l))) * 0.125) / d) / d));
    	}
    	return tmp;
    }
    
    def code(d, h, l, M, D):
    	tmp = 0
    	if M <= 3.8e-115:
    		tmp = math.fabs(d) / math.sqrt((l * h))
    	else:
    		tmp = (math.fabs(d) / math.sqrt((h * l))) * (1.0 - (((((D * D) * ((M * M) * (h / l))) * 0.125) / d) / d))
    	return tmp
    
    function code(d, h, l, M, D)
    	tmp = 0.0
    	if (M <= 3.8e-115)
    		tmp = Float64(abs(d) / sqrt(Float64(l * h)));
    	else
    		tmp = Float64(Float64(abs(d) / sqrt(Float64(h * l))) * Float64(1.0 - Float64(Float64(Float64(Float64(Float64(D * D) * Float64(Float64(M * M) * Float64(h / l))) * 0.125) / d) / d)));
    	end
    	return tmp
    end
    
    function tmp_2 = code(d, h, l, M, D)
    	tmp = 0.0;
    	if (M <= 3.8e-115)
    		tmp = abs(d) / sqrt((l * h));
    	else
    		tmp = (abs(d) / sqrt((h * l))) * (1.0 - (((((D * D) * ((M * M) * (h / l))) * 0.125) / d) / d));
    	end
    	tmp_2 = tmp;
    end
    
    code[d_, h_, l_, M_, D_] := If[LessEqual[M, 3.8e-115], N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(N[(D * D), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;M \leq 3.8 \cdot 10^{-115}:\\
    \;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \cdot \left(1 - \frac{\frac{\left(\left(D \cdot D\right) \cdot \left(\left(M \cdot M\right) \cdot \frac{h}{\ell}\right)\right) \cdot 0.125}{d}}{d}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if M < 3.79999999999999992e-115

      1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        15. lower-*.f649.6

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

        \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
      8. Taylor expanded in h around inf

        \[\leadsto \sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
      9. Step-by-step derivation
        1. sqrt-divN/A

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

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

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

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

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

          \[\leadsto \frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        7. lift-fabs.f6442.9

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

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

          \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
        10. lower-*.f6442.9

          \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      10. Applied rewrites42.9%

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

      if 3.79999999999999992e-115 < M

      1. Initial program 65.6%

        \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      2. 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. 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) \]
        10. 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) \]
        11. 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) \]
        12. 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) \]
        13. sqrt-unprodN/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) \]
        14. lower-sqrt.f64N/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) \]
        15. lower-*.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) \]
        16. 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) \]
        17. lift-/.f6455.0

          \[\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) \]
      3. Applied rewrites55.0%

        \[\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) \]
      4. Step-by-step derivation
        1. lift-sqrt.f64N/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) \]
        2. 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) \]
        3. 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) \]
        4. 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) \]
        5. frac-timesN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 5: 50.7% accurate, 2.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;M \cdot D \leq 10^{+60}:\\ \;\;\;\;\frac{\left|d\right|}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(\left(\frac{1}{t\_0} \cdot h\right) \cdot \left(M \cdot M\right)\right) \cdot D\right) \cdot D}{\ell \cdot d} \cdot -0.125\\ \end{array} \end{array} \]
    (FPCore (d h l M D)
     :precision binary64
     (let* ((t_0 (sqrt (* l h))))
       (if (<= (* M D) 1e+60)
         (/ (fabs d) t_0)
         (* (/ (* (* (* (* (/ 1.0 t_0) h) (* M M)) D) D) (* l d)) -0.125))))
    double code(double d, double h, double l, double M, double D) {
    	double t_0 = sqrt((l * h));
    	double tmp;
    	if ((M * D) <= 1e+60) {
    		tmp = fabs(d) / t_0;
    	} else {
    		tmp = ((((((1.0 / t_0) * h) * (M * M)) * D) * D) / (l * d)) * -0.125;
    	}
    	return tmp;
    }
    
    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((l * h))
        if ((m * d_1) <= 1d+60) then
            tmp = abs(d) / t_0
        else
            tmp = ((((((1.0d0 / t_0) * h) * (m * m)) * d_1) * d_1) / (l * d)) * (-0.125d0)
        end if
        code = tmp
    end function
    
    public static double code(double d, double h, double l, double M, double D) {
    	double t_0 = Math.sqrt((l * h));
    	double tmp;
    	if ((M * D) <= 1e+60) {
    		tmp = Math.abs(d) / t_0;
    	} else {
    		tmp = ((((((1.0 / t_0) * h) * (M * M)) * D) * D) / (l * d)) * -0.125;
    	}
    	return tmp;
    }
    
    def code(d, h, l, M, D):
    	t_0 = math.sqrt((l * h))
    	tmp = 0
    	if (M * D) <= 1e+60:
    		tmp = math.fabs(d) / t_0
    	else:
    		tmp = ((((((1.0 / t_0) * h) * (M * M)) * D) * D) / (l * d)) * -0.125
    	return tmp
    
    function code(d, h, l, M, D)
    	t_0 = sqrt(Float64(l * h))
    	tmp = 0.0
    	if (Float64(M * D) <= 1e+60)
    		tmp = Float64(abs(d) / t_0);
    	else
    		tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(1.0 / t_0) * h) * Float64(M * M)) * D) * D) / Float64(l * d)) * -0.125);
    	end
    	return tmp
    end
    
    function tmp_2 = code(d, h, l, M, D)
    	t_0 = sqrt((l * h));
    	tmp = 0.0;
    	if ((M * D) <= 1e+60)
    		tmp = abs(d) / t_0;
    	else
    		tmp = ((((((1.0 / t_0) * h) * (M * M)) * D) * D) / (l * d)) * -0.125;
    	end
    	tmp_2 = tmp;
    end
    
    code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 1e+60], N[(N[Abs[d], $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(1.0 / t$95$0), $MachinePrecision] * h), $MachinePrecision] * N[(M * M), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision] * D), $MachinePrecision] / N[(l * d), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \sqrt{\ell \cdot h}\\
    \mathbf{if}\;M \cdot D \leq 10^{+60}:\\
    \;\;\;\;\frac{\left|d\right|}{t\_0}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\left(\left(\left(\frac{1}{t\_0} \cdot h\right) \cdot \left(M \cdot M\right)\right) \cdot D\right) \cdot D}{\ell \cdot d} \cdot -0.125\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 M D) < 9.9999999999999995e59

      1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        15. lower-*.f649.6

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

        \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
      8. Taylor expanded in h around inf

        \[\leadsto \sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
      9. Step-by-step derivation
        1. sqrt-divN/A

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

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

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

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

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

          \[\leadsto \frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        7. lift-fabs.f6442.9

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

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

          \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
        10. lower-*.f6442.9

          \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      10. Applied rewrites42.9%

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

      if 9.9999999999999995e59 < (*.f64 M D)

      1. Initial program 65.6%

        \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      2. 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. 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) \]
        10. 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) \]
        11. 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) \]
        12. 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) \]
        13. sqrt-unprodN/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) \]
        14. lower-sqrt.f64N/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) \]
        15. lower-*.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) \]
        16. 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) \]
        17. lift-/.f6455.0

          \[\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) \]
      3. Applied rewrites55.0%

        \[\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) \]
      4. Taylor expanded in d around -inf

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 6: 49.2% accurate, 0.4× speedup?

    \[\begin{array}{l} \\ \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)\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-109}:\\ \;\;\;\;-\sqrt{\frac{d \cdot d}{\ell \cdot h}}\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+152}:\\ \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\ \end{array} \end{array} \]
    (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))))))
       (if (<= t_0 -1e-109)
         (- (sqrt (/ (* d d) (* l h))))
         (if (<= t_0 5e+152)
           (* (sqrt (/ d h)) (* (sqrt (/ d l)) 1.0))
           (/ (fabs d) (sqrt (* l h)))))))
    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 tmp;
    	if (t_0 <= -1e-109) {
    		tmp = -sqrt(((d * d) / (l * h)));
    	} else if (t_0 <= 5e+152) {
    		tmp = sqrt((d / h)) * (sqrt((d / l)) * 1.0);
    	} else {
    		tmp = fabs(d) / sqrt((l * h));
    	}
    	return tmp;
    }
    
    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 / 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_0 <= (-1d-109)) then
            tmp = -sqrt(((d * d) / (l * h)))
        else if (t_0 <= 5d+152) then
            tmp = sqrt((d / h)) * (sqrt((d / l)) * 1.0d0)
        else
            tmp = abs(d) / sqrt((l * h))
        end if
        code = tmp
    end function
    
    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 tmp;
    	if (t_0 <= -1e-109) {
    		tmp = -Math.sqrt(((d * d) / (l * h)));
    	} else if (t_0 <= 5e+152) {
    		tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * 1.0);
    	} else {
    		tmp = Math.abs(d) / Math.sqrt((l * h));
    	}
    	return tmp;
    }
    
    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)))
    	tmp = 0
    	if t_0 <= -1e-109:
    		tmp = -math.sqrt(((d * d) / (l * h)))
    	elif t_0 <= 5e+152:
    		tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * 1.0)
    	else:
    		tmp = math.fabs(d) / math.sqrt((l * h))
    	return tmp
    
    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))))
    	tmp = 0.0
    	if (t_0 <= -1e-109)
    		tmp = Float64(-sqrt(Float64(Float64(d * d) / Float64(l * h))));
    	elseif (t_0 <= 5e+152)
    		tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * 1.0));
    	else
    		tmp = Float64(abs(d) / sqrt(Float64(l * h)));
    	end
    	return tmp
    end
    
    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)));
    	tmp = 0.0;
    	if (t_0 <= -1e-109)
    		tmp = -sqrt(((d * d) / (l * h)));
    	elseif (t_0 <= 5e+152)
    		tmp = sqrt((d / h)) * (sqrt((d / l)) * 1.0);
    	else
    		tmp = abs(d) / sqrt((l * h));
    	end
    	tmp_2 = tmp;
    end
    
    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]}, If[LessEqual[t$95$0, -1e-109], (-N[Sqrt[N[(N[(d * d), $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), If[LessEqual[t$95$0, 5e+152], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
    
    \begin{array}{l}
    
    \\
    \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)\\
    \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-109}:\\
    \;\;\;\;-\sqrt{\frac{d \cdot d}{\ell \cdot h}}\\
    
    \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+152}:\\
    \;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot 1\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
    
    
    \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)))) < -9.9999999999999999e-110

      1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        15. lower-*.f649.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto -\sqrt{\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}} \]
        20. rem-square-sqrtN/A

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

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

      if -9.9999999999999999e-110 < (*.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)))) < 5e152

      1. Initial program 65.6%

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

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \color{blue}{1} \]
      3. Step-by-step derivation
        1. Applied rewrites38.8%

          \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \color{blue}{1} \]
        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 1} \]
          2. 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 1 \]
          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 1 \]
          4. 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 1 \]
          5. 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 1 \]
          6. 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 1 \]
          7. 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 1 \]
          8. 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 1 \]
          9. associate-*l*N/A

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

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

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

        if 5e152 < (*.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 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          15. lower-*.f649.6

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

          \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        8. Taylor expanded in h around inf

          \[\leadsto \sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
        9. Step-by-step derivation
          1. sqrt-divN/A

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

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

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

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

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

            \[\leadsto \frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          7. lift-fabs.f6442.9

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

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

            \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
          10. lower-*.f6442.9

            \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
        10. Applied rewrites42.9%

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

      Alternative 7: 48.6% accurate, 0.5× speedup?

      \[\begin{array}{l} \\ \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)\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-109}:\\ \;\;\;\;-\sqrt{\frac{d \cdot d}{\ell \cdot h}}\\ \mathbf{elif}\;t\_0 \leq 10^{+126}:\\ \;\;\;\;\frac{\left|d\right|}{\sqrt{\frac{h}{\ell}} \cdot \ell}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\ \end{array} \end{array} \]
      (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))))))
         (if (<= t_0 -1e-109)
           (- (sqrt (/ (* d d) (* l h))))
           (if (<= t_0 1e+126)
             (/ (fabs d) (* (sqrt (/ h l)) l))
             (/ (fabs d) (sqrt (* l h)))))))
      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 tmp;
      	if (t_0 <= -1e-109) {
      		tmp = -sqrt(((d * d) / (l * h)));
      	} else if (t_0 <= 1e+126) {
      		tmp = fabs(d) / (sqrt((h / l)) * l);
      	} else {
      		tmp = fabs(d) / sqrt((l * h));
      	}
      	return tmp;
      }
      
      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 / 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_0 <= (-1d-109)) then
              tmp = -sqrt(((d * d) / (l * h)))
          else if (t_0 <= 1d+126) then
              tmp = abs(d) / (sqrt((h / l)) * l)
          else
              tmp = abs(d) / sqrt((l * h))
          end if
          code = tmp
      end function
      
      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 tmp;
      	if (t_0 <= -1e-109) {
      		tmp = -Math.sqrt(((d * d) / (l * h)));
      	} else if (t_0 <= 1e+126) {
      		tmp = Math.abs(d) / (Math.sqrt((h / l)) * l);
      	} else {
      		tmp = Math.abs(d) / Math.sqrt((l * h));
      	}
      	return tmp;
      }
      
      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)))
      	tmp = 0
      	if t_0 <= -1e-109:
      		tmp = -math.sqrt(((d * d) / (l * h)))
      	elif t_0 <= 1e+126:
      		tmp = math.fabs(d) / (math.sqrt((h / l)) * l)
      	else:
      		tmp = math.fabs(d) / math.sqrt((l * h))
      	return tmp
      
      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))))
      	tmp = 0.0
      	if (t_0 <= -1e-109)
      		tmp = Float64(-sqrt(Float64(Float64(d * d) / Float64(l * h))));
      	elseif (t_0 <= 1e+126)
      		tmp = Float64(abs(d) / Float64(sqrt(Float64(h / l)) * l));
      	else
      		tmp = Float64(abs(d) / sqrt(Float64(l * h)));
      	end
      	return tmp
      end
      
      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)));
      	tmp = 0.0;
      	if (t_0 <= -1e-109)
      		tmp = -sqrt(((d * d) / (l * h)));
      	elseif (t_0 <= 1e+126)
      		tmp = abs(d) / (sqrt((h / l)) * l);
      	else
      		tmp = abs(d) / sqrt((l * h));
      	end
      	tmp_2 = tmp;
      end
      
      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]}, If[LessEqual[t$95$0, -1e-109], (-N[Sqrt[N[(N[(d * d), $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), If[LessEqual[t$95$0, 1e+126], N[(N[Abs[d], $MachinePrecision] / N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision], N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \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)\\
      \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-109}:\\
      \;\;\;\;-\sqrt{\frac{d \cdot d}{\ell \cdot h}}\\
      
      \mathbf{elif}\;t\_0 \leq 10^{+126}:\\
      \;\;\;\;\frac{\left|d\right|}{\sqrt{\frac{h}{\ell}} \cdot \ell}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
      
      
      \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)))) < -9.9999999999999999e-110

        1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          15. lower-*.f649.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto -\sqrt{\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}} \]
          20. rem-square-sqrtN/A

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

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

        if -9.9999999999999999e-110 < (*.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)))) < 9.99999999999999925e125

        1. Initial program 65.6%

          \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
        2. 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. 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) \]
          10. 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) \]
          11. 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) \]
          12. 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) \]
          13. sqrt-unprodN/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) \]
          14. lower-sqrt.f64N/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) \]
          15. lower-*.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) \]
          16. 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) \]
          17. lift-/.f6455.0

            \[\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) \]
        3. Applied rewrites55.0%

          \[\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) \]
        4. Step-by-step derivation
          1. lift-sqrt.f64N/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) \]
          2. 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) \]
          3. 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) \]
          4. 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) \]
          5. frac-timesN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{\left|d\right|}{\ell \cdot \sqrt{\frac{h}{\ell}}}} \]
        7. Step-by-step derivation
          1. rem-sqrt-square-revN/A

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

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

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

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

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

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

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

            \[\leadsto \frac{\left|d\right|}{\color{blue}{\ell} \cdot \sqrt{\frac{h}{\ell}}} \]
          9. *-commutativeN/A

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

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

            \[\leadsto \frac{\left|d\right|}{\sqrt{\frac{h}{\ell}} \cdot \ell} \]
          12. lift-/.f6423.0

            \[\leadsto \frac{\left|d\right|}{\sqrt{\frac{h}{\ell}} \cdot \ell} \]
        8. Applied rewrites23.0%

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

        if 9.99999999999999925e125 < (*.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 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          15. lower-*.f649.6

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

          \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        8. Taylor expanded in h around inf

          \[\leadsto \sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
        9. Step-by-step derivation
          1. sqrt-divN/A

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

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

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

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

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

            \[\leadsto \frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          7. lift-fabs.f6442.9

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

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

            \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
          10. lower-*.f6442.9

            \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
        10. Applied rewrites42.9%

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

      Alternative 8: 46.5% accurate, 0.5× speedup?

      \[\begin{array}{l} \\ \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)\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-109}:\\ \;\;\;\;-\sqrt{\frac{d \cdot d}{\ell \cdot h}}\\ \mathbf{elif}\;t\_0 \leq 10^{+116}:\\ \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\ \end{array} \end{array} \]
      (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))))))
         (if (<= t_0 -1e-109)
           (- (sqrt (/ (* d d) (* l h))))
           (if (<= t_0 1e+116)
             (/ (* (sqrt (/ h l)) d) h)
             (/ (fabs d) (sqrt (* l h)))))))
      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 tmp;
      	if (t_0 <= -1e-109) {
      		tmp = -sqrt(((d * d) / (l * h)));
      	} else if (t_0 <= 1e+116) {
      		tmp = (sqrt((h / l)) * d) / h;
      	} else {
      		tmp = fabs(d) / sqrt((l * h));
      	}
      	return tmp;
      }
      
      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 / 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_0 <= (-1d-109)) then
              tmp = -sqrt(((d * d) / (l * h)))
          else if (t_0 <= 1d+116) then
              tmp = (sqrt((h / l)) * d) / h
          else
              tmp = abs(d) / sqrt((l * h))
          end if
          code = tmp
      end function
      
      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 tmp;
      	if (t_0 <= -1e-109) {
      		tmp = -Math.sqrt(((d * d) / (l * h)));
      	} else if (t_0 <= 1e+116) {
      		tmp = (Math.sqrt((h / l)) * d) / h;
      	} else {
      		tmp = Math.abs(d) / Math.sqrt((l * h));
      	}
      	return tmp;
      }
      
      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)))
      	tmp = 0
      	if t_0 <= -1e-109:
      		tmp = -math.sqrt(((d * d) / (l * h)))
      	elif t_0 <= 1e+116:
      		tmp = (math.sqrt((h / l)) * d) / h
      	else:
      		tmp = math.fabs(d) / math.sqrt((l * h))
      	return tmp
      
      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))))
      	tmp = 0.0
      	if (t_0 <= -1e-109)
      		tmp = Float64(-sqrt(Float64(Float64(d * d) / Float64(l * h))));
      	elseif (t_0 <= 1e+116)
      		tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h);
      	else
      		tmp = Float64(abs(d) / sqrt(Float64(l * h)));
      	end
      	return tmp
      end
      
      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)));
      	tmp = 0.0;
      	if (t_0 <= -1e-109)
      		tmp = -sqrt(((d * d) / (l * h)));
      	elseif (t_0 <= 1e+116)
      		tmp = (sqrt((h / l)) * d) / h;
      	else
      		tmp = abs(d) / sqrt((l * h));
      	end
      	tmp_2 = tmp;
      end
      
      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]}, If[LessEqual[t$95$0, -1e-109], (-N[Sqrt[N[(N[(d * d), $MachinePrecision] / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), If[LessEqual[t$95$0, 1e+116], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \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)\\
      \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-109}:\\
      \;\;\;\;-\sqrt{\frac{d \cdot d}{\ell \cdot h}}\\
      
      \mathbf{elif}\;t\_0 \leq 10^{+116}:\\
      \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
      
      
      \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)))) < -9.9999999999999999e-110

        1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          15. lower-*.f649.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto -\sqrt{\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}} \]
          20. rem-square-sqrtN/A

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

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

        if -9.9999999999999999e-110 < (*.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.00000000000000002e116

        1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

        if 1.00000000000000002e116 < (*.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 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          15. lower-*.f649.6

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

          \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        8. Taylor expanded in h around inf

          \[\leadsto \sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
        9. Step-by-step derivation
          1. sqrt-divN/A

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

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

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

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

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

            \[\leadsto \frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          7. lift-fabs.f6442.9

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

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

            \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
          10. lower-*.f6442.9

            \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
        10. Applied rewrites42.9%

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

      Alternative 9: 45.9% accurate, 0.5× speedup?

      \[\begin{array}{l} \\ \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)\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-109}:\\ \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\\ \mathbf{elif}\;t\_0 \leq 10^{+116}:\\ \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\ \end{array} \end{array} \]
      (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))))))
         (if (<= t_0 -1e-109)
           (* (- d) (sqrt (/ 1.0 (* h l))))
           (if (<= t_0 1e+116)
             (/ (* (sqrt (/ h l)) d) h)
             (/ (fabs d) (sqrt (* l h)))))))
      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 tmp;
      	if (t_0 <= -1e-109) {
      		tmp = -d * sqrt((1.0 / (h * l)));
      	} else if (t_0 <= 1e+116) {
      		tmp = (sqrt((h / l)) * d) / h;
      	} else {
      		tmp = fabs(d) / sqrt((l * h));
      	}
      	return tmp;
      }
      
      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 / 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_0 <= (-1d-109)) then
              tmp = -d * sqrt((1.0d0 / (h * l)))
          else if (t_0 <= 1d+116) then
              tmp = (sqrt((h / l)) * d) / h
          else
              tmp = abs(d) / sqrt((l * h))
          end if
          code = tmp
      end function
      
      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 tmp;
      	if (t_0 <= -1e-109) {
      		tmp = -d * Math.sqrt((1.0 / (h * l)));
      	} else if (t_0 <= 1e+116) {
      		tmp = (Math.sqrt((h / l)) * d) / h;
      	} else {
      		tmp = Math.abs(d) / Math.sqrt((l * h));
      	}
      	return tmp;
      }
      
      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)))
      	tmp = 0
      	if t_0 <= -1e-109:
      		tmp = -d * math.sqrt((1.0 / (h * l)))
      	elif t_0 <= 1e+116:
      		tmp = (math.sqrt((h / l)) * d) / h
      	else:
      		tmp = math.fabs(d) / math.sqrt((l * h))
      	return tmp
      
      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))))
      	tmp = 0.0
      	if (t_0 <= -1e-109)
      		tmp = Float64(Float64(-d) * sqrt(Float64(1.0 / Float64(h * l))));
      	elseif (t_0 <= 1e+116)
      		tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h);
      	else
      		tmp = Float64(abs(d) / sqrt(Float64(l * h)));
      	end
      	return tmp
      end
      
      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)));
      	tmp = 0.0;
      	if (t_0 <= -1e-109)
      		tmp = -d * sqrt((1.0 / (h * l)));
      	elseif (t_0 <= 1e+116)
      		tmp = (sqrt((h / l)) * d) / h;
      	else
      		tmp = abs(d) / sqrt((l * h));
      	end
      	tmp_2 = tmp;
      end
      
      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]}, If[LessEqual[t$95$0, -1e-109], N[((-d) * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+116], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \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)\\
      \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-109}:\\
      \;\;\;\;\left(-d\right) \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
      
      \mathbf{elif}\;t\_0 \leq 10^{+116}:\\
      \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
      
      
      \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)))) < -9.9999999999999999e-110

        1. Initial program 65.6%

          \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
        2. 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. 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) \]
          10. 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) \]
          11. 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) \]
          12. 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) \]
          13. sqrt-unprodN/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) \]
          14. lower-sqrt.f64N/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) \]
          15. lower-*.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) \]
          16. 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) \]
          17. lift-/.f6455.0

            \[\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) \]
        3. Applied rewrites55.0%

          \[\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) \]
        4. Taylor expanded in d around -inf

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

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

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

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

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

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

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

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

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

        if -9.9999999999999999e-110 < (*.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.00000000000000002e116

        1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

        if 1.00000000000000002e116 < (*.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 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          15. lower-*.f649.6

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

          \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        8. Taylor expanded in h around inf

          \[\leadsto \sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
        9. Step-by-step derivation
          1. sqrt-divN/A

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

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

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

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

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

            \[\leadsto \frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          7. lift-fabs.f6442.9

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

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

            \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
          10. lower-*.f6442.9

            \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
        10. Applied rewrites42.9%

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

      Alternative 10: 44.9% accurate, 0.5× speedup?

      \[\begin{array}{l} \\ \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)\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-109}:\\ \;\;\;\;-\frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\ \mathbf{elif}\;t\_0 \leq 10^{+116}:\\ \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\ \end{array} \end{array} \]
      (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))))))
         (if (<= t_0 -1e-109)
           (- (/ (fabs d) (sqrt (* h l))))
           (if (<= t_0 1e+116)
             (/ (* (sqrt (/ h l)) d) h)
             (/ (fabs d) (sqrt (* l h)))))))
      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 tmp;
      	if (t_0 <= -1e-109) {
      		tmp = -(fabs(d) / sqrt((h * l)));
      	} else if (t_0 <= 1e+116) {
      		tmp = (sqrt((h / l)) * d) / h;
      	} else {
      		tmp = fabs(d) / sqrt((l * h));
      	}
      	return tmp;
      }
      
      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 / 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_0 <= (-1d-109)) then
              tmp = -(abs(d) / sqrt((h * l)))
          else if (t_0 <= 1d+116) then
              tmp = (sqrt((h / l)) * d) / h
          else
              tmp = abs(d) / sqrt((l * h))
          end if
          code = tmp
      end function
      
      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 tmp;
      	if (t_0 <= -1e-109) {
      		tmp = -(Math.abs(d) / Math.sqrt((h * l)));
      	} else if (t_0 <= 1e+116) {
      		tmp = (Math.sqrt((h / l)) * d) / h;
      	} else {
      		tmp = Math.abs(d) / Math.sqrt((l * h));
      	}
      	return tmp;
      }
      
      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)))
      	tmp = 0
      	if t_0 <= -1e-109:
      		tmp = -(math.fabs(d) / math.sqrt((h * l)))
      	elif t_0 <= 1e+116:
      		tmp = (math.sqrt((h / l)) * d) / h
      	else:
      		tmp = math.fabs(d) / math.sqrt((l * h))
      	return tmp
      
      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))))
      	tmp = 0.0
      	if (t_0 <= -1e-109)
      		tmp = Float64(-Float64(abs(d) / sqrt(Float64(h * l))));
      	elseif (t_0 <= 1e+116)
      		tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h);
      	else
      		tmp = Float64(abs(d) / sqrt(Float64(l * h)));
      	end
      	return tmp
      end
      
      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)));
      	tmp = 0.0;
      	if (t_0 <= -1e-109)
      		tmp = -(abs(d) / sqrt((h * l)));
      	elseif (t_0 <= 1e+116)
      		tmp = (sqrt((h / l)) * d) / h;
      	else
      		tmp = abs(d) / sqrt((l * h));
      	end
      	tmp_2 = tmp;
      end
      
      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]}, If[LessEqual[t$95$0, -1e-109], (-N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), If[LessEqual[t$95$0, 1e+116], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \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)\\
      \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-109}:\\
      \;\;\;\;-\frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\
      
      \mathbf{elif}\;t\_0 \leq 10^{+116}:\\
      \;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\
      
      
      \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)))) < -9.9999999999999999e-110

        1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          15. lower-*.f649.6

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

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

        if -9.9999999999999999e-110 < (*.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.00000000000000002e116

        1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

        if 1.00000000000000002e116 < (*.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 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          15. lower-*.f649.6

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

          \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        8. Taylor expanded in h around inf

          \[\leadsto \sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
        9. Step-by-step derivation
          1. sqrt-divN/A

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

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

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

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

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

            \[\leadsto \frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          7. lift-fabs.f6442.9

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

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

            \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
          10. lower-*.f6442.9

            \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
        10. Applied rewrites42.9%

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

      Alternative 11: 42.9% accurate, 0.9× speedup?

      \[\begin{array}{l} \\ \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 -1 \cdot 10^{-109}:\\ \;\;\;\;-\frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot h}}\\ \end{array} \end{array} \]
      (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))))
            -1e-109)
         (- (/ (fabs d) (sqrt (* h l))))
         (/ (fabs d) (sqrt (* l h)))))
      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)))) <= -1e-109) {
      		tmp = -(fabs(d) / sqrt((h * l)));
      	} else {
      		tmp = fabs(d) / sqrt((l * h));
      	}
      	return tmp;
      }
      
      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 (((((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-109)) then
              tmp = -(abs(d) / sqrt((h * l)))
          else
              tmp = abs(d) / sqrt((l * h))
          end if
          code = tmp
      end function
      
      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)))) <= -1e-109) {
      		tmp = -(Math.abs(d) / Math.sqrt((h * l)));
      	} else {
      		tmp = Math.abs(d) / Math.sqrt((l * h));
      	}
      	return tmp;
      }
      
      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)))) <= -1e-109:
      		tmp = -(math.fabs(d) / math.sqrt((h * l)))
      	else:
      		tmp = math.fabs(d) / math.sqrt((l * h))
      	return tmp
      
      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)))) <= -1e-109)
      		tmp = Float64(-Float64(abs(d) / sqrt(Float64(h * l))));
      	else
      		tmp = Float64(abs(d) / sqrt(Float64(l * h)));
      	end
      	return tmp
      end
      
      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)))) <= -1e-109)
      		tmp = -(abs(d) / sqrt((h * l)));
      	else
      		tmp = abs(d) / sqrt((l * h));
      	end
      	tmp_2 = tmp;
      end
      
      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], -1e-109], (-N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \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 -1 \cdot 10^{-109}:\\
      \;\;\;\;-\frac{\left|d\right|}{\sqrt{h \cdot \ell}}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\left|d\right|}{\sqrt{\ell \cdot 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)))) < -9.9999999999999999e-110

        1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          15. lower-*.f649.6

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

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

        if -9.9999999999999999e-110 < (*.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 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          15. lower-*.f649.6

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

          \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        8. Taylor expanded in h around inf

          \[\leadsto \sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
        9. Step-by-step derivation
          1. sqrt-divN/A

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

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

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

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

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

            \[\leadsto \frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
          7. lift-fabs.f6442.9

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

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

            \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
          10. lower-*.f6442.9

            \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
        10. Applied rewrites42.9%

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

      Alternative 12: 42.1% accurate, 9.0× speedup?

      \[\begin{array}{l} \\ \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \end{array} \]
      (FPCore (d h l M D) :precision binary64 (/ (fabs d) (sqrt (* l h))))
      double code(double d, double h, double l, double M, double D) {
      	return fabs(d) / sqrt((l * h));
      }
      
      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 = abs(d) / sqrt((l * h))
      end function
      
      public static double code(double d, double h, double l, double M, double D) {
      	return Math.abs(d) / Math.sqrt((l * h));
      }
      
      def code(d, h, l, M, D):
      	return math.fabs(d) / math.sqrt((l * h))
      
      function code(d, h, l, M, D)
      	return Float64(abs(d) / sqrt(Float64(l * h)))
      end
      
      function tmp = code(d, h, l, M, D)
      	tmp = abs(d) / sqrt((l * h));
      end
      
      code[d_, h_, l_, M_, D_] := N[(N[Abs[d], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \frac{\left|d\right|}{\sqrt{\ell \cdot h}}
      \end{array}
      
      Derivation
      1. Initial program 65.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        15. lower-*.f649.6

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

        \[\leadsto -\frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
      8. Taylor expanded in h around inf

        \[\leadsto \sqrt{\frac{{d}^{2}}{h \cdot \ell}} \]
      9. Step-by-step derivation
        1. sqrt-divN/A

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

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

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

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

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

          \[\leadsto \frac{\left|d\right|}{\sqrt{h \cdot \ell}} \]
        7. lift-fabs.f6442.9

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

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

          \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
        10. lower-*.f6442.9

          \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \]
      10. Applied rewrites42.9%

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

      Reproduce

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