?

Average Error: 59.7 → 15.2
Time: 29.9s
Precision: binary64
Cost: 42637

?

\[\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) \]
\[\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 -1 \cdot 10^{-224}:\\ \;\;\;\;\frac{d}{\left(\frac{2}{c0} \cdot \left(w \cdot D\right)\right) \cdot \frac{h \cdot \frac{w \cdot D}{2}}{c0 \cdot d}}\\ \mathbf{elif}\;t_1 \leq 0 \lor \neg \left(t_1 \leq \infty\right):\\ \;\;\;\;\frac{0.25}{d} \cdot \left(\left(D \cdot M\right) \cdot \frac{h}{\frac{d}{D \cdot M}}\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{d}{D} \cdot \frac{\frac{c0}{w}}{\sqrt{h}}\right)}^{2}\\ \end{array} \]
(FPCore (c0 w h D d M)
 :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))))))
(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 -1e-224)
     (/ d (* (* (/ 2.0 c0) (* w D)) (/ (* h (/ (* w D) 2.0)) (* c0 d))))
     (if (or (<= t_1 0.0) (not (<= t_1 INFINITY)))
       (* (/ 0.25 d) (* (* D M) (/ h (/ d (* D M)))))
       (pow (* (/ d D) (/ (/ c0 w) (sqrt h))) 2.0)))))
double code(double c0, double w, double h, double D, double d, double M) {
	return (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))));
}
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 <= -1e-224) {
		tmp = d / (((2.0 / c0) * (w * D)) * ((h * ((w * D) / 2.0)) / (c0 * d)));
	} else if ((t_1 <= 0.0) || !(t_1 <= ((double) INFINITY))) {
		tmp = (0.25 / d) * ((D * M) * (h / (d / (D * M))));
	} else {
		tmp = pow(((d / D) * ((c0 / w) / sqrt(h))), 2.0);
	}
	return tmp;
}
public static double code(double c0, double w, double h, double D, double d, double M) {
	return (c0 / (2.0 * w)) * (((c0 * (d * d)) / ((w * h) * (D * D))) + Math.sqrt(((((c0 * (d * d)) / ((w * h) * (D * D))) * ((c0 * (d * d)) / ((w * h) * (D * D)))) - (M * M))));
}
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 <= -1e-224) {
		tmp = d / (((2.0 / c0) * (w * D)) * ((h * ((w * D) / 2.0)) / (c0 * d)));
	} else if ((t_1 <= 0.0) || !(t_1 <= Double.POSITIVE_INFINITY)) {
		tmp = (0.25 / d) * ((D * M) * (h / (d / (D * M))));
	} else {
		tmp = Math.pow(((d / D) * ((c0 / w) / Math.sqrt(h))), 2.0);
	}
	return tmp;
}
def code(c0, w, h, D, d, M):
	return (c0 / (2.0 * w)) * (((c0 * (d * d)) / ((w * h) * (D * D))) + math.sqrt(((((c0 * (d * d)) / ((w * h) * (D * D))) * ((c0 * (d * d)) / ((w * h) * (D * D)))) - (M * M))))
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 <= -1e-224:
		tmp = d / (((2.0 / c0) * (w * D)) * ((h * ((w * D) / 2.0)) / (c0 * d)))
	elif (t_1 <= 0.0) or not (t_1 <= math.inf):
		tmp = (0.25 / d) * ((D * M) * (h / (d / (D * M))))
	else:
		tmp = math.pow(((d / D) * ((c0 / w) / math.sqrt(h))), 2.0)
	return tmp
function code(c0, w, h, D, d, M)
	return Float64(Float64(c0 / Float64(2.0 * w)) * Float64(Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) + sqrt(Float64(Float64(Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) * Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D)))) - Float64(M * M)))))
end
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 <= -1e-224)
		tmp = Float64(d / Float64(Float64(Float64(2.0 / c0) * Float64(w * D)) * Float64(Float64(h * Float64(Float64(w * D) / 2.0)) / Float64(c0 * d))));
	elseif ((t_1 <= 0.0) || !(t_1 <= Inf))
		tmp = Float64(Float64(0.25 / d) * Float64(Float64(D * M) * Float64(h / Float64(d / Float64(D * M)))));
	else
		tmp = Float64(Float64(d / D) * Float64(Float64(c0 / w) / sqrt(h))) ^ 2.0;
	end
	return tmp
end
function tmp = code(c0, w, h, D, d, M)
	tmp = (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))));
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 <= -1e-224)
		tmp = d / (((2.0 / c0) * (w * D)) * ((h * ((w * D) / 2.0)) / (c0 * d)));
	elseif ((t_1 <= 0.0) || ~((t_1 <= Inf)))
		tmp = (0.25 / d) * ((D * M) * (h / (d / (D * M))));
	else
		tmp = ((d / D) * ((c0 / w) / sqrt(h))) ^ 2.0;
	end
	tmp_2 = tmp;
end
code[c0_, w_, h_, D_, d_, M_] := N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Sqrt[N[(N[(N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
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, -1e-224], N[(d / N[(N[(N[(2.0 / c0), $MachinePrecision] * N[(w * D), $MachinePrecision]), $MachinePrecision] * N[(N[(h * N[(N[(w * D), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] / N[(c0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$1, 0.0], N[Not[LessEqual[t$95$1, Infinity]], $MachinePrecision]], N[(N[(0.25 / d), $MachinePrecision] * N[(N[(D * M), $MachinePrecision] * N[(h / N[(d / N[(D * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[(d / D), $MachinePrecision] * N[(N[(c0 / w), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]]]]]
\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)
\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 -1 \cdot 10^{-224}:\\
\;\;\;\;\frac{d}{\left(\frac{2}{c0} \cdot \left(w \cdot D\right)\right) \cdot \frac{h \cdot \frac{w \cdot D}{2}}{c0 \cdot d}}\\

\mathbf{elif}\;t_1 \leq 0 \lor \neg \left(t_1 \leq \infty\right):\\
\;\;\;\;\frac{0.25}{d} \cdot \left(\left(D \cdot M\right) \cdot \frac{h}{\frac{d}{D \cdot M}}\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

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))))) < -1e-224

    1. Initial program 49.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. Simplified50.0

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

      [Start]49.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) \]

      times-frac [=>]51.1

      \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} + \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) \]

      fma-neg [=>]51.1

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

      times-frac [=>]51.1

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

      times-frac [=>]50.0

      \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}}, -M \cdot M\right)}\right) \]
    3. Taylor expanded in c0 around inf 43.0

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

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

      [Start]43.0

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

      associate-*r/ [=>]43.0

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

      *-commutative [=>]43.0

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

      unpow2 [=>]43.0

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

      associate-*r* [=>]39.8

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

      *-commutative [<=]39.8

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

      *-commutative [=>]39.8

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

      unpow2 [=>]39.8

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

      associate-*r* [<=]41.2

      \[ \frac{c0}{2 \cdot w} \cdot \frac{2 \cdot \left(\left(d \cdot c0\right) \cdot d\right)}{\color{blue}{w \cdot \left(h \cdot \left(D \cdot D\right)\right)}} \]
    5. Applied egg-rr29.3

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

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

      [Start]29.3

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

      associate-/l* [=>]26.8

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

      associate-/l/ [=>]25.9

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

      associate-*l* [=>]27.6

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

      *-commutative [=>]27.6

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

      associate-*l* [=>]24.6

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

      associate-*r/ [=>]24.6

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

    if -1e-224 < (*.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 61.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. Applied egg-rr62.1

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

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

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

      [Start]60.0

      \[ \frac{c0}{2 \cdot w} \cdot \left(0.5 \cdot \frac{{D}^{2} \cdot \left(w \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot c0} + -1 \cdot \left(\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot c0\right)\right) \]

      fma-def [=>]60.0

      \[ \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{{D}^{2} \cdot \left(w \cdot \left({M}^{2} \cdot h\right)\right)}{{d}^{2} \cdot c0}, -1 \cdot \left(\left(\frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)} + -1 \cdot \frac{{d}^{2}}{{D}^{2} \cdot \left(w \cdot h\right)}\right) \cdot c0\right)\right)} \]
    5. Taylor expanded in c0 around 0 33.1

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

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

      [Start]33.1

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

      associate-*r/ [=>]33.1

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

      unpow2 [=>]33.1

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

      times-frac [=>]30.1

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

      associate-*r* [=>]29.7

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

      *-commutative [=>]29.7

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

      unpow2 [=>]29.7

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

      unpow2 [=>]29.7

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

      unswap-sqr [=>]20.5

      \[ \frac{0.25}{d} \cdot \frac{h \cdot \color{blue}{\left(\left(D \cdot M\right) \cdot \left(D \cdot M\right)\right)}}{d} \]
    7. Applied egg-rr14.2

      \[\leadsto \frac{0.25}{d} \cdot \color{blue}{\left(\frac{h}{\frac{d}{D \cdot M}} \cdot \left(D \cdot M\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 49.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. Simplified49.7

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

      [Start]49.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) \]

      times-frac [=>]50.7

      \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}} + \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) \]

      fma-neg [=>]50.7

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

      times-frac [=>]50.7

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

      times-frac [=>]49.7

      \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \sqrt{\mathsf{fma}\left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}, \color{blue}{\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D}}, -M \cdot M\right)}\right) \]
    3. Taylor expanded in c0 around inf 55.2

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

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

      [Start]55.2

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

      times-frac [=>]56.7

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

      unpow2 [=>]56.7

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

      unpow2 [=>]56.7

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

      associate-/r* [=>]54.5

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

      associate-*r/ [<=]53.9

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

      associate-*l/ [<=]53.1

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

      unpow2 [<=]53.1

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

      unpow2 [=>]53.1

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

      *-commutative [=>]53.1

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

      unpow2 [=>]53.1

      \[ {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0 \cdot c0}{h \cdot \color{blue}{\left(w \cdot w\right)}} \]
    5. Applied egg-rr34.3

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left({\left(\frac{d}{D} \cdot \frac{c0}{w \cdot \sqrt{h}}\right)}^{2}\right)} - 1} \]
    6. Simplified20.0

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

      [Start]34.3

      \[ e^{\mathsf{log1p}\left({\left(\frac{d}{D} \cdot \frac{c0}{w \cdot \sqrt{h}}\right)}^{2}\right)} - 1 \]

      expm1-def [=>]21.9

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

      expm1-log1p [=>]19.6

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

      associate-/r* [=>]20.0

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

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

Alternatives

Alternative 1
Error15.1
Cost42637
\[\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 -1 \cdot 10^{-224}:\\ \;\;\;\;\frac{d}{\left(\frac{2}{c0} \cdot \left(w \cdot D\right)\right) \cdot \frac{h \cdot \frac{w \cdot D}{2}}{c0 \cdot d}}\\ \mathbf{elif}\;t_1 \leq 0 \lor \neg \left(t_1 \leq \infty\right):\\ \;\;\;\;\frac{0.25}{d} \cdot \left(\left(D \cdot M\right) \cdot \frac{h}{\frac{d}{D \cdot M}}\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{d}{D} \cdot \frac{c0}{w \cdot \sqrt{h}}\right)}^{2}\\ \end{array} \]
Alternative 2
Error16.0
Cost30541
\[\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)\\ \mathbf{if}\;t_2 \leq -1 \cdot 10^{-224}:\\ \;\;\;\;\frac{d}{\left(\frac{2}{c0} \cdot \left(w \cdot D\right)\right) \cdot \frac{h \cdot \frac{w \cdot D}{2}}{c0 \cdot d}}\\ \mathbf{elif}\;t_2 \leq 0 \lor \neg \left(t_2 \leq \infty\right):\\ \;\;\;\;\frac{0.25}{d} \cdot \left(\left(D \cdot M\right) \cdot \frac{h}{\frac{d}{D \cdot M}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(2 \cdot \left(d \cdot \frac{d \cdot \frac{c0}{w}}{D \cdot \left(h \cdot D\right)}\right)\right)\\ \end{array} \]
Alternative 3
Error24.4
Cost1481
\[\begin{array}{l} \mathbf{if}\;d \cdot d \leq 2 \cdot 10^{-278} \lor \neg \left(d \cdot d \leq 10^{+48}\right):\\ \;\;\;\;0.25 \cdot \left(D \cdot \left(D \cdot \left(\left(M \cdot \frac{M}{d}\right) \cdot \frac{h}{d}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(M \cdot \left(\left(h \cdot M\right) \cdot \left(D \cdot \frac{D}{d \cdot d}\right)\right)\right)\\ \end{array} \]
Alternative 4
Error21.4
Cost1225
\[\begin{array}{l} \mathbf{if}\;h \leq -1.3 \cdot 10^{-170} \lor \neg \left(h \leq 6.5 \cdot 10^{+40}\right):\\ \;\;\;\;0.25 \cdot \left(\frac{D}{\frac{d}{h}} \cdot \left(M \cdot \frac{D}{\frac{d}{M}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(\frac{D}{d} \cdot \left(D \cdot \left(M \cdot \frac{h \cdot M}{d}\right)\right)\right)\\ \end{array} \]
Alternative 5
Error18.7
Cost1225
\[\begin{array}{l} \mathbf{if}\;d \leq -6.6 \cdot 10^{-218} \lor \neg \left(d \leq 5.3 \cdot 10^{-77}\right):\\ \;\;\;\;\frac{0.25}{d} \cdot \left(\left(D \cdot M\right) \cdot \frac{h}{\frac{d}{D \cdot M}}\right)\\ \mathbf{else}:\\ \;\;\;\;0.25 \cdot \left(\frac{D}{d} \cdot \left(D \cdot \left(M \cdot \frac{h \cdot M}{d}\right)\right)\right)\\ \end{array} \]
Alternative 6
Error21.8
Cost1224
\[\begin{array}{l} \mathbf{if}\;h \leq -1.45 \cdot 10^{-170}:\\ \;\;\;\;0.25 \cdot \left(\frac{D}{\frac{d}{h}} \cdot \left(M \cdot \frac{D}{\frac{d}{M}}\right)\right)\\ \mathbf{elif}\;h \leq 1.9 \cdot 10^{+41}:\\ \;\;\;\;0.25 \cdot \left(\frac{D}{d} \cdot \left(D \cdot \left(M \cdot \frac{h \cdot M}{d}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.25}{d} \cdot \left(\frac{h}{\frac{d}{D}} \cdot \left(M \cdot \left(D \cdot M\right)\right)\right)\\ \end{array} \]
Alternative 7
Error25.4
Cost960
\[0.25 \cdot \left(D \cdot \left(D \cdot \left(\left(M \cdot \frac{M}{d}\right) \cdot \frac{h}{d}\right)\right)\right) \]
Alternative 8
Error23.0
Cost960
\[0.25 \cdot \left(\frac{D}{d} \cdot \left(D \cdot \left(M \cdot \frac{h \cdot M}{d}\right)\right)\right) \]
Alternative 9
Error31.8
Cost64
\[0 \]

Error

Reproduce?

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