| Alternative 1 | |
|---|---|
| Error | 17.6 |
| Cost | 1865 |
(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 (* w (/ h d)))))
(t_1 (* c0 (/ 0.5 w)))
(t_2 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_3 (* (/ c0 (* 2.0 w)) (+ t_2 (sqrt (- (* t_2 t_2) (* M M)))))))
(if (<= t_3 -5e+52)
(* (* (/ d D) (+ t_0 t_0)) t_1)
(if (<= t_3 0.0)
(* 0.25 (* (/ (* h M) (/ d D)) (* D (/ M d))))
(if (<= t_3 INFINITY)
(* 2.0 (/ (* (/ d D) t_1) (* (/ h d) (* w (/ D c0)))))
(* 0.25 (* (* h (* M (/ D d))) (/ M (/ d D)))))))))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 * (w * (h / d)));
double t_1 = c0 * (0.5 / w);
double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_3 = (c0 / (2.0 * w)) * (t_2 + sqrt(((t_2 * t_2) - (M * M))));
double tmp;
if (t_3 <= -5e+52) {
tmp = ((d / D) * (t_0 + t_0)) * t_1;
} else if (t_3 <= 0.0) {
tmp = 0.25 * (((h * M) / (d / D)) * (D * (M / d)));
} else if (t_3 <= ((double) INFINITY)) {
tmp = 2.0 * (((d / D) * t_1) / ((h / d) * (w * (D / c0))));
} else {
tmp = 0.25 * ((h * (M * (D / d))) * (M / (d / D)));
}
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 * (w * (h / d)));
double t_1 = c0 * (0.5 / w);
double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_3 = (c0 / (2.0 * w)) * (t_2 + Math.sqrt(((t_2 * t_2) - (M * M))));
double tmp;
if (t_3 <= -5e+52) {
tmp = ((d / D) * (t_0 + t_0)) * t_1;
} else if (t_3 <= 0.0) {
tmp = 0.25 * (((h * M) / (d / D)) * (D * (M / d)));
} else if (t_3 <= Double.POSITIVE_INFINITY) {
tmp = 2.0 * (((d / D) * t_1) / ((h / d) * (w * (D / c0))));
} else {
tmp = 0.25 * ((h * (M * (D / d))) * (M / (d / D)));
}
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 * (w * (h / d))) t_1 = c0 * (0.5 / w) t_2 = (c0 * (d * d)) / ((w * h) * (D * D)) t_3 = (c0 / (2.0 * w)) * (t_2 + math.sqrt(((t_2 * t_2) - (M * M)))) tmp = 0 if t_3 <= -5e+52: tmp = ((d / D) * (t_0 + t_0)) * t_1 elif t_3 <= 0.0: tmp = 0.25 * (((h * M) / (d / D)) * (D * (M / d))) elif t_3 <= math.inf: tmp = 2.0 * (((d / D) * t_1) / ((h / d) * (w * (D / c0)))) else: tmp = 0.25 * ((h * (M * (D / d))) * (M / (d / D))) 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(c0 / Float64(D * Float64(w * Float64(h / d)))) t_1 = Float64(c0 * Float64(0.5 / w)) t_2 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) t_3 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_2 + sqrt(Float64(Float64(t_2 * t_2) - Float64(M * M))))) tmp = 0.0 if (t_3 <= -5e+52) tmp = Float64(Float64(Float64(d / D) * Float64(t_0 + t_0)) * t_1); elseif (t_3 <= 0.0) tmp = Float64(0.25 * Float64(Float64(Float64(h * M) / Float64(d / D)) * Float64(D * Float64(M / d)))); elseif (t_3 <= Inf) tmp = Float64(2.0 * Float64(Float64(Float64(d / D) * t_1) / Float64(Float64(h / d) * Float64(w * Float64(D / c0))))); else tmp = Float64(0.25 * Float64(Float64(h * Float64(M * Float64(D / d))) * Float64(M / Float64(d / D)))); 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 * (w * (h / d))); t_1 = c0 * (0.5 / w); t_2 = (c0 * (d * d)) / ((w * h) * (D * D)); t_3 = (c0 / (2.0 * w)) * (t_2 + sqrt(((t_2 * t_2) - (M * M)))); tmp = 0.0; if (t_3 <= -5e+52) tmp = ((d / D) * (t_0 + t_0)) * t_1; elseif (t_3 <= 0.0) tmp = 0.25 * (((h * M) / (d / D)) * (D * (M / d))); elseif (t_3 <= Inf) tmp = 2.0 * (((d / D) * t_1) / ((h / d) * (w * (D / c0)))); else tmp = 0.25 * ((h * (M * (D / d))) * (M / (d / D))); 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[(c0 / N[(D * N[(w * N[(h / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 * N[(0.5 / w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c0 * N[(d * d), $MachinePrecision]), $MachinePrecision] / N[(N[(w * h), $MachinePrecision] * N[(D * D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(c0 / N[(2.0 * w), $MachinePrecision]), $MachinePrecision] * N[(t$95$2 + N[Sqrt[N[(N[(t$95$2 * t$95$2), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -5e+52], N[(N[(N[(d / D), $MachinePrecision] * N[(t$95$0 + t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$3, 0.0], N[(0.25 * N[(N[(N[(h * M), $MachinePrecision] / N[(d / D), $MachinePrecision]), $MachinePrecision] * N[(D * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(2.0 * N[(N[(N[(d / D), $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[(h / d), $MachinePrecision] * N[(w * N[(D / c0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.25 * N[(N[(h * N[(M * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(M / N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}{D \cdot \left(w \cdot \frac{h}{d}\right)}\\
t_1 := c0 \cdot \frac{0.5}{w}\\
t_2 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_3 := \frac{c0}{2 \cdot w} \cdot \left(t_2 + \sqrt{t_2 \cdot t_2 - M \cdot M}\right)\\
\mathbf{if}\;t_3 \leq -5 \cdot 10^{+52}:\\
\;\;\;\;\left(\frac{d}{D} \cdot \left(t_0 + t_0\right)\right) \cdot t_1\\
\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;0.25 \cdot \left(\frac{h \cdot M}{\frac{d}{D}} \cdot \left(D \cdot \frac{M}{d}\right)\right)\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;2 \cdot \frac{\frac{d}{D} \cdot t_1}{\frac{h}{d} \cdot \left(w \cdot \frac{D}{c0}\right)}\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\left(h \cdot \left(M \cdot \frac{D}{d}\right)\right) \cdot \frac{M}{\frac{d}{D}}\right)\\
\end{array}
Results
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))))) < -5e52Initial program 55.6
Simplified55.0
[Start]55.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)
\] |
|---|---|
times-frac [=>]56.3 | \[ \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 [=>]56.3 | \[ \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 [=>]56.3 | \[ \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 [=>]55.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)
\] |
Taylor expanded in c0 around inf 52.1
Simplified50.6
[Start]52.1 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)}\right)
\] |
|---|---|
*-commutative [=>]52.1 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \frac{\color{blue}{c0 \cdot {d}^{2}}}{{D}^{2} \cdot \left(w \cdot h\right)}\right)
\] |
unpow2 [=>]52.1 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{{D}^{2} \cdot \left(w \cdot h\right)}\right)
\] |
*-commutative [=>]52.1 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \frac{c0 \cdot \left(d \cdot d\right)}{\color{blue}{\left(w \cdot h\right) \cdot {D}^{2}}}\right)
\] |
unpow2 [=>]52.1 | \[ \frac{c0}{2 \cdot w} \cdot \left(\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 \color{blue}{\left(D \cdot D\right)}}\right)
\] |
associate-/r* [=>]50.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \color{blue}{\frac{\frac{c0 \cdot \left(d \cdot d\right)}{w \cdot h}}{D \cdot D}}\right)
\] |
Applied egg-rr51.8
Applied egg-rr49.8
Simplified35.9
[Start]49.8 | \[ c0 \cdot \left(\frac{0.5}{w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\right) + c0 \cdot \left(\frac{0.5}{w} \cdot \frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}}\right)
\] |
|---|---|
associate-*r* [=>]49.8 | \[ \color{blue}{\left(c0 \cdot \frac{0.5}{w}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)} + c0 \cdot \left(\frac{0.5}{w} \cdot \frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}}\right)
\] |
associate-*r* [=>]48.0 | \[ \left(c0 \cdot \frac{0.5}{w}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right) + \color{blue}{\left(c0 \cdot \frac{0.5}{w}\right) \cdot \frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}}}
\] |
distribute-lft-in [<=]48.0 | \[ \color{blue}{\left(c0 \cdot \frac{0.5}{w}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}}\right)}
\] |
fma-udef [<=]48.0 | \[ \left(c0 \cdot \frac{0.5}{w}\right) \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}}\right)}
\] |
*-commutative [=>]48.0 | \[ \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \frac{d}{D} \cdot \frac{d}{D}, \frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}}\right) \cdot \left(c0 \cdot \frac{0.5}{w}\right)}
\] |
if -5e52 < (*.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.0Initial program 28.5
Simplified33.5
[Start]28.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)
\] |
|---|---|
times-frac [=>]39.4 | \[ \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 [=>]39.4 | \[ \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 [=>]37.2 | \[ \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 [=>]33.5 | \[ \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)
\] |
Taylor expanded in c0 around -inf 32.7
Simplified34.0
[Start]32.7 | \[ \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 [=>]32.7 | \[ \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)}
\] |
Taylor expanded in c0 around 0 28.6
Simplified23.6
[Start]28.6 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{{d}^{2}}
\] |
|---|---|
*-commutative [=>]28.6 | \[ 0.25 \cdot \frac{\color{blue}{\left(h \cdot {M}^{2}\right) \cdot {D}^{2}}}{{d}^{2}}
\] |
unpow2 [=>]28.6 | \[ 0.25 \cdot \frac{\left(h \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot {D}^{2}}{{d}^{2}}
\] |
associate-/l* [=>]28.5 | \[ 0.25 \cdot \color{blue}{\frac{h \cdot \left(M \cdot M\right)}{\frac{{d}^{2}}{{D}^{2}}}}
\] |
associate-*r* [=>]26.7 | \[ 0.25 \cdot \frac{\color{blue}{\left(h \cdot M\right) \cdot M}}{\frac{{d}^{2}}{{D}^{2}}}
\] |
*-commutative [=>]26.7 | \[ 0.25 \cdot \frac{\color{blue}{M \cdot \left(h \cdot M\right)}}{\frac{{d}^{2}}{{D}^{2}}}
\] |
unpow2 [=>]26.7 | \[ 0.25 \cdot \frac{M \cdot \left(h \cdot M\right)}{\frac{\color{blue}{d \cdot d}}{{D}^{2}}}
\] |
unpow2 [=>]26.7 | \[ 0.25 \cdot \frac{M \cdot \left(h \cdot M\right)}{\frac{d \cdot d}{\color{blue}{D \cdot D}}}
\] |
times-frac [=>]23.6 | \[ 0.25 \cdot \frac{M \cdot \left(h \cdot M\right)}{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}
\] |
unpow2 [<=]23.6 | \[ 0.25 \cdot \frac{M \cdot \left(h \cdot M\right)}{\color{blue}{{\left(\frac{d}{D}\right)}^{2}}}
\] |
Applied egg-rr17.2
Applied egg-rr17.7
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.0Initial program 47.0
Simplified46.9
[Start]47.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 [=>]48.4 | \[ \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 [=>]48.4 | \[ \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 [=>]48.4 | \[ \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 [=>]46.9 | \[ \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)
\] |
Taylor expanded in c0 around inf 44.6
Simplified44.3
[Start]44.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)}\right)
\] |
|---|---|
*-commutative [=>]44.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \frac{\color{blue}{c0 \cdot {d}^{2}}}{{D}^{2} \cdot \left(w \cdot h\right)}\right)
\] |
unpow2 [=>]44.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \frac{c0 \cdot \color{blue}{\left(d \cdot d\right)}}{{D}^{2} \cdot \left(w \cdot h\right)}\right)
\] |
*-commutative [=>]44.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \frac{c0 \cdot \left(d \cdot d\right)}{\color{blue}{\left(w \cdot h\right) \cdot {D}^{2}}}\right)
\] |
unpow2 [=>]44.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(\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 \color{blue}{\left(D \cdot D\right)}}\right)
\] |
associate-/r* [=>]44.3 | \[ \frac{c0}{2 \cdot w} \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{d \cdot d}{D \cdot D} + \color{blue}{\frac{\frac{c0 \cdot \left(d \cdot d\right)}{w \cdot h}}{D \cdot D}}\right)
\] |
Applied egg-rr44.5
Applied egg-rr43.9
Simplified25.9
[Start]43.9 | \[ c0 \cdot \left(\frac{0.5}{w} \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)\right) + c0 \cdot \left(\frac{0.5}{w} \cdot \frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}}\right)
\] |
|---|---|
associate-*r* [=>]43.9 | \[ \color{blue}{\left(c0 \cdot \frac{0.5}{w}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)} + c0 \cdot \left(\frac{0.5}{w} \cdot \frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}}\right)
\] |
associate-*r* [=>]41.7 | \[ \left(c0 \cdot \frac{0.5}{w}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right) + \color{blue}{\left(c0 \cdot \frac{0.5}{w}\right) \cdot \frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}}}
\] |
distribute-lft-in [<=]41.7 | \[ \color{blue}{\left(c0 \cdot \frac{0.5}{w}\right) \cdot \left(\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right) + \frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}}\right)}
\] |
+-commutative [=>]41.7 | \[ \left(c0 \cdot \frac{0.5}{w}\right) \cdot \color{blue}{\left(\frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}} + \frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot \frac{d}{D}\right)\right)}
\] |
associate-*r/ [=>]42.0 | \[ \left(c0 \cdot \frac{0.5}{w}\right) \cdot \left(\frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}} + \frac{c0}{w \cdot h} \cdot \color{blue}{\frac{\frac{d}{D} \cdot d}{D}}\right)
\] |
associate-*r/ [=>]40.9 | \[ \left(c0 \cdot \frac{0.5}{w}\right) \cdot \left(\frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}} + \color{blue}{\frac{\frac{c0}{w \cdot h} \cdot \left(\frac{d}{D} \cdot d\right)}{D}}\right)
\] |
associate-/r* [=>]39.9 | \[ \left(c0 \cdot \frac{0.5}{w}\right) \cdot \left(\frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}} + \frac{\color{blue}{\frac{\frac{c0}{w}}{h}} \cdot \left(\frac{d}{D} \cdot d\right)}{D}\right)
\] |
associate-/r/ [<=]38.8 | \[ \left(c0 \cdot \frac{0.5}{w}\right) \cdot \left(\frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}} + \frac{\color{blue}{\frac{\frac{c0}{w}}{\frac{h}{\frac{d}{D} \cdot d}}}}{D}\right)
\] |
associate-/l/ [<=]35.9 | \[ \left(c0 \cdot \frac{0.5}{w}\right) \cdot \left(\frac{\frac{c0}{w}}{D \cdot \frac{\frac{h}{d}}{\frac{d}{D}}} + \frac{\frac{\frac{c0}{w}}{\color{blue}{\frac{\frac{h}{d}}{\frac{d}{D}}}}}{D}\right)
\] |
if +inf.0 < (*.f64 (/.f64 c0 (*.f64 2 w)) (+.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (sqrt.f64 (-.f64 (*.f64 (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D))) (/.f64 (*.f64 c0 (*.f64 d d)) (*.f64 (*.f64 w h) (*.f64 D D)))) (*.f64 M M))))) Initial program 64.0
Simplified63.3
[Start]64.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 [=>]64.0 | \[ \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 [=>]64.0 | \[ \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 [=>]64.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(\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 [=>]63.3 | \[ \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)
\] |
Taylor expanded in c0 around -inf 63.1
Simplified57.4
[Start]63.1 | \[ \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 [=>]63.1 | \[ \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)}
\] |
Taylor expanded in c0 around 0 34.3
Simplified22.6
[Start]34.3 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{{d}^{2}}
\] |
|---|---|
*-commutative [=>]34.3 | \[ 0.25 \cdot \frac{\color{blue}{\left(h \cdot {M}^{2}\right) \cdot {D}^{2}}}{{d}^{2}}
\] |
unpow2 [=>]34.3 | \[ 0.25 \cdot \frac{\left(h \cdot \color{blue}{\left(M \cdot M\right)}\right) \cdot {D}^{2}}{{d}^{2}}
\] |
associate-/l* [=>]34.3 | \[ 0.25 \cdot \color{blue}{\frac{h \cdot \left(M \cdot M\right)}{\frac{{d}^{2}}{{D}^{2}}}}
\] |
associate-*r* [=>]32.3 | \[ 0.25 \cdot \frac{\color{blue}{\left(h \cdot M\right) \cdot M}}{\frac{{d}^{2}}{{D}^{2}}}
\] |
*-commutative [=>]32.3 | \[ 0.25 \cdot \frac{\color{blue}{M \cdot \left(h \cdot M\right)}}{\frac{{d}^{2}}{{D}^{2}}}
\] |
unpow2 [=>]32.3 | \[ 0.25 \cdot \frac{M \cdot \left(h \cdot M\right)}{\frac{\color{blue}{d \cdot d}}{{D}^{2}}}
\] |
unpow2 [=>]32.3 | \[ 0.25 \cdot \frac{M \cdot \left(h \cdot M\right)}{\frac{d \cdot d}{\color{blue}{D \cdot D}}}
\] |
times-frac [=>]22.6 | \[ 0.25 \cdot \frac{M \cdot \left(h \cdot M\right)}{\color{blue}{\frac{d}{D} \cdot \frac{d}{D}}}
\] |
unpow2 [<=]22.6 | \[ 0.25 \cdot \frac{M \cdot \left(h \cdot M\right)}{\color{blue}{{\left(\frac{d}{D}\right)}^{2}}}
\] |
Applied egg-rr15.1
Applied egg-rr12.2
Final simplification14.8
| Alternative 1 | |
|---|---|
| Error | 17.6 |
| Cost | 1865 |
| Alternative 2 | |
|---|---|
| Error | 18.1 |
| Cost | 1865 |
| Alternative 3 | |
|---|---|
| Error | 23.4 |
| Cost | 960 |
| Alternative 4 | |
|---|---|
| Error | 17.0 |
| Cost | 960 |
| Alternative 5 | |
|---|---|
| Error | 32.5 |
| Cost | 64 |
herbie shell --seed 2023066
(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))))))