Henrywood and Agarwal, Equation (13)

Percentage Accurate: 24.5% → 73.3%
Time: 27.0s
Alternatives: 4
Speedup: 21.6×

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.5% 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: 73.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c0}{2 \cdot w}\\ t_1 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\ t_2 := t\_0 \cdot \left(t\_1 + \sqrt{t\_1 \cdot t\_1 - M \cdot M}\right)\\ t_3 := \frac{D \cdot M}{d}\\ \mathbf{if}\;t\_2 \leq -1 \cdot 10^{-44}:\\ \;\;\;\;t\_0 \cdot \left(2 \cdot \left(c0 \cdot \left(\frac{d}{D} \cdot \frac{\frac{d}{D}}{w \cdot h}\right)\right)\right)\\ \mathbf{elif}\;t\_2 \leq 0 \lor \neg \left(t\_2 \leq \infty\right):\\ \;\;\;\;0.25 \cdot \left(h \cdot \left(t\_3 \cdot t\_3\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot \left(2 \cdot \left(c0 \cdot \left(\frac{\frac{d}{D}}{w} \cdot \frac{\frac{d}{D}}{h}\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ c0 (* 2.0 w)))
        (t_1 (/ (* c0 (* d d)) (* (* w h) (* D D))))
        (t_2 (* t_0 (+ t_1 (sqrt (- (* t_1 t_1) (* M M))))))
        (t_3 (/ (* D M) d)))
   (if (<= t_2 -1e-44)
     (* t_0 (* 2.0 (* c0 (* (/ d D) (/ (/ d D) (* w h))))))
     (if (or (<= t_2 0.0) (not (<= t_2 INFINITY)))
       (* 0.25 (* h (* t_3 t_3)))
       (* t_0 (* 2.0 (* c0 (* (/ (/ d D) w) (/ (/ d D) h)))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 / (2.0 * w);
	double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
	double t_2 = t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))));
	double t_3 = (D * M) / d;
	double tmp;
	if (t_2 <= -1e-44) {
		tmp = t_0 * (2.0 * (c0 * ((d / D) * ((d / D) / (w * h)))));
	} else if ((t_2 <= 0.0) || !(t_2 <= ((double) INFINITY))) {
		tmp = 0.25 * (h * (t_3 * t_3));
	} else {
		tmp = t_0 * (2.0 * (c0 * (((d / D) / w) * ((d / D) / h))));
	}
	return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = c0 / (2.0 * w);
	double t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
	double t_2 = t_0 * (t_1 + Math.sqrt(((t_1 * t_1) - (M * M))));
	double t_3 = (D * M) / d;
	double tmp;
	if (t_2 <= -1e-44) {
		tmp = t_0 * (2.0 * (c0 * ((d / D) * ((d / D) / (w * h)))));
	} else if ((t_2 <= 0.0) || !(t_2 <= Double.POSITIVE_INFINITY)) {
		tmp = 0.25 * (h * (t_3 * t_3));
	} else {
		tmp = t_0 * (2.0 * (c0 * (((d / D) / w) * ((d / D) / h))));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = c0 / (2.0 * w)
	t_1 = (c0 * (d * d)) / ((w * h) * (D * D))
	t_2 = t_0 * (t_1 + math.sqrt(((t_1 * t_1) - (M * M))))
	t_3 = (D * M) / d
	tmp = 0
	if t_2 <= -1e-44:
		tmp = t_0 * (2.0 * (c0 * ((d / D) * ((d / D) / (w * h)))))
	elif (t_2 <= 0.0) or not (t_2 <= math.inf):
		tmp = 0.25 * (h * (t_3 * t_3))
	else:
		tmp = t_0 * (2.0 * (c0 * (((d / D) / w) * ((d / D) / h))))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(c0 / Float64(2.0 * w))
	t_1 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))
	t_2 = Float64(t_0 * Float64(t_1 + sqrt(Float64(Float64(t_1 * t_1) - Float64(M * M)))))
	t_3 = Float64(Float64(D * M) / d)
	tmp = 0.0
	if (t_2 <= -1e-44)
		tmp = Float64(t_0 * Float64(2.0 * Float64(c0 * Float64(Float64(d / D) * Float64(Float64(d / D) / Float64(w * h))))));
	elseif ((t_2 <= 0.0) || !(t_2 <= Inf))
		tmp = Float64(0.25 * Float64(h * Float64(t_3 * t_3)));
	else
		tmp = Float64(t_0 * Float64(2.0 * Float64(c0 * Float64(Float64(Float64(d / D) / w) * Float64(Float64(d / D) / h)))));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = c0 / (2.0 * w);
	t_1 = (c0 * (d * d)) / ((w * h) * (D * D));
	t_2 = t_0 * (t_1 + sqrt(((t_1 * t_1) - (M * M))));
	t_3 = (D * M) / d;
	tmp = 0.0;
	if (t_2 <= -1e-44)
		tmp = t_0 * (2.0 * (c0 * ((d / D) * ((d / D) / (w * h)))));
	elseif ((t_2 <= 0.0) || ~((t_2 <= Inf)))
		tmp = 0.25 * (h * (t_3 * t_3));
	else
		tmp = t_0 * (2.0 * (c0 * (((d / D) / w) * ((d / D) / h))));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(t$95$1 + N[Sqrt[N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(D * M), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[t$95$2, -1e-44], N[(t$95$0 * N[(2.0 * N[(c0 * N[(N[(d / D), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$2, 0.0], N[Not[LessEqual[t$95$2, Infinity]], $MachinePrecision]], N[(0.25 * N[(h * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(2.0 * N[(c0 * N[(N[(N[(d / D), $MachinePrecision] / w), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_2 \leq 0 \lor \neg \left(t\_2 \leq \infty\right):\\
\;\;\;\;0.25 \cdot \left(h \cdot \left(t\_3 \cdot t\_3\right)\right)\\

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


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

    1. Initial program 81.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. Simplified81.2%

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\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. Step-by-step derivation
      1. times-frac81.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999953e-45 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) < -0.0 or +inf.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M)))))

    1. Initial program 3.0%

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\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. Taylor expanded in c0 around -inf 7.6%

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \left({D}^{2} \cdot \frac{\left(h \cdot w\right) \cdot {M}^{2}}{c0 \cdot {d}^{2}}\right) + 0\right)} \]
    7. Taylor expanded in c0 around 0 51.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.25 \cdot \color{blue}{\left(h \cdot \frac{{\left(M \cdot D\right)}^{2}}{{d}^{2}}\right)} \]
    12. Step-by-step derivation
      1. unpow261.2%

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

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

        \[\leadsto 0.25 \cdot \left(h \cdot \color{blue}{\left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{d}\right)}\right) \]
    13. Applied egg-rr74.2%

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

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

    1. Initial program 84.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. Simplified80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 51.1% accurate, 4.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{D \cdot M}{d}\\ \mathbf{if}\;d \leq 9 \cdot 10^{+223} \lor \neg \left(d \leq 4.4 \cdot 10^{+295}\right):\\ \;\;\;\;0.25 \cdot \left(h \cdot \left(t\_0 \cdot t\_0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(c0 \cdot \left(\frac{\frac{d}{D}}{w} \cdot \frac{\frac{d}{D}}{h}\right)\right)\right)\\ \end{array} \end{array} \]
(FPCore (c0 w h D d M)
 :precision binary64
 (let* ((t_0 (/ (* D M) d)))
   (if (or (<= d 9e+223) (not (<= d 4.4e+295)))
     (* 0.25 (* h (* t_0 t_0)))
     (* (/ c0 (* 2.0 w)) (* 2.0 (* c0 (* (/ (/ d D) w) (/ (/ d D) h))))))))
double code(double c0, double w, double h, double D, double d, double M) {
	double t_0 = (D * M) / d;
	double tmp;
	if ((d <= 9e+223) || !(d <= 4.4e+295)) {
		tmp = 0.25 * (h * (t_0 * t_0));
	} else {
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 * (((d / D) / w) * ((d / D) / 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) :: t_0
    real(8) :: tmp
    t_0 = (d * m) / d_1
    if ((d_1 <= 9d+223) .or. (.not. (d_1 <= 4.4d+295))) then
        tmp = 0.25d0 * (h * (t_0 * t_0))
    else
        tmp = (c0 / (2.0d0 * w)) * (2.0d0 * (c0 * (((d_1 / d) / w) * ((d_1 / d) / h))))
    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 = (D * M) / d;
	double tmp;
	if ((d <= 9e+223) || !(d <= 4.4e+295)) {
		tmp = 0.25 * (h * (t_0 * t_0));
	} else {
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 * (((d / D) / w) * ((d / D) / h))));
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	t_0 = (D * M) / d
	tmp = 0
	if (d <= 9e+223) or not (d <= 4.4e+295):
		tmp = 0.25 * (h * (t_0 * t_0))
	else:
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 * (((d / D) / w) * ((d / D) / h))))
	return tmp
function code(c0, w, h, D, d, M)
	t_0 = Float64(Float64(D * M) / d)
	tmp = 0.0
	if ((d <= 9e+223) || !(d <= 4.4e+295))
		tmp = Float64(0.25 * Float64(h * Float64(t_0 * t_0)));
	else
		tmp = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(2.0 * Float64(c0 * Float64(Float64(Float64(d / D) / w) * Float64(Float64(d / D) / h)))));
	end
	return tmp
end
function tmp_2 = code(c0, w, h, D, d, M)
	t_0 = (D * M) / d;
	tmp = 0.0;
	if ((d <= 9e+223) || ~((d <= 4.4e+295)))
		tmp = 0.25 * (h * (t_0 * t_0));
	else
		tmp = (c0 / (2.0 * w)) * (2.0 * (c0 * (((d / D) / w) * ((d / D) / h))));
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := Block[{t$95$0 = N[(N[(D * M), $MachinePrecision] / d), $MachinePrecision]}, If[Or[LessEqual[d, 9e+223], N[Not[LessEqual[d, 4.4e+295]], $MachinePrecision]], N[(0.25 * N[(h * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(2.0 * N[(c0 * N[(N[(N[(d / D), $MachinePrecision] / w), $MachinePrecision] * N[(N[(d / D), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{D \cdot M}{d}\\
\mathbf{if}\;d \leq 9 \cdot 10^{+223} \lor \neg \left(d \leq 4.4 \cdot 10^{+295}\right):\\
\;\;\;\;0.25 \cdot \left(h \cdot \left(t\_0 \cdot t\_0\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < 9e223 or 4.3999999999999996e295 < d

    1. Initial program 27.3%

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\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. Taylor expanded in c0 around -inf 7.3%

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

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

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

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

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

      \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \left({D}^{2} \cdot \frac{\left(h \cdot w\right) \cdot {M}^{2}}{c0 \cdot {d}^{2}}\right) + 0\right)} \]
    7. Taylor expanded in c0 around 0 41.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.25 \cdot \color{blue}{\left(h \cdot \frac{{\left(M \cdot D\right)}^{2}}{{d}^{2}}\right)} \]
    12. Step-by-step derivation
      1. unpow249.1%

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

        \[\leadsto 0.25 \cdot \left(h \cdot \frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\color{blue}{d \cdot d}}\right) \]
      3. times-frac56.7%

        \[\leadsto 0.25 \cdot \left(h \cdot \color{blue}{\left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{d}\right)}\right) \]
    13. Applied egg-rr56.7%

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

    if 9e223 < d < 4.3999999999999996e295

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

      \[\leadsto \color{blue}{\frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\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. Step-by-step derivation
      1. times-frac38.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq 9 \cdot 10^{+223} \lor \neg \left(d \leq 4.4 \cdot 10^{+295}\right):\\ \;\;\;\;0.25 \cdot \left(h \cdot \left(\frac{D \cdot M}{d} \cdot \frac{D \cdot M}{d}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(c0 \cdot \left(\frac{\frac{d}{D}}{w} \cdot \frac{\frac{d}{D}}{h}\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 52.2% accurate, 10.1× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{D \cdot M}{d}\\
0.25 \cdot \left(h \cdot \left(t\_0 \cdot t\_0\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 28.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. Simplified28.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. Taylor expanded in c0 around -inf 6.3%

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

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

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

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

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

    \[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \left({D}^{2} \cdot \frac{\left(h \cdot w\right) \cdot {M}^{2}}{c0 \cdot {d}^{2}}\right) + 0\right)} \]
  7. Taylor expanded in c0 around 0 37.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 0.25 \cdot \color{blue}{\left(h \cdot \frac{{\left(M \cdot D\right)}^{2}}{{d}^{2}}\right)} \]
  12. Step-by-step derivation
    1. unpow244.8%

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

      \[\leadsto 0.25 \cdot \left(h \cdot \frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{\color{blue}{d \cdot d}}\right) \]
    3. times-frac53.3%

      \[\leadsto 0.25 \cdot \left(h \cdot \color{blue}{\left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{d}\right)}\right) \]
  13. Applied egg-rr53.3%

    \[\leadsto 0.25 \cdot \left(h \cdot \color{blue}{\left(\frac{M \cdot D}{d} \cdot \frac{M \cdot D}{d}\right)}\right) \]
  14. Final simplification53.3%

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

Alternative 4: 34.5% accurate, 21.6× speedup?

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

\\
c0 \cdot \frac{0}{2 \cdot w}
\end{array}
Derivation
  1. Initial program 28.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. Simplified39.3%

    \[\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. Taylor expanded in c0 around -inf 3.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto c0 \cdot \frac{-1 \cdot \color{blue}{0}}{2 \cdot w} \]
    10. metadata-eval34.3%

      \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
  6. Simplified34.3%

    \[\leadsto c0 \cdot \frac{\color{blue}{0}}{2 \cdot w} \]
  7. Final simplification34.3%

    \[\leadsto c0 \cdot \frac{0}{2 \cdot w} \]
  8. Add Preprocessing

Reproduce

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