Make an effective projection of matrix

To best explain my problem, I will take the following example: Consider the following matrix : `A = {{1, 2, 3, 4, ""}, {"", 2, 3, 4, ""}, {"", "", 3, 4, ""}, {"", "", "", 4, 5}}` I designed the following two algorithms :               ProjVt[x_, y_, pat_] :=          Block[                     {X = x, Y = y, Grid11, Grid21, Resvf1},                          Grid11 = PosGrid[X, pat];                          Grid21 = ConstantArray["", 10000];                          Table[                           Table[                                 Grid21[[ Grid11[[i, j]] ]] = X[[i, Grid11[[i, j]] [[1]]  ]],                                 {j, 1, Length[Grid11[[i]]], 1}                                ],                                 {i, 1, Length[X], 1}                         ];                           Resvf1 =  Grid21[[1 ;; Length[Y]]]                      ];      and               ProjHt[x_, y_, pat_] :=     Block[                    {X = x, Y = y, Grid12, Grid22, Resvf2},                          Grid12 = PosGrid[X, pat];                          Grid22 = ConstantArray["", 10000];                          Table[                            Grid22[[i]] = X[[ i , Grid12[[i, 1, 1]] ;; Grid12[[i, -1, 1]] ]],                            {i, 1, Length[X], 1}                          ];                          Resvf2 = DeleteCases[Grid22, ""]                      ];      The results provided by `ProjVt` and `ProjHt` in the case of matrix `A` are : > >     Resvf1 = {1,2,3,4,5} >     Resvf2 = {{1, 2, 3, 4}, {2, 3, 4}, {3, 4}, {4, 5}} >      Best known optimization : * * *               ProjHt[X_]:= Map[Select[#, NumberQ] &, X]          ProjVt[X_]:=     Block[           {step1, Res},            step1 = Tranpose[x];            Res = ProjHt[step1][[All,1]]          ]      .


Numerical Differentiation of an interpolated list.

I have a synthetic spectrum with a wavelength range of .3 to .7 microns. I have interpolated this spectrum for re-sampling purposes. However, I am also attempting to calculate the first and second derivatives of the interpolated spectrum to find the locations of local maxima. However, numerical differentiation keeps producing an error, claiming that my input value is outside of the range of the data in the interpolating function. The important parts of my code are:               Needs["NumericalCalculus`"]     template = Import["C:\\Users\\John\\Documents\\Research\\KOI89\\template.txt","Table"];     t = Interpolation[template, InterpolationOrder -> 1]     ND[t[x], x, .4]      my "template" dataset has a domain of 0.3 to 0.7, and contains about 250,000 data points. However, the ND command produces the error:               InterpolatingFunction::dmval: "Input value {1.4} lies outside the range of data in the interpolating function. Extrapolation will be used. "     InterpolatingFunction::dmval: Input value {0.9} lies outside the range of data in the interpolating function. Extrapolation will be used.      I either need to figure out what is causing that error, or figure out another way of finding the location of all the peaks in my spectra. I tried a simple peak-finding For-loop but it is not giving me good results.               peaks = {};     For[n = 4, n <= Length[template] - 4, n++,      If[0.08 < template[[n - 3, 2]] < template[[n - 2, 2]] < template[[n - 1, 2]] < template[[n, 2]] > template[[n + 1, 2]] >   template[[n + 2, 2]] > template[[n + 3, 2]] > 0.08, peaks = Append[peaks, template[[n, All]]]]]      I am looking for simple ideas on how to find the peaks of my spectrum.


How to extend dictionary.txt

How to extend the default dictionary.txt for `Dictionarylookup` to all words? For example, first I               wordsExtended=WordData[]~Join~DictionaryLookup["*"]//Union;     wordsExtended//Length      However, after reloading the dictionary.txt some words are omitted, for example:               In[73]:= DictionaryLookup["appals"]     Out[73]= {}     In[74]:= WordData["appals"]     Out[74]= {{appal,Verb,Frighten},{appal,Verb,Nauseate}}      How to add all such words like #appals# to dictionary.txt? One method: Tuples to create a word verified by WordData, which takes too much time. For               In[78]:= Binomial[26,7]     Out[78]= 657800      Second method:               listAlls = # <> "s" & /@ DictionaryLookup["*"];     wordsToExport = Select[listAlls, Length[WordData@#] > 1 &];     In[81]:= Complement[wordsToExport,DictionaryLookup["*"]]//Length     Out[81]= 2580      I get 2580 new words for dictionary.txt, but how to get all prefix and suffix such like `s` `pre` `es`... and so on.


Manipulating the axis on a ListLinePlot

I am trying to create a plot using `ListLinePlot` in which the x-axis is represented in a logarithmic scale, and is reversed (so larger values are on the right side). I have found that `ScalingFunctions -> {"Reverse"}` will reverse the axis and `ScalingFunctions -> {"Log"}` will scale the axis to a log scale, but the two commands will not work together. Does anyone have any ideas?


Need help evaluating definite integral to a function of Y

Suppose $Y = \sqrt{2T}\cos(U)$, $ 0 \le u \le \pi $, and $ 0 \le \cos^{-1}(\frac{y}{\sqrt {2t}}) \le \pi ) $, so $ -1 \le \frac{y}{\sqrt{2t}} \le 1 $, with all $ \mathbb{R}$. The iterated integral is $$ G(y)= P(Y \le y) =P(\sqrt{2T}\cos(U) \le y)=\int_{0}^{y}\int_{0}^{\cos^{-1}(\frac{y}{\sqrt {2t}})} \frac{e^{-t}}{\pi } \mathrm{d}u \mathrm{d}t$$ My Mathematica code is               Integrate[((E^-t)/(\[Pi])), {u, 0,  ArcCos[y/((2 t)^(1/2))]},       Assumptions ->        0 <= u <= \[Pi] && -1 <= ArcCos[y/((2 t)^(1/2))] <= 1 &&         Element[t, Reals] > 0]          Integrate[%, {t, 0, y},       Assumptions -> -1 <= ArcCos[y/((2 t)^(1/2))] <= 1 &&         Element[t, Reals] > 0]      but then Mathematica never seems to finish evaluating the second one, and so I have to Abort it. Is there any way to find this as a function of $y$? $G(y)$ is a CDF of $Y$.


Where does Documentation Center introduce the basics?

While helping a user who mistakenly thought that `log` rather than `Log` was the correct built-in function name, I included a gently-worded suggestion of a "RTFM" approach to learning basics such as that built-in function names begin with upper-case letters (or possibly `$`). Then I tried to determine where in the Documentation Center one in fact finds such basics. Where, indeed? And how would a rank beginner come across it? I tried some obvious places:   * the Get Started button, but that takes you to an on-line video touting all the things that Mathematica can do;   * The Core Language > Language Overview, but that didn't help;   * The Core Language > Mathematica Syntax, but that didn't mention it. Etc. Is something very basic missing from the docs? (I note that there are a couple of videos at the Video and Screencasts pages of the Learning Resources section on the Wolfram web site that do mention the upper-case requirement, along with using square-brackets to enclose arguments, etc. But these are not something a new user might encounter right at the start. Indeed, even once one gets to the Video and Screencasts pages it's not obvious where to start to obtain such basics.)


Integrate on a logarithmic grid

I am trying to solve numerically an integral equation, and from a couple of tests I can see that the result has a strong logarithmic divergence. For my specific problem it is very important to have accurate results in the region of very small arguments, but that doesn't work since I am forced to replace the lower limit of integration (zero, that is) with non-zero values (0.0001 or whatever) otherwise the program crashes. So I though about integrating on a logarithmic grid, but I don't know how that works in Mathematica. (I have searched in the mathematica references, but could not find an answer). Anyone has an idea?               α = 2.85;     g = (Pi/2) α;     Nf := 2;          cs[x_] := 2 ArcCos[x]/Sqrt[1 - x^2];     csh[x_] := 2 ArcCosh[x]/Sqrt[x^2 - 1];     prefB[p_, k_, d_] :=      (p^2 + k^2 (1 - 1/d^2))/Sqrt[p^2 d^4 - 1/4 ((p^2 + k^2) d^2/k - k )^2];     pieceB[k_, d_] :=        If[d B[k]/k^2 < 1, cs[d B[k]/k^2], If[d B[k]/k^2 > 1, csh[d B[k]/k^2], 2]];          B[p_] = p^2 ;     iterstep :=      (values =      Parallelize[     Table[{p, p^2 +  g/(Pi^3  Nf) (NIntegrate[             prefB[p, k, d] ((d^2 B[k]^2/k^4 - 1) (Pi - g pieceB[k, d]) +                 B[k ]/k^2 d  g^2 csh[g])/(d^2 B[k]^2/k^4 + g^2 - 1),             {d, 0, 1/(1 + p)}, {k, p d/(d + 1), p d/(1 - d)},             WorkingPrecision -> 16,             PrecisionGoal -> 2,             MaxRecursion -> 100,            AccuracyGoal -> 16,             Method -> {"SymbolicPreprocessing", "OscillatorySelection" -> False}] +            NIntegrate[            prefB[p, k, d] ((d^2 B[k]^2/k^4 - 1) (Pi - g pieceB[k, d]) +                 B[k ]/k^2 d  g^2 csh[g])/(d^2 B[k]^2/k^4 + g^2 -1),             {d, 1/(1 - p), Infinity},             {k, p d/(d + 1), p d/(d - 1)},              WorkingPrecision -> 16, PrecisionGoal -> 2,             MaxRecursion -> 100, AccuracyGoal -> 16,            Method -> {"SymbolicPreprocessing","OscillatorySelection" -> False}])},             {p, 0, 0.99999, 1/20}]];          B[p_] = Interpolation[values , p, InterpolationOrder -> 4,   Method -> "Hermite"])               Do[iterstep, {3}] // AbsoluteTiming


Poor performance from Graphics3D

I wrote a game -- 2048，Some codes are from http://blog.wolfram.com/. My codes are in notebook downloads I added code so that the game can play in 3D form, but when I play it, I find that it is too slow, so I write some test code to investigate performance. ![enter image description here](http://i.stack.imgur.com/oxxqV.jpg) The front end seems to be too slow to update the complex 3D graphics in real time. How can I deal with this? ## Edit 1: The main relevant codes               Clear["Global`*"];     SetOptions[Graphics3D, Boxed -> False, Axes -> False];     $empty = "";          colors = {"Color" -> #1, "Background" -> #2} & @@@ {{"#776e65",       "#eee4da"}, {"#776e65", "#ede0c8"}, {"#f9f6f2",       "#f2b179"}, {"#f9f6f2", "#f59563"}, {"#f9f6f2",       "#f67c5f"}, {"#f9f6f2", "#f65e3b"}, {"#f9f6f2",       "#edcf72"}, {"#f9f6f2", "#edcc61"}, {"#f9f6f2",       "#edc850"}, {"#f9f6f2", "#edc53f"}, {"#f9f6f2", "#edc22e"}};     hexToRGB[s_String] :=        RGBColor @@ (IntegerDigits[FromDigits[StringTake[s, -6], 16], 256, 3]/255.);     colorForNumber[n_Integer, s_] := hexToRGB[s /. colors[[Log[2, n]]]];     $emptyColor = RGBColor[0.75436, 0.701427, 0.642634];     $backgroundColor = RGBColor[0.676677, 0.616403, 0.559747];          (*draw 3D*)     drawTile[n_Integer, pos_: {0, 0}] :=       Module[{texture, x0, y0, z0, x1, y1, z1, r},        {{x0, y0}, {x1, y1}} = pos - # & /@ {0.45, -0.45};        z0 = -.1; z1 = Log[2, n]/11; r = 1/16;        texture =         Graphics[{colorForNumber[n, "Background"],           Polygon[{{-0.45, -0.45}, {-0.45, 0.45}, {0.45, 0.45}, {0.45, -0.45}}],           Text[Style[n, Bold, FontFamily -> "Helvetica",           FontSize -> Scaled@Switch[IntegerLength@n, 1 | 2, .5, 3, .4, _, .34],           colorForNumber[n, "Color"]]]}, PlotRangeClipping -> True, PlotRange -> 0.4];       Graphics3D[{EdgeForm@None,           colorForNumber[n, "Background"], {Texture@texture,           Polygon[{{x0 + r, y0 + r, z1}, {x1 - r, y0 + r, z1},            {x1 - r, y1 - r, z1}, {x0 + r, y1 - r, z1}},           VertexTextureCoordinates -> {{0, 1}, {0, 0}, {1, 0}, {1, 1}}]},       Cuboid[{x0, y0, z0} + #, {x1, y1, z1} - #] & /@ {{0, r, r}, {r, 0, r}},       Table[Tube[{{x0 + r, y, z}, {x1 - r, y, z}}, r],            {y, {y0 + r, y1 - r}}, {z, {z0 + r, z1 - r}}],        Table[Tube[{{x, y0 + r, z}, {x, y1 - r, z}}, r],           {x, {x0 + r, x1 - r}}, {z, {z0 + r, z1 - r}}],        Table[Tube[{{x, y, z0 + r}, {x, y, z1 - r}}, r],             {x, {x0 + r, x1 - r}}, {y, {y0 + r, y1 - r}}]}]      ];     drawTile[$empty, pos_: {0, 0}] :=            Module[{texture, x0, y0, z0, x1, y1, z1, r},            {{x0, y0}, {x1, y1}} = pos - # & /@ {0.45, -0.45};            z0 = -.1; z1 = 1/22; r = 1/16;           Graphics3D[{EdgeForm@None, $emptyColor, {Polygon[{{x0 + r, y0 + r, z1},              {x1 - r, y0 + r, z1}, {x1 - r, y1 - r, z1}, {x0 + r, y1 - r, z1}}]},             Cuboid[{x0, y0, z0} + #, {x1, y1, z1} - #] & /@ {{0, r, r}, {r, 0, r}},             Table[Tube[{{x0 + r, y, z}, {x1 - r, y, z}}, r],                {y, {y0 + r, y1 - r}}, {z, {z0 + r, z1 - r}}],              Table[Tube[{{x, y0 + r, z}, {x, y1 - r, z}}, r],                {x, {x0 + r, x1 - r}}, {z, {z0 + r, z1 - r}}],              Table[Tube[{{x, y, z0 + r}, {x, y, z1 - r}}, r],                 {x, {x0 + r, x1 - r}}, {y, {y0 + r, y1 - r}}]}]];         drawBottom = Graphics3D[{$backgroundColor,          Cuboid[{0.4, 0.4, -0.1}, {4.6, 4.6, 0}]}];     drawGrid[board_] := Show[drawBottom,         Table[drawTile[board[[i, j]], {i, j}], {i, 4}, {j, 4}],         PlotRange -> {{0.5, 4.5}, {0.5, 4.5}, {-0.05, 1}}, ImageSize -> 500,         ViewPoint -> {2.13, -0.69, 2.53}, Lighting -> "Neutral"];      I want to write the game -- 2048 in 3D form ,like this: ![enter image description here](http://i.stack.imgur.com/Hy3kA.jpg) So First I need to plot the cuboid with rounded corners and texture.So I used Polygon,Text,Texture to realize the texture，and use Polygon,Cuboid,Cuboid to realize the cuboid with rounded corners.This is the function drawTile[].Then I just need to draw 16 cubes with function drawGrid[].And then the trouble is coming.The drawGrid contains a large number of primitives.It is quickly calculate in kernel.But if show it in the front end ，it will cost a long time that can not negligible.Here is the test codes.               data = Partition[RandomSample@PadLeft[2^# & /@ Range[11], 16, $empty],4];     m = AbsoluteTime[];     Show[drawGrid[data], ImageSize -> 150] // AbsoluteTiming     AbsoluteTime[] - m     m = AbsoluteTime[];     Show[drawGrid[data], ImageSize -> 150]; // AbsoluteTiming     AbsoluteTime[] - m      ![enter image description here](http://i.stack.imgur.com/oxxqV.jpg) Actually when I press the arrow key ,it will be 0.5s delay before image update in 3D form games, while it will be less than 0.1s delay in 2D form games.My cpu is Intel Core i3 370M. I want to reduce the delay because 0.5s is too long.But now I have no idea. ## Edit 2: new version of the program notebook download ## Edit 3: the advises from the original author of “2048 Wolfram Style” I asked the original author to help me how to improve speed,and he give me three advises.It is very helpful!   1. Use graphics multi-primitives whenever you can. This means instead of writing something like {Sphere[point1, r], Sphere[point2, r]}, use {Sphere[{point1, point2}, r]}. This works with many graphics objects.   2. Use floating point arithmetic. This means instead of using 1/16 or Log[2, 5], use 1/16. or Log[2., 5.].   3. You could also try to Rasterize the textures and numbers in advance. his advises My lastest program can download here


Displaying an open Manipulator

Take something like:               Manipulate[N[Pi]*s, {{s, 5}, 0, 10}]      This results in the following: ![The + sign has not been clicked](http://i.stack.imgur.com/CNMkC.jpg) What I would really like is the following: ![The + sign has been clicked](http://i.stack.imgur.com/hpH4A.jpg) Is there any way to make this happen by default? In other words, is there a flag I can set so that the little `+` sign is clicked by default?


FrameLabel not printing completely

Running this code:               Histogram[{RandomVariate[NormalDistribution[1/4,0.12],100],      RandomVariate[NormalDistribution[3/4, 0.12], 100]},       Automatic, "Probability", PlotRange -> {{0, 1}, {0, 1}},      Frame -> True, PlotRangeClipping -> True,      FrameLabel -> {Style["x axis", 15], Style["probability", 15]}     ]      Gives me the following plot: ![enter image description here](http://i.stack.imgur.com/jYSLN.png) As you can see, the label on the right ("probability") is not printed correctly. The character "y" is missing. What's going on here? I am using Mathematica 9.0.0.0. I ran this on two laptops, one with Windows 7 and the other with Windows 8. **Update** : Judging by the comments, this seems to be a bug. So now the question becomes: **Is there a workaround?** **Update** : This seems to be bug, so I'll tag as such. In the meantime, see the answers for workarounds.


Command completion in Wolfram Workbench 2 vs command completion in Mathematica 9

I don't have access to Workbench 2, but I tried a trial version of _Mathematica_ 9\. On reading about the features of Workbench 2, I found that it also supports code completion. I am looking forward to buying it for student V8 I bought. My first question is: are they different or the same? My second question is: does Workbench 2 support graphics visualization and programming?


combined 3D graphics with no interface

I'd like to combine several 3D graphics, but the interface, indicated by the arrow in the figure attached between them is alway present. How to eliminate it? Thanks in advance. Here is my example:                 Graphics3D[{           {EdgeForm[None], Opacity[0.1], Gray,             Cylinder[{{0, 0, 0}, {0, 2, 0}}, 0.5]},            {EdgeForm[None], CapForm["Butt"], Opacity[0.1], Gray,             Tube[{{0, 2, 0}, {0, 3, 0}}, {0.5, 0.2}]},                }, ViewPoint -> {0.8677796780444739`, 2.2396029175520074`,             2.383513625315694`},           ViewVertical -> {-2.366747875495254`, -0.028635050478789906`,             1.8415006920431496`}, Boxed -> False]      ![enter image description here](http://i.stack.imgur.com/3ZoMo.jpg)


histogram fit for probability density

I am trying to fit the (probability density) histogram of some data with the exponential function, but I am having difficulties. My raw data are in file called `datachopped`. They are not 'probability density'. I want to fit the probability density histogram of this data with Exp[-x]. So I use the following command:               Histogram[datachopped, Automatic, "PDF",       Epilog -> First@Plot[Exp[-x], {x, 0, 4}, PlotStyle -> Red]]      This gives me this plot: ![enter image description here](http://i.stack.imgur.com/hJmNi.jpg) However, I don't know how well this plot fit, i.e., how to compute the chi- squared, etc. Any help would be appreciated.


Thread over uneven (ragged) expressions with full functionality?

There are a number of questions on this site about "threading" including several relating to uneven (ragged) lists. However, none that I could find deal with the full functionality of `Thread` but instead things like `MapThread`, or the ragged transpose of `Flatten[expr, {2}]`. `Thread` operates:   * Inside held expressions without errant evaluation   * On arbitrary heads as specified with the second parameter   * By distributing singlets across all subexpressions   * On only the first _n_ arguments (subexpressions) if given as third parameter For example:               expr = Hold[qq[2 + 2, 1/0, 8/4], qq[1, 2, 3], Sqrt[2 + 2]];          Thread[expr, qq]          Thread[expr, qq, 1]      > >     qq[Hold[2 + 2, 1, Sqrt[2 + 2]], Hold[1/0, 2, Sqrt[2 + 2]], Hold[8/4, 3, > Sqrt[2 + 2]]] >   >     qq[Hold[2 + 2, qq[1, 2, 3], Sqrt[2 + 2]], Hold[1/0, qq[1, 2, 3], Sqrt[2 > + 2]], >        Hold[8/4, qq[1, 2, 3], Sqrt[2 + 2]]] >   All of this breaks if we change `qq[1, 2, 3]` to `qq[1, 2]`. What is the most efficient way to extend `Thread` to ragged subexpressions?


Using PlotLegends with a numeric PointSize

Using `PlotLegends` with a `PlotStyle` containing (for instance) `PointSize[0.02]` creates a legend that does not match the plot.               ListPlot[Table[RandomReal[NormalDistribution[], {20, 2}], {2}],      PlotLegends -> {"a", "b"}, PlotStyle -> PointSize[0.02]]      ![enter image description here](http://i.stack.imgur.com/JVtXy.png) How can I get a sensible legend when using a number with `PointSize`? Solutions involving named sizes (like `PointSize[Medium]`) are inadmissible unless they somehow create points that have a constant size relative to the plot size.


can someone how to plot $x = c$ in a different color scheme?

Exactly as title says. I do not know why I am having so much trouble with this. I have googled many solutions and I cannot find a straightforward answer. Also, the only method I know is "Gridlines" and there is no option to change colour


Adding custom GridLines to the "automatic" ones

I need to add custom (vertical) grid lines to a plot (to a `DateListPlot`, to be precise). I know there is the option of `GridLines -> {xgrid, ygrid}`. However, this removes the automatic grid lines which I would like to keep. Is there a simple option to add _additional_ grid lines to the automatic ones? Thank you! * * * **Update:** Added a minimal working example. Take the following `DateListPlot`               DateListPlot[RandomReal[1, 20], {2000}, Joined -> True]      ![automatic grid lines](http://imgur.com/1SUSWgr.png) It automatically includes vertical grid lines for each year in grey, which I would like to keep. But let's say I'd like to add a grid line for Guy Fawkes Day 2007, e.g. because I need to later label the event in the plot. I could write                DateListPlot[RandomReal[1, 20], {2000}, Joined -> True,                   GridLines -> {{"5 Nov 2007"}, None}]      ![custom grid lines](http://imgur.com/SZRkVus.png) but this removes the yearly lines. So I was wondering whether it is possible to _add_ the custom grid lines to the automatic ones rather than to overwrite the latter. Of course, I could manually re-add the annual grid lines, but I hope to avoid this solution because the plots will have different date ranges so I do not always know for which years I'd need to include the lines.


Bug in Integrate for Mathematica

Consider the following:               regFunc[x_,y_]:=Boole[-5<4x+3y<5 && -2<3x+2y<2];     Integrate[regFunc[x,y]*((4x+3y)(3x+2y))^4,{x,-100,100},{y,-100,100}]//N     Integrate[regFunc[x,y]*(12x^2+17x*y+6y^2)^4,{x,-100,100},{y,-100,100}]//N      In the first example, Mathematica seems to figure out the correct substitution, and arrives at 16000, which is the correct answer. In the second integration, (integrating the same expression, but expanded), Mathematica gives 5885078144/382725, which is 15376.8. This is clearly a bug, is this well-known? I am using Mathematica 8.04, 64bit Linux. EDIT: I got an email from the tech support, and I took the answer as a confirmed bug.


Plotting problem

I was wondering why I keep receiving the error message > >     "Derivative should be a triple of numbers, or scaled form" >   from the following code               uT[t_] := Simplify[r'[t]/Norm[r'[t]]]          vN[t_] := Simplify[uT'[t]/Norm[uT'[t]]]          vB[t_] := Simplify[Cross[r'[t], r''[t]]/Norm[Cross[r'[t], r''[t]]]]          N[Evaluate[uT[7 Pi/2]]]      > >     {0., 0.894427, 0.447214} >                 N[Evaluate[vN[7 Pi/2]]]      > >     {-(2./Sqrt[4. + 0.00900633 Abs[2.23607 - 1. Derivative[1][Norm][{0., 3., > 1.5}]]^2]), >     0., ( 2.23607 - 1. Derivative[1][Norm][{0., 3., 1.5}])/Sqrt[444.132 + > Abs[2.23607 - 1. >     Derivative[1][Norm][{0., 3., 1.5}]]^2]} >                 N[Evaluate[vB[7 Pi/2]]]      > >     {0.0944772, -0.445213, 0.890426} >                 N[Evaluate[uT[13 Pi/2]]]      > >     {0., -0.607287, -0.794483} >                 N[Evaluate[vN[13 Pi/2]]]       > >     (*out56*)   >     {50696.9/Sqrt[2.57017*10^9 + 9. Abs[2534.84 + 1539.38 > Derivative[1][Norm][{0., >     -2.29314, -3.}]]^2], (3. (2534.84 + 1539.38 Derivative[1][Norm][{0., > -2.29314, >     -3.}]))/Sqrt[ 2.57017*10^9 + 9. Abs[2534.84 + 1539.38 > Derivative[1][Norm][{0., >     -2.29314, -3.}]]^2], 0.} >                 N[Evaluate[vB[13 Pi/2]]]      > >     {0.118335, -0.7889, 0.60302} >                 Cter = ParametricPlot3D[r[t], {t, 0, 10 Pi}, PlotStyle -> Directive[Blue, Thick]];          stp = Graphics3D[{Opacity[.5], Black, Sphere[r[0], .5]}];          TNBPlot = Graphics3D[{Arrowheads[.07], Thickness[.15], Yellow,                            Arrow[{N[uT[7 Pi/2]], N[uT[13 Pi/2]]}], Green,                            Arrow[{N[vN[7 Pi/2]], N[vN[13 Pi/2]]}], Blue,                            Arrow[{N[vB[7 Pi/2]], N[vB[13 Pi/2]]}]}];          Show[Cter, stp, TNBPlot, PlotRange -> All]      I did narrow it down to the equation to `(*out56*)`, the equation for the Normal Vector. I haven't posted the actual function, because there's a bunch of questions up already pertaining to it, and I didn't want to give the impression that I'm trying to offload my homework onto anyone. Additionally, when I did have it working, I couldn't get the vectors to display properly. Could that possibly be due to the program considering the vectors and the actual 3D-Parametric plot as separate entities or something?


LengthWhile until first duplication

I have the need to trim each of a large number of potentially very long lists (10^6+ elements) to the length where the last occurrence of any distinct element happens, or said another way, where the next element is the first duplication of any prior element of that list. Lists are simple integer elements, but will often be beyond machine precision. For example, given a list `{3, 24, 50, 41, 46, 21, 20, 3, 2, 5, 29, 28, 38, 22, 2}` it should return `7`. I'm using: `-Tr[Unitize[# - #2[[ ;; Length[#]]]] - 1] &[DeleteDuplicates[#], #] &[yourListHere]` which is reasonably swift. Wondering if there's a better solution.


Overlapping accurately Images and Graphics (without loss of resolution)

**Context** In a previous post, I learned how to produce these kind of plots, which are of interest in astrophysics and geophysics. ![Mathematica graphics](http://i.stack.imgur.com/kvqzh.png) ![Mathematica graphics](http://i.stack.imgur.com/ogxt3.png) I am now interested in combining them. **Attempt** For this purpose, @belisarius suggested using the command               ImageCompose[mollwide, grid /. Line[a__] :> {White, Line[a]}]      which produces this (note the incorrect scaling) ![Mathematica graphics](http://i.stack.imgur.com/2cjXJ.png) As an other example (to make this question self contained) let us look at `StreamPlot`                gr = StreamPlot[{-1 - x^2 + y, 1 + x - y^2}, {x, -Pi, Pi}, {y, -Pi/2,      Pi/2}, AspectRatio -> 1/2, Frame -> False];      cart[{lambda_, phi_}] :=  With[{theta = fc[phi]}, {2 /Pi*lambda Cos[theta],   Sin[theta]}];      fc[phi_] := Block[{theta}, If[Abs[phi] == Pi/2, phi,  theta /.       FindRoot[2 theta + Sin[2 theta] == Pi Sin[phi], {theta, phi}]]];           gr2 = gr /. Arrow[pts_] :> Arrow[(cart /@ pts)] /.       Point[pts_] :> Point[cart[ pts]] //       Show[#, PlotRange -> {{-2, 2}, {-1, 1}}] &;           i = Import["http://tpfto.files.wordpress.com/2012/02/firemap.png"];      invmollweide[{x_, y_}] := With[{theta = ArcSin[y]}, {Pi (x)/(2 Cos[theta]),       ArcSin[(2 theta + Sin[2 theta])/Pi]}];      moll = ImageTransformation[i, invmollweide, DataRange -> {{-Pi, Pi}, {-Pi/2, Pi/2}},       PlotRange -> {{-2, 2}, {-1, 1}}, Padding -> White];           ImageCompose[ImageResize[moll, 1200],       gr2 /. Arrow[a__] :> {AbsoluteThickness[3], White, Arrow[a]}]      ![Mathematica graphics](http://i.stack.imgur.com/08nOg.png) **Question**   1. How can I make sure the image size match?   2. How can I combine them so that the grid remains a vector image rather than a raster?


Avoiding re-evaluation of RegionPlot3D on a second computer

After running a `RegionPlot3D` named "testplot" on my desktop, I followed an earlier suggestion from the forum and saved it using:               DumpSave["testplot.mx"].      I then saved and closed the notebook, quit _Mathematica_ and copied the notebook to my laptop. At this point, I re-opened the (copied) notebook and tried to retrieve the plot by using `DumpGet["testplot.mx"]`, but this failed. The plot took 60 mins of run time, and would take even longer on my laptop. The procedure I followed must be incorrect because I am certain this simple transfer can be done successfully allowing me to open the plot on my laptop without re-running. Does anyone have any suggestions?


Generating an editable table that can be used as input

Say I have a number $n_{max}$. I want a command to generate a table like               1 1     2 2     3 3     4 4     ...     nmax nmax      where the second column is editable, and this table can be evaluated so that Mathematica treats the table as the set               replacement = { 1 -> 1, 2 -> 2, ...}      (The point of this is so that I can replace the original list using /.replacement). So for example, after generating the table above, I can edit the second column as follows               1 A     2 B     3 C     4 D     ...     nmax FF      and this output re-evaluates into set               replacement = { 1-> A, 2-> B, 3-> C, F-> D, ... , nmax-> FF}


Exporting Cyrillics in PDF on Linux

I'm using Mathematica from Ubuntu. I need a normal font to display cyrillics inside PDFs. Any default font is very ugly, letters are too close together:               ImportString@       ExportString[Style["Русский", FontFamily -> #, FontSize -> 50],         "PDF"]&/@ {"Times", "Courier", "Arial"}      ![enter image description here](http://i.stack.imgur.com/J2nRN.png) Here is the longer example with also Latin mixed in: ![enter image description here](http://i.stack.imgur.com/T38es.png) As you can see Cyrillics letters are much bigger somehow. It's happening to every text inside the notebook including graphics, even though it looks fine in the editor. This is how it looks on `MacOSX-x86-64` and Mathematica 8.0.4 which can be used as reference: ![Mathematica graphics](http://i.stack.imgur.com/6tNBJ.png)


Interpolation on large 2D list results in erratic function

Previously, I've had problems with _Mathematica_ interpolating and plotting 3D lists, but I finally managed to do so by rescaling the x and y-axes with the help of the methods proposed here. Now my problem is with interpolating 2D lists. I have a large 2D list that I'll call `data` of dimensions {4271,2} for which I need to find an interpolation. Using `f = Interpolation[data]` outputs an interpolating function without error messages or warnings. The problem arises first when comparing the curves produced by `ListLinePlot[data]` and `Plot[f[s], {s, Min[data[[All, 1]]], Max[data[[All, 1]]]}]` as shown below. The first plot looks like this: ![enter image description here](http://i.stack.imgur.com/Cqn6l.png) and the second like this: ![enter image description here](http://i.stack.imgur.com/pbLrD.png) The first plot produces the expected curve whilst the second shows erratic behaviour between points. Evaluating the interpolating function offers only sensible result at points present in `data` and incoherent results elsewhere. I've tried sorting, cleaning, introducing noise into the data, but the interpolation always produces an erratic function. I'll post an excerpt of the first 900 rows of the data below. Any help is much appreciated.               data[[1 ;; 900, All]] = {{1779.55, 9.9227*10^6}, {1784.38, 9.9225*10^6}, {1789.02,        9.92229*10^6}, {1793.49, 9.92208*10^6}, {1797.79,        9.92187*10^6}, {1808.57, 9.92165*10^6}, {1819.04,        9.92143*10^6}, {1829.07, 9.9212*10^6}, {1838.74,        9.92097*10^6}, {1848.07, 9.92074*10^6}, {1857.03,        9.9205*10^6}, {1865.69, 9.92026*10^6}, {1872.35,        9.92001*10^6}, {1875.87, 9.91976*10^6}, {1879.27,        9.91951*10^6}, {1882.56, 9.91925*10^6}, {1885.76,        9.91899*10^6}, {1888.86, 9.91872*10^6}, {1891.86,        9.91845*10^6}, {1896.6, 9.91818*10^6}, {1903.59,        9.9179*10^6}, {1910.38, 9.91762*10^6}, {1916.98,        9.91733*10^6}, {1923.36, 9.91704*10^6}, {1929.56,        9.91675*10^6}, {1935.6, 9.91645*10^6}, {1941.47,        9.91615*10^6}, {1947.16, 9.91584*10^6}, {1952.68,        9.91553*10^6}, {1958.05, 9.91522*10^6}, {1963.29,        9.9149*10^6}, {1968.4, 9.91458*10^6}, {1971.81,        9.91425*10^6}, {1974.01, 9.91392*10^6}, {1976.16,        9.91359*10^6}, {1978.26, 9.91325*10^6}, {1980.3,        9.91291*10^6}, {1982.3, 9.91256*10^6}, {1984.25,        9.91221*10^6}, {1986.15, 9.91186*10^6}, {1990.17,        9.9115*10^6}, {1994.44, 9.91114*10^6}, {1998.61,        9.91077*10^6}, {2002.69, 9.9104*10^6}, {2006.68,        9.91003*10^6}, {2010.59, 9.90965*10^6}, {2014.39,        9.90927*10^6}, {2018.11, 9.90888*10^6}, {2021.75,        9.90849*10^6}, {2025.31, 9.9081*10^6}, {2028.8,        9.9077*10^6}, {2032.23, 9.9073*10^6}, {2035.58,        9.90689*10^6}, {2038.86, 9.90648*10^6}, {2040.37,        9.90607*10^6}, {2041.84, 9.90565*10^6}, {2043.29,        9.90523*10^6}, {2044.7, 9.9048*10^6}, {2046.09,        9.90437*10^6}, {2047.45, 9.90394*10^6}, {2048.79,        9.9035*10^6}, {2050.1, 9.90306*10^6}, {2052.63,        9.90261*10^6}, {2055.48, 9.90216*10^6}, {2058.28,        9.90171*10^6}, {2061.03, 9.90125*10^6}, {2063.73,        9.90079*10^6}, {2066.38, 9.90032*10^6}, {2068.99,        9.89985*10^6}, {2071.56, 9.89938*10^6}, {2074.08,        9.8989*10^6}, {2076.55, 9.89842*10^6}, {2078.97,        9.89793*10^6}, {2081.35, 9.89744*10^6}, {2083.68,        9.89695*10^6}, {2085.98, 9.89645*10^6}, {2088.25,        9.89595*10^6}, {2090.47, 9.89544*10^6}, {2092.66,        9.89493*10^6}, {2094.82, 9.89442*10^6}, {2096.94,        9.8939*10^6}, {2099.03, 9.89338*10^6}, {2101.08,        9.89285*10^6}, {2102.83, 9.89232*10^6}, {2103.77,        9.89179*10^6}, {2104.7, 9.89125*10^6}, {2105.62,        9.89071*10^6}, {2106.52, 9.89016*10^6}, {2107.41,        9.88961*10^6}, {2108.28, 9.88906*10^6}, {2109.14,        9.8885*10^6}, {2109.98, 9.88794*10^6}, {2111.38,        9.88737*10^6}, {2113.19, 9.8868*10^6}, {2114.98,        9.88623*10^6}, {2116.74, 9.88565*10^6}, {2118.47,        9.88507*10^6}, {2120.19, 9.88448*10^6}, {2121.87,        9.88389*10^6}, {2123.54, 9.8833*10^6}, {2125.18,        9.8827*10^6}, {2126.8, 9.8821*10^6}, {2128.39,        9.88149*10^6}, {2129.97, 9.88088*10^6}, {2131.52,        9.88027*10^6}, {2133.05, 9.87965*10^6}, {2134.56,        9.87903*10^6}, {2136.05, 9.8784*10^6}, {2137.5,        9.87777*10^6}, {2138.94, 9.87714*10^6}, {2140.36,        9.8765*10^6}, {2141.76, 9.87586*10^6}, {2143.14,        9.87521*10^6}, {2144.5, 9.87456*10^6}, {2145.84,        9.87391*10^6}, {2147.17, 9.87325*10^6}, {2148.48,        9.87259*10^6}, {2149.78, 9.87192*10^6}, {2151.06,        9.87125*10^6}, {2152.32, 9.87058*10^6}, {2153.56,        9.8699*10^6}, {2154.79, 9.86922*10^6}, {2156.01,        9.86853*10^6}, {2157.21, 9.86784*10^6}, {2158.39,        9.86715*10^6}, {2159.57, 9.86645*10^6}, {2160.72,        9.86575*10^6}, {2161.33, 9.86504*10^6}, {2161.86,        9.86433*10^6}, {2162.38, 9.86362*10^6}, {2162.9,        9.8629*10^6}, {2163.41, 9.86218*10^6}, {2163.91,        9.86145*10^6}, {2164.4, 9.86072*10^6}, {2164.89,        9.85999*10^6}, {2165.39, 9.85925*10^6}, {2166.46,        9.85851*10^6}, {2167.51, 9.85776*10^6}, {2168.55,        9.85701*10^6}, {2169.58, 9.85626*10^6}, {2170.6,        9.8555*10^6}, {2171.6, 9.85474*10^6}, {2172.6,        9.85397*10^6}, {2173.58, 9.8532*10^6}, {2174.55,        9.85243*10^6}, {2175.52, 9.85165*10^6}, {2176.47,        9.85087*10^6}, {2177.41, 9.85008*10^6}, {2178.34,        9.84929*10^6}, {2179.26, 9.8485*10^6}, {2180.16,        9.8477*10^6}, {2181.06, 9.8469*10^6}, {2181.95,        9.84609*10^6}, {2182.83, 9.84528*10^6}, {2183.7,        9.84447*10^6}, {2184.56, 9.84365*10^6}, {2185.41,        9.84283*10^6}, {2186.26, 9.842*10^6}, {2187.09,        9.84117*10^6}, {2187.91, 9.84034*10^6}, {2188.73,        9.8395*10^6}, {2189.53, 9.83866*10^6}, {2190.32,        9.83781*10^6}, {2191.11, 9.83696*10^6}, {2191.88,        9.83611*10^6}, {2192.65, 9.83525*10^6}, {2193.41,        9.83439*10^6}, {2194.16, 9.83352*10^6}, {2194.91,        9.83265*10^6}, {2195.64, 9.83178*10^6}, {2196.37,        9.8309*10^6}, {2197.09, 9.83002*10^6}, {2197.8,        9.82913*10^6}, {2198.51, 9.82824*10^6}, {2199.21,        9.82735*10^6}, {2199.9, 9.82645*10^6}, {2200.58,        9.82555*10^6}, {2201.26, 9.82464*10^6}, {2201.93,        9.82373*10^6}, {2202.6, 9.82282*10^6}, {2203.25,        9.8219*10^6}, {2203.9, 9.82098*10^6}, {2204.55,        9.82005*10^6}, {2205.18, 9.81912*10^6}, {2205.82,        9.81819*10^6}, {2206.44, 9.81725*10^6}, {2207.06,        9.81631*10^6}, {2207.67, 9.81536*10^6}, {2208.28,        9.81441*10^6}, {2208.88, 9.81346*10^6}, {2209.47,        9.8125*10^6}, {2210.06, 9.81154*10^6}, {2210.64,        9.81057*10^6}, {2211.22, 9.8096*10^6}, {2211.6,        9.80863*10^6}, {2211.83, 9.80765*10^6}, {2212.05,        9.80667*10^6}, {2212.28, 9.80568*10^6}, {2212.5,        9.80469*10^6}, {2212.71, 9.8037*10^6}, {2212.93,        9.8027*10^6}, {2213.14, 9.8017*10^6}, {2213.61,        9.80069*10^6}, {2214.15, 9.79968*10^6}, {2214.69,        9.79867*10^6}, {2215.22, 9.79765*10^6}, {2215.74,        9.79663*10^6}, {2216.26, 9.7956*10^6}, {2216.77,        9.79457*10^6}, {2217.28, 9.79354*10^6}, {2217.78,        9.7925*10^6}, {2218.28, 9.79146*10^6}, {2218.78,        9.79041*10^6}, {2219.27, 9.78936*10^6}, {2219.75,        9.78831*10^6}, {2220.23, 9.78725*10^6}, {2220.71,        9.78619*10^6}, {2221.18, 9.78512*10^6}, {2221.64,        9.78405*10^6}, {2222.1, 9.78298*10^6}, {2222.56,        9.7819*10^6}, {2223.02, 9.78082*10^6}, {2223.46,        9.77973*10^6}, {2223.91, 9.77864*10^6}, {2224.35,        9.77755*10^6}, {2224.79, 9.77645*10^6}, {2225.22,        9.77535*10^6}, {2225.65, 9.77424*10^6}, {2226.07,        9.77313*10^6}, {2226.49, 9.77202*10^6}, {2226.91,        9.7709*10^6}, {2227.32, 9.76978*10^6}, {2227.73,        9.76865*10^6}, {2228.13, 9.76752*10^6}, {2228.53,        9.76639*10^6}, {2228.93, 9.76525*10^6}, {2229.32,        9.76411*10^6}, {2229.71, 9.76296*10^6}, {2230.1,        9.76181*10^6}, {2230.48, 9.76066*10^6}, {2230.86,        9.7595*10^6}, {2231.23, 9.75834*10^6}, {2231.6,        9.75717*10^6}, {2231.97, 9.756*10^6}, {2232.34,        9.75483*10^6}, {2232.69, 9.75365*10^6}, {2233.05,        9.75247*10^6}, {2233.4, 9.75128*10^6}, {2233.74,        9.75009*10^6}, {2234.09, 9.7489*10^6}, {2234.43,        9.7477*10^6}, {2234.77, 9.7465*10^6}, {2235.1,        9.74529*10^6}, {2235.43, 9.74408*10^6}, {2235.76,        9.74287*10^6}, {2236.08, 9.74165*10^6}, {2236.41,        9.74043*10^6}, {2236.72, 9.7392*10^6}, {2237.04,        9.73797*10^6}, {2237.35, 9.73674*10^6}, {2237.66,        9.7355*10^6}, {2237.97, 9.73426*10^6}, {2238.27,        9.73301*10^6}, {2238.57, 9.73176*10^6}, {2238.87,        9.73051*10^6}, {2239.17, 9.72925*10^6}, {2239.46,        9.72799*10^6}, {2239.75, 9.72672*10^6}, {2240.03,        9.72545*10^6}, {2240.32, 9.72418*10^6}, {2240.6,        9.7229*10^6}, {2240.88, 9.72162*10^6}, {2241.15,        9.72033*10^6}, {2241.43, 9.71904*10^6}, {2241.7,        9.71775*10^6}, {2241.96, 9.71645*10^6}, {2242.23,        9.71515*10^6}, {2242.49, 9.71384*10^6}, {2242.75,        9.71253*10^6}, {2243.01, 9.71122*10^6}, {2243.26,        9.7099*10^6}, {2243.51, 9.70858*10^6}, {2243.76,        9.70725*10^6}, {2244.01, 9.70592*10^6}, {2244.26,        9.70459*10^6}, {2244.5, 9.70325*10^6}, {2244.74,        9.70191*10^6}, {2244.98, 9.70056*10^6}, {2245.21,        9.69921*10^6}, {2245.44, 9.69786*10^6}, {2245.67,        9.6965*10^6}, {2245.9, 9.69514*10^6}, {2246.13,        9.69377*10^6}, {2246.35, 9.6924*10^6}, {2246.57,        9.69103*10^6}, {2246.79, 9.68965*10^6}, {2247.01,        9.68827*10^6}, {2247.22, 9.68688*10^6}, {2247.44,        9.68549*10^6}, {2247.65, 9.6841*10^6}, {2247.76,        9.6827*10^6}, {2247.78, 9.6813*10^6}, {2247.79,        9.67989*10^6}, {2247.8, 9.67848*10^6}, {2247.95,        9.67707*10^6}, {2248.16, 9.67565*10^6}, {2248.36,        9.67423*10^6}, {2248.56, 9.6728*10^6}, {2248.76,        9.67137*10^6}, {2248.96, 9.66994*10^6}, {2249.15,        9.6685*10^6}, {2249.34, 9.66706*10^6}, {2249.53,        9.66561*10^6}, {2249.72, 9.66416*10^6}, {2249.91,        9.66271*10^6}, {2250.09, 9.66125*10^6}, {2250.27,        9.65979*10^6}, {2250.45, 9.65832*10^6}, {2250.63,        9.65685*10^6}, {2250.81, 9.65538*10^6}, {2250.98,        9.6539*10^6}, {2251.16, 9.65242*10^6}, {2251.33,        9.65093*10^6}, {2251.5, 9.64944*10^6}, {2251.66,        9.64795*10^6}, {2251.83, 9.64645*10^6}, {2251.99,        9.64495*10^6}, {2252.15, 9.64344*10^6}, {2252.31,        9.64193*10^6}, {2252.47, 9.64042*10^6}, {2252.62,        9.6389*10^6}, {2252.78, 9.63738*10^6}, {2252.93,        9.63585*10^6}, {2253.08, 9.63432*10^6}, {2253.23,        9.63279*10^6}, {2253.38, 9.63125*10^6}, {2253.52,        9.62971*10^6}, {2253.67, 9.62816*10^6}, {2253.81,        9.62661*10^6}, {2253.95, 9.62506*10^6}, {2254.09,        9.6235*10^6}, {2254.22, 9.62194*10^6}, {2254.36,        9.62037*10^6}, {2254.49, 9.6188*10^6}, {2254.62,        9.61723*10^6}, {2254.75, 9.61565*10^6}, {2254.88,        9.61407*10^6}, {2255.01, 9.61248*10^6}, {2255.13,        9.61089*10^6}, {2255.26, 9.6093*10^6}, {2255.38,        9.6077*10^6}, {2255.5, 9.6061*10^6}, {2255.62,        9.60449*10^6}, {2255.74, 9.60288*10^6}, {2255.85,        9.60127*10^6}, {2255.97, 9.59965*10^6}, {2256.08,        9.59803*10^6}, {2256.19, 9.5964*10^6}, {2256.3,        9.59477*10^6}, {2256.41, 9.59314*10^6}, {2256.51,        9.5915*10^6}, {2256.62, 9.58986*10^6}, {2256.72,        9.58821*10^6}, {2256.82, 9.58656*10^6}, {2256.92,        9.58491*10^6}, {2257.02, 9.58325*10^6}, {2257.12,        9.58159*10^6}, {2257.22, 9.57992*10^6}, {2257.31,        9.57825*10^6}, {2257.4, 9.57658*10^6}, {2257.5,        9.5749*10^6}, {2257.58, 9.57322*10^6}, {2257.67,        9.57153*10^6}, {2257.75, 9.56984*10^6}, {2257.84,        9.56815*10^6}, {2257.92, 9.56645*10^6}, {2258.,        9.56475*10^6}, {2258.08, 9.56304*10^6}, {2258.16,        9.56133*10^6}, {2258.23, 9.55962*10^6}, {2258.39,        9.5579*10^6}, {2258.82, 9.55618*10^6}, {2259.26,        9.55445*10^6}, {2259.69, 9.55272*10^6}, {2260.13,        9.55099*10^6}, {2260.55, 9.54925*10^6}, {2260.98,        9.54751*10^6}, {2261.4, 9.54576*10^6}, {2261.82,        9.54401*10^6}, {2262.24, 9.54226*10^6}, {2262.65,        9.5405*10^6}, {2263.06, 9.53874*10^6}, {2263.47,        9.53697*10^6}, {2263.87, 9.5352*10^6}, {2264.28,        9.53343*10^6}, {2264.68, 9.53165*10^6}, {2265.07,        9.52987*10^6}, {2265.47, 9.52808*10^6}, {2265.86,        9.52629*10^6}, {2266.25, 9.5245*10^6}, {2266.63,        9.5227*10^6}, {2267.02, 9.5209*10^6}, {2267.4,        9.51909*10^6}, {2267.78, 9.51728*10^6}, {2268.17,        9.51547*10^6}, {2268.56, 9.51365*10^6}, {2268.94,        9.51183*10^6}, {2269.33, 9.51*10^6}, {2269.71,        9.50817*10^6}, {2270.09, 9.50634*10^6}, {2270.47,        9.5045*10^6}, {2270.84, 9.50266*10^6}, {2271.21,        9.50081*10^6}, {2271.58, 9.49896*10^6}, {2271.95,        9.49711*10^6}, {2272.31, 9.49525*10^6}, {2272.67,        9.49339*10^6}, {2273.03, 9.49152*10^6}, {2273.39,        9.48965*10^6}, {2273.74, 9.48778*10^6}, {2274.09,        9.4859*10^6}, {2274.44, 9.48402*10^6}, {2274.78,        9.48213*10^6}, {2275.13, 9.48024*10^6}, {2275.47,        9.47835*10^6}, {2275.81, 9.47645*10^6}, {2276.14,        9.47455*10^6}, {2276.48, 9.47264*10^6}, {2276.81,        9.47073*10^6}, {2277.14, 9.46882*10^6}, {2277.5,        9.4669*10^6}, {2277.93, 9.46498*10^6}, {2278.35,        9.46305*10^6}, {2278.77, 9.46112*10^6}, {2279.19,        9.45919*10^6}, {2279.61, 9.45725*10^6}, {2280.02,        9.45531*10^6}, {2280.4, 9.45336*10^6}, {2280.75,        9.45141*10^6}, {2281.1, 9.44946*10^6}, {2281.44,        9.4475*10^6}, {2281.79, 9.44554*10^6}, {2282.13,        9.44357*10^6}, {2282.47, 9.4416*10^6}, {2282.81,        9.43963*10^6}, {2283.14, 9.43765*10^6}, {2283.47,        9.43567*10^6}, {2283.8, 9.43368*10^6}, {2284.13,        9.43169*10^6}, {2284.46, 9.4297*10^6}, {2284.78,        9.4277*10^6}, {2285.1, 9.4257*10^6}, {2285.42,        9.42369*10^6}, {2285.73, 9.42168*10^6}, {2286.05,        9.41967*10^6}, {2286.36, 9.41765*10^6}, {2286.67,        9.41563*10^6}, {2286.97, 9.4136*10^6}, {2287.28,        9.41157*10^6}, {2287.58, 9.40954*10^6}, {2287.88,        9.4075*10^6}, {2288.18, 9.40546*10^6}, {2288.47,        9.40341*10^6}, {2288.77, 9.40136*10^6}, {2289.06,        9.39931*10^6}, {2289.35, 9.39725*10^6}, {2289.63,        9.39519*10^6}, {2289.92, 9.39312*10^6}, {2290.2,        9.39105*10^6}, {2290.48, 9.38898*10^6}, {2290.76,        9.3869*10^6}, {2291.04, 9.38482*10^6}, {2291.31,        9.38273*10^6}, {2291.58, 9.38064*10^6}, {2291.85,        9.37855*10^6}, {2292.12, 9.37645*10^6}, {2292.39,        9.37435*10^6}, {2292.65, 9.37224*10^6}, {2292.91,        9.37013*10^6}, {2293.17, 9.36802*10^6}, {2293.43,        9.3659*10^6}, {2293.68, 9.36378*10^6}, {2293.94,        9.36165*10^6}, {2294.19, 9.35952*10^6}, {2294.44,        9.35739*10^6}, {2294.69, 9.35525*10^6}, {2294.93,        9.35311*10^6}, {2295.18, 9.35096*10^6}, {2295.42,        9.34881*10^6}, {2295.66, 9.34666*10^6}, {2295.9,        9.3445*10^6}, {2296.23, 9.34234*10^6}, {2296.6,        9.34017*10^6}, {2296.96, 9.338*10^6}, {2297.32,        9.33583*10^6}, {2297.68, 9.33365*10^6}, {2298.03,        9.33147*10^6}, {2298.39, 9.32928*10^6}, {2298.74,        9.32709*10^6}, {2299.09, 9.3249*10^6}, {2299.39,        9.3227*10^6}, {2299.65, 9.3205*10^6}, {2299.9,        9.31829*10^6}, {2300.15, 9.31608*10^6}, {2300.4,        9.31387*10^6}, {2300.65, 9.31165*10^6}, {2300.9,        9.30943*10^6}, {2301.14, 9.3072*10^6}, {2301.38,        9.30497*10^6}, {2301.62, 9.30274*10^6}, {2301.86,        9.3005*10^6}, {2302.1, 9.29826*10^6}, {2302.33,        9.29601*10^6}, {2302.56, 9.29376*10^6}, {2302.8,        9.29151*10^6}, {2303.02, 9.28925*10^6}, {2303.25,        9.28699*10^6}, {2303.48, 9.28472*10^6}, {2303.7,        9.28245*10^6}, {2303.92, 9.28018*10^6}, {2304.14,        9.2779*10^6}, {2304.36, 9.27562*10^6}, {2304.57,        9.27333*10^6}, {2304.79, 9.27104*10^6}, {2305.,        9.26875*10^6}, {2305.21, 9.26645*10^6}, {2305.42,        9.26415*10^6}, {2305.62, 9.26184*10^6}, {2305.83,        9.25953*10^6}, {2306.03, 9.25722*10^6}, {2306.23,        9.2549*10^6}, {2306.43, 9.25258*10^6}, {2306.63,        9.25025*10^6}, {2306.83, 9.24792*10^6}, {2307.02,        9.24559*10^6}, {2307.21, 9.24325*10^6}, {2307.4,        9.24091*10^6}, {2307.59, 9.23856*10^6}, {2307.78,        9.23621*10^6}, {2307.96, 9.23386*10^6}, {2308.15,        9.2315*10^6}, {2308.33, 9.22914*10^6}, {2308.51,        9.22677*10^6}, {2308.69, 9.2244*10^6}, {2308.87,        9.22203*10^6}, {2309.04, 9.21965*10^6}, {2309.22,        9.21727*10^6}, {2309.39, 9.21488*10^6}, {2309.56,        9.21249*10^6}, {2309.73, 9.2101*10^6}, {2309.89,        9.2077*10^6}, {2310.06, 9.2053*10^6}, {2310.22,        9.20289*10^6}, {2310.38, 9.20048*10^6}, {2310.69,        9.19807*10^6}, {2311.04, 9.19565*10^6}, {2311.38,        9.19323*10^6}, {2311.63, 9.1908*10^6}, {2311.82,        9.18837*10^6}, {2312.01, 9.18594*10^6}, {2312.19,        9.1835*10^6}, {2312.38, 9.18106*10^6}, {2312.56,        9.17861*10^6}, {2312.74, 9.17616*10^6}, {2312.92,        9.17371*10^6}, {2313.1, 9.17125*10^6}, {2313.28,        9.16879*10^6}, {2313.45, 9.16632*10^6}, {2313.62,        9.16385*10^6}, {2313.79, 9.16138*10^6}, {2313.96,        9.1589*10^6}, {2314.13, 9.15642*10^6}, {2314.3,        9.15393*10^6}, {2314.46, 9.15144*10^6}, {2314.63,        9.14895*10^6}, {2314.84, 9.14645*10^6}, {2315.05,        9.14395*10^6}, {2315.25, 9.14144*10^6}, {2315.46,        9.13893*10^6}, {2315.66, 9.13642*10^6}, {2315.87,        9.1339*10^6}, {2316.07, 9.13138*10^6}, {2316.27,        9.12885*10^6}, {2316.47, 9.12632*10^6}, {2316.66,        9.12379*10^6}, {2316.86, 9.12125*10^6}, {2317.05,        9.11871*10^6}, {2317.25, 9.11616*10^6}, {2317.44,        9.11361*10^6}, {2317.63, 9.11106*10^6}, {2317.82,        9.1085*10^6}, {2318.01, 9.10594*10^6}, {2318.19,        9.10337*10^6}, {2318.38, 9.1008*10^6}, {2318.56,        9.09823*10^6}, {2318.74, 9.09565*10^6}, {2318.92,        9.09307*10^6}, {2319.1, 9.09048*10^6}, {2319.28,        9.08789*10^6}, {2319.46, 9.0853*10^6}, {2319.63,        9.0827*10^6}, {2319.81, 9.0801*10^6}, {2319.98,        9.07749*10^6}, {2320.15, 9.07488*10^6}, {2320.32,        9.07227*10^6}, {2320.49, 9.06965*10^6}, {2320.59,        9.06703*10^6}, {2320.67, 9.0644*10^6}, {2320.74,        9.06177*10^6}, {2320.81, 9.05914*10^6}, {2320.88,        9.0565*10^6}, {2320.95, 9.05386*10^6}, {2321.01,        9.05121*10^6}, {2321.08, 9.04856*10^6}, {2321.14,        9.04591*10^6}, {2321.21, 9.04325*10^6}, {2321.27,        9.04059*10^6}, {2321.48, 9.03792*10^6}, {2321.71,        9.03525*10^6}, {2321.94, 9.03258*10^6}, {2322.17,        9.0299*10^6}, {2322.4, 9.02722*10^6}, {2322.63,        9.02453*10^6}, {2322.86, 9.02184*10^6}, {2323.08,        9.01915*10^6}, {2323.31, 9.01645*10^6}, {2323.53,        9.01375*10^6}, {2323.75, 9.01104*10^6}, {2323.97,        9.00833*10^6}, {2324.19, 9.00562*10^6}, {2324.41,        9.0029*10^6}, {2324.62, 9.00018*10^6}, {2324.84,        8.99745*10^6}, {2325.05, 8.99472*10^6}, {2325.27,        8.99199*10^6}, {2325.48, 8.98925*10^6}, {2325.69,        8.98651*10^6}, {2325.89, 8.98376*10^6}, {2326.1,        8.98101*10^6}, {2326.31, 8.97826*10^6}, {2326.51,        8.9755*10^6}, {2326.72, 8.97274*10^6}, {2326.92,        8.96997*10^6}, {2327.12, 8.9672*10^6}, {2327.32,        8.96443*10^6}, {2327.52, 8.96165*10^6}, {2327.71,        8.95887*10^6}, {2327.91, 8.95608*10^6}, {2328.08,        8.95329*10^6}, {2328.12, 8.9505*10^6}, {2328.16,        8.9477*10^6}, {2328.2, 8.9449*10^6}, {2328.24,        8.94209*10^6}, {2328.28, 8.93928*10^6}, {2328.32,        8.93647*10^6}, {2328.35, 8.93365*10^6}, {2328.38,        8.93083*10^6}, {2328.42, 8.928*10^6}, {2328.45,        8.92517*10^6}, {2328.48, 8.92234*10^6}, {2328.51,        8.9195*10^6}, {2328.53, 8.91666*10^6}, {2328.56,        8.91381*10^6}, {2328.58, 8.91096*10^6}, {2328.61,        8.90811*10^6}, {2328.63, 8.90525*10^6}, {2328.65,        8.90239*10^6}, {2328.67, 8.89952*10^6}, {2328.69,        8.89665*10^6}, {2328.71, 8.89378*10^6}, {2328.72,        8.8909*10^6}, {2328.74, 8.88802*10^6}, {2328.75,        8.88513*10^6}, {2328.77, 8.88224*10^6}, {2328.78,        8.87935*10^6}, {2328.79, 8.87645*10^6}, {2328.8,        8.87355*10^6}, {2328.8, 8.87064*10^6}, {2328.81,        8.86773*10^6}, {2328.86, 8.86482*10^6}, {2328.94,        8.8619*10^6}, {2329.03, 8.85898*10^6}, {2329.11,        8.85605*10^6}, {2329.19, 8.85312*10^6}, {2329.27,        8.85019*10^6}, {2329.35, 8.84725*10^6}, {2329.43,        8.84431*10^6}, {2329.51, 8.84136*10^6}, {2329.59,        8.83841*10^6}, {2329.66, 8.83546*10^6}, {2329.73,        8.8325*10^6}, {2329.81, 8.82954*10^6}, {2329.88,        8.82657*10^6}, {2329.95, 8.8236*10^6}, {2330.02,        8.82063*10^6}, {2330.09, 8.81765*10^6}, {2330.15,        8.81467*10^6}, {2330.22, 8.81168*10^6}, {2330.28,        8.80869*10^6}, {2330.35, 8.8057*10^6}, {2330.41,        8.8027*10^6}, {2330.47, 8.7997*10^6}, {2330.53,        8.79669*10^6}, {2330.59, 8.79368*10^6}, {2330.64,        8.79067*10^6}, {2330.7, 8.78765*10^6}, {2330.76,        8.78463*10^6}, {2330.81, 8.7816*10^6}, {2330.86,        8.77857*10^6}, {2330.92, 8.77554*10^6}, {2330.97,        8.7725*10^6}, {2331.02, 8.76946*10^6}, {2331.07,        8.76641*10^6}, {2331.11, 8.76336*10^6}, {2331.16,        8.76031*10^6}, {2331.21, 8.75725*10^6}, {2331.25,        8.75419*10^6}, {2331.29, 8.75112*10^6}, {2331.33,        8.74805*10^6}, {2331.38, 8.74498*10^6}, {2331.42,        8.7419*10^6}, {2331.45, 8.73882*10^6}, {2331.49,        8.73573*10^6}, {2331.53, 8.73264*10^6}, {2331.56,        8.72955*10^6}, {2331.6, 8.72645*10^6}, {2331.63,        8.72335*10^6}, {2331.67, 8.72024*10^6}, {2331.7,        8.71713*10^6}, {2331.73, 8.71402*10^6}, {2331.76,        8.7109*10^6}, {2331.78, 8.70778*10^6}, {2331.86,        8.70465*10^6}, {2331.96, 8.70152*10^6}, {2332.05,        8.69839*10^6}, {2332.15, 8.69525*10^6}, {2332.24,        8.69211*10^6}, {2332.34, 8.68896*10^6}, {2332.39,        8.68581*10^6}, {2332.32, 8.68266*10^6}, {2332.25,        8.6795*10^6}, {2332.18, 8.67634*10^6}, {2332.11,        8.67317*10^6}, {2332.11, 8.67*10^6}, {2332.12,        8.66683*10^6}, {2332.12, 8.66365*10^6}, {2332.13,        8.66047*10^6}, {2332.13, 8.65728*10^6}, {2332.14,        8.65409*10^6}, {2332.14, 8.6509*10^6}, {2332.14,        8.6477*10^6}, {2332.14, 8.6445*10^6}, {2332.14,        8.64129*10^6}, {2332.14, 8.63808*10^6}, {2332.14,        8.63487*10^6}, {2332.15, 8.63165*10^6}, {2332.21,        8.62843*10^6}, {2332.26, 8.6252*10^6}, {2332.32,        8.62197*10^6}, {2332.37, 8.61874*10^6}, {2332.42,        8.6155*10^6}, {2332.48, 8.61226*10^6}, {2332.53,        8.60901*10^6}, {2332.58, 8.60576*10^6}, {2332.62,        8.60251*10^6}, {2332.67, 8.59925*10^6}, {2332.72,        8.59599*10^6}, {2332.76, 8.59272*10^6}, {2332.81,        8.58945*10^6}, {2332.85, 8.58618*10^6}, {2332.89,        8.5829*10^6}, {2332.93, 8.57962*10^6}, {2332.97,        8.57633*10^6}, {2333.01, 8.57304*10^6}, {2333.05,        8.56975*10^6}, {2333.09, 8.56645*10^6}, {2333.12,        8.56315*10^6}, {2333.16, 8.55984*10^6}, {2333.19,        8.55653*10^6}, {2333.22, 8.55322*10^6}, {2333.25,        8.5499*10^6}, {2333.28, 8.54658*10^6}, {2333.31,        8.54325*10^6}, {2333.34, 8.53992*10^6}, {2333.37,        8.53659*10^6}, {2333.4, 8.53325*10^6}, {2333.42,        8.52991*10^6}, {2333.45, 8.52656*10^6}, {2333.47,        8.52321*10^6}, {2333.49, 8.51986*10^6}, {2333.51,        8.5165*10^6}, {2333.53, 8.51314*10^6}, {2333.55,        8.50977*10^6}, {2333.57, 8.5064*10^6}, {2333.59,        8.50303*10^6}, {2333.6, 8.49965*10^6}, {2333.62,        8.49627*10^6}, {2333.63, 8.49288*10^6}, {2333.65,        8.48949*10^6}, {2333.66, 8.4861*10^6}, {2333.67,        8.4827*10^6}, {2333.68, 8.4793*10^6}, {2333.69,        8.47589*10^6}, {2333.7, 8.47248*10^6}, {2333.71,        8.46907*10^6}, {2333.71, 8.46565*10^6}, {2333.72,        8.46223*10^6}, {2333.72, 8.4588*10^6}, {2333.73,        8.45537*10^6}, {2333.73, 8.45194*10^6}, {2333.73,        8.4485*10^6}, {2333.73, 8.44506*10^6}, {2333.73,        8.44161*10^6}, {2333.73, 8.43816*10^6}, {2333.73,        8.43471*10^6}, {2333.72, 8.43125*10^6}, {2333.72,        8.42779*10^6}, {2333.71, 8.42432*10^6}, {2333.71,        8.42085*10^6}, {2333.7, 8.41738*10^6}, {2333.69,        8.4139*10^6}, {2333.69, 8.41042*10^6}, {2333.68,        8.40693*10^6}, {2333.66, 8.40344*10^6}, {2333.65,        8.39995*10^6}, {2333.64, 8.39645*10^6}, {2333.63,        8.39295*10^6}, {2333.61, 8.38944*10^6}, {2333.6,        8.38593*10^6}, {2333.58, 8.38242*10^6}, {2333.56,        8.3789*10^6}, {2333.55, 8.37538*10^6}, {2333.53,        8.37185*10^6}, {2333.51, 8.36832*10^6}, {2333.48,        8.36479*10^6}, {2333.46, 8.36125*10^6}, {2333.44,        8.35771*10^6}, {2333.41, 8.35416*10^6}, {2333.39,        8.35061*10^6}, {2333.36, 8.34706*10^6}, {2333.34,        8.3435*10^6}, {2333.31, 8.33994*10^6}, {2333.28,        8.33637*10^6}, {2333.25, 8.3328*10^6}, {2333.22,        8.32923*10^6}, {2333.19, 8.32565*10^6}, {2333.16,        8.32207*10^6}, {2333.12, 8.31848*10^6}, {2333.09,        8.31489*10^6}, {2333.06, 8.3113*10^6}, {2333.02,        8.3077*10^6}, {2332.98, 8.3041*10^6}, {2332.95,        8.30049*10^6}, {2332.91, 8.29688*10^6}, {2332.87,        8.29327*10^6}, {2332.83, 8.28965*10^6}, {2332.79,        8.28603*10^6}, {2332.74, 8.2824*10^6}, {2332.7,        8.27877*10^6}, {2332.66, 8.27514*10^6}, {2332.61,        8.2715*10^6}, {2332.55, 8.26786*10^6}, {2332.48,        8.26421*10^6}, {2332.42, 8.26056*10^6}, {2332.35,        8.25691*10^6}, {2332.29, 8.25325*10^6}, {2332.22,        8.24959*10^6}, {2332.15, 8.24592*10^6}, {2332.08,        8.24225*10^6}, {2332.01, 8.23858*10^6}, {2331.94,        8.2349*10^6}, {2331.87, 8.23122*10^6}, {2331.79,        8.22753*10^6}, {2331.72, 8.22384*10^6}, {2331.64,        8.22015*10^6}, {2331.57, 8.21645*10^6}, {2331.49,        8.21275*10^6}, {2331.42, 8.20904*10^6}, {2331.34,        8.20533*10^6}, {2331.26, 8.20162*10^6}, {2331.18,        8.1979*10^6}, {2331.1, 8.19418*10^6}, {2331.02,        8.19045*10^6}, {2330.94, 8.18672*10^6}, {2330.85,        8.18299*10^6}, {2330.77, 8.17925*10^6}, {2330.68,        8.17551*10^6}, {2330.6, 8.17176*10^6}, {2330.51,        8.16801*10^6}, {2330.43, 8.16426*10^6}, {2330.34,        8.1605*10^6}, {2330.25, 8.15674*10^6}, {2330.16,        8.15297*10^6}, {2330.07, 8.1492*10^6}, {2329.98,        8.14543*10^6}, {2329.89, 8.14165*10^6}, {2329.79,        8.13787*10^6}, {2329.7, 8.13408*10^6}, {2329.6,        8.13029*10^6}, {2329.51, 8.1265*10^6}}


Grid - problem with ItemSize being ignored

Still present in version 10. * * * I have run into another problem with `Grid` today.   An explicitly specified `ItemSize` is being ignored:               dot = Graphics[{Pink, Disk[]}, ImageSize -> 40];          tab = {{"Type", "Name", \[SpanFromLeft], \[SpanFromLeft],          Item[dot, ItemSize -> 2.7],          Item["Esculap",           Alignment ->            Left], \[SpanFromLeft], \[SpanFromLeft]}, {\[SpanFromAbove],          "Dia.", "Spec", \[SpanFromLeft], \[SpanFromAbove],          Item[8.3 "mm", ItemSize -> {3.5, 2.7}, Alignment -> Right],          Item[11, Alignment -> Right], "6.3"}, {Item[dot, ItemSize -> 2.7],          Item["Flycatcher",           Alignment -> Left], \[SpanFromLeft], \[SpanFromLeft],          Item[dot, ItemSize -> 2.7],          Item["Apus",           Alignment ->            Left], \[SpanFromLeft], \[SpanFromLeft]}, {\[SpanFromAbove],          Item[6.9 "mm", ItemSize -> {3.5, 2.7}, Alignment -> Right],          Item[17, Alignment -> Right], "9.8", \[SpanFromAbove],          Item[7.8 "mm", ItemSize -> {3.5, 2.7}, Alignment -> Right],          Item[8, Alignment -> Right], "6.7"}};          Grid[tab,      Spacings -> {Automatic, {{0, -1.1}}},      Alignment -> {Center, Center},      Dividers -> All     ]      ![Mathematica graphics](http://i.stack.imgur.com/ywAOm.png) Please note `Item[8.3 "mm", ItemSize -> {3.5, 2.7}, Alignment -> Right]` where a vertical ItemSize is explicitly specified, yet it is ignored in the layout. If the "Spec" cell is not spanned this does not happen:               tab[[2, 4]] = "X";          Grid[tab,      Spacings -> {Automatic, {{0, -1.1}}},      Alignment -> {Center, Center},      Dividers -> All     ]      ![Mathematica graphics](http://i.stack.imgur.com/7c2kT.png)   * Is this another bug in `Grid`?   * Is it still present in version 8?   * How can I best work around it?


How can we tell Series to treat the expansion parameter as an integer?

It is simple for Mathematica to find an asymptotic expansion for $\frac{1}{-1+p}$ as $p \rightarrow \infty$. However, if we want to restrict $p$ to be an integer and also include some terms that simplify for integer p (but not generally) then Series by itself will no longer do the job (without some prodding, I expect). Is there a simple way to use Series to find the asymptotic expansion of $$\frac{1}{(-1)^p+p}$$ as $p \rightarrow \infty$, assuming integer $p$?


How do I speed up Plot when the independent variable is in the Numerical expression

In the following               HH = H /. {μ -> 1, Δ -> .3, L -> 11, ky -> 0};     Plot[Re[Sort[Eigenvalues[HH]]], {kx, -2 π/11, 2 π/11}, PlotPoints -> 10]      where `H` is a matrix expression that depends on `kx, ky, μ, L, Δ`. Is there a faster way to plot the numerical eigenvalues of this matrix as a function of `kx`, for example? Any help would be really appreciated. **Update** I'd like to state, I want to do this purely numerical. My issue is that I want to solve the eigenvalue problem for MANY values of `kx`. H can be large in this case, sometimes 400 by 400. I only used 10 `PlotPoints` just as an example. I found that `Table` is very quick and I can do a `ListLinePlot`. I just naively thought this same operation would be done in `Plot`. This is where my confusion still lies if someone wants to help :) **Second Update** Here is `H` as requested.               NN = 40;     MM = 2 NN + 1;     kM = Table[           Boole[m == n] (ky + I (kx + m 2 π/L)),            {m, -NN, NN, 1}, {n, -NN, NN, 1}];          kM2 = Table[            Boole[m == n] (ky - I (kx + m 2 π/L)),             {m, -NN, NN, 1}, {n, -NN, NN, 1}];          μM = IdentityMatrix[MM] μ;          ΔM = (Δ I/2 )                  * Table[ (KroneckerDelta[m, n - 1] - KroneckerDelta[m, n + 1]),                           {m, -NN, NN, 1}, {n, -NN, NN, 1}];          H = ArrayFlatten[{          {-μM, kM,0 μM, ΔM},           {kM2, -μM, -ΔM, 0 μM},           {0 μM, -ΔM, μM, kM2},           {ΔM, 0 μM, kM, μM}         }];      **Third update**   This is initially represented as $h= \vec{\sigma} \cdot \vec{k}-\mu$ $h_\tau= \vec{\sigma^{\ast}} \cdot \vec{k}+\mu$ $H=\left(\begin{array}{cc} h & i \Delta \sigma_y\\\ -i \Delta\sigma_y & h_\tau \end{array}\right)$ where $\sigma$ are the Pauli matrices. The individual values change do to some implications from a physical system. I didn't want to get too deep into the physics, as there is another stack for that. The block elements don't commute because the Pauli matrices don't commute, but if you see any symmetries that I don't see please do enlighten me. So far I've always done this numerically.


Find variable name from DumpSave on a scoped variable

I saved an `InterpolationFunction` in a ".mx" files using `DumpSave` on a variable that was scoped by a `Module`. Here is a stripped-down example:               Module[{interpolation},        interpolation=Interpolation[Range[10]];        DumpSave["interpolation.mx", interpolation];     ]      Is there a way to find out the variable name, presumably of the form `interpolation$nnn`, of the expression when I `Get` the interpolation? It is not apparent what the variable is when using               <<"interpolation.mx"      Next time I will not use a `Module` for scoping the save variable, but meantime I'd like to access the saved data and assign it to a new variable.


Mathematica won't simplify multiplication by zero

I'm getting a huge output, but it appears that almost every term should actually be zero, unless I'm misunderstanding the expression. For example, part of the output reads > >     a (0.25 + 0. b) + b^2 (0. + 0./c) + b (-1. + 0. c) - 0.5 c + (b (-1. b - > 0.5 c) c)/a^2 >   `Simplify` and `FullSimplify` won't get rid of these zero terms even with assumptions that `a,b` and `c` are real and non-zero. Suggestions ?


Using DeleteCases with multiple AstronomicalData properties

I am attempting to use `AstronomicalData` and `DeleteCases` together to remove invalid cases of two properties while listing the corresponding name which the data belongs to. I can only selectively choose one of the two properties in which to remove invalid cases from. An example of two selected properties with the first property being filtered;               DeleteCases[Transpose[{      AstronomicalData["Exoplanet", P1], AstronomicalData["Exoplanet", P2], AstronomicalData["Exoplanet"]      }],{_Missing,_,_}],      The issue is having a limitation of defining either `P1` or `P2` as the chosen property to remove invalid cases from. I have tried various ways of correcting this and can't apply it to both properties. I can switch which property it acts upon by swapping the slot _Missing is defined in like this;               {_Missing,_,_}     {_,_Missing,_}      Defining both slots doesn't apply the function to either individual property like this;               {_Missing,_Missing,_}      How can I achieve being able to filter the results where if either property has an invalid value the data is dismissed?


Another fractional part related question

Having known the fact that the evaluation of the integrals containing fractional parts often contains   errors, I wonder if the integral below possibly evaluates to $0.7$ or this is just a coincidence that               N[Integrate[Tan[x] - Floor[Tan[x]], {x, 0, Pi/2}], 16]      yields $0.6991518856432281$. How could I check if $0.7$ is or isn't the right answer?


Solving symbolic matrix equation

I have this equation, $$f(x)=Ax-diag(x)(Ax+b)$$, where $x\in \mathbb{R}^n$, $A\in \mathbb{R}^{n\times n}$ and $b\in \mathbb{R}^n$, for which I need to find the zeros. $x=0$ is an obvious solution, but I would like to see if there are other solutions as well. Is there an explicit way to get the solution in terms of, $A$ and $b$ without specifying the matrices completely?


Projection of curve 3D (x,y,z) on the x-y plane

I have a following systeme : \begin{equation} \left\\{ \begin{array}{rcr} (\beta+\frac{1}{2}\delta^{2})\nu_{1}(u)-\delta\nu_{2}(u)+\nu_{3}(u)& = &0\\\ (\beta+\frac{1}{2}\delta^{2})\upsilon_{1}(u)-\delta\upsilon_{2}(u)+\upsilon_{3}(u)& < &0\\\ \end{array} \right. \end{equation} where \begin{align*} &\nu_{1}(u)= q(u)f[q(u)],\\\ &\nu_{2}(u)= f[q(u)]^2 + F(x)q(u)f[q(u)],\\\ &\nu_{3}(u)= \left(u (f[q(u)])^2 + \frac{1}{2}u^2q(u)f[q(u)]\right),\\\ &q[u] := Quantile[NormalDistribution[0, 1], u], \ (the \ quantale \ at \ u)\\\ &f[q(u)]=PDF[NormalDistribution[0, 1], q(u)] \ (the \ density \ at \ q(u)), \end{align*} and for the inequality, $\upsilon_{i}(u)=\nu_{i}^\prime(u)$ with respect $q(u)$ for $ i\in \\{1,2,3\\}$ with $(\beta,\delta,u)\in [0.1]\times[0.1]\times[0.1]$. I would like to look at the projection of this system of equation onto the plane $(\beta,\delta)$ and $(u,\delta)$ in Mathematica or in r. My code sets up the full 3-d view of the 3D plot, which is not what I want. And I think there are some thing wrong in my picture. I'd like to see two of the views $(\beta,\delta)$ and $(u,\delta)$ on different figure.               q[u_] := Quantile[NormalDistribution[0, 1], u]     f[x_] := PDF[NormalDistribution[0, 1], x]     h1[u_, a_, e_] := ((((a^2)/2 + e)*(-q[u])*(f[q[u]])) -      a*(-q[u]*f[q[u]]*u  +   f[q[u]]^2) +      u*f[q[u]]^2 - (u^2)/2*q[u]*f[q[u]])/(1/6 - a/2 + (a^2)/2 + e)     h2[u_, a_, e_] := (((a^2)/2 + e)*((q[u]^2) - 1)*f[q[u]]) -      a*(u*(q[u]^2 - 1)*f[q[u]] - 3* q[u]*  f[q[u]]^2) + f[q[u]]^3 -      2*u*q[u]*f[q[u]]^2 -      u*q[u]*f[q[u]]^2 + ((u^2)/2)*(q[u]^2 - 1)*f[q[u]]     ContourPlot3D[ h1[u, a, e] == 0,      {a, 0, 1}, {u, 0.1, 0.9}, {e, 0, 1.5},      RegionFunction -> Function[{u, a, e}, h2[u, a, e] > 0]]      The graph 3D : ![enter image description here](http://i.stack.imgur.com/iWWIZ.jpg) I want to try do verify if my plot 3D is true and if it is possible to have the projection on both plan $(\beta,\delta)$ and $(u,\delta)$. Any thoughts on the best way to do this?


Can I have Mathematica show intermediate forms before final evaluation?

If I have               x = 2      and I want to evaluate               y = x^2      I would like to the output to show               y = (2)^2      before evaluating to 4.


Ideas on how to improve the rendering of the letter B in this 3D region plot?

I have been playing with the RegionPlot3D idea from this question and have been trying to approximate the Gödel, Escher, Bach logo, but I am a little bit stuck on how to improve the rendering of the letter B. Here is the code so far:               Letter[s_String] :=       ClusteringComponents[       Rasterize[Style[s, 128, Bold], "Image", RasterSize -> {100, 100}]]          Gödel = Letter["G"];     Escher = Letter["E"];     Bach = Letter["B"];          SetOptions[RegionPlot3D, Axes -> False, Boxed -> False,       PlotPoints -> 100, Mesh -> False, Lighting -> "Neutral",       Background -> Black, PlotStyle -> Orange];          RegionPlot3D[      Gödel[[Round[i], Round[j]]] > 1 &&       Escher[[Round[i], Round[k]]] > 1 &&      Bach[[Round[j], Round[k]]] > 1,       {i, 1, 100}, {j, 1, 100}, {k, 1, 100}]      This works nicely for the letter E and G as can be seen here: ![Mathematica graphics](http://i.stack.imgur.com/RKlEp.png) ![Mathematica graphics](http://i.stack.imgur.com/ja9Al.png) But the letter B is not looking as nice, I think because of the shape of the letter G: ![Mathematica graphics](http://i.stack.imgur.com/cpRlM.png) I am wondering if anyone has any good suggestions to correct the rendering of the letter B?


Undocumented syntax of FilledCurve

> **Possible Duplicate:**   >  Undocumented form for FilledCurve[] A nice trick to get the outline paths of letters is to use the PDF exporter/importer               el=      First[       First[         ImportString[           ExportString[             Style["L", Italic, FontSize -> 24, FontFamily -> "Arial"],              "PDF"           ],            "PDF",            "TextMode" -> "Outlines"          ]        ]     ];          Graphics[{EdgeForm[Black], LightBlue, el}];      ![Mathematica graphics](http://i.stack.imgur.com/xKY39.png) The outline paths are given in a `FilledCurve` construction (new in MMA8):               el          (*     ===>     {Thickness[0.07507507507507508],       Style[        {FilledCurve[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}}},                      {{{12.887695983062486, 5.160000000000004},                        {1.8237311169604027, 5.160000000000004},                        {5.496094644083314, 22.410000000000004},                        {7.823731116960403, 22.410000000000004},                        {4.5834973678187225, 7.222500000000004},                        {13.319824330510414, 7.222500000000004}                     }}         ]        },         Thickness -> 0.07507507507507508       ]}      *)      This syntax variant is not given in the `FilledCurve` help page:` ![Mathematica graphics](http://i.stack.imgur.com/MgqoO.png)   with _segments_ defined as: ![Mathematica graphics](http://i.stack.imgur.com/iTvG1.png) (The doc page doesn't give a formal definition of _components_ , BTW) While the second argument of `FilledCurve` in the undocumented output above is pretty obvious (the coordinates of the outline), the first part is not. My hypothesis is that it has something to do with bezier control points or so. Anyone got an idea about this?


Use of JoinedCurve with list only

When I `Import` an EPS file, bezier curves are converted into something like this:               Graphics[JoinedCurve[       {{{1, 4, 3}}}, {{{0., 0.}, {1., -1.}, {2., 1.}, {3.,  0.}}}, CurveClosed -> {0}]]      Here `JoinedCurve` contains no curve segments but two lists, but such a representation is not documented in the reference: http://reference.wolfram.com/mathematica/ref/JoinedCurve.html I can see that the latter list represents the list of control points, and `{{1, 4, 3}}` seems to do with something like dimensions of the points, but what is the exact use of it?


How to save numbers that are in Mathematica messages

I have a program that calls FindDistributionParameters and I get the Mathematica message FindMaximum::eit each time I call the function. The message is FindMaximum::eit: The algorithm does not converge to the tolerance of _4.641588833612792`*^-9_ in _517_ iterations. The best estimated solution, with feasibility residual, KKT residual, or complementary residual of _{8.785431001660695650243387×10-19,7.654089593359381289428268×10-7,3.755486893336661804848494×10-19}_ , is returned.  I want to save the numbers in the messages, so I setup a list to hold the messages as follows: AppendTo[messagelist, {General::eit}]; This saves the following, with none of the numbers in the original message: The algorithm does not converge to the tolerance of `1` in `2` iterations. The best estimated solution, with feasibility residual, KKT residual, or complementary residual of `3`, is returned. How can I access the numbers in the message and save them to a list or something else? Secondarily, is there a way to increase the number of iterations in FindDistributionParameters?


interpolating function over dates

I've got a bunch of readings at various dates and times. I'd like to be able to interpolate and then integrate over, say days. I can do this by converting my date/time to `AbosluteTime` and get the interpolating function that way. Then by integrating and plugging in seconds as my limits of integration I get what I want. Also, since seconds in really finer than I need, I convert all of the `AbsoluteTimes` to the number of hours since the first reading. I was wondering if there might be a way to do this directly using dates. For what it's worth, my readings last for about 2 months and the values are between about 90 and 300. **SAMPLE DATA**                x[[1 ;; 5]]      > {{{2014, 8, 4, 10, 36, 0.}, 257.},{{2014, 8, 4, 16, 28, 0.}, 385.}, > > {{2014, 8, 4, 22, 53, 0.}, 176.}, {{2014, 8, 5, 6, 52, 0.}, 148.}, {{2014, > 8, 5, 11, 19, 0.}, 192.}}


How to fill only a plotting area with Background

With               ListLinePlot [      {13, 6, 2, 2, 3},      AxesOrigin -> {1, 0},Background -> GrayLevel@0.95,      GridLines -> None, ImageSize -> 300,      ImageMargins -> 0, PlotLabel -> "XYZ",      Filling -> Bottom, PlotMarkers -> Automatic, Frame -> True]      I obtained: ![enter image description here](http://i.stack.imgur.com/8zcxS.jpg)   1. I would like to move the `PlotLabel` `"XYZ"` into the upperright corner of the plotting area.   2. The `Background`-option also colors the background of the axes-values and the label, but I only want to color (like in Excel) the actual plotting-area. I could think of some complicated ways to achieve this, but would like to see a short and handy solution. Thanks in advance for your help.


Function to select a row whose kth element is closest to a given number

I'm trying to write a function that picks out the row of a Matrix whose `kth` element is closest to some given number that will be given to me. So for example,               list = Table[{i, FromCharacterCode[70 + i]}, {i, 1, 10}]     {{1, "G"}, {2, "H"}, {3, "I"}, {4, "J"}, {5, "K"}, {6, "L"}, {7,"M"}, {8, "N"}, {9, "O"}, {10, "P"}}      ![enter image description here](http://i.stack.imgur.com/SZhuE.jpg)               b = RandomReal[{0, 6}]     4.42427      So I want to pick the row whose 1st element is closest to 4.42427. The function should spit out               {4,"J"}      **Edit** Btw, thanks to Mr. Wizard's help, my crappy code works!!               disT[l_List, bb_?NumericQ, cc_Integer] := Table[Abs[bb - l[[j, cc]]], {j, 1,Dimensions[l][[1]]}]          srcH[ll_List, bb_?NumericQ, cc_Integer] := Drop[First[Sort[Transpose[    Prepend[Transpose[ll], disT[ll, bb, cc]]], #1[[1]] < #2[[1]] &]],1]               disT[list,b,1]     {3.42427, 2.42427, 1.42427, 0.42427, 0.57573, 1.57573, 2.57573,3.57573, 4.57573,5.57573}          srcH[list, b, 1]     {4, "J"}      Now I will Implement Mr. Wizard's code or Daniel's code for my actual problem. Thanks!! **Edit2** To expand on what I wrote under Mr. Wizard's answer. The actual task that I am trying to accomplish involves many lists $list_k \; k \; \in \\{1,100\\}$ and many comparison lists $b_k = (b_{k1},...,b_{kj}), \; \; k \; \in \\{1,100\\}$ . So For example:                list[57]=  {{1, "G"}, {2, "H"}, {3, "I"}, {4, "J"}, {5, "K"}, {6, "L"}, {7,"M"}, {8, "N"}, {9, "O"}, {10, "P"}}           b[57]={0.1,7.3,9.8}           list[79]=  {{2.8, "G"}, {3.4, "H"}, {4.5, "I"}, {5.1, "J"}, {6.05, "K"}, {7.1, "L"}, {8.3,"M"}, {8.5, "N"}, {9, "O"}, {10, "P"}}           b[79]={5,7.2,8.1}      and my final output, as index goes from 1 to 100, will find rows where the first element is close to the elements of b[k] respectively:                output[57]={{1,G},{7,M},{10,P}}      output[79]={{5.1,J},{7.1,L},{8.3,M}}      I was planning on using the function I got from the help here at mma.se inside a table or something but since Mr. Wizard has mentioned speeding up computation, I figured it would be best if I described the exact problem I am working on.


Animating mathematica.se logo

As we all know our site's logo was completely generated by Mathematica. I suppose it is quite natural to make the next step -- to generate the animated version of this logo. There's a lot of space for creativity here, and I suggest to consider the following options.   1. Animated process of construction from scratch, as it is described in Verbeia's blog post.   2. Animated morphing of original pentagonal star to the current heptagonal one (J.M.'s idea in the comment)   3. Some less fussy, a neutral animation of the logo itself, more suitable for placing on webpages.


PowersRepresentations Algorithm

I'm trying to understand the mathematics behind counting the number of representations of a positive integer by $n$ distinct $k$th powers, i.e. I would really like to know how to do the Mathematica function PowersRepresentations by hand. Any explanations, references, even special cases (I'm particularly interested in $k=2$) would be appreciated. Thanks.


The same range on each plot in a grid

Suppose I have a bunch of graphics that I want to display in a grid:               GraphicsGrid[{       {Graphics[Circle[], Frame -> True],        Graphics[{Circle[], Circle[{2, 2}]}, Frame -> True]},       {Graphics[{Circle[{5, 5}, 2], Circle[{9, 9}, 2]}, Frame -> True],        Graphics[Circle[{100, 100}, 2], Frame -> True]}}]      ![1](http://i.stack.imgur.com/mN7ED.png) Each graphic is roughly the same size, but the range they cover differs. You can only see this by looking at the numbers on the axes. What I'd like to do is automatically replot the graphics over the same range so that objects are correctly sized relative to each other. Something like: ![2](http://i.stack.imgur.com/ReL5o.png) So given an array of graphics, how would I extract all the plot ranges and determine a new plot range for each one?


When should I use Apply (or Function) and when @@ (or &)?

This is a rather general question, which I fail to answer myself. I guess it is mainly due to my insufficient knowledge of the precise terms. If I understand correctly, the following are equivalent:               f = Function[u, 3 + u]     f = Function[3 + #]     f = (3+#) &     f[x_]:=3+x      In all cases `f[a]` would yield `3+a`. Similarly, `f[a]` is equivalent to `f@@{a}`. I have mainly two questions:   1. What is the right term to call the shorter version, i.e. the version where one uses `@@`, `#`, `&` etc.?   2. When should I prefer the one method and not the other? It seems like many answers given around MA.SE uses the "shorter version". What are the advantages and disadvantages... **Bonus question:** Note my first question. I hope I could get more fishing rods and less fish. In other words, what is the official term for these two notions? Where are can I find documentation of these differences? The examples I presented in the this questions are merely examples, and I try to understand where can I rigorously study these notions and similar ones.


How to find all roots and maxima and minima and graph them

I need to find all the roots of this function. I know it is simple to find by hand, however, I wish to learn how to do it so I can apply it later. The problem is that it only gives me one root.               Distance[t_] := t*(t - 1)*(t - 1.5)^2*(t - 3)     Velocity[t_] := Simplify[Distance'[t]]     FindRoot[Velocity[t], {t, -100, 100}]          {t -> 2.63641}      I can find the minimum and maximum. However, how would I plot them on the same graph as the function without copy and pasting the points manually into a list?


Use of Cellular Automaton or Discrete Convolution to calculate Potts Energy of a 2D Matrix

In a project of Monte Carlo Modelling of Grain Growth (Link) one of the most costly subroutines is the calculation of the Potts-Energy of an Monte Carlo Grid cell by comparing the center cell value with it's 9 neighbours and calculating a resulting Potential energy which is calculated as               pottsenergy[osub_]:=Total[Map[1-KroneckerDelta[#,osub[[2,2]]]&,osub,{2}],2];      with `osub` as a 3x3 matrix of integers. The overall algorithm convolves this calculation across the whole system matrix `oin` which can consist of big 2D matrices in the following way:               energy[o_, indx_, nmax_] := pottsenergy[o[[Sequence @@ energypart[indx, nmax]]]];      with energypart as a routine which returns the boundaries of the center cell position denoted by `indx` and its 9 neighbours in part notation:               energypart[indx_, {nx_, ny_}] :=Module[{ii, jj, it, ib, jl,jr},(*get part specification of nearest neighbours of location (ii,jj). Reflecting boundary conditions are assumed.*)     ii = indx[[1]]; jj = indx[[2]];     (*rows of top and bottom neighbours*)     it = If[ii == 1, 1, ii - 1];     ib = If[ii == ny, ny, ii + 1];     (*rows of left and right neighbours*)     (*rows of top and bottom neighbours*)     jl = If[jj == 1, 1, jj - 1];     jr = If[jj == nx, nx, jj + 1];     {it ;; ib, jl ;; jr}     ];      The actual convolution is then done as               allenergy[oin_, nmax_] := MapIndexed[energy[oin, #2, nmax] &, oin, {2}]      which takes a big 2D matrix and returns a big matrix with the Potts energy values of the input matrix `oin`:               oin = RandomInteger[31, {100, 100}];     allenergy[oin, Dimensions[oin]] // MatrixForm      Now the main problem is that this implementation is rather slow and cannot be easily sped up by use of a CUDA or parallelize implementation. Looking into the _Mathematica_ documentation I found some promising algorithms like Cellular Automaton or Discrete Convolution which would be definitely faster I suppose. Now the use of these routines are unfortunately non-trivial for above way of folding. Any ideas how to speed up above algorithm by using the power of _Mathematica_?


How to pass rules to packages

EDIT: After helpful comment from @Mr.Wizard I added the working implementation below for future reference. I wrote a module that does something with variables provided in form of a rule. It works nicely. A simplified version:               ruleAdd[assList_] := Module[{},       a + b + c /. assList       ]      This can be called by               ruleAdd[{a -> 1, b -> 3, c -> 5}]      And it works nicely. Now I would like to add this module into a package. However, from this point on I do get stuck. The implementation that gets closest to working is the following module:               BeginPackage["MCmoduleTemplate`"]     MCfun::usage = "description"     MCfun[assList_]:=Module[     {a,b,c},     a+b+c/.assList     ]     EndPackage[]      This I can run from the notebook level with the following lines:               a =.; b =.; c =.;     SetDirectory[NotebookDirectory[]];     << MCmoduleTemplate`     MCfun[{a -> 1, b -> 3, c -> 5}]      However, a, b and c are now highlighted in red and weird behavior occurs. Is there a good way, also including the `Begin["Private`"]` part in the Package to properly do this? As a workaround I am now just passing the values as parameters of the module which of course works, but I'd prefer to be able to pass rules to my modules in the long run to add flexibility. Thanks in advance. * * * Please find my favourite working implementation. Please have a look at the links by Mr.Wizard for alternative solutions. Thanks again, Mr.Wizard. Niels               BeginPackage["MCrulepackage`"]     MCfun::usage = "description"     a::usage=""     b::usage=""     c::usage=""          Begin["Private`"]          MCfun[assList_]:=Module[     {(* make sure a,b and c are NOT here. *)},     a+b+c/.assList     ]     End[] (* End Private` context *)     EndPackage[]      * * * BeginPackage["MCrulepackage`"] MCfun::usage = "description" a::usage="" b::usage="" c::usage="" Begin["Private`"] MCfun[assList_]:=Module[ {(* make sure a,b and c are NOT here. _)}, a+b+c/.assList ] End[] (_ End Private` context *) EndPackage[] \-- This can now be called from the notebook as SetDirectory[NotebookDirectory[]]; << MCrulepackage` MCfun[{a -> 1, b -> 2, c -> 3}] and works nicely. EDIT: This is the working solution based on the links provided by @Mr.Wizard. Thanks again!


Filtering beat-to-beat heart rate data

From an experiment, I have a dataset of beat-to-beat heart rate data: a list of the time between each heart beat in [ms]. The data is measured using an infrared optic sensor at the finger tip. The sensor frequently misinterprets a slight movement of the finger as an heart beat. Data therefore often looks somewhat like this:               {1000, 1000, 1000, 1000, 500, 500, 1000, 1000, 1000, 600, 400, 1000}      In this example, one can easily see that the 5th and 6th element should be one; same for the 10th and 11th. However, in real life the data looks more like this:               data = {981, 870, 1099, 1105, 650, 397, 920, 917, 1015, 1085, 210, 344, 457,     950}      where the 5-6 (`650, 397`) and 11-12-13 (`210, 344, 457`) should be taken together. It is easy to just delete the incorrect data by using something like:               DeleteCases[data,     x_ /; x < Mean[data] - StandardDeviation[data] ||      x > Mean[data] + StandardDeviation[data]]      ...but I want to make a function that recognizes when multiple elements should be added to one. One could just add every two, three or four (=`length`) elements and select the `Cases` where the result lies (for example) in the range `Mean[data]±StandardDeviation[data]`:               length = 2;     Position[Total[data[[# ;; # + length]]] & /@        Range[Length[data] - length],       x_ /; x > Mean[data] - StandardDeviation[data] &&         x < Mean[data] + StandardDeviation[data]]      Result:               {{5}, {11}, {12}}      This gives me an idea of where the incorrect data is. Unfortunately, after having this result, I don't know what to do with it... For example, I get confused by the fact that elements 11-12-13 return 2 cases of incorrect data when I use `length=1`. And maybe there are more (simple) ways to filter this data. **Question: can anyone give me a kick-start?** Edit: You can download an example of actual data here. Just `Flatten[Import[filename,"Table"]]`


CorrelationFunction for vectors

_Mathematica_ 9 has a new `CorrelationFunction`. Sadly the joy does not last long, as I can't get it to work with vectors. I would like to make a velocity correlation function. That is, given a list of n vectors I would like to calculate: ![velocity correlation function](http://i.stack.imgur.com/bbI0R.png) For example, this is almost instantaneous:               testdata = RandomVariate[BinormalDistribution[{10, 20}, 0.4], {10000}];     AbsoluteTiming[     x = CorrelationFunction[testdata[[All, 1]], {0, 1000}];     y = CorrelationFunction[testdata[[All, 2]], {0, 1000}];     ]     ListPlot[{x, y}, PlotRange -> {0, 1}]      (the test data here is not the best as it is by definition uncorrelated) Here I would like the autocorrelation of 2D vectors evenly spaced in time. But this does not work:               r = CorrelationFunction[testdata, {0, 100}];      **How can I make an autocorrelation for vectors?** Or do I have to go the manual way?               ClearAll[AbsoluteAutocorrelationT, AutocorrelationT]          AbsoluteAutocorrelationT[l_, 0] := Total[(#.#) & /@ l];     AbsoluteAutocorrelationT[l_, n_] :=        Total@Table[l[[i]].l[[i + n]], {i, Length[l] - n}];     AutocorrelationT[l_, range_] := Block[{t0, ti},        t0 = AbsoluteAutocorrelationT[l, 0];        ti = AbsoluteAutocorrelationT[l, #] & /@ (Range @@ range);        (ti/t0)];          AbsoluteTiming[r = AutocorrelationT[testdata, {1, 1000}];]      Which is 200 times slower. I know I can compile this (but than I have to worry about overflows in the sum, etc.)


This example displays a input window at a position of 675 from the left.               winMargins = {{675, Automatic}, {130, Automatic}};       InputString["testing WindowMargins!  stop: 0",          FieldSize -> Small, WindowMargins -> winMargins];      I want to display the window centered horizontally on the screen. I tried to use the following, but it does not work.               winMargins = {{Scaled[{0.5}], Automatic}, {130, Automatic}};        How can I get a horizontally centered input window?


How to change ColorFunction after plotting

Say I have a plot like               plot = DensityPlot[Exp[-((x-5)^2+(y-5)^2)/5^2], {x, 0, 10}, {y, 0, 10},PlotRange -> {0,1}]      ![Mathematica graphics](http://i.stack.imgur.com/cwkQu.png) Is there a way to change the `ColorFunction` _after the fact_ , as an operation on `plot` (say change it to `ColorFunction -> "Temperature"`) without changing the initial plot instructions?


How can I selectively trigger computations in Manipulate?

I have a `Manipulate` that uses `RandomVariate` and `Random` that I would like to have redraw and recompute random values selectively, depending on what `Manipulate` parameters have been changed. For example, I would like to be able to control redraws and recomputations so that   * new `data` and `honestMeans` are only computed if `n` has changed;   * new `punishMeans` are computed only when `n` or `punish` have changed;   * a redraw is triggered when `zoom` changes, but without triggering an update to `data`, `honestMeans` or `punishMeans`;   * a redraw triggered when any of `data`, `honestMeans` or `punishMeans` or `zoom` changes (without triggering a recomputation of `data`, `honestMeans` or `punishMeans`);   * everything updates if an explicit update is requested (somehow) as indicated in the comments below:               scale = 5;     dist = HypergeometricDistribution[scale, Round[0.7*2*scale], 2*scale];     genVotes[punish_, n_] := Module[{},        votes = {data[[1]]};        For[i = 2, i <= n, i++,         If[Random[] < punish,          If[votes[[i - 1]] > data[[i]], vote = 0, vote = scale],          vote = data[[i]]          ];         AppendTo[votes, Mean[Append[data[[1 ;; i - 1]], vote]]];         AppendTo[votes, Mean[Append[data[[1 ;; i - 1]], data[[i]]]]];         ]; Return[votes];        ];          Manipulate[       data = RandomVariate[dist, n];(* Should only change when n changes *)       punishMeans = genVotes[punish, n]; (* Should change when punish or n change *)       honestMeans = genVotes[0, n]; (* Should only change when n changes *)       GraphicsColumn[{ (* Should redraw when any of the above change, or if zoom changes, without triggering recompilation of data, punishMeans or honestMeans *)        Show[         ListPlot[punishMeans,          Joined -> False, PlotStyle -> Gray, PlotMarkers -> Automatic,           PlotRange -> {{0, n}, {(1 - zoom)*#, (1 + zoom)*#} &[Mean[data]]},          Frame -> True, Axes -> None,          Epilog -> {Blue, Line[{{0, Mean[data]}, {n, Mean[data]}}]}],         ListPlot[honestMeans,          Joined -> True, PlotStyle -> Black, PlotMarkers -> None]         ],        Show[         Histogram[data, scale, PlotRange -> {{0, scale + 1}, All},           Frame -> True,          FrameTicks -> {{Automatic,              Automatic}, {{# + .5, #, 0} & /@ Range[0, scale], None}},           Axes -> None],         DiscretePlot[n*PDF[dist, x], {x, 0, scale + 1}, Joined -> True,           PlotMarkers -> None, Filling -> None]         ]        }],      {{n, 100}, 10, 5000},      {{punish, 0.5}, 0, 1},      Delimiter,      {{zoom, 0.2}, .1, .5},      TrackedSymbols :> {n, punish, zoom}]      Is there a way to do this kind of selective update of elements of a `Manipulate`?


Using Assumptions with Solve

Suppose i have a function defined as follows -               f[x_] := E^-x - E^(-2 x);      I want to find the max/min hence need to find when f'[x]==0. So i tried the following -               Solve[f'[x] == 0, x]          {{x -> ConditionalExpression[2 I \[Pi] C[1] + Log[2],          C[1] \[Element] Integers]}}      Now if i assume x is real then i can do the following -               Solve[f'[x] == 0, x, Reals]     {{x -> Log[2]}}      However when i tried the following -               Assuming[x \[Element] Reals, Solve[f'[x] == 0, x]]     {{x -> ConditionalExpression[2 I \[Pi] C[1] + Log[2],          C[1] \[Element] Integers]}}      Why does Assuming not give me same answer as above ? David.


Can I adjust starting point when using ListPlot?

`RandomInteger[3,3]` produces a vector of length-3 randomly. But it counts index from 1. I need a vector, index of which starts from 0. Because of this, when plotting it, my x-axis starts from 1. Look at the following.               ListPlot[RandomInteger[3, 3]]      So I've searched HELP about this, and I found the option about `AxesOrigin`. I tried out the following.               ListPlot[RandomInteger[3, 3], AxesOrigin -> {1, 0}]      Look at the values of the axis. It's just shifting the axis without adjusting index of the vector. It is starting from 1 still. **How can I count my vectors from the index of 0?**


How can I completely remove the ListAnimate controls?

I want to use `ListAnimate` to show an animation but I want to remove the slider and all of the buttons from the top and show the animation panel only. There is an `AppearanceElements -> None` option but it doesn't remove the slider and the other buttons. How can I remove all of the controls?


Cases Message Valid Notebook Structure

**Note: Spelunking will likely be needed.** Execute the following. You should get back and error along the lines of `First::first:..`. This error is unimportant except it helps illustrate a potential issue with `Cases` internal code.               Print[Button["Print Cell",        Cell[BoxData[          ToBoxes@           First@Cases[NotebookGet[EvaluationNotebook[]][[1]],              Cell[___, CellTags -> "MyCode", ___]]          ], "Input", CellTags -> "MyGraphic"]        ]       ];     CellPrint@       Cell[BoxData[         ToBoxes[Cases[NotebookGet[EvaluationNotebook[]],            Cell[___, CellTags -> "MyGraphic", ___], Infinity], StandardForm]         ], "Output", CellTags -> "MyCode"];      Now ultimately although the notebook is outputting an error the Notebook itself should have a valid structure, considering the notebook can be saved and duplicated like so `NotebookPut@NotebookGet[EvaluationNotebook[]]`. Interestingly if execute the following code in the same `Notebook`.               Cases[NotebookGet[EvaluationNotebook[]]      , Cell[__, CellTags -> "MyGraphic"], Infinity]      `Cases` return the appropriate values and you get back a `First::first` error. My question: **Why does`Cases` return a message from a perfectly valid `Notebook` structure. Other then using `Quiet` to suppress an error, how might I solve such a problem?**


Insert a Quantity Unit literal in TraditionalForm

Is there a keyboard shortcut for creating something like the result of this:               Quantity["Kilograms" * ("Meters")^2 / ("Seconds")^2]      After copying the result to a `TraditionalForm` field it looks like this (line 3): ![enter image description here](http://i.stack.imgur.com/mcvNo.png) Is there a shortcut for creating something like this in `TradionalForm` without having to type `Quantity[..., ...]` directly?


Why don't rules applied inside ContourPlot3D work?

The output of the following code is the same as the input.               waals = (P + a/V^2) (V - b) == R T;          ContourPlot3D[waals /. {a -> 1, b -> 1, R -> 1},      {P, 0, 100}, {V, 0, 100}, {T, 0, 100}]      But               ContourPlot3D[(P + 1/V^2) (-1 + V) == T,      {P, 0, 100}, {V, 0, 100}, {T, 0, 100}]      works fine. What's wrong? Do I have to specify all the parameters in the equation?


How to extract RGB arguments as a list

Although the following lines of code work fine they are very awkward. My questions are below               a = RGBColor[1, 0, 0]     b = RGBColor[0, 1, 0]      Is there a more compact way to construct ab? Can the three entries of `RGBColor[u,v,w]` be extracted as a list? Can the RGBColor argument be entered as a list RGB[{list}]?               ab = RGBColor[a[[1]] + b[[1]], a[[2]] + b[[2]], a[[3]] + b[[3]]]     Graphics[{{a, Disk[{0, .5}, .5]}, {b, Disk[{.25, .5}, .5]}, {ab,         Disk[{.5, .5}, .5]}}]


How to use Mathematica to turn a picture into low poly style?

I want to use _Mathematica_ to turn a picture into low poly style. That is, to make the following conversion: Bill to Bill low poly(Using Image Triangulator App). I think the biggest difficulty is how to extract the points on the boundaries of different colors appropriately. Too much points make the output picture messy, while the picture generated by too little points are not beautiful. And then, after I have extract the points of the original picture, how to turn the original picture to the low poly style? Is using `DelaunayMesh` possible? Or, extract the color of a certain point in a triangle(using `ImageValue` or some functions similar) and make it to be the main color of the triangle? **Edit** : No, I don't think that the answers in artistic image vectorization fit my problem. Because you can see that the question is not using Delaunay mesh or other triangular mesh.


How to format usage messages such that function templates are parsed correctly?

Is it possible to format usage messages (with italic arguments etc) such that Mathematica 9 still parses function templates correctly? For example, plain usage messages work when pressing `Ctrl`+`Shift`+`K`: ![enter image description here](http://i.stack.imgur.com/MEiwC.png) But formatted ones don't: ![enter image description here](http://i.stack.imgur.com/P0EZX.png) Note that this does work correctly on Mathematica 8, so I guess this is a bug on Mathematica 9.0.1. Nonetheless, is there a workaround?


How can I make a notebook with two column layout? Is it possible? I saw something tools could do such thing? Author Tools?


Manipulate executes expressions multiple times

I am using `Manipulate` for a rather intricate front end for data visualization. I was getting very sluggish performance and was able to boil the problem down to a very similar question (Why does Manipulate execute the expression twice?). The suggestions of using _ContinuousAction->False_ and _TrackedSymbols_ does not seem to work in this case. Let's simplify the problem by producing a simple array of numbers and mapping a simple function through them. The array of numbers needs to change dynamically, here we just change the length based on a manipulation parameter, `i`:               manipulateSlow[] := Module[{data, updated},       Manipulate[         Print[i];         data = RandomReal[{0, 1}, 100*i];         updated = Map[Sin, data];       , {i, {1, 2, 3}}]]          manipulateFast[] := Module[{updated},       Manipulate[         Print[i];         updated = Map[Sin, RandomReal[{0, 1}, 100*i]];       , {i, {1, 2, 3}}]]      When one plays with the parameter `i` in `manipulateSlow`               manipulateSlow[]      the code internal to Manipulate is called multiple times. This is in contrast to `manipulateFast`               manipulateFast[]      where when fiddling with the parameter `i` the code internal to `Manipulate` is only called once per manipulation. This example is, of course, just a toy. In my real application the process of `RamdomReal` is replaced by a much slower data reading function. Calling it multiple times is not an option. **EDIT** : I lied when previously saying that `TrackedSymbols` does not work. The follow fixes the issue of multiple `Print` evaluations.               manipulateFixed[] := Module[{data, updated},       Manipulate[         Print[i];         data = RandomReal[{0, 1}, 100*i];         updated = Map[Sin, data];       , {i, {1, 2, 3}},TrackedSymbols :> {i}]]      I must be confused about how `TrackedSymbols` changes the evaluation process. What is happening inside of `manipulateFast` that **does not** cause the evaluation to occur twice?