| Alternative 1 | |
|---|---|
| Error | 20.8 |
| Cost | 38220 |
(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)) (* (* D D) (* w h))))
(t_1 (* (/ c0 (* 2.0 w)) (+ t_0 (sqrt (- (* t_0 t_0) (* M M))))))
(t_2 (* c0 (/ d D))))
(if (<= t_1 -4e-66)
(* t_2 (* t_2 (/ (/ 1.0 (* w h)) w)))
(if (<= t_1 0.0)
(* 0.25 (/ (* (* D M) (* D M)) (/ (* d d) h)))
(if (<= t_1 INFINITY)
(pow (cbrt (pow (* (/ d D) (/ c0 (* w (sqrt h)))) 2.0)) 3.0)
(* D (/ (* (* D -0.25) (* M (* h (/ 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 * d)) / ((D * D) * (w * h));
double t_1 = (c0 / (2.0 * w)) * (t_0 + sqrt(((t_0 * t_0) - (M * M))));
double t_2 = c0 * (d / D);
double tmp;
if (t_1 <= -4e-66) {
tmp = t_2 * (t_2 * ((1.0 / (w * h)) / w));
} else if (t_1 <= 0.0) {
tmp = 0.25 * (((D * M) * (D * M)) / ((d * d) / h));
} else if (t_1 <= ((double) INFINITY)) {
tmp = pow(cbrt(pow(((d / D) * (c0 / (w * sqrt(h)))), 2.0)), 3.0);
} else {
tmp = D * (((D * -0.25) * (M * (h * (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 * d)) / ((D * D) * (w * h));
double t_1 = (c0 / (2.0 * w)) * (t_0 + Math.sqrt(((t_0 * t_0) - (M * M))));
double t_2 = c0 * (d / D);
double tmp;
if (t_1 <= -4e-66) {
tmp = t_2 * (t_2 * ((1.0 / (w * h)) / w));
} else if (t_1 <= 0.0) {
tmp = 0.25 * (((D * M) * (D * M)) / ((d * d) / h));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = Math.pow(Math.cbrt(Math.pow(((d / D) * (c0 / (w * Math.sqrt(h)))), 2.0)), 3.0);
} else {
tmp = D * (((D * -0.25) * (M * (h * (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(Float64(c0 * Float64(d * d)) / Float64(Float64(D * D) * Float64(w * h))) t_1 = Float64(Float64(c0 / Float64(2.0 * w)) * Float64(t_0 + sqrt(Float64(Float64(t_0 * t_0) - Float64(M * M))))) t_2 = Float64(c0 * Float64(d / D)) tmp = 0.0 if (t_1 <= -4e-66) tmp = Float64(t_2 * Float64(t_2 * Float64(Float64(1.0 / Float64(w * h)) / w))); elseif (t_1 <= 0.0) tmp = Float64(0.25 * Float64(Float64(Float64(D * M) * Float64(D * M)) / Float64(Float64(d * d) / h))); elseif (t_1 <= Inf) tmp = cbrt((Float64(Float64(d / D) * Float64(c0 / Float64(w * sqrt(h)))) ^ 2.0)) ^ 3.0; else tmp = Float64(D * Float64(Float64(Float64(D * -0.25) * Float64(M * Float64(h * Float64(M / d)))) / Float64(-d))); end return 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[(D * D), $MachinePrecision] * N[(w * h), $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]}, Block[{t$95$2 = N[(c0 * N[(d / D), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-66], N[(t$95$2 * N[(t$95$2 * N[(N[(1.0 / N[(w * h), $MachinePrecision]), $MachinePrecision] / w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(0.25 * N[(N[(N[(D * M), $MachinePrecision] * N[(D * M), $MachinePrecision]), $MachinePrecision] / N[(N[(d * d), $MachinePrecision] / h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[Power[N[Power[N[Power[N[(N[(d / D), $MachinePrecision] * N[(c0 / N[(w * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision], N[(D * N[(N[(N[(D * -0.25), $MachinePrecision] * N[(M * N[(h * N[(M / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-d)), $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 \cdot \left(d \cdot d\right)}{\left(D \cdot D\right) \cdot \left(w \cdot h\right)}\\
t_1 := \frac{c0}{2 \cdot w} \cdot \left(t_0 + \sqrt{t_0 \cdot t_0 - M \cdot M}\right)\\
t_2 := c0 \cdot \frac{d}{D}\\
\mathbf{if}\;t_1 \leq -4 \cdot 10^{-66}:\\
\;\;\;\;t_2 \cdot \left(t_2 \cdot \frac{\frac{1}{w \cdot h}}{w}\right)\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;0.25 \cdot \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\frac{d \cdot d}{h}}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;{\left(\sqrt[3]{{\left(\frac{d}{D} \cdot \frac{c0}{w \cdot \sqrt{h}}\right)}^{2}}\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;D \cdot \frac{\left(D \cdot -0.25\right) \cdot \left(M \cdot \left(h \cdot \frac{M}{d}\right)\right)}{-d}\\
\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))))) < -3.9999999999999999e-66Initial program 53.7
Simplified54.5
[Start]53.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 [=>]55.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 [=>]55.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 [=>]55.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 [=>]54.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 55.4
Simplified53.9
[Start]55.4 | \[ \frac{{d}^{2} \cdot {c0}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)}
\] |
|---|---|
times-frac [=>]57.2 | \[ \color{blue}{\frac{{d}^{2}}{{D}^{2}} \cdot \frac{{c0}^{2}}{{w}^{2} \cdot h}}
\] |
unpow2 [=>]57.2 | \[ \frac{\color{blue}{d \cdot d}}{{D}^{2}} \cdot \frac{{c0}^{2}}{{w}^{2} \cdot h}
\] |
unpow2 [=>]57.2 | \[ \frac{d \cdot d}{\color{blue}{D \cdot D}} \cdot \frac{{c0}^{2}}{{w}^{2} \cdot h}
\] |
associate-/r* [=>]55.3 | \[ \color{blue}{\frac{\frac{d \cdot d}{D}}{D}} \cdot \frac{{c0}^{2}}{{w}^{2} \cdot h}
\] |
associate-*r/ [<=]54.6 | \[ \frac{\color{blue}{d \cdot \frac{d}{D}}}{D} \cdot \frac{{c0}^{2}}{{w}^{2} \cdot h}
\] |
associate-*l/ [<=]53.9 | \[ \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)} \cdot \frac{{c0}^{2}}{{w}^{2} \cdot h}
\] |
unpow2 [<=]53.9 | \[ \color{blue}{{\left(\frac{d}{D}\right)}^{2}} \cdot \frac{{c0}^{2}}{{w}^{2} \cdot h}
\] |
unpow2 [=>]53.9 | \[ {\left(\frac{d}{D}\right)}^{2} \cdot \frac{\color{blue}{c0 \cdot c0}}{{w}^{2} \cdot h}
\] |
*-commutative [=>]53.9 | \[ {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0 \cdot c0}{\color{blue}{h \cdot {w}^{2}}}
\] |
unpow2 [=>]53.9 | \[ {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0 \cdot c0}{h \cdot \color{blue}{\left(w \cdot w\right)}}
\] |
Applied egg-rr42.9
Simplified39.9
[Start]42.9 | \[ \frac{-{\left(\frac{d}{D} \cdot c0\right)}^{2}}{h \cdot \left(w \cdot \left(-w\right)\right)}
\] |
|---|---|
*-commutative [=>]42.9 | \[ \frac{-{\color{blue}{\left(c0 \cdot \frac{d}{D}\right)}}^{2}}{h \cdot \left(w \cdot \left(-w\right)\right)}
\] |
associate-*r* [=>]39.9 | \[ \frac{-{\left(c0 \cdot \frac{d}{D}\right)}^{2}}{\color{blue}{\left(h \cdot w\right) \cdot \left(-w\right)}}
\] |
*-commutative [=>]39.9 | \[ \frac{-{\left(c0 \cdot \frac{d}{D}\right)}^{2}}{\color{blue}{\left(w \cdot h\right)} \cdot \left(-w\right)}
\] |
Applied egg-rr33.0
if -3.9999999999999999e-66 < (*.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 23.1
Simplified50.4
[Start]23.1 | \[ \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/ [<=]29.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 [=>]29.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 [=>]37.6 | \[ \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)}
\] |
Taylor expanded in c0 around -inf 31.3
Simplified24.6
[Start]31.3 | \[ \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 [=>]31.3 | \[ \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)}
\] |
Applied egg-rr44.5
Simplified43.3
[Start]44.5 | \[ \frac{1}{\frac{w \cdot 2}{c0 \cdot \left(\frac{0.5}{c0} \cdot {\left(\frac{\sqrt{w \cdot h} \cdot M}{\frac{d}{D}}\right)}^{2}\right)}}
\] |
|---|---|
associate-/r/ [=>]44.5 | \[ \color{blue}{\frac{1}{w \cdot 2} \cdot \left(c0 \cdot \left(\frac{0.5}{c0} \cdot {\left(\frac{\sqrt{w \cdot h} \cdot M}{\frac{d}{D}}\right)}^{2}\right)\right)}
\] |
*-commutative [=>]44.5 | \[ \frac{1}{\color{blue}{2 \cdot w}} \cdot \left(c0 \cdot \left(\frac{0.5}{c0} \cdot {\left(\frac{\sqrt{w \cdot h} \cdot M}{\frac{d}{D}}\right)}^{2}\right)\right)
\] |
associate-*r* [=>]43.3 | \[ \frac{1}{2 \cdot w} \cdot \color{blue}{\left(\left(c0 \cdot \frac{0.5}{c0}\right) \cdot {\left(\frac{\sqrt{w \cdot h} \cdot M}{\frac{d}{D}}\right)}^{2}\right)}
\] |
associate-/r/ [=>]43.3 | \[ \frac{1}{2 \cdot w} \cdot \left(\left(c0 \cdot \frac{0.5}{c0}\right) \cdot {\color{blue}{\left(\frac{\sqrt{w \cdot h} \cdot M}{d} \cdot D\right)}}^{2}\right)
\] |
*-commutative [=>]43.3 | \[ \frac{1}{2 \cdot w} \cdot \left(\left(c0 \cdot \frac{0.5}{c0}\right) \cdot {\left(\frac{\color{blue}{M \cdot \sqrt{w \cdot h}}}{d} \cdot D\right)}^{2}\right)
\] |
Taylor expanded in w around 0 26.2
Simplified21.2
[Start]26.2 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \left(h \cdot {M}^{2}\right)}{{d}^{2}}
\] |
|---|---|
*-commutative [=>]26.2 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \color{blue}{\left({M}^{2} \cdot h\right)}}{{d}^{2}}
\] |
associate-*r* [=>]25.9 | \[ 0.25 \cdot \frac{\color{blue}{\left({D}^{2} \cdot {M}^{2}\right) \cdot h}}{{d}^{2}}
\] |
associate-/l* [=>]26.8 | \[ 0.25 \cdot \color{blue}{\frac{{D}^{2} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}}
\] |
unpow2 [=>]26.8 | \[ 0.25 \cdot \frac{\color{blue}{\left(D \cdot D\right)} \cdot {M}^{2}}{\frac{{d}^{2}}{h}}
\] |
unpow2 [=>]26.8 | \[ 0.25 \cdot \frac{\left(D \cdot D\right) \cdot \color{blue}{\left(M \cdot M\right)}}{\frac{{d}^{2}}{h}}
\] |
unswap-sqr [=>]21.2 | \[ 0.25 \cdot \frac{\color{blue}{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}}{\frac{{d}^{2}}{h}}
\] |
unpow2 [=>]21.2 | \[ 0.25 \cdot \frac{\left(D \cdot M\right) \cdot \left(D \cdot M\right)}{\frac{\color{blue}{d \cdot d}}{h}}
\] |
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 48.2
Simplified49.1
[Start]48.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.9 | \[ \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 [=>]49.9 | \[ \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.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 [=>]49.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(\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 53.6
Simplified52.4
[Start]53.6 | \[ \frac{{d}^{2} \cdot {c0}^{2}}{{D}^{2} \cdot \left({w}^{2} \cdot h\right)}
\] |
|---|---|
times-frac [=>]54.6 | \[ \color{blue}{\frac{{d}^{2}}{{D}^{2}} \cdot \frac{{c0}^{2}}{{w}^{2} \cdot h}}
\] |
unpow2 [=>]54.6 | \[ \frac{\color{blue}{d \cdot d}}{{D}^{2}} \cdot \frac{{c0}^{2}}{{w}^{2} \cdot h}
\] |
unpow2 [=>]54.6 | \[ \frac{d \cdot d}{\color{blue}{D \cdot D}} \cdot \frac{{c0}^{2}}{{w}^{2} \cdot h}
\] |
associate-/r* [=>]53.5 | \[ \color{blue}{\frac{\frac{d \cdot d}{D}}{D}} \cdot \frac{{c0}^{2}}{{w}^{2} \cdot h}
\] |
associate-*r/ [<=]53.1 | \[ \frac{\color{blue}{d \cdot \frac{d}{D}}}{D} \cdot \frac{{c0}^{2}}{{w}^{2} \cdot h}
\] |
associate-*l/ [<=]52.4 | \[ \color{blue}{\left(\frac{d}{D} \cdot \frac{d}{D}\right)} \cdot \frac{{c0}^{2}}{{w}^{2} \cdot h}
\] |
unpow2 [<=]52.4 | \[ \color{blue}{{\left(\frac{d}{D}\right)}^{2}} \cdot \frac{{c0}^{2}}{{w}^{2} \cdot h}
\] |
unpow2 [=>]52.4 | \[ {\left(\frac{d}{D}\right)}^{2} \cdot \frac{\color{blue}{c0 \cdot c0}}{{w}^{2} \cdot h}
\] |
*-commutative [=>]52.4 | \[ {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0 \cdot c0}{\color{blue}{h \cdot {w}^{2}}}
\] |
unpow2 [=>]52.4 | \[ {\left(\frac{d}{D}\right)}^{2} \cdot \frac{c0 \cdot c0}{h \cdot \color{blue}{\left(w \cdot w\right)}}
\] |
Applied egg-rr18.4
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.9
[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)}
\] |
Taylor expanded in c0 around -inf 63.1
Simplified34.8
[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.1
Simplified28.6
[Start]34.1 | \[ 0.25 \cdot \frac{{D}^{2} \cdot \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}}}
\] |
associate-*r/ [=>]34.0 | \[ \color{blue}{\frac{0.25 \cdot \left(D \cdot D\right)}{\frac{{d}^{2}}{h \cdot {M}^{2}}}}
\] |
unpow2 [=>]34.0 | \[ \frac{0.25 \cdot \left(D \cdot D\right)}{\frac{\color{blue}{d \cdot d}}{h \cdot {M}^{2}}}
\] |
unpow2 [=>]34.0 | \[ \frac{0.25 \cdot \left(D \cdot D\right)}{\frac{d \cdot d}{h \cdot \color{blue}{\left(M \cdot M\right)}}}
\] |
associate-/l* [=>]31.1 | \[ \frac{0.25 \cdot \left(D \cdot D\right)}{\color{blue}{\frac{d}{\frac{h \cdot \left(M \cdot M\right)}{d}}}}
\] |
associate-*r* [=>]28.6 | \[ \frac{0.25 \cdot \left(D \cdot D\right)}{\frac{d}{\frac{\color{blue}{\left(h \cdot M\right) \cdot M}}{d}}}
\] |
*-commutative [=>]28.6 | \[ \frac{0.25 \cdot \left(D \cdot D\right)}{\frac{d}{\frac{\color{blue}{M \cdot \left(h \cdot M\right)}}{d}}}
\] |
Applied egg-rr25.4
Simplified18.5
[Start]25.4 | \[ \left(D \cdot \left(D \cdot -0.25\right)\right) \cdot \frac{1}{\frac{\frac{d}{M \cdot h}}{M} \cdot \left(-d\right)}
\] |
|---|---|
associate-*l* [=>]20.8 | \[ \color{blue}{D \cdot \left(\left(D \cdot -0.25\right) \cdot \frac{1}{\frac{\frac{d}{M \cdot h}}{M} \cdot \left(-d\right)}\right)}
\] |
associate-/r* [=>]20.9 | \[ D \cdot \left(\left(D \cdot -0.25\right) \cdot \color{blue}{\frac{\frac{1}{\frac{\frac{d}{M \cdot h}}{M}}}{-d}}\right)
\] |
associate-*r/ [=>]19.0 | \[ D \cdot \color{blue}{\frac{\left(D \cdot -0.25\right) \cdot \frac{1}{\frac{\frac{d}{M \cdot h}}{M}}}{-d}}
\] |
associate-/l* [<=]19.0 | \[ D \cdot \frac{\left(D \cdot -0.25\right) \cdot \color{blue}{\frac{1 \cdot M}{\frac{d}{M \cdot h}}}}{-d}
\] |
*-lft-identity [=>]19.0 | \[ D \cdot \frac{\left(D \cdot -0.25\right) \cdot \frac{\color{blue}{M}}{\frac{d}{M \cdot h}}}{-d}
\] |
associate-/r/ [=>]19.0 | \[ D \cdot \frac{\left(D \cdot -0.25\right) \cdot \color{blue}{\left(\frac{M}{d} \cdot \left(M \cdot h\right)\right)}}{-d}
\] |
*-commutative [=>]19.0 | \[ D \cdot \frac{\left(D \cdot -0.25\right) \cdot \color{blue}{\left(\left(M \cdot h\right) \cdot \frac{M}{d}\right)}}{-d}
\] |
associate-*l* [=>]18.5 | \[ D \cdot \frac{\left(D \cdot -0.25\right) \cdot \color{blue}{\left(M \cdot \left(h \cdot \frac{M}{d}\right)\right)}}{-d}
\] |
Final simplification19.5
| Alternative 1 | |
|---|---|
| Error | 20.8 |
| Cost | 38220 |
| Alternative 2 | |
|---|---|
| Error | 21.9 |
| Cost | 1544 |
| Alternative 3 | |
|---|---|
| Error | 24.8 |
| Cost | 1490 |
| Alternative 4 | |
|---|---|
| Error | 23.9 |
| Cost | 1489 |
| Alternative 5 | |
|---|---|
| Error | 23.1 |
| Cost | 1488 |
| Alternative 6 | |
|---|---|
| Error | 25.0 |
| Cost | 1357 |
| Alternative 7 | |
|---|---|
| Error | 27.2 |
| Cost | 1225 |
| Alternative 8 | |
|---|---|
| Error | 26.4 |
| Cost | 1224 |
| Alternative 9 | |
|---|---|
| Error | 31.6 |
| Cost | 64 |
herbie shell --seed 2023034
(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))))))