Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.6% → 61.1%
Time: 46.6s
Alternatives: 11
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 11 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.6% 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: 61.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0}{2 \cdot w}\\ t_1 := \frac{c0}{w \cdot h}\\ t_2 := {\left(\frac{d}{D}\right)}^{2}\\ t_3 := t_1 \cdot t_2\\ t_4 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\ t_5 := t_0 \cdot \left(t_4 + \sqrt{t_4 \cdot t_4 - M \cdot M}\right)\\ \mathbf{if}\;t_5 \leq -2 \cdot 10^{-125}:\\ \;\;\;\;t_0 \cdot \left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right)\\ \mathbf{elif}\;t_5 \leq 0:\\ \;\;\;\;t_0 \cdot \frac{M}{\frac{t_3 - \sqrt{{t_3}^{2} - M \cdot M}}{M}}\\ \mathbf{elif}\;t_5 \leq \infty:\\ \;\;\;\;\frac{c0 \cdot \mathsf{fma}\left(t_1, t_2, \sqrt{\mathsf{fma}\left(t_1, t_2, M\right)} \cdot \sqrt{\frac{d}{D} \cdot \left(\frac{c0}{D} \cdot \frac{d}{w \cdot h}\right) - M}\right)}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ c0 (* 2.0 w)))
        (t_1 (/ c0 (* w h)))
        (t_2 (pow (/ d D) 2.0))
        (t_3 (* t_1 t_2))
        (t_4 (/ (* c0 (* d d)) (* (* D D) (* w h))))
        (t_5 (* t_0 (+ t_4 (sqrt (- (* t_4 t_4) (* M M)))))))
   (if (<= t_5 -2e-125)
     (* t_0 (* 2.0 (/ (* c0 (pow d 2.0)) (* (pow D 2.0) (* w h)))))
     (if (<= t_5 0.0)
       (* t_0 (/ M (/ (- t_3 (sqrt (- (pow t_3 2.0) (* M M)))) M)))
       (if (<= t_5 INFINITY)
         (/
          (*
           c0
           (fma
            t_1
            t_2
            (*
             (sqrt (fma t_1 t_2 M))
             (sqrt (- (* (/ d D) (* (/ c0 D) (/ d (* w h)))) M)))))
          (* 2.0 w))
         (/ (* 0.25 (* h (* (* D M) (* D M)))) (* d d)))))))
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 / (w * h);
	double t_2 = pow((d / D), 2.0);
	double t_3 = t_1 * t_2;
	double t_4 = (c0 * (d * d)) / ((D * D) * (w * h));
	double t_5 = t_0 * (t_4 + sqrt(((t_4 * t_4) - (M * M))));
	double tmp;
	if (t_5 <= -2e-125) {
		tmp = t_0 * (2.0 * ((c0 * pow(d, 2.0)) / (pow(D, 2.0) * (w * h))));
	} else if (t_5 <= 0.0) {
		tmp = t_0 * (M / ((t_3 - sqrt((pow(t_3, 2.0) - (M * M)))) / M));
	} else if (t_5 <= ((double) INFINITY)) {
		tmp = (c0 * fma(t_1, t_2, (sqrt(fma(t_1, t_2, M)) * sqrt((((d / D) * ((c0 / D) * (d / (w * h)))) - M))))) / (2.0 * w);
	} else {
		tmp = (0.25 * (h * ((D * M) * (D * M)))) / (d * d);
	}
	return tmp;
}
function code(c0, w, h, D, d, M)
	t_0 = Float64(c0 / Float64(2.0 * w))
	t_1 = Float64(c0 / Float64(w * h))
	t_2 = Float64(d / D) ^ 2.0
	t_3 = Float64(t_1 * t_2)
	t_4 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(D * D) * Float64(w * h)))
	t_5 = Float64(t_0 * Float64(t_4 + sqrt(Float64(Float64(t_4 * t_4) - Float64(M * M)))))
	tmp = 0.0
	if (t_5 <= -2e-125)
		tmp = Float64(t_0 * Float64(2.0 * Float64(Float64(c0 * (d ^ 2.0)) / Float64((D ^ 2.0) * Float64(w * h)))));
	elseif (t_5 <= 0.0)
		tmp = Float64(t_0 * Float64(M / Float64(Float64(t_3 - sqrt(Float64((t_3 ^ 2.0) - Float64(M * M)))) / M)));
	elseif (t_5 <= Inf)
		tmp = Float64(Float64(c0 * fma(t_1, t_2, Float64(sqrt(fma(t_1, t_2, M)) * sqrt(Float64(Float64(Float64(d / D) * Float64(Float64(c0 / D) * Float64(d / Float64(w * h)))) - M))))) / Float64(2.0 * w));
	else
		tmp = Float64(Float64(0.25 * Float64(h * Float64(Float64(D * M) * Float64(D * M)))) / Float64(d * d));
	end
	return 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[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(d / D), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(D * D), $MachinePrecision] * N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$0 * N[(t$95$4 + N[Sqrt[N[(N[(t$95$4 * t$95$4), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, -2e-125], N[(t$95$0 * N[(2.0 * N[(N[(c0 * N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision] / N[(N[Power[D, 2.0], $MachinePrecision] * N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 0.0], N[(t$95$0 * N[(M / N[(N[(t$95$3 - N[Sqrt[N[(N[Power[t$95$3, 2.0], $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, Infinity], N[(N[(c0 * N[(t$95$1 * t$95$2 + N[(N[Sqrt[N[(t$95$1 * t$95$2 + M), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[(N[(d / D), $MachinePrecision] * N[(N[(c0 / D), $MachinePrecision] * N[(d / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision], N[(N[(0.25 * N[(h * N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t_5 \leq 0:\\
\;\;\;\;t_0 \cdot \frac{M}{\frac{t_3 - \sqrt{{t_3}^{2} - M \cdot M}}{M}}\\

\mathbf{elif}\;t_5 \leq \infty:\\
\;\;\;\;\frac{c0 \cdot \mathsf{fma}\left(t_1, t_2, \sqrt{\mathsf{fma}\left(t_1, t_2, M\right)} \cdot \sqrt{\frac{d}{D} \cdot \left(\frac{c0}{D} \cdot \frac{d}{w \cdot h}\right) - M}\right)}{2 \cdot w}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 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))))) < -2.00000000000000002e-125

    1. Initial program 78.3%

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

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

      \[\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)} \]

    if -2.00000000000000002e-125 < (*.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))))) < -0.0

    1. Initial program 52.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. Simplified32.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{\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. flip-+31.5%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\frac{\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) - \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)} \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)}}{\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)}}} \]
    4. Applied egg-rr31.9%

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\frac{0 + M \cdot M}{\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{{\left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2}\right)}^{2} - M \cdot M}}} \]
    7. Step-by-step derivation
      1. div-inv70.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. associate-*l/71.0%

        \[\leadsto \color{blue}{\frac{c0 \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)}{2 \cdot w}} \]
    4. Applied egg-rr77.8%

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

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

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

        \[\leadsto \frac{c0 \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 \sqrt{\mathsf{fma}\left(\frac{d}{D} \cdot \frac{c0}{D}, \color{blue}{\frac{d}{w \cdot h}}, -M\right)}\right)}{w \cdot 2} \]
    6. Applied egg-rr80.2%

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

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

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

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

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

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

    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. Simplified0.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 1.2%

      \[\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) + 0.5 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)}{c0 \cdot {d}^{2}}\right)} \]
    4. Simplified21.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, 0\right)} \]
    5. Taylor expanded in c0 around 0 38.2%

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    6. Step-by-step derivation
      1. associate-*r/38.2%

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

        \[\leadsto \frac{0.25 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2}} \]
      3. unpow238.8%

        \[\leadsto \frac{0.25 \cdot \left(\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot h\right)}{{d}^{2}} \]
      4. unpow238.8%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot h\right)}{{d}^{2}} \]
      5. unswap-sqr49.8%

        \[\leadsto \frac{0.25 \cdot \left(\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot h\right)}{{d}^{2}} \]
      6. unpow249.8%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h\right)}{\color{blue}{d \cdot d}} \]
    7. Simplified49.8%

      \[\leadsto \color{blue}{\frac{0.25 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h\right)}{d \cdot d}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification60.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)} - M \cdot M}\right) \leq -2 \cdot 10^{-125}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right)\\ \mathbf{elif}\;\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 0:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \frac{M}{\frac{\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)}^{2} - M \cdot M}}{M}}\\ \mathbf{elif}\;\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 \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 \sqrt{\frac{d}{D} \cdot \left(\frac{c0}{D} \cdot \frac{d}{w \cdot h}\right) - M}\right)}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d}\\ \end{array} \]

Alternative 2: 60.9% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t_4 \leq 0:\\
\;\;\;\;t_0 \cdot \frac{M}{\frac{t_1 - t_2}{M}}\\

\mathbf{elif}\;t_4 \leq \infty:\\
\;\;\;\;t_0 \cdot t_1 + t_0 \cdot t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 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))))) < -2.00000000000000002e-125

    1. Initial program 78.3%

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

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

      \[\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)} \]

    if -2.00000000000000002e-125 < (*.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))))) < -0.0

    1. Initial program 52.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. Simplified32.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{\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. flip-+31.5%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\frac{\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) - \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)} \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)}}{\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)}}} \]
    4. Applied egg-rr31.9%

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\frac{0 + M \cdot M}{\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{{\left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2}\right)}^{2} - M \cdot M}}} \]
    7. Step-by-step derivation
      1. div-inv70.9%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 75.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. Simplified75.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. Step-by-step derivation
      1. distribute-lft-in75.7%

        \[\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-rr80.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}} \]

    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. Simplified0.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 1.2%

      \[\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) + 0.5 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)}{c0 \cdot {d}^{2}}\right)} \]
    4. Simplified21.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, 0\right)} \]
    5. Taylor expanded in c0 around 0 38.2%

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    6. Step-by-step derivation
      1. associate-*r/38.2%

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

        \[\leadsto \frac{0.25 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2}} \]
      3. unpow238.8%

        \[\leadsto \frac{0.25 \cdot \left(\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot h\right)}{{d}^{2}} \]
      4. unpow238.8%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot h\right)}{{d}^{2}} \]
      5. unswap-sqr49.8%

        \[\leadsto \frac{0.25 \cdot \left(\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot h\right)}{{d}^{2}} \]
      6. unpow249.8%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h\right)}{\color{blue}{d \cdot d}} \]
    7. Simplified49.8%

      \[\leadsto \color{blue}{\frac{0.25 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h\right)}{d \cdot d}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification60.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)} - M \cdot M}\right) \leq -2 \cdot 10^{-125}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{c0 \cdot {d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right)\\ \mathbf{elif}\;\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 0:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \frac{M}{\frac{\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)}^{2} - M \cdot M}}{M}}\\ \mathbf{elif}\;\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(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right) + \frac{c0}{2 \cdot w} \cdot \sqrt{{\left(\frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)}^{2} - M \cdot M}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d}\\ \end{array} \]

Alternative 3: 61.4% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;t_0 \cdot \frac{M}{\frac{t_1 - \sqrt{{t_1}^{2} - M \cdot M}}{M}}\\

\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{c0 \cdot t_4}{2 \cdot w}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 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))))) < -2.00000000000000002e-125

    1. Initial program 78.3%

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

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

      \[\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)} \]

    if -2.00000000000000002e-125 < (*.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))))) < -0.0

    1. Initial program 52.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. Simplified32.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{\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. flip-+31.5%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\frac{\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) - \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)} \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)}}{\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)}}} \]
    4. Applied egg-rr31.9%

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\frac{0 + M \cdot M}{\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} - \sqrt{{\left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2}\right)}^{2} - M \cdot M}}} \]
    7. Step-by-step derivation
      1. div-inv70.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. associate-*l/71.0%

        \[\leadsto \color{blue}{\frac{c0 \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)}{2 \cdot w}} \]
    4. Applied egg-rr77.8%

      \[\leadsto \color{blue}{\frac{c0 \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)}{w \cdot 2}} \]
    5. Taylor expanded in c0 around inf 78.1%

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

    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. Simplified0.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 1.2%

      \[\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) + 0.5 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)}{c0 \cdot {d}^{2}}\right)} \]
    4. Simplified21.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, 0\right)} \]
    5. Taylor expanded in c0 around 0 38.2%

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    6. Step-by-step derivation
      1. associate-*r/38.2%

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

        \[\leadsto \frac{0.25 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2}} \]
      3. unpow238.8%

        \[\leadsto \frac{0.25 \cdot \left(\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot h\right)}{{d}^{2}} \]
      4. unpow238.8%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot h\right)}{{d}^{2}} \]
      5. unswap-sqr49.8%

        \[\leadsto \frac{0.25 \cdot \left(\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot h\right)}{{d}^{2}} \]
      6. unpow249.8%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h\right)}{\color{blue}{d \cdot d}} \]
    7. Simplified49.8%

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

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

Alternative 4: 61.0% accurate, 0.5× speedup?

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

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

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


\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 74.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) \]

    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. Simplified0.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 1.2%

      \[\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) + 0.5 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)}{c0 \cdot {d}^{2}}\right)} \]
    4. Simplified21.3%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, 0\right)} \]
    5. Taylor expanded in c0 around 0 38.2%

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    6. Step-by-step derivation
      1. associate-*r/38.2%

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

        \[\leadsto \frac{0.25 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2}} \]
      3. unpow238.8%

        \[\leadsto \frac{0.25 \cdot \left(\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot h\right)}{{d}^{2}} \]
      4. unpow238.8%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot h\right)}{{d}^{2}} \]
      5. unswap-sqr49.8%

        \[\leadsto \frac{0.25 \cdot \left(\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot h\right)}{{d}^{2}} \]
      6. unpow249.8%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h\right)}{\color{blue}{d \cdot d}} \]
    7. Simplified49.8%

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

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

Alternative 5: 38.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d}\\ t_1 := \left(\frac{c0}{D} \cdot \frac{c0}{D}\right) \cdot \left(d \cdot \frac{d}{h \cdot \left(w \cdot w\right)}\right)\\ \mathbf{if}\;d \leq 5 \cdot 10^{-104}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 3.6 \cdot 10^{-87}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 5.6 \cdot 10^{-42}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w} \cdot \frac{d \cdot d}{h \cdot \left(D \cdot D\right)}\right)\right)\\ \mathbf{elif}\;d \leq 6500000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 3 \cdot 10^{+37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{+65}:\\ \;\;\;\;\mathsf{fma}\left(0.25, \left(D \cdot \left(D \cdot \left(M \cdot \left(h \cdot M\right)\right)\right)\right) \cdot \frac{1}{d \cdot d}, -0.5 \cdot \frac{0 \cdot \left(c0 \cdot c0\right)}{w}\right)\\ \mathbf{elif}\;d \leq 6.8 \cdot 10^{+95} \lor \neg \left(d \leq 3.3 \cdot 10^{+144}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* 0.25 (* h (* (* D M) (* D M)))) (* d d)))
        (t_1 (* (* (/ c0 D) (/ c0 D)) (* d (/ d (* h (* w w)))))))
   (if (<= d 5e-104)
     t_1
     (if (<= d 3.6e-87)
       t_0
       (if (<= d 5.6e-42)
         (* (/ c0 (* 2.0 w)) (* 2.0 (* (/ c0 w) (/ (* d d) (* h (* D D))))))
         (if (<= d 6500000000000.0)
           t_0
           (if (<= d 3e+37)
             t_1
             (if (<= d 1.35e+65)
               (fma
                0.25
                (* (* D (* D (* M (* h M)))) (/ 1.0 (* d d)))
                (* -0.5 (/ (* 0.0 (* c0 c0)) w)))
               (if (or (<= d 6.8e+95) (not (<= d 3.3e+144))) t_1 t_0)))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (0.25 * (h * ((D * M) * (D * M)))) / (d * d);
	double t_1 = ((c0 / D) * (c0 / D)) * (d * (d / (h * (w * w))));
	double tmp;
	if (d <= 5e-104) {
		tmp = t_1;
	} else if (d <= 3.6e-87) {
		tmp = t_0;
	} else if (d <= 5.6e-42) {
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / w) * ((d * d) / (h * (D * D)))));
	} else if (d <= 6500000000000.0) {
		tmp = t_0;
	} else if (d <= 3e+37) {
		tmp = t_1;
	} else if (d <= 1.35e+65) {
		tmp = fma(0.25, ((D * (D * (M * (h * M)))) * (1.0 / (d * d))), (-0.5 * ((0.0 * (c0 * c0)) / w)));
	} else if ((d <= 6.8e+95) || !(d <= 3.3e+144)) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(0.25 * Float64(h * Float64(Float64(D * M) * Float64(D * M)))) / Float64(d * d))
	t_1 = Float64(Float64(Float64(c0 / D) * Float64(c0 / D)) * Float64(d * Float64(d / Float64(h * Float64(w * w)))))
	tmp = 0.0
	if (d <= 5e-104)
		tmp = t_1;
	elseif (d <= 3.6e-87)
		tmp = t_0;
	elseif (d <= 5.6e-42)
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(c0 / w) * Float64(Float64(d * d) / Float64(h * Float64(D * D))))));
	elseif (d <= 6500000000000.0)
		tmp = t_0;
	elseif (d <= 3e+37)
		tmp = t_1;
	elseif (d <= 1.35e+65)
		tmp = fma(0.25, Float64(Float64(D * Float64(D * Float64(M * Float64(h * M)))) * Float64(1.0 / Float64(d * d))), Float64(-0.5 * Float64(Float64(0.0 * Float64(c0 * c0)) / w)));
	elseif ((d <= 6.8e+95) || !(d <= 3.3e+144))
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(0.25 * N[(h * N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c0 / D), $MachinePrecision] * N[(c0 / D), $MachinePrecision]), $MachinePrecision] * N[(d * N[(d / N[(h * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 5e-104], t$95$1, If[LessEqual[d, 3.6e-87], t$95$0, If[LessEqual[d, 5.6e-42], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(c0 / w), $MachinePrecision] * N[(N[(d * d), $MachinePrecision] / N[(h * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6500000000000.0], t$95$0, If[LessEqual[d, 3e+37], t$95$1, If[LessEqual[d, 1.35e+65], N[(0.25 * N[(N[(D * N[(D * N[(M * N[(h * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(N[(0.0 * N[(c0 * c0), $MachinePrecision]), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d, 6.8e+95], N[Not[LessEqual[d, 3.3e+144]], $MachinePrecision]], t$95$1, t$95$0]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d}\\
t_1 := \left(\frac{c0}{D} \cdot \frac{c0}{D}\right) \cdot \left(d \cdot \frac{d}{h \cdot \left(w \cdot w\right)}\right)\\
\mathbf{if}\;d \leq 5 \cdot 10^{-104}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;d \leq 3.6 \cdot 10^{-87}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq 5.6 \cdot 10^{-42}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w} \cdot \frac{d \cdot d}{h \cdot \left(D \cdot D\right)}\right)\right)\\

\mathbf{elif}\;d \leq 6500000000000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq 3 \cdot 10^{+37}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;d \leq 1.35 \cdot 10^{+65}:\\
\;\;\;\;\mathsf{fma}\left(0.25, \left(D \cdot \left(D \cdot \left(M \cdot \left(h \cdot M\right)\right)\right)\right) \cdot \frac{1}{d \cdot d}, -0.5 \cdot \frac{0 \cdot \left(c0 \cdot c0\right)}{w}\right)\\

\mathbf{elif}\;d \leq 6.8 \cdot 10^{+95} \lor \neg \left(d \leq 3.3 \cdot 10^{+144}\right):\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < 4.99999999999999979e-104 or 6.5e12 < d < 3.00000000000000022e37 or 1.35000000000000009e65 < d < 6.80000000000000043e95 or 3.3e144 < d

    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. Simplified26.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 28.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.1%

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

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

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

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

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

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

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

        \[\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. associate-/l*43.7%

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

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

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

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

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

    if 4.99999999999999979e-104 < d < 3.59999999999999993e-87 or 5.59999999999999996e-42 < d < 6.5e12 or 6.80000000000000043e95 < d < 3.3e144

    1. Initial program 16.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. Simplified16.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 10.9%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, 0\right)} \]
    5. Taylor expanded in c0 around 0 53.6%

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    6. Step-by-step derivation
      1. associate-*r/53.6%

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

        \[\leadsto \frac{0.25 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2}} \]
      3. unpow256.9%

        \[\leadsto \frac{0.25 \cdot \left(\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot h\right)}{{d}^{2}} \]
      4. unpow256.9%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot h\right)}{{d}^{2}} \]
      5. unswap-sqr66.4%

        \[\leadsto \frac{0.25 \cdot \left(\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot h\right)}{{d}^{2}} \]
      6. unpow266.4%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h\right)}{\color{blue}{d \cdot d}} \]
    7. Simplified66.4%

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

    if 3.59999999999999993e-87 < d < 5.59999999999999996e-42

    1. Initial program 40.2%

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\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 50.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)} \]
    4. Step-by-step derivation
      1. associate-*r/50.7%

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.00000000000000022e37 < d < 1.35000000000000009e65

    1. Initial program 14.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. Simplified2.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 23.1%

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

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

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

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

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

        \[\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}}, -0.5 \cdot \frac{{c0}^{2} \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{w}\right) \]
      6. unpow223.1%

        \[\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}}, -0.5 \cdot \frac{{c0}^{2} \cdot \left(-1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)} + \frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)}{w}\right) \]
    5. Simplified45.5%

      \[\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}, -0.5 \cdot \frac{\left(c0 \cdot c0\right) \cdot 0}{w}\right)} \]
    6. Step-by-step derivation
      1. div-inv45.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 5 \cdot 10^{-104}:\\ \;\;\;\;\left(\frac{c0}{D} \cdot \frac{c0}{D}\right) \cdot \left(d \cdot \frac{d}{h \cdot \left(w \cdot w\right)}\right)\\ \mathbf{elif}\;d \leq 3.6 \cdot 10^{-87}:\\ \;\;\;\;\frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d}\\ \mathbf{elif}\;d \leq 5.6 \cdot 10^{-42}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w} \cdot \frac{d \cdot d}{h \cdot \left(D \cdot D\right)}\right)\right)\\ \mathbf{elif}\;d \leq 6500000000000:\\ \;\;\;\;\frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d}\\ \mathbf{elif}\;d \leq 3 \cdot 10^{+37}:\\ \;\;\;\;\left(\frac{c0}{D} \cdot \frac{c0}{D}\right) \cdot \left(d \cdot \frac{d}{h \cdot \left(w \cdot w\right)}\right)\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{+65}:\\ \;\;\;\;\mathsf{fma}\left(0.25, \left(D \cdot \left(D \cdot \left(M \cdot \left(h \cdot M\right)\right)\right)\right) \cdot \frac{1}{d \cdot d}, -0.5 \cdot \frac{0 \cdot \left(c0 \cdot c0\right)}{w}\right)\\ \mathbf{elif}\;d \leq 6.8 \cdot 10^{+95} \lor \neg \left(d \leq 3.3 \cdot 10^{+144}\right):\\ \;\;\;\;\left(\frac{c0}{D} \cdot \frac{c0}{D}\right) \cdot \left(d \cdot \frac{d}{h \cdot \left(w \cdot w\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d}\\ \end{array} \]

Alternative 6: 39.6% accurate, 5.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq 3.5 \cdot 10^{-113} \lor \neg \left(d \leq 4.4 \cdot 10^{-87} \lor \neg \left(d \leq 3 \cdot 10^{-37}\right) \land \left(d \leq 1.8 \cdot 10^{+67} \lor \neg \left(d \leq 2.35 \cdot 10^{+95}\right) \land d \leq 1.06 \cdot 10^{+144}\right)\right):\\ \;\;\;\;\left(\frac{c0}{D} \cdot \frac{c0}{D}\right) \cdot \left(d \cdot \frac{d}{h \cdot \left(w \cdot w\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d}\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (or (<= d 3.5e-113)
         (not
          (or (<= d 4.4e-87)
              (and (not (<= d 3e-37))
                   (or (<= d 1.8e+67)
                       (and (not (<= d 2.35e+95)) (<= d 1.06e+144)))))))
   (* (* (/ c0 D) (/ c0 D)) (* d (/ d (* h (* w w)))))
   (/ (* 0.25 (* h (* (* D M) (* D M)))) (* d d))))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if ((d <= 3.5e-113) || !((d <= 4.4e-87) || (!(d <= 3e-37) && ((d <= 1.8e+67) || (!(d <= 2.35e+95) && (d <= 1.06e+144)))))) {
		tmp = ((c0 / D) * (c0 / D)) * (d * (d / (h * (w * w))));
	} else {
		tmp = (0.25 * (h * ((D * M) * (D * M)))) / (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 ((d_1 <= 3.5d-113) .or. (.not. (d_1 <= 4.4d-87) .or. (.not. (d_1 <= 3d-37)) .and. (d_1 <= 1.8d+67) .or. (.not. (d_1 <= 2.35d+95)) .and. (d_1 <= 1.06d+144))) then
        tmp = ((c0 / d) * (c0 / d)) * (d_1 * (d_1 / (h * (w * w))))
    else
        tmp = (0.25d0 * (h * ((d * m) * (d * m)))) / (d_1 * d_1)
    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.5e-113) || !((d <= 4.4e-87) || (!(d <= 3e-37) && ((d <= 1.8e+67) || (!(d <= 2.35e+95) && (d <= 1.06e+144)))))) {
		tmp = ((c0 / D) * (c0 / D)) * (d * (d / (h * (w * w))));
	} else {
		tmp = (0.25 * (h * ((D * M) * (D * M)))) / (d * d);
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if (d <= 3.5e-113) or not ((d <= 4.4e-87) or (not (d <= 3e-37) and ((d <= 1.8e+67) or (not (d <= 2.35e+95) and (d <= 1.06e+144))))):
		tmp = ((c0 / D) * (c0 / D)) * (d * (d / (h * (w * w))))
	else:
		tmp = (0.25 * (h * ((D * M) * (D * M)))) / (d * d)
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if ((d <= 3.5e-113) || !((d <= 4.4e-87) || (!(d <= 3e-37) && ((d <= 1.8e+67) || (!(d <= 2.35e+95) && (d <= 1.06e+144))))))
		tmp = Float64(Float64(Float64(c0 / D) * Float64(c0 / D)) * Float64(d * Float64(d / Float64(h * Float64(w * w)))));
	else
		tmp = Float64(Float64(0.25 * Float64(h * Float64(Float64(D * M) * Float64(D * M)))) / Float64(d * d));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if ((d <= 3.5e-113) || ~(((d <= 4.4e-87) || (~((d <= 3e-37)) && ((d <= 1.8e+67) || (~((d <= 2.35e+95)) && (d <= 1.06e+144)))))))
		tmp = ((c0 / D) * (c0 / D)) * (d * (d / (h * (w * w))));
	else
		tmp = (0.25 * (h * ((D * M) * (D * M)))) / (d * d);
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[d, 3.5e-113], N[Not[Or[LessEqual[d, 4.4e-87], And[N[Not[LessEqual[d, 3e-37]], $MachinePrecision], Or[LessEqual[d, 1.8e+67], And[N[Not[LessEqual[d, 2.35e+95]], $MachinePrecision], LessEqual[d, 1.06e+144]]]]]], $MachinePrecision]], N[(N[(N[(c0 / D), $MachinePrecision] * N[(c0 / D), $MachinePrecision]), $MachinePrecision] * N[(d * N[(d / N[(h * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.25 * N[(h * N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq 3.5 \cdot 10^{-113} \lor \neg \left(d \leq 4.4 \cdot 10^{-87} \lor \neg \left(d \leq 3 \cdot 10^{-37}\right) \land \left(d \leq 1.8 \cdot 10^{+67} \lor \neg \left(d \leq 2.35 \cdot 10^{+95}\right) \land d \leq 1.06 \cdot 10^{+144}\right)\right):\\
\;\;\;\;\left(\frac{c0}{D} \cdot \frac{c0}{D}\right) \cdot \left(d \cdot \frac{d}{h \cdot \left(w \cdot w\right)}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 3.50000000000000029e-113 or 4.39999999999999976e-87 < d < 3e-37 or 1.7999999999999999e67 < d < 2.34999999999999986e95 or 1.06e144 < d

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

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

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

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

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

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

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

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

        \[\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-frac38.1%

        \[\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. associate-/l*42.7%

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

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

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

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

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

    if 3.50000000000000029e-113 < d < 4.39999999999999976e-87 or 3e-37 < d < 1.7999999999999999e67 or 2.34999999999999986e95 < d < 1.06e144

    1. Initial program 18.0%

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

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

      \[\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) + 0.5 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)}{c0 \cdot {d}^{2}}\right)} \]
    4. Simplified39.6%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, 0\right)} \]
    5. Taylor expanded in c0 around 0 48.4%

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    6. Step-by-step derivation
      1. associate-*r/48.4%

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

        \[\leadsto \frac{0.25 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2}} \]
      3. unpow250.6%

        \[\leadsto \frac{0.25 \cdot \left(\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot h\right)}{{d}^{2}} \]
      4. unpow250.6%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot h\right)}{{d}^{2}} \]
      5. unswap-sqr63.4%

        \[\leadsto \frac{0.25 \cdot \left(\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot h\right)}{{d}^{2}} \]
      6. unpow263.4%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h\right)}{\color{blue}{d \cdot d}} \]
    7. Simplified63.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 3.5 \cdot 10^{-113} \lor \neg \left(d \leq 4.4 \cdot 10^{-87} \lor \neg \left(d \leq 3 \cdot 10^{-37}\right) \land \left(d \leq 1.8 \cdot 10^{+67} \lor \neg \left(d \leq 2.35 \cdot 10^{+95}\right) \land d \leq 1.06 \cdot 10^{+144}\right)\right):\\ \;\;\;\;\left(\frac{c0}{D} \cdot \frac{c0}{D}\right) \cdot \left(d \cdot \frac{d}{h \cdot \left(w \cdot w\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d}\\ \end{array} \]

Alternative 7: 39.9% accurate, 5.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d}\\ t_1 := \left(\frac{c0}{D} \cdot \frac{c0}{D}\right) \cdot \left(d \cdot \frac{d}{h \cdot \left(w \cdot w\right)}\right)\\ \mathbf{if}\;d \leq 1.08 \cdot 10^{-109}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 1.92 \cdot 10^{-87}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 4.5 \cdot 10^{-43}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w} \cdot \frac{d \cdot d}{h \cdot \left(D \cdot D\right)}\right)\right)\\ \mathbf{elif}\;d \leq 5 \cdot 10^{+64} \lor \neg \left(d \leq 3.5 \cdot 10^{+95}\right) \land d \leq 1.46 \cdot 10^{+144}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* 0.25 (* h (* (* D M) (* D M)))) (* d d)))
        (t_1 (* (* (/ c0 D) (/ c0 D)) (* d (/ d (* h (* w w)))))))
   (if (<= d 1.08e-109)
     t_1
     (if (<= d 1.92e-87)
       t_0
       (if (<= d 4.5e-43)
         (* (/ c0 (* 2.0 w)) (* 2.0 (* (/ c0 w) (/ (* d d) (* h (* D D))))))
         (if (or (<= d 5e+64) (and (not (<= d 3.5e+95)) (<= d 1.46e+144)))
           t_0
           t_1))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (0.25 * (h * ((D * M) * (D * M)))) / (d * d);
	double t_1 = ((c0 / D) * (c0 / D)) * (d * (d / (h * (w * w))));
	double tmp;
	if (d <= 1.08e-109) {
		tmp = t_1;
	} else if (d <= 1.92e-87) {
		tmp = t_0;
	} else if (d <= 4.5e-43) {
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / w) * ((d * d) / (h * (D * D)))));
	} else if ((d <= 5e+64) || (!(d <= 3.5e+95) && (d <= 1.46e+144))) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (0.25d0 * (h * ((d * m) * (d * m)))) / (d_1 * d_1)
    t_1 = ((c0 / d) * (c0 / d)) * (d_1 * (d_1 / (h * (w * w))))
    if (d_1 <= 1.08d-109) then
        tmp = t_1
    else if (d_1 <= 1.92d-87) then
        tmp = t_0
    else if (d_1 <= 4.5d-43) then
        tmp = (c0 / (2.0d0 * w)) * (2.0d0 * ((c0 / w) * ((d_1 * d_1) / (h * (d * d)))))
    else if ((d_1 <= 5d+64) .or. (.not. (d_1 <= 3.5d+95)) .and. (d_1 <= 1.46d+144)) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (0.25 * (h * ((D * M) * (D * M)))) / (d * d);
	double t_1 = ((c0 / D) * (c0 / D)) * (d * (d / (h * (w * w))));
	double tmp;
	if (d <= 1.08e-109) {
		tmp = t_1;
	} else if (d <= 1.92e-87) {
		tmp = t_0;
	} else if (d <= 4.5e-43) {
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / w) * ((d * d) / (h * (D * D)))));
	} else if ((d <= 5e+64) || (!(d <= 3.5e+95) && (d <= 1.46e+144))) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = (0.25 * (h * ((D * M) * (D * M)))) / (d * d)
	t_1 = ((c0 / D) * (c0 / D)) * (d * (d / (h * (w * w))))
	tmp = 0
	if d <= 1.08e-109:
		tmp = t_1
	elif d <= 1.92e-87:
		tmp = t_0
	elif d <= 4.5e-43:
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / w) * ((d * d) / (h * (D * D)))))
	elif (d <= 5e+64) or (not (d <= 3.5e+95) and (d <= 1.46e+144)):
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(0.25 * Float64(h * Float64(Float64(D * M) * Float64(D * M)))) / Float64(d * d))
	t_1 = Float64(Float64(Float64(c0 / D) * Float64(c0 / D)) * Float64(d * Float64(d / Float64(h * Float64(w * w)))))
	tmp = 0.0
	if (d <= 1.08e-109)
		tmp = t_1;
	elseif (d <= 1.92e-87)
		tmp = t_0;
	elseif (d <= 4.5e-43)
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(c0 / w) * Float64(Float64(d * d) / Float64(h * Float64(D * D))))));
	elseif ((d <= 5e+64) || (!(d <= 3.5e+95) && (d <= 1.46e+144)))
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = (0.25 * (h * ((D * M) * (D * M)))) / (d * d);
	t_1 = ((c0 / D) * (c0 / D)) * (d * (d / (h * (w * w))));
	tmp = 0.0;
	if (d <= 1.08e-109)
		tmp = t_1;
	elseif (d <= 1.92e-87)
		tmp = t_0;
	elseif (d <= 4.5e-43)
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / w) * ((d * d) / (h * (D * D)))));
	elseif ((d <= 5e+64) || (~((d <= 3.5e+95)) && (d <= 1.46e+144)))
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(0.25 * N[(h * N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c0 / D), $MachinePrecision] * N[(c0 / D), $MachinePrecision]), $MachinePrecision] * N[(d * N[(d / N[(h * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, 1.08e-109], t$95$1, If[LessEqual[d, 1.92e-87], t$95$0, If[LessEqual[d, 4.5e-43], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(c0 / w), $MachinePrecision] * N[(N[(d * d), $MachinePrecision] / N[(h * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[d, 5e+64], And[N[Not[LessEqual[d, 3.5e+95]], $MachinePrecision], LessEqual[d, 1.46e+144]]], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq 1.92 \cdot 10^{-87}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq 4.5 \cdot 10^{-43}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w} \cdot \frac{d \cdot d}{h \cdot \left(D \cdot D\right)}\right)\right)\\

\mathbf{elif}\;d \leq 5 \cdot 10^{+64} \lor \neg \left(d \leq 3.5 \cdot 10^{+95}\right) \land d \leq 1.46 \cdot 10^{+144}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < 1.0799999999999999e-109 or 5e64 < d < 3.5e95 or 1.46e144 < d

    1. Initial program 26.9%

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

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

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

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

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

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

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

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

        \[\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-frac37.9%

        \[\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. associate-/l*42.7%

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

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

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

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

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

    if 1.0799999999999999e-109 < d < 1.92e-87 or 4.50000000000000025e-43 < d < 5e64 or 3.5e95 < d < 1.46e144

    1. Initial program 18.0%

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

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

      \[\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) + 0.5 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)}{c0 \cdot {d}^{2}}\right)} \]
    4. Simplified39.6%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, 0\right)} \]
    5. Taylor expanded in c0 around 0 48.4%

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    6. Step-by-step derivation
      1. associate-*r/48.4%

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

        \[\leadsto \frac{0.25 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2}} \]
      3. unpow250.6%

        \[\leadsto \frac{0.25 \cdot \left(\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot h\right)}{{d}^{2}} \]
      4. unpow250.6%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot h\right)}{{d}^{2}} \]
      5. unswap-sqr63.4%

        \[\leadsto \frac{0.25 \cdot \left(\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot h\right)}{{d}^{2}} \]
      6. unpow263.4%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h\right)}{\color{blue}{d \cdot d}} \]
    7. Simplified63.4%

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

    if 1.92e-87 < d < 4.50000000000000025e-43

    1. Initial program 40.2%

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\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 50.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)} \]
    4. Step-by-step derivation
      1. associate-*r/50.7%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 1.08 \cdot 10^{-109}:\\ \;\;\;\;\left(\frac{c0}{D} \cdot \frac{c0}{D}\right) \cdot \left(d \cdot \frac{d}{h \cdot \left(w \cdot w\right)}\right)\\ \mathbf{elif}\;d \leq 1.92 \cdot 10^{-87}:\\ \;\;\;\;\frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d}\\ \mathbf{elif}\;d \leq 4.5 \cdot 10^{-43}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w} \cdot \frac{d \cdot d}{h \cdot \left(D \cdot D\right)}\right)\right)\\ \mathbf{elif}\;d \leq 5 \cdot 10^{+64} \lor \neg \left(d \leq 3.5 \cdot 10^{+95}\right) \land d \leq 1.46 \cdot 10^{+144}:\\ \;\;\;\;\frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{c0}{D} \cdot \frac{c0}{D}\right) \cdot \left(d \cdot \frac{d}{h \cdot \left(w \cdot w\right)}\right)\\ \end{array} \]

Alternative 8: 36.9% accurate, 7.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;D \cdot D \leq 5 \cdot 10^{-317}:\\
\;\;\;\;0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 D D) < 5.00000017e-317

    1. Initial program 26.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. Simplified26.1%

      \[\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.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-neg0.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-in0.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. Simplified32.5%

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

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

    if 5.00000017e-317 < (*.f64 D D)

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, 0\right)} \]
    5. Taylor expanded in c0 around 0 31.9%

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    6. Step-by-step derivation
      1. associate-*r/31.9%

        \[\leadsto \color{blue}{\frac{0.25 \cdot \left({D}^{2} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2}}} \]
      2. unpow231.9%

        \[\leadsto \frac{0.25 \cdot \left(\color{blue}{\left(D \cdot D\right)} \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2}} \]
      3. *-commutative31.9%

        \[\leadsto \frac{0.25 \cdot \left(\left(D \cdot D\right) \cdot \color{blue}{\left(h \cdot {M}^{2}\right)}\right)}{{d}^{2}} \]
      4. unpow231.9%

        \[\leadsto \frac{0.25 \cdot \left(\left(D \cdot D\right) \cdot \left(h \cdot \color{blue}{\left(M \cdot M\right)}\right)\right)}{{d}^{2}} \]
      5. unpow231.9%

        \[\leadsto \frac{0.25 \cdot \left(\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}{\color{blue}{d \cdot d}} \]
    7. Simplified31.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;D \cdot D \leq 5 \cdot 10^{-317}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25 \cdot \left(\left(D \cdot D\right) \cdot \left(h \cdot \left(M \cdot M\right)\right)\right)}{d \cdot d}\\ \end{array} \]

Alternative 9: 41.5% accurate, 7.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 3.7000000000000001e183

    1. Initial program 28.2%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Simplified26.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 5.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) + 0.5 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)}{c0 \cdot {d}^{2}}\right)} \]
    4. Simplified19.6%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, 0\right)} \]
    5. Taylor expanded in c0 around 0 31.9%

      \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
    6. Step-by-step derivation
      1. associate-*r/31.9%

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

        \[\leadsto \frac{0.25 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2}} \]
      3. unpow232.4%

        \[\leadsto \frac{0.25 \cdot \left(\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot h\right)}{{d}^{2}} \]
      4. unpow232.4%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot h\right)}{{d}^{2}} \]
      5. unswap-sqr39.8%

        \[\leadsto \frac{0.25 \cdot \left(\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot h\right)}{{d}^{2}} \]
      6. unpow239.8%

        \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h\right)}{\color{blue}{d \cdot d}} \]
    7. Simplified39.8%

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

    if 3.7000000000000001e183 < 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. Simplified0.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 55.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. associate-*r/55.4%

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

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

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

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

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

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

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

Alternative 10: 42.0% accurate, 10.1× speedup?

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

\\
\frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d}
\end{array}
Derivation
  1. Initial program 25.8%

    \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
  2. Simplified24.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 4.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) + 0.5 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot \left(h \cdot w\right)\right)}{c0 \cdot {d}^{2}}\right)} \]
  4. Simplified18.0%

    \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{D \cdot D}{c0} \cdot \frac{\left(h \cdot w\right) \cdot \left(M \cdot M\right)}{d \cdot d}, 0\right)} \]
  5. Taylor expanded in c0 around 0 29.6%

    \[\leadsto \color{blue}{0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}} \]
  6. Step-by-step derivation
    1. associate-*r/29.6%

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

      \[\leadsto \frac{0.25 \cdot \color{blue}{\left(\left({D}^{2} \cdot {M}^{2}\right) \cdot h\right)}}{{d}^{2}} \]
    3. unpow230.0%

      \[\leadsto \frac{0.25 \cdot \left(\left(\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}\right) \cdot h\right)}{{d}^{2}} \]
    4. unpow230.0%

      \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot h\right)}{{d}^{2}} \]
    5. unswap-sqr37.6%

      \[\leadsto \frac{0.25 \cdot \left(\color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)} \cdot h\right)}{{d}^{2}} \]
    6. unpow237.6%

      \[\leadsto \frac{0.25 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h\right)}{\color{blue}{d \cdot d}} \]
  7. Simplified37.6%

    \[\leadsto \color{blue}{\frac{0.25 \cdot \left(\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right) \cdot h\right)}{d \cdot d}} \]
  8. Final simplification37.6%

    \[\leadsto \frac{0.25 \cdot \left(h \cdot \left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)\right)}{d \cdot d} \]

Alternative 11: 33.4% 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 25.8%

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

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

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

      \[\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. Simplified27.2%

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

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

    \[\leadsto 0 \]

Reproduce

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