Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.8% → 55.0%
Time: 24.1s
Alternatives: 5
Speedup: 151.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 5 alternatives:

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

Initial Program: 24.8% accurate, 1.0× speedup?

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

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

Alternative 1: 55.0% accurate, 0.9× speedup?

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

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

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


\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 76.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. Simplified68.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/68.3%

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

        \[\leadsto \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{\left(c0 \cdot d\right) \cdot \color{blue}{\frac{d}{w \cdot h}}}{D \cdot D} - M\right)}\right) \]
    4. Applied egg-rr68.3%

      \[\leadsto \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(\color{blue}{\frac{\left(c0 \cdot d\right) \cdot \frac{d}{w \cdot h}}{D \cdot D}} - M\right)}\right) \]
    5. Step-by-step derivation
      1. times-frac69.2%

        \[\leadsto \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(\color{blue}{\frac{c0 \cdot d}{D} \cdot \frac{\frac{d}{w \cdot h}}{D}} - M\right)}\right) \]
      2. associate-/l*69.2%

        \[\leadsto \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(\color{blue}{\frac{c0}{\frac{D}{d}}} \cdot \frac{\frac{d}{w \cdot h}}{D} - M\right)}\right) \]
    6. Simplified69.2%

      \[\leadsto \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(\color{blue}{\frac{c0}{\frac{D}{d}} \cdot \frac{\frac{d}{w \cdot h}}{D}} - M\right)}\right) \]
    7. Taylor expanded in c0 around inf 77.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(-c0 \cdot \color{blue}{0}\right) \]
      6. distribute-rgt-neg-in33.2%

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot 0\right)} \]
    6. Taylor expanded in c0 around 0 39.0%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification52.4%

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

Alternative 2: 44.8% accurate, 5.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c0 \leq -1 \cdot 10^{-65} \lor \neg \left(c0 \leq 2.9 \cdot 10^{-232} \lor \neg \left(c0 \leq 4.5 \cdot 10^{-186}\right) \land c0 \leq 1.42 \cdot 10^{-65}\right):\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (or (<= c0 -1e-65)
         (not
          (or (<= c0 2.9e-232) (and (not (<= c0 4.5e-186)) (<= c0 1.42e-65)))))
   (* (/ c0 (* 2.0 w)) (* 2.0 (* (/ c0 (* w h)) (* (/ d D) (/ d D)))))
   0.0))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if ((c0 <= -1e-65) || !((c0 <= 2.9e-232) || (!(c0 <= 4.5e-186) && (c0 <= 1.42e-65)))) {
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) * ((d / D) * (d / D))));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: tmp
    if ((c0 <= (-1d-65)) .or. (.not. (c0 <= 2.9d-232) .or. (.not. (c0 <= 4.5d-186)) .and. (c0 <= 1.42d-65))) then
        tmp = (c0 / (2.0d0 * w)) * (2.0d0 * ((c0 / (w * h)) * ((d_1 / d) * (d_1 / d))))
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if ((c0 <= -1e-65) || !((c0 <= 2.9e-232) || (!(c0 <= 4.5e-186) && (c0 <= 1.42e-65)))) {
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) * ((d / D) * (d / D))));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if (c0 <= -1e-65) or not ((c0 <= 2.9e-232) or (not (c0 <= 4.5e-186) and (c0 <= 1.42e-65))):
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) * ((d / D) * (d / D))))
	else:
		tmp = 0.0
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if ((c0 <= -1e-65) || !((c0 <= 2.9e-232) || (!(c0 <= 4.5e-186) && (c0 <= 1.42e-65))))
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(Float64(c0 / Float64(w * h)) * Float64(Float64(d / D) * Float64(d / D)))));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if ((c0 <= -1e-65) || ~(((c0 <= 2.9e-232) || (~((c0 <= 4.5e-186)) && (c0 <= 1.42e-65)))))
		tmp = (c0 / (2.0 * w)) * (2.0 * ((c0 / (w * h)) * ((d / D) * (d / D))));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[c0, -1e-65], N[Not[Or[LessEqual[c0, 2.9e-232], And[N[Not[LessEqual[c0, 4.5e-186]], $MachinePrecision], LessEqual[c0, 1.42e-65]]]], $MachinePrecision]], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c0 \leq -1 \cdot 10^{-65} \lor \neg \left(c0 \leq 2.9 \cdot 10^{-232} \lor \neg \left(c0 \leq 4.5 \cdot 10^{-186}\right) \land c0 \leq 1.42 \cdot 10^{-65}\right):\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c0 < -9.99999999999999923e-66 or 2.8999999999999999e-232 < c0 < 4.4999999999999998e-186 or 1.41999999999999993e-65 < c0

    1. Initial program 29.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. Simplified37.8%

      \[\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. Taylor expanded in D around 0 9.8%

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{\frac{c0}{h}}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \mathsf{fma}\left(0.5, \frac{w}{d \cdot d} \cdot \frac{h \cdot 0}{c0}, \frac{d \cdot d}{D \cdot D} \cdot \frac{c0}{w \cdot h}\right)\right)} \]
      2. associate-/l/39.3%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{\color{blue}{h \cdot w}} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \mathsf{fma}\left(0.5, \frac{w}{d \cdot d} \cdot \frac{h \cdot 0}{c0}, \frac{d \cdot d}{D \cdot D} \cdot \frac{c0}{w \cdot h}\right)\right) \]
      4. pow239.3%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} + \mathsf{fma}\left(0.5, \color{blue}{\frac{w \cdot \left(h \cdot 0\right)}{\left(d \cdot d\right) \cdot c0}}, \frac{d \cdot d}{D \cdot D} \cdot \frac{c0}{w \cdot h}\right)\right) \]
      6. mul0-rgt39.8%

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} + \mathsf{fma}\left(0.5, \frac{w \cdot \color{blue}{0}}{\left(d \cdot d\right) \cdot c0}, \frac{d \cdot d}{D \cdot D} \cdot \frac{c0}{w \cdot h}\right)\right) \]
      7. *-commutative39.8%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} + \mathsf{fma}\left(0.5, \frac{w \cdot 0}{c0 \cdot \left(d \cdot d\right)}, \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)} \cdot \frac{c0}{w \cdot h}\right)\right) \]
      9. associate-/l/44.5%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} + \mathsf{fma}\left(0.5, \frac{w \cdot 0}{c0 \cdot \left(d \cdot d\right)}, \color{blue}{\frac{\frac{c0}{h}}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right)\right) \]
      11. associate-/l/45.4%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} + \mathsf{fma}\left(0.5, \frac{w \cdot 0}{c0 \cdot \left(d \cdot d\right)}, \frac{c0}{\color{blue}{h \cdot w}} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\right) \]
      13. pow245.4%

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, 0.5 \cdot \frac{\color{blue}{0}}{c0 \cdot \left(d \cdot d\right)} + \frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2}\right) \]
      5. unpow245.4%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, 0.5 \cdot \frac{0}{\color{blue}{{d}^{2} \cdot c0}} + \frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2}\right) \]
      7. div051.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999923e-66 < c0 < 2.8999999999999999e-232 or 4.4999999999999998e-186 < c0 < 1.41999999999999993e-65

    1. Initial program 15.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. Simplified22.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.4%

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(-c0 \cdot \color{blue}{0}\right) \]
      6. distribute-rgt-neg-in52.1%

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot 0\right)} \]
    6. Taylor expanded in c0 around 0 52.1%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification51.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c0 \leq -1 \cdot 10^{-65} \lor \neg \left(c0 \leq 2.9 \cdot 10^{-232} \lor \neg \left(c0 \leq 4.5 \cdot 10^{-186}\right) \land c0 \leq 1.42 \cdot 10^{-65}\right):\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 3: 36.6% accurate, 6.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq 1.48 \cdot 10^{-214}:\\ \;\;\;\;0\\ \mathbf{elif}\;M \leq 4.9 \cdot 10^{-149} \lor \neg \left(M \leq 1.2 \cdot 10^{-27}\right):\\ \;\;\;\;\frac{d}{\frac{D}{d}} \cdot \frac{\frac{c0 \cdot \frac{c0}{h}}{w \cdot w}}{D}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (<= M 1.48e-214)
   0.0
   (if (or (<= M 4.9e-149) (not (<= M 1.2e-27)))
     (* (/ d (/ D d)) (/ (/ (* c0 (/ c0 h)) (* w w)) D))
     0.0)))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (M <= 1.48e-214) {
		tmp = 0.0;
	} else if ((M <= 4.9e-149) || !(M <= 1.2e-27)) {
		tmp = (d / (D / d)) * (((c0 * (c0 / h)) / (w * w)) / D);
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: tmp
    if (m <= 1.48d-214) then
        tmp = 0.0d0
    else if ((m <= 4.9d-149) .or. (.not. (m <= 1.2d-27))) then
        tmp = (d_1 / (d / d_1)) * (((c0 * (c0 / h)) / (w * w)) / d)
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if (M <= 1.48e-214) {
		tmp = 0.0;
	} else if ((M <= 4.9e-149) || !(M <= 1.2e-27)) {
		tmp = (d / (D / d)) * (((c0 * (c0 / h)) / (w * w)) / D);
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if M <= 1.48e-214:
		tmp = 0.0
	elif (M <= 4.9e-149) or not (M <= 1.2e-27):
		tmp = (d / (D / d)) * (((c0 * (c0 / h)) / (w * w)) / D)
	else:
		tmp = 0.0
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if (M <= 1.48e-214)
		tmp = 0.0;
	elseif ((M <= 4.9e-149) || !(M <= 1.2e-27))
		tmp = Float64(Float64(d / Float64(D / d)) * Float64(Float64(Float64(c0 * Float64(c0 / h)) / Float64(w * w)) / D));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if (M <= 1.48e-214)
		tmp = 0.0;
	elseif ((M <= 4.9e-149) || ~((M <= 1.2e-27)))
		tmp = (d / (D / d)) * (((c0 * (c0 / h)) / (w * w)) / D);
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[LessEqual[M, 1.48e-214], 0.0, If[Or[LessEqual[M, 4.9e-149], N[Not[LessEqual[M, 1.2e-27]], $MachinePrecision]], N[(N[(d / N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(c0 * N[(c0 / h), $MachinePrecision]), $MachinePrecision] / N[(w * w), $MachinePrecision]), $MachinePrecision] / D), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}

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

\mathbf{elif}\;M \leq 4.9 \cdot 10^{-149} \lor \neg \left(M \leq 1.2 \cdot 10^{-27}\right):\\
\;\;\;\;\frac{d}{\frac{D}{d}} \cdot \frac{\frac{c0 \cdot \frac{c0}{h}}{w \cdot w}}{D}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < 1.48000000000000004e-214 or 4.9000000000000004e-149 < M < 1.20000000000000001e-27

    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. Simplified29.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 6.4%

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(-c0 \cdot \color{blue}{0}\right) \]
      6. distribute-rgt-neg-in31.3%

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

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

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

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

    if 1.48000000000000004e-214 < M < 4.9000000000000004e-149 or 1.20000000000000001e-27 < M

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

      \[\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. Taylor expanded in D around 0 7.4%

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{\frac{c0}{h}}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \mathsf{fma}\left(0.5, \frac{w}{d \cdot d} \cdot \frac{h \cdot 0}{c0}, \frac{d \cdot d}{D \cdot D} \cdot \frac{c0}{w \cdot h}\right)\right)} \]
      2. associate-/l/31.9%

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} + \mathsf{fma}\left(0.5, \frac{w \cdot 0}{c0 \cdot \left(d \cdot d\right)}, \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)} \cdot \frac{c0}{w \cdot h}\right)\right) \]
      9. associate-/l/36.9%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} + \mathsf{fma}\left(0.5, \frac{w \cdot 0}{c0 \cdot \left(d \cdot d\right)}, \color{blue}{\frac{\frac{c0}{h}}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right)\right) \]
      11. associate-/l/37.0%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} + \mathsf{fma}\left(0.5, \frac{w \cdot 0}{c0 \cdot \left(d \cdot d\right)}, \frac{c0}{\color{blue}{h \cdot w}} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\right) \]
      13. pow237.0%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} + \mathsf{fma}\left(0.5, \frac{w \cdot 0}{c0 \cdot \left(d \cdot d\right)}, \frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right)} \]
    8. Step-by-step derivation
      1. fma-def37.0%

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, 0.5 \cdot \frac{0}{\color{blue}{{d}^{2} \cdot c0}} + \frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2}\right) \]
      7. div046.2%

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, 0 + \frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)} \]
    10. Taylor expanded in c0 around 0 28.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{d \cdot d}}{D} \cdot \frac{\frac{c0}{h} \cdot \frac{c0}{w \cdot w}}{D} \]
      4. associate-/l*41.9%

        \[\leadsto \color{blue}{\frac{d}{\frac{D}{d}}} \cdot \frac{\frac{c0}{h} \cdot \frac{c0}{w \cdot w}}{D} \]
      5. unpow241.9%

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

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

        \[\leadsto \frac{d}{\frac{D}{d}} \cdot \frac{\frac{\frac{c0}{h} \cdot c0}{\color{blue}{w \cdot w}}}{D} \]
    16. Simplified40.5%

      \[\leadsto \color{blue}{\frac{d}{\frac{D}{d}} \cdot \frac{\frac{\frac{c0}{h} \cdot c0}{w \cdot w}}{D}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification37.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq 1.48 \cdot 10^{-214}:\\ \;\;\;\;0\\ \mathbf{elif}\;M \leq 4.9 \cdot 10^{-149} \lor \neg \left(M \leq 1.2 \cdot 10^{-27}\right):\\ \;\;\;\;\frac{d}{\frac{D}{d}} \cdot \frac{\frac{c0 \cdot \frac{c0}{h}}{w \cdot w}}{D}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 4: 40.7% accurate, 7.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c0 \leq -2.1 \cdot 10^{-65} \lor \neg \left(c0 \leq 5.4 \cdot 10^{-53}\right):\\ \;\;\;\;\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0 \cdot c0}{h \cdot \left(w \cdot w\right)}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (if (or (<= c0 -2.1e-65) (not (<= c0 5.4e-53)))
   (* (* (/ d D) (/ d D)) (/ (* c0 c0) (* h (* w w))))
   0.0))
double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if ((c0 <= -2.1e-65) || !(c0 <= 5.4e-53)) {
		tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w)));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(c0, w, h, d, d_1, m)
    real(8), intent (in) :: c0
    real(8), intent (in) :: w
    real(8), intent (in) :: h
    real(8), intent (in) :: d
    real(8), intent (in) :: d_1
    real(8), intent (in) :: m
    real(8) :: tmp
    if ((c0 <= (-2.1d-65)) .or. (.not. (c0 <= 5.4d-53))) then
        tmp = ((d_1 / d) * (d_1 / d)) * ((c0 * c0) / (h * (w * w)))
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double c0, double w, double h, double D, double d, double M) {
	double tmp;
	if ((c0 <= -2.1e-65) || !(c0 <= 5.4e-53)) {
		tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w)));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	tmp = 0
	if (c0 <= -2.1e-65) or not (c0 <= 5.4e-53):
		tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w)))
	else:
		tmp = 0.0
	return tmp
function code(c0, w, h, D, d, M)
	tmp = 0.0
	if ((c0 <= -2.1e-65) || !(c0 <= 5.4e-53))
		tmp = Float64(Float64(Float64(d / D) * Float64(d / D)) * Float64(Float64(c0 * c0) / Float64(h * Float64(w * w))));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	tmp = 0.0;
	if ((c0 <= -2.1e-65) || ~((c0 <= 5.4e-53)))
		tmp = ((d / D) * (d / D)) * ((c0 * c0) / (h * (w * w)));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := If[Or[LessEqual[c0, -2.1e-65], N[Not[LessEqual[c0, 5.4e-53]], $MachinePrecision]], N[(N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(N[(c0 * c0), $MachinePrecision] / N[(h * N[(w * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c0 \leq -2.1 \cdot 10^{-65} \lor \neg \left(c0 \leq 5.4 \cdot 10^{-53}\right):\\
\;\;\;\;\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0 \cdot c0}{h \cdot \left(w \cdot w\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c0 < -2.10000000000000003e-65 or 5.3999999999999998e-53 < c0

    1. Initial program 29.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. Simplified38.2%

      \[\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. Taylor expanded in D around 0 10.3%

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{\frac{c0}{h}}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \mathsf{fma}\left(0.5, \frac{w}{d \cdot d} \cdot \frac{h \cdot 0}{c0}, \frac{d \cdot d}{D \cdot D} \cdot \frac{c0}{w \cdot h}\right)\right)} \]
      2. associate-/l/39.9%

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} + \mathsf{fma}\left(0.5, \color{blue}{\frac{w \cdot \left(h \cdot 0\right)}{\left(d \cdot d\right) \cdot c0}}, \frac{d \cdot d}{D \cdot D} \cdot \frac{c0}{w \cdot h}\right)\right) \]
      6. mul0-rgt40.4%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} + \mathsf{fma}\left(0.5, \frac{w \cdot 0}{c0 \cdot \left(d \cdot d\right)}, \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)} \cdot \frac{c0}{w \cdot h}\right)\right) \]
      9. associate-/l/44.9%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} + \mathsf{fma}\left(0.5, \frac{w \cdot 0}{c0 \cdot \left(d \cdot d\right)}, \color{blue}{\frac{\frac{c0}{h}}{w} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right)\right) \]
      11. associate-/l/45.3%

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} + \mathsf{fma}\left(0.5, \frac{w \cdot 0}{c0 \cdot \left(d \cdot d\right)}, \frac{c0}{\color{blue}{h \cdot w}} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\right) \]
      13. pow245.3%

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2} + \mathsf{fma}\left(0.5, \frac{w \cdot 0}{c0 \cdot \left(d \cdot d\right)}, \frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2}\right)\right)} \]
    8. Step-by-step derivation
      1. fma-def45.3%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, \color{blue}{0.5 \cdot \frac{w \cdot 0}{c0 \cdot \left(d \cdot d\right)} + \frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2}}\right) \]
      4. mul0-rgt45.3%

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, 0.5 \cdot \frac{0}{\color{blue}{{d}^{2} \cdot c0}} + \frac{c0}{h \cdot w} \cdot {\left(\frac{d}{D}\right)}^{2}\right) \]
      7. div050.2%

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, 0 + \frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\right)} \]
    10. Taylor expanded in c0 around 0 34.1%

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

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

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

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

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

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

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

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

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

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

    if -2.10000000000000003e-65 < c0 < 5.3999999999999998e-53

    1. Initial program 16.7%

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(-c0 \cdot \color{blue}{0}\right) \]
      6. distribute-rgt-neg-in47.1%

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot 0\right)} \]
    6. Taylor expanded in c0 around 0 47.1%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification43.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c0 \leq -2.1 \cdot 10^{-65} \lor \neg \left(c0 \leq 5.4 \cdot 10^{-53}\right):\\ \;\;\;\;\left(\frac{d}{D} \cdot \frac{d}{D}\right) \cdot \frac{c0 \cdot c0}{h \cdot \left(w \cdot w\right)}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 5: 33.6% accurate, 151.0× speedup?

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

\\
0
\end{array}
Derivation
  1. Initial program 26.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. Simplified27.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(\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot c0\right)\right)} \]
  4. Step-by-step derivation
    1. mul-1-neg4.6%

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(-c0 \cdot \color{blue}{0}\right) \]
    6. distribute-rgt-neg-in26.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot \left(-0\right)\right)} \]
    7. metadata-eval26.4%

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

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

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

    \[\leadsto 0 \]

Reproduce

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