Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.8% → 54.0%
Time: 31.4s
Alternatives: 5
Speedup: 151.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 5 alternatives:

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

Initial Program: 24.8% accurate, 1.0× speedup?

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

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

Alternative 1: 54.0% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 77.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. Simplified76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{c0 \cdot {\left(\frac{d}{D}\right)}^{2}}{w \cdot h}}\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. Simplified21.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. Step-by-step derivation
      1. *-un-lft-identity21.9%

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

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

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

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

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

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

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

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

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

      \[\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} \]
    9. Step-by-step derivation
      1. mul-1-neg1.4%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{-\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. 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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      3. associate-/r*2.0%

        \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -c0 \cdot \color{blue}{\frac{\frac{{d}^{2}}{{D}^{2}}}{h \cdot w}}\right)}{2 \cdot w} \]
    10. Simplified2.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}{-c0 \cdot \frac{\frac{{d}^{2}}{{D}^{2}}}{h \cdot w}}\right)}{2 \cdot w} \]
    11. Taylor expanded in c0 around 0 45.7%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 39.3% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 3.7 \cdot 10^{-142}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{h} \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w}\right)\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (<= M 3.7e-142)
   0.0
   (* (/ c0 (* 2.0 w)) (* 2.0 (* (/ c0 h) (/ (pow (/ d D) 2.0) w))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (M <= 3.7e-142) {
		tmp = 0.0;
	} else {
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / h) * (pow((d / D), 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 <= 3.7d-142) then
        tmp = 0.0d0
    else
        tmp = (c0 / (2.0d0 * w)) * (2.0d0 * ((c0 / h) * (((d_1 / d) ** 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 <= 3.7e-142) {
		tmp = 0.0;
	} else {
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / h) * (Math.pow((d / D), 2.0) / w)));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if M <= 3.7e-142:
		tmp = 0.0
	else:
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / h) * (math.pow((d / D), 2.0) / w)))
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if (M <= 3.7e-142)
		tmp = 0.0;
	else
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(c0 / h) * Float64((Float64(d / D) ^ 2.0) / w))));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if (M <= 3.7e-142)
		tmp = 0.0;
	else
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / h) * (((d / D) ^ 2.0) / w)));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 3.7e-142], 0.0, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(c0 / h), $MachinePrecision] * N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq 3.7 \cdot 10^{-142}:\\
\;\;\;\;0\\

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


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

    1. Initial program 25.5%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified39.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. Step-by-step derivation
      1. *-un-lft-identity39.2%

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

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

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

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

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

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

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

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \left(c0 \cdot \left(d \cdot \color{blue}{\frac{d}{w \cdot \left(h \cdot {D}^{2}\right)}}\right) - M\right)}\right)}{2 \cdot w} \]
    8. Taylor expanded in c0 around -inf 5.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}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    9. Step-by-step derivation
      1. mul-1-neg5.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 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. associate-*r/5.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      3. 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)}, -c0 \cdot \color{blue}{\frac{\frac{{d}^{2}}{{D}^{2}}}{h \cdot w}}\right)}{2 \cdot w} \]
    10. 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}{-c0 \cdot \frac{\frac{{d}^{2}}{{D}^{2}}}{h \cdot w}}\right)}{2 \cdot w} \]
    11. Taylor expanded in c0 around 0 40.0%

      \[\leadsto \color{blue}{0} \]

    if 3.69999999999999986e-142 < M

    1. Initial program 21.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. Simplified21.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 39.1% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 9 \cdot 10^{-141}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(c0 \cdot \frac{{\left(\frac{d}{D}\right)}^{2}}{w \cdot h}\right)\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (<= M 9e-141)
   0.0
   (* (/ c0 (* 2.0 w)) (* 2.0 (* c0 (/ (pow (/ d D) 2.0) (* w h)))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (M <= 9e-141) {
		tmp = 0.0;
	} else {
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 * (pow((d / D), 2.0) / (w * h))));
	}
	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 <= 9d-141) then
        tmp = 0.0d0
    else
        tmp = (c0 / (2.0d0 * w)) * (2.0d0 * (c0 * (((d_1 / d) ** 2.0d0) / (w * h))))
    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 <= 9e-141) {
		tmp = 0.0;
	} else {
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 * (Math.pow((d / D), 2.0) / (w * h))));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if M <= 9e-141:
		tmp = 0.0
	else:
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 * (math.pow((d / D), 2.0) / (w * h))))
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if (M <= 9e-141)
		tmp = 0.0;
	else
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(c0 * Float64((Float64(d / D) ^ 2.0) / Float64(w * h)))));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if (M <= 9e-141)
		tmp = 0.0;
	else
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 * (((d / D) ^ 2.0) / (w * h))));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 9e-141], 0.0, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(c0 * N[(N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq 9 \cdot 10^{-141}:\\
\;\;\;\;0\\

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


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

    1. Initial program 25.5%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified39.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. Step-by-step derivation
      1. *-un-lft-identity39.2%

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

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

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

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

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

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

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

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \left(c0 \cdot \left(d \cdot \color{blue}{\frac{d}{w \cdot \left(h \cdot {D}^{2}\right)}}\right) - M\right)}\right)}{2 \cdot w} \]
    8. Taylor expanded in c0 around -inf 5.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}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    9. Step-by-step derivation
      1. mul-1-neg5.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 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. associate-*r/5.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      3. 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)}, -c0 \cdot \color{blue}{\frac{\frac{{d}^{2}}{{D}^{2}}}{h \cdot w}}\right)}{2 \cdot w} \]
    10. 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}{-c0 \cdot \frac{\frac{{d}^{2}}{{D}^{2}}}{h \cdot w}}\right)}{2 \cdot w} \]
    11. Taylor expanded in c0 around 0 40.0%

      \[\leadsto \color{blue}{0} \]

    if 9.0000000000000001e-141 < M

    1. Initial program 21.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. Simplified21.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 39.4% accurate, 5.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 8 \cdot 10^{-142}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{c0}{h}}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (<= M 8e-142)
   0.0
   (* (/ c0 (* 2.0 w)) (* 2.0 (* (/ (/ c0 h) w) (* (/ d D) (/ d D)))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (M <= 8e-142) {
		tmp = 0.0;
	} else {
		tmp = (c0 / (2.0 * w)) * (2.0 * (((c0 / h) / w) * ((d / D) * (d / D))));
	}
	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 <= 8d-142) then
        tmp = 0.0d0
    else
        tmp = (c0 / (2.0d0 * w)) * (2.0d0 * (((c0 / h) / w) * ((d_1 / d) * (d_1 / d))))
    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 <= 8e-142) {
		tmp = 0.0;
	} else {
		tmp = (c0 / (2.0 * w)) * (2.0 * (((c0 / h) / w) * ((d / D) * (d / D))));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if M <= 8e-142:
		tmp = 0.0
	else:
		tmp = (c0 / (2.0 * w)) * (2.0 * (((c0 / h) / w) * ((d / D) * (d / D))))
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if (M <= 8e-142)
		tmp = 0.0;
	else
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(Float64(c0 / h) / w) * Float64(Float64(d / D) * Float64(d / D)))));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if (M <= 8e-142)
		tmp = 0.0;
	else
		tmp = (c0 / (2.0 * w)) * (2.0 * (((c0 / h) / w) * ((d / D) * (d / D))));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 8e-142], 0.0, N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(N[(c0 / h), $MachinePrecision] / w), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq 8 \cdot 10^{-142}:\\
\;\;\;\;0\\

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


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

    1. Initial program 25.5%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified39.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. Step-by-step derivation
      1. *-un-lft-identity39.2%

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

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

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

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

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

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

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

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

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \sqrt{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, M\right) \cdot \left(c0 \cdot \left(d \cdot \color{blue}{\frac{d}{w \cdot \left(h \cdot {D}^{2}\right)}}\right) - M\right)}\right)}{2 \cdot w} \]
    8. Taylor expanded in c0 around -inf 5.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}{-1 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    9. Step-by-step derivation
      1. mul-1-neg5.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 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      2. associate-*r/5.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
      3. 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)}, -c0 \cdot \color{blue}{\frac{\frac{{d}^{2}}{{D}^{2}}}{h \cdot w}}\right)}{2 \cdot w} \]
    10. 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}{-c0 \cdot \frac{\frac{{d}^{2}}{{D}^{2}}}{h \cdot w}}\right)}{2 \cdot w} \]
    11. Taylor expanded in c0 around 0 40.0%

      \[\leadsto \color{blue}{0} \]

    if 8.0000000000000003e-142 < M

    1. Initial program 21.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. Simplified21.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 33.1% accurate, 151.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (c0 w h D d M) :precision binary64 0.0)
double code(double c0, double w, double h, double D, double d, double M) {
	return 0.0;
}
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    code = 0.0d0
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	return 0.0;
}
def code(c0, w, h, D, d, M):
	return 0.0
function code(c0, w, h, D, d, M)
	return 0.0
end
function tmp = code(c0, w, h, D, d, M)
	tmp = 0.0;
end
code[c0_, w_, h_, D_, d_, M_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 24.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. Simplified39.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. Step-by-step derivation
    1. *-un-lft-identity39.3%

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

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

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

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

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

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

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

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

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

    \[\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} \]
  9. Step-by-step derivation
    1. mul-1-neg3.8%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, \color{blue}{-\frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    2. associate-*r/4.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}{c0 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)}{2 \cdot w} \]
    3. associate-/r*5.0%

      \[\leadsto c0 \cdot \frac{\mathsf{fma}\left(c0, d \cdot \frac{d}{D \cdot \left(w \cdot \left(h \cdot D\right)\right)}, -c0 \cdot \color{blue}{\frac{\frac{{d}^{2}}{{D}^{2}}}{h \cdot w}}\right)}{2 \cdot w} \]
  10. Simplified5.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}{-c0 \cdot \frac{\frac{{d}^{2}}{{D}^{2}}}{h \cdot w}}\right)}{2 \cdot w} \]
  11. Taylor expanded in c0 around 0 35.6%

    \[\leadsto \color{blue}{0} \]
  12. Add Preprocessing

Reproduce

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