Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.4% → 56.2%
Time: 20.4s
Alternatives: 4
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 4 alternatives:

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

Initial Program: 24.4% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 78.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. Add Preprocessing
    3. Taylor expanded in c0 around inf

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

        \[\leadsto \mathsf{/.f64}\left(\left({c0}^{2} \cdot {d}^{2}\right), \color{blue}{\left({D}^{2} \cdot \left(h \cdot {w}^{2}\right)\right)}\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\left({d}^{2} \cdot {c0}^{2}\right), \left(\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left({d}^{2}\right), \left({c0}^{2}\right)\right), \left(\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(d \cdot d\right), \left({c0}^{2}\right)\right), \left({\color{blue}{D}}^{2} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \left({c0}^{2}\right)\right), \left({\color{blue}{D}}^{2} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      6. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \left(c0 \cdot c0\right)\right), \left({D}^{\color{blue}{2}} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \left({D}^{\color{blue}{2}} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\left({D}^{2}\right), \color{blue}{\left(h \cdot {w}^{2}\right)}\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\left(D \cdot D\right), \left(\color{blue}{h} \cdot {w}^{2}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(D, D\right), \left(\color{blue}{h} \cdot {w}^{2}\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(D, D\right), \mathsf{*.f64}\left(h, \color{blue}{\left({w}^{2}\right)}\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(D, D\right), \mathsf{*.f64}\left(h, \left(w \cdot \color{blue}{w}\right)\right)\right)\right) \]
      13. *-lowering-*.f6461.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(D, D\right), \mathsf{*.f64}\left(h, \mathsf{*.f64}\left(w, \color{blue}{w}\right)\right)\right)\right) \]
    5. Simplified61.4%

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

        \[\leadsto \frac{\left(c0 \cdot c0\right) \cdot \left(d \cdot d\right)}{\color{blue}{\left(D \cdot D\right)} \cdot \left(h \cdot \left(w \cdot w\right)\right)} \]
      2. swap-sqrN/A

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

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

        \[\leadsto \frac{\left(c0 \cdot d\right) \cdot \left(c0 \cdot d\right)}{\left(h \cdot \left(D \cdot D\right)\right) \cdot \left(\color{blue}{w} \cdot w\right)} \]
      5. frac-timesN/A

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

        \[\leadsto \frac{c0 \cdot d}{\left(h \cdot D\right) \cdot D} \cdot \frac{c0 \cdot \color{blue}{d}}{w \cdot w} \]
      7. frac-timesN/A

        \[\leadsto \left(\frac{c0}{h \cdot D} \cdot \frac{d}{D}\right) \cdot \frac{\color{blue}{c0 \cdot d}}{w \cdot w} \]
      8. *-commutativeN/A

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

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

        \[\leadsto \frac{\frac{c0 \cdot d}{w}}{w} \cdot \frac{c0 \cdot \frac{d}{D}}{\color{blue}{h \cdot D}} \]
      11. frac-timesN/A

        \[\leadsto \frac{\frac{c0 \cdot d}{w} \cdot \left(c0 \cdot \frac{d}{D}\right)}{\color{blue}{w \cdot \left(h \cdot D\right)}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\frac{c0 \cdot d}{w} \cdot \left(c0 \cdot \frac{d}{D}\right)}{\left(h \cdot D\right) \cdot \color{blue}{w}} \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{c0 \cdot d}{w} \cdot \left(c0 \cdot \frac{d}{D}\right)\right), \color{blue}{\left(\left(h \cdot D\right) \cdot w\right)}\right) \]
    7. Applied egg-rr84.8%

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

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

    1. Initial program 0.0%

      \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in c0 around -inf

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \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)}\right) \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(-1 \cdot c0\right) \cdot \color{blue}{\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) \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(\color{blue}{-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) \]
      3. distribute-lft1-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(\left(-1 + 1\right) \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)\right)\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(0 \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right)\right) \]
      5. mul0-lftN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot 0\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(-1 + \color{blue}{1}\right)\right)\right) \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\mathsf{neg}\left(c0 \cdot \left(-1 + 1\right)\right)\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot \color{blue}{\left(\mathsf{neg}\left(\left(-1 + 1\right)\right)\right)}\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot \left(\mathsf{neg}\left(0\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot 0\right)\right) \]
      11. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot \left(-1 + \color{blue}{1}\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \mathsf{*.f64}\left(c0, \color{blue}{\left(-1 + 1\right)}\right)\right) \]
      13. metadata-eval40.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \mathsf{*.f64}\left(c0, 0\right)\right) \]
    5. Simplified40.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot 0\right)} \]
    6. Step-by-step derivation
      1. mul0-rgtN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot 0 \]
      2. mul0-rgt46.0%

        \[\leadsto 0 \]
    7. Applied egg-rr46.0%

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

Alternative 2: 43.6% accurate, 4.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0}{w} \cdot \frac{\frac{d}{w}}{\frac{\frac{D}{\frac{c0}{h}}}{\frac{d}{D}}}\\ \mathbf{if}\;c0 \leq -1.7 \cdot 10^{-66}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c0 \leq 3.8 \cdot 10^{-150}:\\ \;\;\;\;0\\ \mathbf{elif}\;c0 \leq 8.2 \cdot 10^{+220}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (* (/ c0 w) (/ (/ d w) (/ (/ D (/ c0 h)) (/ d D))))))
   (if (<= c0 -1.7e-66)
     t_0
     (if (<= c0 3.8e-150) 0.0 (if (<= c0 8.2e+220) t_0 0.0)))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (c0 / w) * ((d / w) / ((D / (c0 / h)) / (d / D)));
	double tmp;
	if (c0 <= -1.7e-66) {
		tmp = t_0;
	} else if (c0 <= 3.8e-150) {
		tmp = 0.0;
	} else if (c0 <= 8.2e+220) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = (c0 / w) * ((d_1 / w) / ((d / (c0 / h)) / (d_1 / d)))
    if (c0 <= (-1.7d-66)) then
        tmp = t_0
    else if (c0 <= 3.8d-150) then
        tmp = 0.0d0
    else if (c0 <= 8.2d+220) then
        tmp = t_0
    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 t_0 = (c0 / w) * ((d / w) / ((D / (c0 / h)) / (d / D)));
	double tmp;
	if (c0 <= -1.7e-66) {
		tmp = t_0;
	} else if (c0 <= 3.8e-150) {
		tmp = 0.0;
	} else if (c0 <= 8.2e+220) {
		tmp = t_0;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = (c0 / w) * ((d / w) / ((D / (c0 / h)) / (d / D)))
	tmp = 0
	if c0 <= -1.7e-66:
		tmp = t_0
	elif c0 <= 3.8e-150:
		tmp = 0.0
	elif c0 <= 8.2e+220:
		tmp = t_0
	else:
		tmp = 0.0
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(c0 / w) * Float64(Float64(d / w) / Float64(Float64(D / Float64(c0 / h)) / Float64(d / D))))
	tmp = 0.0
	if (c0 <= -1.7e-66)
		tmp = t_0;
	elseif (c0 <= 3.8e-150)
		tmp = 0.0;
	elseif (c0 <= 8.2e+220)
		tmp = t_0;
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = (c0 / w) * ((d / w) / ((D / (c0 / h)) / (d / D)));
	tmp = 0.0;
	if (c0 <= -1.7e-66)
		tmp = t_0;
	elseif (c0 <= 3.8e-150)
		tmp = 0.0;
	elseif (c0 <= 8.2e+220)
		tmp = t_0;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(c0 / w), $MachinePrecision] * N[(N[(d / w), $MachinePrecision] / N[(N[(D / N[(c0 / h), $MachinePrecision]), $MachinePrecision] / N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c0, -1.7e-66], t$95$0, If[LessEqual[c0, 3.8e-150], 0.0, If[LessEqual[c0, 8.2e+220], t$95$0, 0.0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{c0}{w} \cdot \frac{\frac{d}{w}}{\frac{\frac{D}{\frac{c0}{h}}}{\frac{d}{D}}}\\
\mathbf{if}\;c0 \leq -1.7 \cdot 10^{-66}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;c0 \leq 3.8 \cdot 10^{-150}:\\
\;\;\;\;0\\

\mathbf{elif}\;c0 \leq 8.2 \cdot 10^{+220}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c0 < -1.69999999999999999e-66 or 3.7999999999999998e-150 < c0 < 8.19999999999999962e220

    1. Initial program 29.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. Add Preprocessing
    3. Taylor expanded in c0 around inf

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

        \[\leadsto \mathsf{/.f64}\left(\left({c0}^{2} \cdot {d}^{2}\right), \color{blue}{\left({D}^{2} \cdot \left(h \cdot {w}^{2}\right)\right)}\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\left({d}^{2} \cdot {c0}^{2}\right), \left(\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left({d}^{2}\right), \left({c0}^{2}\right)\right), \left(\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(d \cdot d\right), \left({c0}^{2}\right)\right), \left({\color{blue}{D}}^{2} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \left({c0}^{2}\right)\right), \left({\color{blue}{D}}^{2} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      6. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \left(c0 \cdot c0\right)\right), \left({D}^{\color{blue}{2}} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \left({D}^{\color{blue}{2}} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\left({D}^{2}\right), \color{blue}{\left(h \cdot {w}^{2}\right)}\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\left(D \cdot D\right), \left(\color{blue}{h} \cdot {w}^{2}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(D, D\right), \left(\color{blue}{h} \cdot {w}^{2}\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(D, D\right), \mathsf{*.f64}\left(h, \color{blue}{\left({w}^{2}\right)}\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(D, D\right), \mathsf{*.f64}\left(h, \left(w \cdot \color{blue}{w}\right)\right)\right)\right) \]
      13. *-lowering-*.f6437.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(D, D\right), \mathsf{*.f64}\left(h, \mathsf{*.f64}\left(w, \color{blue}{w}\right)\right)\right)\right) \]
    5. Simplified37.5%

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

        \[\leadsto \frac{\left(c0 \cdot c0\right) \cdot \left(d \cdot d\right)}{\color{blue}{\left(D \cdot D\right)} \cdot \left(h \cdot \left(w \cdot w\right)\right)} \]
      2. swap-sqrN/A

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

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

        \[\leadsto \frac{\left(c0 \cdot d\right) \cdot \left(c0 \cdot d\right)}{\left(h \cdot \left(D \cdot D\right)\right) \cdot \left(\color{blue}{w} \cdot w\right)} \]
      5. frac-timesN/A

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

        \[\leadsto \frac{c0 \cdot d}{\left(h \cdot D\right) \cdot D} \cdot \frac{c0 \cdot \color{blue}{d}}{w \cdot w} \]
      7. frac-timesN/A

        \[\leadsto \left(\frac{c0}{h \cdot D} \cdot \frac{d}{D}\right) \cdot \frac{\color{blue}{c0 \cdot d}}{w \cdot w} \]
      8. *-commutativeN/A

        \[\leadsto \frac{c0 \cdot d}{w \cdot w} \cdot \color{blue}{\left(\frac{c0}{h \cdot D} \cdot \frac{d}{D}\right)} \]
      9. times-fracN/A

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

        \[\leadsto \frac{c0}{w} \cdot \color{blue}{\left(\frac{d}{w} \cdot \left(\frac{c0}{h \cdot D} \cdot \frac{d}{D}\right)\right)} \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{c0}{w}\right), \color{blue}{\left(\frac{d}{w} \cdot \left(\frac{c0}{h \cdot D} \cdot \frac{d}{D}\right)\right)}\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, w\right), \left(\color{blue}{\frac{d}{w}} \cdot \left(\frac{c0}{h \cdot D} \cdot \frac{d}{D}\right)\right)\right) \]
      13. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, w\right), \left(\frac{d}{w} \cdot \left(\frac{1}{\frac{h \cdot D}{c0}} \cdot \frac{\color{blue}{d}}{D}\right)\right)\right) \]
      14. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, w\right), \left(\frac{d}{w} \cdot \left(\frac{1}{\frac{h \cdot D}{c0}} \cdot \frac{1}{\color{blue}{\frac{D}{d}}}\right)\right)\right) \]
      15. frac-timesN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, w\right), \left(\frac{d}{w} \cdot \frac{1 \cdot 1}{\color{blue}{\frac{h \cdot D}{c0} \cdot \frac{D}{d}}}\right)\right) \]
      16. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, w\right), \left(\frac{d}{w} \cdot \frac{1}{\color{blue}{\frac{h \cdot D}{c0}} \cdot \frac{D}{d}}\right)\right) \]
      17. un-div-invN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, w\right), \left(\frac{\frac{d}{w}}{\color{blue}{\frac{h \cdot D}{c0} \cdot \frac{D}{d}}}\right)\right) \]
      18. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, w\right), \mathsf{/.f64}\left(\left(\frac{d}{w}\right), \color{blue}{\left(\frac{h \cdot D}{c0} \cdot \frac{D}{d}\right)}\right)\right) \]
    7. Applied egg-rr54.7%

      \[\leadsto \color{blue}{\frac{c0}{w} \cdot \frac{\frac{d}{w}}{\frac{\frac{D}{\frac{c0}{h}}}{\frac{d}{D}}}} \]

    if -1.69999999999999999e-66 < c0 < 3.7999999999999998e-150 or 8.19999999999999962e220 < c0

    1. Initial program 15.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. Add Preprocessing
    3. Taylor expanded in c0 around -inf

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \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)}\right) \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(-1 \cdot c0\right) \cdot \color{blue}{\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) \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(\color{blue}{-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) \]
      3. distribute-lft1-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(\left(-1 + 1\right) \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)\right)\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(0 \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right)\right) \]
      5. mul0-lftN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot 0\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(-1 + \color{blue}{1}\right)\right)\right) \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\mathsf{neg}\left(c0 \cdot \left(-1 + 1\right)\right)\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot \color{blue}{\left(\mathsf{neg}\left(\left(-1 + 1\right)\right)\right)}\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot \left(\mathsf{neg}\left(0\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot 0\right)\right) \]
      11. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot \left(-1 + \color{blue}{1}\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \mathsf{*.f64}\left(c0, \color{blue}{\left(-1 + 1\right)}\right)\right) \]
      13. metadata-eval48.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \mathsf{*.f64}\left(c0, 0\right)\right) \]
    5. Simplified48.4%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot 0\right)} \]
    6. Step-by-step derivation
      1. mul0-rgtN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot 0 \]
      2. mul0-rgt53.8%

        \[\leadsto 0 \]
    7. Applied egg-rr53.8%

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

Alternative 3: 38.6% accurate, 6.9× speedup?

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

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

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


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

    1. Initial program 25.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. Add Preprocessing
    3. Taylor expanded in c0 around -inf

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \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)}\right) \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(-1 \cdot c0\right) \cdot \color{blue}{\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) \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(\color{blue}{-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) \]
      3. distribute-lft1-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(\left(-1 + 1\right) \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)\right)\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(0 \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right)\right) \]
      5. mul0-lftN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot 0\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(-1 + \color{blue}{1}\right)\right)\right) \]
      7. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\mathsf{neg}\left(c0 \cdot \left(-1 + 1\right)\right)\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot \color{blue}{\left(\mathsf{neg}\left(\left(-1 + 1\right)\right)\right)}\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot \left(\mathsf{neg}\left(0\right)\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot 0\right)\right) \]
      11. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot \left(-1 + \color{blue}{1}\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \mathsf{*.f64}\left(c0, \color{blue}{\left(-1 + 1\right)}\right)\right) \]
      13. metadata-eval33.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \mathsf{*.f64}\left(c0, 0\right)\right) \]
    5. Simplified33.1%

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot 0\right)} \]
    6. Step-by-step derivation
      1. mul0-rgtN/A

        \[\leadsto \frac{c0}{2 \cdot w} \cdot 0 \]
      2. mul0-rgt38.1%

        \[\leadsto 0 \]
    7. Applied egg-rr38.1%

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

    if 9.5000000000000008e-31 < M

    1. Initial program 22.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. Add Preprocessing
    3. Taylor expanded in c0 around inf

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

        \[\leadsto \mathsf{/.f64}\left(\left({c0}^{2} \cdot {d}^{2}\right), \color{blue}{\left({D}^{2} \cdot \left(h \cdot {w}^{2}\right)\right)}\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\left({d}^{2} \cdot {c0}^{2}\right), \left(\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left({d}^{2}\right), \left({c0}^{2}\right)\right), \left(\color{blue}{{D}^{2}} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(d \cdot d\right), \left({c0}^{2}\right)\right), \left({\color{blue}{D}}^{2} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \left({c0}^{2}\right)\right), \left({\color{blue}{D}}^{2} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      6. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \left(c0 \cdot c0\right)\right), \left({D}^{\color{blue}{2}} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \left({D}^{\color{blue}{2}} \cdot \left(h \cdot {w}^{2}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\left({D}^{2}\right), \color{blue}{\left(h \cdot {w}^{2}\right)}\right)\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\left(D \cdot D\right), \left(\color{blue}{h} \cdot {w}^{2}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(D, D\right), \left(\color{blue}{h} \cdot {w}^{2}\right)\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(D, D\right), \mathsf{*.f64}\left(h, \color{blue}{\left({w}^{2}\right)}\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(D, D\right), \mathsf{*.f64}\left(h, \left(w \cdot \color{blue}{w}\right)\right)\right)\right) \]
      13. *-lowering-*.f6438.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(d, d\right), \mathsf{*.f64}\left(c0, c0\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(D, D\right), \mathsf{*.f64}\left(h, \mathsf{*.f64}\left(w, \color{blue}{w}\right)\right)\right)\right) \]
    5. Simplified38.5%

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

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

        \[\leadsto \frac{\left(c0 \cdot c0\right) \cdot \left(d \cdot d\right)}{\color{blue}{\left(h \cdot \left(w \cdot w\right)\right)} \cdot \left(D \cdot D\right)} \]
      3. swap-sqrN/A

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

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

        \[\leadsto \frac{\left(c0 \cdot d\right) \cdot \left(c0 \cdot d\right)}{\left(w \cdot w\right) \cdot \color{blue}{\left(h \cdot \left(D \cdot D\right)\right)}} \]
      6. frac-timesN/A

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

        \[\leadsto \frac{\frac{c0 \cdot d}{w}}{w} \cdot \frac{\color{blue}{c0 \cdot d}}{h \cdot \left(D \cdot D\right)} \]
      8. frac-timesN/A

        \[\leadsto \frac{\frac{c0 \cdot d}{w} \cdot \left(c0 \cdot d\right)}{\color{blue}{w \cdot \left(h \cdot \left(D \cdot D\right)\right)}} \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{c0 \cdot d}{w} \cdot \left(c0 \cdot d\right)\right), \color{blue}{\left(w \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)}\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\frac{c0 \cdot d}{w}\right), \left(c0 \cdot d\right)\right), \left(\color{blue}{w} \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)\right) \]
      11. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(c0 \cdot \frac{d}{w}\right), \left(c0 \cdot d\right)\right), \left(w \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)\right) \]
      12. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(c0 \cdot \frac{1}{\frac{w}{d}}\right), \left(c0 \cdot d\right)\right), \left(w \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)\right) \]
      13. un-div-invN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\frac{c0}{\frac{w}{d}}\right), \left(c0 \cdot d\right)\right), \left(w \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)\right) \]
      14. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \left(\frac{w}{d}\right)\right), \left(c0 \cdot d\right)\right), \left(w \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)\right) \]
      15. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{/.f64}\left(w, d\right)\right), \left(c0 \cdot d\right)\right), \left(w \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{/.f64}\left(w, d\right)\right), \mathsf{*.f64}\left(c0, d\right)\right), \left(w \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)\right) \]
      17. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{/.f64}\left(w, d\right)\right), \mathsf{*.f64}\left(c0, d\right)\right), \mathsf{*.f64}\left(w, \color{blue}{\left(h \cdot \left(D \cdot D\right)\right)}\right)\right) \]
      18. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{/.f64}\left(w, d\right)\right), \mathsf{*.f64}\left(c0, d\right)\right), \mathsf{*.f64}\left(w, \left(\left(h \cdot D\right) \cdot \color{blue}{D}\right)\right)\right) \]
      19. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{/.f64}\left(w, d\right)\right), \mathsf{*.f64}\left(c0, d\right)\right), \mathsf{*.f64}\left(w, \left(D \cdot \color{blue}{\left(h \cdot D\right)}\right)\right)\right) \]
      20. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{/.f64}\left(w, d\right)\right), \mathsf{*.f64}\left(c0, d\right)\right), \mathsf{*.f64}\left(w, \mathsf{*.f64}\left(D, \color{blue}{\left(h \cdot D\right)}\right)\right)\right) \]
      21. *-lowering-*.f6459.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{/.f64}\left(w, d\right)\right), \mathsf{*.f64}\left(c0, d\right)\right), \mathsf{*.f64}\left(w, \mathsf{*.f64}\left(D, \mathsf{*.f64}\left(h, \color{blue}{D}\right)\right)\right)\right) \]
    7. Applied egg-rr59.7%

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

Alternative 4: 34.1% accurate, 151.0× speedup?

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

\\
0
\end{array}
Derivation
  1. Initial program 24.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. Add Preprocessing
  3. Taylor expanded in c0 around -inf

    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \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)}\right) \]
  4. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(-1 \cdot c0\right) \cdot \color{blue}{\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) \]
    2. mul-1-negN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(\color{blue}{-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) \]
    3. distribute-lft1-inN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(\left(-1 + 1\right) \cdot \color{blue}{\frac{{d}^{2}}{{D}^{2} \cdot \left(h \cdot w\right)}}\right)\right)\right) \]
    4. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(0 \cdot \frac{\color{blue}{{d}^{2}}}{{D}^{2} \cdot \left(h \cdot w\right)}\right)\right)\right) \]
    5. mul0-lftN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot 0\right)\right) \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\left(\mathsf{neg}\left(c0\right)\right) \cdot \left(-1 + \color{blue}{1}\right)\right)\right) \]
    7. distribute-lft-neg-inN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(\mathsf{neg}\left(c0 \cdot \left(-1 + 1\right)\right)\right)\right) \]
    8. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot \color{blue}{\left(\mathsf{neg}\left(\left(-1 + 1\right)\right)\right)}\right)\right) \]
    9. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot \left(\mathsf{neg}\left(0\right)\right)\right)\right) \]
    10. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot 0\right)\right) \]
    11. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \left(c0 \cdot \left(-1 + \color{blue}{1}\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \mathsf{*.f64}\left(c0, \color{blue}{\left(-1 + 1\right)}\right)\right) \]
    13. metadata-eval30.3%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(c0, \mathsf{*.f64}\left(2, w\right)\right), \mathsf{*.f64}\left(c0, 0\right)\right) \]
  5. Simplified30.3%

    \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(c0 \cdot 0\right)} \]
  6. Step-by-step derivation
    1. mul0-rgtN/A

      \[\leadsto \frac{c0}{2 \cdot w} \cdot 0 \]
    2. mul0-rgt34.1%

      \[\leadsto 0 \]
  7. Applied egg-rr34.1%

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

Reproduce

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