Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.4% → 53.7%
Time: 38.1s
Alternatives: 6
Speedup: 21.6×

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.4% accurate, 1.0× speedup?

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

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

Alternative 1: 53.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\ \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \leq \infty:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* c0 (* d d)) (* (* D D) (* w h)))))
   (if (<=
        (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))
        INFINITY)
     (*
      c0
      (/ (* 2.0 (/ (* c0 (pow d 2.0)) (* (pow D 2.0) (* w h)))) (* 2.0 w)))
     (* c0 (/ 0.0 (* 2.0 w))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= ((double) INFINITY)) {
		tmp = c0 * ((2.0 * ((c0 * pow(d, 2.0)) / (pow(D, 2.0) * (w * h)))) / (2.0 * w));
	} else {
		tmp = c0 * (0.0 / (2.0 * w));
	}
	return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
	double tmp;
	if (((c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))))) <= Double.POSITIVE_INFINITY) {
		tmp = c0 * ((2.0 * ((c0 * Math.pow(d, 2.0)) / (Math.pow(D, 2.0) * (w * h)))) / (2.0 * w));
	} else {
		tmp = c0 * (0.0 / (2.0 * w));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = (c0 * (d * d)) / ((D * D) * (w * h))
	tmp = 0
	if ((c0 / (2.0 * w)) * (t_0 + math.sqrt(((t_0 * t_0) - (M * M))))) <= math.inf:
		tmp = c0 * ((2.0 * ((c0 * math.pow(d, 2.0)) / (math.pow(D, 2.0) * (w * h)))) / (2.0 * w))
	else:
		tmp = c0 * (0.0 / (2.0 * w))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(D * D) * Float64(w * h)))
	tmp = 0.0
	if (Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) <= Inf)
		tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(c0 * (d ^ 2.0)) / Float64((D ^ 2.0) * Float64(w * h)))) / Float64(2.0 * w)));
	else
		tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w)));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = (c0 * (d * d)) / ((D * D) * (w * h));
	tmp = 0.0;
	if (((c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))))) <= Inf)
		tmp = c0 * ((2.0 * ((c0 * (d ^ 2.0)) / ((D ^ 2.0) * (w * h)))) / (2.0 * w));
	else
		tmp = c0 * (0.0 / (2.0 * w));
	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[(D * D), $MachinePrecision] * N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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], Infinity], N[(c0 * N[(N[(2.0 * N[(N[(c0 * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision] / N[(N[Power[D, 2.0], $MachinePrecision] * N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\


\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 70.6%

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

      \[\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 74.1%

      \[\leadsto c0 \cdot \frac{\color{blue}{2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\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. Simplified17.6%

      \[\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 1.3%

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

        \[\leadsto c0 \cdot \frac{-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)}}{2 \cdot w} \]
      2. mul-1-neg0.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      3. distribute-rgt-neg-in0.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      4. associate-/l*0.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      5. mul-1-neg0.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      6. associate-/l*0.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      7. distribute-lft1-in0.1%

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

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

        \[\leadsto c0 \cdot \frac{-1 \cdot \color{blue}{0}}{2 \cdot w} \]
      10. metadata-eval44.8%

        \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
    6. Simplified44.8%

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

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

Alternative 2: 53.8% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\


\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 70.6%

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

      \[\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 6.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}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. associate-*r/6.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{-1 \cdot \left(c0 \cdot {d}^{2}\right)}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. neg-mul-16.2%

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{c0 \cdot \left(-{d}^{2}\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
    6. Simplified6.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 \left(-{d}^{2}\right)}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. times-frac4.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}{\frac{c0}{{D}^{2}} \cdot \frac{-{d}^{2}}{h \cdot w}}\right)}{2 \cdot w} \]
      2. *-commutative4.5%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{c0}{{D}^{2}} \cdot \frac{-{d}^{2}}{\color{blue}{w \cdot h}}\right)}{2 \cdot w} \]
    8. Applied egg-rr4.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}{\frac{c0}{{D}^{2}} \cdot \frac{-{d}^{2}}{w \cdot h}}\right)}{2 \cdot w} \]
    9. Step-by-step derivation
      1. fma-undefine4.5%

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \color{blue}{\frac{\left(-{d}^{2}\right) \cdot c0}{\left(w \cdot h\right) \cdot {D}^{2}}}}{2 \cdot w} \]
      7. add-sqr-sqrt1.4%

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \frac{\color{blue}{\sqrt{\left(-{d}^{2}\right) \cdot \left(-{d}^{2}\right)}} \cdot c0}{\left(w \cdot h\right) \cdot {D}^{2}}}{2 \cdot w} \]
      9. sqr-neg68.8%

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \frac{\color{blue}{\left(\sqrt{{d}^{2}} \cdot \sqrt{{d}^{2}}\right)} \cdot c0}{\left(w \cdot h\right) \cdot {D}^{2}}}{2 \cdot w} \]
      11. add-sqr-sqrt70.4%

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \frac{\color{blue}{{d}^{2}} \cdot c0}{\left(w \cdot h\right) \cdot {D}^{2}}}{2 \cdot w} \]
      12. *-commutative70.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto c0 \cdot \frac{\color{blue}{c0 \cdot \left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}\right)}}{2 \cdot w} \]
    13. Step-by-step derivation
      1. div-inv73.8%

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

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

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

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

    1. Initial program 0.0%

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

      \[\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 1.3%

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

        \[\leadsto c0 \cdot \frac{-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)}}{2 \cdot w} \]
      2. mul-1-neg0.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      3. distribute-rgt-neg-in0.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      4. associate-/l*0.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      5. mul-1-neg0.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      6. associate-/l*0.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      7. distribute-lft1-in0.1%

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

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

        \[\leadsto c0 \cdot \frac{-1 \cdot \color{blue}{0}}{2 \cdot w} \]
      10. metadata-eval44.8%

        \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
    6. Simplified44.8%

      \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification53.9%

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

Alternative 3: 37.9% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 1.7 \cdot 10^{-109} \lor \neg \left(M \leq 7 \cdot 10^{-32}\right) \land M \leq 64000000:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \left(\frac{c0}{h} \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)}{2 \cdot w}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (or (<= M 1.7e-109) (and (not (<= M 7e-32)) (<= M 64000000.0)))
   (* c0 (/ 0.0 (* 2.0 w)))
   (* c0 (/ (* 2.0 (* (/ c0 h) (/ (pow (/ d D) 2.0) w))) (* 2.0 w)))))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if ((M <= 1.7e-109) || (!(M <= 7e-32) && (M <= 64000000.0))) {
		tmp = c0 * (0.0 / (2.0 * w));
	} else {
		tmp = c0 * ((2.0 * ((c0 / h) * (pow((d / D), 2.0) / w))) / (2.0 * w));
	}
	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) :: tmp
    if ((m <= 1.7d-109) .or. (.not. (m <= 7d-32)) .and. (m <= 64000000.0d0)) then
        tmp = c0 * (0.0d0 / (2.0d0 * w))
    else
        tmp = c0 * ((2.0d0 * ((c0 / h) * (((d_1 / d) ** 2.0d0) / w))) / (2.0d0 * w))
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if ((M <= 1.7e-109) || (!(M <= 7e-32) && (M <= 64000000.0))) {
		tmp = c0 * (0.0 / (2.0 * w));
	} else {
		tmp = c0 * ((2.0 * ((c0 / h) * (Math.pow((d / D), 2.0) / w))) / (2.0 * w));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if (M <= 1.7e-109) or (not (M <= 7e-32) and (M <= 64000000.0)):
		tmp = c0 * (0.0 / (2.0 * w))
	else:
		tmp = c0 * ((2.0 * ((c0 / h) * (math.pow((d / D), 2.0) / w))) / (2.0 * w))
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if ((M <= 1.7e-109) || (!(M <= 7e-32) && (M <= 64000000.0)))
		tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w)));
	else
		tmp = Float64(c0 * Float64(Float64(2.0 * Float64(Float64(c0 / h) * Float64((Float64(d / D) ^ 2.0) / w))) / Float64(2.0 * w)));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if ((M <= 1.7e-109) || (~((M <= 7e-32)) && (M <= 64000000.0)))
		tmp = c0 * (0.0 / (2.0 * w));
	else
		tmp = c0 * ((2.0 * ((c0 / h) * (((d / D) ^ 2.0) / w))) / (2.0 * w));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[M, 1.7e-109], And[N[Not[LessEqual[M, 7e-32]], $MachinePrecision], LessEqual[M, 64000000.0]]], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(N[(2.0 * N[(N[(c0 / h), $MachinePrecision] * N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.7 \cdot 10^{-109} \lor \neg \left(M \leq 7 \cdot 10^{-32}\right) \land M \leq 64000000:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 1.70000000000000006e-109 or 6.9999999999999997e-32 < M < 6.4e7

    1. Initial program 22.4%

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

      \[\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 3.2%

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

        \[\leadsto c0 \cdot \frac{-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)}}{2 \cdot w} \]
      2. mul-1-neg2.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      3. distribute-rgt-neg-in2.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      4. associate-/l*2.2%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      5. mul-1-neg2.2%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      6. associate-/l*3.2%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      7. distribute-lft1-in3.2%

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

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

        \[\leadsto c0 \cdot \frac{-1 \cdot \color{blue}{0}}{2 \cdot w} \]
      10. metadata-eval39.8%

        \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
    6. Simplified39.8%

      \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]

    if 1.70000000000000006e-109 < M < 6.9999999999999997e-32 or 6.4e7 < M

    1. Initial program 21.3%

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

      \[\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 0.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}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. associate-*r/0.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}{\frac{-1 \cdot \left(c0 \cdot {d}^{2}\right)}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. neg-mul-10.5%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{-c0 \cdot {d}^{2}}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      3. distribute-rgt-neg-in0.5%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{c0 \cdot \left(-{d}^{2}\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
    6. Simplified0.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}{\frac{c0 \cdot \left(-{d}^{2}\right)}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. times-frac0.0%

        \[\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}{{D}^{2}} \cdot \frac{-{d}^{2}}{h \cdot w}}\right)}{2 \cdot w} \]
      2. *-commutative0.0%

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

      \[\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}{{D}^{2}} \cdot \frac{-{d}^{2}}{w \cdot h}}\right)}{2 \cdot w} \]
    9. Step-by-step derivation
      1. fma-undefine0.0%

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \color{blue}{\frac{\left(-{d}^{2}\right) \cdot c0}{\left(w \cdot h\right) \cdot {D}^{2}}}}{2 \cdot w} \]
      7. add-sqr-sqrt0.0%

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \frac{\color{blue}{\sqrt{\left(-{d}^{2}\right) \cdot \left(-{d}^{2}\right)}} \cdot c0}{\left(w \cdot h\right) \cdot {D}^{2}}}{2 \cdot w} \]
      9. sqr-neg35.8%

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \frac{\color{blue}{\left(\sqrt{{d}^{2}} \cdot \sqrt{{d}^{2}}\right)} \cdot c0}{\left(w \cdot h\right) \cdot {D}^{2}}}{2 \cdot w} \]
      11. add-sqr-sqrt40.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{\color{blue}{c0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot h}} + c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)}}{2 \cdot w} \]
      4. distribute-lft-out42.3%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto c0 \cdot \frac{\color{blue}{c0 \cdot \left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} + \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}\right)}}{2 \cdot w} \]
    13. Step-by-step derivation
      1. distribute-lft-in50.2%

        \[\leadsto c0 \cdot \frac{\color{blue}{c0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} + c0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}}}{2 \cdot w} \]
    14. Applied egg-rr50.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 1.7 \cdot 10^{-109} \lor \neg \left(M \leq 7 \cdot 10^{-32}\right) \land M \leq 64000000:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \left(\frac{c0}{h} \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)}{2 \cdot w}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 38.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot h}\\ t_1 := c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{if}\;M \leq 1.45 \cdot 10^{-109}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;M \leq 2.2 \cdot 10^{-33}:\\ \;\;\;\;c0 \cdot \left(c0 \cdot \frac{t\_0}{w}\right)\\ \mathbf{elif}\;M \leq 550:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(\frac{c0}{2} \cdot \frac{2 \cdot t\_0}{w}\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (pow (/ d D) 2.0) (* w h))) (t_1 (* c0 (/ 0.0 (* 2.0 w)))))
   (if (<= M 1.45e-109)
     t_1
     (if (<= M 2.2e-33)
       (* c0 (* c0 (/ t_0 w)))
       (if (<= M 550.0) t_1 (* c0 (* (/ c0 2.0) (/ (* 2.0 t_0) w))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = pow((d / D), 2.0) / (w * h);
	double t_1 = c0 * (0.0 / (2.0 * w));
	double tmp;
	if (M <= 1.45e-109) {
		tmp = t_1;
	} else if (M <= 2.2e-33) {
		tmp = c0 * (c0 * (t_0 / w));
	} else if (M <= 550.0) {
		tmp = t_1;
	} else {
		tmp = c0 * ((c0 / 2.0) * ((2.0 * t_0) / w));
	}
	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 = ((d_1 / d) ** 2.0d0) / (w * h)
    t_1 = c0 * (0.0d0 / (2.0d0 * w))
    if (m <= 1.45d-109) then
        tmp = t_1
    else if (m <= 2.2d-33) then
        tmp = c0 * (c0 * (t_0 / w))
    else if (m <= 550.0d0) then
        tmp = t_1
    else
        tmp = c0 * ((c0 / 2.0d0) * ((2.0d0 * t_0) / w))
    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 = Math.pow((d / D), 2.0) / (w * h);
	double t_1 = c0 * (0.0 / (2.0 * w));
	double tmp;
	if (M <= 1.45e-109) {
		tmp = t_1;
	} else if (M <= 2.2e-33) {
		tmp = c0 * (c0 * (t_0 / w));
	} else if (M <= 550.0) {
		tmp = t_1;
	} else {
		tmp = c0 * ((c0 / 2.0) * ((2.0 * t_0) / w));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = math.pow((d / D), 2.0) / (w * h)
	t_1 = c0 * (0.0 / (2.0 * w))
	tmp = 0
	if M <= 1.45e-109:
		tmp = t_1
	elif M <= 2.2e-33:
		tmp = c0 * (c0 * (t_0 / w))
	elif M <= 550.0:
		tmp = t_1
	else:
		tmp = c0 * ((c0 / 2.0) * ((2.0 * t_0) / w))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64((Float64(d / D) ^ 2.0) / Float64(w * h))
	t_1 = Float64(c0 * Float64(0.0 / Float64(2.0 * w)))
	tmp = 0.0
	if (M <= 1.45e-109)
		tmp = t_1;
	elseif (M <= 2.2e-33)
		tmp = Float64(c0 * Float64(c0 * Float64(t_0 / w)));
	elseif (M <= 550.0)
		tmp = t_1;
	else
		tmp = Float64(c0 * Float64(Float64(c0 / 2.0) * Float64(Float64(2.0 * t_0) / w)));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = ((d / D) ^ 2.0) / (w * h);
	t_1 = c0 * (0.0 / (2.0 * w));
	tmp = 0.0;
	if (M <= 1.45e-109)
		tmp = t_1;
	elseif (M <= 2.2e-33)
		tmp = c0 * (c0 * (t_0 / w));
	elseif (M <= 550.0)
		tmp = t_1;
	else
		tmp = c0 * ((c0 / 2.0) * ((2.0 * t_0) / w));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 1.45e-109], t$95$1, If[LessEqual[M, 2.2e-33], N[(c0 * N[(c0 * N[(t$95$0 / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 550.0], t$95$1, N[(c0 * N[(N[(c0 / 2.0), $MachinePrecision] * N[(N[(2.0 * t$95$0), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot h}\\
t_1 := c0 \cdot \frac{0}{2 \cdot w}\\
\mathbf{if}\;M \leq 1.45 \cdot 10^{-109}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;M \leq 2.2 \cdot 10^{-33}:\\
\;\;\;\;c0 \cdot \left(c0 \cdot \frac{t\_0}{w}\right)\\

\mathbf{elif}\;M \leq 550:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if M < 1.45e-109 or 2.20000000000000005e-33 < M < 550

    1. Initial program 22.1%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified30.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 3.2%

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

        \[\leadsto c0 \cdot \frac{-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)}}{2 \cdot w} \]
      2. mul-1-neg2.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      3. distribute-rgt-neg-in2.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      4. associate-/l*2.2%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      5. mul-1-neg2.2%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      6. associate-/l*3.2%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      7. distribute-lft1-in3.2%

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

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

        \[\leadsto c0 \cdot \frac{-1 \cdot \color{blue}{0}}{2 \cdot w} \]
      10. metadata-eval40.3%

        \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
    6. Simplified40.3%

      \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]

    if 1.45e-109 < M < 2.20000000000000005e-33

    1. Initial program 37.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. Simplified42.4%

      \[\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 1.3%

      \[\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}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. associate-*r/1.3%

        \[\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{-1 \cdot \left(c0 \cdot {d}^{2}\right)}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. neg-mul-11.3%

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

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

      \[\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 \left(-{d}^{2}\right)}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. times-frac0.1%

        \[\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}{{D}^{2}} \cdot \frac{-{d}^{2}}{h \cdot w}}\right)}{2 \cdot w} \]
      2. *-commutative0.1%

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

      \[\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}{{D}^{2}} \cdot \frac{-{d}^{2}}{w \cdot h}}\right)}{2 \cdot w} \]
    9. Step-by-step derivation
      1. fma-undefine0.0%

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \frac{\color{blue}{\sqrt{\left(-{d}^{2}\right) \cdot \left(-{d}^{2}\right)}} \cdot c0}{\left(w \cdot h\right) \cdot {D}^{2}}}{2 \cdot w} \]
      9. sqr-neg37.8%

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \frac{\color{blue}{\left(\sqrt{{d}^{2}} \cdot \sqrt{{d}^{2}}\right)} \cdot c0}{\left(w \cdot h\right) \cdot {D}^{2}}}{2 \cdot w} \]
      11. add-sqr-sqrt37.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 550 < M

    1. Initial program 16.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. Simplified41.0%

      \[\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 0.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}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. associate-*r/0.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{-1 \cdot \left(c0 \cdot {d}^{2}\right)}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. neg-mul-10.2%

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

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{c0 \cdot \left(-{d}^{2}\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
    6. Simplified0.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 \left(-{d}^{2}\right)}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. times-frac0.0%

        \[\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}{{D}^{2}} \cdot \frac{-{d}^{2}}{h \cdot w}}\right)}{2 \cdot w} \]
      2. *-commutative0.0%

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

      \[\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}{{D}^{2}} \cdot \frac{-{d}^{2}}{w \cdot h}}\right)}{2 \cdot w} \]
    9. Step-by-step derivation
      1. fma-undefine0.0%

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \color{blue}{\frac{\left(-{d}^{2}\right) \cdot c0}{\left(w \cdot h\right) \cdot {D}^{2}}}}{2 \cdot w} \]
      7. add-sqr-sqrt0.0%

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

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \frac{\color{blue}{\left(\sqrt{{d}^{2}} \cdot \sqrt{{d}^{2}}\right)} \cdot c0}{\left(w \cdot h\right) \cdot {D}^{2}}}{2 \cdot w} \]
      11. add-sqr-sqrt41.2%

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \color{blue}{\frac{c0}{w \cdot h} \cdot \frac{{d}^{2}}{{D}^{2}}}}{2 \cdot w} \]
      14. pow243.0%

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \frac{c0}{w \cdot h} \cdot \frac{\color{blue}{d \cdot d}}{{D}^{2}}}{2 \cdot w} \]
      15. pow243.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} + \frac{\color{blue}{{\left(\frac{d}{D}\right)}^{2}}}{w \cdot h}\right)}{2 \cdot w} \]
      15. *-commutative50.7%

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

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

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

        \[\leadsto c0 \cdot \left(\frac{c0}{2} \cdot \frac{\color{blue}{2 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}}}{w}\right) \]
    14. Applied egg-rr49.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 1.45 \cdot 10^{-109}:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{elif}\;M \leq 2.2 \cdot 10^{-33}:\\ \;\;\;\;c0 \cdot \left(c0 \cdot \frac{\frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot h}}{w}\right)\\ \mathbf{elif}\;M \leq 550:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(\frac{c0}{2} \cdot \frac{2 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot h}}{w}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 38.1% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 1.05 \cdot 10^{-108} \lor \neg \left(M \leq 4.1 \cdot 10^{-33}\right) \land M \leq 34000:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(c0 \cdot \frac{\frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot h}}{w}\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (or (<= M 1.05e-108) (and (not (<= M 4.1e-33)) (<= M 34000.0)))
   (* c0 (/ 0.0 (* 2.0 w)))
   (* c0 (* c0 (/ (/ (pow (/ d D) 2.0) (* w h)) w)))))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if ((M <= 1.05e-108) || (!(M <= 4.1e-33) && (M <= 34000.0))) {
		tmp = c0 * (0.0 / (2.0 * w));
	} else {
		tmp = c0 * (c0 * ((pow((d / D), 2.0) / (w * h)) / w));
	}
	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) :: tmp
    if ((m <= 1.05d-108) .or. (.not. (m <= 4.1d-33)) .and. (m <= 34000.0d0)) then
        tmp = c0 * (0.0d0 / (2.0d0 * w))
    else
        tmp = c0 * (c0 * ((((d_1 / d) ** 2.0d0) / (w * h)) / w))
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if ((M <= 1.05e-108) || (!(M <= 4.1e-33) && (M <= 34000.0))) {
		tmp = c0 * (0.0 / (2.0 * w));
	} else {
		tmp = c0 * (c0 * ((Math.pow((d / D), 2.0) / (w * h)) / w));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if (M <= 1.05e-108) or (not (M <= 4.1e-33) and (M <= 34000.0)):
		tmp = c0 * (0.0 / (2.0 * w))
	else:
		tmp = c0 * (c0 * ((math.pow((d / D), 2.0) / (w * h)) / w))
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if ((M <= 1.05e-108) || (!(M <= 4.1e-33) && (M <= 34000.0)))
		tmp = Float64(c0 * Float64(0.0 / Float64(2.0 * w)));
	else
		tmp = Float64(c0 * Float64(c0 * Float64(Float64((Float64(d / D) ^ 2.0) / Float64(w * h)) / w)));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if ((M <= 1.05e-108) || (~((M <= 4.1e-33)) && (M <= 34000.0)))
		tmp = c0 * (0.0 / (2.0 * w));
	else
		tmp = c0 * (c0 * ((((d / D) ^ 2.0) / (w * h)) / w));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[M, 1.05e-108], And[N[Not[LessEqual[M, 4.1e-33]], $MachinePrecision], LessEqual[M, 34000.0]]], N[(c0 * N[(0.0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * N[(c0 * N[(N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq 1.05 \cdot 10^{-108} \lor \neg \left(M \leq 4.1 \cdot 10^{-33}\right) \land M \leq 34000:\\
\;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 1.05e-108 or 4.1e-33 < M < 34000

    1. Initial program 22.1%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified30.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 3.2%

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

        \[\leadsto c0 \cdot \frac{-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)}}{2 \cdot w} \]
      2. mul-1-neg2.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      3. distribute-rgt-neg-in2.1%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      4. associate-/l*2.2%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      5. mul-1-neg2.2%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      6. associate-/l*3.2%

        \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
      7. distribute-lft1-in3.2%

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

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

        \[\leadsto c0 \cdot \frac{-1 \cdot \color{blue}{0}}{2 \cdot w} \]
      10. metadata-eval40.3%

        \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
    6. Simplified40.3%

      \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]

    if 1.05e-108 < M < 4.1e-33 or 34000 < M

    1. Initial program 22.1%

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

      \[\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 0.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}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    5. Step-by-step derivation
      1. associate-*r/0.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}{\frac{-1 \cdot \left(c0 \cdot {d}^{2}\right)}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. neg-mul-10.5%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{-c0 \cdot {d}^{2}}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
      3. distribute-rgt-neg-in0.5%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \frac{\color{blue}{c0 \cdot \left(-{d}^{2}\right)}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{2 \cdot w} \]
    6. Simplified0.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}{\frac{c0 \cdot \left(-{d}^{2}\right)}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    7. Step-by-step derivation
      1. times-frac0.0%

        \[\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}{{D}^{2}} \cdot \frac{-{d}^{2}}{h \cdot w}}\right)}{2 \cdot w} \]
      2. *-commutative0.0%

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

      \[\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}{{D}^{2}} \cdot \frac{-{d}^{2}}{w \cdot h}}\right)}{2 \cdot w} \]
    9. Step-by-step derivation
      1. fma-undefine0.0%

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \color{blue}{\frac{\left(-{d}^{2}\right) \cdot c0}{\left(w \cdot h\right) \cdot {D}^{2}}}}{2 \cdot w} \]
      7. add-sqr-sqrt0.0%

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

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \frac{\color{blue}{\left(\sqrt{{d}^{2}} \cdot \sqrt{{d}^{2}}\right)} \cdot c0}{\left(w \cdot h\right) \cdot {D}^{2}}}{2 \cdot w} \]
      11. add-sqr-sqrt40.4%

        \[\leadsto c0 \cdot \frac{c0 \cdot \frac{{d}^{2}}{\left(D \cdot w\right) \cdot \left(h \cdot D\right)} + \frac{\color{blue}{{d}^{2}} \cdot c0}{\left(w \cdot h\right) \cdot {D}^{2}}}{2 \cdot w} \]
      12. *-commutative40.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} + \frac{d \cdot \frac{d}{D}}{\color{blue}{\left(w \cdot h\right) \cdot D}}\right)}{2 \cdot w} \]
      11. *-commutative50.4%

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

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} + \frac{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}{w \cdot h}\right)}{2 \cdot w} \]
      14. unpow251.6%

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

        \[\leadsto c0 \cdot \frac{c0 \cdot \left(\frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w} + \frac{{\left(\frac{d}{D}\right)}^{2}}{\color{blue}{h \cdot w}}\right)}{2 \cdot w} \]
    12. Simplified51.6%

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

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

        \[\leadsto c0 \cdot \left(c0 \cdot \frac{\color{blue}{2 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{h \cdot w}}}{2 \cdot w}\right) \]
    14. Applied egg-rr50.3%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 1.05 \cdot 10^{-108} \lor \neg \left(M \leq 4.1 \cdot 10^{-33}\right) \land M \leq 34000:\\ \;\;\;\;c0 \cdot \frac{0}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot \left(c0 \cdot \frac{\frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot h}}{w}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 33.5% accurate, 21.6× speedup?

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

\\
c0 \cdot \frac{0}{2 \cdot w}
\end{array}
Derivation
  1. Initial program 22.1%

    \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
  2. Simplified33.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 2.3%

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

      \[\leadsto c0 \cdot \frac{-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)}}{2 \cdot w} \]
    2. mul-1-neg1.5%

      \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
    3. distribute-rgt-neg-in1.5%

      \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
    4. associate-/l*1.6%

      \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
    5. mul-1-neg1.6%

      \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
    6. associate-/l*2.3%

      \[\leadsto c0 \cdot \frac{-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)}{2 \cdot w} \]
    7. distribute-lft1-in2.3%

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

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

      \[\leadsto c0 \cdot \frac{-1 \cdot \color{blue}{0}}{2 \cdot w} \]
    10. metadata-eval33.5%

      \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
  6. Simplified33.5%

    \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
  7. Final simplification33.5%

    \[\leadsto c0 \cdot \frac{0}{2 \cdot w} \]
  8. Add Preprocessing

Reproduce

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