Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.8% → 54.6%
Time: 35.4s
Alternatives: 6
Speedup: 16.8×

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 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 24.8% 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: 54.6% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}\\ t_1 := \left(w \cdot h\right) \cdot D\\ t_2 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ t_3 := \frac{c0}{2 \cdot w}\\ t_4 := t\_3 \cdot \left(t\_2 + \sqrt{t\_2 \cdot t\_2 - M \cdot M}\right)\\ t_5 := \frac{c0}{w \cdot h}\\ \mathbf{if}\;t\_4 \leq -\infty:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_0, \sqrt{\mathsf{fma}\left(\frac{c0}{t\_1}, \frac{{d}^{2}}{D}, -M\right)} \cdot \sqrt{\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot t\_1}, M\right)}\right)}{2 \cdot w}\\ \mathbf{elif}\;t\_4 \leq 0:\\ \;\;\;\;t\_3 \cdot \left(t\_5 \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(t\_5 \cdot {\left(\frac{d}{D}\right)}^{2}\right)}^{2} - M \cdot M}\right)\\ \mathbf{elif}\;t\_4 \leq \infty:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_0, \frac{c0 \cdot {d}^{2}}{\left(w \cdot h\right) \cdot {D}^{2}}\right)}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(0 \cdot \frac{\frac{1}{w}}{2}\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (* d (/ d (* D (* w (* h D))))))
        (t_1 (* (* w h) D))
        (t_2 (/ (* c0 (* d d)) (* (* w h) (* D D))))
        (t_3 (/ c0 (* 2.0 w)))
        (t_4 (* t_3 (+ t_2 (sqrt (- (* t_2 t_2) (* M M))))))
        (t_5 (/ c0 (* w h))))
   (if (<= t_4 (- INFINITY))
     (*
      c0
      (/
       (fma
        c0
        t_0
        (*
         (sqrt (fma (/ c0 t_1) (/ (pow d 2.0) D) (- M)))
         (sqrt (fma c0 (/ (pow d 2.0) (* D t_1)) M))))
       (* 2.0 w)))
     (if (<= t_4 0.0)
       (*
        t_3
        (+
         (* t_5 (* (/ d D) (/ d D)))
         (sqrt (- (pow (* t_5 (pow (/ d D) 2.0)) 2.0) (* M M)))))
       (if (<= t_4 INFINITY)
         (*
          c0
          (/
           (fma c0 t_0 (/ (* c0 (pow d 2.0)) (* (* w h) (pow D 2.0))))
           (* 2.0 w)))
         (* c0 (* 0.0 (/ (/ 1.0 w) 2.0))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = d * (d / (D * (w * (h * D))));
	double t_1 = (w * h) * D;
	double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
	double t_3 = c0 / (2.0 * w);
	double t_4 = t_3 * (t_2 + sqrt(((t_2 * t_2) - (M * M))));
	double t_5 = c0 / (w * h);
	double tmp;
	if (t_4 <= -((double) INFINITY)) {
		tmp = c0 * (fma(c0, t_0, (sqrt(fma((c0 / t_1), (pow(d, 2.0) / D), -M)) * sqrt(fma(c0, (pow(d, 2.0) / (D * t_1)), M)))) / (2.0 * w));
	} else if (t_4 <= 0.0) {
		tmp = t_3 * ((t_5 * ((d / D) * (d / D))) + sqrt((pow((t_5 * pow((d / D), 2.0)), 2.0) - (M * M))));
	} else if (t_4 <= ((double) INFINITY)) {
		tmp = c0 * (fma(c0, t_0, ((c0 * pow(d, 2.0)) / ((w * h) * pow(D, 2.0)))) / (2.0 * w));
	} else {
		tmp = c0 * (0.0 * ((1.0 / w) / 2.0));
	}
	return tmp;
}
function code(c0, w, h, D, d, M)
	t_0 = Float64(d * Float64(d / Float64(D * Float64(w * Float64(h * D)))))
	t_1 = Float64(Float64(w * h) * D)
	t_2 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	t_3 = Float64(c0 / Float64(2.0 * w))
	t_4 = Float64(t_3 * Float64(t_2 + sqrt(Float64(Float64(t_2 * t_2) - Float64(M * M)))))
	t_5 = Float64(c0 / Float64(w * h))
	tmp = 0.0
	if (t_4 <= Float64(-Inf))
		tmp = Float64(c0 * Float64(fma(c0, t_0, Float64(sqrt(fma(Float64(c0 / t_1), Float64((d ^ 2.0) / D), Float64(-M))) * sqrt(fma(c0, Float64((d ^ 2.0) / Float64(D * t_1)), M)))) / Float64(2.0 * w)));
	elseif (t_4 <= 0.0)
		tmp = Float64(t_3 * Float64(Float64(t_5 * Float64(Float64(d / D) * Float64(d / D))) + sqrt(Float64((Float64(t_5 * (Float64(d / D) ^ 2.0)) ^ 2.0) - Float64(M * M)))));
	elseif (t_4 <= Inf)
		tmp = Float64(c0 * Float64(fma(c0, t_0, Float64(Float64(c0 * (d ^ 2.0)) / Float64(Float64(w * h) * (D ^ 2.0)))) / Float64(2.0 * w)));
	else
		tmp = Float64(c0 * Float64(0.0 * Float64(Float64(1.0 / w) / 2.0)));
	end
	return tmp
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(d * N[(d / N[(D * N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(w * h), $MachinePrecision] * D), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(t$95$2 + N[Sqrt[N[(N[(t$95$2 * t$95$2), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], N[(c0 * N[(N[(c0 * t$95$0 + N[(N[Sqrt[N[(N[(c0 / t$95$1), $MachinePrecision] * N[(N[Power[d, 2.0], $MachinePrecision] / D), $MachinePrecision] + (-M)), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(c0 * N[(N[Power[d, 2.0], $MachinePrecision] / N[(D * t$95$1), $MachinePrecision]), $MachinePrecision] + M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 0.0], N[(t$95$3 * N[(N[(t$95$5 * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Sqrt[N[(N[Power[N[(t$95$5 * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, Infinity], N[(c0 * N[(N[(c0 * t$95$0 + N[(N[(c0 * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[Power[D, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 * N[(N[(1.0 / w), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_4 \leq 0:\\
\;\;\;\;t\_3 \cdot \left(t\_5 \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(t\_5 \cdot {\left(\frac{d}{D}\right)}^{2}\right)}^{2} - M \cdot M}\right)\\

\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_0, \frac{c0 \cdot {d}^{2}}{\left(w \cdot h\right) \cdot {D}^{2}}\right)}{2 \cdot w}\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot \left(0 \cdot \frac{\frac{1}{w}}{2}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 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 71.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. Simplified73.5%

      \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-/l*73.5%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    5. Applied egg-rr73.5%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    6. Step-by-step derivation
      1. pow1/273.5%

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, {\color{blue}{\left(\mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, d \cdot \frac{d}{D}, -M\right) \cdot \mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}}^{0.5}\right)}{2 \cdot w} \]
      3. metadata-eval73.5%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, {\left(\mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, d \cdot \frac{d}{D}, -M\right) \cdot \mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{\color{blue}{\left(1.5 \cdot 0.3333333333333333\right)}}\right)}{2 \cdot w} \]
      4. unpow-prod-down81.6%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{{\left(\mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, d \cdot \frac{d}{D}, -M\right)\right)}^{\left(1.5 \cdot 0.3333333333333333\right)} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}}\right)}{2 \cdot w} \]
      5. metadata-eval81.6%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, {\left(\mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, d \cdot \frac{d}{D}, -M\right)\right)}^{\color{blue}{0.5}} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}\right)}{2 \cdot w} \]
      6. pow1/281.6%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, d \cdot \frac{d}{D}, -M\right)}} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}\right)}{2 \cdot w} \]
      7. associate-*r*81.6%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(\frac{c0}{\color{blue}{\left(w \cdot h\right) \cdot D}}, d \cdot \frac{d}{D}, -M\right)} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}\right)}{2 \cdot w} \]
      8. associate-*r/81.7%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \color{blue}{\frac{d \cdot d}{D}}, -M\right)} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}\right)}{2 \cdot w} \]
      9. pow281.7%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{\color{blue}{{d}^{2}}}{D}, -M\right)} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}\right)}{2 \cdot w} \]
      10. metadata-eval81.7%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{{d}^{2}}{D}, -M\right)} \cdot {\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)\right)}^{\color{blue}{0.5}}\right)}{2 \cdot w} \]
      11. pow1/281.7%

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{{d}^{2}}{D}, -M\right)} \cdot \sqrt{\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}}\right)}{2 \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))))) < -0.0

    1. Initial program 75.9%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified83.4%

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) - M \cdot M}\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. times-frac68.4%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) - M \cdot M}\right) \]
    6. Step-by-step derivation
      1. cancel-sign-sub-inv68.4%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{\color{blue}{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) + \left(-M\right) \cdot M}}\right) \]
      2. pow268.4%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{\color{blue}{{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right)}^{2}} + \left(-M\right) \cdot M}\right) \]
      3. frac-times91.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(\frac{c0}{w \cdot h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right)}^{2} + \left(-M\right) \cdot M}\right) \]
      4. pow291.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(\frac{c0}{w \cdot h} \cdot \color{blue}{{\left(\frac{d}{D}\right)}^{2}}\right)}^{2} + \left(-M\right) \cdot M}\right) \]
      5. unpow-prod-down41.8%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{\color{blue}{{\left(\frac{c0}{w \cdot h}\right)}^{2} \cdot {\left({\left(\frac{d}{D}\right)}^{2}\right)}^{2}} + \left(-M\right) \cdot M}\right) \]
      6. associate-/r*42.1%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\color{blue}{\left(\frac{\frac{c0}{w}}{h}\right)}}^{2} \cdot {\left({\left(\frac{d}{D}\right)}^{2}\right)}^{2} + \left(-M\right) \cdot M}\right) \]
      7. pow-pow42.1%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(\frac{\frac{c0}{w}}{h}\right)}^{2} \cdot \color{blue}{{\left(\frac{d}{D}\right)}^{\left(2 \cdot 2\right)}} + \left(-M\right) \cdot M}\right) \]
      8. metadata-eval42.1%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\color{blue}{\left(\frac{c0}{w \cdot h}\right)}}^{2} \cdot {\left(\frac{d}{D}\right)}^{4} + \left(-M\right) \cdot M}\right) \]
      2. metadata-eval50.0%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(\frac{c0}{w \cdot h}\right)}^{2} \cdot {\left(\frac{d}{D}\right)}^{\color{blue}{\left(2 + 2\right)}} + \left(-M\right) \cdot M}\right) \]
      3. pow-prod-up41.8%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(\frac{c0}{w \cdot h}\right)}^{2} \cdot \color{blue}{\left({\left(\frac{d}{D}\right)}^{2} \cdot {\left(\frac{d}{D}\right)}^{2}\right)} + \left(-M\right) \cdot M}\right) \]
      4. pow-prod-down41.8%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(\frac{c0}{w \cdot h}\right)}^{2} \cdot \color{blue}{{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}^{2}} + \left(-M\right) \cdot M}\right) \]
      5. unpow-prod-down91.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{\color{blue}{{\left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)}^{2}} + \left(-M\right) \cdot M}\right) \]
      6. *-commutative91.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\color{blue}{\left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0}{w \cdot h}\right)}}^{2} + \left(-M\right) \cdot M}\right) \]
      7. pow291.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(\color{blue}{{\left(\frac{d}{D}\right)}^{2}} \cdot \frac{c0}{w \cdot h}\right)}^{2} + \left(-M\right) \cdot M}\right) \]
    9. Applied egg-rr91.6%

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

    if -0.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))))) < +inf.0

    1. Initial program 78.9%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified78.9%

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \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. Simplified15.5%

      \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-/l*18.9%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    5. Applied egg-rr18.9%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    6. Step-by-step derivation
      1. div-inv18.9%

        \[\leadsto c0 \cdot \color{blue}{\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, d \cdot \frac{d}{D}, -M\right)}\right) \cdot \frac{1}{2 \cdot w}\right)} \]
    7. Applied egg-rr12.5%

      \[\leadsto c0 \cdot \color{blue}{\left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{{d}^{2}}{D}, -M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right)} \]
    8. Step-by-step derivation
      1. associate-*l*12.5%

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

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\color{blue}{\left(\frac{c0}{\left(w \cdot h\right) \cdot D} \cdot \frac{{d}^{2}}{D} - M\right)} \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
      3. associate-*l*12.6%

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\left(\frac{c0}{\color{blue}{w \cdot \left(h \cdot D\right)}} \cdot \frac{{d}^{2}}{D} - M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
      4. associate-*l*15.3%

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\left(\frac{c0}{w \cdot \left(h \cdot D\right)} \cdot \frac{{d}^{2}}{D} - M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \color{blue}{\left(w \cdot \left(h \cdot D\right)\right)}}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
    9. Simplified15.3%

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

      \[\leadsto c0 \cdot \left(\color{blue}{\left(-1 \cdot \left(c0 \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)\right)\right)} \cdot \frac{\frac{1}{w}}{2}\right) \]
    11. Step-by-step derivation
      1. distribute-lft-in1.3%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \color{blue}{\left(c0 \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right) + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      2. mul-1-neg1.3%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(c0 \cdot \color{blue}{\left(-\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      3. distribute-rgt-neg-in1.3%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{\left(-c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      4. associate-/l*0.0%

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

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      6. associate-/l*0.0%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      7. distribute-lft1-in0.0%

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

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{0} \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      9. mul0-lft43.5%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \color{blue}{0}\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      10. metadata-eval43.5%

        \[\leadsto c0 \cdot \left(\color{blue}{0} \cdot \frac{\frac{1}{w}}{2}\right) \]
    12. Simplified43.5%

      \[\leadsto c0 \cdot \left(\color{blue}{0} \cdot \frac{\frac{1}{w}}{2}\right) \]
  3. Recombined 4 regimes into one program.
  4. Final simplification57.0%

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

Alternative 2: 54.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := w \cdot \left(h \cdot D\right)\\ t_1 := D \cdot t\_0\\ t_2 := d \cdot \frac{d}{t\_1}\\ t_3 := \frac{c0}{w \cdot h}\\ t_4 := \frac{c0}{2 \cdot w}\\ t_5 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ t_6 := t\_4 \cdot \left(t\_5 + \sqrt{t\_5 \cdot t\_5 - M \cdot M}\right)\\ \mathbf{if}\;t\_6 \leq -\infty:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_2, \sqrt{\frac{{d}^{2}}{D} \cdot \frac{c0}{t\_0} - M} \cdot \sqrt{\mathsf{fma}\left(c0, \frac{{d}^{2}}{t\_1}, M\right)}\right)}{2 \cdot w}\\ \mathbf{elif}\;t\_6 \leq 0:\\ \;\;\;\;t\_4 \cdot \left(t\_3 \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(t\_3 \cdot {\left(\frac{d}{D}\right)}^{2}\right)}^{2} - M \cdot M}\right)\\ \mathbf{elif}\;t\_6 \leq \infty:\\ \;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_2, \frac{c0 \cdot {d}^{2}}{\left(w \cdot h\right) \cdot {D}^{2}}\right)}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(0 \cdot \frac{\frac{1}{w}}{2}\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (* w (* h D)))
        (t_1 (* D t_0))
        (t_2 (* d (/ d t_1)))
        (t_3 (/ c0 (* w h)))
        (t_4 (/ c0 (* 2.0 w)))
        (t_5 (/ (* c0 (* d d)) (* (* w h) (* D D))))
        (t_6 (* t_4 (+ t_5 (sqrt (- (* t_5 t_5) (* M M)))))))
   (if (<= t_6 (- INFINITY))
     (*
      c0
      (/
       (fma
        c0
        t_2
        (*
         (sqrt (- (* (/ (pow d 2.0) D) (/ c0 t_0)) M))
         (sqrt (fma c0 (/ (pow d 2.0) t_1) M))))
       (* 2.0 w)))
     (if (<= t_6 0.0)
       (*
        t_4
        (+
         (* t_3 (* (/ d D) (/ d D)))
         (sqrt (- (pow (* t_3 (pow (/ d D) 2.0)) 2.0) (* M M)))))
       (if (<= t_6 INFINITY)
         (*
          c0
          (/
           (fma c0 t_2 (/ (* c0 (pow d 2.0)) (* (* w h) (pow D 2.0))))
           (* 2.0 w)))
         (* c0 (* 0.0 (/ (/ 1.0 w) 2.0))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = w * (h * D);
	double t_1 = D * t_0;
	double t_2 = d * (d / t_1);
	double t_3 = c0 / (w * h);
	double t_4 = c0 / (2.0 * w);
	double t_5 = (c0 * (d * d)) / ((w * h) * (D * D));
	double t_6 = t_4 * (t_5 + sqrt(((t_5 * t_5) - (M * M))));
	double tmp;
	if (t_6 <= -((double) INFINITY)) {
		tmp = c0 * (fma(c0, t_2, (sqrt((((pow(d, 2.0) / D) * (c0 / t_0)) - M)) * sqrt(fma(c0, (pow(d, 2.0) / t_1), M)))) / (2.0 * w));
	} else if (t_6 <= 0.0) {
		tmp = t_4 * ((t_3 * ((d / D) * (d / D))) + sqrt((pow((t_3 * pow((d / D), 2.0)), 2.0) - (M * M))));
	} else if (t_6 <= ((double) INFINITY)) {
		tmp = c0 * (fma(c0, t_2, ((c0 * pow(d, 2.0)) / ((w * h) * pow(D, 2.0)))) / (2.0 * w));
	} else {
		tmp = c0 * (0.0 * ((1.0 / w) / 2.0));
	}
	return tmp;
}
function code(c0, w, h, D, d, M)
	t_0 = Float64(w * Float64(h * D))
	t_1 = Float64(D * t_0)
	t_2 = Float64(d * Float64(d / t_1))
	t_3 = Float64(c0 / Float64(w * h))
	t_4 = Float64(c0 / Float64(2.0 * w))
	t_5 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	t_6 = Float64(t_4 * Float64(t_5 + sqrt(Float64(Float64(t_5 * t_5) - Float64(M * M)))))
	tmp = 0.0
	if (t_6 <= Float64(-Inf))
		tmp = Float64(c0 * Float64(fma(c0, t_2, Float64(sqrt(Float64(Float64(Float64((d ^ 2.0) / D) * Float64(c0 / t_0)) - M)) * sqrt(fma(c0, Float64((d ^ 2.0) / t_1), M)))) / Float64(2.0 * w)));
	elseif (t_6 <= 0.0)
		tmp = Float64(t_4 * Float64(Float64(t_3 * Float64(Float64(d / D) * Float64(d / D))) + sqrt(Float64((Float64(t_3 * (Float64(d / D) ^ 2.0)) ^ 2.0) - Float64(M * M)))));
	elseif (t_6 <= Inf)
		tmp = Float64(c0 * Float64(fma(c0, t_2, Float64(Float64(c0 * (d ^ 2.0)) / Float64(Float64(w * h) * (D ^ 2.0)))) / Float64(2.0 * w)));
	else
		tmp = Float64(c0 * Float64(0.0 * Float64(Float64(1.0 / w) / 2.0)));
	end
	return tmp
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(w * N[(h * D), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(D * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(d * N[(d / t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$4 * N[(t$95$5 + N[Sqrt[N[(N[(t$95$5 * t$95$5), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$6, (-Infinity)], N[(c0 * N[(N[(c0 * t$95$2 + N[(N[Sqrt[N[(N[(N[(N[Power[d, 2.0], $MachinePrecision] / D), $MachinePrecision] * N[(c0 / t$95$0), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(c0 * N[(N[Power[d, 2.0], $MachinePrecision] / t$95$1), $MachinePrecision] + M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 0.0], N[(t$95$4 * N[(N[(t$95$3 * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Sqrt[N[(N[Power[N[(t$95$3 * N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, Infinity], N[(c0 * N[(N[(c0 * t$95$2 + N[(N[(c0 * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[Power[D, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 * N[(N[(1.0 / w), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_6 \leq 0:\\
\;\;\;\;t\_4 \cdot \left(t\_3 \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(t\_3 \cdot {\left(\frac{d}{D}\right)}^{2}\right)}^{2} - M \cdot M}\right)\\

\mathbf{elif}\;t\_6 \leq \infty:\\
\;\;\;\;c0 \cdot \frac{\mathsf{fma}\left(c0, t\_2, \frac{c0 \cdot {d}^{2}}{\left(w \cdot h\right) \cdot {D}^{2}}\right)}{2 \cdot w}\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot \left(0 \cdot \frac{\frac{1}{w}}{2}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 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 71.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. Simplified73.5%

      \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-/l*73.5%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    5. Applied egg-rr73.5%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    6. Step-by-step derivation
      1. sqrt-prod81.6%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)} \cdot \sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, d \cdot \frac{d}{D}, -M\right)}}\right)}{2 \cdot w} \]
      2. associate-*r/81.6%

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

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

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)} \cdot \sqrt{\mathsf{fma}\left(\frac{c0}{\color{blue}{\left(w \cdot h\right) \cdot D}}, d \cdot \frac{d}{D}, -M\right)}\right)}{2 \cdot w} \]
      6. associate-*r/81.7%

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

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\sqrt{\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)} \cdot \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{{d}^{2}}{D}, -M\right)}}\right)}{2 \cdot w} \]
    8. Step-by-step derivation
      1. *-commutative81.7%

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\color{blue}{\frac{c0}{\left(w \cdot h\right) \cdot D} \cdot \frac{{d}^{2}}{D} - M}} \cdot \sqrt{\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right)}{2 \cdot w} \]
      3. associate-*l*81.7%

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

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\sqrt{\frac{c0}{w \cdot \left(h \cdot D\right)} \cdot \frac{{d}^{2}}{D} - M} \cdot \sqrt{\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right)}}\right)}{2 \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))))) < -0.0

    1. Initial program 75.9%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified83.4%

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) - M \cdot M}\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. times-frac68.4%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) - M \cdot M}\right) \]
    6. Step-by-step derivation
      1. cancel-sign-sub-inv68.4%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{\color{blue}{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) + \left(-M\right) \cdot M}}\right) \]
      2. pow268.4%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{\color{blue}{{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right)}^{2}} + \left(-M\right) \cdot M}\right) \]
      3. frac-times91.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(\frac{c0}{w \cdot h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right)}^{2} + \left(-M\right) \cdot M}\right) \]
      4. pow291.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(\frac{c0}{w \cdot h} \cdot \color{blue}{{\left(\frac{d}{D}\right)}^{2}}\right)}^{2} + \left(-M\right) \cdot M}\right) \]
      5. unpow-prod-down41.8%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{\color{blue}{{\left(\frac{c0}{w \cdot h}\right)}^{2} \cdot {\left({\left(\frac{d}{D}\right)}^{2}\right)}^{2}} + \left(-M\right) \cdot M}\right) \]
      6. associate-/r*42.1%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\color{blue}{\left(\frac{\frac{c0}{w}}{h}\right)}}^{2} \cdot {\left({\left(\frac{d}{D}\right)}^{2}\right)}^{2} + \left(-M\right) \cdot M}\right) \]
      7. pow-pow42.1%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(\frac{\frac{c0}{w}}{h}\right)}^{2} \cdot \color{blue}{{\left(\frac{d}{D}\right)}^{\left(2 \cdot 2\right)}} + \left(-M\right) \cdot M}\right) \]
      8. metadata-eval42.1%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\color{blue}{\left(\frac{c0}{w \cdot h}\right)}}^{2} \cdot {\left(\frac{d}{D}\right)}^{4} + \left(-M\right) \cdot M}\right) \]
      2. metadata-eval50.0%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(\frac{c0}{w \cdot h}\right)}^{2} \cdot {\left(\frac{d}{D}\right)}^{\color{blue}{\left(2 + 2\right)}} + \left(-M\right) \cdot M}\right) \]
      3. pow-prod-up41.8%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(\frac{c0}{w \cdot h}\right)}^{2} \cdot \color{blue}{\left({\left(\frac{d}{D}\right)}^{2} \cdot {\left(\frac{d}{D}\right)}^{2}\right)} + \left(-M\right) \cdot M}\right) \]
      4. pow-prod-down41.8%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(\frac{c0}{w \cdot h}\right)}^{2} \cdot \color{blue}{{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}^{2}} + \left(-M\right) \cdot M}\right) \]
      5. unpow-prod-down91.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{\color{blue}{{\left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)}^{2}} + \left(-M\right) \cdot M}\right) \]
      6. *-commutative91.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\color{blue}{\left(\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0}{w \cdot h}\right)}}^{2} + \left(-M\right) \cdot M}\right) \]
      7. pow291.6%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{{\left(\color{blue}{{\left(\frac{d}{D}\right)}^{2}} \cdot \frac{c0}{w \cdot h}\right)}^{2} + \left(-M\right) \cdot M}\right) \]
    9. Applied egg-rr91.6%

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

    if -0.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))))) < +inf.0

    1. Initial program 78.9%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified78.9%

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \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. Simplified15.5%

      \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-/l*18.9%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    5. Applied egg-rr18.9%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    6. Step-by-step derivation
      1. div-inv18.9%

        \[\leadsto c0 \cdot \color{blue}{\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, d \cdot \frac{d}{D}, -M\right)}\right) \cdot \frac{1}{2 \cdot w}\right)} \]
    7. Applied egg-rr12.5%

      \[\leadsto c0 \cdot \color{blue}{\left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{{d}^{2}}{D}, -M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right)} \]
    8. Step-by-step derivation
      1. associate-*l*12.5%

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

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\color{blue}{\left(\frac{c0}{\left(w \cdot h\right) \cdot D} \cdot \frac{{d}^{2}}{D} - M\right)} \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
      3. associate-*l*12.6%

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\left(\frac{c0}{\color{blue}{w \cdot \left(h \cdot D\right)}} \cdot \frac{{d}^{2}}{D} - M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
      4. associate-*l*15.3%

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\left(\frac{c0}{w \cdot \left(h \cdot D\right)} \cdot \frac{{d}^{2}}{D} - M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \color{blue}{\left(w \cdot \left(h \cdot D\right)\right)}}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
    9. Simplified15.3%

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

      \[\leadsto c0 \cdot \left(\color{blue}{\left(-1 \cdot \left(c0 \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)\right)\right)} \cdot \frac{\frac{1}{w}}{2}\right) \]
    11. Step-by-step derivation
      1. distribute-lft-in1.3%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \color{blue}{\left(c0 \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right) + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      2. mul-1-neg1.3%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(c0 \cdot \color{blue}{\left(-\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      3. distribute-rgt-neg-in1.3%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{\left(-c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      4. associate-/l*0.0%

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

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      6. associate-/l*0.0%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      7. distribute-lft1-in0.0%

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

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{0} \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      9. mul0-lft43.5%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \color{blue}{0}\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      10. metadata-eval43.5%

        \[\leadsto c0 \cdot \left(\color{blue}{0} \cdot \frac{\frac{1}{w}}{2}\right) \]
    12. Simplified43.5%

      \[\leadsto c0 \cdot \left(\color{blue}{0} \cdot \frac{\frac{1}{w}}{2}\right) \]
  3. Recombined 4 regimes into one program.
  4. Final simplification57.0%

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

Alternative 3: 53.5% accurate, 0.3× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;c0 \cdot \left(0 \cdot t\_0\right)\\


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

    1. Initial program 75.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. Simplified73.8%

      \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-/l*73.7%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    5. Applied egg-rr73.7%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    6. Step-by-step derivation
      1. div-inv73.7%

        \[\leadsto c0 \cdot \color{blue}{\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, d \cdot \frac{d}{D}, -M\right)}\right) \cdot \frac{1}{2 \cdot w}\right)} \]
    7. Applied egg-rr72.7%

      \[\leadsto c0 \cdot \color{blue}{\left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{{d}^{2}}{D}, -M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right)} \]
    8. Step-by-step derivation
      1. associate-*l*72.8%

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

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\color{blue}{\left(\frac{c0}{\left(w \cdot h\right) \cdot D} \cdot \frac{{d}^{2}}{D} - M\right)} \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
      3. associate-*l*72.6%

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\left(\frac{c0}{\color{blue}{w \cdot \left(h \cdot D\right)}} \cdot \frac{{d}^{2}}{D} - M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
      4. associate-*l*73.7%

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\left(\frac{c0}{w \cdot \left(h \cdot D\right)} \cdot \frac{{d}^{2}}{D} - M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \color{blue}{\left(w \cdot \left(h \cdot D\right)\right)}}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
    9. Simplified73.7%

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

      \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
    11. Step-by-step derivation
      1. associate-/l*76.7%

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
    12. Simplified76.7%

      \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right) \cdot \frac{\frac{1}{w}}{2}\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. Simplified15.5%

      \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-/l*18.9%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    5. Applied egg-rr18.9%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    6. Step-by-step derivation
      1. div-inv18.9%

        \[\leadsto c0 \cdot \color{blue}{\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, d \cdot \frac{d}{D}, -M\right)}\right) \cdot \frac{1}{2 \cdot w}\right)} \]
    7. Applied egg-rr12.5%

      \[\leadsto c0 \cdot \color{blue}{\left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{{d}^{2}}{D}, -M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right)} \]
    8. Step-by-step derivation
      1. associate-*l*12.5%

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

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\color{blue}{\left(\frac{c0}{\left(w \cdot h\right) \cdot D} \cdot \frac{{d}^{2}}{D} - M\right)} \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
      3. associate-*l*12.6%

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\left(\frac{c0}{\color{blue}{w \cdot \left(h \cdot D\right)}} \cdot \frac{{d}^{2}}{D} - M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
      4. associate-*l*15.3%

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\left(\frac{c0}{w \cdot \left(h \cdot D\right)} \cdot \frac{{d}^{2}}{D} - M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \color{blue}{\left(w \cdot \left(h \cdot D\right)\right)}}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
    9. Simplified15.3%

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

      \[\leadsto c0 \cdot \left(\color{blue}{\left(-1 \cdot \left(c0 \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)\right)\right)} \cdot \frac{\frac{1}{w}}{2}\right) \]
    11. Step-by-step derivation
      1. distribute-lft-in1.3%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \color{blue}{\left(c0 \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right) + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      2. mul-1-neg1.3%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(c0 \cdot \color{blue}{\left(-\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      3. distribute-rgt-neg-in1.3%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{\left(-c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      4. associate-/l*0.0%

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

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      6. associate-/l*0.0%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      7. distribute-lft1-in0.0%

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

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{0} \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      9. mul0-lft43.5%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \color{blue}{0}\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      10. metadata-eval43.5%

        \[\leadsto c0 \cdot \left(\color{blue}{0} \cdot \frac{\frac{1}{w}}{2}\right) \]
    12. Simplified43.5%

      \[\leadsto c0 \cdot \left(\color{blue}{0} \cdot \frac{\frac{1}{w}}{2}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification54.9%

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

Alternative 4: 54.3% accurate, 0.5× 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)}\\ t_1 := \frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)\\ \mathbf{if}\;t\_1 \leq \infty:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(0 \cdot \frac{\frac{1}{w}}{2}\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D))))
        (t_1 (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
   (if (<= t_1 INFINITY) t_1 (* c0 (* 0.0 (/ (/ 1.0 w) 2.0))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	double t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
	double tmp;
	if (t_1 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = c0 * (0.0 * ((1.0 / w) / 2.0));
	}
	return tmp;
}
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));
	double t_1 = (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
	double tmp;
	if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else {
		tmp = c0 * (0.0 * ((1.0 / w) / 2.0));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D))
	t_1 = (c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))
	tmp = 0
	if t_1 <= math.inf:
		tmp = t_1
	else:
		tmp = c0 * (0.0 * ((1.0 / w) / 2.0))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	t_1 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M)))))
	tmp = 0.0
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = Float64(c0 * Float64(0.0 * Float64(Float64(1.0 / w) / 2.0)));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
	tmp = 0.0;
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = c0 * (0.0 * ((1.0 / w) / 2.0));
	end
	tmp_2 = tmp;
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]}, Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(c0 * N[(0.0 * N[(N[(1.0 / w), $MachinePrecision] / 2.0), $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)}\\
t_1 := \frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right)\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot \left(0 \cdot \frac{\frac{1}{w}}{2}\right)\\


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

    1. Initial program 75.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

    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. Simplified15.5%

      \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-/l*18.9%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    5. Applied egg-rr18.9%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    6. Step-by-step derivation
      1. div-inv18.9%

        \[\leadsto c0 \cdot \color{blue}{\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, d \cdot \frac{d}{D}, -M\right)}\right) \cdot \frac{1}{2 \cdot w}\right)} \]
    7. Applied egg-rr12.5%

      \[\leadsto c0 \cdot \color{blue}{\left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{{d}^{2}}{D}, -M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right)} \]
    8. Step-by-step derivation
      1. associate-*l*12.5%

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

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\color{blue}{\left(\frac{c0}{\left(w \cdot h\right) \cdot D} \cdot \frac{{d}^{2}}{D} - M\right)} \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
      3. associate-*l*12.6%

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\left(\frac{c0}{\color{blue}{w \cdot \left(h \cdot D\right)}} \cdot \frac{{d}^{2}}{D} - M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
      4. associate-*l*15.3%

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\left(\frac{c0}{w \cdot \left(h \cdot D\right)} \cdot \frac{{d}^{2}}{D} - M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \color{blue}{\left(w \cdot \left(h \cdot D\right)\right)}}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
    9. Simplified15.3%

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

      \[\leadsto c0 \cdot \left(\color{blue}{\left(-1 \cdot \left(c0 \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)\right)\right)} \cdot \frac{\frac{1}{w}}{2}\right) \]
    11. Step-by-step derivation
      1. distribute-lft-in1.3%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \color{blue}{\left(c0 \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right) + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      2. mul-1-neg1.3%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(c0 \cdot \color{blue}{\left(-\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      3. distribute-rgt-neg-in1.3%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{\left(-c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      4. associate-/l*0.0%

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

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      6. associate-/l*0.0%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      7. distribute-lft1-in0.0%

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

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{0} \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      9. mul0-lft43.5%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \color{blue}{0}\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      10. metadata-eval43.5%

        \[\leadsto c0 \cdot \left(\color{blue}{0} \cdot \frac{\frac{1}{w}}{2}\right) \]
    12. Simplified43.5%

      \[\leadsto c0 \cdot \left(\color{blue}{0} \cdot \frac{\frac{1}{w}}{2}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 33.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0}{w \cdot h}\\ t_1 := t\_0 \cdot \frac{d \cdot d}{D \cdot D}\\ \mathbf{if}\;M \leq 4.6 \cdot 10^{+33} \lor \neg \left(M \leq 7 \cdot 10^{+152}\right):\\ \;\;\;\;c0 \cdot \left(0 \cdot \frac{\frac{1}{w}}{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ c0 (* w h))) (t_1 (* t_0 (/ (* d d) (* D D)))))
   (if (or (<= M 4.6e+33) (not (<= M 7e+152)))
     (* c0 (* 0.0 (/ (/ 1.0 w) 2.0)))
     (*
      (/ c0 (* 2.0 w))
      (+ (* t_0 (* (/ d D) (/ d D))) (sqrt (- (* t_1 t_1) (* M M))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 / (w * h);
	double t_1 = t_0 * ((d * d) / (D * D));
	double tmp;
	if ((M <= 4.6e+33) || !(M <= 7e+152)) {
		tmp = c0 * (0.0 * ((1.0 / w) / 2.0));
	} else {
		tmp = (c0 / (2.0 * w)) * ((t_0 * ((d / D) * (d / D))) + sqrt(((t_1 * t_1) - (M * M))));
	}
	return tmp;
}
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
    real(8) :: t_1
    real(8) :: tmp
    t_0 = c0 / (w * h)
    t_1 = t_0 * ((d_1 * d_1) / (d * d))
    if ((m <= 4.6d+33) .or. (.not. (m <= 7d+152))) then
        tmp = c0 * (0.0d0 * ((1.0d0 / w) / 2.0d0))
    else
        tmp = (c0 / (2.0d0 * w)) * ((t_0 * ((d_1 / d) * (d_1 / d))) + sqrt(((t_1 * t_1) - (m * m))))
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 / (w * h);
	double t_1 = t_0 * ((d * d) / (D * D));
	double tmp;
	if ((M <= 4.6e+33) || !(M <= 7e+152)) {
		tmp = c0 * (0.0 * ((1.0 / w) / 2.0));
	} else {
		tmp = (c0 / (2.0 * w)) * ((t_0 * ((d / D) * (d / D))) + Math.sqrt(((t_1 * t_1) - (M * M))));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = c0 / (w * h)
	t_1 = t_0 * ((d * d) / (D * D))
	tmp = 0
	if (M <= 4.6e+33) or not (M <= 7e+152):
		tmp = c0 * (0.0 * ((1.0 / w) / 2.0))
	else:
		tmp = (c0 / (2.0 * w)) * ((t_0 * ((d / D) * (d / D))) + math.sqrt(((t_1 * t_1) - (M * M))))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(c0 / Float64(w * h))
	t_1 = Float64(t_0 * Float64(Float64(d * d) / Float64(D * D)))
	tmp = 0.0
	if ((M <= 4.6e+33) || !(M <= 7e+152))
		tmp = Float64(c0 * Float64(0.0 * Float64(Float64(1.0 / w) / 2.0)));
	else
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(t_0 * Float64(Float64(d / D) * Float64(d / D))) + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M)))));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = c0 / (w * h);
	t_1 = t_0 * ((d * d) / (D * D));
	tmp = 0.0;
	if ((M <= 4.6e+33) || ~((M <= 7e+152)))
		tmp = c0 * (0.0 * ((1.0 / w) / 2.0));
	else
		tmp = (c0 / (2.0 * w)) * ((t_0 * ((d / D) * (d / D))) + sqrt(((t_1 * t_1) - (M * M))));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(d * d), $MachinePrecision] / N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[M, 4.6e+33], N[Not[LessEqual[M, 7e+152]], $MachinePrecision]], N[(c0 * N[(0.0 * N[(N[(1.0 / w), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(t$95$0 * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{c0}{w \cdot h}\\
t_1 := t\_0 \cdot \frac{d \cdot d}{D \cdot D}\\
\mathbf{if}\;M \leq 4.6 \cdot 10^{+33} \lor \neg \left(M \leq 7 \cdot 10^{+152}\right):\\
\;\;\;\;c0 \cdot \left(0 \cdot \frac{\frac{1}{w}}{2}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 4.60000000000000021e33 or 6.99999999999999963e152 < M

    1. Initial program 24.9%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified35.1%

      \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. associate-/l*37.2%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    5. Applied egg-rr37.2%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
    6. Step-by-step derivation
      1. div-inv37.2%

        \[\leadsto c0 \cdot \color{blue}{\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, d \cdot \frac{d}{D}, -M\right)}\right) \cdot \frac{1}{2 \cdot w}\right)} \]
    7. Applied egg-rr32.5%

      \[\leadsto c0 \cdot \color{blue}{\left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{{d}^{2}}{D}, -M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right)} \]
    8. Step-by-step derivation
      1. associate-*l*32.6%

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

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\color{blue}{\left(\frac{c0}{\left(w \cdot h\right) \cdot D} \cdot \frac{{d}^{2}}{D} - M\right)} \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
      3. associate-*l*32.6%

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\left(\frac{c0}{\color{blue}{w \cdot \left(h \cdot D\right)}} \cdot \frac{{d}^{2}}{D} - M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
      4. associate-*l*35.0%

        \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\left(\frac{c0}{w \cdot \left(h \cdot D\right)} \cdot \frac{{d}^{2}}{D} - M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \color{blue}{\left(w \cdot \left(h \cdot D\right)\right)}}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
    9. Simplified35.0%

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

      \[\leadsto c0 \cdot \left(\color{blue}{\left(-1 \cdot \left(c0 \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)\right)\right)} \cdot \frac{\frac{1}{w}}{2}\right) \]
    11. Step-by-step derivation
      1. distribute-lft-in4.2%

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

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(c0 \cdot \color{blue}{\left(-\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      3. distribute-rgt-neg-in4.2%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{\left(-c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      4. associate-/l*2.9%

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

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      6. associate-/l*3.7%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      7. distribute-lft1-in3.7%

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

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{0} \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      9. mul0-lft34.0%

        \[\leadsto c0 \cdot \left(\left(-1 \cdot \color{blue}{0}\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
      10. metadata-eval34.0%

        \[\leadsto c0 \cdot \left(\color{blue}{0} \cdot \frac{\frac{1}{w}}{2}\right) \]
    12. Simplified34.0%

      \[\leadsto c0 \cdot \left(\color{blue}{0} \cdot \frac{\frac{1}{w}}{2}\right) \]

    if 4.60000000000000021e33 < M < 6.99999999999999963e152

    1. Initial program 35.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified35.2%

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) - M \cdot M}\right)} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. times-frac35.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 4.6 \cdot 10^{+33} \lor \neg \left(M \leq 7 \cdot 10^{+152}\right):\\ \;\;\;\;c0 \cdot \left(0 \cdot \frac{\frac{1}{w}}{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \sqrt{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) - M \cdot M}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 33.3% accurate, 16.8× speedup?

\[\begin{array}{l} \\ c0 \cdot \left(0 \cdot \frac{\frac{1}{w}}{2}\right) \end{array} \]
(FPCore (c0 w h D d M) :precision binary64 (* c0 (* 0.0 (/ (/ 1.0 w) 2.0))))
double code(double c0, double w, double h, double D, double d, double M) {
	return c0 * (0.0 * ((1.0 / w) / 2.0));
}
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
    code = c0 * (0.0d0 * ((1.0d0 / w) / 2.0d0))
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	return c0 * (0.0 * ((1.0 / w) / 2.0));
}
def code(c0, w, h, D, d, M):
	return c0 * (0.0 * ((1.0 / w) / 2.0))
function code(c0, w, h, D, d, M)
	return Float64(c0 * Float64(0.0 * Float64(Float64(1.0 / w) / 2.0)))
end
function tmp = code(c0, w, h, D, d, M)
	tmp = c0 * (0.0 * ((1.0 / w) / 2.0));
end
code[c0_, w_, h_, D_, d_, M_] := N[(c0 * N[(0.0 * N[(N[(1.0 / w), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
c0 \cdot \left(0 \cdot \frac{\frac{1}{w}}{2}\right)
\end{array}
Derivation
  1. Initial program 25.8%

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

    \[\leadsto \color{blue}{c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \frac{d \cdot d}{D}, -M\right)}\right)}{2 \cdot w}} \]
  3. Add Preprocessing
  4. Step-by-step derivation
    1. associate-/l*37.8%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
  5. Applied egg-rr37.8%

    \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, \color{blue}{d \cdot \frac{d}{D}}, -M\right)}\right)}{2 \cdot w} \]
  6. Step-by-step derivation
    1. div-inv37.8%

      \[\leadsto c0 \cdot \color{blue}{\left(\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \mathsf{fma}\left(\frac{c0}{w \cdot \left(h \cdot D\right)}, d \cdot \frac{d}{D}, -M\right)}\right) \cdot \frac{1}{2 \cdot w}\right)} \]
  7. Applied egg-rr33.2%

    \[\leadsto c0 \cdot \color{blue}{\left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, \sqrt{\mathsf{fma}\left(\frac{c0}{\left(w \cdot h\right) \cdot D}, \frac{{d}^{2}}{D}, -M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right)} \]
  8. Step-by-step derivation
    1. associate-*l*33.2%

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

      \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\color{blue}{\left(\frac{c0}{\left(w \cdot h\right) \cdot D} \cdot \frac{{d}^{2}}{D} - M\right)} \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
    3. associate-*l*33.2%

      \[\leadsto c0 \cdot \left(\mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\left(\frac{c0}{\color{blue}{w \cdot \left(h \cdot D\right)}} \cdot \frac{{d}^{2}}{D} - M\right) \cdot \mathsf{fma}\left(c0, \frac{{d}^{2}}{D \cdot \left(\left(w \cdot h\right) \cdot D\right)}, M\right)}\right) \cdot \frac{1}{w \cdot 2}\right) \]
    4. associate-*l*35.4%

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

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

    \[\leadsto c0 \cdot \left(\color{blue}{\left(-1 \cdot \left(c0 \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)\right)\right)} \cdot \frac{\frac{1}{w}}{2}\right) \]
  11. Step-by-step derivation
    1. distribute-lft-in3.8%

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

      \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(c0 \cdot \color{blue}{\left(-\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
    3. distribute-rgt-neg-in3.8%

      \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{\left(-c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
    4. associate-/l*2.6%

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

      \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}} + c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
    6. associate-/l*3.4%

      \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \color{blue}{\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
    7. distribute-lft1-in3.4%

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

      \[\leadsto c0 \cdot \left(\left(-1 \cdot \left(\color{blue}{0} \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
    9. mul0-lft32.3%

      \[\leadsto c0 \cdot \left(\left(-1 \cdot \color{blue}{0}\right) \cdot \frac{\frac{1}{w}}{2}\right) \]
    10. metadata-eval32.3%

      \[\leadsto c0 \cdot \left(\color{blue}{0} \cdot \frac{\frac{1}{w}}{2}\right) \]
  12. Simplified32.3%

    \[\leadsto c0 \cdot \left(\color{blue}{0} \cdot \frac{\frac{1}{w}}{2}\right) \]
  13. Add Preprocessing

Reproduce

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