Henrywood and Agarwal, Equation (12)

Percentage Accurate: 34.4% → 74.1%
Time: 10.5s
Alternatives: 12
Speedup: 10.2×

Specification

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

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

real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
    real(8), intent (in) :: d
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d_1
    code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
	return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D):
	return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D)
	return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l))))
end
function tmp = code(d, h, l, M, D)
	tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 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: 34.4% 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.1% accurate, 1.4× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := 1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\\ \mathbf{if}\;h \leq -1 \cdot 10^{+241}:\\ \;\;\;\;\left(\left(\frac{1}{\sqrt{\left(\left(d\_m \cdot d\_m\right) \cdot h\right) \cdot \ell}} \cdot d\_m\right) \cdot d\_m\right) \cdot t\_0\\ \mathbf{elif}\;h \leq -1 \cdot 10^{-298}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}} \cdot t\_0\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0
         (-
          1.0
          (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l)))))
   (if (<= h -1e+241)
     (* (* (* (/ 1.0 (sqrt (* (* (* d_m d_m) h) l))) d_m) d_m) t_0)
     (if (<= h -1e-298)
       (* (/ d_m (sqrt (* l h))) t_0)
       (* (/ d_m (* (sqrt l) (sqrt h))) t_0)))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = 1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l));
	double tmp;
	if (h <= -1e+241) {
		tmp = (((1.0 / sqrt((((d_m * d_m) * h) * l))) * d_m) * d_m) * t_0;
	} else if (h <= -1e-298) {
		tmp = (d_m / sqrt((l * h))) * t_0;
	} else {
		tmp = (d_m / (sqrt(l) * sqrt(h))) * t_0;
	}
	return tmp;
}
d_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l))
    if (h <= (-1d+241)) then
        tmp = (((1.0d0 / sqrt((((d_m * d_m) * h) * l))) * d_m) * d_m) * t_0
    else if (h <= (-1d-298)) then
        tmp = (d_m / sqrt((l * h))) * t_0
    else
        tmp = (d_m / (sqrt(l) * sqrt(h))) * t_0
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
	double t_0 = 1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l));
	double tmp;
	if (h <= -1e+241) {
		tmp = (((1.0 / Math.sqrt((((d_m * d_m) * h) * l))) * d_m) * d_m) * t_0;
	} else if (h <= -1e-298) {
		tmp = (d_m / Math.sqrt((l * h))) * t_0;
	} else {
		tmp = (d_m / (Math.sqrt(l) * Math.sqrt(h))) * t_0;
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = 1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l))
	tmp = 0
	if h <= -1e+241:
		tmp = (((1.0 / math.sqrt((((d_m * d_m) * h) * l))) * d_m) * d_m) * t_0
	elif h <= -1e-298:
		tmp = (d_m / math.sqrt((l * h))) * t_0
	else:
		tmp = (d_m / (math.sqrt(l) * math.sqrt(h))) * t_0
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))
	tmp = 0.0
	if (h <= -1e+241)
		tmp = Float64(Float64(Float64(Float64(1.0 / sqrt(Float64(Float64(Float64(d_m * d_m) * h) * l))) * d_m) * d_m) * t_0);
	elseif (h <= -1e-298)
		tmp = Float64(Float64(d_m / sqrt(Float64(l * h))) * t_0);
	else
		tmp = Float64(Float64(d_m / Float64(sqrt(l) * sqrt(h))) * t_0);
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = 1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l));
	tmp = 0.0;
	if (h <= -1e+241)
		tmp = (((1.0 / sqrt((((d_m * d_m) * h) * l))) * d_m) * d_m) * t_0;
	elseif (h <= -1e-298)
		tmp = (d_m / sqrt((l * h))) * t_0;
	else
		tmp = (d_m / (sqrt(l) * sqrt(h))) * t_0;
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -1e+241], N[(N[(N[(N[(1.0 / N[Sqrt[N[(N[(N[(d$95$m * d$95$m), $MachinePrecision] * h), $MachinePrecision] * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * d$95$m), $MachinePrecision] * d$95$m), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[h, -1e-298], N[(N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(d$95$m / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|

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

\mathbf{elif}\;h \leq -1 \cdot 10^{-298}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}} \cdot t\_0\\

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


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

    1. Initial program 34.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0000000000000001e241 < h < -9.99999999999999912e-299

    1. Initial program 34.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\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) \]
      8. frac-timesN/A

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\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) \]
      15. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\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) \]
      16. *-commutativeN/A

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

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

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

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

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

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

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

    if -9.99999999999999912e-299 < h

    1. Initial program 34.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\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) \]
      14. frac-timesN/A

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{d}^{1}}}{\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) \]
      20. unpow1N/A

        \[\leadsto \frac{\color{blue}{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) \]
      21. lower-/.f64N/A

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

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

        \[\leadsto \frac{d}{\color{blue}{\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) \]
      24. lower-sqrt.f6439.0

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \color{blue}{\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 rewrites39.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: 73.8% accurate, 1.6× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := 1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\\ \mathbf{if}\;h \leq -1 \cdot 10^{-298}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}} \cdot t\_0\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0
         (-
          1.0
          (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l)))))
   (if (<= h -1e-298)
     (* (/ d_m (sqrt (* l h))) t_0)
     (* (/ d_m (* (sqrt l) (sqrt h))) t_0))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = 1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l));
	double tmp;
	if (h <= -1e-298) {
		tmp = (d_m / sqrt((l * h))) * t_0;
	} else {
		tmp = (d_m / (sqrt(l) * sqrt(h))) * t_0;
	}
	return tmp;
}
d_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l))
    if (h <= (-1d-298)) then
        tmp = (d_m / sqrt((l * h))) * t_0
    else
        tmp = (d_m / (sqrt(l) * sqrt(h))) * t_0
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
	double t_0 = 1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l));
	double tmp;
	if (h <= -1e-298) {
		tmp = (d_m / Math.sqrt((l * h))) * t_0;
	} else {
		tmp = (d_m / (Math.sqrt(l) * Math.sqrt(h))) * t_0;
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = 1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l))
	tmp = 0
	if h <= -1e-298:
		tmp = (d_m / math.sqrt((l * h))) * t_0
	else:
		tmp = (d_m / (math.sqrt(l) * math.sqrt(h))) * t_0
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))
	tmp = 0.0
	if (h <= -1e-298)
		tmp = Float64(Float64(d_m / sqrt(Float64(l * h))) * t_0);
	else
		tmp = Float64(Float64(d_m / Float64(sqrt(l) * sqrt(h))) * t_0);
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = 1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l));
	tmp = 0.0;
	if (h <= -1e-298)
		tmp = (d_m / sqrt((l * h))) * t_0;
	else
		tmp = (d_m / (sqrt(l) * sqrt(h))) * t_0;
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -1e-298], N[(N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(d$95$m / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := 1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
\mathbf{if}\;h \leq -1 \cdot 10^{-298}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}} \cdot t\_0\\

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


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

    1. Initial program 34.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\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) \]
      8. frac-timesN/A

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\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) \]
      15. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\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) \]
      16. *-commutativeN/A

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

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

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

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

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

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

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

    if -9.99999999999999912e-299 < h

    1. Initial program 34.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\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) \]
      14. frac-timesN/A

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{d}^{1}}}{\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) \]
      20. unpow1N/A

        \[\leadsto \frac{\color{blue}{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) \]
      21. lower-/.f64N/A

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

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

        \[\leadsto \frac{d}{\color{blue}{\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) \]
      24. lower-sqrt.f6439.0

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

Alternative 3: 71.6% accurate, 0.4× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := 1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\\ t_1 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot t\_0\\ \mathbf{if}\;t\_1 \leq -2 \cdot 10^{-169}:\\ \;\;\;\;\frac{-0.125 \cdot \left(M \cdot \left(D \cdot M\right)\right)}{\left(\ell \cdot d\_m\right) \cdot \sqrt{\frac{1}{h} \cdot \ell}} \cdot D\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+222}:\\ \;\;\;\;\frac{\frac{d\_m}{\sqrt{h}}}{\sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}} \cdot t\_0\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0
         (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l))))
        (t_1
         (* (* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0))) t_0)))
   (if (<= t_1 -2e-169)
     (* (/ (* -0.125 (* M (* D M))) (* (* l d_m) (sqrt (* (/ 1.0 h) l)))) D)
     (if (<= t_1 2e+222)
       (/ (/ d_m (sqrt h)) (sqrt l))
       (* (/ d_m (sqrt (* l h))) t_0)))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = 1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l));
	double t_1 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * t_0;
	double tmp;
	if (t_1 <= -2e-169) {
		tmp = ((-0.125 * (M * (D * M))) / ((l * d_m) * sqrt(((1.0 / h) * l)))) * D;
	} else if (t_1 <= 2e+222) {
		tmp = (d_m / sqrt(h)) / sqrt(l);
	} else {
		tmp = (d_m / sqrt((l * h))) * t_0;
	}
	return tmp;
}
d_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l))
    t_1 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * t_0
    if (t_1 <= (-2d-169)) then
        tmp = (((-0.125d0) * (m * (d * m))) / ((l * d_m) * sqrt(((1.0d0 / h) * l)))) * d
    else if (t_1 <= 2d+222) then
        tmp = (d_m / sqrt(h)) / sqrt(l)
    else
        tmp = (d_m / sqrt((l * h))) * t_0
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
	double t_0 = 1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l));
	double t_1 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * t_0;
	double tmp;
	if (t_1 <= -2e-169) {
		tmp = ((-0.125 * (M * (D * M))) / ((l * d_m) * Math.sqrt(((1.0 / h) * l)))) * D;
	} else if (t_1 <= 2e+222) {
		tmp = (d_m / Math.sqrt(h)) / Math.sqrt(l);
	} else {
		tmp = (d_m / Math.sqrt((l * h))) * t_0;
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = 1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l))
	t_1 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * t_0
	tmp = 0
	if t_1 <= -2e-169:
		tmp = ((-0.125 * (M * (D * M))) / ((l * d_m) * math.sqrt(((1.0 / h) * l)))) * D
	elif t_1 <= 2e+222:
		tmp = (d_m / math.sqrt(h)) / math.sqrt(l)
	else:
		tmp = (d_m / math.sqrt((l * h))) * t_0
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))
	t_1 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * t_0)
	tmp = 0.0
	if (t_1 <= -2e-169)
		tmp = Float64(Float64(Float64(-0.125 * Float64(M * Float64(D * M))) / Float64(Float64(l * d_m) * sqrt(Float64(Float64(1.0 / h) * l)))) * D);
	elseif (t_1 <= 2e+222)
		tmp = Float64(Float64(d_m / sqrt(h)) / sqrt(l));
	else
		tmp = Float64(Float64(d_m / sqrt(Float64(l * h))) * t_0);
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = 1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l));
	t_1 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * t_0;
	tmp = 0.0;
	if (t_1 <= -2e-169)
		tmp = ((-0.125 * (M * (D * M))) / ((l * d_m) * sqrt(((1.0 / h) * l)))) * D;
	elseif (t_1 <= 2e+222)
		tmp = (d_m / sqrt(h)) / sqrt(l);
	else
		tmp = (d_m / sqrt((l * h))) * t_0;
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-169], N[(N[(N[(-0.125 * N[(M * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(l * d$95$m), $MachinePrecision] * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision], If[LessEqual[t$95$1, 2e+222], N[(N[(d$95$m / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], N[(N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := 1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\\
t_1 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-169}:\\
\;\;\;\;\frac{-0.125 \cdot \left(M \cdot \left(D \cdot M\right)\right)}{\left(\ell \cdot d\_m\right) \cdot \sqrt{\frac{1}{h} \cdot \ell}} \cdot D\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+222}:\\
\;\;\;\;\frac{\frac{d\_m}{\sqrt{h}}}{\sqrt{\ell}}\\

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


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

    1. Initial program 34.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{h} \cdot \color{blue}{\sqrt{\ell}}} \]
      6. associate-/r*N/A

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

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

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\color{blue}{\ell}}} \]
      9. lift-sqrt.f64N/A

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}} \]
      10. lift-sqrt.f6424.0

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}} \]
    6. Applied rewrites24.0%

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

    if 2.0000000000000001e222 < (*.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 34.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\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) \]
      8. frac-timesN/A

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\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) \]
      15. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\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) \]
      16. *-commutativeN/A

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

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

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

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

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

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

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

Alternative 4: 71.4% accurate, 0.4× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\ t_1 := M \cdot \frac{D}{d\_m + d\_m}\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-169}:\\ \;\;\;\;\frac{-0.125 \cdot \left(M \cdot \left(D \cdot M\right)\right)}{\left(\ell \cdot d\_m\right) \cdot \sqrt{\frac{1}{h} \cdot \ell}} \cdot D\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+222}:\\ \;\;\;\;\frac{\frac{d\_m}{\sqrt{h}}}{\sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(t\_1 \cdot t\_1\right)\right) \cdot \frac{h}{\ell}\right)\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0
         (*
          (* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
          (-
           1.0
           (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l)))))
        (t_1 (* M (/ D (+ d_m d_m)))))
   (if (<= t_0 -2e-169)
     (* (/ (* -0.125 (* M (* D M))) (* (* l d_m) (sqrt (* (/ 1.0 h) l)))) D)
     (if (<= t_0 2e+222)
       (/ (/ d_m (sqrt h)) (sqrt l))
       (*
        (/ d_m (sqrt (* l h)))
        (- 1.0 (* (* (/ 1.0 2.0) (* t_1 t_1)) (/ h l))))))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
	double t_1 = M * (D / (d_m + d_m));
	double tmp;
	if (t_0 <= -2e-169) {
		tmp = ((-0.125 * (M * (D * M))) / ((l * d_m) * sqrt(((1.0 / h) * l)))) * D;
	} else if (t_0 <= 2e+222) {
		tmp = (d_m / sqrt(h)) / sqrt(l);
	} else {
		tmp = (d_m / sqrt((l * h))) * (1.0 - (((1.0 / 2.0) * (t_1 * t_1)) * (h / l)));
	}
	return tmp;
}
d_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
    t_1 = m * (d / (d_m + d_m))
    if (t_0 <= (-2d-169)) then
        tmp = (((-0.125d0) * (m * (d * m))) / ((l * d_m) * sqrt(((1.0d0 / h) * l)))) * d
    else if (t_0 <= 2d+222) then
        tmp = (d_m / sqrt(h)) / sqrt(l)
    else
        tmp = (d_m / sqrt((l * h))) * (1.0d0 - (((1.0d0 / 2.0d0) * (t_1 * t_1)) * (h / l)))
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
	double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
	double t_1 = M * (D / (d_m + d_m));
	double tmp;
	if (t_0 <= -2e-169) {
		tmp = ((-0.125 * (M * (D * M))) / ((l * d_m) * Math.sqrt(((1.0 / h) * l)))) * D;
	} else if (t_0 <= 2e+222) {
		tmp = (d_m / Math.sqrt(h)) / Math.sqrt(l);
	} else {
		tmp = (d_m / Math.sqrt((l * h))) * (1.0 - (((1.0 / 2.0) * (t_1 * t_1)) * (h / l)));
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)))
	t_1 = M * (D / (d_m + d_m))
	tmp = 0
	if t_0 <= -2e-169:
		tmp = ((-0.125 * (M * (D * M))) / ((l * d_m) * math.sqrt(((1.0 / h) * l)))) * D
	elif t_0 <= 2e+222:
		tmp = (d_m / math.sqrt(h)) / math.sqrt(l)
	else:
		tmp = (d_m / math.sqrt((l * h))) * (1.0 - (((1.0 / 2.0) * (t_1 * t_1)) * (h / l)))
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l))))
	t_1 = Float64(M * Float64(D / Float64(d_m + d_m)))
	tmp = 0.0
	if (t_0 <= -2e-169)
		tmp = Float64(Float64(Float64(-0.125 * Float64(M * Float64(D * M))) / Float64(Float64(l * d_m) * sqrt(Float64(Float64(1.0 / h) * l)))) * D);
	elseif (t_0 <= 2e+222)
		tmp = Float64(Float64(d_m / sqrt(h)) / sqrt(l));
	else
		tmp = Float64(Float64(d_m / sqrt(Float64(l * h))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * Float64(t_1 * t_1)) * Float64(h / l))));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
	t_1 = M * (D / (d_m + d_m));
	tmp = 0.0;
	if (t_0 <= -2e-169)
		tmp = ((-0.125 * (M * (D * M))) / ((l * d_m) * sqrt(((1.0 / h) * l)))) * D;
	elseif (t_0 <= 2e+222)
		tmp = (d_m / sqrt(h)) / sqrt(l);
	else
		tmp = (d_m / sqrt((l * h))) * (1.0 - (((1.0 / 2.0) * (t_1 * t_1)) * (h / l)));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(M * N[(D / N[(d$95$m + d$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-169], N[(N[(N[(-0.125 * N[(M * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(l * d$95$m), $MachinePrecision] * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision], If[LessEqual[t$95$0, 2e+222], N[(N[(d$95$m / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], N[(N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := M \cdot \frac{D}{d\_m + d\_m}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-169}:\\
\;\;\;\;\frac{-0.125 \cdot \left(M \cdot \left(D \cdot M\right)\right)}{\left(\ell \cdot d\_m\right) \cdot \sqrt{\frac{1}{h} \cdot \ell}} \cdot D\\

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

\mathbf{else}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot \left(t\_1 \cdot t\_1\right)\right) \cdot \frac{h}{\ell}\right)\\


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

    1. Initial program 34.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{h} \cdot \color{blue}{\sqrt{\ell}}} \]
      6. associate-/r*N/A

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

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

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\color{blue}{\ell}}} \]
      9. lift-sqrt.f64N/A

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}} \]
      10. lift-sqrt.f6424.0

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}} \]
    6. Applied rewrites24.0%

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

    if 2.0000000000000001e222 < (*.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 34.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\sqrt{d}}{\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) \]
      8. frac-timesN/A

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\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) \]
      15. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\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) \]
      16. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 68.0% accurate, 0.4× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := M \cdot \left(D \cdot M\right)\\ t_1 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{if}\;t\_1 \leq -2 \cdot 10^{-169}:\\ \;\;\;\;\frac{-0.125 \cdot t\_0}{\left(\ell \cdot d\_m\right) \cdot \sqrt{\frac{1}{h} \cdot \ell}} \cdot D\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+222}:\\ \;\;\;\;\frac{\frac{d\_m}{\sqrt{h}}}{\sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d\_m}{\sqrt{h \cdot \ell}} \cdot \mathsf{fma}\left(\frac{-0.125 \cdot \left(t\_0 \cdot D\right)}{\left(d\_m \cdot d\_m\right) \cdot \ell}, h, 1\right)\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (* M (* D M)))
        (t_1
         (*
          (* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
          (-
           1.0
           (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l))))))
   (if (<= t_1 -2e-169)
     (* (/ (* -0.125 t_0) (* (* l d_m) (sqrt (* (/ 1.0 h) l)))) D)
     (if (<= t_1 2e+222)
       (/ (/ d_m (sqrt h)) (sqrt l))
       (*
        (/ d_m (sqrt (* h l)))
        (fma (/ (* -0.125 (* t_0 D)) (* (* d_m d_m) l)) h 1.0))))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = M * (D * M);
	double t_1 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
	double tmp;
	if (t_1 <= -2e-169) {
		tmp = ((-0.125 * t_0) / ((l * d_m) * sqrt(((1.0 / h) * l)))) * D;
	} else if (t_1 <= 2e+222) {
		tmp = (d_m / sqrt(h)) / sqrt(l);
	} else {
		tmp = (d_m / sqrt((h * l))) * fma(((-0.125 * (t_0 * D)) / ((d_m * d_m) * l)), h, 1.0);
	}
	return tmp;
}
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(M * Float64(D * M))
	t_1 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l))))
	tmp = 0.0
	if (t_1 <= -2e-169)
		tmp = Float64(Float64(Float64(-0.125 * t_0) / Float64(Float64(l * d_m) * sqrt(Float64(Float64(1.0 / h) * l)))) * D);
	elseif (t_1 <= 2e+222)
		tmp = Float64(Float64(d_m / sqrt(h)) / sqrt(l));
	else
		tmp = Float64(Float64(d_m / sqrt(Float64(h * l))) * fma(Float64(Float64(-0.125 * Float64(t_0 * D)) / Float64(Float64(d_m * d_m) * l)), h, 1.0));
	end
	return tmp
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(M * N[(D * M), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-169], N[(N[(N[(-0.125 * t$95$0), $MachinePrecision] / N[(N[(l * d$95$m), $MachinePrecision] * N[Sqrt[N[(N[(1.0 / h), $MachinePrecision] * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision], If[LessEqual[t$95$1, 2e+222], N[(N[(d$95$m / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], N[(N[(d$95$m / N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(-0.125 * N[(t$95$0 * D), $MachinePrecision]), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * h + 1.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := M \cdot \left(D \cdot M\right)\\
t_1 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-169}:\\
\;\;\;\;\frac{-0.125 \cdot t\_0}{\left(\ell \cdot d\_m\right) \cdot \sqrt{\frac{1}{h} \cdot \ell}} \cdot D\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+222}:\\
\;\;\;\;\frac{\frac{d\_m}{\sqrt{h}}}{\sqrt{\ell}}\\

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


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

    1. Initial program 34.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{h} \cdot \color{blue}{\sqrt{\ell}}} \]
      6. associate-/r*N/A

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

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

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\color{blue}{\ell}}} \]
      9. lift-sqrt.f64N/A

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}} \]
      10. lift-sqrt.f6424.0

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}} \]
    6. Applied rewrites24.0%

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

    if 2.0000000000000001e222 < (*.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 34.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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)} \]
    5. Step-by-step derivation
      1. fp-cancel-sub-sign-invN/A

        \[\leadsto \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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 \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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 \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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 \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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 \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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 \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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 \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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 \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \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 \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \mathsf{fma}\left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot {M}^{2}}{{d}^{2} \cdot \ell}, \color{blue}{h}, 1\right) \]
    6. Applied rewrites23.8%

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

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

Alternative 6: 49.7% accurate, 2.8× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;M \leq 1.26 \cdot 10^{-109}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(M \cdot \left(D \cdot M\right)\right) \cdot D\right) \cdot h}{\left(\ell \cdot d\_m\right) \cdot \sqrt{h \cdot \ell}} \cdot -0.125\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (if (<= M 1.26e-109)
   (/ d_m (sqrt (* l h)))
   (* (/ (* (* (* M (* D M)) D) h) (* (* l d_m) (sqrt (* h l)))) -0.125)))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double tmp;
	if (M <= 1.26e-109) {
		tmp = d_m / sqrt((l * h));
	} else {
		tmp = ((((M * (D * M)) * D) * h) / ((l * d_m) * sqrt((h * l)))) * -0.125;
	}
	return tmp;
}
d_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8) :: tmp
    if (m <= 1.26d-109) then
        tmp = d_m / sqrt((l * h))
    else
        tmp = ((((m * (d * m)) * d) * h) / ((l * d_m) * sqrt((h * l)))) * (-0.125d0)
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
	double tmp;
	if (M <= 1.26e-109) {
		tmp = d_m / Math.sqrt((l * h));
	} else {
		tmp = ((((M * (D * M)) * D) * h) / ((l * d_m) * Math.sqrt((h * l)))) * -0.125;
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	tmp = 0
	if M <= 1.26e-109:
		tmp = d_m / math.sqrt((l * h))
	else:
		tmp = ((((M * (D * M)) * D) * h) / ((l * d_m) * math.sqrt((h * l)))) * -0.125
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	tmp = 0.0
	if (M <= 1.26e-109)
		tmp = Float64(d_m / sqrt(Float64(l * h)));
	else
		tmp = Float64(Float64(Float64(Float64(Float64(M * Float64(D * M)) * D) * h) / Float64(Float64(l * d_m) * sqrt(Float64(h * l)))) * -0.125);
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	tmp = 0.0;
	if (M <= 1.26e-109)
		tmp = d_m / sqrt((l * h));
	else
		tmp = ((((M * (D * M)) * D) * h) / ((l * d_m) * sqrt((h * l)))) * -0.125;
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[M, 1.26e-109], N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(M * N[(D * M), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision] * h), $MachinePrecision] / N[(N[(l * d$95$m), $MachinePrecision] * N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.26 \cdot 10^{-109}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}}\\

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


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

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
      8. lower-*.f6443.1

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

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

    if 1.26000000000000007e-109 < M

    1. Initial program 34.4%

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

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

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

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

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

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

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

Alternative 7: 48.4% accurate, 2.8× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;M \leq 2.6 \cdot 10^{-99}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\frac{\left(M \cdot M\right) \cdot h}{\left(\ell \cdot d\_m\right) \cdot \sqrt{h \cdot \ell}} \cdot -0.125\right) \cdot D\right) \cdot D\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (if (<= M 2.6e-99)
   (/ d_m (sqrt (* l h)))
   (* (* (* (/ (* (* M M) h) (* (* l d_m) (sqrt (* h l)))) -0.125) D) D)))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double tmp;
	if (M <= 2.6e-99) {
		tmp = d_m / sqrt((l * h));
	} else {
		tmp = (((((M * M) * h) / ((l * d_m) * sqrt((h * l)))) * -0.125) * D) * D;
	}
	return tmp;
}
d_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8) :: tmp
    if (m <= 2.6d-99) then
        tmp = d_m / sqrt((l * h))
    else
        tmp = (((((m * m) * h) / ((l * d_m) * sqrt((h * l)))) * (-0.125d0)) * d) * d
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
	double tmp;
	if (M <= 2.6e-99) {
		tmp = d_m / Math.sqrt((l * h));
	} else {
		tmp = (((((M * M) * h) / ((l * d_m) * Math.sqrt((h * l)))) * -0.125) * D) * D;
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	tmp = 0
	if M <= 2.6e-99:
		tmp = d_m / math.sqrt((l * h))
	else:
		tmp = (((((M * M) * h) / ((l * d_m) * math.sqrt((h * l)))) * -0.125) * D) * D
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	tmp = 0.0
	if (M <= 2.6e-99)
		tmp = Float64(d_m / sqrt(Float64(l * h)));
	else
		tmp = Float64(Float64(Float64(Float64(Float64(Float64(M * M) * h) / Float64(Float64(l * d_m) * sqrt(Float64(h * l)))) * -0.125) * D) * D);
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	tmp = 0.0;
	if (M <= 2.6e-99)
		tmp = d_m / sqrt((l * h));
	else
		tmp = (((((M * M) * h) / ((l * d_m) * sqrt((h * l)))) * -0.125) * D) * D;
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[M, 2.6e-99], N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(M * M), $MachinePrecision] * h), $MachinePrecision] / N[(N[(l * d$95$m), $MachinePrecision] * N[Sqrt[N[(h * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * D), $MachinePrecision] * D), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
\mathbf{if}\;M \leq 2.6 \cdot 10^{-99}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}}\\

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


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

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
      8. lower-*.f6443.1

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

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

    if 2.60000000000000005e-99 < M

    1. Initial program 34.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\left(\frac{\left(M \cdot M\right) \cdot h}{\left(\ell \cdot d\right) \cdot \sqrt{h \cdot \ell}} \cdot -0.125\right) \cdot D\right) \cdot D \]
    6. Applied rewrites32.5%

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

Alternative 8: 46.8% accurate, 0.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-169}:\\ \;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot d\_m}} \cdot d\_m\right) \cdot \left(-\sqrt{\frac{1}{h \cdot d\_m}} \cdot d\_m\right)\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+222}:\\ \;\;\;\;\frac{\frac{d\_m}{\sqrt{h}}}{\sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0
         (*
          (* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
          (-
           1.0
           (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l))))))
   (if (<= t_0 -2e-169)
     (* (* (sqrt (/ 1.0 (* l d_m))) d_m) (- (* (sqrt (/ 1.0 (* h d_m))) d_m)))
     (if (<= t_0 2e+222)
       (/ (/ d_m (sqrt h)) (sqrt l))
       (/ d_m (sqrt (* l h)))))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
	double tmp;
	if (t_0 <= -2e-169) {
		tmp = (sqrt((1.0 / (l * d_m))) * d_m) * -(sqrt((1.0 / (h * d_m))) * d_m);
	} else if (t_0 <= 2e+222) {
		tmp = (d_m / sqrt(h)) / sqrt(l);
	} else {
		tmp = d_m / sqrt((l * h));
	}
	return tmp;
}
d_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
    if (t_0 <= (-2d-169)) then
        tmp = (sqrt((1.0d0 / (l * d_m))) * d_m) * -(sqrt((1.0d0 / (h * d_m))) * d_m)
    else if (t_0 <= 2d+222) then
        tmp = (d_m / sqrt(h)) / sqrt(l)
    else
        tmp = d_m / sqrt((l * h))
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
	double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
	double tmp;
	if (t_0 <= -2e-169) {
		tmp = (Math.sqrt((1.0 / (l * d_m))) * d_m) * -(Math.sqrt((1.0 / (h * d_m))) * d_m);
	} else if (t_0 <= 2e+222) {
		tmp = (d_m / Math.sqrt(h)) / Math.sqrt(l);
	} else {
		tmp = d_m / Math.sqrt((l * h));
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)))
	tmp = 0
	if t_0 <= -2e-169:
		tmp = (math.sqrt((1.0 / (l * d_m))) * d_m) * -(math.sqrt((1.0 / (h * d_m))) * d_m)
	elif t_0 <= 2e+222:
		tmp = (d_m / math.sqrt(h)) / math.sqrt(l)
	else:
		tmp = d_m / math.sqrt((l * h))
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l))))
	tmp = 0.0
	if (t_0 <= -2e-169)
		tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * d_m))) * d_m) * Float64(-Float64(sqrt(Float64(1.0 / Float64(h * d_m))) * d_m)));
	elseif (t_0 <= 2e+222)
		tmp = Float64(Float64(d_m / sqrt(h)) / sqrt(l));
	else
		tmp = Float64(d_m / sqrt(Float64(l * h)));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
	tmp = 0.0;
	if (t_0 <= -2e-169)
		tmp = (sqrt((1.0 / (l * d_m))) * d_m) * -(sqrt((1.0 / (h * d_m))) * d_m);
	elseif (t_0 <= 2e+222)
		tmp = (d_m / sqrt(h)) / sqrt(l);
	else
		tmp = d_m / sqrt((l * h));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-169], N[(N[(N[Sqrt[N[(1.0 / N[(l * d$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision] * (-N[(N[Sqrt[N[(1.0 / N[(h * d$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d$95$m), $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$0, 2e+222], N[(N[(d$95$m / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-169}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot d\_m}} \cdot d\_m\right) \cdot \left(-\sqrt{\frac{1}{h \cdot d\_m}} \cdot d\_m\right)\\

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

\mathbf{else}:\\
\;\;\;\;\frac{d\_m}{\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)))) < -2.00000000000000004e-169

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{1}{\ell \cdot d}} \cdot d\right) \cdot \sqrt{\frac{d}{h}} \]
      6. lift-*.f6417.4

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{1}{\ell \cdot d}} \cdot d\right) \cdot \left(-\sqrt{\frac{1}{h \cdot d}} \cdot d\right) \]
    8. Applied rewrites7.5%

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

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

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{h} \cdot \color{blue}{\sqrt{\ell}}} \]
      6. associate-/r*N/A

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

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

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\color{blue}{\ell}}} \]
      9. lift-sqrt.f64N/A

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}} \]
      10. lift-sqrt.f6424.0

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}} \]
    6. Applied rewrites24.0%

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

    if 2.0000000000000001e222 < (*.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 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
      8. lower-*.f6443.1

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

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

Alternative 9: 46.5% accurate, 0.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-169}:\\ \;\;\;\;\frac{d\_m}{-\sqrt{\frac{\ell}{h}} \cdot h}\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+222}:\\ \;\;\;\;\frac{\frac{d\_m}{\sqrt{h}}}{\sqrt{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0
         (*
          (* (pow (/ d_m h) (/ 1.0 2.0)) (pow (/ d_m l) (/ 1.0 2.0)))
          (-
           1.0
           (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d_m)) 2.0)) (/ h l))))))
   (if (<= t_0 -2e-169)
     (/ d_m (- (* (sqrt (/ l h)) h)))
     (if (<= t_0 2e+222)
       (/ (/ d_m (sqrt h)) (sqrt l))
       (/ d_m (sqrt (* l h)))))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = (pow((d_m / h), (1.0 / 2.0)) * pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
	double tmp;
	if (t_0 <= -2e-169) {
		tmp = d_m / -(sqrt((l / h)) * h);
	} else if (t_0 <= 2e+222) {
		tmp = (d_m / sqrt(h)) / sqrt(l);
	} else {
		tmp = d_m / sqrt((l * h));
	}
	return tmp;
}
d_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (((d_m / h) ** (1.0d0 / 2.0d0)) * ((d_m / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
    if (t_0 <= (-2d-169)) then
        tmp = d_m / -(sqrt((l / h)) * h)
    else if (t_0 <= 2d+222) then
        tmp = (d_m / sqrt(h)) / sqrt(l)
    else
        tmp = d_m / sqrt((l * h))
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
	double t_0 = (Math.pow((d_m / h), (1.0 / 2.0)) * Math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)));
	double tmp;
	if (t_0 <= -2e-169) {
		tmp = d_m / -(Math.sqrt((l / h)) * h);
	} else if (t_0 <= 2e+222) {
		tmp = (d_m / Math.sqrt(h)) / Math.sqrt(l);
	} else {
		tmp = d_m / Math.sqrt((l * h));
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = (math.pow((d_m / h), (1.0 / 2.0)) * math.pow((d_m / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d_m)), 2.0)) * (h / l)))
	tmp = 0
	if t_0 <= -2e-169:
		tmp = d_m / -(math.sqrt((l / h)) * h)
	elif t_0 <= 2e+222:
		tmp = (d_m / math.sqrt(h)) / math.sqrt(l)
	else:
		tmp = d_m / math.sqrt((l * h))
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = Float64(Float64((Float64(d_m / h) ^ Float64(1.0 / 2.0)) * (Float64(d_m / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l))))
	tmp = 0.0
	if (t_0 <= -2e-169)
		tmp = Float64(d_m / Float64(-Float64(sqrt(Float64(l / h)) * h)));
	elseif (t_0 <= 2e+222)
		tmp = Float64(Float64(d_m / sqrt(h)) / sqrt(l));
	else
		tmp = Float64(d_m / sqrt(Float64(l * h)));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = (((d_m / h) ^ (1.0 / 2.0)) * ((d_m / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d_m)) ^ 2.0)) * (h / l)));
	tmp = 0.0;
	if (t_0 <= -2e-169)
		tmp = d_m / -(sqrt((l / h)) * h);
	elseif (t_0 <= 2e+222)
		tmp = (d_m / sqrt(h)) / sqrt(l);
	else
		tmp = d_m / sqrt((l * h));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d$95$m / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-169], N[(d$95$m / (-N[(N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision] * h), $MachinePrecision])), $MachinePrecision], If[LessEqual[t$95$0, 2e+222], N[(N[(d$95$m / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \left({\left(\frac{d\_m}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d\_m}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-169}:\\
\;\;\;\;\frac{d\_m}{-\sqrt{\frac{\ell}{h}} \cdot h}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{d\_m}{\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)))) < -2.00000000000000004e-169

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
      8. lower-*.f6443.1

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

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]
    7. Taylor expanded in h around -inf

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

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

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

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

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

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

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

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

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

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{h} \cdot \color{blue}{\sqrt{\ell}}} \]
      6. associate-/r*N/A

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

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

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\color{blue}{\ell}}} \]
      9. lift-sqrt.f64N/A

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}} \]
      10. lift-sqrt.f6424.0

        \[\leadsto \frac{\frac{d}{\sqrt{h}}}{\sqrt{\ell}} \]
    6. Applied rewrites24.0%

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

    if 2.0000000000000001e222 < (*.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 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
      8. lower-*.f6443.1

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

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

Alternative 10: 46.4% accurate, 4.6× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;\ell \leq -1 \cdot 10^{-189}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-307}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\frac{\ell}{h}} \cdot h}\\ \mathbf{else}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (if (<= l -1e-189)
   (/ d_m (sqrt (* l h)))
   (if (<= l -2e-307)
     (/ d_m (* (sqrt (/ l h)) h))
     (/ d_m (* (sqrt l) (sqrt h))))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double tmp;
	if (l <= -1e-189) {
		tmp = d_m / sqrt((l * h));
	} else if (l <= -2e-307) {
		tmp = d_m / (sqrt((l / h)) * h);
	} else {
		tmp = d_m / (sqrt(l) * sqrt(h));
	}
	return tmp;
}
d_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8) :: tmp
    if (l <= (-1d-189)) then
        tmp = d_m / sqrt((l * h))
    else if (l <= (-2d-307)) then
        tmp = d_m / (sqrt((l / h)) * h)
    else
        tmp = d_m / (sqrt(l) * sqrt(h))
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
	double tmp;
	if (l <= -1e-189) {
		tmp = d_m / Math.sqrt((l * h));
	} else if (l <= -2e-307) {
		tmp = d_m / (Math.sqrt((l / h)) * h);
	} else {
		tmp = d_m / (Math.sqrt(l) * Math.sqrt(h));
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	tmp = 0
	if l <= -1e-189:
		tmp = d_m / math.sqrt((l * h))
	elif l <= -2e-307:
		tmp = d_m / (math.sqrt((l / h)) * h)
	else:
		tmp = d_m / (math.sqrt(l) * math.sqrt(h))
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	tmp = 0.0
	if (l <= -1e-189)
		tmp = Float64(d_m / sqrt(Float64(l * h)));
	elseif (l <= -2e-307)
		tmp = Float64(d_m / Float64(sqrt(Float64(l / h)) * h));
	else
		tmp = Float64(d_m / Float64(sqrt(l) * sqrt(h)));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	tmp = 0.0;
	if (l <= -1e-189)
		tmp = d_m / sqrt((l * h));
	elseif (l <= -2e-307)
		tmp = d_m / (sqrt((l / h)) * h);
	else
		tmp = d_m / (sqrt(l) * sqrt(h));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[l, -1e-189], N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -2e-307], N[(d$95$m / N[(N[Sqrt[N[(l / h), $MachinePrecision]], $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision], N[(d$95$m / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{-189}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}}\\

\mathbf{elif}\;\ell \leq -2 \cdot 10^{-307}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\frac{\ell}{h}} \cdot h}\\

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


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

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
      8. lower-*.f6443.1

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

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

    if -1.00000000000000007e-189 < l < -1.99999999999999982e-307

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
      8. lower-*.f6443.1

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

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]
    7. Taylor expanded in h around inf

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

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

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

        \[\leadsto \frac{d}{\sqrt{\frac{\ell}{h}} \cdot h} \]
      4. lower-/.f6424.9

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

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

    if -1.99999999999999982e-307 < l

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

Alternative 11: 46.2% accurate, 6.3× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2 \cdot 10^{-307}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (if (<= l -2e-307) (/ d_m (sqrt (* l h))) (/ d_m (* (sqrt l) (sqrt h)))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double tmp;
	if (l <= -2e-307) {
		tmp = d_m / sqrt((l * h));
	} else {
		tmp = d_m / (sqrt(l) * sqrt(h));
	}
	return tmp;
}
d_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    real(8) :: tmp
    if (l <= (-2d-307)) then
        tmp = d_m / sqrt((l * h))
    else
        tmp = d_m / (sqrt(l) * sqrt(h))
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
	double tmp;
	if (l <= -2e-307) {
		tmp = d_m / Math.sqrt((l * h));
	} else {
		tmp = d_m / (Math.sqrt(l) * Math.sqrt(h));
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	tmp = 0
	if l <= -2e-307:
		tmp = d_m / math.sqrt((l * h))
	else:
		tmp = d_m / (math.sqrt(l) * math.sqrt(h))
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	tmp = 0.0
	if (l <= -2e-307)
		tmp = Float64(d_m / sqrt(Float64(l * h)));
	else
		tmp = Float64(d_m / Float64(sqrt(l) * sqrt(h)));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	tmp = 0.0;
	if (l <= -2e-307)
		tmp = d_m / sqrt((l * h));
	else
		tmp = d_m / (sqrt(l) * sqrt(h));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[l, -2e-307], N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(d$95$m / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -2 \cdot 10^{-307}:\\
\;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}}\\

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


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

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

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

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

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

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
      8. lower-*.f6443.1

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

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

    if -1.99999999999999982e-307 < l

    1. Initial program 34.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
      7. pow1/2N/A

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

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

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

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

        \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
      12. unpow1N/A

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

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

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

        \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
      16. lower-sqrt.f6424.8

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

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

Alternative 12: 43.1% accurate, 10.2× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \frac{d\_m}{\sqrt{\ell \cdot h}} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D) :precision binary64 (/ d_m (sqrt (* l h))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	return d_m / sqrt((l * h));
}
d_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(d_m, h, l, m, d)
use fmin_fmax_functions
    real(8), intent (in) :: d_m
    real(8), intent (in) :: h
    real(8), intent (in) :: l
    real(8), intent (in) :: m
    real(8), intent (in) :: d
    code = d_m / sqrt((l * h))
end function
d_m = Math.abs(d);
public static double code(double d_m, double h, double l, double M, double D) {
	return d_m / Math.sqrt((l * h));
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	return d_m / math.sqrt((l * h))
d_m = abs(d)
function code(d_m, h, l, M, D)
	return Float64(d_m / sqrt(Float64(l * h)))
end
d_m = abs(d);
function tmp = code(d_m, h, l, M, D)
	tmp = d_m / sqrt((l * h));
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|

\\
\frac{d\_m}{\sqrt{\ell \cdot h}}
\end{array}
Derivation
  1. Initial program 34.4%

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

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

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

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

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

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

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

      \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\color{blue}{\sqrt{\ell} \cdot \sqrt{h}}} \]
    7. pow1/2N/A

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

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

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

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

      \[\leadsto \frac{{d}^{1}}{\color{blue}{\sqrt{\ell}} \cdot \sqrt{h}} \]
    12. unpow1N/A

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

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

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

      \[\leadsto \frac{d}{\sqrt{\ell} \cdot \sqrt{\color{blue}{h}}} \]
    16. lower-sqrt.f6424.8

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

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

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

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

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

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

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

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

      \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
    8. lower-*.f6443.1

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

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

Reproduce

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