Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.9% → 42.9%
Time: 11.2s
Alternatives: 11
Speedup: 3.3×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
   (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
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(c0, w, h, d, d_1, m)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: t_0
    t_0 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
    code = (c0 / (2.0d0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (m * m))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	return (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
}
def code(c0, w, h, D, d, M):
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D))
	return (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M)))))
end
function tmp = code(c0, w, h, D, d, M)
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	tmp = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)
\end{array}
\end{array}

Sampling outcomes in binary64 precision:

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

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
   (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
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(c0, w, h, d, d_1, m)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: t_0
    t_0 = (c0 * (d_1 * d_1)) / ((w * h) * (d * d))
    code = (c0 / (2.0d0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (m * m))))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	return (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
}
def code(c0, w, h, D, d, M):
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D))
	return (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M)))))
end
function tmp = code(c0, w, h, D, d, M)
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	tmp = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 + N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)
\end{array}
\end{array}

Alternative 1: 42.9% accurate, 1.0× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \frac{\frac{{\left(d\_m \cdot c0\right)}^{2}}{\left(D \cdot w\right) \cdot \left(D \cdot w\right)}}{h}\\ t_1 := \left(d\_m \cdot d\_m\right) \cdot c0\\ \mathbf{if}\;d\_m \leq 5.3 \cdot 10^{-160}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d\_m \leq 10^{+103}:\\ \;\;\;\;\frac{c0 \cdot \left(\frac{2}{\left(h \cdot w\right) \cdot D} \cdot \frac{t\_1}{D}\right)}{w \cdot 2}\\ \mathbf{elif}\;d\_m \leq 1.4 \cdot 10^{+277}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{t\_1}\right) \cdot -0.5\right)\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
 :precision binary64
 (let* ((t_0 (/ (/ (pow (* d_m c0) 2.0) (* (* D w) (* D w))) h))
        (t_1 (* (* d_m d_m) c0)))
   (if (<= d_m 5.3e-160)
     t_0
     (if (<= d_m 1e+103)
       (/ (* c0 (* (/ 2.0 (* (* h w) D)) (/ t_1 D))) (* w 2.0))
       (if (<= d_m 1.4e+277)
         t_0
         (*
          (/ c0 (* 2.0 w))
          (* (* (* (* M D) (* M D)) (/ (* h w) t_1)) -0.5)))))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
	double t_0 = (pow((d_m * c0), 2.0) / ((D * w) * (D * w))) / h;
	double t_1 = (d_m * d_m) * c0;
	double tmp;
	if (d_m <= 5.3e-160) {
		tmp = t_0;
	} else if (d_m <= 1e+103) {
		tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0);
	} else if (d_m <= 1.4e+277) {
		tmp = t_0;
	} else {
		tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5);
	}
	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(c0, w, h, d, d_m, m)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_m
    real(8), intent (in) :: m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (((d_m * c0) ** 2.0d0) / ((d * w) * (d * w))) / h
    t_1 = (d_m * d_m) * c0
    if (d_m <= 5.3d-160) then
        tmp = t_0
    else if (d_m <= 1d+103) then
        tmp = (c0 * ((2.0d0 / ((h * w) * d)) * (t_1 / d))) / (w * 2.0d0)
    else if (d_m <= 1.4d+277) then
        tmp = t_0
    else
        tmp = (c0 / (2.0d0 * w)) * ((((m * d) * (m * d)) * ((h * w) / t_1)) * (-0.5d0))
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
	double t_0 = (Math.pow((d_m * c0), 2.0) / ((D * w) * (D * w))) / h;
	double t_1 = (d_m * d_m) * c0;
	double tmp;
	if (d_m <= 5.3e-160) {
		tmp = t_0;
	} else if (d_m <= 1e+103) {
		tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0);
	} else if (d_m <= 1.4e+277) {
		tmp = t_0;
	} else {
		tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5);
	}
	return tmp;
}
d_m = math.fabs(d)
def code(c0, w, h, D, d_m, M):
	t_0 = (math.pow((d_m * c0), 2.0) / ((D * w) * (D * w))) / h
	t_1 = (d_m * d_m) * c0
	tmp = 0
	if d_m <= 5.3e-160:
		tmp = t_0
	elif d_m <= 1e+103:
		tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0)
	elif d_m <= 1.4e+277:
		tmp = t_0
	else:
		tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5)
	return tmp
d_m = abs(d)
function code(c0, w, h, D, d_m, M)
	t_0 = Float64(Float64((Float64(d_m * c0) ^ 2.0) / Float64(Float64(D * w) * Float64(D * w))) / h)
	t_1 = Float64(Float64(d_m * d_m) * c0)
	tmp = 0.0
	if (d_m <= 5.3e-160)
		tmp = t_0;
	elseif (d_m <= 1e+103)
		tmp = Float64(Float64(c0 * Float64(Float64(2.0 / Float64(Float64(h * w) * D)) * Float64(t_1 / D))) / Float64(w * 2.0));
	elseif (d_m <= 1.4e+277)
		tmp = t_0;
	else
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * Float64(Float64(h * w) / t_1)) * -0.5));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(c0, w, h, D, d_m, M)
	t_0 = (((d_m * c0) ^ 2.0) / ((D * w) * (D * w))) / h;
	t_1 = (d_m * d_m) * c0;
	tmp = 0.0;
	if (d_m <= 5.3e-160)
		tmp = t_0;
	elseif (d_m <= 1e+103)
		tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0);
	elseif (d_m <= 1.4e+277)
		tmp = t_0;
	else
		tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5);
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := Block[{t$95$0 = N[(N[(N[Power[N[(d$95$m * c0), $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(D * w), $MachinePrecision] * N[(D * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]}, Block[{t$95$1 = N[(N[(d$95$m * d$95$m), $MachinePrecision] * c0), $MachinePrecision]}, If[LessEqual[d$95$m, 5.3e-160], t$95$0, If[LessEqual[d$95$m, 1e+103], N[(N[(c0 * N[(N[(2.0 / N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(w * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d$95$m, 1.4e+277], t$95$0, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * N[(N[(h * w), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \frac{\frac{{\left(d\_m \cdot c0\right)}^{2}}{\left(D \cdot w\right) \cdot \left(D \cdot w\right)}}{h}\\
t_1 := \left(d\_m \cdot d\_m\right) \cdot c0\\
\mathbf{if}\;d\_m \leq 5.3 \cdot 10^{-160}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d\_m \leq 10^{+103}:\\
\;\;\;\;\frac{c0 \cdot \left(\frac{2}{\left(h \cdot w\right) \cdot D} \cdot \frac{t\_1}{D}\right)}{w \cdot 2}\\

\mathbf{elif}\;d\_m \leq 1.4 \cdot 10^{+277}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{t\_1}\right) \cdot -0.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < 5.3000000000000001e-160 or 1e103 < d < 1.39999999999999993e277

    1. Initial program 20.5%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around inf

      \[\leadsto \color{blue}{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h} \cdot {w}^{2}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      7. pow2N/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{h \cdot {w}^{2}} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{{w}^{2} \cdot \color{blue}{h}} \]
      11. unpow2N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      12. lower-*.f6434.2

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
    5. Applied rewrites34.2%

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

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

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

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      6. lift-*.f64N/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      8. pow2N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{{w}^{2} \cdot h} \]
      9. associate-/r*N/A

        \[\leadsto \frac{\frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{{w}^{2}}}{\color{blue}{h}} \]
    7. Applied rewrites42.2%

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

        \[\leadsto \frac{\frac{{\left(d \cdot c0\right)}^{2}}{{\left(D \cdot w\right)}^{2}}}{h} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(d \cdot c0\right)}^{2}}{{\left(D \cdot w\right)}^{2}}}{h} \]
      3. unpow2N/A

        \[\leadsto \frac{\frac{{\left(d \cdot c0\right)}^{2}}{\left(D \cdot w\right) \cdot \left(D \cdot w\right)}}{h} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\frac{{\left(d \cdot c0\right)}^{2}}{\left(D \cdot w\right) \cdot \left(D \cdot w\right)}}{h} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\frac{{\left(d \cdot c0\right)}^{2}}{\left(D \cdot w\right) \cdot \left(D \cdot w\right)}}{h} \]
      6. lift-*.f6442.2

        \[\leadsto \frac{\frac{{\left(d \cdot c0\right)}^{2}}{\left(D \cdot w\right) \cdot \left(D \cdot w\right)}}{h} \]
    9. Applied rewrites42.2%

      \[\leadsto \frac{\frac{{\left(d \cdot c0\right)}^{2}}{\left(D \cdot w\right) \cdot \left(D \cdot w\right)}}{h} \]

    if 5.3000000000000001e-160 < d < 1e103

    1. Initial program 37.4%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around inf

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2} \cdot \left(h \cdot w\right)}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2} \cdot \left(h \cdot w\right)}} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2}} \cdot \left(h \cdot w\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left({d}^{2} \cdot c0\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left({d}^{2} \cdot c0\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)} \]
      6. pow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{{D}^{2} \cdot \left(h \cdot w\right)} \]
      7. lift-*.f64N/A

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot w\right) \cdot \color{blue}{{D}^{2}}} \]
      9. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(w \cdot h\right) \cdot {\color{blue}{D}}^{2}} \]
      10. pow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(w \cdot h\right) \cdot \left(D \cdot \color{blue}{D}\right)} \]
      11. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(w \cdot h\right) \cdot D\right) \cdot \color{blue}{D}} \]
      12. lower-*.f64N/A

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      14. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      15. lower-*.f6454.6

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
    5. Applied rewrites54.6%

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

        \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D}} \]
      2. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\frac{c0}{2 \cdot w}} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      4. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{c0 \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D}}{2 \cdot w}} \]
      5. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{c0 \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D}}{2 \cdot w}} \]
    7. Applied rewrites58.9%

      \[\leadsto \color{blue}{\frac{c0 \cdot \left(\frac{2}{\left(h \cdot w\right) \cdot D} \cdot \frac{\left(d \cdot d\right) \cdot c0}{D}\right)}{w \cdot 2}} \]

    if 1.39999999999999993e277 < d

    1. Initial program 26.3%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in w around 0

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{\frac{-1}{2} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot {w}^{2}\right)\right)}{c0 \cdot {d}^{2}} + 2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot h}}{\color{blue}{w}} \]
    5. Applied rewrites21.5%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\frac{\mathsf{fma}\left(\frac{c0}{D \cdot D} \cdot \frac{d \cdot d}{h}, 2, \frac{{\left(D \cdot M\right)}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)}{\left(d \cdot d\right) \cdot c0} \cdot -0.5\right)}{w}} \]
    6. Taylor expanded in c0 around 0

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w\right)}{c0 \cdot {d}^{2}} \cdot \frac{-1}{2}\right) \]
      5. unpow-prod-downN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{\left(d \cdot d\right) \cdot c0} \cdot \frac{-1}{2}\right) \]
      14. lift-*.f6447.8

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{\left(d \cdot d\right) \cdot c0} \cdot -0.5\right) \]
    8. Applied rewrites47.8%

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{\left(d \cdot d\right) \cdot c0} \cdot \frac{-1}{2}\right) \]
      6. associate-/l*N/A

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left({\left(M \cdot D\right)}^{2} \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot \frac{-1}{2}\right) \]
      9. unpow-prod-downN/A

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(\left({M}^{2} \cdot {D}^{2}\right) \cdot \frac{h \cdot w}{c0 \cdot {d}^{2}}\right) \cdot \frac{-1}{2}\right) \]
      15. unpow-prod-downN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left({\left(M \cdot D\right)}^{2} \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot \frac{-1}{2}\right) \]
      23. lift-*.f6447.9

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left({\left(M \cdot D\right)}^{2} \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot -0.5\right) \]
    10. Applied rewrites47.9%

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot \frac{-1}{2}\right) \]
      6. lift-*.f6447.9

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot -0.5\right) \]
    12. Applied rewrites47.9%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot -0.5\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification45.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 5.3 \cdot 10^{-160}:\\ \;\;\;\;\frac{\frac{{\left(d \cdot c0\right)}^{2}}{\left(D \cdot w\right) \cdot \left(D \cdot w\right)}}{h}\\ \mathbf{elif}\;d \leq 10^{+103}:\\ \;\;\;\;\frac{c0 \cdot \left(\frac{2}{\left(h \cdot w\right) \cdot D} \cdot \frac{\left(d \cdot d\right) \cdot c0}{D}\right)}{w \cdot 2}\\ \mathbf{elif}\;d \leq 1.4 \cdot 10^{+277}:\\ \;\;\;\;\frac{\frac{{\left(d \cdot c0\right)}^{2}}{\left(D \cdot w\right) \cdot \left(D \cdot w\right)}}{h}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot -0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 49.2% accurate, 0.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \left(d\_m \cdot d\_m\right) \cdot c0\\ t_1 := \frac{c0 \cdot \left(d\_m \cdot d\_m\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right) \leq \infty:\\ \;\;\;\;\frac{c0 \cdot \left(\frac{2}{\left(h \cdot w\right) \cdot D} \cdot \frac{t\_0}{D}\right)}{w \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0 \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{t\_0} \cdot -0.5\right)}{w \cdot 2}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
 :precision binary64
 (let* ((t_0 (* (* d_m d_m) c0))
        (t_1 (/ (* c0 (* d_m d_m)) (* (* w h) (* D D)))))
   (if (<=
        (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))
        INFINITY)
     (/ (* c0 (* (/ 2.0 (* (* h w) D)) (/ t_0 D))) (* w 2.0))
     (/ (* c0 (* (/ (* (pow (* M D) 2.0) (* h w)) t_0) -0.5)) (* w 2.0)))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
	double t_0 = (d_m * d_m) * c0;
	double t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
		tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_0 / D))) / (w * 2.0);
	} else {
		tmp = (c0 * (((pow((M * D), 2.0) * (h * w)) / t_0) * -0.5)) / (w * 2.0);
	}
	return tmp;
}
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
	double t_0 = (d_m * d_m) * c0;
	double t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))))) <= Double.POSITIVE_INFINITY) {
		tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_0 / D))) / (w * 2.0);
	} else {
		tmp = (c0 * (((Math.pow((M * D), 2.0) * (h * w)) / t_0) * -0.5)) / (w * 2.0);
	}
	return tmp;
}
d_m = math.fabs(d)
def code(c0, w, h, D, d_m, M):
	t_0 = (d_m * d_m) * c0
	t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D))
	tmp = 0
	if ((c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))) <= math.inf:
		tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_0 / D))) / (w * 2.0)
	else:
		tmp = (c0 * (((math.pow((M * D), 2.0) * (h * w)) / t_0) * -0.5)) / (w * 2.0)
	return tmp
d_m = abs(d)
function code(c0, w, h, D, d_m, M)
	t_0 = Float64(Float64(d_m * d_m) * c0)
	t_1 = Float64(Float64(c0 * Float64(d_m * d_m)) / Float64(Float64(w * h) * Float64(D * D)))
	tmp = 0.0
	if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) <= Inf)
		tmp = Float64(Float64(c0 * Float64(Float64(2.0 / Float64(Float64(h * w) * D)) * Float64(t_0 / D))) / Float64(w * 2.0));
	else
		tmp = Float64(Float64(c0 * Float64(Float64(Float64((Float64(M * D) ^ 2.0) * Float64(h * w)) / t_0) * -0.5)) / Float64(w * 2.0));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(c0, w, h, D, d_m, M)
	t_0 = (d_m * d_m) * c0;
	t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D));
	tmp = 0.0;
	if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= Inf)
		tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_0 / D))) / (w * 2.0);
	else
		tmp = (c0 * (((((M * D) ^ 2.0) * (h * w)) / t_0) * -0.5)) / (w * 2.0);
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := Block[{t$95$0 = N[(N[(d$95$m * d$95$m), $MachinePrecision] * c0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(c0 * N[(N[(2.0 / N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(w * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c0 * N[(N[(N[(N[Power[N[(M * D), $MachinePrecision], 2.0], $MachinePrecision] * N[(h * w), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] / N[(w * 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \left(d\_m \cdot d\_m\right) \cdot c0\\
t_1 := \frac{c0 \cdot \left(d\_m \cdot d\_m\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;\frac{c0 \cdot \left(\frac{2}{\left(h \cdot w\right) \cdot D} \cdot \frac{t\_0}{D}\right)}{w \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{c0 \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{t\_0} \cdot -0.5\right)}{w \cdot 2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0

    1. Initial program 72.3%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around inf

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2} \cdot \left(h \cdot w\right)}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2} \cdot \left(h \cdot w\right)}} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2}} \cdot \left(h \cdot w\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left({d}^{2} \cdot c0\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left({d}^{2} \cdot c0\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)} \]
      6. pow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{{D}^{2} \cdot \left(h \cdot w\right)} \]
      7. lift-*.f64N/A

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot w\right) \cdot \color{blue}{{D}^{2}}} \]
      9. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(w \cdot h\right) \cdot {\color{blue}{D}}^{2}} \]
      10. pow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(w \cdot h\right) \cdot \left(D \cdot \color{blue}{D}\right)} \]
      11. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(w \cdot h\right) \cdot D\right) \cdot \color{blue}{D}} \]
      12. lower-*.f64N/A

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      14. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      15. lower-*.f6474.6

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
    5. Applied rewrites74.6%

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

        \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D}} \]
      2. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\frac{c0}{2 \cdot w}} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      4. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{c0 \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D}}{2 \cdot w}} \]
      5. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{c0 \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D}}{2 \cdot w}} \]
    7. Applied rewrites78.3%

      \[\leadsto \color{blue}{\frac{c0 \cdot \left(\frac{2}{\left(h \cdot w\right) \cdot D} \cdot \frac{\left(d \cdot d\right) \cdot c0}{D}\right)}{w \cdot 2}} \]

    if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M)))))

    1. Initial program 0.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in w around 0

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{\frac{-1}{2} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot {w}^{2}\right)\right)}{c0 \cdot {d}^{2}} + 2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot h}}{\color{blue}{w}} \]
    5. Applied rewrites6.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\frac{\mathsf{fma}\left(\frac{c0}{D \cdot D} \cdot \frac{d \cdot d}{h}, 2, \frac{{\left(D \cdot M\right)}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)}{\left(d \cdot d\right) \cdot c0} \cdot -0.5\right)}{w}} \]
    6. Taylor expanded in c0 around 0

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w\right)}{c0 \cdot {d}^{2}} \cdot \frac{-1}{2}\right) \]
      5. unpow-prod-downN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{\left(d \cdot d\right) \cdot c0} \cdot \frac{-1}{2}\right) \]
      14. lift-*.f6427.6

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{\left(d \cdot d\right) \cdot c0} \cdot -0.5\right) \]
    8. Applied rewrites27.6%

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

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

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

        \[\leadsto \color{blue}{\frac{c0}{2 \cdot w}} \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{\left(d \cdot d\right) \cdot c0} \cdot \frac{-1}{2}\right) \]
    10. Applied rewrites33.5%

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

Alternative 3: 34.4% accurate, 0.7× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)\\ t_1 := \frac{c0 \cdot \left(d\_m \cdot d\_m\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right) \leq \infty:\\ \;\;\;\;c0 \cdot \frac{\left(d\_m \cdot d\_m\right) \cdot c0}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\left(c0 \cdot c0\right) \cdot \left(d\_m \cdot \frac{d\_m}{t\_0}\right)\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
 :precision binary64
 (let* ((t_0 (* (* (* w w) h) (* D D)))
        (t_1 (/ (* c0 (* d_m d_m)) (* (* w h) (* D D)))))
   (if (<=
        (* (/ c0 (* 2.0 w)) (+ t_1 (sqrt (- (* t_1 t_1) (* M M)))))
        INFINITY)
     (* c0 (/ (* (* d_m d_m) c0) t_0))
     (* (* c0 c0) (* d_m (/ d_m t_0))))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
	double t_0 = ((w * w) * h) * (D * D);
	double t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= ((double) INFINITY)) {
		tmp = c0 * (((d_m * d_m) * c0) / t_0);
	} else {
		tmp = (c0 * c0) * (d_m * (d_m / t_0));
	}
	return tmp;
}
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
	double t_0 = ((w * w) * h) * (D * D);
	double t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))))) <= Double.POSITIVE_INFINITY) {
		tmp = c0 * (((d_m * d_m) * c0) / t_0);
	} else {
		tmp = (c0 * c0) * (d_m * (d_m / t_0));
	}
	return tmp;
}
d_m = math.fabs(d)
def code(c0, w, h, D, d_m, M):
	t_0 = ((w * w) * h) * (D * D)
	t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D))
	tmp = 0
	if ((c0 / (2.0 * w)) * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))) <= math.inf:
		tmp = c0 * (((d_m * d_m) * c0) / t_0)
	else:
		tmp = (c0 * c0) * (d_m * (d_m / t_0))
	return tmp
d_m = abs(d)
function code(c0, w, h, D, d_m, M)
	t_0 = Float64(Float64(Float64(w * w) * h) * Float64(D * D))
	t_1 = Float64(Float64(c0 * Float64(d_m * d_m)) / Float64(Float64(w * h) * Float64(D * D)))
	tmp = 0.0
	if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M))))) <= Inf)
		tmp = Float64(c0 * Float64(Float64(Float64(d_m * d_m) * c0) / t_0));
	else
		tmp = Float64(Float64(c0 * c0) * Float64(d_m * Float64(d_m / t_0)));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(c0, w, h, D, d_m, M)
	t_0 = ((w * w) * h) * (D * D);
	t_1 = (c0 * (d_m * d_m)) / ((w * h) * (D * D));
	tmp = 0.0;
	if (((c0 / (2.0 * w)) * (t_1 + sqrt(((t_1 * t_1) - (M * M))))) <= Inf)
		tmp = c0 * (((d_m * d_m) * c0) / t_0);
	else
		tmp = (c0 * c0) * (d_m * (d_m / t_0));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := Block[{t$95$0 = N[(N[(N[(w * w), $MachinePrecision] * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d$95$m * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(c0 * N[(N[(N[(d$95$m * d$95$m), $MachinePrecision] * c0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(c0 * c0), $MachinePrecision] * N[(d$95$m * N[(d$95$m / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)\\
t_1 := \frac{c0 \cdot \left(d\_m \cdot d\_m\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;c0 \cdot \frac{\left(d\_m \cdot d\_m\right) \cdot c0}{t\_0}\\

\mathbf{else}:\\
\;\;\;\;\left(c0 \cdot c0\right) \cdot \left(d\_m \cdot \frac{d\_m}{t\_0}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < +inf.0

    1. Initial program 72.3%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around inf

      \[\leadsto \color{blue}{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h} \cdot {w}^{2}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      7. pow2N/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{h \cdot {w}^{2}} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{{w}^{2} \cdot \color{blue}{h}} \]
      11. unpow2N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      12. lower-*.f6461.5

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
    5. Applied rewrites61.5%

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

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

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

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      6. unpow-prod-downN/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      7. pow2N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\left(w \cdot \color{blue}{w}\right) \cdot h} \]
      8. associate-/l/N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)}} \]
      9. lift-*.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot \color{blue}{h}\right)} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)} \]
      11. pow2N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)} \]
      12. *-commutativeN/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot \color{blue}{{w}^{2}}\right)} \]
      13. associate-/l*N/A

        \[\leadsto {c0}^{2} \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      14. lower-*.f64N/A

        \[\leadsto {c0}^{2} \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      15. unpow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      16. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      17. lower-/.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{{d}^{2}}{\color{blue}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      18. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      19. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      20. associate-*r*N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
      21. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
    7. Applied rewrites53.9%

      \[\leadsto \left(c0 \cdot c0\right) \cdot \color{blue}{\frac{d \cdot d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{\color{blue}{d \cdot d}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \color{blue}{\frac{d \cdot d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}} \]
      3. associate-*l*N/A

        \[\leadsto c0 \cdot \color{blue}{\left(c0 \cdot \frac{d \cdot d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}\right)} \]
      4. lift-*.f64N/A

        \[\leadsto c0 \cdot \left(c0 \cdot \frac{d \cdot d}{\color{blue}{\left(\left(D \cdot D\right) \cdot h\right)} \cdot \left(w \cdot w\right)}\right) \]
      5. lift-/.f64N/A

        \[\leadsto c0 \cdot \left(c0 \cdot \frac{d \cdot d}{\color{blue}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}}\right) \]
      6. pow2N/A

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

        \[\leadsto c0 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot \color{blue}{w}\right)}\right) \]
      8. lift-*.f64N/A

        \[\leadsto c0 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \color{blue}{\left(w \cdot w\right)}}\right) \]
      9. lift-*.f64N/A

        \[\leadsto c0 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}\right) \]
      10. lift-*.f64N/A

        \[\leadsto c0 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(\color{blue}{w} \cdot w\right)}\right) \]
      11. pow2N/A

        \[\leadsto c0 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left({D}^{2} \cdot h\right) \cdot \left(w \cdot w\right)}\right) \]
      12. pow2N/A

        \[\leadsto c0 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left({D}^{2} \cdot h\right) \cdot {w}^{\color{blue}{2}}}\right) \]
      13. associate-*r*N/A

        \[\leadsto c0 \cdot \left(c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \color{blue}{\left(h \cdot {w}^{2}\right)}}\right) \]
      14. associate-/l*N/A

        \[\leadsto c0 \cdot \frac{c0 \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
    9. Applied rewrites63.4%

      \[\leadsto c0 \cdot \color{blue}{\frac{\left(d \cdot d\right) \cdot c0}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)}} \]

    if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #s(literal 2 binary64) w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M)))))

    1. Initial program 0.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around inf

      \[\leadsto \color{blue}{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h} \cdot {w}^{2}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      7. pow2N/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{h \cdot {w}^{2}} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{{w}^{2} \cdot \color{blue}{h}} \]
      11. unpow2N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      12. lower-*.f6423.1

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
    5. Applied rewrites23.1%

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

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

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

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      6. unpow-prod-downN/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      7. pow2N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\left(w \cdot \color{blue}{w}\right) \cdot h} \]
      8. associate-/l/N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)}} \]
      9. lift-*.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot \color{blue}{h}\right)} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)} \]
      11. pow2N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)} \]
      12. *-commutativeN/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot \color{blue}{{w}^{2}}\right)} \]
      13. associate-/l*N/A

        \[\leadsto {c0}^{2} \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      14. lower-*.f64N/A

        \[\leadsto {c0}^{2} \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      15. unpow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      16. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      17. lower-/.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{{d}^{2}}{\color{blue}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      18. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      19. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      20. associate-*r*N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
      21. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
    7. Applied rewrites11.1%

      \[\leadsto \left(c0 \cdot c0\right) \cdot \color{blue}{\frac{d \cdot d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\color{blue}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}} \]
      3. associate-/l*N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \color{blue}{\frac{d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}}\right) \]
      4. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \color{blue}{\frac{d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot \color{blue}{w}\right)}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \color{blue}{\left(w \cdot w\right)}}\right) \]
      7. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}\right) \]
      8. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(\color{blue}{w} \cdot w\right)}\right) \]
      9. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left({D}^{2} \cdot h\right) \cdot \left(w \cdot w\right)}\right) \]
      10. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left({D}^{2} \cdot h\right) \cdot {w}^{\color{blue}{2}}}\right) \]
      11. associate-*r*N/A

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

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\color{blue}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}}\right) \]
      13. *-commutativeN/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(h \cdot {w}^{2}\right) \cdot \color{blue}{{D}^{2}}}\right) \]
      14. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(h \cdot {w}^{2}\right) \cdot \color{blue}{{D}^{2}}}\right) \]
      15. *-commutativeN/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left({w}^{2} \cdot h\right) \cdot {\color{blue}{D}}^{2}}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left({w}^{2} \cdot h\right) \cdot {\color{blue}{D}}^{2}}\right) \]
      17. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(w \cdot w\right) \cdot h\right) \cdot {D}^{2}}\right) \]
      18. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(w \cdot w\right) \cdot h\right) \cdot {D}^{2}}\right) \]
      19. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot \color{blue}{D}\right)}\right) \]
      20. lift-*.f6423.4

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot \color{blue}{D}\right)}\right) \]
    9. Applied rewrites23.4%

      \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \color{blue}{\frac{d}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)}}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification36.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \leq \infty:\\ \;\;\;\;c0 \cdot \frac{\left(d \cdot d\right) \cdot c0}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 42.5% accurate, 1.0× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \frac{{\left(d\_m \cdot c0\right)}^{2}}{\left(\left(D \cdot w\right) \cdot \left(D \cdot w\right)\right) \cdot h}\\ t_1 := \left(d\_m \cdot d\_m\right) \cdot c0\\ \mathbf{if}\;d\_m \leq 3.1 \cdot 10^{-136}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d\_m \leq 1.85 \cdot 10^{+104}:\\ \;\;\;\;\frac{c0 \cdot \left(\frac{2}{\left(h \cdot w\right) \cdot D} \cdot \frac{t\_1}{D}\right)}{w \cdot 2}\\ \mathbf{elif}\;d\_m \leq 1.4 \cdot 10^{+277}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{t\_1}\right) \cdot -0.5\right)\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
 :precision binary64
 (let* ((t_0 (/ (pow (* d_m c0) 2.0) (* (* (* D w) (* D w)) h)))
        (t_1 (* (* d_m d_m) c0)))
   (if (<= d_m 3.1e-136)
     t_0
     (if (<= d_m 1.85e+104)
       (/ (* c0 (* (/ 2.0 (* (* h w) D)) (/ t_1 D))) (* w 2.0))
       (if (<= d_m 1.4e+277)
         t_0
         (*
          (/ c0 (* 2.0 w))
          (* (* (* (* M D) (* M D)) (/ (* h w) t_1)) -0.5)))))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
	double t_0 = pow((d_m * c0), 2.0) / (((D * w) * (D * w)) * h);
	double t_1 = (d_m * d_m) * c0;
	double tmp;
	if (d_m <= 3.1e-136) {
		tmp = t_0;
	} else if (d_m <= 1.85e+104) {
		tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0);
	} else if (d_m <= 1.4e+277) {
		tmp = t_0;
	} else {
		tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5);
	}
	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(c0, w, h, d, d_m, m)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_m
    real(8), intent (in) :: m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = ((d_m * c0) ** 2.0d0) / (((d * w) * (d * w)) * h)
    t_1 = (d_m * d_m) * c0
    if (d_m <= 3.1d-136) then
        tmp = t_0
    else if (d_m <= 1.85d+104) then
        tmp = (c0 * ((2.0d0 / ((h * w) * d)) * (t_1 / d))) / (w * 2.0d0)
    else if (d_m <= 1.4d+277) then
        tmp = t_0
    else
        tmp = (c0 / (2.0d0 * w)) * ((((m * d) * (m * d)) * ((h * w) / t_1)) * (-0.5d0))
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
	double t_0 = Math.pow((d_m * c0), 2.0) / (((D * w) * (D * w)) * h);
	double t_1 = (d_m * d_m) * c0;
	double tmp;
	if (d_m <= 3.1e-136) {
		tmp = t_0;
	} else if (d_m <= 1.85e+104) {
		tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0);
	} else if (d_m <= 1.4e+277) {
		tmp = t_0;
	} else {
		tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5);
	}
	return tmp;
}
d_m = math.fabs(d)
def code(c0, w, h, D, d_m, M):
	t_0 = math.pow((d_m * c0), 2.0) / (((D * w) * (D * w)) * h)
	t_1 = (d_m * d_m) * c0
	tmp = 0
	if d_m <= 3.1e-136:
		tmp = t_0
	elif d_m <= 1.85e+104:
		tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0)
	elif d_m <= 1.4e+277:
		tmp = t_0
	else:
		tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5)
	return tmp
d_m = abs(d)
function code(c0, w, h, D, d_m, M)
	t_0 = Float64((Float64(d_m * c0) ^ 2.0) / Float64(Float64(Float64(D * w) * Float64(D * w)) * h))
	t_1 = Float64(Float64(d_m * d_m) * c0)
	tmp = 0.0
	if (d_m <= 3.1e-136)
		tmp = t_0;
	elseif (d_m <= 1.85e+104)
		tmp = Float64(Float64(c0 * Float64(Float64(2.0 / Float64(Float64(h * w) * D)) * Float64(t_1 / D))) / Float64(w * 2.0));
	elseif (d_m <= 1.4e+277)
		tmp = t_0;
	else
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * Float64(Float64(h * w) / t_1)) * -0.5));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(c0, w, h, D, d_m, M)
	t_0 = ((d_m * c0) ^ 2.0) / (((D * w) * (D * w)) * h);
	t_1 = (d_m * d_m) * c0;
	tmp = 0.0;
	if (d_m <= 3.1e-136)
		tmp = t_0;
	elseif (d_m <= 1.85e+104)
		tmp = (c0 * ((2.0 / ((h * w) * D)) * (t_1 / D))) / (w * 2.0);
	elseif (d_m <= 1.4e+277)
		tmp = t_0;
	else
		tmp = (c0 / (2.0 * w)) * ((((M * D) * (M * D)) * ((h * w) / t_1)) * -0.5);
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := Block[{t$95$0 = N[(N[Power[N[(d$95$m * c0), $MachinePrecision], 2.0], $MachinePrecision] / N[(N[(N[(D * w), $MachinePrecision] * N[(D * w), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(d$95$m * d$95$m), $MachinePrecision] * c0), $MachinePrecision]}, If[LessEqual[d$95$m, 3.1e-136], t$95$0, If[LessEqual[d$95$m, 1.85e+104], N[(N[(c0 * N[(N[(2.0 / N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(w * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d$95$m, 1.4e+277], t$95$0, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * N[(N[(h * w), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \frac{{\left(d\_m \cdot c0\right)}^{2}}{\left(\left(D \cdot w\right) \cdot \left(D \cdot w\right)\right) \cdot h}\\
t_1 := \left(d\_m \cdot d\_m\right) \cdot c0\\
\mathbf{if}\;d\_m \leq 3.1 \cdot 10^{-136}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d\_m \leq 1.85 \cdot 10^{+104}:\\
\;\;\;\;\frac{c0 \cdot \left(\frac{2}{\left(h \cdot w\right) \cdot D} \cdot \frac{t\_1}{D}\right)}{w \cdot 2}\\

\mathbf{elif}\;d\_m \leq 1.4 \cdot 10^{+277}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{t\_1}\right) \cdot -0.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < 3.1e-136 or 1.8499999999999999e104 < d < 1.39999999999999993e277

    1. Initial program 20.5%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around inf

      \[\leadsto \color{blue}{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h} \cdot {w}^{2}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      7. pow2N/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{h \cdot {w}^{2}} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{{w}^{2} \cdot \color{blue}{h}} \]
      11. unpow2N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      12. lower-*.f6434.6

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
    5. Applied rewrites34.6%

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

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

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

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      6. lift-*.f64N/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      8. pow2N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{{w}^{2} \cdot h} \]
      9. associate-/r*N/A

        \[\leadsto \frac{\frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{{w}^{2}}}{\color{blue}{h}} \]
    7. Applied rewrites42.5%

      \[\leadsto \color{blue}{\frac{\frac{{\left(d \cdot c0\right)}^{2}}{{\left(D \cdot w\right)}^{2}}}{h}} \]
    8. Step-by-step derivation
      1. count-2-rev42.5

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

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

        \[\leadsto \frac{\frac{{\left(d \cdot c0\right)}^{2}}{{\left(D \cdot w\right)}^{2}}}{h} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\frac{{\left(d \cdot c0\right)}^{2}}{{\left(D \cdot w\right)}^{2}}}{h} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(d \cdot c0\right)}^{2}}{{\left(D \cdot w\right)}^{2}}}{h} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\frac{{\left(d \cdot c0\right)}^{2}}{{\left(D \cdot w\right)}^{2}}}{h} \]
      7. lift-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(d \cdot c0\right)}^{2}}{{\left(D \cdot w\right)}^{2}}}{h} \]
      8. lift-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(d \cdot c0\right)}^{2}}{{\left(D \cdot w\right)}^{2}}}{h} \]
      9. lift-*.f64N/A

        \[\leadsto \frac{\frac{{\left(d \cdot c0\right)}^{2}}{{\left(D \cdot w\right)}^{2}}}{h} \]
      10. associate-/l/N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\color{blue}{{\left(D \cdot w\right)}^{2} \cdot h}} \]
    9. Applied rewrites42.9%

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

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{{\left(D \cdot w\right)}^{2} \cdot h} \]
      2. lift-pow.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{{\left(D \cdot w\right)}^{2} \cdot h} \]
      3. unpow2N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot w\right) \cdot \left(D \cdot w\right)\right) \cdot h} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot w\right) \cdot \left(D \cdot w\right)\right) \cdot h} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot w\right) \cdot \left(D \cdot w\right)\right) \cdot h} \]
      6. lift-*.f6442.9

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot w\right) \cdot \left(D \cdot w\right)\right) \cdot h} \]
    11. Applied rewrites42.9%

      \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot w\right) \cdot \left(D \cdot w\right)\right) \cdot h} \]

    if 3.1e-136 < d < 1.8499999999999999e104

    1. Initial program 37.9%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around inf

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2} \cdot \left(h \cdot w\right)}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2} \cdot \left(h \cdot w\right)}} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2}} \cdot \left(h \cdot w\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left({d}^{2} \cdot c0\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left({d}^{2} \cdot c0\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)} \]
      6. pow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{{D}^{2} \cdot \left(h \cdot w\right)} \]
      7. lift-*.f64N/A

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot w\right) \cdot \color{blue}{{D}^{2}}} \]
      9. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(w \cdot h\right) \cdot {\color{blue}{D}}^{2}} \]
      10. pow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(w \cdot h\right) \cdot \left(D \cdot \color{blue}{D}\right)} \]
      11. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(w \cdot h\right) \cdot D\right) \cdot \color{blue}{D}} \]
      12. lower-*.f64N/A

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      14. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      15. lower-*.f6453.5

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
    5. Applied rewrites53.5%

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

        \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D}} \]
      2. lift-*.f64N/A

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

        \[\leadsto \color{blue}{\frac{c0}{2 \cdot w}} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      4. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{c0 \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D}}{2 \cdot w}} \]
      5. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{c0 \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D}}{2 \cdot w}} \]
    7. Applied rewrites57.9%

      \[\leadsto \color{blue}{\frac{c0 \cdot \left(\frac{2}{\left(h \cdot w\right) \cdot D} \cdot \frac{\left(d \cdot d\right) \cdot c0}{D}\right)}{w \cdot 2}} \]

    if 1.39999999999999993e277 < d

    1. Initial program 26.3%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in w around 0

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{\frac{-1}{2} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot {w}^{2}\right)\right)}{c0 \cdot {d}^{2}} + 2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot h}}{\color{blue}{w}} \]
    5. Applied rewrites21.5%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\frac{\mathsf{fma}\left(\frac{c0}{D \cdot D} \cdot \frac{d \cdot d}{h}, 2, \frac{{\left(D \cdot M\right)}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)}{\left(d \cdot d\right) \cdot c0} \cdot -0.5\right)}{w}} \]
    6. Taylor expanded in c0 around 0

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w\right)}{c0 \cdot {d}^{2}} \cdot \frac{-1}{2}\right) \]
      5. unpow-prod-downN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{\left(d \cdot d\right) \cdot c0} \cdot \frac{-1}{2}\right) \]
      14. lift-*.f6447.8

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{\left(d \cdot d\right) \cdot c0} \cdot -0.5\right) \]
    8. Applied rewrites47.8%

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{\left(d \cdot d\right) \cdot c0} \cdot \frac{-1}{2}\right) \]
      6. associate-/l*N/A

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left({\left(M \cdot D\right)}^{2} \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot \frac{-1}{2}\right) \]
      9. unpow-prod-downN/A

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(\left({M}^{2} \cdot {D}^{2}\right) \cdot \frac{h \cdot w}{c0 \cdot {d}^{2}}\right) \cdot \frac{-1}{2}\right) \]
      15. unpow-prod-downN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left({\left(M \cdot D\right)}^{2} \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot \frac{-1}{2}\right) \]
      23. lift-*.f6447.9

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left({\left(M \cdot D\right)}^{2} \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot -0.5\right) \]
    10. Applied rewrites47.9%

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot \frac{-1}{2}\right) \]
      6. lift-*.f6447.9

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot -0.5\right) \]
    12. Applied rewrites47.9%

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

Alternative 5: 40.3% accurate, 2.0× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} t_0 := \frac{c0}{2 \cdot w}\\ \mathbf{if}\;d\_m \leq 4.4 \cdot 10^{+271}:\\ \;\;\;\;t\_0 \cdot \frac{2 \cdot \left(\left(d\_m \cdot c0\right) \cdot d\_m\right)}{\left(h \cdot \left(w \cdot D\right)\right) \cdot D}\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{\left(d\_m \cdot d\_m\right) \cdot c0}\right) \cdot -0.5\right)\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
 :precision binary64
 (let* ((t_0 (/ c0 (* 2.0 w))))
   (if (<= d_m 4.4e+271)
     (* t_0 (/ (* 2.0 (* (* d_m c0) d_m)) (* (* h (* w D)) D)))
     (* t_0 (* (* (* (* M D) (* M D)) (/ (* h w) (* (* d_m d_m) c0))) -0.5)))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
	double t_0 = c0 / (2.0 * w);
	double tmp;
	if (d_m <= 4.4e+271) {
		tmp = t_0 * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D));
	} else {
		tmp = t_0 * ((((M * D) * (M * D)) * ((h * w) / ((d_m * d_m) * c0))) * -0.5);
	}
	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(c0, w, h, d, d_m, m)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_m
    real(8), intent (in) :: m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = c0 / (2.0d0 * w)
    if (d_m <= 4.4d+271) then
        tmp = t_0 * ((2.0d0 * ((d_m * c0) * d_m)) / ((h * (w * d)) * d))
    else
        tmp = t_0 * ((((m * d) * (m * d)) * ((h * w) / ((d_m * d_m) * c0))) * (-0.5d0))
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
	double t_0 = c0 / (2.0 * w);
	double tmp;
	if (d_m <= 4.4e+271) {
		tmp = t_0 * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D));
	} else {
		tmp = t_0 * ((((M * D) * (M * D)) * ((h * w) / ((d_m * d_m) * c0))) * -0.5);
	}
	return tmp;
}
d_m = math.fabs(d)
def code(c0, w, h, D, d_m, M):
	t_0 = c0 / (2.0 * w)
	tmp = 0
	if d_m <= 4.4e+271:
		tmp = t_0 * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D))
	else:
		tmp = t_0 * ((((M * D) * (M * D)) * ((h * w) / ((d_m * d_m) * c0))) * -0.5)
	return tmp
d_m = abs(d)
function code(c0, w, h, D, d_m, M)
	t_0 = Float64(c0 / Float64(2.0 * w))
	tmp = 0.0
	if (d_m <= 4.4e+271)
		tmp = Float64(t_0 * Float64(Float64(2.0 * Float64(Float64(d_m * c0) * d_m)) / Float64(Float64(h * Float64(w * D)) * D)));
	else
		tmp = Float64(t_0 * Float64(Float64(Float64(Float64(M * D) * Float64(M * D)) * Float64(Float64(h * w) / Float64(Float64(d_m * d_m) * c0))) * -0.5));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(c0, w, h, D, d_m, M)
	t_0 = c0 / (2.0 * w);
	tmp = 0.0;
	if (d_m <= 4.4e+271)
		tmp = t_0 * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D));
	else
		tmp = t_0 * ((((M * D) * (M * D)) * ((h * w) / ((d_m * d_m) * c0))) * -0.5);
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d$95$m, 4.4e+271], N[(t$95$0 * N[(N[(2.0 * N[(N[(d$95$m * c0), $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(h * N[(w * D), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] * N[(N[(h * w), $MachinePrecision] / N[(N[(d$95$m * d$95$m), $MachinePrecision] * c0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
t_0 := \frac{c0}{2 \cdot w}\\
\mathbf{if}\;d\_m \leq 4.4 \cdot 10^{+271}:\\
\;\;\;\;t\_0 \cdot \frac{2 \cdot \left(\left(d\_m \cdot c0\right) \cdot d\_m\right)}{\left(h \cdot \left(w \cdot D\right)\right) \cdot D}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 4.40000000000000002e271

    1. Initial program 23.5%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around inf

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2} \cdot \left(h \cdot w\right)}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2} \cdot \left(h \cdot w\right)}} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2}} \cdot \left(h \cdot w\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left({d}^{2} \cdot c0\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left({d}^{2} \cdot c0\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)} \]
      6. pow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{{D}^{2} \cdot \left(h \cdot w\right)} \]
      7. lift-*.f64N/A

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot w\right) \cdot \color{blue}{{D}^{2}}} \]
      9. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(w \cdot h\right) \cdot {\color{blue}{D}}^{2}} \]
      10. pow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(w \cdot h\right) \cdot \left(D \cdot \color{blue}{D}\right)} \]
      11. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(w \cdot h\right) \cdot D\right) \cdot \color{blue}{D}} \]
      12. lower-*.f64N/A

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      14. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      15. lower-*.f6437.4

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
    5. Applied rewrites37.4%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      3. associate-*l*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot \left(w \cdot D\right)\right) \cdot D} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot \left(w \cdot D\right)\right) \cdot D} \]
      5. lower-*.f6437.4

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot \left(w \cdot D\right)\right) \cdot D} \]
    7. Applied rewrites37.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot \left(w \cdot D\right)\right) \cdot D} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot \color{blue}{\left(w \cdot D\right)}\right) \cdot D} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot \left(\color{blue}{w} \cdot D\right)\right) \cdot D} \]
      3. pow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left({d}^{2} \cdot c0\right)}{\left(h \cdot \left(\color{blue}{w} \cdot D\right)\right) \cdot D} \]
      4. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\left(h \cdot \color{blue}{\left(w \cdot D\right)}\right) \cdot D} \]
      5. pow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot \left(d \cdot d\right)\right)}{\left(h \cdot \left(w \cdot \color{blue}{D}\right)\right) \cdot D} \]
      6. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(c0 \cdot d\right) \cdot d\right)}{\left(h \cdot \color{blue}{\left(w \cdot D\right)}\right) \cdot D} \]
      7. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot c0\right) \cdot d\right)}{\left(h \cdot \left(\color{blue}{w} \cdot D\right)\right) \cdot D} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot c0\right) \cdot d\right)}{\left(h \cdot \color{blue}{\left(w \cdot D\right)}\right) \cdot D} \]
      9. lift-*.f6443.0

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot c0\right) \cdot d\right)}{\left(h \cdot \left(\color{blue}{w} \cdot D\right)\right) \cdot D} \]
    9. Applied rewrites43.0%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot c0\right) \cdot d\right)}{\left(h \cdot \color{blue}{\left(w \cdot D\right)}\right) \cdot D} \]

    if 4.40000000000000002e271 < d

    1. Initial program 26.3%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in w around 0

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{\frac{-1}{2} \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot {w}^{2}\right)\right)}{c0 \cdot {d}^{2}} + 2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot h}}{\color{blue}{w}} \]
    5. Applied rewrites21.5%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\frac{\mathsf{fma}\left(\frac{c0}{D \cdot D} \cdot \frac{d \cdot d}{h}, 2, \frac{{\left(D \cdot M\right)}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)}{\left(d \cdot d\right) \cdot c0} \cdot -0.5\right)}{w}} \]
    6. Taylor expanded in c0 around 0

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{\left({D}^{2} \cdot {M}^{2}\right) \cdot \left(h \cdot w\right)}{c0 \cdot {d}^{2}} \cdot \frac{-1}{2}\right) \]
      5. unpow-prod-downN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{\left(d \cdot d\right) \cdot c0} \cdot \frac{-1}{2}\right) \]
      14. lift-*.f6447.8

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{\left(d \cdot d\right) \cdot c0} \cdot -0.5\right) \]
    8. Applied rewrites47.8%

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{{\left(M \cdot D\right)}^{2} \cdot \left(h \cdot w\right)}{\left(d \cdot d\right) \cdot c0} \cdot \frac{-1}{2}\right) \]
      6. associate-/l*N/A

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left({\left(M \cdot D\right)}^{2} \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot \frac{-1}{2}\right) \]
      9. unpow-prod-downN/A

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(\left({M}^{2} \cdot {D}^{2}\right) \cdot \frac{h \cdot w}{c0 \cdot {d}^{2}}\right) \cdot \frac{-1}{2}\right) \]
      15. unpow-prod-downN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left({\left(M \cdot D\right)}^{2} \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot \frac{-1}{2}\right) \]
      23. lift-*.f6447.9

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left({\left(M \cdot D\right)}^{2} \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot -0.5\right) \]
    10. Applied rewrites47.9%

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot \frac{-1}{2}\right) \]
      6. lift-*.f6447.9

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\left(\left(\left(M \cdot D\right) \cdot \left(M \cdot D\right)\right) \cdot \frac{h \cdot w}{\left(d \cdot d\right) \cdot c0}\right) \cdot -0.5\right) \]
    12. Applied rewrites47.9%

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

Alternative 6: 39.2% accurate, 2.1× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;d\_m \leq 1.4 \cdot 10^{-161} \lor \neg \left(d\_m \leq 1.35 \cdot 10^{+177}\right):\\ \;\;\;\;\frac{\left(d\_m \cdot c0\right) \cdot \left(d\_m \cdot c0\right)}{\left(D \cdot \left(D \cdot h\right)\right) \cdot \left(w \cdot w\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{w + w} \cdot \frac{2 \cdot \left(\left(d\_m \cdot d\_m\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
 :precision binary64
 (if (or (<= d_m 1.4e-161) (not (<= d_m 1.35e+177)))
   (/ (* (* d_m c0) (* d_m c0)) (* (* D (* D h)) (* w w)))
   (* (/ c0 (+ w w)) (/ (* 2.0 (* (* d_m d_m) c0)) (* (* (* h w) D) D)))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
	double tmp;
	if ((d_m <= 1.4e-161) || !(d_m <= 1.35e+177)) {
		tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w));
	} else {
		tmp = (c0 / (w + w)) * ((2.0 * ((d_m * d_m) * c0)) / (((h * w) * D) * D));
	}
	return tmp;
}
d_m =     private
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(c0, w, h, d, d_m, m)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_m
    real(8), intent (in) :: m
    real(8) :: tmp
    if ((d_m <= 1.4d-161) .or. (.not. (d_m <= 1.35d+177))) then
        tmp = ((d_m * c0) * (d_m * c0)) / ((d * (d * h)) * (w * w))
    else
        tmp = (c0 / (w + w)) * ((2.0d0 * ((d_m * d_m) * c0)) / (((h * w) * d) * d))
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
	double tmp;
	if ((d_m <= 1.4e-161) || !(d_m <= 1.35e+177)) {
		tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w));
	} else {
		tmp = (c0 / (w + w)) * ((2.0 * ((d_m * d_m) * c0)) / (((h * w) * D) * D));
	}
	return tmp;
}
d_m = math.fabs(d)
def code(c0, w, h, D, d_m, M):
	tmp = 0
	if (d_m <= 1.4e-161) or not (d_m <= 1.35e+177):
		tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w))
	else:
		tmp = (c0 / (w + w)) * ((2.0 * ((d_m * d_m) * c0)) / (((h * w) * D) * D))
	return tmp
d_m = abs(d)
function code(c0, w, h, D, d_m, M)
	tmp = 0.0
	if ((d_m <= 1.4e-161) || !(d_m <= 1.35e+177))
		tmp = Float64(Float64(Float64(d_m * c0) * Float64(d_m * c0)) / Float64(Float64(D * Float64(D * h)) * Float64(w * w)));
	else
		tmp = Float64(Float64(c0 / Float64(w + w)) * Float64(Float64(2.0 * Float64(Float64(d_m * d_m) * c0)) / Float64(Float64(Float64(h * w) * D) * D)));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(c0, w, h, D, d_m, M)
	tmp = 0.0;
	if ((d_m <= 1.4e-161) || ~((d_m <= 1.35e+177)))
		tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w));
	else
		tmp = (c0 / (w + w)) * ((2.0 * ((d_m * d_m) * c0)) / (((h * w) * D) * D));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := If[Or[LessEqual[d$95$m, 1.4e-161], N[Not[LessEqual[d$95$m, 1.35e+177]], $MachinePrecision]], N[(N[(N[(d$95$m * c0), $MachinePrecision] * N[(d$95$m * c0), $MachinePrecision]), $MachinePrecision] / N[(N[(D * N[(D * h), $MachinePrecision]), $MachinePrecision] * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c0 / N[(w + w), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * N[(N[(d$95$m * d$95$m), $MachinePrecision] * c0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
\mathbf{if}\;d\_m \leq 1.4 \cdot 10^{-161} \lor \neg \left(d\_m \leq 1.35 \cdot 10^{+177}\right):\\
\;\;\;\;\frac{\left(d\_m \cdot c0\right) \cdot \left(d\_m \cdot c0\right)}{\left(D \cdot \left(D \cdot h\right)\right) \cdot \left(w \cdot w\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{c0}{w + w} \cdot \frac{2 \cdot \left(\left(d\_m \cdot d\_m\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 1.39999999999999996e-161 or 1.34999999999999995e177 < d

    1. Initial program 20.1%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around inf

      \[\leadsto \color{blue}{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h} \cdot {w}^{2}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      7. pow2N/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{h \cdot {w}^{2}} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{{w}^{2} \cdot \color{blue}{h}} \]
      11. unpow2N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      12. lower-*.f6433.4

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
    5. Applied rewrites33.4%

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

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

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

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      6. unpow-prod-downN/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      7. pow2N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\left(w \cdot \color{blue}{w}\right) \cdot h} \]
      8. associate-/l/N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)}} \]
      9. lift-*.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot \color{blue}{h}\right)} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)} \]
      11. pow2N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)} \]
      12. *-commutativeN/A

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

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      14. unpow-prod-downN/A

        \[\leadsto \frac{{\left(c0 \cdot d\right)}^{2}}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{{\left(c0 \cdot d\right)}^{2}}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      16. *-commutativeN/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{{\color{blue}{D}}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{{\color{blue}{D}}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      18. associate-*r*N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
      19. lower-*.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
      20. lower-*.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left({D}^{2} \cdot h\right) \cdot {\color{blue}{w}}^{2}} \]
      21. pow2N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot {w}^{2}} \]
      22. lift-*.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot {w}^{2}} \]
      23. pow2N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot \color{blue}{w}\right)} \]
    7. Applied rewrites32.8%

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

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(\color{blue}{w} \cdot w\right)} \]
      3. associate-*l*N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(D \cdot \left(D \cdot h\right)\right) \cdot \left(\color{blue}{w} \cdot w\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(D \cdot \left(D \cdot h\right)\right) \cdot \left(\color{blue}{w} \cdot w\right)} \]
      5. lower-*.f6435.4

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(D \cdot \left(D \cdot h\right)\right) \cdot \left(w \cdot w\right)} \]
    9. Applied rewrites35.4%

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

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

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\color{blue}{\left(D \cdot \left(D \cdot h\right)\right)} \cdot \left(w \cdot w\right)} \]
      3. unpow2N/A

        \[\leadsto \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\color{blue}{\left(D \cdot \left(D \cdot h\right)\right)} \cdot \left(w \cdot w\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\color{blue}{\left(D \cdot \left(D \cdot h\right)\right)} \cdot \left(w \cdot w\right)} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\left(\color{blue}{D} \cdot \left(D \cdot h\right)\right) \cdot \left(w \cdot w\right)} \]
      6. lift-*.f6435.4

        \[\leadsto \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\left(D \cdot \color{blue}{\left(D \cdot h\right)}\right) \cdot \left(w \cdot w\right)} \]
    11. Applied rewrites35.4%

      \[\leadsto \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\color{blue}{\left(D \cdot \left(D \cdot h\right)\right)} \cdot \left(w \cdot w\right)} \]

    if 1.39999999999999996e-161 < d < 1.34999999999999995e177

    1. Initial program 35.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around inf

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2} \cdot \left(h \cdot w\right)}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2} \cdot \left(h \cdot w\right)}} \]
      3. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2}} \cdot \left(h \cdot w\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left({d}^{2} \cdot c0\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left({d}^{2} \cdot c0\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)} \]
      6. pow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{{D}^{2} \cdot \left(h \cdot w\right)} \]
      7. lift-*.f64N/A

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot w\right) \cdot \color{blue}{{D}^{2}}} \]
      9. *-commutativeN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(w \cdot h\right) \cdot {\color{blue}{D}}^{2}} \]
      10. pow2N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(w \cdot h\right) \cdot \left(D \cdot \color{blue}{D}\right)} \]
      11. associate-*r*N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(w \cdot h\right) \cdot D\right) \cdot \color{blue}{D}} \]
      12. lower-*.f64N/A

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      14. lower-*.f64N/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      15. lower-*.f6451.9

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
    5. Applied rewrites51.9%

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

        \[\leadsto \frac{c0}{\color{blue}{2 \cdot w}} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      2. count-2-revN/A

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
      3. lower-+.f6451.9

        \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
    7. Applied rewrites51.9%

      \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification39.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 1.4 \cdot 10^{-161} \lor \neg \left(d \leq 1.35 \cdot 10^{+177}\right):\\ \;\;\;\;\frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\left(D \cdot \left(D \cdot h\right)\right) \cdot \left(w \cdot w\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{w + w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 41.1% accurate, 2.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d\_m \cdot c0\right) \cdot d\_m\right)}{\left(h \cdot \left(w \cdot D\right)\right) \cdot D} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
 :precision binary64
 (* (/ c0 (* 2.0 w)) (/ (* 2.0 (* (* d_m c0) d_m)) (* (* h (* w D)) D))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
	return (c0 / (2.0 * w)) * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D));
}
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(c0, w, h, d, d_m, m)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_m
    real(8), intent (in) :: m
    code = (c0 / (2.0d0 * w)) * ((2.0d0 * ((d_m * c0) * d_m)) / ((h * (w * d)) * d))
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
	return (c0 / (2.0 * w)) * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D));
}
d_m = math.fabs(d)
def code(c0, w, h, D, d_m, M):
	return (c0 / (2.0 * w)) * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D))
d_m = abs(d)
function code(c0, w, h, D, d_m, M)
	return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(2.0 * Float64(Float64(d_m * c0) * d_m)) / Float64(Float64(h * Float64(w * D)) * D)))
end
d_m = abs(d);
function tmp = code(c0, w, h, D, d_m, M)
	tmp = (c0 / (2.0 * w)) * ((2.0 * ((d_m * c0) * d_m)) / ((h * (w * D)) * D));
end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * N[(N[(d$95$m * c0), $MachinePrecision] * d$95$m), $MachinePrecision]), $MachinePrecision] / N[(N[(h * N[(w * D), $MachinePrecision]), $MachinePrecision] * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|

\\
\frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d\_m \cdot c0\right) \cdot d\_m\right)}{\left(h \cdot \left(w \cdot D\right)\right) \cdot D}
\end{array}
Derivation
  1. Initial program 23.7%

    \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in c0 around inf

    \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} \]
  4. Step-by-step derivation
    1. associate-*r/N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2} \cdot \left(h \cdot w\right)}} \]
    2. lower-/.f64N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2} \cdot \left(h \cdot w\right)}} \]
    3. lower-*.f64N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\color{blue}{{D}^{2}} \cdot \left(h \cdot w\right)} \]
    4. *-commutativeN/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left({d}^{2} \cdot c0\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)} \]
    5. lower-*.f64N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left({d}^{2} \cdot c0\right)}{{D}^{\color{blue}{2}} \cdot \left(h \cdot w\right)} \]
    6. pow2N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{{D}^{2} \cdot \left(h \cdot w\right)} \]
    7. lift-*.f64N/A

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot w\right) \cdot \color{blue}{{D}^{2}}} \]
    9. *-commutativeN/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(w \cdot h\right) \cdot {\color{blue}{D}}^{2}} \]
    10. pow2N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(w \cdot h\right) \cdot \left(D \cdot \color{blue}{D}\right)} \]
    11. associate-*r*N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(w \cdot h\right) \cdot D\right) \cdot \color{blue}{D}} \]
    12. lower-*.f64N/A

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
    14. lower-*.f64N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
    15. lower-*.f6436.6

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
  5. Applied rewrites36.6%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(\left(h \cdot w\right) \cdot D\right) \cdot D} \]
    3. associate-*l*N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot \left(w \cdot D\right)\right) \cdot D} \]
    4. lower-*.f64N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot \left(w \cdot D\right)\right) \cdot D} \]
    5. lower-*.f6436.6

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot \left(w \cdot D\right)\right) \cdot D} \]
  7. Applied rewrites36.6%

    \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot \left(w \cdot D\right)\right) \cdot D} \]
  8. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot \color{blue}{\left(w \cdot D\right)}\right) \cdot D} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot d\right) \cdot c0\right)}{\left(h \cdot \left(\color{blue}{w} \cdot D\right)\right) \cdot D} \]
    3. pow2N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left({d}^{2} \cdot c0\right)}{\left(h \cdot \left(\color{blue}{w} \cdot D\right)\right) \cdot D} \]
    4. *-commutativeN/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot {d}^{2}\right)}{\left(h \cdot \color{blue}{\left(w \cdot D\right)}\right) \cdot D} \]
    5. pow2N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(c0 \cdot \left(d \cdot d\right)\right)}{\left(h \cdot \left(w \cdot \color{blue}{D}\right)\right) \cdot D} \]
    6. associate-*r*N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(c0 \cdot d\right) \cdot d\right)}{\left(h \cdot \color{blue}{\left(w \cdot D\right)}\right) \cdot D} \]
    7. *-commutativeN/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot c0\right) \cdot d\right)}{\left(h \cdot \left(\color{blue}{w} \cdot D\right)\right) \cdot D} \]
    8. lower-*.f64N/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot c0\right) \cdot d\right)}{\left(h \cdot \color{blue}{\left(w \cdot D\right)}\right) \cdot D} \]
    9. lift-*.f6442.2

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot c0\right) \cdot d\right)}{\left(h \cdot \left(\color{blue}{w} \cdot D\right)\right) \cdot D} \]
  9. Applied rewrites42.2%

    \[\leadsto \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot c0\right) \cdot d\right)}{\left(h \cdot \color{blue}{\left(w \cdot D\right)}\right) \cdot D} \]
  10. Add Preprocessing

Alternative 8: 36.6% accurate, 2.6× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;d\_m \leq 1.7 \cdot 10^{-158} \lor \neg \left(d\_m \leq 3.4 \cdot 10^{+122}\right):\\ \;\;\;\;\frac{\left(d\_m \cdot c0\right) \cdot \left(d\_m \cdot c0\right)}{\left(D \cdot \left(D \cdot h\right)\right) \cdot \left(w \cdot w\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(c0 \cdot c0\right) \cdot \frac{d\_m \cdot d\_m}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot w}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
 :precision binary64
 (if (or (<= d_m 1.7e-158) (not (<= d_m 3.4e+122)))
   (/ (* (* d_m c0) (* d_m c0)) (* (* D (* D h)) (* w w)))
   (* (* c0 c0) (/ (* d_m d_m) (* (* (* (* h w) D) D) w)))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
	double tmp;
	if ((d_m <= 1.7e-158) || !(d_m <= 3.4e+122)) {
		tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w));
	} else {
		tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w));
	}
	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(c0, w, h, d, d_m, m)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_m
    real(8), intent (in) :: m
    real(8) :: tmp
    if ((d_m <= 1.7d-158) .or. (.not. (d_m <= 3.4d+122))) then
        tmp = ((d_m * c0) * (d_m * c0)) / ((d * (d * h)) * (w * w))
    else
        tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * d) * d) * w))
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
	double tmp;
	if ((d_m <= 1.7e-158) || !(d_m <= 3.4e+122)) {
		tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w));
	} else {
		tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w));
	}
	return tmp;
}
d_m = math.fabs(d)
def code(c0, w, h, D, d_m, M):
	tmp = 0
	if (d_m <= 1.7e-158) or not (d_m <= 3.4e+122):
		tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w))
	else:
		tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w))
	return tmp
d_m = abs(d)
function code(c0, w, h, D, d_m, M)
	tmp = 0.0
	if ((d_m <= 1.7e-158) || !(d_m <= 3.4e+122))
		tmp = Float64(Float64(Float64(d_m * c0) * Float64(d_m * c0)) / Float64(Float64(D * Float64(D * h)) * Float64(w * w)));
	else
		tmp = Float64(Float64(c0 * c0) * Float64(Float64(d_m * d_m) / Float64(Float64(Float64(Float64(h * w) * D) * D) * w)));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(c0, w, h, D, d_m, M)
	tmp = 0.0;
	if ((d_m <= 1.7e-158) || ~((d_m <= 3.4e+122)))
		tmp = ((d_m * c0) * (d_m * c0)) / ((D * (D * h)) * (w * w));
	else
		tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := If[Or[LessEqual[d$95$m, 1.7e-158], N[Not[LessEqual[d$95$m, 3.4e+122]], $MachinePrecision]], N[(N[(N[(d$95$m * c0), $MachinePrecision] * N[(d$95$m * c0), $MachinePrecision]), $MachinePrecision] / N[(N[(D * N[(D * h), $MachinePrecision]), $MachinePrecision] * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c0 * c0), $MachinePrecision] * N[(N[(d$95$m * d$95$m), $MachinePrecision] / N[(N[(N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision] * D), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
\mathbf{if}\;d\_m \leq 1.7 \cdot 10^{-158} \lor \neg \left(d\_m \leq 3.4 \cdot 10^{+122}\right):\\
\;\;\;\;\frac{\left(d\_m \cdot c0\right) \cdot \left(d\_m \cdot c0\right)}{\left(D \cdot \left(D \cdot h\right)\right) \cdot \left(w \cdot w\right)}\\

\mathbf{else}:\\
\;\;\;\;\left(c0 \cdot c0\right) \cdot \frac{d\_m \cdot d\_m}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot w}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 1.7e-158 or 3.4e122 < d

    1. Initial program 21.2%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around inf

      \[\leadsto \color{blue}{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h} \cdot {w}^{2}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      7. pow2N/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{h \cdot {w}^{2}} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{{w}^{2} \cdot \color{blue}{h}} \]
      11. unpow2N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      12. lower-*.f6434.3

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
    5. Applied rewrites34.3%

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

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

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

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      6. unpow-prod-downN/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      7. pow2N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\left(w \cdot \color{blue}{w}\right) \cdot h} \]
      8. associate-/l/N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)}} \]
      9. lift-*.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot \color{blue}{h}\right)} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)} \]
      11. pow2N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)} \]
      12. *-commutativeN/A

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

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      14. unpow-prod-downN/A

        \[\leadsto \frac{{\left(c0 \cdot d\right)}^{2}}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{{\left(c0 \cdot d\right)}^{2}}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      16. *-commutativeN/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{{\color{blue}{D}}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      17. lower-*.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{{\color{blue}{D}}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      18. associate-*r*N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
      19. lower-*.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
      20. lower-*.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left({D}^{2} \cdot h\right) \cdot {\color{blue}{w}}^{2}} \]
      21. pow2N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot {w}^{2}} \]
      22. lift-*.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot {w}^{2}} \]
      23. pow2N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot \color{blue}{w}\right)} \]
    7. Applied rewrites34.1%

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

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(\color{blue}{w} \cdot w\right)} \]
      3. associate-*l*N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(D \cdot \left(D \cdot h\right)\right) \cdot \left(\color{blue}{w} \cdot w\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(D \cdot \left(D \cdot h\right)\right) \cdot \left(\color{blue}{w} \cdot w\right)} \]
      5. lower-*.f6436.6

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\left(D \cdot \left(D \cdot h\right)\right) \cdot \left(w \cdot w\right)} \]
    9. Applied rewrites36.6%

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

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

        \[\leadsto \frac{{\left(d \cdot c0\right)}^{2}}{\color{blue}{\left(D \cdot \left(D \cdot h\right)\right)} \cdot \left(w \cdot w\right)} \]
      3. unpow2N/A

        \[\leadsto \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\color{blue}{\left(D \cdot \left(D \cdot h\right)\right)} \cdot \left(w \cdot w\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\color{blue}{\left(D \cdot \left(D \cdot h\right)\right)} \cdot \left(w \cdot w\right)} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\left(\color{blue}{D} \cdot \left(D \cdot h\right)\right) \cdot \left(w \cdot w\right)} \]
      6. lift-*.f6436.6

        \[\leadsto \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\left(D \cdot \color{blue}{\left(D \cdot h\right)}\right) \cdot \left(w \cdot w\right)} \]
    11. Applied rewrites36.6%

      \[\leadsto \frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\color{blue}{\left(D \cdot \left(D \cdot h\right)\right)} \cdot \left(w \cdot w\right)} \]

    if 1.7e-158 < d < 3.4e122

    1. Initial program 34.1%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around inf

      \[\leadsto \color{blue}{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h} \cdot {w}^{2}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      7. pow2N/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{h \cdot {w}^{2}} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{{w}^{2} \cdot \color{blue}{h}} \]
      11. unpow2N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      12. lower-*.f6441.6

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
    5. Applied rewrites41.6%

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

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

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

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      6. unpow-prod-downN/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      7. pow2N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\left(w \cdot \color{blue}{w}\right) \cdot h} \]
      8. associate-/l/N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)}} \]
      9. lift-*.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot \color{blue}{h}\right)} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)} \]
      11. pow2N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)} \]
      12. *-commutativeN/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot \color{blue}{{w}^{2}}\right)} \]
      13. associate-/l*N/A

        \[\leadsto {c0}^{2} \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      14. lower-*.f64N/A

        \[\leadsto {c0}^{2} \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      15. unpow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      16. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      17. lower-/.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{{d}^{2}}{\color{blue}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      18. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      19. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      20. associate-*r*N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
      21. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
    7. Applied rewrites34.2%

      \[\leadsto \left(c0 \cdot c0\right) \cdot \color{blue}{\frac{d \cdot d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot \color{blue}{w}\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \color{blue}{\left(w \cdot w\right)}} \]
      3. associate-*r*N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(D \cdot D\right) \cdot h\right) \cdot w\right) \cdot \color{blue}{w}} \]
      4. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(D \cdot D\right) \cdot h\right) \cdot w\right) \cdot w} \]
      5. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(D \cdot D\right) \cdot h\right) \cdot w\right) \cdot w} \]
      6. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left({D}^{2} \cdot h\right) \cdot w\right) \cdot w} \]
      7. associate-*r*N/A

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

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot \left(h \cdot w\right)\right) \cdot \color{blue}{w}} \]
      9. *-commutativeN/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot \left(w \cdot h\right)\right) \cdot w} \]
      10. *-commutativeN/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(w \cdot h\right) \cdot {D}^{2}\right) \cdot w} \]
      11. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(w \cdot h\right) \cdot \left(D \cdot D\right)\right) \cdot w} \]
      12. associate-*r*N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(w \cdot h\right) \cdot D\right) \cdot D\right) \cdot w} \]
      13. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(w \cdot h\right) \cdot D\right) \cdot D\right) \cdot w} \]
      14. *-commutativeN/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot w} \]
      15. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot w} \]
      16. lift-*.f6446.4

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot w} \]
    9. Applied rewrites46.4%

      \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot \color{blue}{w}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification38.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 1.7 \cdot 10^{-158} \lor \neg \left(d \leq 3.4 \cdot 10^{+122}\right):\\ \;\;\;\;\frac{\left(d \cdot c0\right) \cdot \left(d \cdot c0\right)}{\left(D \cdot \left(D \cdot h\right)\right) \cdot \left(w \cdot w\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 35.3% accurate, 2.6× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \begin{array}{l} \mathbf{if}\;d\_m \leq 5 \cdot 10^{-136} \lor \neg \left(d\_m \leq 4 \cdot 10^{+171}\right):\\ \;\;\;\;\left(c0 \cdot c0\right) \cdot \left(d\_m \cdot \frac{d\_m}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(c0 \cdot c0\right) \cdot \frac{d\_m \cdot d\_m}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot w}\\ \end{array} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
 :precision binary64
 (if (or (<= d_m 5e-136) (not (<= d_m 4e+171)))
   (* (* c0 c0) (* d_m (/ d_m (* (* (* w w) h) (* D D)))))
   (* (* c0 c0) (/ (* d_m d_m) (* (* (* (* h w) D) D) w)))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
	double tmp;
	if ((d_m <= 5e-136) || !(d_m <= 4e+171)) {
		tmp = (c0 * c0) * (d_m * (d_m / (((w * w) * h) * (D * D))));
	} else {
		tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w));
	}
	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(c0, w, h, d, d_m, m)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_m
    real(8), intent (in) :: m
    real(8) :: tmp
    if ((d_m <= 5d-136) .or. (.not. (d_m <= 4d+171))) then
        tmp = (c0 * c0) * (d_m * (d_m / (((w * w) * h) * (d * d))))
    else
        tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * d) * d) * w))
    end if
    code = tmp
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
	double tmp;
	if ((d_m <= 5e-136) || !(d_m <= 4e+171)) {
		tmp = (c0 * c0) * (d_m * (d_m / (((w * w) * h) * (D * D))));
	} else {
		tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w));
	}
	return tmp;
}
d_m = math.fabs(d)
def code(c0, w, h, D, d_m, M):
	tmp = 0
	if (d_m <= 5e-136) or not (d_m <= 4e+171):
		tmp = (c0 * c0) * (d_m * (d_m / (((w * w) * h) * (D * D))))
	else:
		tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w))
	return tmp
d_m = abs(d)
function code(c0, w, h, D, d_m, M)
	tmp = 0.0
	if ((d_m <= 5e-136) || !(d_m <= 4e+171))
		tmp = Float64(Float64(c0 * c0) * Float64(d_m * Float64(d_m / Float64(Float64(Float64(w * w) * h) * Float64(D * D)))));
	else
		tmp = Float64(Float64(c0 * c0) * Float64(Float64(d_m * d_m) / Float64(Float64(Float64(Float64(h * w) * D) * D) * w)));
	end
	return tmp
end
d_m = abs(d);
function tmp_2 = code(c0, w, h, D, d_m, M)
	tmp = 0.0;
	if ((d_m <= 5e-136) || ~((d_m <= 4e+171)))
		tmp = (c0 * c0) * (d_m * (d_m / (((w * w) * h) * (D * D))));
	else
		tmp = (c0 * c0) * ((d_m * d_m) / ((((h * w) * D) * D) * w));
	end
	tmp_2 = tmp;
end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := If[Or[LessEqual[d$95$m, 5e-136], N[Not[LessEqual[d$95$m, 4e+171]], $MachinePrecision]], N[(N[(c0 * c0), $MachinePrecision] * N[(d$95$m * N[(d$95$m / N[(N[(N[(w * w), $MachinePrecision] * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c0 * c0), $MachinePrecision] * N[(N[(d$95$m * d$95$m), $MachinePrecision] / N[(N[(N[(N[(h * w), $MachinePrecision] * D), $MachinePrecision] * D), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|

\\
\begin{array}{l}
\mathbf{if}\;d\_m \leq 5 \cdot 10^{-136} \lor \neg \left(d\_m \leq 4 \cdot 10^{+171}\right):\\
\;\;\;\;\left(c0 \cdot c0\right) \cdot \left(d\_m \cdot \frac{d\_m}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(c0 \cdot c0\right) \cdot \frac{d\_m \cdot d\_m}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot w}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 5.0000000000000002e-136 or 3.99999999999999982e171 < d

    1. Initial program 20.1%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around inf

      \[\leadsto \color{blue}{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h} \cdot {w}^{2}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      7. pow2N/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{h \cdot {w}^{2}} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{{w}^{2} \cdot \color{blue}{h}} \]
      11. unpow2N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      12. lower-*.f6433.8

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
    5. Applied rewrites33.8%

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

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

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

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      6. unpow-prod-downN/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      7. pow2N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\left(w \cdot \color{blue}{w}\right) \cdot h} \]
      8. associate-/l/N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)}} \]
      9. lift-*.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot \color{blue}{h}\right)} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)} \]
      11. pow2N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)} \]
      12. *-commutativeN/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot \color{blue}{{w}^{2}}\right)} \]
      13. associate-/l*N/A

        \[\leadsto {c0}^{2} \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      14. lower-*.f64N/A

        \[\leadsto {c0}^{2} \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      15. unpow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      16. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      17. lower-/.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{{d}^{2}}{\color{blue}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      18. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      19. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      20. associate-*r*N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
      21. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
    7. Applied rewrites22.4%

      \[\leadsto \left(c0 \cdot c0\right) \cdot \color{blue}{\frac{d \cdot d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\color{blue}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}} \]
      3. associate-/l*N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \color{blue}{\frac{d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}}\right) \]
      4. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \color{blue}{\frac{d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}}\right) \]
      5. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot \color{blue}{w}\right)}\right) \]
      6. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \color{blue}{\left(w \cdot w\right)}}\right) \]
      7. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}\right) \]
      8. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(\color{blue}{w} \cdot w\right)}\right) \]
      9. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left({D}^{2} \cdot h\right) \cdot \left(w \cdot w\right)}\right) \]
      10. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left({D}^{2} \cdot h\right) \cdot {w}^{\color{blue}{2}}}\right) \]
      11. associate-*r*N/A

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

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\color{blue}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}}\right) \]
      13. *-commutativeN/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(h \cdot {w}^{2}\right) \cdot \color{blue}{{D}^{2}}}\right) \]
      14. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(h \cdot {w}^{2}\right) \cdot \color{blue}{{D}^{2}}}\right) \]
      15. *-commutativeN/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left({w}^{2} \cdot h\right) \cdot {\color{blue}{D}}^{2}}\right) \]
      16. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left({w}^{2} \cdot h\right) \cdot {\color{blue}{D}}^{2}}\right) \]
      17. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(w \cdot w\right) \cdot h\right) \cdot {D}^{2}}\right) \]
      18. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(w \cdot w\right) \cdot h\right) \cdot {D}^{2}}\right) \]
      19. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot \color{blue}{D}\right)}\right) \]
      20. lift-*.f6433.7

        \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot \color{blue}{D}\right)}\right) \]
    9. Applied rewrites33.7%

      \[\leadsto \left(c0 \cdot c0\right) \cdot \left(d \cdot \color{blue}{\frac{d}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)}}\right) \]

    if 5.0000000000000002e-136 < d < 3.99999999999999982e171

    1. Initial program 35.3%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around inf

      \[\leadsto \color{blue}{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
    4. Step-by-step derivation
      1. associate-/r*N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
      3. lower-/.f64N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h} \cdot {w}^{2}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      5. lower-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
      7. pow2N/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{h \cdot {w}^{2}} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{{w}^{2} \cdot \color{blue}{h}} \]
      11. unpow2N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      12. lower-*.f6441.7

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
    5. Applied rewrites41.7%

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

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

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

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

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
      5. lift-pow.f64N/A

        \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      6. unpow-prod-downN/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
      7. pow2N/A

        \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\left(w \cdot \color{blue}{w}\right) \cdot h} \]
      8. associate-/l/N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)}} \]
      9. lift-*.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot \color{blue}{h}\right)} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)} \]
      11. pow2N/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)} \]
      12. *-commutativeN/A

        \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot \color{blue}{{w}^{2}}\right)} \]
      13. associate-/l*N/A

        \[\leadsto {c0}^{2} \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      14. lower-*.f64N/A

        \[\leadsto {c0}^{2} \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      15. unpow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      16. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
      17. lower-/.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{{d}^{2}}{\color{blue}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
      18. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      19. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
      20. associate-*r*N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
      21. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
    7. Applied rewrites34.0%

      \[\leadsto \left(c0 \cdot c0\right) \cdot \color{blue}{\frac{d \cdot d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}} \]
    8. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot \color{blue}{w}\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \color{blue}{\left(w \cdot w\right)}} \]
      3. associate-*r*N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(D \cdot D\right) \cdot h\right) \cdot w\right) \cdot \color{blue}{w}} \]
      4. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(D \cdot D\right) \cdot h\right) \cdot w\right) \cdot w} \]
      5. lift-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(D \cdot D\right) \cdot h\right) \cdot w\right) \cdot w} \]
      6. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left({D}^{2} \cdot h\right) \cdot w\right) \cdot w} \]
      7. associate-*r*N/A

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

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot \left(h \cdot w\right)\right) \cdot \color{blue}{w}} \]
      9. *-commutativeN/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot \left(w \cdot h\right)\right) \cdot w} \]
      10. *-commutativeN/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(w \cdot h\right) \cdot {D}^{2}\right) \cdot w} \]
      11. pow2N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(w \cdot h\right) \cdot \left(D \cdot D\right)\right) \cdot w} \]
      12. associate-*r*N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(w \cdot h\right) \cdot D\right) \cdot D\right) \cdot w} \]
      13. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(w \cdot h\right) \cdot D\right) \cdot D\right) \cdot w} \]
      14. *-commutativeN/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot w} \]
      15. lower-*.f64N/A

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot w} \]
      16. lift-*.f6443.9

        \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot w} \]
    9. Applied rewrites43.9%

      \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot \color{blue}{w}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification36.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 5 \cdot 10^{-136} \lor \neg \left(d \leq 4 \cdot 10^{+171}\right):\\ \;\;\;\;\left(c0 \cdot c0\right) \cdot \left(d \cdot \frac{d}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left(\left(\left(h \cdot w\right) \cdot D\right) \cdot D\right) \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 29.2% accurate, 3.3× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ c0 \cdot \frac{\left(d\_m \cdot d\_m\right) \cdot c0}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)} \end{array} \]
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
 :precision binary64
 (* c0 (/ (* (* d_m d_m) c0) (* (* (* w w) h) (* D D)))))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
	return c0 * (((d_m * d_m) * c0) / (((w * w) * h) * (D * D)));
}
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(c0, w, h, d, d_m, m)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_m
    real(8), intent (in) :: m
    code = c0 * (((d_m * d_m) * c0) / (((w * w) * h) * (d * d)))
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
	return c0 * (((d_m * d_m) * c0) / (((w * w) * h) * (D * D)));
}
d_m = math.fabs(d)
def code(c0, w, h, D, d_m, M):
	return c0 * (((d_m * d_m) * c0) / (((w * w) * h) * (D * D)))
d_m = abs(d)
function code(c0, w, h, D, d_m, M)
	return Float64(c0 * Float64(Float64(Float64(d_m * d_m) * c0) / Float64(Float64(Float64(w * w) * h) * Float64(D * D))))
end
d_m = abs(d);
function tmp = code(c0, w, h, D, d_m, M)
	tmp = c0 * (((d_m * d_m) * c0) / (((w * w) * h) * (D * D)));
end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := N[(c0 * N[(N[(N[(d$95$m * d$95$m), $MachinePrecision] * c0), $MachinePrecision] / N[(N[(N[(w * w), $MachinePrecision] * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|

\\
c0 \cdot \frac{\left(d\_m \cdot d\_m\right) \cdot c0}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)}
\end{array}
Derivation
  1. Initial program 23.7%

    \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in c0 around inf

    \[\leadsto \color{blue}{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
  4. Step-by-step derivation
    1. associate-/r*N/A

      \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
    2. lower-/.f64N/A

      \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h \cdot {w}^{2}}} \]
    3. lower-/.f64N/A

      \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\color{blue}{h} \cdot {w}^{2}} \]
    4. pow-prod-downN/A

      \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
    5. lower-pow.f64N/A

      \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
    6. lower-*.f64N/A

      \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{{D}^{2}}}{h \cdot {w}^{2}} \]
    7. pow2N/A

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

      \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{h \cdot {w}^{2}} \]
    9. *-commutativeN/A

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

      \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{{w}^{2} \cdot \color{blue}{h}} \]
    11. unpow2N/A

      \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
    12. lower-*.f6435.7

      \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
  5. Applied rewrites35.7%

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

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

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

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

      \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(w \cdot w\right) \cdot h} \]
    5. lift-pow.f64N/A

      \[\leadsto \frac{\frac{{\left(c0 \cdot d\right)}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
    6. unpow-prod-downN/A

      \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{D \cdot D}}{\left(\color{blue}{w} \cdot w\right) \cdot h} \]
    7. pow2N/A

      \[\leadsto \frac{\frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2}}}{\left(w \cdot \color{blue}{w}\right) \cdot h} \]
    8. associate-/l/N/A

      \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)}} \]
    9. lift-*.f64N/A

      \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot \color{blue}{h}\right)} \]
    10. lift-*.f64N/A

      \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(\left(w \cdot w\right) \cdot h\right)} \]
    11. pow2N/A

      \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)} \]
    12. *-commutativeN/A

      \[\leadsto \frac{{c0}^{2} \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot \color{blue}{{w}^{2}}\right)} \]
    13. associate-/l*N/A

      \[\leadsto {c0}^{2} \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
    14. lower-*.f64N/A

      \[\leadsto {c0}^{2} \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
    15. unpow2N/A

      \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
    16. lower-*.f64N/A

      \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} \]
    17. lower-/.f64N/A

      \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{{d}^{2}}{\color{blue}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
    18. pow2N/A

      \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
    19. lift-*.f64N/A

      \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)} \]
    20. associate-*r*N/A

      \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
    21. lower-*.f64N/A

      \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{d \cdot d}{\left({D}^{2} \cdot h\right) \cdot \color{blue}{{w}^{2}}} \]
  7. Applied rewrites25.2%

    \[\leadsto \left(c0 \cdot c0\right) \cdot \color{blue}{\frac{d \cdot d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}} \]
  8. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \left(c0 \cdot c0\right) \cdot \frac{\color{blue}{d \cdot d}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \left(c0 \cdot c0\right) \cdot \color{blue}{\frac{d \cdot d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}} \]
    3. associate-*l*N/A

      \[\leadsto c0 \cdot \color{blue}{\left(c0 \cdot \frac{d \cdot d}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}\right)} \]
    4. lift-*.f64N/A

      \[\leadsto c0 \cdot \left(c0 \cdot \frac{d \cdot d}{\color{blue}{\left(\left(D \cdot D\right) \cdot h\right)} \cdot \left(w \cdot w\right)}\right) \]
    5. lift-/.f64N/A

      \[\leadsto c0 \cdot \left(c0 \cdot \frac{d \cdot d}{\color{blue}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}}\right) \]
    6. pow2N/A

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

      \[\leadsto c0 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot \color{blue}{w}\right)}\right) \]
    8. lift-*.f64N/A

      \[\leadsto c0 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \color{blue}{\left(w \cdot w\right)}}\right) \]
    9. lift-*.f64N/A

      \[\leadsto c0 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(w \cdot w\right)}\right) \]
    10. lift-*.f64N/A

      \[\leadsto c0 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left(\left(D \cdot D\right) \cdot h\right) \cdot \left(\color{blue}{w} \cdot w\right)}\right) \]
    11. pow2N/A

      \[\leadsto c0 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left({D}^{2} \cdot h\right) \cdot \left(w \cdot w\right)}\right) \]
    12. pow2N/A

      \[\leadsto c0 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left({D}^{2} \cdot h\right) \cdot {w}^{\color{blue}{2}}}\right) \]
    13. associate-*r*N/A

      \[\leadsto c0 \cdot \left(c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \color{blue}{\left(h \cdot {w}^{2}\right)}}\right) \]
    14. associate-/l*N/A

      \[\leadsto c0 \cdot \frac{c0 \cdot {d}^{2}}{\color{blue}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}} \]
  9. Applied rewrites30.3%

    \[\leadsto c0 \cdot \color{blue}{\frac{\left(d \cdot d\right) \cdot c0}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)}} \]
  10. Final simplification30.3%

    \[\leadsto c0 \cdot \frac{\left(d \cdot d\right) \cdot c0}{\left(\left(w \cdot w\right) \cdot h\right) \cdot \left(D \cdot D\right)} \]
  11. Add Preprocessing

Alternative 11: 0.0% accurate, 4.5× speedup?

\[\begin{array}{l} d_m = \left|d\right| \\ \frac{c0}{w + w} \cdot \left(\sqrt{-1} \cdot M\right) \end{array} \]
d_m = (fabs.f64 d)
(FPCore (c0 w h D d_m M)
 :precision binary64
 (* (/ c0 (+ w w)) (* (sqrt -1.0) M)))
d_m = fabs(d);
double code(double c0, double w, double h, double D, double d_m, double M) {
	return (c0 / (w + w)) * (sqrt(-1.0) * M);
}
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(c0, w, h, d, d_m, m)
use fmin_fmax_functions
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_m
    real(8), intent (in) :: m
    code = (c0 / (w + w)) * (sqrt((-1.0d0)) * m)
end function
d_m = Math.abs(d);
public static double code(double c0, double w, double h, double D, double d_m, double M) {
	return (c0 / (w + w)) * (Math.sqrt(-1.0) * M);
}
d_m = math.fabs(d)
def code(c0, w, h, D, d_m, M):
	return (c0 / (w + w)) * (math.sqrt(-1.0) * M)
d_m = abs(d)
function code(c0, w, h, D, d_m, M)
	return Float64(Float64(c0 / Float64(w + w)) * Float64(sqrt(-1.0) * M))
end
d_m = abs(d);
function tmp = code(c0, w, h, D, d_m, M)
	tmp = (c0 / (w + w)) * (sqrt(-1.0) * M);
end
d_m = N[Abs[d], $MachinePrecision]
code[c0_, w_, h_, D_, d$95$m_, M_] := N[(N[(c0 / N[(w + w), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[-1.0], $MachinePrecision] * M), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|

\\
\frac{c0}{w + w} \cdot \left(\sqrt{-1} \cdot M\right)
\end{array}
Derivation
  1. Initial program 23.7%

    \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in c0 around 0

    \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(M \cdot \sqrt{-1}\right)} \]
  4. Step-by-step derivation
    1. *-commutativeN/A

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\sqrt{-1} \cdot \color{blue}{M}\right) \]
    3. lower-sqrt.f640.0

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\sqrt{-1} \cdot M\right) \]
  5. Applied rewrites0.0%

    \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\sqrt{-1} \cdot M\right)} \]
  6. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{c0}{\color{blue}{2 \cdot w}} \cdot \left(\sqrt{-1} \cdot M\right) \]
    2. count-2-revN/A

      \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \left(\sqrt{-1} \cdot M\right) \]
    3. lower-+.f640.0

      \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \left(\sqrt{-1} \cdot M\right) \]
  7. Applied rewrites0.0%

    \[\leadsto \frac{c0}{\color{blue}{w + w}} \cdot \left(\sqrt{-1} \cdot M\right) \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2025040 
(FPCore (c0 w h D d M)
  :name "Henrywood and Agarwal, Equation (13)"
  :precision binary64
  (* (/ c0 (* 2.0 w)) (+ (/ (* c0 (* d d)) (* (* w h) (* D D))) (sqrt (- (* (/ (* c0 (* d d)) (* (* w h) (* D D))) (/ (* c0 (* d d)) (* (* w h) (* D D)))) (* M M))))))