| Alternative 1 | |
|---|---|
| Error | 16.9 |
| Cost | 43148 |
(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 (* (/ d D) (sqrt (* 2.0 (/ c0 (* w h))))))
(t_1 (/ c0 (* 2.0 w)))
(t_2 (/ (* c0 (* d d)) (* (* w h) (* D D))))
(t_3 (* t_1 (+ t_2 (sqrt (- (* t_2 t_2) (* M M)))))))
(if (<= t_3 -1e-175)
(* t_1 (* 2.0 (/ (/ d D) (* (* h (/ w c0)) (/ D d)))))
(if (<= t_3 0.0)
(* 0.25 (* (/ M (* (/ d D) (/ d D))) (* h M)))
(if (<= t_3 INFINITY)
(/ (* t_0 (/ c0 (/ w t_0))) 2.0)
(* 0.25 (/ (* (/ D d) (* h M)) (/ (/ d D) M))))))))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 = (d / D) * sqrt((2.0 * (c0 / (w * h))));
double t_1 = c0 / (2.0 * w);
double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_3 = t_1 * (t_2 + sqrt(((t_2 * t_2) - (M * M))));
double tmp;
if (t_3 <= -1e-175) {
tmp = t_1 * (2.0 * ((d / D) / ((h * (w / c0)) * (D / d))));
} else if (t_3 <= 0.0) {
tmp = 0.25 * ((M / ((d / D) * (d / D))) * (h * M));
} else if (t_3 <= ((double) INFINITY)) {
tmp = (t_0 * (c0 / (w / t_0))) / 2.0;
} else {
tmp = 0.25 * (((D / d) * (h * M)) / ((d / D) / M));
}
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 = (d / D) * Math.sqrt((2.0 * (c0 / (w * h))));
double t_1 = c0 / (2.0 * w);
double t_2 = (c0 * (d * d)) / ((w * h) * (D * D));
double t_3 = t_1 * (t_2 + Math.sqrt(((t_2 * t_2) - (M * M))));
double tmp;
if (t_3 <= -1e-175) {
tmp = t_1 * (2.0 * ((d / D) / ((h * (w / c0)) * (D / d))));
} else if (t_3 <= 0.0) {
tmp = 0.25 * ((M / ((d / D) * (d / D))) * (h * M));
} else if (t_3 <= Double.POSITIVE_INFINITY) {
tmp = (t_0 * (c0 / (w / t_0))) / 2.0;
} else {
tmp = 0.25 * (((D / d) * (h * M)) / ((d / D) / M));
}
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 = (d / D) * math.sqrt((2.0 * (c0 / (w * h)))) t_1 = c0 / (2.0 * w) t_2 = (c0 * (d * d)) / ((w * h) * (D * D)) t_3 = t_1 * (t_2 + math.sqrt(((t_2 * t_2) - (M * M)))) tmp = 0 if t_3 <= -1e-175: tmp = t_1 * (2.0 * ((d / D) / ((h * (w / c0)) * (D / d)))) elif t_3 <= 0.0: tmp = 0.25 * ((M / ((d / D) * (d / D))) * (h * M)) elif t_3 <= math.inf: tmp = (t_0 * (c0 / (w / t_0))) / 2.0 else: tmp = 0.25 * (((D / d) * (h * M)) / ((d / D) / M)) 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(d / D) * sqrt(Float64(2.0 * Float64(c0 / Float64(w * h))))) t_1 = Float64(c0 / Float64(2.0 * w)) t_2 = Float64(Float64(c0 * Float64(d * d)) / Float64(Float64(w * h) * Float64(D * D))) t_3 = Float64(t_1 * Float64(t_2 + sqrt(Float64(Float64(t_2 * t_2) - Float64(M * M))))) tmp = 0.0 if (t_3 <= -1e-175) tmp = Float64(t_1 * Float64(2.0 * Float64(Float64(d / D) / Float64(Float64(h * Float64(w / c0)) * Float64(D / d))))); elseif (t_3 <= 0.0) tmp = Float64(0.25 * Float64(Float64(M / Float64(Float64(d / D) * Float64(d / D))) * Float64(h * M))); elseif (t_3 <= Inf) tmp = Float64(Float64(t_0 * Float64(c0 / Float64(w / t_0))) / 2.0); else tmp = Float64(0.25 * Float64(Float64(Float64(D / d) * Float64(h * M)) / Float64(Float64(d / D) / M))); 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 = (d / D) * sqrt((2.0 * (c0 / (w * h)))); t_1 = c0 / (2.0 * w); t_2 = (c0 * (d * d)) / ((w * h) * (D * D)); t_3 = t_1 * (t_2 + sqrt(((t_2 * t_2) - (M * M)))); tmp = 0.0; if (t_3 <= -1e-175) tmp = t_1 * (2.0 * ((d / D) / ((h * (w / c0)) * (D / d)))); elseif (t_3 <= 0.0) tmp = 0.25 * ((M / ((d / D) * (d / D))) * (h * M)); elseif (t_3 <= Inf) tmp = (t_0 * (c0 / (w / t_0))) / 2.0; else tmp = 0.25 * (((D / d) * (h * M)) / ((d / D) / M)); 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[(d / D), $MachinePrecision] * N[Sqrt[N[(2.0 * N[(c0 / N[(w * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c0 / N[(2.0 * 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[(t$95$1 * 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, -1e-175], N[(t$95$1 * N[(2.0 * N[(N[(d / D), $MachinePrecision] / N[(N[(h * N[(w / c0), $MachinePrecision]), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.0], N[(0.25 * N[(N[(M / N[(N[(d / D), $MachinePrecision] * N[(d / D), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(h * M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[(t$95$0 * N[(c0 / N[(w / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[(0.25 * N[(N[(N[(D / d), $MachinePrecision] * N[(h * M), $MachinePrecision]), $MachinePrecision] / N[(N[(d / D), $MachinePrecision] / M), $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{d}{D} \cdot \sqrt{2 \cdot \frac{c0}{w \cdot h}}\\
t_1 := \frac{c0}{2 \cdot w}\\
t_2 := \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)}\\
t_3 := t_1 \cdot \left(t_2 + \sqrt{t_2 \cdot t_2 - M \cdot M}\right)\\
\mathbf{if}\;t_3 \leq -1 \cdot 10^{-175}:\\
\;\;\;\;t_1 \cdot \left(2 \cdot \frac{\frac{d}{D}}{\left(h \cdot \frac{w}{c0}\right) \cdot \frac{D}{d}}\right)\\
\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;0.25 \cdot \left(\frac{M}{\frac{d}{D} \cdot \frac{d}{D}} \cdot \left(h \cdot M\right)\right)\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\frac{t_0 \cdot \frac{c0}{\frac{w}{t_0}}}{2}\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{\frac{D}{d} \cdot \left(h \cdot M\right)}{\frac{\frac{d}{D}}{M}}\\
\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))))) < -1e-175Initial program 50.7
Simplified47.8
[Start]50.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)
\] |
|---|---|
times-frac [=>]52.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-def [=>]52.7 | \[ \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \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)}
\] |
associate-/r* [=>]52.7 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\color{blue}{\frac{\frac{c0}{w}}{h}}, \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)
\] |
times-frac [=>]52.8 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{\frac{c0}{w}}{h}, \color{blue}{\frac{d}{D} \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)
\] |
difference-of-squares [=>]52.8 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{\frac{c0}{w}}{h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + M\right) \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M\right)}}\right)
\] |
sub-neg [=>]52.8 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{\frac{c0}{w}}{h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + M\right) \cdot \color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \left(-M\right)\right)}}\right)
\] |
Taylor expanded in c0 around inf 43.9
Simplified37.8
[Start]43.9 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)}\right)
\] |
|---|---|
times-frac [=>]43.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\left(\frac{{d}^{2}}{{D}^{2}} \cdot \frac{c0}{w \cdot h}\right)}\right)
\] |
*-commutative [=>]43.6 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{{d}^{2}}{{D}^{2}} \cdot \frac{c0}{\color{blue}{h \cdot w}}\right)\right)
\] |
associate-/l/ [<=]42.8 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{{d}^{2}}{{D}^{2}} \cdot \color{blue}{\frac{\frac{c0}{w}}{h}}\right)\right)
\] |
associate-*l/ [=>]42.3 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{{d}^{2} \cdot \frac{\frac{c0}{w}}{h}}{{D}^{2}}}\right)
\] |
unpow2 [=>]42.3 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\color{blue}{\left(d \cdot d\right)} \cdot \frac{\frac{c0}{w}}{h}}{{D}^{2}}\right)
\] |
unpow2 [=>]42.3 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\left(d \cdot d\right) \cdot \frac{\frac{c0}{w}}{h}}{\color{blue}{D \cdot D}}\right)
\] |
*-commutative [<=]42.3 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\color{blue}{\frac{\frac{c0}{w}}{h} \cdot \left(d \cdot d\right)}}{D \cdot D}\right)
\] |
times-frac [=>]36.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\left(\frac{\frac{\frac{c0}{w}}{h}}{D} \cdot \frac{d \cdot d}{D}\right)}\right)
\] |
associate-*l/ [<=]35.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{\frac{c0}{w}}{h}}{D} \cdot \color{blue}{\left(\frac{d}{D} \cdot d\right)}\right)\right)
\] |
associate-/r/ [<=]35.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{\frac{c0}{w}}{h}}{D} \cdot \color{blue}{\frac{d}{\frac{D}{d}}}\right)\right)
\] |
associate-*l/ [=>]35.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{\frac{\frac{c0}{w}}{h} \cdot \frac{d}{\frac{D}{d}}}{D}}\right)
\] |
associate-*r/ [<=]38.2 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\left(\frac{\frac{c0}{w}}{h} \cdot \frac{\frac{d}{\frac{D}{d}}}{D}\right)}\right)
\] |
associate-/l/ [=>]39.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\color{blue}{\frac{c0}{h \cdot w}} \cdot \frac{\frac{d}{\frac{D}{d}}}{D}\right)\right)
\] |
*-commutative [<=]39.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{\color{blue}{w \cdot h}} \cdot \frac{\frac{d}{\frac{D}{d}}}{D}\right)\right)
\] |
associate-/r/ [=>]39.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{\color{blue}{\frac{d}{D} \cdot d}}{D}\right)\right)
\] |
associate-*r/ [<=]37.8 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w \cdot h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right)\right)
\] |
unpow2 [<=]37.8 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w \cdot h} \cdot \color{blue}{{\left(\frac{d}{D}\right)}^{2}}\right)\right)
\] |
Applied egg-rr30.7
if -1e-175 < (*.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 29.3
Simplified54.9
[Start]29.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)
\] |
|---|---|
associate-*l/ [<=]34.5 | \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\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)
\] |
*-commutative [=>]34.5 | \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(d \cdot d\right) \cdot \frac{c0}{\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)
\] |
fma-def [=>]42.7 | \[ \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot d, \frac{c0}{\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)}
\] |
associate-*l* [=>]45.1 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{c0}{\color{blue}{w \cdot \left(h \cdot \left(D \cdot D\right)\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)
\] |
associate-/r* [=>]45.5 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \color{blue}{\frac{\frac{c0}{w}}{h \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)
\] |
associate-*r* [=>]46.2 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{\frac{c0}{w}}{\color{blue}{\left(h \cdot D\right) \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)
\] |
*-commutative [=>]46.2 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{\frac{c0}{w}}{\color{blue}{D \cdot \left(h \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)
\] |
Taylor expanded in c0 around -inf 29.0
Simplified23.0
[Start]29.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 [=>]29.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)}
\] |
Taylor expanded in c0 around 0 24.9
Simplified23.6
[Start]24.9 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}
\] |
|---|---|
unpow2 [=>]24.9 | \[ 0.25 \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}
\] |
unpow2 [=>]24.9 | \[ 0.25 \cdot \frac{\left(D \cdot D\right) \cdot \left(\color{blue}{\left(M \cdot M\right)} \cdot h\right)}{{d}^{2}}
\] |
associate-*r* [<=]23.6 | \[ 0.25 \cdot \frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot \left(M \cdot h\right)\right)}}{{d}^{2}}
\] |
*-commutative [<=]23.6 | \[ 0.25 \cdot \frac{\color{blue}{\left(M \cdot \left(M \cdot h\right)\right) \cdot \left(D \cdot D\right)}}{{d}^{2}}
\] |
unpow2 [=>]23.6 | \[ 0.25 \cdot \frac{\left(M \cdot \left(M \cdot h\right)\right) \cdot \left(D \cdot D\right)}{\color{blue}{d \cdot d}}
\] |
Applied egg-rr17.5
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.2
Simplified44.6
[Start]47.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 [=>]49.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-def [=>]49.6 | \[ \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(\frac{c0}{w \cdot h}, \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)}
\] |
associate-/r* [=>]49.6 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\color{blue}{\frac{\frac{c0}{w}}{h}}, \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)
\] |
times-frac [=>]49.6 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{\frac{c0}{w}}{h}, \color{blue}{\frac{d}{D} \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)
\] |
difference-of-squares [=>]49.6 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{\frac{c0}{w}}{h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + M\right) \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M\right)}}\right)
\] |
sub-neg [=>]49.6 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(\frac{\frac{c0}{w}}{h}, \frac{d}{D} \cdot \frac{d}{D}, \sqrt{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + M\right) \cdot \color{blue}{\left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \left(-M\right)\right)}}\right)
\] |
Taylor expanded in c0 around inf 41.4
Simplified35.1
[Start]41.4 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{{d}^{2} \cdot c0}{{D}^{2} \cdot \left(w \cdot h\right)}\right)
\] |
|---|---|
times-frac [=>]41.8 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\left(\frac{{d}^{2}}{{D}^{2}} \cdot \frac{c0}{w \cdot h}\right)}\right)
\] |
*-commutative [=>]41.8 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{{d}^{2}}{{D}^{2}} \cdot \frac{c0}{\color{blue}{h \cdot w}}\right)\right)
\] |
associate-/l/ [<=]40.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{{d}^{2}}{{D}^{2}} \cdot \color{blue}{\frac{\frac{c0}{w}}{h}}\right)\right)
\] |
associate-*l/ [=>]38.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{{d}^{2} \cdot \frac{\frac{c0}{w}}{h}}{{D}^{2}}}\right)
\] |
unpow2 [=>]38.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\color{blue}{\left(d \cdot d\right)} \cdot \frac{\frac{c0}{w}}{h}}{{D}^{2}}\right)
\] |
unpow2 [=>]38.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\left(d \cdot d\right) \cdot \frac{\frac{c0}{w}}{h}}{\color{blue}{D \cdot D}}\right)
\] |
*-commutative [<=]38.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \frac{\color{blue}{\frac{\frac{c0}{w}}{h} \cdot \left(d \cdot d\right)}}{D \cdot D}\right)
\] |
times-frac [=>]33.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\left(\frac{\frac{\frac{c0}{w}}{h}}{D} \cdot \frac{d \cdot d}{D}\right)}\right)
\] |
associate-*l/ [<=]30.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{\frac{c0}{w}}{h}}{D} \cdot \color{blue}{\left(\frac{d}{D} \cdot d\right)}\right)\right)
\] |
associate-/r/ [<=]30.7 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{\frac{\frac{c0}{w}}{h}}{D} \cdot \color{blue}{\frac{d}{\frac{D}{d}}}\right)\right)
\] |
associate-*l/ [=>]30.5 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\frac{\frac{\frac{c0}{w}}{h} \cdot \frac{d}{\frac{D}{d}}}{D}}\right)
\] |
associate-*r/ [<=]34.4 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \color{blue}{\left(\frac{\frac{c0}{w}}{h} \cdot \frac{\frac{d}{\frac{D}{d}}}{D}\right)}\right)
\] |
associate-/l/ [=>]36.3 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\color{blue}{\frac{c0}{h \cdot w}} \cdot \frac{\frac{d}{\frac{D}{d}}}{D}\right)\right)
\] |
*-commutative [<=]36.3 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{\color{blue}{w \cdot h}} \cdot \frac{\frac{d}{\frac{D}{d}}}{D}\right)\right)
\] |
associate-/r/ [=>]36.3 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w \cdot h} \cdot \frac{\color{blue}{\frac{d}{D} \cdot d}}{D}\right)\right)
\] |
associate-*r/ [<=]35.1 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w \cdot h} \cdot \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)}\right)\right)
\] |
unpow2 [<=]35.1 | \[ \frac{c0}{2 \cdot w} \cdot \left(2 \cdot \left(\frac{c0}{w \cdot h} \cdot \color{blue}{{\left(\frac{d}{D}\right)}^{2}}\right)\right)
\] |
Applied egg-rr38.1
Applied egg-rr23.3
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.7
[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)
\] |
|---|---|
associate-*l/ [<=]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\frac{c0}{\left(w \cdot h\right) \cdot \left(D \cdot D\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)
\] |
*-commutative [=>]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \left(\color{blue}{\left(d \cdot d\right) \cdot \frac{c0}{\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)
\] |
fma-def [=>]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \color{blue}{\mathsf{fma}\left(d \cdot d, \frac{c0}{\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)}
\] |
associate-*l* [=>]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{c0}{\color{blue}{w \cdot \left(h \cdot \left(D \cdot D\right)\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)
\] |
associate-/r* [=>]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \color{blue}{\frac{\frac{c0}{w}}{h \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)
\] |
associate-*r* [=>]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{\frac{c0}{w}}{\color{blue}{\left(h \cdot D\right) \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)
\] |
*-commutative [=>]64.0 | \[ \frac{c0}{2 \cdot w} \cdot \mathsf{fma}\left(d \cdot d, \frac{\frac{c0}{w}}{\color{blue}{D \cdot \left(h \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)
\] |
Taylor expanded in c0 around -inf 62.7
Simplified32.9
[Start]62.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 [=>]62.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 34.0
Simplified23.7
[Start]34.0 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \left({M}^{2} \cdot h\right)}{{d}^{2}}
\] |
|---|---|
*-commutative [<=]34.0 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \color{blue}{\left(h \cdot {M}^{2}\right)}}{{d}^{2}}
\] |
associate-/l* [=>]34.0 | \[ 0.25 \cdot \color{blue}{\frac{{D}^{2}}{\frac{{d}^{2}}{h \cdot {M}^{2}}}}
\] |
unpow2 [=>]34.0 | \[ 0.25 \cdot \frac{\color{blue}{D \cdot D}}{\frac{{d}^{2}}{h \cdot {M}^{2}}}
\] |
unpow2 [=>]34.0 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{\color{blue}{d \cdot d}}{h \cdot {M}^{2}}}
\] |
*-commutative [=>]34.0 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{{M}^{2} \cdot h}}}
\] |
unpow2 [=>]34.0 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{\left(M \cdot M\right)} \cdot h}}
\] |
associate-*r* [<=]32.0 | \[ 0.25 \cdot \frac{D \cdot D}{\frac{d \cdot d}{\color{blue}{M \cdot \left(M \cdot h\right)}}}
\] |
associate-/r/ [=>]31.9 | \[ 0.25 \cdot \color{blue}{\left(\frac{D \cdot D}{d \cdot d} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)}
\] |
associate-/r* [=>]28.6 | \[ 0.25 \cdot \left(\color{blue}{\frac{\frac{D \cdot D}{d}}{d}} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)
\] |
associate-*r/ [<=]23.7 | \[ 0.25 \cdot \left(\frac{\color{blue}{D \cdot \frac{D}{d}}}{d} \cdot \left(M \cdot \left(M \cdot h\right)\right)\right)
\] |
Applied egg-rr22.2
Applied egg-rr14.7
Final simplification16.4
| Alternative 1 | |
|---|---|
| Error | 16.9 |
| Cost | 43148 |
| Alternative 2 | |
|---|---|
| Error | 16.6 |
| Cost | 30540 |
| Alternative 3 | |
|---|---|
| Error | 18.3 |
| Cost | 1740 |
| Alternative 4 | |
|---|---|
| Error | 20.2 |
| Cost | 1224 |
| Alternative 5 | |
|---|---|
| Error | 19.8 |
| Cost | 1092 |
| Alternative 6 | |
|---|---|
| Error | 19.2 |
| Cost | 1092 |
| Alternative 7 | |
|---|---|
| Error | 19.2 |
| Cost | 1092 |
| Alternative 8 | |
|---|---|
| Error | 19.9 |
| Cost | 960 |
| Alternative 9 | |
|---|---|
| Error | 32.1 |
| Cost | 64 |
herbie shell --seed 2023047
(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))))))