Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.9% → 53.7%
Time: 46.2s
Alternatives: 7
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 7 alternatives:

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

Initial Program: 24.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ \frac{c0}{2 \cdot w} \cdot \left(t_0 + \sqrt{t_0 \cdot t_0 - M \cdot M}\right) \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* c0 (* d d)) (* (* w h) (* D D)))))
   (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M)))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 * (d * d)) / ((w * h) * (D * D));
	return (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
}
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.6× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.25, \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{d \cdot d}, 0\right)\\


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

    1. Initial program 71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \sqrt[3]{{\color{blue}{\left(2 \cdot \left(\frac{c0}{w \cdot \left(\left(D \cdot D\right) \cdot h\right)} \cdot \left(d \cdot d\right)\right)\right)}}^{3}} \]
    10. Step-by-step derivation
      1. rem-cbrt-cube70.7%

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\left(\left(d \cdot d\right) \cdot \frac{c0}{w \cdot \left(D \cdot \left(D \cdot h\right)\right)}\right) \cdot 2\right)} \]
    12. Taylor expanded in d around 0 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if +inf.0 < (*.f64 (/.f64 c0 (*.f64 2 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. Simplified1.9%

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

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

      \[\leadsto \color{blue}{\frac{c0}{w \cdot 2} \cdot \left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) + \frac{c0}{w \cdot 2} \cdot \sqrt{{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)}^{2} - M \cdot M}} \]
    5. Taylor expanded in c0 around -inf 1.9%

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}} + {c0}^{2} \cdot \left(-0.5 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} + 0.5 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}\right)} \]
    6. Step-by-step derivation
      1. fma-def1.9%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(0.25, \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{d \cdot d}, \color{blue}{\left(c0 \cdot c0\right)} \cdot \left(-0.5 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} + 0.5 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)}\right)\right) \]
      7. distribute-rgt-out1.9%

        \[\leadsto \mathsf{fma}\left(0.25, \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{d \cdot d}, \left(c0 \cdot c0\right) \cdot \color{blue}{\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot {w}^{2}\right)} \cdot \left(-0.5 + 0.5\right)\right)}\right) \]
      8. metadata-eval1.9%

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

        \[\leadsto \mathsf{fma}\left(0.25, \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{d \cdot d}, \left(c0 \cdot c0\right) \cdot \color{blue}{0}\right) \]
    7. Simplified20.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.25, \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{d \cdot d}, \left(c0 \cdot c0\right) \cdot 0\right)} \]
    8. Taylor expanded in c0 around 0 35.8%

      \[\leadsto \mathsf{fma}\left(0.25, \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{d \cdot d}, \color{blue}{0}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification50.2%

    \[\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:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(d \cdot \left(d \cdot \frac{c0}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.25, \frac{\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)}{d \cdot d}, 0\right)\\ \end{array} \]

Alternative 2: 42.5% accurate, 6.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;w \leq -5.1 \cdot 10^{+48}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 9.5 \cdot 10^{-164} \lor \neg \left(w \leq 3.4 \cdot 10^{-138}\right) \land w \leq 5.2 \cdot 10^{+97}:\\ \;\;\;\;\left(\frac{c0}{D} \cdot \frac{c0}{D}\right) \cdot \left(\frac{d}{h} \cdot \frac{d}{w \cdot w}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (<= w -5.1e+48)
   0.0
   (if (or (<= w 9.5e-164) (and (not (<= w 3.4e-138)) (<= w 5.2e+97)))
     (* (* (/ c0 D) (/ c0 D)) (* (/ d h) (/ d (* w w))))
     0.0)))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (w <= -5.1e+48) {
		tmp = 0.0;
	} else if ((w <= 9.5e-164) || (!(w <= 3.4e-138) && (w <= 5.2e+97))) {
		tmp = ((c0 / D) * (c0 / D)) * ((d / h) * (d / (w * w)));
	} else {
		tmp = 0.0;
	}
	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 (w <= (-5.1d+48)) then
        tmp = 0.0d0
    else if ((w <= 9.5d-164) .or. (.not. (w <= 3.4d-138)) .and. (w <= 5.2d+97)) then
        tmp = ((c0 / d) * (c0 / d)) * ((d_1 / h) * (d_1 / (w * w)))
    else
        tmp = 0.0d0
    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 (w <= -5.1e+48) {
		tmp = 0.0;
	} else if ((w <= 9.5e-164) || (!(w <= 3.4e-138) && (w <= 5.2e+97))) {
		tmp = ((c0 / D) * (c0 / D)) * ((d / h) * (d / (w * w)));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if w <= -5.1e+48:
		tmp = 0.0
	elif (w <= 9.5e-164) or (not (w <= 3.4e-138) and (w <= 5.2e+97)):
		tmp = ((c0 / D) * (c0 / D)) * ((d / h) * (d / (w * w)))
	else:
		tmp = 0.0
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if (w <= -5.1e+48)
		tmp = 0.0;
	elseif ((w <= 9.5e-164) || (!(w <= 3.4e-138) && (w <= 5.2e+97)))
		tmp = Float64(Float64(Float64(c0 / D) * Float64(c0 / D)) * Float64(Float64(d / h) * Float64(d / Float64(w * w))));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if (w <= -5.1e+48)
		tmp = 0.0;
	elseif ((w <= 9.5e-164) || (~((w <= 3.4e-138)) && (w <= 5.2e+97)))
		tmp = ((c0 / D) * (c0 / D)) * ((d / h) * (d / (w * w)));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[w, -5.1e+48], 0.0, If[Or[LessEqual[w, 9.5e-164], And[N[Not[LessEqual[w, 3.4e-138]], $MachinePrecision], LessEqual[w, 5.2e+97]]], N[(N[(N[(c0 / D), $MachinePrecision] * N[(c0 / D), $MachinePrecision]), $MachinePrecision] * N[(N[(d / h), $MachinePrecision] * N[(d / N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;w \leq -5.1 \cdot 10^{+48}:\\
\;\;\;\;0\\

\mathbf{elif}\;w \leq 9.5 \cdot 10^{-164} \lor \neg \left(w \leq 3.4 \cdot 10^{-138}\right) \land w \leq 5.2 \cdot 10^{+97}:\\
\;\;\;\;\left(\frac{c0}{D} \cdot \frac{c0}{D}\right) \cdot \left(\frac{d}{h} \cdot \frac{d}{w \cdot w}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if w < -5.0999999999999998e48 or 9.5000000000000001e-164 < w < 3.4000000000000001e-138 or 5.2e97 < w

    1. Initial program 19.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. Simplified20.6%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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. distribute-lft-in6.4%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{0} \]
    6. Taylor expanded in c0 around 0 36.0%

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

    if -5.0999999999999998e48 < w < 9.5000000000000001e-164 or 3.4000000000000001e-138 < w < 5.2e97

    1. Initial program 29.7%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified31.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{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, -M \cdot M\right)}\right)} \]
    3. Taylor expanded in c0 around inf 32.4%

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

        \[\leadsto \color{blue}{\frac{{c0}^{2}}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}}} \]
      2. unpow233.4%

        \[\leadsto \frac{\color{blue}{c0 \cdot c0}}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}} \]
      3. unpow233.4%

        \[\leadsto \frac{c0 \cdot c0}{\color{blue}{D \cdot D}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}} \]
      4. unpow233.4%

        \[\leadsto \frac{c0 \cdot c0}{D \cdot D} \cdot \frac{\color{blue}{d \cdot d}}{h \cdot {w}^{2}} \]
      5. unpow233.4%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -5.1 \cdot 10^{+48}:\\ \;\;\;\;0\\ \mathbf{elif}\;w \leq 9.5 \cdot 10^{-164} \lor \neg \left(w \leq 3.4 \cdot 10^{-138}\right) \land w \leq 5.2 \cdot 10^{+97}:\\ \;\;\;\;\left(\frac{c0}{D} \cdot \frac{c0}{D}\right) \cdot \left(\frac{d}{h} \cdot \frac{d}{w \cdot w}\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 3: 42.0% accurate, 6.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;M \cdot M \leq 1.32 \cdot 10^{-122}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(d \cdot \left(d \cdot \frac{c0}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\right)\right)\right)\\

\mathbf{elif}\;M \cdot M \leq 5.4 \cdot 10^{-35}:\\
\;\;\;\;0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 M M) < 1.3200000000000001e-122

    1. Initial program 34.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. Simplified34.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \sqrt[3]{{\color{blue}{\left(2 \cdot \left(\frac{c0}{w \cdot \left(\left(D \cdot D\right) \cdot h\right)} \cdot \left(d \cdot d\right)\right)\right)}}^{3}} \]
    10. Step-by-step derivation
      1. rem-cbrt-cube37.2%

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\left(\left(d \cdot d\right) \cdot \frac{c0}{w \cdot \left(D \cdot \left(D \cdot h\right)\right)}\right) \cdot 2\right)} \]
    12. Taylor expanded in d around 0 34.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3200000000000001e-122 < (*.f64 M M) < 5.3999999999999995e-35

    1. Initial program 17.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. Simplified17.6%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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. distribute-lft-in0.3%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{0} \]
    6. Taylor expanded in c0 around 0 49.3%

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

    if 5.3999999999999995e-35 < (*.f64 M M)

    1. Initial program 20.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. Simplified21.9%

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

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

        \[\leadsto \color{blue}{\frac{{c0}^{2}}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}}} \]
      2. unpow225.6%

        \[\leadsto \frac{\color{blue}{c0 \cdot c0}}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}} \]
      3. unpow225.6%

        \[\leadsto \frac{c0 \cdot c0}{\color{blue}{D \cdot D}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}} \]
      4. unpow225.6%

        \[\leadsto \frac{c0 \cdot c0}{D \cdot D} \cdot \frac{\color{blue}{d \cdot d}}{h \cdot {w}^{2}} \]
      5. unpow225.6%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \cdot M \leq 1.32 \cdot 10^{-122}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(d \cdot \left(d \cdot \frac{c0}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\right)\right)\right)\\ \mathbf{elif}\;M \cdot M \leq 5.4 \cdot 10^{-35}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{D} \cdot \left(\frac{c0}{D} \cdot \frac{d \cdot \frac{\frac{d}{w}}{w}}{h}\right)\\ \end{array} \]

Alternative 4: 43.8% accurate, 7.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;D \leq 3.7 \cdot 10^{+56}:\\
\;\;\;\;\frac{c0}{D} \cdot \left(\frac{c0}{D} \cdot \frac{\frac{d \cdot \frac{d}{w}}{w}}{h}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if D < 3.69999999999999997e56

    1. Initial program 27.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. Simplified28.7%

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

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

        \[\leadsto \color{blue}{\frac{{c0}^{2}}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}}} \]
      2. unpow224.4%

        \[\leadsto \frac{\color{blue}{c0 \cdot c0}}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}} \]
      3. unpow224.4%

        \[\leadsto \frac{c0 \cdot c0}{\color{blue}{D \cdot D}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}} \]
      4. unpow224.4%

        \[\leadsto \frac{c0 \cdot c0}{D \cdot D} \cdot \frac{\color{blue}{d \cdot d}}{h \cdot {w}^{2}} \]
      5. unpow224.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.69999999999999997e56 < D

    1. Initial program 19.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. Simplified19.0%

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

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

        \[\leadsto \color{blue}{\frac{{c0}^{2}}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}}} \]
      2. unpow229.4%

        \[\leadsto \frac{\color{blue}{c0 \cdot c0}}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}} \]
      3. unpow229.4%

        \[\leadsto \frac{c0 \cdot c0}{\color{blue}{D \cdot D}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}} \]
      4. unpow229.4%

        \[\leadsto \frac{c0 \cdot c0}{D \cdot D} \cdot \frac{\color{blue}{d \cdot d}}{h \cdot {w}^{2}} \]
      5. unpow229.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0 \cdot \left(\frac{c0}{D} \cdot \frac{d}{\frac{h}{\color{blue}{\frac{d}{w \cdot w}}}}\right)}{D} \]
    11. Applied egg-rr44.8%

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

        \[\leadsto \color{blue}{\frac{c0}{\frac{D}{\frac{c0}{D} \cdot \frac{d}{\frac{h}{\frac{d}{w \cdot w}}}}}} \]
      2. associate-*r/54.0%

        \[\leadsto \frac{c0}{\frac{D}{\color{blue}{\frac{\frac{c0}{D} \cdot d}{\frac{h}{\frac{d}{w \cdot w}}}}}} \]
      3. unpow254.0%

        \[\leadsto \frac{c0}{\frac{D}{\frac{\frac{c0}{D} \cdot d}{\frac{h}{\frac{d}{\color{blue}{{w}^{2}}}}}}} \]
      4. associate-/r/49.2%

        \[\leadsto \frac{c0}{\frac{D}{\frac{\frac{c0}{D} \cdot d}{\color{blue}{\frac{h}{d} \cdot {w}^{2}}}}} \]
      5. unpow249.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \leq 3.7 \cdot 10^{+56}:\\ \;\;\;\;\frac{c0}{D} \cdot \left(\frac{c0}{D} \cdot \frac{\frac{d \cdot \frac{d}{w}}{w}}{h}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{\frac{D}{\frac{d \cdot \frac{c0}{D}}{\frac{h}{d} \cdot \left(w \cdot w\right)}}}\\ \end{array} \]

Alternative 5: 44.4% accurate, 8.9× speedup?

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

\\
\frac{c0}{D} \cdot \left(\frac{c0}{D} \cdot \frac{d \cdot \frac{\frac{d}{w}}{w}}{h}\right)
\end{array}
Derivation
  1. Initial program 26.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. Simplified27.9%

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

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

      \[\leadsto \color{blue}{\frac{{c0}^{2}}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}}} \]
    2. unpow224.8%

      \[\leadsto \frac{\color{blue}{c0 \cdot c0}}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}} \]
    3. unpow224.8%

      \[\leadsto \frac{c0 \cdot c0}{\color{blue}{D \cdot D}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}} \]
    4. unpow224.8%

      \[\leadsto \frac{c0 \cdot c0}{D \cdot D} \cdot \frac{\color{blue}{d \cdot d}}{h \cdot {w}^{2}} \]
    5. unpow224.8%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{c0}{D} \cdot \left(\frac{c0}{D} \cdot \frac{d \cdot \frac{\frac{d}{w}}{w}}{h}\right)} \]
  10. Final simplification41.7%

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

Alternative 6: 43.8% accurate, 8.9× speedup?

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

\\
\frac{c0}{D} \cdot \left(\frac{c0}{D} \cdot \frac{\frac{d \cdot \frac{d}{w}}{w}}{h}\right)
\end{array}
Derivation
  1. Initial program 26.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. Simplified27.9%

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

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

      \[\leadsto \color{blue}{\frac{{c0}^{2}}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}}} \]
    2. unpow224.8%

      \[\leadsto \frac{\color{blue}{c0 \cdot c0}}{{D}^{2}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}} \]
    3. unpow224.8%

      \[\leadsto \frac{c0 \cdot c0}{\color{blue}{D \cdot D}} \cdot \frac{{d}^{2}}{h \cdot {w}^{2}} \]
    4. unpow224.8%

      \[\leadsto \frac{c0 \cdot c0}{D \cdot D} \cdot \frac{\color{blue}{d \cdot d}}{h \cdot {w}^{2}} \]
    5. unpow224.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 34.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 26.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. Simplified27.9%

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\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. distribute-lft-in3.0%

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

    \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{0} \]
  6. Taylor expanded in c0 around 0 24.0%

    \[\leadsto \color{blue}{0} \]
  7. Final simplification24.0%

    \[\leadsto 0 \]

Reproduce

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