Henrywood and Agarwal, Equation (13)

Percentage Accurate: 23.7% → 53.2%
Time: 17.5s
Alternatives: 8
Speedup: 156.0×

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))));
}
real(8) function code(c0, w, h, d, d_1, m)
    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 8 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: 23.7% 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))));
}
real(8) function code(c0, w, h, d, d_1, m)
    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: 53.2% accurate, 0.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;0\\


\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 78.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. Applied rewrites78.6%

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{d}{D} \cdot \sqrt{\color{blue}{\frac{c0}{h \cdot w}}}, \sqrt{\mathsf{fma}\left({\left(\frac{d}{D}\right)}^{2}, \frac{c0}{h \cdot w}, M\right)}, \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
      5. lower-*.f6442.4

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{d}{D} \cdot \sqrt{\frac{c0}{\color{blue}{h \cdot w}}}, \sqrt{\mathsf{fma}\left({\left(\frac{d}{D}\right)}^{2}, \frac{c0}{h \cdot w}, M\right)}, \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\right) \]
    6. Applied rewrites42.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\color{blue}{\frac{d}{D} \cdot \sqrt{\frac{c0}{h \cdot w}}}, \sqrt{\mathsf{fma}\left({\left(\frac{d}{D}\right)}^{2}, \frac{c0}{h \cdot w}, M\right)}, \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} \cdot c0\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{-1}{2} \cdot \frac{{c0}^{2} \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{w}} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

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

      \[\leadsto \color{blue}{\frac{0 \cdot \left(c0 \cdot c0\right)}{w} \cdot -0.5} \]
    6. Taylor expanded in w around 0

      \[\leadsto 0 \]
    7. Step-by-step derivation
      1. Applied rewrites49.5%

        \[\leadsto 0 \]
    8. Recombined 2 regimes into one program.
    9. Final simplification47.3%

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

    Alternative 2: 54.0% accurate, 0.5× speedup?

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

          \[\leadsto \color{blue}{\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. clear-numN/A

          \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot w}{c0}}} \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) \]
        3. associate-/r/N/A

          \[\leadsto \color{blue}{\left(\frac{1}{2 \cdot w} \cdot c0\right)} \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) \]
        4. lower-*.f64N/A

          \[\leadsto \color{blue}{\left(\frac{1}{2 \cdot w} \cdot c0\right)} \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) \]
        5. lift-*.f64N/A

          \[\leadsto \left(\frac{1}{\color{blue}{2 \cdot w}} \cdot c0\right) \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) \]
        6. associate-/r*N/A

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

          \[\leadsto \left(\frac{\color{blue}{\frac{1}{2}}}{w} \cdot c0\right) \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) \]
        8. lower-/.f6478.3

          \[\leadsto \left(\color{blue}{\frac{0.5}{w}} \cdot c0\right) \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) \]
      4. Applied rewrites78.3%

        \[\leadsto \color{blue}{\left(\frac{0.5}{w} \cdot c0\right)} \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) \]

      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{-1}{2} \cdot \frac{{c0}^{2} \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{w}} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

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

        \[\leadsto \color{blue}{\frac{0 \cdot \left(c0 \cdot c0\right)}{w} \cdot -0.5} \]
      6. Taylor expanded in w around 0

        \[\leadsto 0 \]
      7. Step-by-step derivation
        1. Applied rewrites49.5%

          \[\leadsto 0 \]
      8. Recombined 2 regimes into one program.
      9. Final simplification58.4%

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

      Alternative 3: 54.0% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\left(c0 \cdot \frac{c0}{D \cdot D}\right) \cdot \left(d \cdot \frac{d}{\left(w \cdot w\right) \cdot h}\right)} \]
        6. Step-by-step derivation
          1. Applied rewrites75.1%

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

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

            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{-1}{2} \cdot \frac{{c0}^{2} \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{w}} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

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

              \[\leadsto \color{blue}{\frac{0 \cdot \left(c0 \cdot c0\right)}{w} \cdot -0.5} \]
            6. Taylor expanded in w around 0

              \[\leadsto 0 \]
            7. Step-by-step derivation
              1. Applied rewrites49.5%

                \[\leadsto 0 \]
            8. Recombined 2 regimes into one program.
            9. Final simplification57.8%

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

            Alternative 4: 53.1% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              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{-1}{2} \cdot \frac{{c0}^{2} \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{w}} \]
              4. Step-by-step derivation
                1. *-commutativeN/A

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

                \[\leadsto \color{blue}{\frac{0 \cdot \left(c0 \cdot c0\right)}{w} \cdot -0.5} \]
              6. Taylor expanded in w around 0

                \[\leadsto 0 \]
              7. Step-by-step derivation
                1. Applied rewrites49.5%

                  \[\leadsto 0 \]
              8. Recombined 2 regimes into one program.
              9. Final simplification57.1%

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

              Alternative 5: 53.0% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\left(c0 \cdot \frac{c0}{D \cdot D}\right) \cdot \left(d \cdot \frac{d}{\left(w \cdot w\right) \cdot h}\right)} \]
                6. Step-by-step derivation
                  1. Applied rewrites75.1%

                    \[\leadsto \frac{{\left(\frac{c0}{D}\right)}^{2} \cdot d}{\color{blue}{w \cdot \frac{h \cdot w}{d}}} \]
                  2. Step-by-step derivation
                    1. Applied rewrites74.0%

                      \[\leadsto \frac{c0}{D} \cdot \color{blue}{\left(\frac{c0}{D} \cdot \left(\frac{d}{\left(h \cdot w\right) \cdot w} \cdot d\right)\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{-1}{2} \cdot \frac{{c0}^{2} \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{w}} \]
                    4. Step-by-step derivation
                      1. *-commutativeN/A

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

                      \[\leadsto \color{blue}{\frac{0 \cdot \left(c0 \cdot c0\right)}{w} \cdot -0.5} \]
                    6. Taylor expanded in w around 0

                      \[\leadsto 0 \]
                    7. Step-by-step derivation
                      1. Applied rewrites49.5%

                        \[\leadsto 0 \]
                    8. Recombined 2 regimes into one program.
                    9. Final simplification57.1%

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

                    Alternative 6: 52.0% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \color{blue}{\left(c0 \cdot \frac{c0}{D \cdot D}\right) \cdot \left(d \cdot \frac{d}{\left(w \cdot w\right) \cdot h}\right)} \]
                      6. Step-by-step derivation
                        1. Applied rewrites70.2%

                          \[\leadsto \left(c0 \cdot \frac{c0}{D \cdot D}\right) \cdot \left(d \cdot \frac{d}{\left(h \cdot w\right) \cdot \color{blue}{w}}\right) \]
                        2. Step-by-step derivation
                          1. Applied rewrites72.7%

                            \[\leadsto \left(c0 \cdot \frac{c0}{D \cdot D}\right) \cdot \left(d \cdot \frac{\frac{d}{w}}{\color{blue}{h \cdot w}}\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{-1}{2} \cdot \frac{{c0}^{2} \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{w}} \]
                          4. Step-by-step derivation
                            1. *-commutativeN/A

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

                            \[\leadsto \color{blue}{\frac{0 \cdot \left(c0 \cdot c0\right)}{w} \cdot -0.5} \]
                          6. Taylor expanded in w around 0

                            \[\leadsto 0 \]
                          7. Step-by-step derivation
                            1. Applied rewrites49.5%

                              \[\leadsto 0 \]
                          8. Recombined 2 regimes into one program.
                          9. Final simplification56.7%

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

                          Alternative 7: 50.7% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \color{blue}{\left(c0 \cdot \frac{c0}{D \cdot D}\right) \cdot \left(d \cdot \frac{d}{\left(w \cdot w\right) \cdot h}\right)} \]
                            6. Step-by-step derivation
                              1. Applied rewrites70.2%

                                \[\leadsto \left(c0 \cdot \frac{c0}{D \cdot D}\right) \cdot \left(d \cdot \frac{d}{\left(h \cdot w\right) \cdot \color{blue}{w}}\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{-1}{2} \cdot \frac{{c0}^{2} \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{w}} \]
                              4. Step-by-step derivation
                                1. *-commutativeN/A

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

                                \[\leadsto \color{blue}{\frac{0 \cdot \left(c0 \cdot c0\right)}{w} \cdot -0.5} \]
                              6. Taylor expanded in w around 0

                                \[\leadsto 0 \]
                              7. Step-by-step derivation
                                1. Applied rewrites49.5%

                                  \[\leadsto 0 \]
                              8. Recombined 2 regimes into one program.
                              9. Final simplification55.9%

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

                              Alternative 8: 33.8% accurate, 156.0× speedup?

                              \[\begin{array}{l} d_m = \left|d\right| \\ D_m = \left|D\right| \\ 0 \end{array} \]
                              d_m = (fabs.f64 d)
                              D_m = (fabs.f64 D)
                              (FPCore (c0 w h D_m d_m M) :precision binary64 0.0)
                              d_m = fabs(d);
                              D_m = fabs(D);
                              double code(double c0, double w, double h, double D_m, double d_m, double M) {
                              	return 0.0;
                              }
                              
                              d_m = abs(d)
                              D_m = abs(d)
                              real(8) function code(c0, w, h, d_m, d_m_1, m)
                                  real(8), intent (in) :: c0
                                  real(8), intent (in) :: w
                                  real(8), intent (in) :: h
                                  real(8), intent (in) :: d_m
                                  real(8), intent (in) :: d_m_1
                                  real(8), intent (in) :: m
                                  code = 0.0d0
                              end function
                              
                              d_m = Math.abs(d);
                              D_m = Math.abs(D);
                              public static double code(double c0, double w, double h, double D_m, double d_m, double M) {
                              	return 0.0;
                              }
                              
                              d_m = math.fabs(d)
                              D_m = math.fabs(D)
                              def code(c0, w, h, D_m, d_m, M):
                              	return 0.0
                              
                              d_m = abs(d)
                              D_m = abs(D)
                              function code(c0, w, h, D_m, d_m, M)
                              	return 0.0
                              end
                              
                              d_m = abs(d);
                              D_m = abs(D);
                              function tmp = code(c0, w, h, D_m, d_m, M)
                              	tmp = 0.0;
                              end
                              
                              d_m = N[Abs[d], $MachinePrecision]
                              D_m = N[Abs[D], $MachinePrecision]
                              code[c0_, w_, h_, D$95$m_, d$95$m_, M_] := 0.0
                              
                              \begin{array}{l}
                              d_m = \left|d\right|
                              \\
                              D_m = \left|D\right|
                              
                              \\
                              0
                              \end{array}
                              
                              Derivation
                              1. Initial program 24.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{-1}{2} \cdot \frac{{c0}^{2} \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{w}} \]
                              4. Step-by-step derivation
                                1. *-commutativeN/A

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

                                \[\leadsto \color{blue}{\frac{0 \cdot \left(c0 \cdot c0\right)}{w} \cdot -0.5} \]
                              6. Taylor expanded in w around 0

                                \[\leadsto 0 \]
                              7. Step-by-step derivation
                                1. Applied rewrites36.9%

                                  \[\leadsto 0 \]
                                2. Add Preprocessing

                                Reproduce

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