title: How to obtain a useful answer from integration when Simplify is insufficient?

text: I have been trying to integrate a function AND get an output that is sufficiently simple as to be usable. Simply using the `Simplify` and `FullSimplify` commands has not done nearly enough, and it takes me over 2 hours to get a result from this integration. Are there any further tricks I can use to force further simplifications? Any assumptions I can put in to make it simpler or faster? Maybe get more than one core involved (I have other similar integrals I need to do too so even if I can just set them all running at once on different cores that would be an improvement)? Be warned, the example output is stupidly long, so much so that it is impossible to read, much less manually simplify. Input (ai, bi, ci, and di are unit vectors, and so will be replaced with the appropriate cosine later. ki has a value but is still kept track of so the proper cosine can be used later. The cosines are independent of the integration, so it makes it marginally easier to read this way):               r = {r1, r2, r3};     a = {a1, a2, a3}/σa;     b = {b1, b2, b3}/σb;     c = {c1, c2, c3}/σc;     d = {d1, d2, d3}/σd;     k = {k1, k2, k3};     S = {{S11, S12, S13}, {S21, S22, S23}, {S31, S32, S33}};     FullSimplify[Integrate[(1/(2*Pi*σa*σb))*Exp[-(1/2)*((a.r)^2 + (b.r)^2)]*(1/(2*Pi*σc*σd))*Exp[-(1/2)*((c.r)^2 + (d.r)^2)],      {r1, -Infinity, Infinity}, {r2, -Infinity, Infinity}, {r3, -Infinity, Infinity},      Assumptions -> Element[{r1, r2, r3, a1, a2, a3, b1, b2, b3, c1, c2, c3, d1, d2, d3, k1, k2, k3, S11, S12, S13, S21, S22, S23, S31, S32, S33, σa, σb, σc, σd, τ}, Reals] && σa > 0 && σb > 0 && σc > 0 && σd > 0 && τ > 0 && 1 >= a1 >= -1 && 1 >= a2 >= -1 && 1 >= a3 >= -1 && 1 >= b1 >= -1 && 1 >= b2 >= -1 && 1 >= b3 >= -1 && 1 >= c1 >= -1 && 1 >= c2 >= -1 && 1 >= c3 >= -1 && 1 >= d1 >= -1 && 1 >= d2 >= -1 && 1 >= d3 >= -1]]]]      Output:                      ConditionalExpression[      1/(Sqrt[2 π] √(c3^2 (d2^2 σa^2 σb^2 + (b2^2 \     σa^2 + a2^2 σb^2) σd^2) -             2 c2 c3 (d2 d3 σa^2 σb^2 + (b2 b3 σa^2 +                   a2 a3 σb^2) σd^2) +             c2^2 (d3^2 σa^2 σb^2 + (b3^2 σa^2 +                   a3^2 σb^2) σd^2) + σc^2 ((a3 d2 -                   a2 d3)^2 σb^2 +                b3^2 (d2^2 σa^2 + a2^2 σd^2) -                2 b2 b3 (d2 d3 σa^2 + a2 a3 σd^2) +                b2^2 (d3^2 σa^2 +                   a3^2 σd^2))) √((b1^2 c3^2 d2^2 σa^2 \     - 2 b1^2 c2 c3 d2 d3 σa^2 + b1^2 c2^2 d3^2 σa^2 +               a3^2 c2^2 d1^2 σb^2 - 2 a2 a3 c2 c3 d1^2 σb^2 +               a2^2 c3^2 d1^2 σb^2 -               2 a3^2 c1 c2 d1 d2 σb^2 +               2 a2 a3 c1 c3 d1 d2 σb^2 +               2 a1 a3 c2 c3 d1 d2 σb^2 -               2 a1 a2 c3^2 d1 d2 σb^2 +               a3^2 c1^2 d2^2 σb^2 - 2 a1 a3 c1 c3 d2^2 σb^2 +               a1^2 c3^2 d2^2 σb^2 +               2 a2 a3 c1 c2 d1 d3 σb^2 -               2 a1 a3 c2^2 d1 d3 σb^2 -               2 a2^2 c1 c3 d1 d3 σb^2 +               2 a1 a2 c2 c3 d1 d3 σb^2 -               2 a2 a3 c1^2 d2 d3 σb^2 +               2 a1 a3 c1 c2 d2 d3 σb^2 +               2 a1 a2 c1 c3 d2 d3 σb^2 -               2 a1^2 c2 c3 d2 d3 σb^2 +               a2^2 c1^2 d3^2 σb^2 - 2 a1 a2 c1 c2 d3^2 σb^2 +               a1^2 c2^2 d3^2 σb^2 + a3^2 b1^2 d2^2 σc^2 -               2 a2 a3 b1^2 d2 d3 σc^2 + a2^2 b1^2 d3^2 σc^2 +               a3^2 b1^2 c2^2 σd^2 -               2 a2 a3 b1^2 c2 c3 σd^2 + a2^2 b1^2 c3^2 σd^2 +               b3^2 ((a2 d1 - a1 d2)^2 σc^2 +                  c2^2 (d1^2 σa^2 + a1^2 σd^2) -                  2 c1 c2 (d1 d2 σa^2 + a1 a2 σd^2) +                  c1^2 (d2^2 σa^2 + a2^2 σd^2)) +               b2^2 ((a3 d1 - a1 d3)^2 σc^2 +                  c3^2 (d1^2 σa^2 + a1^2 σd^2) -                  2 c1 c3 (d1 d3 σa^2 + a1 a3 σd^2) +                  c1^2 (d3^2 σa^2 + a3^2 σd^2)) -               2 b1 b2 ((a3 d1 - a1 d3) (a3 d2 - a2 d3) σc^2 +                  c3^2 (d1 d2 σa^2 + a1 a2 σd^2) +                  c1 c2 (d3^2 σa^2 + a3^2 σd^2) -                  c3 (c2 d1 d3 σa^2 + c1 d2 d3 σa^2 +                     a2 a3 c1 σd^2 + a1 a3 c2 σd^2)) -               2 b3 (b2 ((a2 d1 - a1 d2) (a3 d1 - a1 d3) σc^2 -                     c1 c3 (d1 d2 σa^2 + a1 a2 σd^2) +                     c1^2 (d2 d3 σa^2 + a2 a3 σd^2) +                     c2 (c3 d1^2 σa^2 - c1 d1 d3 σa^2 -                        a1 a3 c1 σd^2 + a1^2 c3 σd^2)) +                  b1 ((a2 d1 - a1 d2) (-a3 d2 + a2 d3) σc^2 +                     c1 c3 (d2^2 σa^2 + a2^2 σd^2) +                     c2^2 (d1 d3 σa^2 + a1 a3 σd^2) -                     c2 (c3 d1 d2 σa^2 + c1 d2 d3 σa^2 +                        a2 a3 c1 σd^2 +                        a1 a2 c3 σd^2))))/(c3^2 (d2^2 σa^2 \     σb^2 + (b2^2 σa^2 + a2^2 σb^2) σd^2) -               2 c2 c3 (d2 d3 σa^2 σb^2 + (b2 b3 σa^2 +                     a2 a3 σb^2) σd^2) +               c2^2 (d3^2 σa^2 σb^2 + (b3^2 σa^2 +                     a3^2 σb^2) σd^2) + σc^2 ((a3 d2 -                     a2 d3)^2 σb^2 +                  b3^2 (d2^2 σa^2 + a2^2 σd^2) -                  2 b2 b3 (d2 d3 σa^2 + a2 a3 σd^2) +                  b2^2 (d3^2 σa^2 +                     a3^2 σd^2))))), ((b1^2 c3^2 d2^2 σa^2 -              2 b1^2 c2 c3 d2 d3 σa^2 + b1^2 c2^2 d3^2 σa^2 +              a3^2 c2^2 d1^2 σb^2 - 2 a2 a3 c2 c3 d1^2 σb^2 +              a2^2 c3^2 d1^2 σb^2 - 2 a3^2 c1 c2 d1 d2 σb^2 +              2 a2 a3 c1 c3 d1 d2 σb^2 +              2 a1 a3 c2 c3 d1 d2 σb^2 -              2 a1 a2 c3^2 d1 d2 σb^2 + a3^2 c1^2 d2^2 σb^2 -              2 a1 a3 c1 c3 d2^2 σb^2 + a1^2 c3^2 d2^2 σb^2 +              2 a2 a3 c1 c2 d1 d3 σb^2 -              2 a1 a3 c2^2 d1 d3 σb^2 -              2 a2^2 c1 c3 d1 d3 σb^2 +              2 a1 a2 c2 c3 d1 d3 σb^2 -              2 a2 a3 c1^2 d2 d3 σb^2 +              2 a1 a3 c1 c2 d2 d3 σb^2 +              2 a1 a2 c1 c3 d2 d3 σb^2 -              2 a1^2 c2 c3 d2 d3 σb^2 + a2^2 c1^2 d3^2 σb^2 -              2 a1 a2 c1 c2 d3^2 σb^2 + a1^2 c2^2 d3^2 σb^2 +              a3^2 b1^2 d2^2 σc^2 - 2 a2 a3 b1^2 d2 d3 σc^2 +              a2^2 b1^2 d3^2 σc^2 + a3^2 b1^2 c2^2 σd^2 -              2 a2 a3 b1^2 c2 c3 σd^2 + a2^2 b1^2 c3^2 σd^2 +              b3^2 ((a2 d1 - a1 d2)^2 σc^2 +                 c2^2 (d1^2 σa^2 + a1^2 σd^2) -                 2 c1 c2 (d1 d2 σa^2 + a1 a2 σd^2) +                 c1^2 (d2^2 σa^2 + a2^2 σd^2)) +              b2^2 ((a3 d1 - a1 d3)^2 σc^2 +                 c3^2 (d1^2 σa^2 + a1^2 σd^2) -                 2 c1 c3 (d1 d3 σa^2 + a1 a3 σd^2) +                 c1^2 (d3^2 σa^2 + a3^2 σd^2)) -              2 b1 b2 ((a3 d1 - a1 d3) (a3 d2 - a2 d3) σc^2 +                 c3^2 (d1 d2 σa^2 + a1 a2 σd^2) +                 c1 c2 (d3^2 σa^2 + a3^2 σd^2) -                 c3 (c2 d1 d3 σa^2 + c1 d2 d3 σa^2 +                    a2 a3 c1 σd^2 + a1 a3 c2 σd^2)) -              2 b3 (b2 ((a2 d1 - a1 d2) (a3 d1 - a1 d3) σc^2 -                    c1 c3 (d1 d2 σa^2 + a1 a2 σd^2) +                    c1^2 (d2 d3 σa^2 + a2 a3 σd^2) +                    c2 (c3 d1^2 σa^2 - c1 d1 d3 σa^2 -                       a1 a3 c1 σd^2 + a1^2 c3 σd^2)) +                 b1 ((a2 d1 - a1 d2) (-a3 d2 + a2 d3) σc^2 +                    c1 c3 (d2^2 σa^2 + a2^2 σd^2) +                    c2^2 (d1 d3 σa^2 + a1 a3 σd^2) -                    c2 (c3 d1 d2 σa^2 + c1 d2 d3 σa^2 +                       a2 a3 c1 σd^2 +                       a1 a2 c3 σd^2))))/(c3^2 (d2^2 σa^2 \     σb^2 + (b2^2 σa^2 + a2^2 σb^2) σd^2) -              2 c2 c3 (d2 d3 σa^2 σb^2 + (b2 b3 σa^2 +                    a2 a3 σb^2) σd^2) +              c2^2 (d3^2 σa^2 σb^2 + (b3^2 σa^2 +                    a3^2 σb^2) σd^2) + σc^2 ((a3 d2 -                    a2 d3)^2 σb^2 +                 b3^2 (d2^2 σa^2 + a2^2 σd^2) -                 2 b2 b3 (d2 d3 σa^2 + a2 a3 σd^2) +                 b2^2 (d3^2 σa^2 + a3^2 σd^2))) ∈           Reals && (c3^2 (d2^2 σa^2 σb^2 + (b2^2 σa^2 \     + a2^2 σb^2) σd^2) -              2 c2 c3 (d2 d3 σa^2 σb^2 + (b2 b3 σa^2 +                    a2 a3 σb^2) σd^2) +              c2^2 (d3^2 σa^2 σb^2 + (b3^2 σa^2 +                    a3^2 σb^2) σd^2) + σc^2 ((a3 d2 -                    a2 d3)^2 σb^2 +                 b3^2 (d2^2 σa^2 + a2^2 σd^2) -                 2 b2 b3 (d2 d3 σa^2 + a2 a3 σd^2) +                 b2^2 (d3^2 σa^2 +                    a3^2 σd^2))) (b1^2 c3^2 d2^2 σa^2 -              2 b1^2 c2 c3 d2 d3 σa^2 + b1^2 c2^2 d3^2 σa^2 +              a3^2 c2^2 d1^2 σb^2 - 2 a2 a3 c2 c3 d1^2 σb^2 +              a2^2 c3^2 d1^2 σb^2 - 2 a3^2 c1 c2 d1 d2 σb^2 +              2 a2 a3 c1 c3 d1 d2 σb^2 +              2 a1 a3 c2 c3 d1 d2 σb^2 -              2 a1 a2 c3^2 d1 d2 σb^2 + a3^2 c1^2 d2^2 σb^2 -              2 a1 a3 c1 c3 d2^2 σb^2 + a1^2 c3^2 d2^2 σb^2 +              2 a2 a3 c1 c2 d1 d3 σb^2 -              2 a1 a3 c2^2 d1 d3 σb^2 -              2 a2^2 c1 c3 d1 d3 σb^2 +              2 a1 a2 c2 c3 d1 d3 σb^2 -              2 a2 a3 c1^2 d2 d3 σb^2 +              2 a1 a3 c1 c2 d2 d3 σb^2 +              2 a1 a2 c1 c3 d2 d3 σb^2 -              2 a1^2 c2 c3 d2 d3 σb^2 + a2^2 c1^2 d3^2 σb^2 -              2 a1 a2 c1 c2 d3^2 σb^2 + a1^2 c2^2 d3^2 σb^2 +              a3^2 b1^2 d2^2 σc^2 - 2 a2 a3 b1^2 d2 d3 σc^2 +              a2^2 b1^2 d3^2 σc^2 + a3^2 b1^2 c2^2 σd^2 -              2 a2 a3 b1^2 c2 c3 σd^2 + a2^2 b1^2 c3^2 σd^2 +              b3^2 ((a2 d1 - a1 d2)^2 σc^2 +                 c2^2 (d1^2 σa^2 + a1^2 σd^2) -                 2 c1 c2 (d1 d2 σa^2 + a1 a2 σd^2) +                 c1^2 (d2^2 σa^2 + a2^2 σd^2)) +              b2^2 ((a3 d1 - a1 d3)^2 σc^2 +                 c3^2 (d1^2 σa^2 + a1^2 σd^2) -                 2 c1 c3 (d1 d3 σa^2 + a1 a3 σd^2) +                 c1^2 (d3^2 σa^2 + a3^2 σd^2)) -              2 b1 b2 ((a3 d1 - a1 d3) (a3 d2 - a2 d3) σc^2 +                 c3^2 (d1 d2 σa^2 + a1 a2 σd^2) +                 c1 c2 (d3^2 σa^2 + a3^2 σd^2) -                 c3 (c2 d1 d3 σa^2 + c1 d2 d3 σa^2 +                    a2 a3 c1 σd^2 + a1 a3 c2 σd^2)) -              2 b3 (b2 ((a2 d1 - a1 d2) (a3 d1 - a1 d3) σc^2 -                    c1 c3 (d1 d2 σa^2 + a1 a2 σd^2) +                    c1^2 (d2 d3 σa^2 + a2 a3 σd^2) +                    c2 (c3 d1^2 σa^2 - c1 d1 d3 σa^2 -                       a1 a3 c1 σd^2 + a1^2 c3 σd^2)) +                 b1 ((a2 d1 - a1 d2) (-a3 d2 + a2 d3) σc^2 +                    c1 c3 (d2^2 σa^2 + a2^2 σd^2) +                    c2^2 (d1 d3 σa^2 + a1 a3 σd^2) -                    c2 (c3 d1 d2 σa^2 + c1 d2 d3 σa^2 +                       a2 a3 c1 σd^2 + a1 a2 c3 σd^2)))) >           0) || 2 Abs[          Arg[(b1^2 c3^2 d2^2 σa^2 -               2 b1^2 c2 c3 d2 d3 σa^2 + b1^2 c2^2 d3^2 σa^2 +               a3^2 c2^2 d1^2 σb^2 -               2 a2 a3 c2 c3 d1^2 σb^2 +               a2^2 c3^2 d1^2 σb^2 -               2 a3^2 c1 c2 d1 d2 σb^2 +               2 a2 a3 c1 c3 d1 d2 σb^2 +               2 a1 a3 c2 c3 d1 d2 σb^2 -               2 a1 a2 c3^2 d1 d2 σb^2 +               a3^2 c1^2 d2^2 σb^2 - 2 a1 a3 c1 c3 d2^2 σb^2 +               a1^2 c3^2 d2^2 σb^2 +               2 a2 a3 c1 c2 d1 d3 σb^2 -               2 a1 a3 c2^2 d1 d3 σb^2 -               2 a2^2 c1 c3 d1 d3 σb^2 +               2 a1 a2 c2 c3 d1 d3 σb^2 -               2 a2 a3 c1^2 d2 d3 σb^2 +               2 a1 a3 c1 c2 d2 d3 σb^2 +               2 a1 a2 c1 c3 d2 d3 σb^2 -               2 a1^2 c2 c3 d2 d3 σb^2 +               a2^2 c1^2 d3^2 σb^2 - 2 a1 a2 c1 c2 d3^2 σb^2 +               a1^2 c2^2 d3^2 σb^2 + a3^2 b1^2 d2^2 σc^2 -               2 a2 a3 b1^2 d2 d3 σc^2 + a2^2 b1^2 d3^2 σc^2 +               a3^2 b1^2 c2^2 σd^2 -               2 a2 a3 b1^2 c2 c3 σd^2 + a2^2 b1^2 c3^2 σd^2 +               b3^2 ((a2 d1 - a1 d2)^2 σc^2 +                  c2^2 (d1^2 σa^2 + a1^2 σd^2) -                  2 c1 c2 (d1 d2 σa^2 + a1 a2 σd^2) +                  c1^2 (d2^2 σa^2 + a2^2 σd^2)) +               b2^2 ((a3 d1 - a1 d3)^2 σc^2 +                  c3^2 (d1^2 σa^2 + a1^2 σd^2) -                  2 c1 c3 (d1 d3 σa^2 + a1 a3 σd^2) +                  c1^2 (d3^2 σa^2 + a3^2 σd^2)) -               2 b1 b2 ((a3 d1 - a1 d3) (a3 d2 - a2 d3) σc^2 +                  c3^2 (d1 d2 σa^2 + a1 a2 σd^2) +                  c1 c2 (d3^2 σa^2 + a3^2 σd^2) -                  c3 (c2 d1 d3 σa^2 + c1 d2 d3 σa^2 +                     a2 a3 c1 σd^2 + a1 a3 c2 σd^2)) -               2 b3 (b2 ((a2 d1 - a1 d2) (a3 d1 - a1 d3) σc^2 -                     c1 c3 (d1 d2 σa^2 + a1 a2 σd^2) +                     c1^2 (d2 d3 σa^2 + a2 a3 σd^2) +                     c2 (c3 d1^2 σa^2 - c1 d1 d3 σa^2 -                        a1 a3 c1 σd^2 + a1^2 c3 σd^2)) +                  b1 ((a2 d1 - a1 d2) (-a3 d2 + a2 d3) σc^2 +                     c1 c3 (d2^2 σa^2 + a2^2 σd^2) +                     c2^2 (d1 d3 σa^2 + a1 a3 σd^2) -                     c2 (c3 d1 d2 σa^2 + c1 d2 d3 σa^2 +                        a2 a3 c1 σd^2 +                        a1 a2 c3 σd^2))))/(c3^2 (d2^2 σa^2 \     σb^2 + (b2^2 σa^2 + a2^2 σb^2) σd^2) -               2 c2 c3 (d2 d3 σa^2 σb^2 + (b2 b3 σa^2 +                     a2 a3 σb^2) σd^2) +               c2^2 (d3^2 σa^2 σb^2 + (b3^2 σa^2 +                     a3^2 σb^2) σd^2) + σc^2 ((a3 d2 -                     a2 d3)^2 σb^2 +                  b3^2 (d2^2 σa^2 + a2^2 σd^2) -                  2 b2 b3 (d2 d3 σa^2 + a2 a3 σd^2) +                  b2^2 (d3^2 σa^2 + a3^2 σd^2)))]] < π]


title: Performance on Multinomial Deviate is slow

text: Most of the time in my program is spent on this single line of code:               out = RandomVariate[MultinomialDistribution[nt, tmp]];      `tmp` is a vector of `np+1` probabilities which sum to 1. `nt` is an integer. `out` is an np-component vector of integers that sums to `nt`. pseudo-code:               Loop:          Get new np and nt values     set up tmp.     out = RandomVariate[MultinomialDistribution[nt, tmp]];          Do stuff with out     End Loop      Here is an example with timing results. In the real problem `nt` and the length of `tmp` are random but this example is enough to illustrate the difficulty. Is there an obvious way to improve the performance?               tmp = {.1, .1, .8}     nt = 2;     timer = TimeUsed[];     For[i = 1, i < 10000, i++,        (* tmp may be changed here *)        out = RandomVariate[MultinomialDistribution[nt, tmp]];     ];     Print["time in loop=", TimeUsed[] - timer];      Sorry if this has been discussed before.


title: Placing Manipulate controls in multiple columns

text: I have a `Manipulate` construct with a square `Graphic` on the left side and all the controls placed on the right side. There are so many (and also pretty large) control items, however, that they take up about double the vertical space of the graphic. Is there a simple way to place the controls into two seperate columns (like in the sketch below)?                _________     |         | Control 1 | Control 4     | Graphic | Control 2 | Control 5     |_________| Control 3 | Control 6      I could do something similar using `Item` and `Grid`, but as far as I know, in such a construct the default control syntax wouldn't work and I'd have to re- program all the controls with `Dynamic`. It seems `ControlPlacement` also does not support multiple columns. **Edit:** To be clear: I'm trying to find a solution that preserves as much of `Manipulate`'s properties as possible, i.e. things like alignment, labeling and using default control types.


title: Solution of equation with power series (perturbation)

text: So I need to use _Mathematica_ to find the solution of $y=x- \epsilon \sin(2y)$ as a power series in terms of $\epsilon$. I'd assume I'd need to create an equation $f=x-y- \epsilon \sin(2y)$, then express $y(\epsilon)=\sum_n a_n \epsilon^n$, then input into series, but I can't seem to get it to work. Some help would be appreciated.


title: Generating Gelfand-Tsetlin patterns

text: I am doing some research on some combinatorial object called GT-patterns. They are generated from three parts of data. Two integer, partitions (sequences of weakly decreasing numbers), $\lambda = \lambda_1 \geq \lambda_2,\dotsc, \lambda_n \geq 0$ and $\mu = \mu_1 \geq \dotsc, \mu_n \geq 0$ such that $\lambda_i \geq \mu_i$, and vector of non- negative integers, $w = (w_1,\dotsc,w_k)$ such that $w_1+w_2+\dots + w_k = (\lambda_1+\dots + \lambda_n)-(\mu_1+\dots + \mu_n)$, generate all arrays where certain equalities and inequalities are satisfied, as in the example below: Here, $\lambda = (4, 3, 3, 2, 1, 1, 0, 0)$, $\mu = (2, 2, 1)$, and $w = (3, 3, 2, 1)$. Note that we pad $\mu$ with zeros so that it has the same length as $\lambda$. The arrays are constructed as follows: It consists of $k+1$ rows, the first row is $\lambda$ and the last row is $\mu$. The difference of the sum of the entries in row $i$ and $i+1$ must be equal to $w_{k-i+1}$. Thus, thus, in the example, going to 5th row to 4th row, the row sum increases by 3. 4th to 3rd is also an increase by 3, followed by 2 and 1. That are all equalities that are needed to be satisfied. Now, the inequalities we require to be fulfilled are that each down-right diagonal is weakly decreasing, and each down-left diagonal is weakly increasing. All entries should be non-negative integers. All solutions for the example is given below: ![GT-patterns](http://i.stack.imgur.com/YebAY.png) The output consists of the rows, (as a matrix). I am also interested in the case where instead of specifying the row sums, we only specify the number of rows. The number of patterns that fit the requirement is still a finite number. Thus, the method could be specified as follows:               FindGTPatterns[lambda_List, mu_List, w_List]     FindGTPatterns[lambda_List, mu_List, rows_Integer]      and the output is a list of matrices. The method I currently use is the one below. It is very straigthforward, it encodes the equalities and inequalities, and just use `Reduce`. This works ok, but when the number of solutions is large (>30000), `Reduce` cannot take it. Also, I strongly suspect that there is a more efficient solution that does not rely on `Reduce`.               (* ToTableauShape is a method that pads the partitions so that they have the same lenghts, and wars if total of lambda minus total of mu is not the total of w *)          GTPatterns[lambda_List, mu_List:{},weight_List:{}]:=GTPatterns[ToTableauShape[lambda,mu,weight]];     GTPatterns[lambda_List, mu_List:{},maxBox_Integer]:=GTPatterns[ToTableauShape[lambda,mu,{}],maxBox];     GTPatterns[lambda_List, maxBox_Integer]:=GTPatterns[ToTableauShape[lambda,{},{}],maxBox];          GTPatterns[TableauShape[lambda_, mu_, weight_],maxBoxIn_Integer:0]:=Module[         {w, h, x, gtp, bddconds, wconds=True, ineqs, sol,maxBox=maxBoxIn},              (* Calculate width, height, of GT-pattern. *)         w = Length[lambda];              (* If no weight or maxBox specified, then maxBox is the number of parts of lambda. *)         h = 1 + Which[             Length[weight] >0 , Length[weight],             maxBox > 0, maxBox,             True, w];              gtp = Table[x[r][c], {r, h, 1, -1}, {c, w}]; (* The GT-pattern *)              (* Boundary conditions. *)         bddconds = And @@ Table[x[h][c] == lambda[[c]] && x[1][c] == mu[[c]], {c, w}];              If[Length[weight]>0,             wconds = And @@ Table[ Sum[x[r + 1][c] - x[r][c], {c, w}] == weight[[r]], {r, h - 1}];         ];              (* Inequalities that must hold. *)         ineqs = And @@ Flatten[Table[             If[r < h, x[r + 1][c] >= x[r][c], True] &&             If[r < h && c < w, x[r][c] >= x[r + 1][c + 1], True] , {r, h}, {c, w}]];              sol = Reduce[bddconds && ineqs && wconds, Flatten@gtp, Integers];              If[sol===False, Return[{}]];              sol = gtp /. List[ToRules[sol]];         Return[GTPattern/@sol];     ];      On a side note, these patterns are called Gelfand-Tsetlin patterns, and are related to representation theory in mathematics. I asked another question related to these earlier here, and got some really nice algorithms related to doing computations on these types of patterns. _Side note:_ In what I am doing, I am trying things for $m=1,2,3,...$ and examine all $\lambda$ where the total is $m$, and for each such $\lambda$, examine all $\mu$ and $w$ that fits the requirements, I examine all patterns. Currently, up to $m=8$ is ok, but after that, it takes too much time. Of course, for some parameters $\lambda,\mu,w$ the set of patterns can be empty. If you have a nice description on WHEN this happens, you can write an article (but I think this is proven to be NP-hard in $m$).


title: How to pass composite function list to SortBy?

text: In order to sort alphanumeric-as-string data of the form `{"T3", "T14", "T1", "E2"}`, so that `"T14"` comes after `"T3"`, `SortBy` requires the tiebreaker function list:               {StringTake[#, 1] &, ToExpression@StringDrop[#, 1] &}      Which works as intended when this expression is inserted literally in `SortBy`. However, defining a utility function `mySort[x_String]:={StringTake[x, 1] , ToExpression@StringDrop[x, 1]}` doesn't work since the output is a list of expressions rather than a list of functions. The alternative - to define a function via               mySort := {StringTake[#, 1] &, ToExpression@StringDrop[#, 1] &}      only works when the list to be sorted is 1-dimensional (as above) but not with lists of the form `data2={"T3"->a, "T14"->b, "T1"->c, "E2"->d}` where it is necessary to use `SortBy[data2,mySort[#[[1]]]&]`. Any alternatives that will work for general expressions?


title: Faster alternatives for DayOfWeek

text: It has been noticed on several occasions that `DayOfWeek` function is rather slow when applied to a large list of dates, e.g. in this recent question. What faster alternatives do we have in such situations?


Background. See question Moving controls from Manipulate to a Palette ( or similar GUI object ). As suggested in the answer to this question I use a CreateDialog window to group and handle controls and added WindowFloating->True as an option. Clicking a second time on the external button creates an identical copy of the Window. Question: **What it is the best way to enforce that only one CreateDialog window can be created?**


title: Pattern test for variables during function definition

text: I am having a problem with pattern testing on variables during function definition               nfun[M : Repeated[_?(test1&&test2||test3..)&, {10}]]:= N@(Norm@(Sin[#] & /@ M))      I want to have a few tests on the vectors `M` that I want to feed `nfun`. One example that does not work if I want to test if `M` has `Integer` entries using `Repeated` is the following.               nfun[M : Repeated[_?IntegerQ, {10}]]:= N@(Norm@(Sin[#] & /@ M))      Here goes another filed trial with the same aim.               nfun[M_?((VectorQ[#, IntegerQ]) && (Length[#] == 10)) &]:= N@(Norm@(Sin[#] & /@ M))


title: Integrate perfomance

text: I have a notebook in Mathematica 4. I'm trying to convert it to use in Mathematica 9. One of the problem is the long computation of definite integral in the new version of Mathematica. Here's the example: ![enter image description here](http://i.stack.imgur.com/3lY6S.png) I understand that the new Mathematica produces more accurate answer, but even NIntegrate loses in speed of calculations. Is there any simple solution to make the integration work faster?


title: Remove versus ClearAll

text: What is the difference between `Remove` and `ClearAll`? I thought that " _not being recognized by Mathematica_ ", which is the effect of `Remove`, meant that there would be no " _values, definitions, attributes, messages, and defaults associated with symbols_ ", which is the effect of `ClearAll`. That naive equivalence is wrong as shown by the different output out of these two lines:               b := a; Remove[a]; b     b := a; ClearAll[a]; b      Which side effects of `Remove` are not shared by `ClearAll` (and viceversa)?


title: How can we multiply nested matrices?

text: If we have nested matrices, such as: $$ \begin{bmatrix} \begin{bmatrix} a_{1,1} & a_{1,2}\\ a_{2,1} & a_{2,2}\\ \end{bmatrix} \begin{bmatrix} b_{1,1} & b_{1,2}\\ b_{2,1} & b_{2,2}\\ \end{bmatrix} \\ \begin{bmatrix} c_{1,1} & c_{1,2}\\ c_{2,1} & c_{2,2}\\ \end{bmatrix} \begin{bmatrix} d_{1,1} & d_{1,2}\\ d_{2,1} & d_{2,2}\\ \end{bmatrix} \\ \end{bmatrix} $$ ...and we wish to multiply two of these matrices together, how can we accomplish this? Here I assume that the conventional rules of matric multiplication apply. For example, we treat each "sub-matrix" (or block matrix, if you prefer), for lack of a better term, as an entry in the main matrix. Then we recursively apply the rules of matrix multiplication. **AN ATTEMPT TO EXPLAIN** So, for example, the matrix from above could be represented as: $$ \begin{bmatrix} a & b\\ c & d\\ \end{bmatrix} $$ ...and multiplied by another matrix to get: $$ \begin{bmatrix} a & b\\ c & d\\ \end{bmatrix} * \begin{bmatrix} e & f\\ g & h\\ \end{bmatrix} = \begin{bmatrix} (ae+bg) & (af+bh)\\ (ce+dg) & (cf+dh)\\ \end{bmatrix} $$ Where each entry above is actually another matrix. For example, the entry $(ae+bg)$ is actually: $$ (ae+bg) = \begin{bmatrix} a_{1,1} & a_{1,2}\\ a_{2,1} & a_{2,2}\\ \end{bmatrix} * \begin{bmatrix} e_{1,1} & e_{1,2}\\ e_{2,1} & e_{2,2}\\ \end{bmatrix} + \begin{bmatrix} b_{1,1} & b_{1,2}\\ b_{2,1} & b_{2,2}\\ \end{bmatrix} * \begin{bmatrix} g_{1,1} & g_{1,2}\\ g_{2,1} & g_{2,2}\\ \end{bmatrix} $$


title: Interpolating a list with exclusion

text: I have a list, `data`, where the elements `data[[i]]` range over `i` from `-N` to `N`. I want to define a function interpolating this list at every point except for `i`=`0`. Is there a way to do this?


title: Tensor product involving Levi Civita symbol

text: I'm working with xAct package. I've defined the tensor component values and my issue is that I want an expression involving Levi Civita symbols and tensor components, I don't know how to deal with it. The expression is something like $\epsilon_{abc}$T$_{ade}$ and other two index tensor components. Does anybody know how to deal with it? I try multipling the tensor T to the Levi Civita, but my output writes 'T' instead of the components of the tensor. Can anybody help me please? Thank you


title: Sum with Levi-Civita

text: I'm trying to write the expression $$\sum_{\alpha,\beta = 1}^{4}\epsilon_{\mu \nu\alpha\beta}a^{\nu} b^{\alpha} c^{\beta}$$ in Mathematica, where $\epsilon$ is the Levi-Civita symbol and $a$, $b$, $c$ are 4-dimensional vectors. I tried this but the problem is with Levi-Civita as $\mu$ and $\nu$ are not specified in advance               a = {a1, a2, a3, a4};      b = {b1, b2, b3, b4};      c = {c1, c2, c3, c4};          Sum[       LeviCivitaTensor[4][[mu, nu, alpha, beta]] a[[nu]] b[[alpha]] c[[beta]],       {alpha, 1, 4}, {beta, 1, 4}     ]


title: White regions in DensityPlot — is this a bug with ColorFunctionScaling?

text: Is this a bug with `ColorFunctionScaling`? When I try to supply my own `ColorFunction` Mathematica seems to partially ignore it, and the white color "burns through" if the function is too "sharp":               mycf[z_] := RGBColor[z, 0, 0]          GraphicsRow[       {DensityPlot[(Sin[x] Sin[y])^4, {x, 0, Pi}, {y, 0, Pi},         ColorFunction -> mycf, ColorFunctionScaling -> False],        DensityPlot[(Sin[x] Sin[y])^5, {x, 0, Pi}, {y, 0, Pi},          ColorFunction -> mycf, ColorFunctionScaling -> False]}     ]      ![density plots](http://i.stack.imgur.com/gy5p0.png)


title: How to improve a DensityPlot?

text: Given that               x1 =        -((π^2 (x - x0) Cosh[π (x - x0)]) /        (2 (-Cos[π (y - y0)] + Cosh[π (x - x0)]))) + (π^2 (x - x0) Cosh[π (x - x0)]) /         ( 2 (-Cos[π (-1 + y + y0)] + Cosh[π (x - x0)])) + (π^2 (x - x0) Sinh[π (x - x0)]^2) /         ( 2 (-Cos[π (y - y0)] + Cosh[π (x - x0)])^2) - (π^2 (x - x0) Sinh[π (x - x0)]^2) /         ( 2 (-Cos[π (-1 + y + y0)] + Cosh[π (x - x0)])^2)      I want to do a density plot by using:               DensityPlot[ x1 /. {x0 -> 0, y0 -> 0.2}, {x, -0.5, 0.5}, {y, -0.5, 0.5}]      ![Mathematica graphics](http://i.stack.imgur.com/y6gfc.png) But there are some white regions which are not plotted by density color. How to plot the density color also in the white regions?


title: Debugging the context of a Package

text: I am working on a package of functions that complement the `NeuralNetworks`` package that Wolfram provides. I am having a problem with the following code, which is essentially a wrapper for two commands that I run frequently:               runNetwork[data_,desc_,dlist_,{tlist_,vlist_}]:= Module[{fdfwd,m,r},         fdfwd = InitializeRBFNet[                 desc[[tlist,dlist]],                 data[[tlist]],                 1,RandomInitialization->False];         {m,r} = NeuralFit[fdfwd,             desc[[tlist,dlist]],             data[[tlist]],             desc[[vlist,dlist]],             data[[vlist]],             100,Method->SteepestDescent,CriterionPlot->False];         {m,r}]      When I declare this function within my notebook, it runs as expected; however if I place it in a package (for instance, `MyNeuralNetworks``) then I get errors of the following type: > Set::shape: "Lists > {SolarNeuralNetwork`Private`m\$2436,SolarNeuralNetwork`Private`r\$2436} and > SolarNeuralNetwork`Private`NeuralFit[<<1>>] are not the same shape." which suggests to me that the list `fdfwd` that is returned by the first function is not being passed correctly to the second function. I have tried adding a `Needs["NeuralNetworks`"]` line in both the Public and Private portions of the package as well as in the `BeginPackage` line following this question and answer. I'm new to package writing, so there may be something obvious I'm missing. It's possible that the answer I'm looking for is hidden somewhere in this discussion but I don't know how to implement those suggestions in my context.


title: Table function with Part[] call misbehaving, but only after initial startup of Mathematica

text: I am getting errors like:               Part::partd:         Part specification standardBasis[[1]] is longer than depth of object.      with the following Manipulate expression:               Clear[  e1, e2, standardBasis, y]     e1 := {1, 0}     e2 := {0, 1}     standardBasis := {e1, e2}     y := 3     Manipulate[      p := {x, y} ;      Clear[j];      arrowsReference = Table[Arrow[{p, p + Part[standardBasis, j]}], {j, 2}]      , {{x, 1}, -10, 10} ]      The odd thing about it is that this only occurs immediately after starting Mathematica, on the source file that contains this manipulate. A second shift- enter on the expression after that works without complaint and I get the desired result. This appears to be related to the startup of mathematica using specific notebooks. The sequence I'm using is:   * go to windows explorer.   * double click on a .nb or .cdf file with this source.   * click enable-dynamics.   * get the error.   * shift-enter: error goes away. whereas if I take a notebook that is blank and already opened and then cut and paste this source into it, I don't get any errors about the `Part[]` expressions.


title: Efficient conditional Mean[] on a large data set

text: Consider a list, `AK6`, that has 382 sublists of length varying from 2500 to 3000. Each "subsublist" is as such : `AK6[[1,1]]={5.5,1001}` With `AK6[[All,1]]` going from 1001 to 4001 with gaps (missing points) I now need to compute the `Mean[]` for all the sublists with equal second value. That is `Select` with `Flatten[AK6,1]` all the list with 2005 as the second value (from 350 to 384 items approx) I do this using :               ParallelTable[                  Mean[Select[Flatten[AK6s, 1], #[[2]] == gazeNo &][[All,1]]],                   {gazeNo, Range[1000, 4000, 1]}]      It does what I need but this is very slow. Is there a way to do this computation faster? * * * Download the 13 MB list as               AK6 = Uncompress@Import["http://api2.ge.tt/0/9F8d6WD/0/blob/download", "String"];


title: NDSolve example - analytical vs numerical solution. How to specify initial conditions?

text: So, I have the following equation:               y[t]^-3 == w^2 y[t]/t^2 + y''[t]      where               w^2 = (t0 k0)^2.      Analytic solution is easy to obtain:               y[t] = a Sqrt[t]      where               a = 1/Sqrt[t0 k0]      Since the solution is singular in `0`, am I not sure how to specify the initial conditions for `NDSolve`. When I put this in `NDSolve` I expect to get a solution that behaves like `~t^(1/2))`, but I get a `~t` solution which doesn't make sense.               NDSolve[{-y''[t] - y[t]/t^2 + y[t]^(-3) ==                      0, y[?] == ?, y'[?] == ?}, y, {t, ?, ?}]      I don't have any constrains for `t0` and `k0` from physics (yet), I just want to understand better how the `NDSolve` really works. Edit: When I try with: w=1, k0, t0=1, it works fine: NDSolve[{-y''[t] - 1(y[t])/(t^2) + (y[t])^(-3) == 0, y[1] == 1, y'[1] == 1}, y, {t, 1, 100}] -> ~t^1/2 behaviour. But when I try with: w=10, k0=1, t0=10 NDSolve[{-y''[t] - 10*(y[t])/(t^2) + (y[t])^(-3) == 0, y[10] == 10, y'[10] == 0.045}, y, {t, 10, 100}], I get some kind of crazy periodic functions. Why? (IC for y'[10] == 0.045 follows directly from derivative.)


title: How to define a new copula distribution family

text: The function `CopulaDistribution` can be used with the most well known kernels. I was wondering how I can add a new family of kernels in a way that it works in the same way as the current function. For example as the documentation explains: > `CopulaDistribution` can be used with such functions as `Mean`, `PDF`, and > `RandomVariate`, etc. Do I need to define all these functions myself or is there a smart way of using the functions which are already defined in Mathematica? I wonder if anyone has done something similar and would like to share his/her experience on this.


title: What is a "Paclet"?

text: I often see references to "paclets", for example the `PacletManager`` context, the `PacletInfo.m` file in some packages and next to downloaded computable data, `$UserBaseDirectory/Paclets`, etc. **Question:** What are "paclets", what is their relevance to end users, and how can one use them with packages? **Clarification:** Since I saw a `PacletInfo.m` file in several third party packages as well, I assume that they must be useful in packages and there must be some documentation on how to use them somewhere. I am hoping someone could point me to the relevant documentation.


title: Sum does not converge, but I think it should

text: Why does _Mathematica_ return > Sum::div: Sum does not converge. >> When I input               Sum[Boole[!IntegerQ[x]], {x, 1, Infinity}]      The sum is obviously 0.


title: Is it possible to use Begin and End inside a Manipulate?

text: May be someone can explain why I can't use `Begin["context`"]` and `End[]` inside a `Manipulate` expression, or inside the initialization section? When I use it in the `Manipulate` expression, and close the notebook and restart, I get the error: ![enter image description here](http://i.stack.imgur.com/kzkr3.png) Here is the code, please feel free to modify as needed. I am just trying to see if the idea of different contexts can be used inside Manipulate. It is just not seeing `obj`f[]` at all.               Manipulate[           Begin["obj`"];      f[y_] := y^2 + 1;      End[];           {x, Date[], obj`f[1]},           {{x, 0, "x"}, 0, 10, 1, Appearance -> "Labeled"},      TrackedSymbols :> {x}      ]      I also tried in the initialization section, same problem. I think this is because `Manipulate` itself is a `Dynamic` module, it does not like new context created inside it? This is a snapshot of the above:               DynamicModule[{x = 5},           Begin["obj`"];           f[y_] := y^2 + 1;           End[];           {x, Date[], obj`f[1]}      ]      Outside `Manipulate`, it works fine of course: (restating kernel helps before running this below again after the above just in case)               Begin["obj`"];     f[y_] := y^2 + 1;     End[];          obj`f[2]      gives `5`


title: How to make a new analytic function work seamlessly with Mathematica's analysis functions?

text: I am defining a new analytic function of six variables. I have algorithms to evaluate it numerically, and have amassed a large catalog of analytic properties. It is easy for me to program the numerics using:               funcF[a_?NumericQ, b_?NumericQ, c_?NumericQ, d_?NumericQ, e_?NumericQ, f_?NumericQ] = (*...*)      I know the analytic expression for its derivative with respect to each argument. I also know the location of all the singularities and the Taylor/asymptotic series expansion of this function near these singularities in all six variables, and a bunch of other identities. **Question** : I want to make a package that incorporates this function into _Mathematica_. What do I need to do to to make it work as seamlessly as possible with its built-in functions like `Derivative`, `Limit`, `Series` `Simplify`, _etc._ Clearly, there will be a lot of coding to do, but I'm more than willing. * * * I already have a head-start from the answer to this question, which nicely makes the custom function `ln` work well with `Derivative` and `Series`. I stumbled upon this page: http://functions.wolfram.com/NB/StruveH.nb which includes functions like `DomainAndRange`, `Singularities`, etc. and thought this would be the key to accomplishing my task. Alas, these functions aren't `Mathematica` functions and can't be evaluated. Is there a template/guideline for this?


title: Why is FindInstance finding non-instances?

text: Consider this example:               FindInstance[Exists[{x, y}, x > 1 && y > 1 && x > Sqrt[x + y]], {x, y}]      which finds values of $x$ and $y$ such that $x>\sqrt{x + y}$. Why does Mathematica output `{{x->0, y->0}}`? The condition is obviously violated in all three parts: none of $x>1$, $y>1$, or $x>\sqrt{x+y}$ are satisfied by $(0,0)$. What's going on here? Am I misusing `FindInstance`? Or `Exists`?


title: Take the function f(x)=2x-x^2 and the open interval P=(0,2) why is f(P)=(0,1]? why is that 1 closed?

text: I would think it would be f(P)=(0,1). Why does it include the endpoint?


title: How to plot a list of lists with ListLinePlot?

text: (edited, after rasher comment, changing any detail and variable names) You can plot an evolution with 3 lines (up=maximmun, in the middle=mean, bottom=Minimum) with this code               historytargetmax = {10, 15, 20, 30, 35}     historytargetmean = {6, 8, 10, 13, 15}     historytargetmin = {6, 3, 5, 7, 8}          ListLinePlot[{historytargetmax, historytargetmean,        historytargetmin}, PlotStyle -> {Thickness[0.008]},       AxesLabel -> {"Generation", "Target"}, LabelStyle -> {24, Bold},       ImageSize -> Large]      My question is How do you do this with multiple (for example 3) series. For example... in the next lines... each list historytarget___ contains 3 list. Each list represent s the maximun/mean/minimun of target function trought iterations {1,2,3,4,5} We made 3 simulations and in the first simulation we obtain this evolution os maximun {10, 15, 20, 30, 35} and this evolution of mean {6, 8, 10, 13, 15} and this evolution of min {2, 3, 5, 7, 8} So we would like to view the maximun line in blue, the min-line evolution en green, and min-lin evo in red. The same in the other 2 simulations. So finally we can see 3 lines representing the evo of maximun (BLUE and UP) 3 lines representing the evo of mean (GREEN and middle) and 3 lines representing the evo of min (RED and BOTTOM) for example with               historytargetmax = {{10, 15, 20, 30, 35}, {12, 14, 17, 27,  31}, {11, 12, 22, 32, 32}}     historytargetmean = {{6, 8, 10, 13, 15}, {8, 9, 11, 12, 13}, {11, 12, 12, 13, 19}}     historytargetmin = {{2, 3, 5, 7, 8}, {2, 4, 5, 7, 8}, {6, 2, 5, 3, 7}}      Last thing.- I think that it would be interesting plotting all the maximun series in BLUE all the mean series in GREEN all the minimum series in RED how to do this?


title: List plot 3D not showing correct data

text: I have a list of values of the form `{{a_1,b_1,c_1},{a_2,b_2,c_2}...}` where `a` goes from 0 to 30, `b` goes from 0 to 30, and `c` goes from 0 to .05. For some reason, when I plot this using `ListPlot3D` I get ranges of 1 to 4, 0 to 40, and 0 to 500 respectively (the number of data points that I am plotting. The exact command that I am using is: `ListPlot3D[data,PlotRange->{Full,Full,Full},AxesLabel->{"Length","Distance","Time"}]` Does anyone know what might be the issue? Note: If anyone wants to look at the actual data, I posted it here.


title: Asymptotic series

text: I need to solve the following problem. I have the following function: `Erf[Sqrt[a x^2 + b y^2]]/Sqrt[a x^2 + b y^2]`, where x and y are variables and a and b parameters. I need to slightly modify the function (maybe adding an additional parameter, multiplying with the given parameters or modifying denominator, such as, that its major term in the series expansion about infinity for x and y would be 1/x and 1/y, respectively. This is what I get:               FullSimplify[Series[Erf[Sqrt[a x^2 + b y^2]]/Sqrt[a x^2 + b y^2], {x, Infinity, 2}]]      and the major term in the output would be `1/(Sqrt[a] x)` Also with the y:               FullSimplify[Series[Erf[Sqrt[a x^2 + b y^2]]/Sqrt[a x^2 + b y^2], {y, Infinity,     2}]]1/(Sqrt[a] x)      and the major term in the output would be `1/(Sqrt[a] y)` So I need a function similar to one here `(Erf[Sqrt[a x^2 + b y^2]]/Sqrt[a x^2 + b y^2])`, who will give both 1/x and 1/y respectively, for the given mathematica inputs. Has anybody got an idea how to modify the function? An intuitive way was to multiply it by `Square[a b]`, but I tried and it did not work. I tried the other things, but the problem to me didn't seem trivial. Has anyone got an idea? Also does anybody know what Mathematica does to make a series of a function of 2 variables around infinity? I know it is called the asymptotic series, but what would be practical way to get it. Having an insight about that some constraint can be found about the function, and therefore the above-mentioned problem can be solved.


title: Simplifying the trace of a matrix expression

text: I have a long expression involving matrices that I derived using the NCAlgebra package. Can I simplify the trace of the expression? For example, say `b` is a scalar (commutes with all) and `x` and `y` are matrices (non-commutative). Can I simplify `Tr[b x.y.y + b y.x.y]` to `2b Tr[x.y.y]` using the properties of the trace? * * * Thanks, that is what I am going for (although I don't quite understand the code) but I only have version 8. The expression is given below, where `e` and `r` are scalars, `q` and `v` are matrices and the double star (`**`) denotes products of non-commutative elements. I've done it by hand, but I want to be able to simplify the trace of this with _Mathematica_ (and others which are much longer).               e^2 q ** q - e r q ** v - e r v ** q + r^2 v ** v -       1/12 e^3 r q ** q ** q ** v + 1/12 e^3 r q ** q ** v ** q +       1/24 e^2 r^2 q ** q ** v ** v + 1/12 e^3 r q ** v ** q ** q -       1/12 e^2 r^2 q ** v ** q ** v - 1/12 e^2 r^2 q ** v ** v ** q +       1/24 e r^3 q ** v ** v ** v - 1/12 e^3 r v ** q ** q ** q +       1/6 e^2 r^2 v ** q ** q ** v - 1/12 e^2 r^2 v ** q ** v ** q -       1/24 e r^3 v ** q ** v ** v + 1/24 e^2 r^2 v ** v ** q ** q -       1/24 e r^3 v ** v ** q ** v + 1/24 e r^3 v ** v ** v ** q


title: Avoid making repeated Random Integer in different iterations

text: Assume following code :               Do[        i1 = RandomInteger[{1, 5}];        i2 = RandomInteger[{1, 5}];        While[i1 == i2,  i2 = RandomInteger[{1, 5}]]         , {k, 1, 4}];`      This code makes two `RandomIntegers` which are `i1` and `i2`. I have used `While` loop to avoid making repeated Random numbers in each iteration. But I don't know how it is possible to avoid making repeated Random numbers in whole iterations. For example, following result is the answer after 4 iteration and it is not acceptable : > >      i1=1, i2=2 >      i1=3, i2=2 >      i1=1, i2=2 >      i1,4, i2=1 >   `i1=1` and `i2=2` are repeated twice after 4 iterations. I would be appreciated if someone could help me with this problem.


title: How to efficiently select element in a list of lists?

text: How can I write an efficient version of the following statement?               Cases[list, {_, feature_} /; feature < constant]; // AbsoluteTiming      List is of the form, list = {{feature11,feature12},...,{featuren1,featuren2}}. It has a length in the order of 10^5. On my laptop, a Macbook pro from last year it takes around 0.25s. However, I need to evaluate this expression a lot of times. Any suggestion. Thank you.


title: Apply a function to each element of a list and sum it

text: I have a list               {-1.8, 1.44, 0.2736, -1.72514, 1.17612}      where each element stands for a value of x. e.g. $x1 = -1.8$, $x2 = 1.44$ and so on. How can I find the summation of $ln(2x)$ without manuall calculating it? That is: $ln(2(-1.8)) + ln(2(1.44)) + \ldots + ln(2(1.17612))$


title: 4 circular arcs, how plot the minimal surface?

text: By using Sjoerd de Vries code for circular arcs:               ClearAll[splineCircle];      splineCircle[m_List, r_, angles_List: {0, 2 π}] :=       Module[{seg, ϕ, start, end, pts, w, k}, {start, end} =          Mod[angles // N, 2 π]; If[end <= start, end += 2 π];         seg = Quotient[end - start // N, π/2]; ϕ =          Mod[end - start // N, π/2];         If[seg == 4, seg = 3; ϕ = π/2];         pts = r RotationMatrix[start].# & /@           Join[Take[{{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1,               0}, {-1, -1}, {0, -1}}, 2 seg + 1],            RotationMatrix[seg π/2].# & /@ {{1,               Tan[ϕ/2]}, {Cos[ϕ], Sin[ϕ]}}];         If[Length[m] == 2, pts = m + # & /@ pts,          pts = m + # & /@            Transpose[            Append[Transpose[pts], ConstantArray[0, Length[pts]]]]];         w = Join[          Take[{1, 1/Sqrt[2], 1, 1/Sqrt[2], 1, 1/Sqrt[2], 1},            2 seg + 1], {Cos[ϕ/2], 1}];         k = Join[{0, 0, 0}, Riffle[#, #] &@Range[seg + 1], {seg + 1}];         BSplineCurve[pts, SplineDegree -> 2, SplineKnots -> k,          SplineWeights -> w]] /; Length[m] == 2 || Length[m] == 3          g1 = Graphics3D[        Table[{Hue@0.1,           GeometricTransformation[           Tube[splineCircle[{0, 0, 0}, 1, {0, 3.141592653589}],             1/12], {-1, 1, 1}]}, {1}], Boxed -> False];     g2 = Graphics3D[        Table[{Hue@0.1,           GeometricTransformation[           Tube[splineCircle[{0, -1, 0}, 1, {0, 3.141592653589}], 1/12],            RotationTransform[Pi, {1, 0, 1}]]}, {1}], Boxed -> False];     g3 = Graphics3D[        Table[{Hue@0.1,           GeometricTransformation[           Tube[splineCircle[{0, -1, -2}, 1, {0, 3.141592653589}], 1/12],            RotationTransform[Pi, {1, 0, 1}]]}, {1}], Boxed -> False];     g4 = Graphics3D[        Table[{Hue@0.1,           GeometricTransformation[           Tube[splineCircle[{0, 0, -2}, 1, {0, 3.141592653589}],             1/12], {-1, 1, 1}]}, {1}], Boxed -> False];     g4 = Show[g1, g2, g3, g4]      I plotted these four circular arcs: ![bent circle](http://i.stack.imgur.com/EhSoZ.jpg) How can I make a minimal surface that describes both the space inside it, and outside it stretching out to infinity? The minimal surface should describe the object as a whole and not the four arcs individually.


title: An equivalent in Mathematica

text: Let's say I have a $n$x$m$ matrix $M$ in Matlab and I want to substitute the elements of $M$ that exceed $15$ for $-1$. In Matlab I just write               M(M>15)=-1      and I'm done. I have been struggling to do this in Mathematica. Does Mathematica have an equivalent way to do this? Something that is easy to remember and that takes few lines will be appreciated Thank you


title: Is there a cleaner/shorter way to select-replace in matrices?

text: I love _Mathematica_ , but I find it oddly lacking when it comes to how matrices are handled. Here is an example of code that _works_ but seems like it should be a lot shorter (and minus the loop). I'm a super-newbie though so maybe one of you smart people has an idea for making this nicer. The point is to take all elements of the matrix that evaluate as `True` for some criterion (here, being less than 7) and re-assign them to a new value.               testmat = {{-1, 1, -3}, {10, 11, 5}, {15, -2, 7}};     MatrixForm[testmat]     badpos = Position[testmat, _?(# < 7 &)];     {nend, trash} = Dimensions[badpos];     For[i = 1, i <= nend, i++,       selpos = badpos[[i]];       p1 = selpos[[1]];       p2 = selpos[[2]];       testmat[[p1, p2]] = 0;     ]     MatrixForm[testmat]


title: MATLAB's "logical indexing" in Mathematica

text: % MATLAB code     A=reshape(1:16,4,[])'     k=logical([1 0 0 1; 0 1 1 0; 0 1 1 0;1 0 0 1 ])     A(k)=5-A(k)     %{      4     2     3     1      5    -1    -2     8      9    -5    -6    12     -8    14    15   -11     %}      I need _Mathematica_ code that works like the MATLAB code above. Is there a easy way do this?               A = Range[16]~Partition~4     k = {{1, 0, 0, 1}, {0, 1, 1, 0}, {0, 1, 1, 0}, {1, 0, 0, 1}}     A[[k]] = 5 - A[[k]]      **Updated** :               fA = Flatten[A];     p = Flatten@Position[Flatten@k, 1];     fA[[p]] = 5 - fA[[p]];     Partition[fA, 4]          (*{{4, 2, 3, 1}, {5, -1, -2, 8}, {9, -5, -6, 12}, {-8, 14, 15, -11}}*)


title: RefProp in Mathematica

text: `RefProp` by NIST is a program that calculates the thermodynamic properties of fluids. I need to call certain `RefProp` functions from inside _Mathematica_. Can any one here, who has experience calling `RefProp` functions from _Mathematica_ , tell me how to do this??


title: Fetching data from HTML source

text: I want to generate a couple of plots/graphs with Area51 statistics. Since Area51 doesn't work with the SE API, I'm forced to find another way to get the information I want. That other way is with `RegularExpression[]` (or _Mathematica_ 's string patterns). Let's start with a specific example, then move on to a more general case. _Mathematica_ lets me fetch the source of an `HTML` page with               src=Import["http://area51.stackexchange.com/proposals/4470/martial-arts","Source"];      `src` now contains a string, which is the source code of the page. **What am I looking for?** The information that interests me is the value inside each of the blue squares, as well as its textual counterpart, namely _Needs Work_ , _Okay_ , or _Excellent_. ![enter image description here](http://i.stack.imgur.com/tncq6.png) I would use something like               StringCases[a,       RegularExpression[        "regex"] ->        "$1"]      to get the data I want, but unfortunately I don't know how to write regexes. _Side question_ : should I use _Mathematica_ 's string patterns, or `RegularExpression[]`? **The more general case** Once I can fetch the data above for one site, it's a piece of cake to get it for every proposal in beta. My goal is to be able to plot this data, to see how our site compares against the others concerning SE's top 5 health indicators.


title: Running a package automatically when it's saved

text: When developing some new code (eg. a function to analyse something) I usually make a .m and .nb file. The code goes in to .m is then called from the .nb. But sometimes I forget to run the package after saving and then spend some time wondering why my code changes don't have the desired effect. **Is there a way to run a package automatically after it's saved?** Basically I would like that when I press [Ctrl]+S the package is saved and that the effect of this button being pressed is achieved. ![Mathematica graphics](http://i.stack.imgur.com/JfnBt.png) Currently I put `Import["MyPackage.m"]` at the top of the evaluation cell I'm currently working on in the notebook. Perhaps I could also abuse $Pre for this, but then the package would get imported on every cell evaluation (which is a bit needles). **EDIT** Well, this is what I have so far based on Chirs's answer               FrontEndExecute[      FrontEnd`AddMenuCommands[       "Save", {Delimiter,         MenuItem["Save and Run &Package",          FrontEnd`KernelExecute[NotebookSave[SelectedNotebook[]];          If[FileExtension[NotebookFileName[SelectedNotebook[]]] ==             "m",(*then*)           Get[NotebookFileName[SelectedNotebook[]]];           ];          ], MenuKey["S", Modifiers -> {"Control"}],          System`MenuEvaluator -> Automatic]}]]


title: Use selfdefined ColorFunction to encode z dimension with predefined limits

text: In my last question we defined a colorfunction `cf`. Now I want to use this `ColorFunction` for a number of different plots (`MatrixPlot`, `BarChart3D`, `ListContourPlot` and `ListPlot3D`) as encoding for the `z` value from a given table. For the `ListContourPlot` and `BarChart3D` it seems to work, but I don't know how to apply the color encoding for the remaining plots. An another problem is the definition of a interval for the color encoding - here I mean that my data ranges from e.g. 0...30 , but i want to define a limit for the `ColorFunction` such that values are encoded from 10...20 according to the `ColorFunction`, values below 10 and over 30 should be clamped to the extrema of the `ColorFunction`. Is it possible to achieve something like that?! Thanks in advance!               dataResponse = {{1, 1, 3.}, {2, 1, 3.5}, {3, 1, 5.5}, {4, 1, 9.}, {5, 1, 13.}, {6, 1,        30.}, {1, 2, 3.5}, {2, 2, 5.5}, {3, 2, 7.5}, {4, 2, 8.5}, {5, 2,        15.}, {6, 2, 30.}, {1, 3, 4.}, {2, 3, 5.5}, {3, 3, 8.5}, {4, 3,        10.}, {5, 3, 20.5}, {6, 3, 30.}, {1, 4, 4.5}, {2, 4, 7.5}, {3, 4,        12.5}, {4, 4, 30.}, {5, 4, 30.}, {6, 4, 30.}, {1, 5, 5.}, {2, 5,        8.}, {3, 5, 14.5}, {4, 5, 30.}, {5, 5, 30.}, {6, 5, 30.}, {1, 6,        7.5}, {2, 6, 13.}, {3, 6, 30.}, {4, 6, 30.}, {5, 6, 30.}, {6, 6,        30.}}          cbData = {{215, 48, 39},{252, 141, 89},{254, 224, 144}, {224, 243, 248}, {145, 191, 219}, {69, 117, 180}}     cbData = Reverse[cbData]     With[{rgb = RGBColor @@@(cbData/255)},      cf = Blend[rgb, #]&;     ]          ListPlot3D[ dataResponse,                 Mesh -> All,                  ColorFunction -> cf,                 Boxed -> False,                 FaceGrids -> {                                 {Bottom,{Range[0,5,1],Range[0,5,1]}},                                 {Back,{Range[0,5,1],Range[0,30,5]}},                                 {Left,{Range[0,5,1],Range[0,30,5]}}},                 AspectRatio->1,                 AxesLabel -> {"Scene Complexity","Object Coherence","Response Time"},                 Ticks -> {  {{0,20},{1,30},{2,40},{3,50},{4,60},{5,70}}, {{0,0.045},{1,0.054},{2,0.063},{3,0.072},{4,0.081},{5,0.09}} ,Range[0,30,5]}                 ]      As you can see the resulting mesh is color-coded along the y axis, but I want to have the z-axis color encoded and in addition the values from 0...10 should have the same blue and values 20...30 should be red --> so that they are clamped ![Mesh](http://i.stack.imgur.com/uRfkZ.jpg)


title: Make further objects blurry?

text: I have the following function:               normalSpheres =       Table[Sphere[RandomVariate[NormalDistribution[0, 10], 3], .2], {500}];          Manipulate[      Graphics3D[normalSpheres, Background -> Black, ViewAngle -> 1,        ViewVector -> {{50 Sin[t], 50 Cos[t], 0}, {0, 0, 0}},        ImageSize -> Large], {t, 0, 2 Pi}]      ![enter image description here](http://i.stack.imgur.com/la3jJ.gif) I want to imbue this with a feeling of depth though. The best way I can think of is by creating a blur effect for each `Sphere` that increases the further away the object is from the `ViewPoint` (or `ViewVector[[1]]` in this case). Does anybody have any tips on how I could achieve this? P.S. sorry if the GIF makes anyone dizzy... Keyword: depth of field


title: Disable alert message with internet connectivity off

text: I work in an environment that has mathematica's internet connectivity turned off under Help > Internet Connectivity. Recently, after installing mathematica 10.0, every time mathematica is loaded it complains about internet connectivity and put up messages saying               PacletInstall::offline: The Wolfram System cannot install paclet WolframAutoUpdate because it is currently configured not to use the Internet for paclet downloads. To allow internet access, use Help > Internet Connectivity....      is there a way to disable such alerts/disable the auto update?


title: Setting parts of a list

text: Suppose I have list               a = Range[10]      > `{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}` in which I want to set some elements to be a list               a[[4 ;; 7]] = {1, 2, 3};       > `{1, 2, 3, {1, 2, 3}, {1, 2, 3}, {1, 2, 3}, {1, 2, 3}, 8, 9, 10}` Which is fine and dandy unless my part span is the same length as my list:               a[[4 ;; 6]] = {1, 2, 3};      > `{1, 2, 3, 1, 2, 3, 7, 8, 9, 10}` How can I force the assignment to behave consistently? In my case, I always want the first behaviour. But conceivably someone might always want the second behaviour with errors if the lengths don't match.


title: Nest , Fold ... is there an extension for more than 2 arguments?

text: Fold is an extension of Nest for 2 arguments. How does one extend this concept to multiple arguments. Here is a trivial example:               FoldList[#1 (1 + #2) &, 1000, {.01, .02, .03}]      Say I want do something like:               FoldList[#1(1+#2)-#3&,1000,{.01,.02,.03},{100,200,300}]       where 100,200,300 are the values for #3. I know Fold doesn't work this way. I'm looking for an approach that will work like this... ((1000*(1.01)-100)*1.02-200)*1.03-300). Is there a way to extend Fold to more than 2 arguments? or is there a better approach for solving problems like this?


title: Animating a 2D Plot as a 3D Plot

text: This is a follow up question to the original question: Original Question The accepted solution (provided by @Mark McClure) can also be found in the original question. It is as follows.               u[x_, t_] = -(1/2) Cos[x - t]^2 + 1;     pics = Table[Plot[u[x, t], {x, -10, 10}, PlotRange -> {0, 1.5},      PlotStyle -> {Red, Thickness[0.005]}], {t, 0, 2 Pi, 2 Pi/50}];       Then, export as follows:               Export["anim.gif", pics]      Is there a way of creating a 3D animation from the 2D animation? Something along the lines of the following: Example Thanks, Radz.


title: Exporting BarChart3D as PDF produces artefacts

text: So I think the following image already shows the problem, similar to Avoiding white lines inside filled area in RegionPlot exported as PDF or PS the pdf export of the chart creates thin lines in the plot. The fixing rule proposed in the related question seems not to work (sorry I am really new to mathematica). Disabling the Antialiasing doesnt improves the situation! ![BarChart3D](http://i.stack.imgur.com/7yv57.png)


title: How to group certain symbolic expressions?

text: For example, I have the following expression :               A( 2 x1 + B(y1 + y2) + 2 x2 )      How do I make the output look like this (grouping `(x1 + x2)` and `(y1 + y2)` terms together) ?               2A (x1 + x2) + A B (y1 + y2)      I don't know why `Simplify` doesn't group `(x1 + x2)` together but just gives:               A (2 x1 + 2 x2 + B (y1 + y2))      I can use `Collect` to get `(y1 + y2)` after `Simplify` but how about `(x1 + x2)` ? Remember this is just a simple example, I would have a much more complicated terms involving `(x1 + x2)` and `(y1 + y2)`, so a method with no operation on the constants (`2A` and `A B`) would be great.


title: What's wrong with the following Plot in Manipulate?

text: I try to show the convolution of a step function and a triangle function is smooth with the following code:               Manipulate[f0 = UnitBox[p - t0]; f1 = 2 UnitTriangle[t0];       f2 = Convolve[f0, f1, t0, t1];      Plot[{f0, f1, f2} /. {t0 -> x, t1 -> x}, {x, -3, 3}],      {{p, -2}, Locator}]      It should be something like this: ![The original PIC](http://i.stack.imgur.com/PnT9w.png) But after have a click to locate the Locator, it seems Mathematica have plot some "non-necessary" curves (I have marked by red cross): ![After cilck](http://i.stack.imgur.com/Q22of.png) How the get the right plot?


title: Plot the solution complex transcendental equation

text: I'm trying to plot an implicit function satisfying a complex transcendental equation. The code is the following:               ContourPlot[(e (-1 + e^2) l (-3 + 2 e^2 - l^2) Cosh[2 Sqrt[1 - e^2]] +        (-1 + e^2) (-1 + l^2) (e l Cos[2] - I (1 + l^2) Sin[2]) + Sqrt[1 - e^2]       (I - I l^4 - 2 e (-2 + e^2) l Sqrt[-e^2 + l^2]) Sinh[2 Sqrt[1 - e^2]]) == 0,        {l, 1, 2}, {e, -2, 2}]      I need a real solution of `e` as a function of `l` and also `e<=Min{1,l}`. I don't know why it's empty in the plot. I don't think it's because the solution is out of the range since I tried `l=1`, and there are several solutions, one of which is `e = 0`. Thus I think there must be something wrong with the plot.


title: Importing HDF5 with compound data

text: I am looking to `Import` HDF5 data with compound data. It appears, at least from what I read, that Mathematica 8.0.4 (and previous versions) does not support reading HDF5 with compound data.               file = "someData.h5";     Import[file, "Data"]     Import[file, {"Datasets", 1}]      Returns:               {{"Unsupported Datatype Class", "Compound"}, ... }     Import::h5type: "The datatype of the dataset "\foobar" is not currently supported. "      It has been a while, since Oct 2011 when Mathematica HDF5 and compound arrays was last updated. It was update with info about Scot Martin's HDF5 package. Unfortunately that package appears be a solution for Windows which uses two .Net dlls (hdf5dll.dll and HDF5DotNet.dll) and I have a Mac. Just wondering if there has been any progress? I have looked at using h5dump to create an ASCII file and writing an importer. However there is the overhead of writing the file, reading it, and then parsing it.


title: Approximating a stochastic integral with a Wiener process

text: I would like some assistance to solve the following: $\sum\limits_{i=0}^{n-1} e^{-k(n\Delta t -i\Delta t)}\Delta z_i$ where $z$ is a Wiener process, $\Delta z_i = z((i+1)\Delta t)-z(i\Delta t)$. The code I have so far is as follows. I am very new to _Mathematica_ (and programming in general) so please let me know of any errors.               k = 0.5; t = 2; n = 100; M = 1000     Sum[       Exp[-k (n (t/n) - i (t/n))][WienerProcess[][(i + 1) (t/n)]] -          Exp[-k (n (t/n) - i (t/n))][WienerProcess[][i (t/n)]],        {i, 0, n - 1}]      Note that $k$, $t$, $n$ and $M$ are user defined inputs. Also, I would like some guidance on how to perform $M=1000$ simulations.


title: How can I create an image like this

text: I'm trying to get an algorithm that generates a picture like this ![enter image description here](http://i.stack.imgur.com/vfrVr.png) So far I've tried a little something with the help of the knowledge center, getting a graphics grid of squares already. But what now? I'm completely in the dark on how to trim it in the circle-shape I want. (If there are better solutions out there, please forget what I have started with. My only goal is to get the end result where I can make a pattern like this with variable size in terms of diameter in squares, size of the squares themselves and spacing in between.)               size = 10;     scalesize = 1;     table1 = Table[Graphics[Rectangle[]], {size}, {size}];          GraphicsGrid[table1, Frame -> None, Spacings -> Scaled[scalesize]]


title: random geometric graph generation problem

text: I'm new to Mathematica. I'm trying to generate a random geometric graph in which to have a secure link between any two arbitrary nodes they should share a common key in their key rings (have assigned some keys to each node) in order to get a random key graph but when I write `ShowGraph[g]` I'm unable to plot the graph. Here is my code.               v = {};     If[Length[v] == 0,      n = 100,(*Total number of nodes*)      n = Length[v];(*For pre-defined topologies*)      ]     nprime = 20;(*Average number of neighbours per node*)rc =       N[Sqrt[(nprime + 1)/(n*\[Pi])]]    (*Transmission range*)     rs = rc;(*Sensory range*)K = 4;(*Key ring size*)     Pstart = 10;(*Initial key pool size*)     Pend = 10;(*Last key pool size*)     If[Length[v] == 0,      nsim = 50,(*Number of iterations per P*)      nsim = 1;(*Only makes sense to simulate once for a fixed topology*)      ];     edist[xi_, yi_, xj_, yj_] := {Sqrt[(xi - xj)^2 + (yi - yj)^2], xi, yi};          If[euclidean == True,        dist[xi_, yi_, xj_, yj_] := edist[xi, yi, xj, yj],        dist[xi_, yi_, xj_, yj_] := tdist[xi, yi, xj, yj]];      (* * * * * * * * * * * _Main calculation_ * * * * * * * * * **)               (* * * * * * * * * * * * Main calculation * * * * * * * * * * * *)     For[P = Pstart, P <= Pend, P++,     For[sim = 1, sim <= nsim, sim++,         SeedRandom[sim];     (* Generate vertices if not using a fixed topology {{{ *)         If[Length[v] == 0 || sim > 1,                 v = {};                 For[i = 1, i <= n, i++, v = Append[v, {{Random[], Random[]}}]];             ];         g = Graph[{}, v];         Print["Vertices: ", v]; (* Debug *)          (* Distribute keys randomly {{{ *)         keyrings = {};         For[i = 1, i <= n, i++,                 keyring = {};                 If[P == K,                      For[k = 1, Length[keyring] < K, k++,                         keyring = Append[keyring, k]                     ],                     (* P > K *)                     For[k = 1, Length[keyring] < K, k++,                         key = Random[Integer, {1, P}];                         If[MemberQ[keyring, key] == False,                             keyring = Append[keyring, key]                         ]                     ]                 ];                 keyrings = Append[keyrings, keyring];             ];         Print["Key rings: ", keyrings]; (* Debug *)          (* Determine edges {{{ *)         For[i = 1, i <= n, i++,                 For[j = i + 1, j <= n, j++,                      xi = Extract[Extract[Extract[v, i], 1], 1];                     xj = Extract[Extract[Extract[v, j], 1], 1];                     yi = Extract[Extract[Extract[v, i], 1], 2];                     yj = Extract[Extract[Extract[v, j], 1], 2];                     If[dist[xi, yi, xj, yj][[1]] < rc,             If[Extract[keyrings, {i}] \[Intersection]           Extract[keyrings, {j}] != {},                             g = AddEdge[g, {{i, j}}],                             (* Else *)                             Print["No secure link between ",  i, " ", j]                         ]                     ]                 ]             ];     (*g=Graph[vertices,edgelst,VertexCoordinates\[Rule]v,     DirectedEdges\[Rule]False];*)         ShowGraph[g];     ]     ];      What’s the problem? Can anyone help?


title: Using transparency in ContourPlot makes mesh visible

text: I am trying to use a ColorFunction with Opacity in ContourPlot. Here's my code:               data = RandomVariate[BinormalDistribution[.75], 10];     d = SmoothKernelDistribution[data];     cf[z_] := {Opacity[z], Red};     sc1 = ContourPlot[        Evaluate@PDF[d, {x, y}], {x, -3, 3}, {y, -3, 3},         PlotRange -> All, PlotPoints -> 50, ColorFunction -> cf,         ColorFunctionScaling -> True]      And here's what it produces: ![enter image description here](http://i.stack.imgur.com/mT8td.png) How can the ugly mesh be avoided? I am using Mathematica 8.0.1 in OS X.


title: Mesh and ParametricPlot

text: Is this a bug, or something going over my head? When using the following code, nothing "special" happens:               ParametricPlot[a {Cos[t], Sin[t]}, {a, 1, 2}, {t, 0, 2 Pi},       Mesh -> None, PlotStyle -> Opacity[0.2]]      it works as expected, one gets this graphic, without any mesh lines: ![enter image description here](http://i.stack.imgur.com/uY41e.png) When adding `Graphics[]` in front of that—as I'd like to `Show` such a `ParametricPlot` with some other graphics, I get this:               Show[      Graphics[],      ParametricPlot[a {Cos[t], Sin[t]}, {a, 1, 2}, {t, 0, 2 Pi},        Mesh -> None, PlotStyle -> Opacity[0.2]]      ]      yields: ![enter image description here](http://i.stack.imgur.com/m2Ggy.png) Why do those mesh-lines come up? Are those actually Mesh-lines, as I used `Mesh -> None`? How can I delete those lines, while still using `Show` and others `Graphics[]`? Thanks for all help!


title: parameter NDSolve

text: the question I need to solve is:               t x'[t] == -x[t] + y[t],       t y'[t] == -5 t^2/x[t]^2 + x[t] - y[t],            x[1] == 4, x[b] == 1      in order to solve the coupled equations, I need 2 boundaries for `x[1]` and `y[1]`, so I can convert the question into shooting method               {xsoln, ysoln} = {x, y} /. ParametricNDSolve[{  t x'[t] == -x[t] + y[t],       t y'[t] == -5 t^2/x[t]^2 + x[t] - y[t],     x[1] == 4, y[1] == a}, {x, y}, {t, 1, b}, {a,b}]      for each specific value of `b`, I can find the value of `a` which satisfies `x[b]==1` manually. But if there is any possibility that I can find the value of `a` for any value of `b` instead of plugging the value of `b` and repeating the above process. the way I am getting the value of `a` is as follows: first I set `b=100`, then I plot `xsoln[a][100]`, then I can locate the region of `a` which satisfies `x[100]==1`, so I use `findroot` to find the exact value of `a`. I naively set `f[b_?NumericQ]:=a/.FindRoot[xsoln[a][b]==1,{a,0}]`, so for any `b`, I have the value of `a`. But `xsol[a][b]` is not well behaved. I can not set `FindRoot` at `a` around `0`, the starting point differs for different `b`, which can only be seted by plotting the profile and detect the starting point. my another idea is by adding `WhenEvent` into `NDSolve`, which is like `WhenEvent[xsoln[a][b] does not equal to 1, change the value of a, and do the calculation again]` Thanks folks


title: Automatic replacing of [ with []

text: I tried to modify the `KeyEventTranslations.tr` file in order to always place a closed bracket instead of an open bracket once I press `[`. However once I press `[` after the modification nothing happens (the cursor just stays at the same position and not even a `[` is placed).               Item[KeyEvent["["],             FrontEndExecute[{                 FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],                     "[", After],                 FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],                     "]", Before]             }]],       the Code is a slight modification of what i found regarding double brackets: Automating Esc [[ Esc formatting? (There is a comment below the top answer, which also mentions Problems regarding `[` and German keyboard language). If I use a different character like `/` to trigger the `KeyEvent`, which does not have to be typed using the AltGr-key               Item[KeyEvent["/"],             FrontEndExecute[{                 FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],                     "[", After],                 FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],                     "]", Before]             }]],       the closed bracket will be placed as expected. Other keys like `{` using `AltGr` do not work either. I tried renaming the `term.dll` files as suggested here: Is it possible to get AltGr key to work in Math.exe? unfortunately this did not fix the Problem. Additional Information: I'm using Win7 and my keyboard language is set to German. (And I would like to keep it set to German). If there is any other way circumventing the `KeyEventTranslations.tr` to automaticaly place `[]` with the cursor placed between the brackets once I press `[`, it would be fine as well. Thanks in advance if anyone tries to answer my question :)


title: Reading from a text file and store the results back into it

text: I am totally new to mathematica but started learning how to use it. I use the following function to convert a decimal number into its binary representation.               binExp[num_, d_] := First[RealDigits[N[num, d], 2]];      Currently, I am stuck with two points:   1. If I type `binExp[240, 7]`, I get a 23-bit binary representation of a decimal number in the interval `[0,255]` BUT I need a 24-bit binary representation of it.   2. I have a `100,000` decimal numbers stored in a text file and want to use the previous function within mathematica to convert all of them to their 24-bit binary representation and store them back in a text file. Any help is appreciated.


title: Subgraph, HighlightGraph not acting as expected

text: I'm trying to create a simple graph from a matrix and then highlight a particular subgraph. My code (simplified from a bigger task) is as follows. I keep getting the "Subgraph::graph: A graph object is expected at position 1" message whenever I try to use Subgraph (or HighlightGraph). What might I be doing wrong? Thanks in advance for the help.               << Combinatorica`      > General::compat: Combinatorica Graph and Permutations functionality has been > superseded by preloaded functionality. The package now being loaded may > conflict with this. Please see the Compatibility Guide for details.               BB = Table[0, {i, 4}, {j, 4}];     BB[[1]][[2]] = 1;     BB[[2]][[1]] = 1;     BB      > {{0, 1, 0, 0}, {1, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}               Gr = FromAdjacencyMatrix[BB];     Subgraph[Gr, {1, 2}]      > Subgraph::graph: A graph object is expected at position 1 in > RowBox[{"Subgraph", "[", > RowBox[{InterpretationBox[StyleBox[RowBox[{"[SkeletonIndicator]", "Graph:<", > 0, ",", 4, ",", "Undirected", ">[SkeletonIndicator]"}], ShowAutoStyles -> > False, AutoSpacing -> False], Graph[{}, {{{0, 1.}}, {{-1., 0}}, {{0, -1.}}, > {{1., 0}}}], Editable -> False], ",", ({1, 2})}], "]"}]. >>


title: Given a Table of Plots with some parameter, how would I mark each of the plots with that parameter

text: I've got a two variable function that I'm plotting against one axis for a few different values of a parameter               Clear[f, r]     f[r_] := 4 r /(1 - r)^2     i[r_, delta_] := 1/(1 + f[r] Sin[delta/2]^2)     Show[      Table[ Plot[i[r, delta], {delta, 0, 4 Pi},        PlotRange -> {0, 1}], {r, {0.1, 0.3, 0.6, 0.97}}]      ]      This looks like ![Plot of etalon interference](http://i.stack.imgur.com/jd5PZ.png) but I'd like to label each of the curves with the value of the parameter (`r = 0.1`, `r = 0.3`, ...). I can do this manually inserting labels with the Graphics controls, but figured there's got to be a better way.


title: How to test if file exists and stop

text: At the moment I'm using >               filename = FileNameJoin[{root = "F:\\somefolderpath", file = "somefile.extention"}];     If[! DirectoryQ[root],        Print[Style["Directory '" <> root <> "' does not exist!", {Red, Bold, Large}]]; Quit[]];     If[! FileExistsQ[filename],        Print[Style["File '" <> filename <> "' does not exist!", {Red, Bold, Large}]]; Quit[]];     (*Start using 'filename'*)      edit: Ended up using               SafeFile::usage = "Use instead of Import.";     SafeFile::nodir = "Directory `1` does not exist.";     SafeFile::nofile = "File `1` does not exist.";     SafeFile[filename_,root_:NotebookDirectory[]]:=Module[{         fullfilename=FileNameJoin[{root,filename}]     },         If[!TrueQ@DirectoryQ@root,Message[SafeFile::nodir,root];Quit[]];         If[!TrueQ@FileExistsQ@fullfilename,Message[SafeFile::nofile,filename];Quit[]];         Import[fullfilename]     ]      Quitting kernel was actually what I needed.


title: Ugly output when combining 2 plots with GraphicsRow

text: Here are the data that I want to plot:               meandatf1 = Mean /@ datf1     meandatf2 = Mean /@ datf2          {1.48908, 1.49641, 1.49354, 1.50385, 1.49835, 1.49617, 1.50569, \     1.50117, 1.50226, 1.50151, 1.50108, 1.50031, 1.49955, 1.49721, \     1.49898, 1.50266, 1.50177, 1.50227, 1.49886, 1.50002}          {-0.00127783, 0.000556012, 0.0000143709, -0.000602328, -0.000375952, \     -0.00125357, 0.0000228143, 0.000175103, 0.000868018, -0.0003298, \     0.000230178, 0.000222689, -0.0000624273, -0.0000760139, -0.000263302, \     0.0000826082, 0.000206463, 0.0000507921, -0.0000955452, 0.000184107}      And here is how I generate my individual plots:               genPlot[c_, dat_, ymin_, ymax_, legend_] :=      ListPlot[{        Table[c, {Length[dat]}], dat},        AxesLabel -> {"N", "\[Mu]"}, PlotRange -> {Automatic, {ymin, ymax}},        PlotLegends -> Placed[legend, Above],        Joined -> True, Mesh -> None, InterpolationOrder -> 0,         ImageSize -> 400] (* I tried also without ImageSize, see below *)          plot1 = genPlot[3/2, meandatf1,  1.45,  1.55,  "\[ScriptCapitalD]1"]     plot2 = genPlot[0,   meandatf2, -0.004, 0.004, "\[ScriptCapitalD]2"]      The output of the individual plots is fine: ![enter image description here](http://i.stack.imgur.com/gOVTt.png) But when I combine the two plots with `GraphicsRow[]` I get this ugly output: ![enter image description here](http://i.stack.imgur.com/vJUfz.png) When I don't specify `ImageSize` in `genPlot[]` the combined plot is very small (but otherwise looks fine): ![enter image description here](http://i.stack.imgur.com/b3cQJ.png) If I set `ImageSize` in the `GraphicsRow[]` (and not in `genPlot[]`) the container image is increased instead of the contained cells (which is reasonable, but was a desperate long shot by my side): ![enter image description here](http://i.stack.imgur.com/ARihe.png) It must be something trivial that I am missing. Any ideas? **EDIT1** : I am using _Mathematica_ 9.0.1 under Mac OSX Mavericks. **EDIT2** : Pretty much all of the proposed solutions worked for me. I wish I could accept >1 but, since this is not possible, I'll accept the one from @JasonB for its beauty of simplicity.


title: How can I compute the chromatic index and number of a graph?

text: I saw a recent question from M.R. and realized there is no function to compute the chromatic index and number of a graph, other than a really slow method in the now deprecated _Combinatorica_. So, how can I compute the chromatic index and number of a graph?


title: Locking a value when Manipulating variables

text: I'm trying to achieve something similar to Bret Victor's brilliant Scrubbing Calculator in Mathematica. By using Manipulate I'd like to change the values of the variables such that if I modify one the others adapt to ensure the equation is always true. In the example below I'd like to be able to move spaces and have boxes change accordingly.               Manipulate[4 spaces + 3 boxes = 640, {spaces, 0, 640}, {boxes, 0, 640}]      ![The simplest case](http://i.stack.imgur.com/cHgE2.png) Solving for the two variables explicitly I can achieve the desired effect but doing so kind of voids the idea of an intuitive calculator.               Manipulate[{Dynamic[spaces = 160 - (3 boxes)/4],        Dynamic[boxes = -(4/3) (spaces - 160)]}, {boxes, 0, 640}, {spaces,        0, 640}]      ![The hard way](http://i.stack.imgur.com/fAX5N.png) Now, kind Mathematicans, my question is this: Is there a way of doing this the first, more intuitive, way?


Graphing the sequence {$p_k$} = $\frac{c - a + dp_{k-1}}{b}$ I need to know how to graph this function where it automatically plugs in the previous term for $p_{k-1}$, the coefficients are of my choosing lets just say $a=1$, $b=3$, $c=2$, $d=-1$, these numbers are arbitrary. The whole point is that i want to find out what coefficients will make this oscillate.


title: Jacobian matrix formation from polynomial expressions

text: I want to find the jacobian matrix for 3 polynomial expression with 3 variables.. the polynomial expressions have the degree of 8.how to form it.?


title: Select Cells to End of Notebook

text: I'd like to create a keyboard shortcut that will allow me to select all of the cells from the current cell until the end of the notebook, similar to how `Shift``Ctrl``End` functions when editing text in most Windows applications. By editing `KeyEventTranslations.tr`, I've already created a shortcut using `Shift``Ctrl``A` that allows me to select the current cell (rather then pressing `Ctrl``.` repeatedly). I'd like to then use another shortcut that would allow me to avoid having to hold down `Shift` and press `↓` over and over until I reach the bottom. Any ideas?


title: Maximization of a 3-variable function

text: So I define a 3-variable function $h$ and I want to find the maximum of $h$ in a region $\mathcal{R}$:               h[x_, y_, z_] := y (a - z) - z (a - t) + (y + x) (Max[0, b - (y - z)] - x + 1)     Maximize[{h[x, y, z], 0 <= z <= t, z <= y <= a, 0 <= x <= Max[0, b - (y - z)]}, {x, y, z}]      Here I'm treating $a,b,t$ as constants. Shouldn't Mathematica return the maximum of $h$ as a function of $a,b,t$?


title: Density plot on the surface of sphere

text: I would like to make density plots of a list of (size 2 or 3) spherical harmonics on the surface of a sphere. I'd like to plot it so that each element of that list is using a different color (red density plot for the first one, blue for the next, green... and so on) I tried using `ColorFunction` like               SphericalPlot3D[1, {θ, 0, Pi}, {ϕ, 0, 2 Pi},       ColorFunction ->        Function[{x, y, z, θ, ϕ, r},         RGBColor[Abs[SphericalHarmonicY[1, 1, θ, ϕ]]^2,          Abs[SphericalHarmonicY[1, 0, θ, ϕ]]^2,          Abs[SphericalHarmonicY[1, -1, θ, ϕ]]^2]]]      but all I get is some dark-green sphere. Is there a function like `SphericalDensityPlot` so that I can illustrate the functions? Also, a big problem I'm running into is the ambient lighting direction, which interferes with what it's supposed to look like.


title: Visualizing 3D vector field on surface of sphere

text: I want to vizualize (quite complicated) 3D vector field which has both real and imaginary part and is expressed in spherical coordinates. I was thinking about expressing the field for certain _r_ and then plotting Norm of the vector field on the surface of sphere as some color map. Can anyone give me advice how to do it, please?


title: How to protect functions in a Mathematica Package?

text: I'm writing a Mathematica Package with many functions, but only two can be seen/public. I have:               BeginPackage["VolumeReserves`"];          startInterface::usage = "...";          detailRock::usage = "...";          (* Implementation of functions *)          Begin["`private`"];          global private and initialized variables;          startInterface[___] := ...          detailRock[___] := ...          f1[] := ...          f2[] := ...          f3[] := ...               (* And finally I do: *)          SetAttributes[startInterface, {Protected, Locked}];     SetAttributes[detailRock, {Protected, Locked}];     SetAttributes[f1, {Protected, Locked}];     SetAttributes[f2, {Protected, Locked}];     SetAttributes[f3, {Protected, Locked}];          End[];     EndPackage[];      When I open a new notebook and I load the package for the first time with:               SetDirectory[StringJoin[NotebookDirectory[]]];     << VolumeReserves`      Everything is OK, but if I evaluate the notebook one more time (and so on) I get:               Set::write: Tag startInterface in startInterface[___] is Protected. >>     Set::write: Tag detailRock in detailRock[] is Protected. >>     Set::write: Tag f1 in detailRock[] is Protected. >>     ...     General::stop: Further output of SetDelayed::write will be suppressed during this calculation. >>      So this is a little strange... Why can't I reload/re-evaluate the notebook/package? Should I quit the kernel every time? I've tried to evaluate some of Mathematica Packages, such ComputerArithmetic, more than once, and it doesn't show that error...


title: Finding neighbors from list

text: Say you are given the following list:               list={{3, 2, 1}, {3, 4, 2}, {2, 4, 1}, {1, 4, 3}};      Two numbers $x,y$, not necessarily distinct, are neighbors if one of the sub- lists contains both of $x$ and $y$. In more precise mathematical language: let $S=\{A_1,A_2,\dots,A_n\}$ be a collection of $n$ sets, each containing integers between $1$ and $m$. Then $x$ and $y$ are neighbors if $\exists A_i:x,y\in A_i$. I am looking for an efficient way of finding all the neighbors of each element. That is, let $S'=\{B_1,B_2,\dots,B_m\}$. Then $B_i$ contains all the neighbors of $i$. Note that $B_i$ may be empty if the integer $i$ does not appear in any of the sets in $S$. My current implementation is:               Union @@@Function[x, Select[list, MemberQ[#, x] &]] /@ Range@Max@list          (*{{1, 2, 3, 4}, {1, 2, 3, 4}, {1, 2, 3, 4}, {1, 2, 3, 4}}*)      However, it gets fairly slow on large lists. Is there a more efficient way of finding $S'$ in Mathematica?


title: importing a file with asterisk in its name (Linux machines)

text: I am trying to import a file:               filename = "furan.b3lyp.6-31G*.sdat"     path = "/home/molkee/Desktop/plots/scr/" <> filename;     FileExistsQ[path]     data = Import[path, "Table"];      I am getting the _Recursion Limit_ error. I guess this happens because of the asterisk in the filename, but why? What is going on? What is the right way to import it? FILE


title: Energy Equation: Boundary and initial condition

text: I'm trying to solve the energy equation and NDSolve is able to solve the problem. Even though the result is acceptable, I have always the warning "boundary and initial conditions are inconsistent". I've been trying a lot of function in order to solve this inconsistence, but I couldn't. The energy equation in cylindrical coordinate is:                (df*cf*(D[tf[x, r, t], t] + mom[r]*D[tf[x, r, t], x])) == ((1/r)*         D[(r*kf*D[tf[x, r, t], r]), r])       The initial condition is: 1) tf[x,r,0]==298 The boundary conditions are:   * 1) tf[0,r,t]==373   * 2) (D[tf[x, r, t], r] /. r -> 0.0000001) == 0 (for r=0 there is a discontinuity due to mom[r], the velocity profile)   * 3) kf*(D[tf[x, r, t], r] /. r -> (r0/1000)) == hi*(335 - 298) (this bc is not respected by Mathematica). Could some one help me? Thank you!


title: Equating and solving equations that have been generated using table[]

text: I am in the process of trying to use Mathematica to find the coefficients of transmission and reflection for the wavefunction of a beam of particles tunnelling across any number of identical potential barriers. I have got to the stage where I am able to generate the equations for n numbers of barriers, but I am not able to equate the appropriate equations to each other to solve them for the coefficients. The module I have written to generate the relavant equations is:               GeneratePhiEqs[N_] :=         Module[{inceqs, diffinceqs, bareqs, diffbareqs, finaleq, difffinaleq,         IncidentPhi, BarrierPhi, FinalTransmittedPhi, phieqs},          IncidentPhi[x_, n_] := T[n]*E^(I*k*x) + R[n]*E^(-I*k*x);         BarrierPhi[x_, n_] := A[n]*E^(r*x) + B[n]*E^(-r*x);         FinalTransmittedPhi[x_, n_] := T[n]*E^(I*k*x); T[0] = 1;              inceqs = Table[Phi[j] = {IncidentPhi[x, j]}, {j, 0, N}];         diffinceqs =          Table[Phi[N + j] = {D[IncidentPhi[x, j], x]}, {j, 0, N - 1}];         bareqs = Table[Phi[2 N + j - 1] = {BarrierPhi[x, j]}, {j, N}];         diffbareqs =          Table[Phi[3 N + j - 1] = {D[BarrierPhi[x, j], x]}, {j, N}];         finaleq = Phi[4 N] = FinalTransmittedPhi[ x, N];         difffinaleq = Phi[4 N + 1] = D[FinalTransmittedPhi[x, N], x];         phieqs = {inceqs, diffinceqs, bareqs, diffbareqs, finaleq,          difffinaleq}; phieqs]      The module I have written (or what it looks like so far) to equate the relevant equations is:               SolvePhiEqs[number_] :=          Module[{eqs, simeqs}, eqs = GeneratePhiEqs[number];          simeqs = Table[{Phi[j] /. phieqs == Phi[2*number + j] /.          phieqs}, {j, 2*number - 1}]; simeqs]       Basically, the equations that I generated with the first module will not substitute in correctly, they just remain isolated from each other surrounded by curly brackets. Any suggestions would be much appreciated! Thanks.


title: Performing a chi-square goodness of fit test

text: How would I perform a chi-square goodness of fit test? I have tried the following, where my data consists of the observed values whilst the data pair contains the correct values. Then I use the `DistributionFitTest` on the data and the data pair.               data = {115, 188, 97};     datapair = {100, 200, 100};     DistributionFitTest[datapair, data]          (* Out= 0.248213 *)      However the result I get is `0.248` and should be `0.216`. Am I doing something wrong? And how would I measure the $\chi^2$ value?


title: Image convolution, motion blur

text: I define my degradation function as $$H(x,y;a,b,t)=\frac{T}{z}\sin z~e^{-jz}$$ where $$z=\pi(ax+by)$$ So I write               H[a_, b_, T_] :=        Function[{x, y}, z = Pi*(a*x + b*y); If[z == 0, T, T*N[Sin[z]*Exp[-I*z]/z]]];      But when I convolve it with image               Image[Abs[InverseFourier[Fourier[img]*Array[H[a, b, T], {row, col}]]], "Real"]      The blurred image is almost white. What's wrong with my program? ### Edit Here is my runnable program               img = Import["Lena.tif", "Data"];     {row, col} = Dimensions[img];     H[a_, b_, T_] := Function[{x, y}, z = Pi*(a*x+b*y); T*N[Sinc[z]*Exp[-I*z]]];     filter = Array[H[0.1, 0.1, 1], {row, col}];     Image[Abs[InverseFourier[Fourier[img]*filter]], "Real"]


title: Question about making TabView remember what tab to open

text: Background: Consider the following ( for the purpose of illustrating this question ) simplified, but working snippet of code.                TabView[       {        {patt, "Pattern" -> 1},        {motif, "Motif" -> Column[{           Button["Type", Print[" NOT IMPLEMENTED YET"], ImageSize -> 100],           Button["New shape", Print[" NOT IMPLEMENTED YET"], ImageSize -> 100],           Button["Pixel", Print[" NOT IMPLEMENTED YET"], ImageSize -> 100]}]}       },       Dynamic[tab]]      I have a GUI in a Module / Manipulate construction which contains a tabview that displays several views of the same data on its tabs. Each tab contains a series of buttons to further specify the particular view on that tab. Each tab consists several buttons and other controls, i.e. setterbars, 2D sliders. After each click or other action on a control the data is modified and all views are recalculated and displayed on the tabs. The issue is that after each tab the tabview always returns to page 1. I have already made accomodations by using the following format of TabView:                 TabView[{         {value1, "Tabname"->CodeOnTab1},         {valueN, "Tabname"->CodeOnTabn} },        Dynamic[VAR]      As I understand the Tabview opens tabN if VAR is set to valueN. This leads to the following question: what is the best =coding strategy= to make a TabView aware of the tab it should display ( open ) when it is re-displayed ( considering the last user action ) ? **The goal / criteria is: minimal code use.**


title: Lorenz map for the Rössler system

text: > **Possible Duplicate:**   >  How to find all the local minima/maxima in a range I have the solution of the following non-linear system:               sol1 = NDSolve[       {x'[t] == -(y[t] + z[t]),        y'[t] == x[t] + 0.2 y[t],        z'[t] == 0.2 + x[t] z[t] - 5.7 z[t],        x[0] == 1, y[0] == 1, z[0] == 1       },       {x, y, z},       {t, 0, 100}       ]      How can I find the $k^{th}$ local maximum of $z(t)$, i.e. $z(k)$, and then plot $z(k+1)$ vs. $z(k)$? There is an example in the "Mapping local maxima" section in Rössler attractor's wiki page. I am working with Wolfram Mathematica 8.0.


title: Find all points that have the same minimum?

text: > **Possible Duplicate:**   >  How to find all the local minima/maxima in a range `Sin[x]` have two points ($3\pi/2,7\pi/2$) where the same minimum ($-1$) is achieved at the range from $0$ to 4 $\pi$. I don't know how to get two points at once, if using `Minimize`, only only one point can be got.               Minimize[{Sin[x], 0 <= x <= 4 Pi}, x]      the output: > `{-1, {x -> (7 \\[Pi])/2}}` And the last sentence of the information about `Minimize` gives a definitely declaration, which almost cut off this road: > Even if the same minimum is achieved at several points, only one is > returned. Other similar function like `FindMinimum` seems to be helpless either,so are there any methods to help achieve that goal?


title: How to obtain all minima?

text: If you `Solve` an equation, you obtain _all_ solutions. But If you `NMinimize` a function, you only get one minimum. The question is: is there a way to obtain all minima of a given function? Example:               Solve[((x - 2) (x + 2))^2 == 0, x]     Print["____________"]     NMinimize[((x - 2) (x + 2))^2, x]     NMinimize[ {((x - 2) (x + 2))^2, x >= 0}, x]      yields               {{x -> -2}, {x -> -2}, {x -> 2}, {x -> 2}}     ____________     {0., {x -> -2.}}     {0., {x -> 2.}}      You can see that for `Solve` you obtain all solutions, even with their multiplicity, but in the minimization, you only obtain one solution.


title: ParallelTable and expensive functions

text: I would like to build up a 2D-Table using `ParallelTable` as follows               tab = Flatten[ParallelTable[{i,j,f[i,j]},{i,1,ni},{j,1,nj}],1];      This instruction works perfectly. However, I would like to speed it up. Indeed, the function `f[i,j]` is defined as `f[i_,j_] := f1[i] f2[i,j]` The particularity here is that `f1[i]` is expensive to compute, so that I would like to compute it only one time for each `i`. How would it be possible to tune the `ParallelTable` so that `f1[i]` is only evaluated when it has never been done before ? A kind of _nested_ `ParallelTable` ? Using _memoization_ ? (As the construction of the table remains long, it is key for me to necessarily use parallelized evaluations on multiples cores)


title: Missing arrow tips and colors

text: **My main problem is:** I plotted a curve here, but the tip of some arrows are missing. Why does this happen, and how can I fix this? _Not the main problem:_ Also, I once tried to make the arrows with different colors, but all of them would be of the same color as the first one. How can I make them different colors? And I have a strong impression that I'm not being intelligent using `Graphics3D` all this much, for every single arrow. It must have a cleaner way to do it. (Maybe I should ask a different question for this, but I don't want to flood the site. If you can help me with the main problem, I'll be happy already) [ **EDIT:** wxffles already helped me with this issue in the comments. What is left is the main problem now.] ![enter image description here](http://i.stack.imgur.com/ssdqE.png) The code as it is now, in case it helps:               a[t_] := {1 + Cos[t], Sin[t], 2 Sin[t/2]}     tf[t_] := {(-Sin[t])/(Sqrt[1 + Cos[t/2]^2]), (Cos[t])/(Sqrt[          1 + Cos[t/2]^2]), (Cos[t/2])/(Sqrt[1 + Cos[t/2]^2])}     bf[t_] :=       Rationalize@{(-0.5 Cos[t] Sin[t/2] + Cos[t/2] Sin[t])/          Sqrt[1.625 + 0.375 Cos[t]], (-Cos[t/2] Cos[t] -            0.5 Sin[t/2] Sin[t])/Sqrt[1.625 + 0.375 Cos[t]],         1/Sqrt[1.625 + 0.375 Cos[t]]}     nf[t_] := {-((3 + 12 Cos[t] + Cos[2 t])/(        2 Sqrt[3 + Cos[t]] Sqrt[13 + 3 Cos[t]])), -(((6 + Cos[t]) Sin[t])/(        Sqrt[3 + Cos[t]] Sqrt[13 + 3 Cos[t]])), -((2 Sin[t/2])/(        Sqrt[3 + Cos[t]] Sqrt[13 + 3 Cos[t]]))}                   Show[ParametricPlot3D[{1 + Cos[t], Sin[t], 2 Sin[t/2]}, {t, 0,             4 \[Pi]},            PlotStyle -> Directive[RGBColor[0.91`, 0.`, 0.`], Opacity[1.`]],            BoxRatios -> {1, 1, 1}, Boxed -> False, AxesOrigin -> {0, 0, 0}],           Graphics3D[Arrowheads[0.02], Arrow[{a[0], a[0] + tf[0]}]],           Graphics3D[Arrow[{a[0], a[0] + tf[0]}]],           Graphics3D[Arrow[{a[1], a[1] + tf[1]}]],           Graphics3D[Arrow[{a[Pi/2], a[Pi/2] + tf[Pi/2]}]],           Graphics3D[Arrow[{a[2], a[2] + tf[2]}]],           Graphics3D[Arrow[{a[Pi], a[Pi] + tf[Pi]}]],           Graphics3D[Arrow[{a[3 Pi/2], a[3 Pi/2] + tf[3 Pi/2]}]],           Graphics3D[Arrow[{a[2 Pi], a[2 Pi] + tf[2 Pi]}]],           Graphics3D[Arrow[{a[0], a[0] + bf[0]}]],           Graphics3D[Arrow[{a[0], a[0] + bf[0]}]],           Graphics3D[Arrow[{a[1], a[1] + bf[1]}]],           Graphics3D[Arrow[{a[Pi/2], a[Pi/2] + bf[Pi/2]}]],           Graphics3D[Arrow[{a[2], a[2] + bf[2]}]],           Graphics3D[Arrow[{a[Pi], a[Pi] + bf[Pi]}]],           Graphics3D[Arrow[{a[3 Pi/2], a[3 Pi/2] + bf[3 Pi/2]}]],           Graphics3D[Arrow[{a[2 Pi], a[2 Pi] + bf[2 Pi]}]],           Graphics3D[Arrow[{a[0], a[0] + nf[0]}]],           Graphics3D[Arrow[{a[0], a[0] + nf[0]}]],           Graphics3D[Arrow[{a[1], a[1] + nf[1]}]],           Graphics3D[Arrow[{a[Pi/2], a[Pi/2] + nf[Pi/2]}]],           Graphics3D[Arrow[{a[2], a[2] + nf[2]}]],           Graphics3D[Arrow[{a[Pi], a[Pi] + nf[Pi]}]],           Graphics3D[Arrow[{a[3 Pi/2], a[3 Pi/2] + nf[3 Pi/2]}]],           Graphics3D[Arrow[{a[2 Pi], a[2 Pi] + nf[2 Pi]}]]]      Thanks for your time.


title: 3D view of a route shown on a map

text: You should have already seen such a thing, specially in documentaries about ancient life: the movement of a tribe is shown on an ancient map along a route with a dashed arrow. I want to do the same thing in Mathematica. Given a bitmap image of a map like this one and a list of points on the 2d map such as `{{123,233}, {177, 279}, ...}`, I want to make a movie that shows an arrow along the given route on the map. The movie looks like it is captured from a helicopter flying on the map. _Edit:_ This is what I did after `rm -rf♦`'s comment:               map = ImageResize[        Import["http://upload.wikimedia.org/wikipedia/commons/e/e3/China_\     old_map.jpg"], 500];     path = .3 {{300, 500}, {350, 600}, {450, 700}, {600, 750}, {650,           750}, {700, 780}, {800, 800}, {850, 900}, {900, 1000}, {1000,           1050}, {1100, 1050}, {1150, 1100}};     ListAnimate[      Table[Show[map, Graphics[{Thick, Dashed, Arrow[Take[path, i]]}],         ImageSize -> {500}], {i, Length@path}]]