Henrywood and Agarwal, Equation (12)

Percentage Accurate: 35.8% → 75.7%
Time: 12.2s
Alternatives: 17
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 17 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: 35.8% 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: 75.7% accurate, 1.4× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if h < -9.9999999999999998e184

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

    if -9.9999999999999998e184 < h < -1.99999999999999998e132

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\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) \]
      6. sqrt-unprodN/A

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

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

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

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

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

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

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

    if -1.99999999999999998e132 < h < 8.79999999999999983e-277

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{1}{h \cdot \ell}} \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) \]
    6. Applied rewrites69.3%

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

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

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

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

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

        \[\leadsto \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) \]
      2. frac-timesN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{{d}^{2}}}{\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) \]
      11. pow2N/A

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

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

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

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

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

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      17. lift-*.f6469.5

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

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

    if 8.79999999999999983e-277 < h

    1. Initial program 35.8%

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

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

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

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

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\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.8

        \[\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.8%

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

Alternative 2: 75.5% accurate, 1.5× speedup?

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

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

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

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


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

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

    if -5.0000000000000002e237 < h < 8.79999999999999983e-277

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{1}{h \cdot \ell}} \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) \]
    6. Applied rewrites69.3%

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

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

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

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

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

        \[\leadsto \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) \]
      2. frac-timesN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{{d}^{2}}}{\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) \]
      11. pow2N/A

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

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

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

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

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

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      17. lift-*.f6469.5

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

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

    if 8.79999999999999983e-277 < h

    1. Initial program 35.8%

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

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

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

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

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\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.8

        \[\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.8%

      \[\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 3: 72.0% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := M \cdot \frac{D}{d\_m + d\_m}\\
t_2 := \left(M \cdot \left(D \cdot M\right)\right) \cdot D\\
\mathbf{if}\;h \leq -5 \cdot 10^{+237}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t\_2 \cdot h}{\left(t\_0 \cdot \ell\right) \cdot d\_m}, -0.125, \frac{d\_m}{t\_0}\right)\\

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

\mathbf{elif}\;h \leq 1.65 \cdot 10^{+236}:\\
\;\;\;\;\sqrt{\frac{d\_m}{h}} \cdot \left(\sqrt{\frac{d\_m}{\ell}} \cdot \left(1 - \left(\left(t\_1 \cdot t\_1\right) \cdot 0.5\right) \cdot \frac{h}{\ell}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if h < -5.0000000000000002e237

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

    if -5.0000000000000002e237 < h < 2.9000000000000001e116

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{\frac{1}{h \cdot \ell}} \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) \]
    6. Applied rewrites69.3%

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

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

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

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

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

        \[\leadsto \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) \]
      2. frac-timesN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{{d}^{2}}}{\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) \]
      11. pow2N/A

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

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

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

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

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

        \[\leadsto \frac{\left|d\right|}{\sqrt{\ell \cdot h}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      17. lift-*.f6469.5

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

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

    if 2.9000000000000001e116 < h < 1.6499999999999999e236

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.6499999999999999e236 < h

    1. Initial program 35.8%

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

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

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

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

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

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

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

Alternative 4: 71.9% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{d\_m}{\sqrt{\ell} \cdot \sqrt{h}}\\
t_1 := M \cdot \frac{D}{d\_m + d\_m}\\
\mathbf{if}\;\ell \leq -2 \cdot 10^{+243}:\\
\;\;\;\;\sqrt{\frac{d\_m}{\ell} \cdot \frac{d\_m}{h}}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if l < -2.0000000000000001e243

    1. Initial program 35.8%

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

      \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.25} \cdot \left({\left(\frac{d}{h}\right)}^{0.25} \cdot \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)\right)} \]
    3. Taylor expanded in h around 0

      \[\leadsto \color{blue}{{\left(e^{\frac{1}{4} \cdot \left(\log d + -1 \cdot \log h\right)}\right)}^{2} \cdot \sqrt{\frac{d}{\ell}}} \]
    4. Applied rewrites43.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e243 < l < 5.00000000000000018e61

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000018e61 < l

    1. Initial program 35.8%

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

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

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

Alternative 5: 68.7% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := M \cdot \frac{D}{d\_m + d\_m}\\
t_2 := \left(M \cdot \left(D \cdot M\right)\right) \cdot D\\
\mathbf{if}\;h \leq -5 \cdot 10^{+192}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t\_2 \cdot h}{\left(t\_0 \cdot \ell\right) \cdot d\_m}, -0.125, \frac{d\_m}{t\_0}\right)\\

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

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


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

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

    if -5.00000000000000033e192 < h < 4.35000000000000017e210

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.35000000000000017e210 < h

    1. Initial program 35.8%

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

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

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

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

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

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

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

Alternative 6: 54.6% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
t_1 := \frac{d\_m}{t\_0}\\
\mathbf{if}\;M \cdot D \leq 5 \cdot 10^{-151}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;M \cdot D \leq 2 \cdot 10^{+188}:\\
\;\;\;\;\sqrt{\frac{d\_m}{\ell} \cdot \frac{d\_m}{h}}\\

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


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

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000003e-151 < (*.f64 M D) < 9.99999999999999925e125

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

    if 9.99999999999999925e125 < (*.f64 M D) < 2e188

    1. Initial program 35.8%

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

      \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.25} \cdot \left({\left(\frac{d}{h}\right)}^{0.25} \cdot \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)\right)} \]
    3. Taylor expanded in h around 0

      \[\leadsto \color{blue}{{\left(e^{\frac{1}{4} \cdot \left(\log d + -1 \cdot \log h\right)}\right)}^{2} \cdot \sqrt{\frac{d}{\ell}}} \]
    4. Applied rewrites43.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e188 < (*.f64 M D)

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 51.9% accurate, 2.7× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;M \leq 4.1 \cdot 10^{-116}:\\ \;\;\;\;\frac{d\_m}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{t\_0 \cdot d\_m} \cdot -0.125}{\ell}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (* l h))))
   (if (<= M 4.1e-116)
     (/ d_m t_0)
     (/ (* (/ (* (* (* M M) h) (* D D)) (* t_0 d_m)) -0.125) l))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = sqrt((l * h));
	double tmp;
	if (M <= 4.1e-116) {
		tmp = d_m / t_0;
	} else {
		tmp = (((((M * M) * h) * (D * D)) / (t_0 * d_m)) * -0.125) / 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) :: tmp
    t_0 = sqrt((l * h))
    if (m <= 4.1d-116) then
        tmp = d_m / t_0
    else
        tmp = (((((m * m) * h) * (d * d)) / (t_0 * d_m)) * (-0.125d0)) / 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.sqrt((l * h));
	double tmp;
	if (M <= 4.1e-116) {
		tmp = d_m / t_0;
	} else {
		tmp = (((((M * M) * h) * (D * D)) / (t_0 * d_m)) * -0.125) / l;
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = math.sqrt((l * h))
	tmp = 0
	if M <= 4.1e-116:
		tmp = d_m / t_0
	else:
		tmp = (((((M * M) * h) * (D * D)) / (t_0 * d_m)) * -0.125) / l
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (M <= 4.1e-116)
		tmp = Float64(d_m / t_0);
	else
		tmp = Float64(Float64(Float64(Float64(Float64(Float64(M * M) * h) * Float64(D * D)) / Float64(t_0 * d_m)) * -0.125) / l);
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = sqrt((l * h));
	tmp = 0.0;
	if (M <= 4.1e-116)
		tmp = d_m / t_0;
	else
		tmp = (((((M * M) * h) * (D * D)) / (t_0 * d_m)) * -0.125) / 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[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, 4.1e-116], N[(d$95$m / t$95$0), $MachinePrecision], N[(N[(N[(N[(N[(N[(M * M), $MachinePrecision] * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * d$95$m), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] / l), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;M \leq 4.1 \cdot 10^{-116}:\\
\;\;\;\;\frac{d\_m}{t\_0}\\

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


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

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0999999999999999e-116 < M

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 47.0% accurate, 2.8× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;M \leq 1.06 \cdot 10^{-69}:\\ \;\;\;\;\frac{d\_m}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(M \cdot M\right) \cdot h\right) \cdot \left(D \cdot D\right)}{\left(\ell \cdot d\_m\right) \cdot t\_0} \cdot -0.125\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (* l h))))
   (if (<= M 1.06e-69)
     (/ d_m t_0)
     (* (/ (* (* (* M M) h) (* D D)) (* (* l d_m) t_0)) -0.125))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = sqrt((l * h));
	double tmp;
	if (M <= 1.06e-69) {
		tmp = d_m / t_0;
	} else {
		tmp = ((((M * M) * h) * (D * D)) / ((l * d_m) * t_0)) * -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) :: t_0
    real(8) :: tmp
    t_0 = sqrt((l * h))
    if (m <= 1.06d-69) then
        tmp = d_m / t_0
    else
        tmp = ((((m * m) * h) * (d * d)) / ((l * d_m) * t_0)) * (-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 t_0 = Math.sqrt((l * h));
	double tmp;
	if (M <= 1.06e-69) {
		tmp = d_m / t_0;
	} else {
		tmp = ((((M * M) * h) * (D * D)) / ((l * d_m) * t_0)) * -0.125;
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = math.sqrt((l * h))
	tmp = 0
	if M <= 1.06e-69:
		tmp = d_m / t_0
	else:
		tmp = ((((M * M) * h) * (D * D)) / ((l * d_m) * t_0)) * -0.125
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (M <= 1.06e-69)
		tmp = Float64(d_m / t_0);
	else
		tmp = Float64(Float64(Float64(Float64(Float64(M * M) * h) * Float64(D * D)) / Float64(Float64(l * d_m) * t_0)) * -0.125);
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = sqrt((l * h));
	tmp = 0.0;
	if (M <= 1.06e-69)
		tmp = d_m / t_0;
	else
		tmp = ((((M * M) * h) * (D * D)) / ((l * d_m) * t_0)) * -0.125;
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, 1.06e-69], N[(d$95$m / t$95$0), $MachinePrecision], N[(N[(N[(N[(N[(M * M), $MachinePrecision] * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision] / N[(N[(l * d$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;M \leq 1.06 \cdot 10^{-69}:\\
\;\;\;\;\frac{d\_m}{t\_0}\\

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


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

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.05999999999999997e-69 < M

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

Alternative 9: 46.2% accurate, 2.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;M \cdot D \leq 2 \cdot 10^{+19}:\\ \;\;\;\;\frac{d\_m}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\left(M \cdot \left(D \cdot M\right)\right) \cdot D}{\left(t\_0 \cdot \ell\right) \cdot d\_m} \cdot -0.125\right) \cdot h\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (* l h))))
   (if (<= (* M D) 2e+19)
     (/ d_m t_0)
     (* (* (/ (* (* M (* D M)) D) (* (* t_0 l) d_m)) -0.125) h))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = sqrt((l * h));
	double tmp;
	if ((M * D) <= 2e+19) {
		tmp = d_m / t_0;
	} else {
		tmp = ((((M * (D * M)) * D) / ((t_0 * l) * d_m)) * -0.125) * 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 = sqrt((l * h))
    if ((m * d) <= 2d+19) then
        tmp = d_m / t_0
    else
        tmp = ((((m * (d * m)) * d) / ((t_0 * l) * d_m)) * (-0.125d0)) * 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.sqrt((l * h));
	double tmp;
	if ((M * D) <= 2e+19) {
		tmp = d_m / t_0;
	} else {
		tmp = ((((M * (D * M)) * D) / ((t_0 * l) * d_m)) * -0.125) * h;
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = math.sqrt((l * h))
	tmp = 0
	if (M * D) <= 2e+19:
		tmp = d_m / t_0
	else:
		tmp = ((((M * (D * M)) * D) / ((t_0 * l) * d_m)) * -0.125) * h
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (Float64(M * D) <= 2e+19)
		tmp = Float64(d_m / t_0);
	else
		tmp = Float64(Float64(Float64(Float64(Float64(M * Float64(D * M)) * D) / Float64(Float64(t_0 * l) * d_m)) * -0.125) * h);
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = sqrt((l * h));
	tmp = 0.0;
	if ((M * D) <= 2e+19)
		tmp = d_m / t_0;
	else
		tmp = ((((M * (D * M)) * D) / ((t_0 * l) * d_m)) * -0.125) * 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[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 2e+19], N[(d$95$m / t$95$0), $MachinePrecision], N[(N[(N[(N[(N[(M * N[(D * M), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision] / N[(N[(t$95$0 * l), $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] * h), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;M \cdot D \leq 2 \cdot 10^{+19}:\\
\;\;\;\;\frac{d\_m}{t\_0}\\

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


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

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e19 < (*.f64 M D)

    1. Initial program 35.8%

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

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

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

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

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

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

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

Alternative 10: 46.1% accurate, 2.6× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2 \cdot 10^{-227}:\\ \;\;\;\;\frac{-d\_m}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell}\\ \mathbf{elif}\;\ell \leq -5 \cdot 10^{-301}:\\ \;\;\;\;\left(-d\_m\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \mathbf{elif}\;\ell \leq 6.5 \cdot 10^{-192}:\\ \;\;\;\;\sqrt{h \cdot d\_m} \cdot \frac{\left(-d\_m\right) \cdot \sqrt{\frac{1}{\ell \cdot d\_m}}}{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-227)
   (/ (- d_m) (* (sqrt (* (/ 1.0 l) h)) l))
   (if (<= l -5e-301)
     (* (- d_m) (sqrt (/ 1.0 (* l h))))
     (if (<= l 6.5e-192)
       (* (sqrt (* h d_m)) (/ (* (- d_m) (sqrt (/ 1.0 (* l d_m)))) 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-227) {
		tmp = -d_m / (sqrt(((1.0 / l) * h)) * l);
	} else if (l <= -5e-301) {
		tmp = -d_m * sqrt((1.0 / (l * h)));
	} else if (l <= 6.5e-192) {
		tmp = sqrt((h * d_m)) * ((-d_m * sqrt((1.0 / (l * d_m)))) / 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-227)) then
        tmp = -d_m / (sqrt(((1.0d0 / l) * h)) * l)
    else if (l <= (-5d-301)) then
        tmp = -d_m * sqrt((1.0d0 / (l * h)))
    else if (l <= 6.5d-192) then
        tmp = sqrt((h * d_m)) * ((-d_m * sqrt((1.0d0 / (l * d_m)))) / 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-227) {
		tmp = -d_m / (Math.sqrt(((1.0 / l) * h)) * l);
	} else if (l <= -5e-301) {
		tmp = -d_m * Math.sqrt((1.0 / (l * h)));
	} else if (l <= 6.5e-192) {
		tmp = Math.sqrt((h * d_m)) * ((-d_m * Math.sqrt((1.0 / (l * d_m)))) / 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-227:
		tmp = -d_m / (math.sqrt(((1.0 / l) * h)) * l)
	elif l <= -5e-301:
		tmp = -d_m * math.sqrt((1.0 / (l * h)))
	elif l <= 6.5e-192:
		tmp = math.sqrt((h * d_m)) * ((-d_m * math.sqrt((1.0 / (l * d_m)))) / 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-227)
		tmp = Float64(Float64(-d_m) / Float64(sqrt(Float64(Float64(1.0 / l) * h)) * l));
	elseif (l <= -5e-301)
		tmp = Float64(Float64(-d_m) * sqrt(Float64(1.0 / Float64(l * h))));
	elseif (l <= 6.5e-192)
		tmp = Float64(sqrt(Float64(h * d_m)) * Float64(Float64(Float64(-d_m) * sqrt(Float64(1.0 / Float64(l * d_m)))) / 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-227)
		tmp = -d_m / (sqrt(((1.0 / l) * h)) * l);
	elseif (l <= -5e-301)
		tmp = -d_m * sqrt((1.0 / (l * h)));
	elseif (l <= 6.5e-192)
		tmp = sqrt((h * d_m)) * ((-d_m * sqrt((1.0 / (l * d_m)))) / 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-227], N[((-d$95$m) / N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] * h), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-301], N[((-d$95$m) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6.5e-192], N[(N[Sqrt[N[(h * d$95$m), $MachinePrecision]], $MachinePrecision] * N[(N[((-d$95$m) * N[Sqrt[N[(1.0 / N[(l * d$95$m), $MachinePrecision]), $MachinePrecision]], $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 -2 \cdot 10^{-227}:\\
\;\;\;\;\frac{-d\_m}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell}\\

\mathbf{elif}\;\ell \leq -5 \cdot 10^{-301}:\\
\;\;\;\;\left(-d\_m\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\

\mathbf{elif}\;\ell \leq 6.5 \cdot 10^{-192}:\\
\;\;\;\;\sqrt{h \cdot d\_m} \cdot \frac{\left(-d\_m\right) \cdot \sqrt{\frac{1}{\ell \cdot d\_m}}}{h}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if l < -1.99999999999999989e-227

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-d}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell} \]
      11. lower-/.f6424.1

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

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

    if -1.99999999999999989e-227 < l < -5.00000000000000013e-301

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-d\right) \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
      9. rem-square-sqrtN/A

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

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

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

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

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

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

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

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

    if -5.00000000000000013e-301 < l < 6.49999999999999966e-192

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{d \cdot h} \cdot \sqrt{\frac{d}{\ell}}}{h} \]
      8. associate-/l*N/A

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

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

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

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

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

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

        \[\leadsto \sqrt{h \cdot d} \cdot \frac{\sqrt{\frac{d}{\ell}}}{h} \]
      15. lift-/.f6418.0

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.49999999999999966e-192 < l

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 45.8% accurate, 3.7× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2 \cdot 10^{-227}:\\ \;\;\;\;\frac{-d\_m}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell}\\ \mathbf{elif}\;\ell \leq 4.6 \cdot 10^{-235}:\\ \;\;\;\;\frac{-\frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}} \cdot h}{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-227)
   (/ (- d_m) (* (sqrt (* (/ 1.0 l) h)) l))
   (if (<= l 4.6e-235)
     (/ (- (* (/ (fabs d_m) (sqrt (* l h))) 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 <= -2e-227) {
		tmp = -d_m / (sqrt(((1.0 / l) * h)) * l);
	} else if (l <= 4.6e-235) {
		tmp = -((fabs(d_m) / sqrt((l * h))) * 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 <= (-2d-227)) then
        tmp = -d_m / (sqrt(((1.0d0 / l) * h)) * l)
    else if (l <= 4.6d-235) then
        tmp = -((abs(d_m) / sqrt((l * h))) * 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 <= -2e-227) {
		tmp = -d_m / (Math.sqrt(((1.0 / l) * h)) * l);
	} else if (l <= 4.6e-235) {
		tmp = -((Math.abs(d_m) / Math.sqrt((l * h))) * 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 <= -2e-227:
		tmp = -d_m / (math.sqrt(((1.0 / l) * h)) * l)
	elif l <= 4.6e-235:
		tmp = -((math.fabs(d_m) / math.sqrt((l * h))) * 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 <= -2e-227)
		tmp = Float64(Float64(-d_m) / Float64(sqrt(Float64(Float64(1.0 / l) * h)) * l));
	elseif (l <= 4.6e-235)
		tmp = Float64(Float64(-Float64(Float64(abs(d_m) / sqrt(Float64(l * h))) * 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 <= -2e-227)
		tmp = -d_m / (sqrt(((1.0 / l) * h)) * l);
	elseif (l <= 4.6e-235)
		tmp = -((abs(d_m) / sqrt((l * h))) * 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, -2e-227], N[((-d$95$m) / N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] * h), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.6e-235], N[((-N[(N[(N[Abs[d$95$m], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision]) / h), $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^{-227}:\\
\;\;\;\;\frac{-d\_m}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell}\\

\mathbf{elif}\;\ell \leq 4.6 \cdot 10^{-235}:\\
\;\;\;\;\frac{-\frac{\left|d\_m\right|}{\sqrt{\ell \cdot h}} \cdot h}{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.99999999999999989e-227

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-d}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell} \]
      11. lower-/.f6424.1

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

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

    if -1.99999999999999989e-227 < l < 4.59999999999999995e-235

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.59999999999999995e-235 < l

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 45.6% accurate, 4.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2 \cdot 10^{-227}:\\ \;\;\;\;\frac{-d\_m}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell}\\ \mathbf{elif}\;\ell \leq 4.6 \cdot 10^{-235}:\\ \;\;\;\;\left(-d\_m\right) \cdot \sqrt{\frac{1}{\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-227)
   (/ (- d_m) (* (sqrt (* (/ 1.0 l) h)) l))
   (if (<= l 4.6e-235)
     (* (- d_m) (sqrt (/ 1.0 (* 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-227) {
		tmp = -d_m / (sqrt(((1.0 / l) * h)) * l);
	} else if (l <= 4.6e-235) {
		tmp = -d_m * sqrt((1.0 / (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-227)) then
        tmp = -d_m / (sqrt(((1.0d0 / l) * h)) * l)
    else if (l <= 4.6d-235) then
        tmp = -d_m * sqrt((1.0d0 / (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-227) {
		tmp = -d_m / (Math.sqrt(((1.0 / l) * h)) * l);
	} else if (l <= 4.6e-235) {
		tmp = -d_m * Math.sqrt((1.0 / (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-227:
		tmp = -d_m / (math.sqrt(((1.0 / l) * h)) * l)
	elif l <= 4.6e-235:
		tmp = -d_m * math.sqrt((1.0 / (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-227)
		tmp = Float64(Float64(-d_m) / Float64(sqrt(Float64(Float64(1.0 / l) * h)) * l));
	elseif (l <= 4.6e-235)
		tmp = Float64(Float64(-d_m) * sqrt(Float64(1.0 / 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-227)
		tmp = -d_m / (sqrt(((1.0 / l) * h)) * l);
	elseif (l <= 4.6e-235)
		tmp = -d_m * sqrt((1.0 / (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-227], N[((-d$95$m) / N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] * h), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.6e-235], N[((-d$95$m) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $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^{-227}:\\
\;\;\;\;\frac{-d\_m}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell}\\

\mathbf{elif}\;\ell \leq 4.6 \cdot 10^{-235}:\\
\;\;\;\;\left(-d\_m\right) \cdot \sqrt{\frac{1}{\ell \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.99999999999999989e-227

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-d}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell} \]
      11. lower-/.f6424.1

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

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

    if -1.99999999999999989e-227 < l < 4.59999999999999995e-235

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-d\right) \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
      9. rem-square-sqrtN/A

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

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

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

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

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

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

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

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

    if 4.59999999999999995e-235 < l

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 45.6% accurate, 4.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;\ell \leq -2 \cdot 10^{-227}:\\ \;\;\;\;\frac{-d\_m}{\sqrt{\frac{h}{\ell}} \cdot \ell}\\ \mathbf{elif}\;\ell \leq 4.6 \cdot 10^{-235}:\\ \;\;\;\;\left(-d\_m\right) \cdot \sqrt{\frac{1}{\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-227)
   (/ (- d_m) (* (sqrt (/ h l)) l))
   (if (<= l 4.6e-235)
     (* (- d_m) (sqrt (/ 1.0 (* 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-227) {
		tmp = -d_m / (sqrt((h / l)) * l);
	} else if (l <= 4.6e-235) {
		tmp = -d_m * sqrt((1.0 / (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-227)) then
        tmp = -d_m / (sqrt((h / l)) * l)
    else if (l <= 4.6d-235) then
        tmp = -d_m * sqrt((1.0d0 / (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-227) {
		tmp = -d_m / (Math.sqrt((h / l)) * l);
	} else if (l <= 4.6e-235) {
		tmp = -d_m * Math.sqrt((1.0 / (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-227:
		tmp = -d_m / (math.sqrt((h / l)) * l)
	elif l <= 4.6e-235:
		tmp = -d_m * math.sqrt((1.0 / (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-227)
		tmp = Float64(Float64(-d_m) / Float64(sqrt(Float64(h / l)) * l));
	elseif (l <= 4.6e-235)
		tmp = Float64(Float64(-d_m) * sqrt(Float64(1.0 / 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-227)
		tmp = -d_m / (sqrt((h / l)) * l);
	elseif (l <= 4.6e-235)
		tmp = -d_m * sqrt((1.0 / (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-227], N[((-d$95$m) / N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 4.6e-235], N[((-d$95$m) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $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^{-227}:\\
\;\;\;\;\frac{-d\_m}{\sqrt{\frac{h}{\ell}} \cdot \ell}\\

\mathbf{elif}\;\ell \leq 4.6 \cdot 10^{-235}:\\
\;\;\;\;\left(-d\_m\right) \cdot \sqrt{\frac{1}{\ell \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.99999999999999989e-227

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-d}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell} \]
      11. lower-/.f6424.1

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

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

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

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

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

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

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

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

    if -1.99999999999999989e-227 < l < 4.59999999999999995e-235

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-d\right) \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
      9. rem-square-sqrtN/A

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

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

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

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

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

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

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

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

    if 4.59999999999999995e-235 < l

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 44.5% accurate, 3.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;M \cdot D \leq 4.5 \cdot 10^{-35}:\\ \;\;\;\;\frac{d\_m}{\sqrt{\ell \cdot h}}\\ \mathbf{elif}\;M \cdot D \leq 8 \cdot 10^{+189}:\\ \;\;\;\;\sqrt{\frac{d\_m}{\ell} \cdot \frac{d\_m}{h}}\\ \mathbf{else}:\\ \;\;\;\;\left(-d\_m\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (if (<= (* M D) 4.5e-35)
   (/ d_m (sqrt (* l h)))
   (if (<= (* M D) 8e+189)
     (sqrt (* (/ d_m l) (/ d_m h)))
     (* (- d_m) (sqrt (/ 1.0 (* l h)))))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double tmp;
	if ((M * D) <= 4.5e-35) {
		tmp = d_m / sqrt((l * h));
	} else if ((M * D) <= 8e+189) {
		tmp = sqrt(((d_m / l) * (d_m / h)));
	} else {
		tmp = -d_m * sqrt((1.0 / (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) :: tmp
    if ((m * d) <= 4.5d-35) then
        tmp = d_m / sqrt((l * h))
    else if ((m * d) <= 8d+189) then
        tmp = sqrt(((d_m / l) * (d_m / h)))
    else
        tmp = -d_m * sqrt((1.0d0 / (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 tmp;
	if ((M * D) <= 4.5e-35) {
		tmp = d_m / Math.sqrt((l * h));
	} else if ((M * D) <= 8e+189) {
		tmp = Math.sqrt(((d_m / l) * (d_m / h)));
	} else {
		tmp = -d_m * Math.sqrt((1.0 / (l * h)));
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	tmp = 0
	if (M * D) <= 4.5e-35:
		tmp = d_m / math.sqrt((l * h))
	elif (M * D) <= 8e+189:
		tmp = math.sqrt(((d_m / l) * (d_m / h)))
	else:
		tmp = -d_m * math.sqrt((1.0 / (l * h)))
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	tmp = 0.0
	if (Float64(M * D) <= 4.5e-35)
		tmp = Float64(d_m / sqrt(Float64(l * h)));
	elseif (Float64(M * D) <= 8e+189)
		tmp = sqrt(Float64(Float64(d_m / l) * Float64(d_m / h)));
	else
		tmp = Float64(Float64(-d_m) * sqrt(Float64(1.0 / Float64(l * h))));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	tmp = 0.0;
	if ((M * D) <= 4.5e-35)
		tmp = d_m / sqrt((l * h));
	elseif ((M * D) <= 8e+189)
		tmp = sqrt(((d_m / l) * (d_m / h)));
	else
		tmp = -d_m * sqrt((1.0 / (l * h)));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[d$95$m_, h_, l_, M_, D_] := If[LessEqual[N[(M * D), $MachinePrecision], 4.5e-35], N[(d$95$m / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 8e+189], N[Sqrt[N[(N[(d$95$m / l), $MachinePrecision] * N[(d$95$m / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[((-d$95$m) * N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|

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

\mathbf{elif}\;M \cdot D \leq 8 \cdot 10^{+189}:\\
\;\;\;\;\sqrt{\frac{d\_m}{\ell} \cdot \frac{d\_m}{h}}\\

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


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

    1. Initial program 35.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.5000000000000001e-35 < (*.f64 M D) < 8.0000000000000002e189

    1. Initial program 35.8%

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

      \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.25} \cdot \left({\left(\frac{d}{h}\right)}^{0.25} \cdot \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)\right)} \]
    3. Taylor expanded in h around 0

      \[\leadsto \color{blue}{{\left(e^{\frac{1}{4} \cdot \left(\log d + -1 \cdot \log h\right)}\right)}^{2} \cdot \sqrt{\frac{d}{\ell}}} \]
    4. Applied rewrites43.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.0000000000000002e189 < (*.f64 M D)

    1. Initial program 35.8%

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

        \[\leadsto \color{blue}{\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right)} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      2. lift-/.f64N/A

        \[\leadsto \left({\color{blue}{\left(\frac{d}{h}\right)}}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      3. lift-pow.f64N/A

        \[\leadsto \left(\color{blue}{{\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)}} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\color{blue}{\left(\frac{d}{\ell}\right)}}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      5. lift-pow.f64N/A

        \[\leadsto \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot \color{blue}{{\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      6. pow-prod-downN/A

        \[\leadsto \color{blue}{{\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      7. lift-/.f64N/A

        \[\leadsto {\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\color{blue}{\left(\frac{1}{2}\right)}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      8. metadata-evalN/A

        \[\leadsto {\left(\frac{d}{h} \cdot \frac{d}{\ell}\right)}^{\color{blue}{\frac{1}{2}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      9. pow1/2N/A

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      10. lower-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{\frac{d}{h} \cdot \frac{d}{\ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      11. frac-timesN/A

        \[\leadsto \sqrt{\color{blue}{\frac{d \cdot d}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      12. unpow2N/A

        \[\leadsto \sqrt{\frac{\color{blue}{{d}^{2}}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      13. lower-/.f64N/A

        \[\leadsto \sqrt{\color{blue}{\frac{{d}^{2}}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      14. unpow2N/A

        \[\leadsto \sqrt{\frac{\color{blue}{d \cdot d}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      15. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{\color{blue}{d \cdot d}}{h \cdot \ell}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
      16. lower-*.f6443.2

        \[\leadsto \sqrt{\frac{d \cdot d}{\color{blue}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    3. Applied rewrites43.2%

      \[\leadsto \color{blue}{\sqrt{\frac{d \cdot d}{h \cdot \ell}}} \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    4. Taylor expanded in d around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right)} \]
    5. Step-by-step derivation
      1. pow1/2N/A

        \[\leadsto -1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      2. times-fracN/A

        \[\leadsto -1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      3. metadata-evalN/A

        \[\leadsto -1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      4. pow-prod-downN/A

        \[\leadsto -1 \cdot \left(d \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \]
      5. associate-*r*N/A

        \[\leadsto \left(-1 \cdot d\right) \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      6. mul-1-negN/A

        \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
      7. lower-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(d\right)\right) \cdot \color{blue}{\sqrt{\frac{1}{h \cdot \ell}}} \]
      8. lower-neg.f64N/A

        \[\leadsto \left(-d\right) \cdot \sqrt{\color{blue}{\frac{1}{h \cdot \ell}}} \]
      9. rem-square-sqrtN/A

        \[\leadsto \left(-d\right) \cdot \sqrt{\sqrt{\frac{1}{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      10. sqrt-divN/A

        \[\leadsto \left(-d\right) \cdot \sqrt{\frac{\sqrt{1}}{\sqrt{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      11. metadata-evalN/A

        \[\leadsto \left(-d\right) \cdot \sqrt{\frac{1}{\sqrt{h \cdot \ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      12. sqrt-unprodN/A

        \[\leadsto \left(-d\right) \cdot \sqrt{\frac{1}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \sqrt{\frac{1}{h \cdot \ell}}} \]
      13. sqrt-divN/A

        \[\leadsto \left(-d\right) \cdot \sqrt{\frac{1}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \frac{\sqrt{1}}{\sqrt{h \cdot \ell}}} \]
      14. metadata-evalN/A

        \[\leadsto \left(-d\right) \cdot \sqrt{\frac{1}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \frac{1}{\sqrt{h \cdot \ell}}} \]
      15. sqrt-unprodN/A

        \[\leadsto \left(-d\right) \cdot \sqrt{\frac{1}{\sqrt{h} \cdot \sqrt{\ell}} \cdot \frac{1}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    6. Applied rewrites10.2%

      \[\leadsto \color{blue}{\left(-d\right) \cdot \sqrt{\frac{1}{\ell \cdot h}}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 15: 43.7% accurate, 3.6× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;M \cdot D \leq 4.5 \cdot 10^{-35}:\\ \;\;\;\;\frac{d\_m}{t\_0}\\ \mathbf{elif}\;M \cdot D \leq 8 \cdot 10^{+189}:\\ \;\;\;\;\sqrt{\frac{d\_m}{\ell} \cdot \frac{d\_m}{h}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-d\_m}{t\_0}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (* l h))))
   (if (<= (* M D) 4.5e-35)
     (/ d_m t_0)
     (if (<= (* M D) 8e+189) (sqrt (* (/ d_m l) (/ d_m h))) (/ (- d_m) t_0)))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = sqrt((l * h));
	double tmp;
	if ((M * D) <= 4.5e-35) {
		tmp = d_m / t_0;
	} else if ((M * D) <= 8e+189) {
		tmp = sqrt(((d_m / l) * (d_m / h)));
	} else {
		tmp = -d_m / 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 = sqrt((l * h))
    if ((m * d) <= 4.5d-35) then
        tmp = d_m / t_0
    else if ((m * d) <= 8d+189) then
        tmp = sqrt(((d_m / l) * (d_m / h)))
    else
        tmp = -d_m / 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 = Math.sqrt((l * h));
	double tmp;
	if ((M * D) <= 4.5e-35) {
		tmp = d_m / t_0;
	} else if ((M * D) <= 8e+189) {
		tmp = Math.sqrt(((d_m / l) * (d_m / h)));
	} else {
		tmp = -d_m / t_0;
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = math.sqrt((l * h))
	tmp = 0
	if (M * D) <= 4.5e-35:
		tmp = d_m / t_0
	elif (M * D) <= 8e+189:
		tmp = math.sqrt(((d_m / l) * (d_m / h)))
	else:
		tmp = -d_m / t_0
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (Float64(M * D) <= 4.5e-35)
		tmp = Float64(d_m / t_0);
	elseif (Float64(M * D) <= 8e+189)
		tmp = sqrt(Float64(Float64(d_m / l) * Float64(d_m / h)));
	else
		tmp = Float64(Float64(-d_m) / t_0);
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = sqrt((l * h));
	tmp = 0.0;
	if ((M * D) <= 4.5e-35)
		tmp = d_m / t_0;
	elseif ((M * D) <= 8e+189)
		tmp = sqrt(((d_m / l) * (d_m / h)));
	else
		tmp = -d_m / 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[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 4.5e-35], N[(d$95$m / t$95$0), $MachinePrecision], If[LessEqual[N[(M * D), $MachinePrecision], 8e+189], N[Sqrt[N[(N[(d$95$m / l), $MachinePrecision] * N[(d$95$m / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[((-d$95$m) / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;M \cdot D \leq 4.5 \cdot 10^{-35}:\\
\;\;\;\;\frac{d\_m}{t\_0}\\

\mathbf{elif}\;M \cdot D \leq 8 \cdot 10^{+189}:\\
\;\;\;\;\sqrt{\frac{d\_m}{\ell} \cdot \frac{d\_m}{h}}\\

\mathbf{else}:\\
\;\;\;\;\frac{-d\_m}{t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 M D) < 4.5000000000000001e-35

    1. Initial program 35.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Taylor expanded in h around inf

      \[\leadsto \color{blue}{h \cdot \left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}{{d}^{2} \cdot \ell} + \frac{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}}{h}\right)} \]
    3. Applied rewrites21.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(M \cdot M\right)\right) \cdot D\right) \cdot D}{\left(d \cdot d\right) \cdot \ell}, -0.125, \frac{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}{h}\right) \cdot h} \]
    4. Taylor expanded in l around inf

      \[\leadsto \frac{\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right)\right)} + \frac{d}{\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}}}{\color{blue}{\ell}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right)\right)} + \frac{d}{\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}}}{\ell} \]
    6. Applied rewrites25.5%

      \[\leadsto \frac{\mathsf{fma}\left(\left(D \cdot D\right) \cdot \frac{\left(M \cdot M\right) \cdot h}{\left(\ell \cdot d\right) \cdot \sqrt{\frac{1}{\ell} \cdot h}}, -0.125, \frac{d}{\sqrt{\frac{1}{\ell} \cdot h}}\right)}{\color{blue}{\ell}} \]
    7. Taylor expanded in d around inf

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Step-by-step derivation
      1. sqrt-prodN/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
      4. lift-sqrt.f64N/A

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
      5. lift-*.f6443.7

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
    9. Applied rewrites43.7%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]

    if 4.5000000000000001e-35 < (*.f64 M D) < 8.0000000000000002e189

    1. Initial program 35.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Applied rewrites24.5%

      \[\leadsto \color{blue}{{\left(\frac{d}{h}\right)}^{0.25} \cdot \left({\left(\frac{d}{h}\right)}^{0.25} \cdot \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)\right)} \]
    3. Taylor expanded in h around 0

      \[\leadsto \color{blue}{{\left(e^{\frac{1}{4} \cdot \left(\log d + -1 \cdot \log h\right)}\right)}^{2} \cdot \sqrt{\frac{d}{\ell}}} \]
    4. Applied rewrites43.7%

      \[\leadsto \color{blue}{\frac{\left|d\right|}{\sqrt{\ell \cdot h}}} \]
    5. Step-by-step derivation
      1. lift-fabs.f64N/A

        \[\leadsto \frac{\left|d\right|}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{\left|d\right|}{\color{blue}{\sqrt{\ell \cdot h}}} \]
      3. rem-sqrt-square-revN/A

        \[\leadsto \frac{\sqrt{d \cdot d}}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      4. sqrt-prodN/A

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\color{blue}{\ell \cdot h}}} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell \cdot h}} \]
      6. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell \cdot h}} \]
      7. sqrt-prodN/A

        \[\leadsto \frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \color{blue}{\sqrt{h}}} \]
      8. frac-timesN/A

        \[\leadsto \frac{\sqrt{d}}{\sqrt{\ell}} \cdot \color{blue}{\frac{\sqrt{d}}{\sqrt{h}}} \]
      9. sqrt-divN/A

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \frac{\color{blue}{\sqrt{d}}}{\sqrt{h}} \]
      10. sqrt-divN/A

        \[\leadsto \sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}} \]
      11. sqrt-unprodN/A

        \[\leadsto \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
      12. lower-sqrt.f64N/A

        \[\leadsto \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
      13. lower-*.f64N/A

        \[\leadsto \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
      14. lift-/.f64N/A

        \[\leadsto \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
      15. lower-/.f6433.4

        \[\leadsto \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]
    6. Applied rewrites33.4%

      \[\leadsto \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \]

    if 8.0000000000000002e189 < (*.f64 M D)

    1. Initial program 35.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Taylor expanded in h around inf

      \[\leadsto \color{blue}{h \cdot \left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}{{d}^{2} \cdot \ell} + \frac{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}}{h}\right)} \]
    3. Applied rewrites21.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(M \cdot M\right)\right) \cdot D\right) \cdot D}{\left(d \cdot d\right) \cdot \ell}, -0.125, \frac{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}{h}\right) \cdot h} \]
    4. Taylor expanded in l around -inf

      \[\leadsto -1 \cdot \color{blue}{\frac{d}{\ell \cdot \left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right)}} \]
    5. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot d}{\ell \cdot \color{blue}{\left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right)}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(d\right)}{\ell \cdot \left(\color{blue}{\sqrt{h}} \cdot \sqrt{\frac{1}{\ell}}\right)} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(d\right)}{\ell \cdot \color{blue}{\left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right)}} \]
      4. lower-neg.f64N/A

        \[\leadsto \frac{-d}{\ell \cdot \left(\color{blue}{\sqrt{h}} \cdot \sqrt{\frac{1}{\ell}}\right)} \]
      5. *-commutativeN/A

        \[\leadsto \frac{-d}{\left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right) \cdot \ell} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{-d}{\left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right) \cdot \ell} \]
      7. *-commutativeN/A

        \[\leadsto \frac{-d}{\left(\sqrt{\frac{1}{\ell}} \cdot \sqrt{h}\right) \cdot \ell} \]
      8. sqrt-unprodN/A

        \[\leadsto \frac{-d}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell} \]
      9. lower-sqrt.f64N/A

        \[\leadsto \frac{-d}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{-d}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell} \]
      11. lower-/.f6424.1

        \[\leadsto \frac{-d}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell} \]
    6. Applied rewrites24.1%

      \[\leadsto \frac{-d}{\color{blue}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell}} \]
    7. Taylor expanded in l around 0

      \[\leadsto -1 \cdot \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. sqrt-prodN/A

        \[\leadsto -1 \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      2. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(d\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      4. lift-neg.f64N/A

        \[\leadsto \frac{-d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{-d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{-d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      7. sqrt-prodN/A

        \[\leadsto \frac{-d}{\sqrt{\ell \cdot h}} \]
      8. lift-sqrt.f64N/A

        \[\leadsto \frac{-d}{\sqrt{\ell \cdot h}} \]
      9. lift-*.f649.9

        \[\leadsto \frac{-d}{\sqrt{\ell \cdot h}} \]
    9. Applied rewrites9.9%

      \[\leadsto \frac{-d}{\sqrt{\ell \cdot h}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 16: 43.2% accurate, 5.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \sqrt{\ell \cdot h}\\ \mathbf{if}\;M \cdot D \leq 4.4 \cdot 10^{+172}:\\ \;\;\;\;\frac{d\_m}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{-d\_m}{t\_0}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (d_m h l M D)
 :precision binary64
 (let* ((t_0 (sqrt (* l h))))
   (if (<= (* M D) 4.4e+172) (/ d_m t_0) (/ (- d_m) t_0))))
d_m = fabs(d);
double code(double d_m, double h, double l, double M, double D) {
	double t_0 = sqrt((l * h));
	double tmp;
	if ((M * D) <= 4.4e+172) {
		tmp = d_m / t_0;
	} else {
		tmp = -d_m / 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 = sqrt((l * h))
    if ((m * d) <= 4.4d+172) then
        tmp = d_m / t_0
    else
        tmp = -d_m / 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 = Math.sqrt((l * h));
	double tmp;
	if ((M * D) <= 4.4e+172) {
		tmp = d_m / t_0;
	} else {
		tmp = -d_m / t_0;
	}
	return tmp;
}
d_m = math.fabs(d)
def code(d_m, h, l, M, D):
	t_0 = math.sqrt((l * h))
	tmp = 0
	if (M * D) <= 4.4e+172:
		tmp = d_m / t_0
	else:
		tmp = -d_m / t_0
	return tmp
d_m = abs(d)
function code(d_m, h, l, M, D)
	t_0 = sqrt(Float64(l * h))
	tmp = 0.0
	if (Float64(M * D) <= 4.4e+172)
		tmp = Float64(d_m / t_0);
	else
		tmp = Float64(Float64(-d_m) / t_0);
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(d_m, h, l, M, D)
	t_0 = sqrt((l * h));
	tmp = 0.0;
	if ((M * D) <= 4.4e+172)
		tmp = d_m / t_0;
	else
		tmp = -d_m / 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[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(M * D), $MachinePrecision], 4.4e+172], N[(d$95$m / t$95$0), $MachinePrecision], N[((-d$95$m) / t$95$0), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \sqrt{\ell \cdot h}\\
\mathbf{if}\;M \cdot D \leq 4.4 \cdot 10^{+172}:\\
\;\;\;\;\frac{d\_m}{t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{-d\_m}{t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 M D) < 4.4000000000000002e172

    1. Initial program 35.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Taylor expanded in h around inf

      \[\leadsto \color{blue}{h \cdot \left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}{{d}^{2} \cdot \ell} + \frac{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}}{h}\right)} \]
    3. Applied rewrites21.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(M \cdot M\right)\right) \cdot D\right) \cdot D}{\left(d \cdot d\right) \cdot \ell}, -0.125, \frac{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}{h}\right) \cdot h} \]
    4. Taylor expanded in l around inf

      \[\leadsto \frac{\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right)\right)} + \frac{d}{\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}}}{\color{blue}{\ell}} \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right)\right)} + \frac{d}{\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}}}{\ell} \]
    6. Applied rewrites25.5%

      \[\leadsto \frac{\mathsf{fma}\left(\left(D \cdot D\right) \cdot \frac{\left(M \cdot M\right) \cdot h}{\left(\ell \cdot d\right) \cdot \sqrt{\frac{1}{\ell} \cdot h}}, -0.125, \frac{d}{\sqrt{\frac{1}{\ell} \cdot h}}\right)}{\color{blue}{\ell}} \]
    7. Taylor expanded in d around inf

      \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
    8. Step-by-step derivation
      1. sqrt-prodN/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
      4. lift-sqrt.f64N/A

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
      5. lift-*.f6443.7

        \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
    9. Applied rewrites43.7%

      \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]

    if 4.4000000000000002e172 < (*.f64 M D)

    1. Initial program 35.8%

      \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
    2. Taylor expanded in h around inf

      \[\leadsto \color{blue}{h \cdot \left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}{{d}^{2} \cdot \ell} + \frac{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}}{h}\right)} \]
    3. Applied rewrites21.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(M \cdot M\right)\right) \cdot D\right) \cdot D}{\left(d \cdot d\right) \cdot \ell}, -0.125, \frac{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}{h}\right) \cdot h} \]
    4. Taylor expanded in l around -inf

      \[\leadsto -1 \cdot \color{blue}{\frac{d}{\ell \cdot \left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right)}} \]
    5. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot d}{\ell \cdot \color{blue}{\left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right)}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(d\right)}{\ell \cdot \left(\color{blue}{\sqrt{h}} \cdot \sqrt{\frac{1}{\ell}}\right)} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(d\right)}{\ell \cdot \color{blue}{\left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right)}} \]
      4. lower-neg.f64N/A

        \[\leadsto \frac{-d}{\ell \cdot \left(\color{blue}{\sqrt{h}} \cdot \sqrt{\frac{1}{\ell}}\right)} \]
      5. *-commutativeN/A

        \[\leadsto \frac{-d}{\left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right) \cdot \ell} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{-d}{\left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right) \cdot \ell} \]
      7. *-commutativeN/A

        \[\leadsto \frac{-d}{\left(\sqrt{\frac{1}{\ell}} \cdot \sqrt{h}\right) \cdot \ell} \]
      8. sqrt-unprodN/A

        \[\leadsto \frac{-d}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell} \]
      9. lower-sqrt.f64N/A

        \[\leadsto \frac{-d}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell} \]
      10. lower-*.f64N/A

        \[\leadsto \frac{-d}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell} \]
      11. lower-/.f6424.1

        \[\leadsto \frac{-d}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell} \]
    6. Applied rewrites24.1%

      \[\leadsto \frac{-d}{\color{blue}{\sqrt{\frac{1}{\ell} \cdot h} \cdot \ell}} \]
    7. Taylor expanded in l around 0

      \[\leadsto -1 \cdot \frac{d}{\color{blue}{\sqrt{h \cdot \ell}}} \]
    8. Step-by-step derivation
      1. sqrt-prodN/A

        \[\leadsto -1 \cdot \frac{d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      2. associate-*r/N/A

        \[\leadsto \frac{-1 \cdot d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(d\right)}{\sqrt{h} \cdot \sqrt{\ell}} \]
      4. lift-neg.f64N/A

        \[\leadsto \frac{-d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{-d}{\sqrt{h} \cdot \sqrt{\ell}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{-d}{\sqrt{\ell} \cdot \sqrt{h}} \]
      7. sqrt-prodN/A

        \[\leadsto \frac{-d}{\sqrt{\ell \cdot h}} \]
      8. lift-sqrt.f64N/A

        \[\leadsto \frac{-d}{\sqrt{\ell \cdot h}} \]
      9. lift-*.f649.9

        \[\leadsto \frac{-d}{\sqrt{\ell \cdot h}} \]
    9. Applied rewrites9.9%

      \[\leadsto \frac{-d}{\sqrt{\ell \cdot h}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 17: 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 35.8%

    \[\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \]
  2. Taylor expanded in h around inf

    \[\leadsto \color{blue}{h \cdot \left(\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}\right)\right)}{{d}^{2} \cdot \ell} + \frac{\sqrt{\frac{d}{h}} \cdot \sqrt{\frac{d}{\ell}}}{h}\right)} \]
  3. Applied rewrites21.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\left(\left(\frac{d}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(M \cdot M\right)\right) \cdot D\right) \cdot D}{\left(d \cdot d\right) \cdot \ell}, -0.125, \frac{\frac{d}{\sqrt{\ell} \cdot \sqrt{h}}}{h}\right) \cdot h} \]
  4. Taylor expanded in l around inf

    \[\leadsto \frac{\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right)\right)} + \frac{d}{\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}}}{\color{blue}{\ell}} \]
  5. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \frac{\frac{-1}{8} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{d \cdot \left(\ell \cdot \left(\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}\right)\right)} + \frac{d}{\sqrt{h} \cdot \sqrt{\frac{1}{\ell}}}}{\ell} \]
  6. Applied rewrites25.5%

    \[\leadsto \frac{\mathsf{fma}\left(\left(D \cdot D\right) \cdot \frac{\left(M \cdot M\right) \cdot h}{\left(\ell \cdot d\right) \cdot \sqrt{\frac{1}{\ell} \cdot h}}, -0.125, \frac{d}{\sqrt{\frac{1}{\ell} \cdot h}}\right)}{\color{blue}{\ell}} \]
  7. Taylor expanded in d around inf

    \[\leadsto \frac{d}{\color{blue}{\sqrt{h} \cdot \sqrt{\ell}}} \]
  8. Step-by-step derivation
    1. sqrt-prodN/A

      \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    2. lower-/.f64N/A

      \[\leadsto \frac{d}{\sqrt{h \cdot \ell}} \]
    3. *-commutativeN/A

      \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
    4. lift-sqrt.f64N/A

      \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
    5. lift-*.f6443.7

      \[\leadsto \frac{d}{\sqrt{\ell \cdot h}} \]
  9. Applied rewrites43.7%

    \[\leadsto \frac{d}{\color{blue}{\sqrt{\ell \cdot h}}} \]
  10. Add Preprocessing

Reproduce

?
herbie shell --seed 2025138 
(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)))))