Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.8% → 54.2%
Time: 31.1s
Alternatives: 7
Speedup: 50.3×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 24.8% accurate, 1.0× speedup?

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

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

Alternative 1: 54.2% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\frac{c0}{w}}{h}\\
t_1 := {\left(\frac{d}{D}\right)}^{2}\\
t_2 := t\_0 \cdot t\_1\\
t_3 := \frac{c0}{2 \cdot w}\\
t_4 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
\mathbf{if}\;t\_3 \cdot \left(t\_4 + \sqrt{t\_4 \cdot t\_4 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;t\_3 \cdot \mathsf{fma}\left(\sqrt{\mathsf{fma}\left(t\_0, t\_1, M\right)}, \sqrt{t\_2 - M}, t\_2\right)\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot 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 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. Simplified72.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{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) - M \cdot M}\right)} \]
    3. Add Preprocessing
    4. Applied egg-rr78.3%

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

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

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

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

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

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

      \[\leadsto c0 \cdot \frac{\color{blue}{M \cdot \sqrt{-1}}}{2 \cdot w} \]
    5. Step-by-step derivation
      1. add-log-exp0.0%

        \[\leadsto c0 \cdot \color{blue}{\log \left(e^{\frac{M \cdot \sqrt{-1}}{2 \cdot w}}\right)} \]
      2. associate-/l*0.0%

        \[\leadsto c0 \cdot \log \left(e^{\color{blue}{M \cdot \frac{\sqrt{-1}}{2 \cdot w}}}\right) \]
      3. exp-prod30.3%

        \[\leadsto c0 \cdot \log \color{blue}{\left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)} \]
    6. Applied egg-rr30.3%

      \[\leadsto c0 \cdot \color{blue}{\log \left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)} \]
    7. Taylor expanded in M around 0 45.8%

      \[\leadsto c0 \cdot \log \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification55.6%

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

Alternative 2: 42.5% accurate, 0.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;c0 \cdot 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 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. Simplified72.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{\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}\right) - M \cdot M}\right)} \]
    3. Add Preprocessing
    4. Applied egg-rr78.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(\sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h}, {\left(\frac{d}{D}\right)}^{2}, M\right)} \cdot \left(\frac{d}{D} \cdot \sqrt{\frac{c0}{w \cdot h}}\right) + \frac{c0}{w \cdot h} \cdot {\left(\frac{d}{D}\right)}^{2}\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. Simplified12.4%

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

      \[\leadsto c0 \cdot \frac{\color{blue}{M \cdot \sqrt{-1}}}{2 \cdot w} \]
    5. Step-by-step derivation
      1. add-log-exp0.0%

        \[\leadsto c0 \cdot \color{blue}{\log \left(e^{\frac{M \cdot \sqrt{-1}}{2 \cdot w}}\right)} \]
      2. associate-/l*0.0%

        \[\leadsto c0 \cdot \log \left(e^{\color{blue}{M \cdot \frac{\sqrt{-1}}{2 \cdot w}}}\right) \]
      3. exp-prod30.3%

        \[\leadsto c0 \cdot \log \color{blue}{\left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)} \]
    6. Applied egg-rr30.3%

      \[\leadsto c0 \cdot \color{blue}{\log \left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)} \]
    7. Taylor expanded in M around 0 45.8%

      \[\leadsto c0 \cdot \log \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification41.7%

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

Alternative 3: 54.1% accurate, 0.4× 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:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left(w \cdot h\right) \cdot {D}^{2}}\right)}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot 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
      (/ (* 2.0 (* c0 (/ (pow d 2.0) (* (* w h) (pow D 2.0))))) (* 2.0 w)))
     (* c0 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 * ((2.0 * (c0 * (pow(d, 2.0) / ((w * h) * pow(D, 2.0))))) / (2.0 * w));
	} else {
		tmp = c0 * 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 * ((2.0 * (c0 * (Math.pow(d, 2.0) / ((w * h) * Math.pow(D, 2.0))))) / (2.0 * w));
	} else {
		tmp = c0 * 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 * ((2.0 * (c0 * (math.pow(d, 2.0) / ((w * h) * math.pow(D, 2.0))))) / (2.0 * w))
	else:
		tmp = c0 * 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(c0 * Float64(Float64(2.0 * Float64(c0 * Float64((d ^ 2.0) / Float64(Float64(w * h) * (D ^ 2.0))))) / Float64(2.0 * w)));
	else
		tmp = Float64(c0 * 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 * ((2.0 * (c0 * ((d ^ 2.0) / ((w * h) * (D ^ 2.0))))) / (2.0 * w));
	else
		tmp = c0 * 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[(c0 * N[(N[(2.0 * N[(c0 * N[(N[Power[d, 2.0], $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[Power[D, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c0 * 0.0), $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)}\\
\mathbf{if}\;\frac{c0}{2 \cdot w} \cdot \left(t\_0 + \sqrt{t\_0 \cdot t\_0 - M \cdot M}\right) \leq \infty:\\
\;\;\;\;c0 \cdot \frac{2 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left(w \cdot h\right) \cdot {D}^{2}}\right)}{2 \cdot w}\\

\mathbf{else}:\\
\;\;\;\;c0 \cdot 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 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. Simplified75.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    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. Simplified12.4%

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

      \[\leadsto c0 \cdot \frac{\color{blue}{M \cdot \sqrt{-1}}}{2 \cdot w} \]
    5. Step-by-step derivation
      1. add-log-exp0.0%

        \[\leadsto c0 \cdot \color{blue}{\log \left(e^{\frac{M \cdot \sqrt{-1}}{2 \cdot w}}\right)} \]
      2. associate-/l*0.0%

        \[\leadsto c0 \cdot \log \left(e^{\color{blue}{M \cdot \frac{\sqrt{-1}}{2 \cdot w}}}\right) \]
      3. exp-prod30.3%

        \[\leadsto c0 \cdot \log \color{blue}{\left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)} \]
    6. Applied egg-rr30.3%

      \[\leadsto c0 \cdot \color{blue}{\log \left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)} \]
    7. Taylor expanded in M around 0 45.8%

      \[\leadsto c0 \cdot \log \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification55.3%

    \[\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:\\ \;\;\;\;c0 \cdot \frac{2 \cdot \left(c0 \cdot \frac{{d}^{2}}{\left(w \cdot h\right) \cdot {D}^{2}}\right)}{2 \cdot w}\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot 0\\ \end{array} \]
  5. Add Preprocessing

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

\mathbf{else}:\\
\;\;\;\;c0 \cdot 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 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. Add Preprocessing
    3. Step-by-step derivation
      1. div-inv76.5%

        \[\leadsto \color{blue}{\left(c0 \cdot \frac{1}{2 \cdot w}\right)} \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. *-commutative76.5%

        \[\leadsto \left(c0 \cdot \frac{1}{\color{blue}{w \cdot 2}}\right) \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) \]
    4. Applied egg-rr76.5%

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

    if +inf.0 < (*.f64 (/.f64 c0 (*.f64 #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. Simplified12.4%

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

      \[\leadsto c0 \cdot \frac{\color{blue}{M \cdot \sqrt{-1}}}{2 \cdot w} \]
    5. Step-by-step derivation
      1. add-log-exp0.0%

        \[\leadsto c0 \cdot \color{blue}{\log \left(e^{\frac{M \cdot \sqrt{-1}}{2 \cdot w}}\right)} \]
      2. associate-/l*0.0%

        \[\leadsto c0 \cdot \log \left(e^{\color{blue}{M \cdot \frac{\sqrt{-1}}{2 \cdot w}}}\right) \]
      3. exp-prod30.3%

        \[\leadsto c0 \cdot \log \color{blue}{\left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)} \]
    6. Applied egg-rr30.3%

      \[\leadsto c0 \cdot \color{blue}{\log \left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)} \]
    7. Taylor expanded in M around 0 45.8%

      \[\leadsto c0 \cdot \log \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification55.0%

    \[\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:\\ \;\;\;\;\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) \cdot \left(c0 \cdot \frac{1}{2 \cdot w}\right)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot 0\\ \end{array} \]
  5. Add Preprocessing

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

\mathbf{else}:\\
\;\;\;\;c0 \cdot 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 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. Add Preprocessing

    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. Simplified12.4%

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

      \[\leadsto c0 \cdot \frac{\color{blue}{M \cdot \sqrt{-1}}}{2 \cdot w} \]
    5. Step-by-step derivation
      1. add-log-exp0.0%

        \[\leadsto c0 \cdot \color{blue}{\log \left(e^{\frac{M \cdot \sqrt{-1}}{2 \cdot w}}\right)} \]
      2. associate-/l*0.0%

        \[\leadsto c0 \cdot \log \left(e^{\color{blue}{M \cdot \frac{\sqrt{-1}}{2 \cdot w}}}\right) \]
      3. exp-prod30.3%

        \[\leadsto c0 \cdot \log \color{blue}{\left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)} \]
    6. Applied egg-rr30.3%

      \[\leadsto c0 \cdot \color{blue}{\log \left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)} \]
    7. Taylor expanded in M around 0 45.8%

      \[\leadsto c0 \cdot \log \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification55.0%

    \[\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(\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)\\ \mathbf{else}:\\ \;\;\;\;c0 \cdot 0\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 33.9% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;M \leq 1760000000:\\
\;\;\;\;c0 \cdot 0\\

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


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

    1. Initial program 24.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. Simplified30.6%

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

      \[\leadsto c0 \cdot \frac{\color{blue}{M \cdot \sqrt{-1}}}{2 \cdot w} \]
    5. Step-by-step derivation
      1. add-log-exp0.0%

        \[\leadsto c0 \cdot \color{blue}{\log \left(e^{\frac{M \cdot \sqrt{-1}}{2 \cdot w}}\right)} \]
      2. associate-/l*0.0%

        \[\leadsto c0 \cdot \log \left(e^{\color{blue}{M \cdot \frac{\sqrt{-1}}{2 \cdot w}}}\right) \]
      3. exp-prod28.3%

        \[\leadsto c0 \cdot \log \color{blue}{\left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)} \]
    6. Applied egg-rr28.3%

      \[\leadsto c0 \cdot \color{blue}{\log \left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)} \]
    7. Taylor expanded in M around 0 36.1%

      \[\leadsto c0 \cdot \log \color{blue}{1} \]

    if 1.76e9 < M

    1. Initial program 18.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{c0}{2 \cdot w} \cdot \left(\frac{d}{D} \cdot \sqrt{\color{blue}{\frac{M}{h} \cdot \frac{c0}{w}}}\right) \]
    12. Simplified8.0%

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

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

Alternative 7: 33.9% accurate, 50.3× speedup?

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

\\
c0 \cdot 0
\end{array}
Derivation
  1. Initial program 23.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. Simplified30.9%

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

    \[\leadsto c0 \cdot \frac{\color{blue}{M \cdot \sqrt{-1}}}{2 \cdot w} \]
  5. Step-by-step derivation
    1. add-log-exp0.0%

      \[\leadsto c0 \cdot \color{blue}{\log \left(e^{\frac{M \cdot \sqrt{-1}}{2 \cdot w}}\right)} \]
    2. associate-/l*0.0%

      \[\leadsto c0 \cdot \log \left(e^{\color{blue}{M \cdot \frac{\sqrt{-1}}{2 \cdot w}}}\right) \]
    3. exp-prod22.8%

      \[\leadsto c0 \cdot \log \color{blue}{\left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)} \]
  6. Applied egg-rr22.8%

    \[\leadsto c0 \cdot \color{blue}{\log \left({\left(e^{M}\right)}^{\left(\frac{\sqrt{-1}}{2 \cdot w}\right)}\right)} \]
  7. Taylor expanded in M around 0 33.8%

    \[\leadsto c0 \cdot \log \color{blue}{1} \]
  8. Final simplification33.8%

    \[\leadsto c0 \cdot 0 \]
  9. Add Preprocessing

Reproduce

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