Power series with decimal and arbitrary powers

Is there a way to make Mathematica do a series of the form:                Series[ E^{\beta}$ , {x, 0, 1}]      I have noticed that                Series[E^x^(1/2), {x, 0, 1}]      work but                Series[E^x^(.5), {x, 0, 1}]      does not. Thanks for the help. EDIT: I have tried things like                 Assuming[{\bet>0},Series[ E^{\beta}$ , {x, 0, 1}]]      which hasn't helped.


I'm re-implementing some tools previously implemented in Java in Wolfram Language. Is there any metadata-holding mechanisms in Mathematica programming similar to Java annotations?


iterating piecewise linear maps on [0,1]

I have been trying to make code work for iterating piecewise linear maps on the unit interval in Mathematica to compare with MATLAB and Maple. Tent and logistic maps are easy to implement but Bernoulli and other non-traditional maps have been difficult (at least for me). I wish to investigate histograms of the invariant densities of map iterations for non periodic orbits.


Histogram of runs

What I would like to do is generate a histogram of the consecutive time spent under a level. For example if the level I was interested in was 1.0 and I had this data;               {{{2010, 1, 1, 6, 15, 0.}, 0.04375}, {{2010, 1, 1, 6, 30, 0.},0.04375},      {{2010, 1, 1, 6, 45, 0.},0.04375}, {{2010, 1, 1, 7, 0, 0.},5},     {{2010, 1, 1, 7, 15, 0.}, 0.5},{2010, 1, 1, 7, 30, 0.}, 5}}}      I would get a histogram containing two values, 45 (7:00am - 6:15am) and 15 (7:30am - 7:15am) minutes. Any help would be appreciated.


NIntegrate Error-Estimate Question

When I do some complicated 4-dimensional integral numerically, _Mathematica_ tells me its estimate for the value of the integral, and its estimate for the value of the error in the calculation. The integrand:               Integrand[x_, y_, z_, Ekb_] := Sqrt[-4.14195`*^-29 +1.38065`*^-29 Ekb + (1.7055100000000003`*^-29 2.71828`^(-((2.76817`*^8 ((0.986286` x + 0.165048` y)^2 + z^2))/(1.` + 4707.27` (-0.165048` x + 0.986286` y)^2))))/(1.` + 4707.27` (-0.165048` x +0.986286` y)^2) + (2.4364400000000005`*^-29 2.71828`^(-((2.76817`*^8 ((0.986286` x -0.165048` y)^2 + z^2))/(1.` + 4707.27` (0.165048` x + 0.986286` y)^2))))/(1.` + 4707.27`(0.165048` x + 0.986286` y)^2)]/(1.` + 2.71828`^(7.2429699999999995`*^28 (-2.7613`*^-29 + 1.38065`*^-29 Ekb)))      The Integration:               Re@NIntegrate[Integrand[x,y,z,Ekb],{x,-9.53853 10^(-5),9.53853 10^(-5)},{y,-57 10^(-5),57 10^(-5)},{z,-4.37824 10^(-5),4.37824 10^(-5)},{Ekb,0,7*3/17},Method ->     {"GlobalAdaptive", Method -> "MultiDimensionalRule", "MaxErrorIncreases" -> 100}]      It puts out the error message: > NIntegrate::eincr: The global error of the strategy GlobalAdaptive has > increased more than 100 times. The global error is expected to decrease > monotonically after a number of integrand evaluations. Suspect one of the > following: the working precision is insufficient for the specified precision > goal; the integrand is highly oscillatory or it is not a (piecewise) smooth > function; or the true value of the integral is 0. Increasing the value of > the GlobalAdaptive option MaxErrorIncreases might lead to a convergent > numerical integration. NIntegrate obtained 1.51764*10^-27+7.31069*10^-26 I > and 1.0039003041591675`*^-28 for the integral and error estimates. >> Should this be interpreted as (1.51764*10^-27+7.31069*10^-26 I) ± 1.0039003041591675`*^-28,   or   (1.51764*10^-27+7.31069*10^-26 I) ± 5.0195*10^-29 ?


What are the differences between library call back functions and WolframCompileLibrary macros?

I'm trying to use LibraryLink in Mathematica, and come across some problems. Consider if we have a `MTensor m1` which contains a one dimensional double array, and I want to get the data of that array. I come across two methods. One is to use library callback functions `libData->MTensor_getRealData(m1)` as shown here , the other is use the micros `MTensor_getRealDataMacro(m1)` in the `WolframCompileLibrary.h file` as shown here. What are the differences between them? Does the library call back functions are slower then the macro since they need to "call back" to Mathematica?


Establish connection with RLink and Rtools

Has anyone gotten _RLink_ to work with _Rtools_ (or even tried)? If so a simple step-by-step would be much appreciated ! When attempting to access any _Rtools_ functionality through _RLink_ I get: > The following R error was encountered: Error in system(cmd, intern = \ > !verbose) : 'C:/Program' not found Background: I'm trying to get data in and out of the _RStan_ package with _Mathematica_ (mostly because _Mathematica_ is the program I've used most for manipulating data and the more I can do in _Mathematica_ the less time I'll have to spend learning how to manipulate the data in _R_ ) and _Rtools_ is required for _RStan_. Thanks for the responses- Some new info in response to the comments: I installed R 2.15.3 (since version 3 doesn't work with RLink in Windows yet) Then:               InstallR["RHomeLocation" -> "C:\\Program Files\\R\\R-2.15.3"]      And that works for the basic RLink functionality. Through the R command line, I got the required packages installed. Then restart Mathematica, and check to make sure the packages are installed (which they are) and accessible - at least at the level that `REvaluate["library(Rcpp)"]` and `REvaluate["library(rstan)"]` both seem to work - returning a list of the loaded libraries. But then either running the "hello world" example from https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started or trying to use any of the rstan commands results in the above error. Any further thoughts?


Creating simple table

How do I create a table like this? I find it very hard to create the zero-row and zero-column. ![The table](http://i.stack.imgur.com/ySDiv.png) Edit: I am looking for a solution where a formula eg. Table or something else is being used. I can already create the table manually.


How to declare a function that uses local variables of a module outside this module?

I have the following code               Module[{f,x=0},     f[t_] := x + t;     ..........;     ...f[1]...;     ..........;     ]      My aim is to put the declaration of the function `f` outside the module.


Inverting a function in a certain region

`InverseFunction` works well for globally invertible functions, like               f = 2*# + 2 &;     InverseFunction[f]      > >     1/2 (-2 + #1) & >   However, how would one for example find the inverse of $f(x)=x^2$ around $(x,f(x))=(1,1)$? My _Mathematica (8.0.4)_ gives me a warning about multivalued inverses in this case, as well as the result $-\sqrt{x}$, which is not the branch that I'm looking for:               f = #^2 &     InverseFunction[f]      > >     #1^2 & >   >     InverseFunction::ifun: >       Inverse functions are being used. Values may be lost for multivalued > inverses. >> >   >     -Sqrt[#1] & >   So: How can I specify the neighbourhood a function should be inverted on?


Finding the InverseFunction of a polynomial function restricted to an interval

I want to calculate the inverse of               f[x_] := 1/2 - (x (4 x^2 - 9))/12 /; -1/2 <= x <= 1/2      `f[x]` is monotonic inside $-0.5 < x <= 0.5$, but I don't know how to calculate its inverse.


Maximum of NDSolve output. Problem with interpolating function

I solve a NonLinear PDE and get a solution (which for other reasons I put into a vector): SolVec1[1][[2]][x,t], where x and t are the indipendent variables. Now, I would like to get a distribution of the maximum of the solution vs time. I tried two different things, but the most intuitive and quick doesn't work. 1) A For loop to fill the function of the maxima >>> works but takes very long.               For[it = 0, it <= T, it++,             MAX1[it] = First[Maximize[SolVec1[[1]][[2]][x, it], 0 <= x <= L , x]];           ]      2) Defining a function MAX1[t] of time, and then plot it >>> doesn't work.               MAX1[t_] := First[Maximize[SolVec1[[1]][[2]][x, t],      0 <= x <= L , x]];           Plot[Evaluate[MAX1[t]], {t, 0, T}, PlotRange -> All,       AxesLabel -> {"t", "Max[\[Theta]]"}, Frame -> True,       PlotLabel -> "Max[\[Theta]](t), A=0"]          NMaximize::nnum: The function value -InterpolatingFunction[{{0.,10.},{0.,15.}},{3,10,1,     {25,228},{6,4},0,0,0,0},<<1>>,{Developer`PackedArrayForm,{<<1>>},{<<1>>}},     {Automatic,Automatic}][<<1>>] is not a number at {x} = {6.52468}. >>      Edit: SolVec1[1][[2]] is the solution coming out from a call of NDSolve.               u[\[Lambda]_, \[Omega]_, v_, \[Alpha]a_, aa_, A_] = -(1/(1 + \[Lambda]^2*(aa + A E ^-\[Phi][x, t])*Sin[2*\[Theta][x, t]]^2))*((aa + A E ^-\[Phi][x, t])*\[Lambda]*\[Omega]*\!\(\*SuperscriptBox["\[Theta]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[x, t]^2*Sin[2*\[Theta][x, t]]*      Sin[\[Theta][x, t]]^2 -       2*(aa + A E ^-\[Phi][x, t])*v*\[Phi][x, t]^2*\!\(\*SuperscriptBox["\[Theta]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[x, t]*      Sin[\[Theta][x, t]] + (aa +          A E ^-\[Phi][x, t])*\[Alpha]a*\[Phi][x, t]^2*       Sin[2*\[Theta][x, t]] + \!\(\*SuperscriptBox["\[Phi]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[x, t]*      Cos[\[Theta][x,          t]]*(\[Omega] - \[Lambda]*\[Omega]*Cos[2*\[Theta][x, t]]));               eqn1[\[Lambda]_, w_, v_, \[Alpha]a_, a_, A_] := \!\(\*SubscriptBox[\(\[PartialD]\), \(t\)]\ \(\[Theta][x, t]\)\) - (\!\(\*SuperscriptBox["\[Theta]", TagBox[RowBox[{"(", RowBox[{"2", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[x,        t] (1 - w Cos[\[Theta][x, t]]^2) (a + A E^\[Phi][x, t]) +      1/2*(a + A E^\[Phi][x, t]) w \!\(\*SuperscriptBox["\[Theta]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[x, t]^2 Sin[2 \[Theta][x, t]] - \[Phi][x,        t] (a + A E^-\[Phi][x, t]) v \!\(\*SuperscriptBox["\[Theta]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[x, t] Sin[\[Theta][x, t]] -      u[\[Lambda], w, v, \[Alpha]a, a,        A] (1 - \[Lambda] Cos[2 \[Theta][x, t]]) + (a +         A E^\[Phi][x, t]) w \!\(\*SuperscriptBox["\[Phi]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[x, t] Cos[\[Theta][x, t]]);               eqn2[\[Lambda]_, w_, v_, \[Alpha]a_, a_, A_] := \!\(\*SubscriptBox[\(\[PartialD]\), (t\)]\ \(\[Phi][x, t]\)\) - \!\(\*SubscriptBox[\(\[PartialD]\), \(x\)]\ \((v \((a +\*StyleBox["A",FontSize->10]\*StyleBox[" ",FontSize->10]\*SuperscriptBox[StyleBox["E",FontSize->10], RowBox[{"-", RowBox[{"\[Phi]", "[", RowBox[{"x", ",", "t"}], "]"}]}]])\) SuperscriptBox[\(\[Phi][x, t]\), \(2\)] Sin[\[Theta][x,          t]] + \((DD \((1 - \[Xi]\ \*SuperscriptBox[\(Sin[\[Theta][x, t]]\), \(2\)])\) - w\ \*SuperscriptBox[\(Cos[\[Theta][x, t]]\), \(2\)])\)\ *\((a + \*StyleBox["A",FontSize->10]\*StyleBox[" ",FontSize->10]\*SuperscriptBox[StyleBox["E",FontSize->10], RowBox[{"\[Phi]", "[", RowBox[{"x", ",", "t"}], "]"}]])\)*\ \*SuperscriptBox["\[Phi]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None][x, t] + \[Lambda]\ u[\[Lambda], w,         v, \[Alpha]a, a, A]\ Sin[\[Theta][x, t]]\ Sin[        2\ \[Theta][x, t]])\)\);                     sol1 = {\[Theta], \[Phi]} /. First[NDSolve[{       eqn1[\[Lambda], w, \[Beta], \[Alpha]j, 1, 0] == 0,       eqn2[\[Lambda], w, \[Beta], \[Alpha]j, 1, 0] == 0,       \[Theta][0, t] == 0,       \[Theta][L, t] == 0,       \[Theta][x, 0] == First[InitialMode[x, 1, 0.5]],          \!\(\*SuperscriptBox["\[Phi]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[0, t] == 0,          \!\(\*SuperscriptBox["\[Phi]", TagBox[RowBox[{"(", RowBox[{"1", ",", "0"}], ")"}],Derivative],MultilineFunction->None]\)[L, t] == 0,       \[Phi][x, 0] == Last[InitialMode[x, 1, 0.5]]},      {\[Theta], \[Phi]}, {x, 0,        L}, {t, 0, T}, AccuracyGoal -> 4, PrecisionGoal -> 5]] ;          SolVec1[[i]] = {sol1[[1]], sol1[[2]]};      Plotting at the point ($x\simeq6.525$), nothing special happens:                In[124]:= Plot[SolVec1[[1]][[2]][6.5246780797402835`, t], {t, 0, T}, PlotRange ->All]      ![enter image description here](http://i.stack.imgur.com/lpoXV.png)


Questions regarding DictionaryLookup of Mathematica

**a.** Make a function `longest[lang_]` that gives the length of the longest word in the dictionary of lang. You should get `longest["French"]=25` For this part, I have `lang = DictionaryLookup[All];`   `longest[lang_] := Max[StringLength[lang]]` But this isn't working. **b.** Now give a list with entries `{language,longest[language]}`. `Table[{lang[[i]], Length[DictionaryLookup[{lang[[i]], All}]]}, {i, 1, Length[lang]}]` Again not working **c.** Make a function `lonegestwords[lang_]` that gives the output `{longest[lang],lang,longwords}` where `longwords` is the list of the words of longest length in lang. I tried `longestwords[lang_] := {longest[lang], lang, Select[DictionaryLookup[{lang, All}], StringLength[#] == longest[lang] &]}` **d.** Now get the list with entries `longestwords[lang]` for all languages and sort it in descending order by the longest word. I know that I have to use `Sort[longestwords[lang],#2[[1]]<#1[[1]]&]` But since I don't have the function, I can't do it.


Rotating perspective of an image in the z axis

A purely recreational question, but one I hoped the community would find interesting enough to suggest a way to approach it. Let me preface this question with the admission that I have done nothing to date with Mathematica's image processing or any other program's image processing. I don't even take photos. I have an photo of a wall mural: ![mural](http://i.stack.imgur.com/DOGOB.jpg) taken at an angle of approximately 40 degrees to its center. The mural no longer exists so I can't rephotograph it. I'd like to process this image so that I would get an image as if I had a perspective perpendicular to the center (or approximate center) of the mural. One could think of it as say anchoring the right edge of the image and then pulling the left edge forward. Or think of it as the plane of the white wall having an x and y axis with the origin at the center of the image, then I want to rotate the image in the z axis. I've reviewed Mathematica's image processing functions. I hoped I'd find an obvious way to do this, perhaps using the Morphological Analysis capabilities, but everything appears 2D oriented. I recognize the difficulty of the problem. Rotating the perspective would require everything to the left of the y axis to enlarge relative to its distance from the y axis while simultaneously doing the inverse to the right of the axis. 3D plots do this inherently, which is why I thought one ought to be able to do this. `ImageData[] and RotationTransform[]` seem likely candidates to do this. The documentation show how to create a `TransformationFunction[]`: ![enter image description here](http://i.stack.imgur.com/wCkBd.png) The ideas to do this exist, but I haven't found an example of this applied to an image in the way I want to do it. In the end, I only want the colors of the mural on a white background, like a poster image, I don't need the lighting or the floor or gradations of color. Solid colors for each of the elements would work fine. Doing these things seems relatively straightforward and should reduce the size of a raster file or the amount of data one needs to process and move around. Can anyone direct me towards any examples or even documentation on how to approach this? P.S., Can everyone see the wolf in the mural? * * * I wanted to show what I got to with Vitaliy Kaurov's solution:                t = FindGeometricTransform[{{1924.19`, 880.846`}, {154.761`,           1200.69`}, {190.872`, 189.582`}, {1893.24`,           297.914`}}, {{1924.19`, 880.846`}, {175.395`,           1283.22`}, {175.395`, 571.325`}, {1893.24`, 297.914`}},         "Transformation" -> "Perspective"];          ImagePerspectiveTransformation[image, t[[2]], 1000, DataRange -> Full,        PlotRange -> All];     ImageTake[%, {100, 480}, {120, 965}];     ImageAdjust[Lighter[Lighter[%]], 0.85]      ![enter image description here](http://i.stack.imgur.com/7dJw6.png) This gets me closer to what I hoped than I imagined possible. Given that the original artist constructed the mural as a collage from rectangular sheets of paper, most of which have gone trapezoidalish I still need to twist the image to restore some of what original photo and image processing has skewed. If I figure it out in a reasonable time I'll post the final image. Thanks to all.


How to extract a variable names (not values) from a list of transformation rules?

I am trying to extract variable names from a list of transformation rules `mapping = {var1 -> 'val1', var2 -> 'val2' }`. Variables `var1` and `var2` are already defined in my notebook: ` var1 = 'init-val1'; var2 = 'init-val2'; ` When I try to evaluate `Extract[mapping, {1,1}, HoldForm]`, I get `'init- val1'`, instead of `var1`. What am I doing wrong? Why is `var1` getting evaluated despite the explicit `HoldForm` wrapper? How can I fix the problem?


Why does Mathematica use [[ ]] notation for array indexing?

I am confused by why _Mathematica_ uses `[[3]]` to get the 3rd element, or `[[i,j]` to get the i,j-th element of a 2D array. This seems counter-intuitive. Is this main reason for this to separate array- indexing from function calls? i.e. where I see:               f[3, 4] <-- this is currently function call     f[[3, 4]] <-- f is a 2D array, and we're accessing 3,4-th element      **Question** : Given that Mathematica knows the type of the arguments, can't it infer:   * if we're dealing with a function, apply arguments   * if the object is an array, index it? Thus, why do we need separate `[[ ]]` notation for array indexing?


Convex optimization

I am playing with some Compressed Sensing (think single pixel camera) applications and would like to have a Mathematica equivalent of a Matlab package call Convex Optimization (CVX). Specifically, I am solving an underdetermined, constrained, L1Norm minimization problem. I have been using NMinimize, but it very slow compared to the Matlab code written by a colleague. I don’t want to give him the pleasure of thinking Matlab is superior. I am sure that the long run times are due to my poor programing skills. The solution is sparse but I do not know how to add that as an additional constraint. Anyway, seems I can’t find a good reference for compressed sensing in Mathematica. Any suggestions would be great!


Optimizing a rank 3 tensor

Assume we have the following elements \begin{equation} F_i{}^j \;and\; S_{ij}{}^k, \end{equation} which represent the components of tensorial objects of ranks 2 and 3 respectively, with Complex coefficients. Let the components of $F$ be given by $F_1{}^j$ = \begin{matrix} 0 \\\ -x-iy \\\ -i(-1+x^2+2ixy-y^2+z^2)/2z \\\ (1-x^2-2ixy+y^2+z^2)/2z \end{matrix} $F_2{}^j$ = \begin{matrix} x+iy \\\ 0\\\ (1-x^2-2ixy+y^2+z^2)/2z\\\ i(-1+x^2+2ixy-y^2+z^2)/2z \end{matrix} $F_3{}^j$ = \begin{matrix} i(-1+x^2+2ixy-y^2+z^2)/2z\\\ -(1-x^2-2ixy+y^2+z^2)/2z \\\ 0\\\ -x-iy \end{matrix} $F_4{}^j$ = \begin{matrix} -(1-x^2-2ixy+y^2+z^2)/2z\\\ -i(-1+x^2+2ixy-y^2+z^2)/2z\\\ x+iy\\\ 0 \end{matrix} ($j=1,2,3,4$). We would like to solve for the components of $S$ if they satisfy the following equation \begin{equation} S_{li}{}^jF_k{}^l-S_{lk}{}^jF_i{}^l=0, \end{equation} where $l$ is summed over, all the indices run from 1 to 4, and $S$ is symmetric in the lower indices. Would it be possible to write a code that find the components of $S$? The code provided in my previous question Solving antisymmetric tensorial equation would work well for simple examples of $F$, but not for the example we have here.


Replace values of a list containing words and numbers

I'm trying to import some data in a .txt file which contains numbers and words. I import a list which consists of four rows of measured data acquired with an oscilloscope, but the acquisition program puts units in every measured value. Here's an example:               data={{-1.1000u s,-120.00m V,-1.1000u s,8.0000 V},           {-1.0800u s,-120.00m V,-1.0800u s,8.0000 V},           {-60.000n s,-40.000m V,-60.000n s,8.0000 V},           {-40.000n s,-40.000m V,-40.000n s,8.0000 V},           {-20.000n s,-32.000m V,-20.000n s,8.0000 V},           {0.0000 s,-32.000m V,0.0000 s,8.0000 V}}      I would like to know if there's any way I can turn the above list into something more like this:               newdata={{-1.1000,-0.12000,-1.1000,8.0000},              {-0.060000,-0.040000,-0.060000,8.0000},              {-0.040000,-0.040.000,-0.040000,8.0000},              {-0.020000,-0.032000,-0.020.000,8.0000},              {0.0000,-0.032000,0.0000,8.0000}}      I'll appreciate any ideas. Thanks.


How to make Eigensystem in version 10 produce the same results as version 9

The Eigensystem in version 10 seems to give slightly different results as in version 9:               Hmtx={{12.375, -0.06250000000000006 - 8.834874115176436*^-18*I, -1.1548235516929313*^-17 - 4.417437057588218*^-18*I, 7.507272729062478*^-19 + 2.4295903816735198*^-17*I, 3.5296840598063115*^-17 - 4.417437057588218*^-18*I, 6.284659706684547*^-19 - 2.6504622345529306*^-17*I, -1.2338675571278232*^-17 - 2.208718528794109*^-18*I, -4.6634340043469916*^-18 - 1.1043592643970545*^-18*I, 5.9846202809437726*^-18 - 1.8774107494749925*^-17*I, -5.0917886236526596*^-17 - 3.6443855725102797*^-17*I, -1.7364763179227213*^-17 + 5.2457065058860084*^-17*I}, {-0.06250000000000006 + 8.834874115176436*^-18*I, 7.875, -0.06250000000000006 - 8.834874115176436*^-18*I, -1.1548235516929313*^-17 - 4.417437057588218*^-18*I, 7.507272729062478*^-19 + 2.4295903816735198*^-17*I, 3.5296840598063115*^-17 - 4.417437057588218*^-18*I, 6.284659706684547*^-19 - 2.6504622345529306*^-17*I, -1.2338675571278232*^-17 - 2.208718528794109*^-18*I, -4.6634340043469916*^-18 - 1.1043592643970545*^-18*I, 5.9846202809437726*^-18 - 1.8774107494749925*^-17*I, -5.0917886236526596*^-17 - 3.6443855725102797*^-17*I}, {-1.1548235516929313*^-17 + 4.417437057588218*^-18*I, -0.06250000000000006 + 8.834874115176436*^-18*I, 4.375, -0.06250000000000006 - 8.834874115176436*^-18*I, -1.1548235516929313*^-17 - 4.417437057588218*^-18*I, 7.507272729062478*^-19 + 2.4295903816735198*^-17*I, 3.5296840598063115*^-17 - 4.417437057588218*^-18*I, 6.284659706684547*^-19 - 2.6504622345529306*^-17*I, -1.2338675571278232*^-17 - 2.208718528794109*^-18*I, -4.6634340043469916*^-18 - 1.1043592643970545*^-18*I, 5.9846202809437726*^-18 - 1.8774107494749925*^-17*I}, {7.507272729062478*^-19 - 2.4295903816735198*^-17*I, -1.1548235516929313*^-17 + 4.417437057588218*^-18*I, -0.06250000000000006 + 8.834874115176436*^-18*I, 1.8749999999999998, -0.06250000000000006 - 8.834874115176436*^-18*I, -1.1548235516929313*^-17 - 4.417437057588218*^-18*I, 7.507272729062478*^-19 + 2.4295903816735198*^-17*I, 3.5296840598063115*^-17 - 4.417437057588218*^-18*I, 6.284659706684547*^-19 - 2.6504622345529306*^-17*I, -1.2338675571278232*^-17 - 2.208718528794109*^-18*I, -4.6634340043469916*^-18 - 1.1043592643970545*^-18*I}, {3.5296840598063115*^-17 + 4.417437057588218*^-18*I, 7.507272729062478*^-19 - 2.4295903816735198*^-17*I, -1.1548235516929313*^-17 + 4.417437057588218*^-18*I, -0.06250000000000006 + 8.834874115176436*^-18*I, 0.3749999999999999, -0.06250000000000006 - 8.834874115176436*^-18*I, -1.1548235516929313*^-17 - 4.417437057588218*^-18*I, 7.507272729062478*^-19 + 2.4295903816735198*^-17*I, 3.5296840598063115*^-17 - 4.417437057588218*^-18*I, 6.284659706684547*^-19 - 2.6504622345529306*^-17*I, -1.2338675571278232*^-17 - 2.208718528794109*^-18*I}, {6.284659706684547*^-19 + 2.6504622345529306*^-17*I, 3.5296840598063115*^-17 + 4.417437057588218*^-18*I, 7.507272729062478*^-19 - 2.4295903816735198*^-17*I, -1.1548235516929313*^-17 + 4.417437057588218*^-18*I, -0.06250000000000006 + 8.834874115176436*^-18*I, -0.12500000000000014, -0.06250000000000006 - 8.834874115176436*^-18*I, -1.1548235516929313*^-17 - 4.417437057588218*^-18*I, 7.507272729062478*^-19 + 2.4295903816735198*^-17*I, 3.5296840598063115*^-17 - 4.417437057588218*^-18*I, 6.284659706684547*^-19 - 2.6504622345529306*^-17*I}, {-1.2338675571278232*^-17 + 2.208718528794109*^-18*I, 6.284659706684547*^-19 + 2.6504622345529306*^-17*I, 3.5296840598063115*^-17 + 4.417437057588218*^-18*I, 7.507272729062478*^-19 - 2.4295903816735198*^-17*I, -1.1548235516929313*^-17 + 4.417437057588218*^-18*I, -0.06250000000000006 + 8.834874115176436*^-18*I, 0.3749999999999999, -0.06250000000000006 - 8.834874115176436*^-18*I, -1.1548235516929313*^-17 - 4.417437057588218*^-18*I, 7.507272729062478*^-19 + 2.4295903816735198*^-17*I, 3.5296840598063115*^-17 - 4.417437057588218*^-18*I}, {-4.6634340043469916*^-18 + 1.1043592643970545*^-18*I, -1.2338675571278232*^-17 + 2.208718528794109*^-18*I, 6.284659706684547*^-19 + 2.6504622345529306*^-17*I, 3.5296840598063115*^-17 + 4.417437057588218*^-18*I, 7.507272729062478*^-19 - 2.4295903816735198*^-17*I, -1.1548235516929313*^-17 + 4.417437057588218*^-18*I, -0.06250000000000006 + 8.834874115176436*^-18*I, 1.8749999999999998, -0.06250000000000006 - 8.834874115176436*^-18*I, -1.1548235516929313*^-17 - 4.417437057588218*^-18*I, 7.507272729062478*^-19 + 2.4295903816735198*^-17*I}, {5.9846202809437726*^-18 + 1.8774107494749925*^-17*I, -4.6634340043469916*^-18 + 1.1043592643970545*^-18*I, -1.2338675571278232*^-17 + 2.208718528794109*^-18*I, 6.284659706684547*^-19 + 2.6504622345529306*^-17*I, 3.5296840598063115*^-17 + 4.417437057588218*^-18*I, 7.507272729062478*^-19 - 2.4295903816735198*^-17*I, -1.1548235516929313*^-17 + 4.417437057588218*^-18*I, -0.06250000000000006 + 8.834874115176436*^-18*I, 4.375, -0.06250000000000006 - 8.834874115176436*^-18*I, -1.1548235516929313*^-17 - 4.417437057588218*^-18*I}, {-5.0917886236526596*^-17 + 3.6443855725102797*^-17*I, 5.9846202809437726*^-18 + 1.8774107494749925*^-17*I, -4.6634340043469916*^-18 + 1.1043592643970545*^-18*I, -1.2338675571278232*^-17 + 2.208718528794109*^-18*I, 6.284659706684547*^-19 + 2.6504622345529306*^-17*I, 3.5296840598063115*^-17 + 4.417437057588218*^-18*I, 7.507272729062478*^-19 - 2.4295903816735198*^-17*I, -1.1548235516929313*^-17 + 4.417437057588218*^-18*I, -0.06250000000000006 + 8.834874115176436*^-18*I, 7.875, -0.06250000000000006 - 8.834874115176436*^-18*I}, {-1.7364763179227213*^-17 - 5.2457065058860084*^-17*I, -5.0917886236526596*^-17 + 3.6443855725102797*^-17*I, 5.9846202809437726*^-18 + 1.8774107494749925*^-17*I, -4.6634340043469916*^-18 + 1.1043592643970545*^-18*I, -1.2338675571278232*^-17 + 2.208718528794109*^-18*I, 6.284659706684547*^-19 + 2.6504622345529306*^-17*I, 3.5296840598063115*^-17 + 4.417437057588218*^-18*I, 7.507272729062478*^-19 - 2.4295903816735198*^-17*I, -1.1548235516929313*^-17 + 4.417437057588218*^-18*I, -0.06250000000000006 + 8.834874115176436*^-18*I, 12.375}};          {vals, vecs} = Eigensystem[Hmtx];     vals     vecs[[1]]      in version 9 I get: eigenvalue               (*     {12.3759, 12.3759, 7.87525, 7.87525, 4.37545, 4.37545, 1.87605, 1.87604, 0.387613, 0.372399, -0.140221}     *)      first eigenvector               (*     {-0.000534641 + 0.00179264 I, 7.42495*10^-6 - 0.0000248957 I, -5.80038*10^-8 + 1.94486*10^-7 I,  3.45242*10^-10 - 1.15759*10^-9 I, -1.71049*10^-12 +  6.02886*10^-12 I, -1.68042*10^-11 - 3.01451*10^-14 I,  3.36278*10^-9 + 1.56589*10^-16 I, -6.45683*10^-7 + 1.38957*10^-18 I, 0.00010848 - 5.32021*10^-19 I, -0.0138864 -  1.97975*10^-18 I, 0.999902}     *)      in version 10 I get: eigenvalue               (*     {12.3759 - 1.02031*10^-15 I, 12.3759 - 9.91618*10^-29 I, 7.87525 - 8.85813*10^-16 I, 7.87525 - 4.21836*10^-20 I,  4.37545 + 8.4819*10^-17 I, 4.37545 + 8.48193*10^-17 I, 1.87605 - 9.81335*10^-20 I, 1.87604 - 9.81346*10^-20 I,  0.387613 - 1.396*10^-22 I,  0.372399 - 1.40297*10^-22 I, -0.140221 - 1.24838*10^-24 I}     *)      first eigenvector               (*     {-0.00639256 + 0.0131895 I,  0.0000887781 - 0.000183172 I, -6.93536*10^-7 + 1.43094*10^-6 I,  4.12798*10^-9 - 8.51706*10^-9 I, -2.14113*10^-11 +   4.43576*10^-11 I, -1.67039*10^-11 - 2.21781*10^-13 I,  3.36242*10^-9 + 1.15472*10^-15 I, -6.45615*10^-7 + 1.42743*10^-17 I,  0.000108469 - 7.67751*10^-17 I, -0.0138849 - 4.92661*10^-16 I,  0.999796 + 0. I}     *)      How can I make version 10 produce the same results as version 9? How can I know which method is used in version 9? I tried to set the `Method` options in version 10 but still unable to get an agreement. **Edit** I agree that the comments are all right, that they are both correct results. I'm curious what's the change in the "internal mechanism", method, etc, so that it produce different correct results. I use this Eigensystem in calculating some quantum mechanic problem called high harmonic generation, which is very sensitive to small errors in the results. In theory , an overall phase change should not effect my results, but after upgrading to version 10, the noise floor in my results increase more then one order of magnitude. I'm trying to see why that happens, and this is my first stop. Mathematica is now a language, I guess I would expect to have exactly the same results if I update the "compiler", or at least I should know why the results are different.


Context Sensitive Formatting for a Table

Suppose I am calculating the correlation of a a set of vectors.               Correlation[RandomReal[1, {5,5}]]      I would like to display the output using TableForm or Grid and use either Style or Background to highlight the entries that exceed some threshold (say > .5 and < -.5) I found How can I add row and column header images to my TableForm output? which highlights the minimum in each row using:                   TableForm[With[{min = Min[#]}, # /. min -> Style[min, Red]] & /@ data,      TableHeadings -> {ConstantArray[lena, 3], ConstantArray[lena, 9]}]      Can someone help me adapt this for my purpose? Edit: Of course I can do it this way:                data = RandomReal[1,{5,5}];      cors = Round[Correlation[data], .01];      Table[Style[cors[[i, j]],       If[Abs[cors[[i, j]]] > .35, Red, Black]], {i, 1, 5}, {j, 1, 5}] // TableForm      but I would like to understand how to do it in one line Edit #2: Here is the inelegant solution I came up with:                cors = Correlation[RandomReal[1, {5, 5}]];      headers = Table["Header " <> ToString[j], {j, 1, 5}];      backs = Table[ If[cors[[i, j]] > .35, {i + 1, j + 1} -> Green,       If[cors[[i, j]] < -.35, {i + 1, j + 1} -> Red]], {i, 1,       Length[cors]}, {j, 1, Length[cors]}] // Flatten;           Grid[MapThread[Prepend[#2, #1] &, {Join[{""}, headers], Prepend[     (Round[cors, .01]), headers]}],       Background -> {LightGray, LightGray, backs}, Frame -> All]      Which produces ![enter image description here](http://i.stack.imgur.com/QZu34.jpg)


Why is Dataset upset by division by zero?

Consider this example:               ds = Dataset@Transpose[<|"a" -> {1, 2, 3, 4, 3, 2, 1}, "b" -> {6, 5, 4, 3, 2, 1, 0}|>, AllowedHeads -> All]      ![Mathematica graphics](http://i.stack.imgur.com/1xM43.png) Now say I need to work with the ratios of these two values. This works fine:               ds[;;-2, #a/#b &]      ![Mathematica graphics](http://i.stack.imgur.com/xiozu.png) But this fails:               ds[All, #a/#b &]      ![Mathematica graphics](http://i.stack.imgur.com/pJpS6.png) It would be easier for me to just get a result with some ComplexInfinities. Does the operation fail by desgin or oversight? Is there a workaround? Should I just use               ds[All, Quiet[#a/#b] &]      all the time or is there a more general solution? `Off[General::infy]` doesn't prevent this from failing, though the failure message can't be displayed properly.


error when defining a compiled function with ReplacePart

I always have difficulty in writing a non-trivial compiled function. I'm using _Mathematica_ 9\. Please see the following code               Clear[longtermCompiled];      longtermCompiled =       Compile[{{M, _Real, 2}},        Module[{len = Length[M]},         ReplacePart[Transpose[M] - IdentityMatrix[len], {len, i_} -> Table[1, {len}]]]];      where `M` is expected to be a matrix (two-dimensional). Upon executing the above definition, it complained:               ReplacePart::argrx: ReplacePart called with 2 arguments; 3 arguments are expected.      I don't understand this error message, because the following code works without any problems:               Clear[longtermX];      longtermX[M_] :=       Module[{len = Length[M]},        ReplacePart[Transpose[M] - IdentityMatrix[len], {len, i_} -> Table[1, {len}]]];      What's wrong?


pointer like operations in mathematica and evaluation control

I would like to create a data structure of the type "header[pointer]" where pointer would point to a list. I will shown on an example how I'd like this to work, and where the problems are.               In[1]:= pointer = Unique[storage];     Out[1]= storage$113      So far so good. Now I want to assign some values to the storage               In[3]:= Evaluate[pointer] = {v1, v2, v3}     Out[1]={v1,v2,v3}      Evaluate is needed in order to enforce evaluation of the left hand side of the assignment. The pointer has not been touched/changed which is good:               In: Trace[pointer]     Out: {pointer, storage$113, {v1,v2,v3}}      it still points to the storage, which in turn points to the list with the actual data. Yet, now it starts evaluating to something beyond storage$113. This will turn up later as the main problem. Now I'd like to have something like header[storage$113] as a wrapper to pass this around functions, and here the problems start. If one tries               In: header[pointer]     Out: header[{v1,v2,v3}]      the pointer evaluates down to the values. Thus we get bust since pointer evaluates way to much. If one tries               In: SetAttributes[header, HoldAll]      to prevent its evaluation one gets, alas, that it evaluates too little:               In: header[pointer]     Out: header[pointer]      I found a way               In: header[tmp] /. tmp -> Trace[pointer][[2]]     Out: header[storage$113]      that finally does the trick. I really do not understand why this works, actually. Trace[pointer][[2]] should also evaluate down to values v1, v2, ... This implementation might be problematic for several reasons: Trace might come up with a rather long list, and I just need the second element of it! Another problem, I suppose that the output of the Trace command might change dynamically depending on whether one puts in some extra definitions. I suppose that this is theoretically possible. Another way would be to issue header[pointer] command while pointer is still unspecified as               pointer = Unique[storage];     object = header @@ {pointer}     ... fix storage here...      but this forces me to do something I potentially might not want to do. For example, what if the command object = header... has to come at the end for whatever reasons? Anyway, I feel these both constructs looks very fragile I think and I'd like to understand how to controll these things better. Are there better ways?


How to connect to remote kernels inside home router?

How to use remote kernels inside a home router? My router has the demilitarized zone (DMZ) feature, which can expose my computer to the internet, and should be able to work, but I can't figure out how to setup the connection command in Mathematica to make it work.


Question on operator: // N

I've seen a notebook with the following:               FullSimplify[      Solve[{eq1, eq2, eq3, eq4, eq5, eq6, eq7, eq8, eq9, eq10, eq11, eq12},            {hbbbf, hbcf, hbbcr, hbcc, hbvbf, hbbc, hsbbf, hssd, hsvbf, hsf, hsbr, hsc}      ]     ][[1]] // N      I searched the _Mathemtatica_ help documentation for `//` and it seems to be a postfix operator. On the other hand `N` seems to be a way to specify the precision of a numerical value. What does the `[[1]] // N` mean? Thanks.


How to find all data points within closed curve

I want to find all data points inside curve as given below:               data = RandomReal[{-1, 1}, {200, 2}];     ParametricPlot[{Sin[u], Sin[2 u]}, {u, 0, 2 Pi},       Epilog -> {Red, Point[data]}]      Short solution is preferable Thanks.


Difference in two codes

When I check the following for the Fibonacci sequence, there is no problem:               α := (1 + Sqrt[5])/2;     M := 59793;          g[t_] := Denominator[FromContinuedFraction[ContinuedFraction[N[Log[α]/Log[5]], t]]];     δ := Log[α]/Log[5];     μ := -1/2;          Abs[Round[N[μ, 20]*g[12]] - N[μ, 20]*g[12]] -          M*Abs[(Round[N[δ, 20]*g[12]] - N[δ, 20]*g[12])]      > Out[80]= 0.4419847132 But when I tried to adapt it to the Tribonacci sequence, it does not give the correct result.                a := 1/3 (1 + (19 - 3 Sqrt[33])^(1/3) + (19 + 3 Sqrt[33])^(1/3))          a1 := (a - 1)/(4 a - 6)      w[t_] := Denominator[FromContinuedFraction[ContinuedFraction[Log[a]/Log[5], t]]]        S := 12*(10^13)                  e := Log[a1]/Log[5]         f := Log[a]/Log[5]           Abs[(Round[N[e, 100]*w[33]] - N[e, 100]*w[33])] -       Expand[S]*Abs[(Round[N [f, 100]*w[33]] - N[f, 100]*w[33])]      > Out[107]= \ > -0.0011766892841599426027968279324940525950672232471234884904296672047\ 564 Theoretically, the output should be nearly `0.498`. What is the problem in my code? I could not see it.


How do I get a list of unique random integers? Avoiding numbers being drawn twice

I am trying to get a set of random integers for which I used the function `RandomInteger[{1, 50}, 5]`. That way, however, there is the chance to get doubles such as `{46, 7, 9, 39, 39}`. How do I avoid numbers being drawn twice? Thank you very much for your help Sincerely


Animation of Differential Equations from NDSolve with ParametricPlot3D and Evaluate

I have a system of differential equations (referred to as "s") and use `NDSolve` to obtain the solution. I substitute the interpolated functions for the original functions in order to represent the trajectories of two objects in 3 dimensions. Here is the system that I am working with: **(I added this as an edit after I got some feedback that some more information about what I was attempting to animate would be useful )**               sysstars = {((sx[t]^2 + sy[t]^2 + sz[t]^2)^(3/2))*(1 +            2*(mstar1/mstar2) + (mstar1/mstar2)^2)*sx''[t] ==         g*mstar2*(-sx[t]), ((sx[t]^2 + sy[t]^2 + sz[t]^2)^(3/2))*(1 +            2*(mstar1/mstar2) + (mstar1/mstar2)^2)*sy''[t] ==         g*mstar2*(-sy[t]), ((sx[t]^2 + sy[t]^2 + sz[t]^2)^(3/2))*(1 +            2*(mstar1/mstar2) + (mstar1/mstar2)^2)*sz''[t] ==         g*mstar2*(-sz[t]), sx[0] == tpostar1[[1]], sy[0] == tpostar1[[2]],        sz[0] == tpostar1[[3]], sx'[0] == v0com1[[1]],        sy'[0] == v0com1[[2]],        sz'[0] ==         v0com1[[3]], ((qx[t]^2 + qy[t]^2 + qz[t]^2)^(3/2))*(1 +            2*(mstar2/mstar1) + (mstar2/mstar1)^2)*qx''[t] ==         g*mstar1*(-qx[t]), ((qx[t]^2 + qy[t]^2 + qz[t]^2)^(3/2))*(1 +            2*(mstar2/mstar1) + (mstar2/mstar1)^2)*qy''[t] ==         g*mstar2*(-qy[t]), ((qx[t]^2 + qy[t]^2 + qz[t]^2)^(3/2))*(1 +            2*(mstar2/mstar1) + (mstar2/mstar1)^2)*qz''[t] ==         g*mstar2*(-qz[t]), qx[0] == tpostar2[[1]], qy[0] == tpostar2[[2]],        qz[0] == tpostar2[[3]], qx'[0] == v0com2[[1]],        qy'[0] == v0com2[[2]], qz'[0] == v0com2[[3]]}          s = NDSolve[       sysstars, {sx[t], sy[t], sz[t], qx[t], qy[t], qz[t]}, {t, 0,         8*10^7}, MaxSteps -> 10^8]        **And here is how I am plotting them:**               ParametricPlot3D[      Evaluate[{sx[t], sy[t], sz[t], qx[t], qy[t], qz[t]} /. s, {t, 0,         10^7}], PlotRange -> All]     ParametricPlot3D[      Evaluate[{qx[t] + comx[t], qy[t] + comy[t], qz[t] + comz[t],          sx[t] + comx[t], sy[t] + comy[t], sz[t] + comz[t]} /. s, {t, 0,         3*10^7}], PlotRange -> All,]      **(The second Parametric Plot above is where the center of mass vector is added back to show the system from outside the center of mass inertial frame. So the first one plots two objects on initial trajectories that then go into orbit around the center of mass, with the center of mass treated as static)** The results of this are good - static lines in 3D, with the sensible paths. Now, I would like to animate this so that, say two spheres, move as a function of t. I have tried a few on-line suggestions using `Manipulate[Show[...`, but without success so far. I believe that the difficulty may relate to the use of Evaluate inside `ParametricPlot3D` \- in conjunction with the animation techniques. It does not seem possible to get rid of `Evaluate` with `ParamatricPlot3D`, and still get `ParametricPlot3D` to work with the interpolated functions which get substituted to generate the representation. There must be a way to do this in _Mathematica_ \- the program is way to good not to have a good way to do such an obvious thing with solutions, but I am stumped. Suggestions greatly appreciated (after too many hours) ! Delphi


Plot, HoldAll and the color problem

I have a similar problem as posted in Difference in Plot when using Evaluate vs when not using Evaluate, however due to a numerical evaluation I cannot use `Evaluated->True` as a `Plot[]` option. Her a small example which gives errors:               f[y_, a_] := NIntegrate[y^2 + x, {x, 0, a}];     Plot[Table[f[y, a], {a, 1, 3}], {y, 0, 3}, Evaluated -> True]      The desired output should be equal to               Plot[{f[y, 1],f[y, 2],f[y, 3]}, {y, 0, 3}, Evaluated -> True]      How can I fix this example ?


Polynomial expectations of generic distributions

**Summary** _Polynomial expectations depend only moments and cross moments of a multivariate distribution. I would like to use`Expectation` to compute polynomial expectations for generic distribution of which only the necessary moments are specified._ **Some details** I would like to compute polynomial exectations with the function `Expectation` for variables distributed according to a generic distribution. Here is a toy example:               In[139]:= ClearAll[myDist]          myDist /: Moment[myDist[mu_, var_], 1] := mu     myDist /: Moment[myDist[mu_, var_], 2] := Moment[myDist[mu, var], 1]^2 + var     myDist /: Moment[myDist[0, var_], 4] :=       Cumulant[myDist[0, var], 4] + 2 Moment[myDist[0, var], 2]     myDist /: Moment[myDist[0, var_], 3] := 0      This few lines provide enough information about the distribution `myDist` so that Mathematica can compute               In[144]:= Expectation[2 x^2, x \[Distributed] myDist[0, s^2], Method -> "Moment"]     Expectation[2 x^4, x \[Distributed] myDist[0, s^2], Method -> "Moment"]          Out[144]= 2 s^2          Out[145]= 2 (2 s^2 + Cumulant[myDist[0, s^2], 4])      I would like to carry out similar calculations with several random variables. For example.               In[147]:= ClearAll[a, b, x, y]     Expectation[      a x + b y, {x \[Distributed] myDist[0, s^2],        y \[Distributed] myDist[0, s^2]}, Method -> "Moment"]     Expectation[(a x + b y)^2, {x \[Distributed] myDist[0, s^2],        y \[Distributed] myDist[0, s^2]}, Method -> "Moment"]          Out[148]= Expectation[      a x + b y, {x \[Distributed] myDist[0, s^2],        y \[Distributed] myDist[0, s^2]}, Method -> "Moment"]          Out[149]= Expectation[(a x + b y)^2, {x \[Distributed] myDist[0, s^2],        y \[Distributed] myDist[0, s^2]}, Method -> "Moment"]      In this case Mathematica doesn't carry out the computation, even though it has all the information to do so. Namely   1. `x` and `y` are independent (this is implied in the specification `{x\[Distributed]myDist[0,s^2],y\[Distributed]myDist[0,s^2]}`, according to the definition of `Expectation`);   2. the result is completely determined by the first and second moment of `x` and `y` (Provided).  One of the problems is that `Expectation` doesn't know (or it is pre-emped by some other rule or evaluation)               In[153]:= Expectation[       a x + b y, {x \[Distributed] myDist[0, s^2],         y \[Distributed] myDist[0, s^2]}, Method -> "Moment"] ===           a Expectation[x, x \[Distributed] myDist[0, s^2], Method -> "Moment"] +        b Expectation[y, y \[Distributed] myDist[0, s^2], Method -> "Moment"]          Out[153]= False      Notice that all-is-well when the distribution is one that Mathematica knows               In[166]:= Expectation[      a x + b y, {x \[Distributed] NormalDistribution[0, s^2],        y \[Distributed] NormalDistribution[0, s^2]}, Method -> "Moment"]          Out[166]= 0      One possible solution is to define an operator such as `myExpectation` that knows/uses linearity properties of the mathematical expectation, but I would rather not reinvent the wheel and leverage the power of the built in symbol `Expectation` (for example specializing a result to one of the built in distributions) as well as the ease with it deals with higher momenta and cumulants. I tried (with no success)   1. using `ProductDistribution[{myDist[], 2}]` instead of ` {x\[Distributed]myDist[0,s^2],y\[Distributed]myDist[0,s^2]}`;   2. definiting a generic distribution as suggested (here) with the symbol `ProbabilityDistribution`. In this case the delayed `UpValues` for the moments cannot be set. Indeed                myDist2[mu_, var_] =      ProbabilityDistribution[myDistPDF[x, mu, var], {x, -Infinity, Infinity}]     myDist2 /: Moment[myDist[mu_, var_], 1] := mu          Out[164]= ProbabilityDistribution[      myDistPDF[\[FormalX], mu, var], {\[FormalX], -\[Infinity], \[Infinity]}]          During evaluation of In[164]:= TagSetDelayed::tagnf: Tag myDist2 not found in Moment[ProbabilityDistribution[myDistPDF[\[FormalX],mu_,var_],{\[FormalX],-\[Infinity],\[Infinity]}],1]. >>          Out[165]= $Failed      If a `HoldPattern` the left-hand-side of the moment delayed assignment, the command executes with no error, but it the information won't be used by `Expectation`. The reason for this is that `Expectation` first evaluates its arguments and `myDist2` evaluated to               ProbabilityDistribution[myDistPDF[\[FormalX],mu,var],{\[FormalX],-\[Infinity],\[Infinity]}]      and the upvalues of `myDist` are from then on "invisible" to `Expectation`. Some related question on how to define an arbitrary distributions are here and here.


Word Squares and Beyond

A word square is a set of words which, when placed in a grid, read the same horizontally and vertically. For example, the following is an English word square of order 5:               F A C E D     A L I V E     C I V I L     E V I C T     D E L T A      A word cube is an extension of this idea into three dimensions. For example, here are the slices of a word cube of order 4:               H A N D    A R E A    N E T S    D A S H     A R E A    R E A L    E A R L    A L L Y     N E T S    E A R L    T R I O    S L O P     D A S H    A L L Y    S L O P    H Y P E      Imagine stacking these squares vertically to form a cube; then notice how each the nth vertical slice is the same as the nth horizontal slice, and both are word squares. This idea can be extended into word hypercubes, but for simplicity, let's keep the dimensions to 2 or 3. How can we use Mathematica to generate word squares and word cubes? This is a difficult combinatorics question, so I'm only looking for a function which can generate word squares and word cubes of small order in a reasonable amount of time.


Animation of 2 Differential Equations - 1 Independent Variable

I have effectively 1 differential equation that had to be broken up into 2 (max number of steps reached). I have gotten the solutions for both using NDSolve and have plotted each together. Now, I am trying to animate this solution using Manipulate for each differential equation and then use Show to plot the two together. Ideally, Manipulate would then go through the independent variable (starts at beginning of domain from first interpolating function and goes to end of domain of the second interpolating function) that commands both solutions producing a continuous plot. Unfortunately, Show will not combine these two - I am getting two graphs next to one another. How can I achieve the result I desire? Thanks in advance for any help. I have spent days trying to figure out how to do this - even attempting quite unsuccessfully to extract results and put into a data table.               g1 = NDSolve[{r'[ϕ] == Sin[ArcCot[2/r[ϕ]]]*Sqrt[6 - r[ϕ]^2 - 1/r[ϕ]^2],  r[0] == 1}, r, {ϕ, 0, 4}]     g2 = NDSolve[{r'[ϕ] == -Sin[ArcCot[2/r[ϕ]]]* Sqrt[6 - r[ϕ]^2 - 1/r[ϕ]^2],                   r[ 1.7775896893621104`] == 2.41421},                   r, {ϕ, 1.7775896893621104`, 5}]     v1 = RevolutionPlot3D[x^2, {x, 0, 3}, PlotStyle -> Opacity[0.4], Mesh -> None]     w1 = Manipulate[       ParametricPlot3D[        Evaluate[{1/r[ϕ] Cos[ϕ], 1/r[ϕ] Sin[ϕ], 1/r[ϕ]^2} /. g1], {ϕ, 0.000001, a},         PlotRange -> {{-3, 3}, {-3, 3}, {0, 3}}, PlotStyle -> Thick,         Evaluated -> True], {a, 0.0, 1.7775640272780204}]     w2 = Manipulate[       ParametricPlot3D[        Evaluate[{1/r[ϕ] Cos[ϕ], 1/r[ϕ] Sin[ϕ], 1/r[ϕ]^2} /. g2], {ϕ, 1.77758968936211, a},         PlotRange -> {{-3, 3}, {-3, 3}, {0, 3}}, PlotStyle -> Thick,         Evaluated -> True], {a, 1.7775896893621104, 4.925661999190314}]     Show[v1, w1, w2]


Generating a position lookup function for an arbitrary list of integers

In my code, I generate a list of integers called `numlist`. Here is an example `numlist`:               numlist = Sort[Table[RandomInteger[{1, 100}], {3}]]      which gives, for example, the output: > {17, 74, 96} I would like to write a function `generateFun` that, using `numlist` as input, generates the following function `myfun`:               myfun[int_Integer] := Which[       int == 17, 1,       int == 74, 2,       int == 96, 3       ]      In other words, `myfun` takes an integer and returns the position of that integer in `numlist`. `numlist` is created at the beginning of the code and does not change during a given execution; however, a new execution will in general create a new list of integers `numlist`. The length of `numlist` varies (it is not guaranteed to be 3), although this fact is not present in the minimal working example that I gave above. I could bypass `generateFun` and simply use this function `myfun2`:               myfun2[int_Integer, numlist_] := First[First[Position[numlist, int]]]      which returns the position of `int_` in `numlist_`. However, since I will need to call the function (`myfun` or `myfun2`) _many_ times (~1,000,000 times), I think that calling `Position` every time may be quite expensive -- since `numlist`, once generated, does not change during the execution. Do you have any advice on how I can generate the `Which` expression automatically from `numlist`?


Thread[] seems to reset changes made with Manipulate[]

Recently I have been working on group theory and I have found checking for associativity for specific Cayley tables to be rather tedious so I wrote a program to do it for me. Most of the time I would make the Cayley tables first and then run the program to check if it is associative. However, I recently decided to put it all together into one `Manipulate[]` to speed up my productivity. By doing so though, things got a little glitchy. The problem I am having is with creating the rules. I think I managed to narrowed it down to one line of code(?) and so below is my code _without_ the actual function for checking associativity, only the part which seems to make the program to malfunction.               alphabet = "IABCDEFGHJKLMNOPQRSTUVWXYZ";          Manipulate[     aList = StringJoin[#] & /@Tuples[Table[StringTake[alphabet, {n}], {n, letters}], {2}];      bList = Table["I",{letters},{letters}];      rules = Thread[aList -> Flatten[bList]]; (*If I comment out this line everything works fine*)     Row[{Grid[     Prepend[Map[Flatten[#] &,        Transpose[{Table[StringTake[alphabet, {n}], {n, letters}],          Table[With[{n = n, m = m},            PopupMenu[Dynamic[bList[[n, m]]],             Table[StringTake[alphabet, {o}], {o, letters}]]], {n,            letters}, {m, letters}]}]],       Prepend[Table[StringTake[alphabet, {n}], {n, letters}], ""]],      Dividers -> {2 -> True, 2 -> True}], Spacer[50],      Dynamic[bList]}], {letters, 1, 8, 1}]      When I run this program and set a value for a particular element in the grid; `bList` will update, but quickly switch back to it's initial state. However if I remove               rules = Thread[aList -> Flatten[bList]];      the value changes as it should. I tried placing `Dynamic[]` in various places without success. I'm not sure how to proceed, so any help on how to fix the problem would be greatly appreciated.


Problems with log-log histograms

I'm using a custom function to create Log-Log Histograms of my data. It uses the CustomTicks` package (in LevelScheme, http://scidraw.nd.edu/levelscheme/) to display Log Ticks.               Needs["CustomTicks`"];          domainSizesHistogram[data_List,opts:OptionsPattern[]]:=         Module[{},(         Histogram[             Log[10,data],             {-0.05,5.05,0.1},             "LogCount",             opts,             AxesLabel->{"Basin of attraction", "Number of attractors"},             PlotRange->{Automatic,{-1,9}},             Ticks->{CustomTicks`LogTicks[0,5],Automatic}         ]     )]      It's got to be Log-Log because my simulations produce highly varied output and I would like to generate histograms to quickly compare the output of different runs. Although the function generally works fine, it sometimes produces incorrect histograms.               data1 = {32, 20, 63, 234, 12, 50, 1, 332, 11, 210, 116, 88, 11, 68, 194, 202, \     11, 46, 116, 3, 41, 236, 41, 9, 23,      48, 3, 52, 72, 20, 10, 9, 191, 52, 148, 50, 15, 105, 92, 130, 50, \     12, 244, 131, 159, 55, 189, 161, 83,      17, 22, 7, 36, 51, 15, 132, 130, 42, 6, 51, 79, 39, 10, 4, 32, 13, \     63, 83, 68, 28, 8, 1, 48, 44, 144, 28,      4, 19, 19, 54, 71, 276, 32, 39, 1, 20, 38, 72, 64, 60, 3, 93, 28, \     17, 56, 50, 7, 41, 3, 39, 11, 4, 30,      49, 58, 7, 87, 15, 10, 13, 4, 51, 8, 6, 42, 21, 67, 8, 14, 19, 4, \     2, 49, 56, 15, 3, 58, 11, 5, 15, 5, 4,      1, 27, 9, 34, 41, 3, 13, 14, 48, 69, 5, 38, 26, 8, 31, 23, 2, 21, \     28, 22, 28, 40, 14, 1, 14, 19, 1, 1,      19, 8, 3, 35, 3, 61, 1, 18, 23, 21, 25, 28, 42, 5, 2, 11, 9, 3, 2, \     1, 50, 56, 13, 9, 14, 5, 19, 2, 2, 12,      67, 6, 11, 1, 14, 7, 73, 23, 11, 2, 4, 10, 10, 3, 2, 8, 12, 4, 12, \     1, 8, 43, 6, 10, 15, 7, 6, 9, 9, 17,      4, 6, 9, 2, 7, 9, 4, 2, 3, 25, 7, 2, 18, 4, 5, 13, 1, 16, 5, 13, \     25, 9, 13, 13, 2, 5, 3, 2, 2, 3, 10, 8,      32, 12, 4, 5, 14, 6, 2, 6, 26, 4, 15, 10, 3, 11, 10, 8, 5, 6, 3, \     6, 2, 12, 3, 2, 7, 19, 14, 21, 6, 13, 2,      21, 3, 5, 1, 3, 6, 4, 2, 15, 2, 11, 6, 12, 2, 2, 10, 1, 14, 2, 5, \     1, 2, 1, 3, 2, 3, 2, 2, 1, 5, 2, 4, 7,      7, 6, 4, 2, 2, 13, 12, 4, 10, 5, 2, 2, 3, 7, 4, 1, 8, 4, 2, 4, 3, \     8, 4, 1, 2, 1, 6, 1, 1, 5, 1, 6, 8, 6,      3, 4, 6, 2, 1, 1, 1, 1, 2, 10, 1, 2, 3, 3, 5, 5, 8, 4, 1, 3, 1, 1, \     5, 2, 1, 6, 4, 2, 4, 6, 1, 5, 3, 4, 1,      6, 4, 2, 2, 2, 1, 1, 2, 1, 4, 5, 2, 3, 5, 4, 2, 2, 2, 3, 2, 1, 2, \     1, 1, 4, 2, 2, 2, 1, 3, 1, 1, 3, 3, 3,      1, 3, 3, 1, 1, 5, 1, 1, 2, 1, 2, 2, 1, 1, 1, 1, 2, 1, 3, 1, 1, 1, \     5, 1, 2, 3, 2, 3, 1, 3, 1, 1, 2, 1, 2,      1, 1, 4, 1, 2, 1, 2, 2, 2, 2, 1, 1, 1, 2, 2, 1, 3, 1, 2, 2, 1, 1, \     1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1,      1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \     2, 1, 1, 1, 1};          data2 = {2655, 72, 3862, 2414, 577, 307, 21, 38, 8, 41, 4, 1};      `domainSizesHistogram[data1]` produces a normal histogram: ![Histogram of data1](http://i.stack.imgur.com/WUBNA.png) But `domainSizesHistogram[data2]` gives a histogram where the axes are all messed up: ![enter image description here](http://i.stack.imgur.com/VoJmK.png) How can I fix the function to always produce a histogram with the same axes? I already tried to set a hard `PlotRange` for both axes, but this didn't produce the right results either. Some of my fixes seemed to produce the right axes, but then the bars would float above the horizontal axis. Any help would be appriciated. **Edit:** After adding `AxesOrigin->{-0.05,-1}` to the function, a lot of problem were solved. However, now I get floating bars in some cases. data3 = {4535, 5465}; And `domainSizesHistogram[data3]` produces this: ![Histogram of data3](http://i.stack.imgur.com/LidbO.png)


Find intersecting rectangles groups

I've a list of rectangles in the form               {index, {centerX, centerY}, {width, height}}      I want to find intersecting rectangles list. I want to obtain a list on the form               {{indx...indy},{indt...indz}...}      Every element of this list is a list of rectangles that have at least an intersection in common, with transitive property: if rectangle 1 intersects rectangle 2 that intersect rectangle 3, these are a part of the same group. If I've this situation in the image below, my intersecting list should be               {{1,2,10},{6},{7,5},{3},{4,8,9}}      (element order is not important). How can I accomplish this? ![enter image description here](http://i.stack.imgur.com/iIKTw.png) EDIT: There's a real sample data, with two groups and an isolated rectangle:               obj2 = {        {1, {0, 0}, {1, 1}},        {2, {0.5, 0.5}, {1, 1}},        {3, {3, 2}, {0.5, 0.6}},        {4, {1.2, 0.5}, {0.5, 0.6}},        {5, {2, -0.3}, {0.4, 0.4}},        {6, {2.1, -0.4}, {0.3, 0.4}}        };


Find zero crossing in a list

I'm looking for a function that finds the index of the zero-crossing points of a list. Before I go making my own subroutine to do this, I was wondering if anyone knows of any built-in Mathematica function for it. Example of what I want:               list = {-2,-1,0,1,2,3,4,3,1,-2,-4,8,9,10};     ZeroCrossing[list] returns: {3,10,12}      Thanks, EDIT: Per whuber's suggestion, I'm adding my findings to the initial question, instead of just in a solution. I've checked LabVIEW (the other language I know well), and it considers "Bounces" ({1,0,2}, {-2,0,1}) and duplicates ({1,0,0,2}) to be zero-crossings. It outputs a T/F value for each array index. Example:               ZeroCrossing[{1,0,2}]     (* Returns: {F,T,T} *)     ZeroCrossing[{1,0,0,2,3}]     (* Returns: {F,T,T,T,F} *)


ImageAlign doesn't always work correctly

I've been working with `ImageAlign` in Mathematica 8 and I'm having trouble getting it working reliably. Perhaps there are some subtleties that I'm not yet aware of? Here's an example:               mandrill = ExampleData[{"TestImage", "Mandrill"}]     eye = ImageTake[mandrill, {50, 91} , {150, 190}]      ![mandrill and the mandrill eye](http://i.stack.imgur.com/qCE31.png) Now `ImageAlign` is supposed to be able to align these two images, returning, say, the eye in the right place on the original image:               ImageAlign[mandrill, eye, Background -> Gray]      ![enter image description here](http://i.stack.imgur.com/P99f6.png) but it appears in the wrong place. According to the documentation, it should appear in the correct location, but it shows up in the bottom corner. There are Transformation options, but they seem to make no difference to the success of the function. Strangely, I have been achieving some success with other images, although it's not consistent. Are there some restrictions that I'm not aware of?


Using Partition to allow sublists of different lengths

As a minimal example, suppose I have a list of the integers from 1 to 25. Suppose I want to use `Partition` to partition the list into sublists of length 10 **but** without dropping the "end" elements. For example, this code               list = Range[1, 25];     Partition[list, 10]      gives: `{{1,2,3,4,5,6,7,8,9,10},{11,12,13,14,15,16,17,18,19,20}}`, where the integers 21 through 25 have been dropped. What if I want to keep those integers? I would like `Partition` to partition the list into sublists of length 10 only when possible (i.e., keeping the "end" elements). How can I do this? In the `Partition` documentation, this entry looks like a possibility: > `Partition[list, n, d, {kL, kR}, {}]` uses no padding, and so can yield > sublists of different lengths. So I tried: Partition[list, 10, 0, {1, 1}, {}] but this did not work (according to the documentation `{kL, kR} = {1, 1}` means "allow maximal overhang at the end"). On the other hand, this seems to work:               Partition[list, 10, 10, 1, {}]      which gives the correct output: `{{1,2,3,4,5,6,7,8,9,10},{11,12,13,14,15,16,17,18,19,20},{21,22,23,24,25}}`. Is this the best way to solve the problem, or am I making a conceptual mistake? I obtained the idea `Partition[list, 10, 10, 1, {}]` from the following documentation, but conceptually I am not really sure what it is doing: > Use no padding, so later sublists can be shorter: > `Partition[{a,b,c,d,e,f,g},3,3,1,{}]` > > `{{a,b,c},{d,e,f},{g}}`


Why does Assuming[...] work in one case but not in another?

Why does this work               Assuming[α > 0 && ϵ > 0 && t > 0,      FullSimplify @ Integrate[(z^2 Exp[-α t (z^2 + ϵ)])/(z^2 + 1), {z, 0, ∞}]]      > >     (E^(-t α ϵ) (Sqrt[π] - E^(t α) π Sqrt[t α] Erfc[Sqrt[t α]]))/(2 Sqrt[t > α]) >   but not this?               MyAssumptions := Assuming[α > 0 && ϵ > 0 && t > 0, #] &;     MyAssumptions[FullSimplify @ Integrate[(z^2 Exp[-α t (z^2 + ϵ)])/(z^2 + 1), {z, 0, ∞}]]      > >     ConditionalExpression[ >       (E^(-t α ϵ) (Sqrt[π] - E^(t α) π Sqrt[t α] Erfc[Sqrt[t α]]))/(2 Sqrt[t > α]), >       Re[t α] > 0] >


Filter list with different list in it

I have a list like:                  {{{4, 14}, 1}, {{4, 15}, 1}, {{4, 16}, 1}, {{4, 17}, 1},          {{4, 18}, 1}, {{4, 14}, 3},  {4,15},      {{4, 16}, 2},{4,18}}      Now I want to filter this list. First I want to delete lists that have the form: `{a,b}` like `{4,15}` and `{4,18}`. So what remains is:                {{{4, 14}, 1}, {{4, 15}, 1}, {{4, 16}, 1}, {{4, 17}, 1},        {{4, 18}, 1}, {{4, 14} ,3}, {{4, 16}, 2}}      And now I want only the lists which are a minimum: For example now you have a list with:               {{4, 14}, 1} and {{4, 14}, 3}     {{4, 16}, 1} and {{4, 16}, 2}      I want that only `{{4, 14}, 1}` and `{{4, 16}, 1}` remain (minimum of the third number). Finally remains:               {{{4, 14}, 1}, {{4, 15}, 1}, {{4, 16}, 1}, {{4, 17}, 1}, {{4, 18}, 1}      How can I easily do this??


Composition à la Mondrian

I would like to paint something like this ![enter image description here](http://i.stack.imgur.com/XiK7O.jpg) or,even better, like this ![enter image description here](http://i.stack.imgur.com/vrJcC.jpg) I have tried               colors =       {Red, Blue, Yellow, White, Black};          cells =       ConstantImage[RandomChoice[colors], #] & /@         RandomInteger[{50, 10}, {30, 2}];          ImageCollage[      cells,      Background -> Black,      Method -> "Rows",      ImagePadding -> 1,      ImageSize -> 400]      ![enter image description here](http://i.stack.imgur.com/djFWm.jpg) The result is unpleasing, especially because all rows have equal height. How could one produce a more Mondrian - like image?


RegionPlot3D in cylindrical or spherical coordinates?

RegionPlot3D is awesome. Unfortunately, it appears to work only for Cartesian coordinates. While there are ways to draw surfaces in spherical or cylindrical coordinates, I can't find a way to draw solids. Is there a way to do so that doesn't involve translating the equations to Cartesian coordinates? Thanks.


Solving Integrals

Here's a problem that I don't understand.               f[x_] := Exp[Cos[3*x]]     g[x_] := (1/3)*x^3 - x^2 + 2       When I try to find the limit:               Solve[NIntegrate[f[x] - 0.1 g[x], {x, 0, t}] == 3, t]       I get these errors x3 > NIntegrate::nlim: > > Solve::inex: Solve was unable to solve the system with inexact coefficients > or the system obtained by direct rationalization of inexact numbers present > in the system. Since many of the methods used by Solve require exact input, > providing Solve with an exact version of the system may help. >>


Factoring polynomials to factors involving complex coefficients

I've run into some problems using `Factor` on polynomials with complex coefficient factors. Reading the documentation it looks like it only factors over the `Integers` by default. So I've found I can factor some polynomials with complex factors like this:               Factor[ poly, Extension -> I ]      For example `x^2+1` won't factor with just `Factor[x^2+1]` but it does factor properly when I add the imaginary unit extension. However another polynomial such as: $$8x^3-7x^2+10x-5$$ still won't be factorized even with the imaginary extension added. What am I missing here? How do I simply get `Mathematica` to completely factor any polynomial with complex factors I give it?


List Manipulation matrices

I have the following two lists: List A:               A={{-0.0390625, 0., 0., 0., 0.0390625}, {-0.174377, -0.073478,        3.0893*10^-16, 0.073478,        0.174377}, {-0.196939, -0.112309, -1.50053*10^-16, 0.112309,        0.196939}, {-0.174377, -0.073478, 5.52991*10^-16, 0.073478,        0.174377}, {-0.0390625, 0., 0., 0., 0.0390625}}      List B:               B={{5, 6, 6, 5, 5}, {5, 5, 1, 5, 5}, {5, 4, 3, 4, 5}, {5, 5, 5, 5,        5}, {5, 0, 5,6, 5}}      I want to create 6 (max. value in list B) copies of List A, but if a value at point {i,j} in List B is smaller then 6, by example value X at point {i,j} in List B, then the value at point {i,j} in List A should only be used in the first X copies. Hence the last 6-X copie(s) should be zero at point {i,j}. How can I fix this?


How can I graph an equation with five variables?

{c*((a - b*Cot θ)/(Subscript[r, 1])^4) + ((b*Csc θ)/(Subscript[r, 2])^4)      This is a form of Poiseuille's Law I need to graph. I want the value of the variables to be `c = 1, a = 10, b = 5, r1 = 1, r2 = 2/3`.


Checking result for expression

I want to verify the following result: $\sum _{y=2}^{n+1} \left(\sum _{x=y-1}^n \frac{1}{x-y}\right)=n \left(H_n^{(1)}-1\right)$ In Mathematica i try with:               Sum[Sum[1/(x - y), {x, y - 1, n}], {y, 2, n + 1}] == n*(HarmonicNumber[n, 1] - 1)      But I don't understand Mathematica output, is a large formula. And WolframAlpha doesn't say anything for it.


Finding the coefficient of a certain power in a generating function

I want to compute $(t^1+\dots +t^5)(t^2+\dots+ t^6)(t^3+\dots +t^9)$ and find the coefficient of $t^{15}$ for example. $t$ is an indeterminate Now in _Maple_ this is simply as               p:=sum(t^i,i=1..5)*sum(t^i,i=2..6)*sum(t^i,i=3..9);     coeff(p,t,15);      But I can't seem to learn how to do this in _Mathematica_. I have tried using               Series[ %, {t, 1, 10}] * Series[ %, {t, 4, 20}] * Series[ %, {t, 6, 15}]      But it outputs a number(I don't know what this number even is) Where can I find documentation to solve such a problem?


Character display color

I'm looking to cause the front end to display individual characters in a specific color, just in general, as a default sort of thing. For instance, the character "1" would always display as a red 1, except of course when an output color is manually specified. I'm basically looking for something like the image. I have no idea how to go about doing this. I looked at stylesheets enough to know I hate them. ![enter image description here](http://i.stack.imgur.com/4V4Ki.png)


Evaluate Initialization Cells of another notebook

Although there may be better ways to get data and definitions from another notebook (packages, read/write dumps, ...), sometimes it is convenient to just evaluate the initialization cells from another notebook to re-use the data and definitions. Normally I would open this notebook and manually `Evaluate Initialization Cells`, but I was wondering if there is a way to do this automatically, i.e. with some code. **Question: is there a way to evaluate the Initialization Cells of a certain notebook by filename?** Related questions:   * Evaluation of Notebook chosen by FileNameSetter   * How to select all initialization cells?


How can I construct "better" block graphs?

A graph is a _block graph_ if it can be constructed from an undirected tree by replacing each edge with a clique. My method of generating "random" block graphs is as follows. The parameters are the number of blocks and the maximum size of any clique.               RandomBlockGraph[b_, max_] :=       Module[{g = Graph[{}], L = Table[i, {i, 1, b*max}]},         For[i = 1, i <= b, ++i,           r = RandomInteger[{2, max}];           h = IndexGraph[CompleteGraph[r], First[L]];           L = Drop[L, r - 1];           g = GraphUnion[g, h];         ];           Return[g];       ];      The function "glues" together cliques. The weakness is that right now, a vertex is joining at most 2 cliques. Here's a few examples of what the function spits out with `RandomBlockGraph[3, 5]`: ![enter image description here](http://i.stack.imgur.com/oqk7s.png) ![enter image description here](http://i.stack.imgur.com/IwJSl.png) It would be nice if my function could say take a tree, and then actually replace every edge with a clique. This would make it possible to get as an output say a star graph on $n$ vertices, where every edge was replaced with a clique. The current function can't do this, since every vertex joins at most 2 cliques. > How can I modify (or write a better function) for generating block graphs > such that a vertex can join more than just 2 cliques?


Placing bar chart labels on the upper and lower frame axes

In the bar chart (with negative values)               BarChart[{{1, 2, 3}, -{4, 5, 6}},       ChartLabels -> {Placed[{"r1", "r2"}, Above],         Placed[{"c1", "c2", "c2"}, Below]}]      ![enter image description here](http://i.stack.imgur.com/QmI3s.png) the bar and group labels can be placed above and below the bars. How can I place the bar and group labels on the upper and lower frame axes like in the paired bar chart               PairedBarChart[{Range[4], Range[4]/2}, {Range[4], Range[4]/2},       ChartLabels -> {Placed[{"pair1", "pair2"}, Above],         Placed[{"g1", "g2"}, "LeftAxis"],         Placed[{"a", "b", "c", "d"}, "RightAxis"]}]      ![enter image description here](http://i.stack.imgur.com/Ipx5E.png) where the labels are placed to the left and right axis by using `Placed[{"g1", "g2"}, "LeftAxis"]` and `Placed[{"a", "b", "c", "d"}, "RightAxis"]`? Unfortunately, this doesn't work with `BarChart` and "TopAxis" nor "BottomAxis".


Incorporating a Manipulation in an Animation

I am having trouble incorporating a manipulation into my animation. I want to be able to maniuplate the 5 constants at the beginning. Am I going to need to combine all of the code into one string?                N0 = 10; ρ = .1; d = 1; ϵ = 2; j = 1     eqone = Flatten[                Join[                Table[x[i]''[t] == ϵ*(1 - x[i][t]^2)*x[i]'[t] - x[i][t] + d (z[t] - x[i][t]),                      {i, 0, N0}],                 {z'[t] == ρ*d/N0 (Sum[x[i][t] - z[t], {i, 0, N0}]) - j*z[t], z[0] == 1,                x[0][0]        == 0,                 x[0]'[0]       == 0,                 x[N0/2][0]     == 0,                 x[N0/2]'[0]    == 0},                 Table[x[i]'[0] == 0, {i, 1, N0/2 - 1}],                 Table[x[i][0]  == 0, {i, 1, N0/2 - 1}],                 Table[x[i]'[0] == 0, {i, N0/2 + 1, N0}],                 Table[x[i][0]  == 0, {i, N0/2 + 1, N0}]]];          eqtwo = NDSolve[eqone, Append[Table[x[i], {i, 0, N0}], z], {t, 500},      MaxSteps -> Infinity]          Animate[ptss = Table[{i, x[i][t]} /. eqtwo, {i, 0, N0}];        ListPlot[ptss, PlotRange -> {{0, N0}, {-5, 5}},                       PlotStyle -> Directive@AbsolutePointSize@4,                       Epilog -> {Line@ptss[[All, 1]]}, ImageSize -> Large],              {t, 0, 500},              AnimationRate -> 2,              AnimationRepetitions -> 2,              AnimationRunning -> False]


Solving and plotting ODEs while varying one of the initial conditions

How can I vary an initial condition in the numerical solution of a system of ODEs and then make a 3D plot of the solution space with that condition as one of the variables.               sol = NDSolve[       {y''[t] + y'[t] + 4*y[t] + x[t] - x'[t] == 0,         x'[t] + 3*c*y[t] == 0,        y[1] == 1, y'[1] == 1,         x[0] == 1}, {x, y}, {t, 0, 10}]      I want to vary one of the condition variables, say `y[1]` over `u = Range[-10, 10, step]`. Then I want to make a 3D plot of the solution space `(x[t[, y[t], y[1][u])`. Can anyone please guide me in solving this query.


Is it possible to use a mathematical expression as function name?

This might seem as a silly question, but is it feasible to use a mathematical expression as the name of a function? For example, I'm studying the cross section of Compton scattering and there is a formula for the differential cross section, which is denoted as $\frac{d\sigma}{d\Omega}$. I'd like to express the latter as a function of energy E, angle θ and atomic number Z. If I, naively, use $\frac{d\sigma}{d\Omega}[Z\\_, E\\_, \theta\\_] := \ldots$ I get the anticipated error: > SetDelayed::write : Tag Times in dσ/dΩ[Z_,E_,θ_] is Protected Instead of the obvious workaround of using a name such as `diffSection`[Z_,E_,θ_] := ... is there any other way ?


Creating documentation for sub-packages in Workbench

I'd like to create proper documentation for a package of mine, and Workbench in principle provides the tools to do this. However, I've split my package into multiple sub-packages (because I found it easier to maintain the code that way), structured as follows:               mainPackage`                `myPackage`                          `subPackage1`                          `subPackage2`                          `subPackage3`      The documentation tools in Workbench are set up in such a way that, out of the box, they only work with one top-layered package. For instance, the _Create symbol pages_ button from the _Documentation_ tab in the PacletInfo.m editor only looks for symbols within the context \$ApplicationName (which you can set in the _Overview_ tab of the PlacletInfo.m editor), and it's not possible for $ApplicationName to have quotes (`). So my question is: does anyone have a workaround for this? I could merge all my _subPackages_ into _myPackage_ , but unfortunately it won't be possible to remove the top-layer _mainPackage_.


How can I get all the results from a Wolfram | Alpha query?

When I query Wolfram | Alpha with "city in orange county, california", it returns the first four results with a note that there are "42 total". I can then hit the "more" button until all 42 are visible. I tried to get the same 42 results as computable data, in Mathematica 9.0.1.0, with this:               WolframAlpha["city in orange county, california", "ComputableData"]      which returns a list of the four items that initially come up when I ran the query on the Wolfram Alpha website:               {"Santa Ana", "Anaheim", "Irvine", "Huntington Beach", "Garden Grove"}      I've been sifting through online documentation and Google but haven't been able to figure out how to get all 42 cities. Any hints?


factorization of integer into two parts with specific prime factors

I would like to write a _Mathematica_ code to decompose an integer into two or more parts with primes in special intervals. For instance, I want to decompose $m=\binom{n}{k}$ into two parts U and V such that $\binom{n}{k}=UV$ and $$ U=\prod_{\substack{p\le k\\\p^\alpha||m}} p^{\alpha} $$ and $$ V=\prod_{\substack{k<p\le n\\\p^\alpha||m}} p^{\alpha} $$ where $p^\alpha||m$ mean $p^\alpha$ is the maximum prime power dividing m. I tried               Product[If[Element[p,Primes]&&Mod[Binomial[n, k], p] == 0, p, 1], {p,2,k-1}]          Product[If[Element[p,Primes]&&Mod[Binomial[n, k], p] == 0, p, 1], {p,k,n}]      , but it was not true


m equations and n variables. Reducing using Mathematica

I have six equations and thirteen variables. I would like to reduce it to seven free parameters. I used Reduce to solve it but it is taking really long (one full day and no output yet) and I think there must be a better way. Here is my code               Y = {{y1}, {y2}, {y3}}      T = {{t11, t12, t13}, {t21, t22, t23}, {t31, t32, t33}}      K = k*IdentityMatrix[3]          M = Y.Transpose[Y] + T.Transpose[T] - K %This is a symmetric matrix          Reduce[M[[1]][[1]]==0&&M[[1]][[2]]==0&&M[[1]][[3]]==0&&M[[2]][[2]]==0&&M[[2]][[3]]==0&&M[[3]][[3]]==0, Reals]      What should I do to speed this up? I'm sure if I spent a few hours, I could do it by hand but surely, there is a simple way to do it in Mathematica?


Whats the best practice of using subscripts in symbols?

I have stumbled over several issues about subscripted symbols recently. I would like that I can enter subscripted variables with my keyboard and that they are treated as symbols. I would also like to have lists (matrices) of these subscripted symbols and that they are formatted in the output nicely so that I can do calculations which them and still be able to see the nice output. **So far I have come up with the following (which uses the Notation Package):**               Needs["Notation`"];          Symbolize[ParsedBoxWrapper[SubscriptBox["_", "_"]]]     Symbolize[ParsedBoxWrapper[SubsuperscriptBox["_", "_", "_"]]]          makeSpecialSymb[var_String, i_, j_] :=        ToExpression[SubscriptBox[var, ToString[i], ToString[j]]];          makeSpecialSymb[var_SubscriptBox, i_, j_] :=        ToExpression[        SubscriptBox[var[[1]],          var[[2]] <> "," <> ToString[i] <> "," <> ToString[j]]];               makeSpecialSymb[var_SubsuperscriptBox, i_, j_] :=        ToExpression[        SubsuperscriptBox[var[[1]],          var[[2]] <> "," <> ToString[i] <> "," <> ToString[j], var[[3]] ]];          SymbolicMatrix[func_Function, m_Integer, n_Integer] :=       Table[func[i, j], {i, 1, m}, {j, 1, n}];          SymbolicMatrix[func_Function, m_Integer] :=       Table[func[i], {i, 1, m}, {j, 1, 1}];          SymbolicMatrix[argSpecSymb_, m_Integer, n_Integer] :=       Table[makeSpecialSymb[argSpecSymb, i, j], {i, 1, m}, {j, 1, n}];          SymbolicMatrix[argSpecSymb_, m_Integer] :=       Table[makeSpecialSymb[argSpecSymb, i], {i, 1, m}, {j, 1, 1}];      **So i can do the following:**               A = Map[HoldForm, SymbolicMatrix["W", 2, 2], 2];     B = SymbolicMatrix[SubsuperscriptBox["G", "S", "k"], 2, 2] ;     A // FullForm     B // MatrixForm     ?"Global`*"      ![enter image description here](http://i.stack.imgur.com/QRRd7.png) **So everything works fine, I can make a Matrix out of Symbols which are defined in the global context and which get formatted really nice. This is cool!** Another approach would be something (from Mike), where we do not generate the symbols but rather use some sort of formatting expression like the following:                ClearAll[fancySubscript1];          SetAttributes[fancySubscript1, HoldFirst]          fancySubscript1 /:       MakeBoxes[fancySubscript1[var_, index_], StandardForm] :=       SubscriptBox[MakeBoxes[var, StandardForm],        StyleBox[RowBox[{MakeBoxes[var, StandardForm],           MakeBoxes[index, StandardForm]}], ZeroWidthTimes -> True]]          fancySubscript1[var_, indices : {_Integer ..}] :=       fancySubscript1[var, #] & /@ indices               fancySubscript[H, {{1, 2}, {3, 4}}]      **Which gives:** ![enter image description here](http://i.stack.imgur.com/iTEbe.png) If I would go with this method, which prints all values very nicely, I can make matrices which do not contain symbols but rather function expression. In this method I am probably also much more flexible when I want to define my own look how the individual fancySubscripts are formatted. Which version would you go for in which cases? I am a bit unsure, which one of these is better to use, also with respect to flexibility. Also with respect to what method is better to use for if I want to replace the variables with values in subsequent calculations (either by replacement rules or by Set[] ) ? Another question for method 1, how does mathematica decide how to display my crazy named variables like: `W\[UnderBracket]Subscript\[UnderBracket]1` in the output? It seems that all symbols, which get created by the `ParsedBoxWrapper` which I think gets called when ever it sees a `SubscriptBox` pattern as defined in the `Symbolize` command, are displayed nicely. If I enter `RR\[UnderBracket]Subscript\[UnderBracket]100` in a new notebook it does not immediately get converted to a nice subcripted output format? Whats the problem here? I would be really interessted what the caveats are in these two methods, because I am not kind of a hero with mathematica. Thanks!


Add a column to a matrix as a function of the other columns

I was wondering if its possible to add a column to a matrix by a formula that uses all other columns, like this:               {a1,b1,c1,f(a1,b1,c1)}     {a2,b2,c2,f(a2,b2,c2)}     {a3,b3,c3,f(a3,b3,c3)}      Thanks!


Solving a large system of non-linear equations

I am new to _Mathematica_ , and I am currently trying to use it to solve a large symbolic system of non-linear equations. I began the code below about 30 hrs ago, and the _Mathematica_ Kernal has been using between 4 and 7GB of RAM since that time. Is there any chance (at this point) that a solution is still forthcoming? That is, should I continue to let this thing run? If so, is there any time threshold beyond which a solution is unlikely? There are currently 22 unknowns, and a bunch of other parameters. An alternative specification of the problem could drop this to 16 unknowns with 16 equations. Would _Mathematica_ be significantly more likely to solve this formulation in a reasonable amount of time? Here is my code:               Solve[{F1^γ1 L1^(-1 + α1)       P1 R1^η1 S1^β1 T1^ζ1 α1 - λ - P1 r (S1 θ1 + F1 S1 ι1 + S1 TV1 κ1 + RV1 S1 μ1) == 0,       -Cs + F1^γ1 L1^α1 P1 R1^η1 S1^(-1 + β1) T1^ζ1 β1 -          L1 P1 r (θ1 + F1 ι1 + TV1 κ1 + RV1 μ1) == 0,       -Cf + F1^(-1 + γ1) L1^α1 P1 R1^η1 S1^β1 T1^ζ1 γ1 - L1 P1 r S1 ι1 == 0,       F2^γ2 L2^(-1 + α2) P2 R2^η2 S2^β2 T2^ζ2 α2 - λ -          P2 r (S2 θ2 + F2 S2 ι2 + S2 TV2 κ2 + RV2 S2 μ2) == 0,       -Cs + F2^γ2 L2^α2 P2 R2^η2 S2^(-1 + β2) T2^ζ2 β2 -        L2 P2 r (θ2 + F2 ι2 + TV2 κ2 + RV2 μ2) == 0,       -Cf + F2^(-1 + γ2) L2^α2 P2 R2^η2 S2^β2 T2^ζ2 γ2 - L2 P2 r S2 ι2 == 0,       F3^γ3 L3^(-1 + α3) P3 R3^η3 S3^β3 T3^ζ3 α3 - λ -          P3 r (S3 θ3 + F3 S3 ι3 + S3 TV3 κ3 + RV3 S3 μ3) == 0,       -Cs + F3^γ3 L3^α3 P3 R3^η3 S3^(-1 + β3) T3^ζ3 β3 -          L3 P3 r (θ3 + F3 ι3 + TV3 κ3 + RV3 μ3) == 0,       -Cf + F3^(-1 + γ3) L3^α3 P3 R3^η3 S3^β3 T3^ζ3 γ3 - L3 P3 r S3 ι3 == 0,       F4^γ4 L4^(-1 + α4) P4 R4^η4 S4^β4 T4^ζ4 α4 - λ -         P4 r (S4 θ4 + F4 S4 ι4 + S4 TV4 κ4 + RV4 S4 μ4) == 0,       -Cs + F4^γ4 L4^α4 P4 R4^η4 S4^(-1 + β4) T4^ζ4 β4 -          L4 P4 r (θ4 + F4 ι4 + TV4 κ4 + RV4 μ4) == 0,       -Cf + F4^(-1 + γ4) L4^α4 P4 R4^η4 S4^β4 T4^ζ4 γ4 - L4 P4 r S4 ι4 == 0,       F5^γ5 L5^(-1 + α5) P5 R5^η5 S5^β5 T5^ζ5 α5 - λ -          P5 r (S5 θ5 + F5 S5 ι5 + S5 TV5 κ5 + RV5 S5 μ5) == 0,       -Cs + F5^γ5 L5^α5 P5 R5^η5 S5^(-1 + β5) T5^ζ5 β5 -          L5 P5 r (θ5 + F5 ι5 + TV5 κ5 + RV5 μ5) == 0,       -Cf + F5^(-1 + γ5) L5^α5 P5 R5^η5 S5^β5 T5^ζ5 γ5 - L5 P5 r S5 ι5 == 0,       F6^γ6 L6^(-1 + α6) P6 R6^η6 S6^β6 T6^ζ6 α6 - λ -         P6 r (S6 θ6 + F6 S6 ι6 + S6 TV6 κ6 + RV6 S6 μ6) == 0,       -Cs + F6^γ6 L6^α6 P6 R6^η6 S6^(-1 + β6) T6^ζ6 β6 -          L6 P6 r (θ6 + F6 ι6 + TV6 κ6 + RV6 μ6) == 0,       -Cf + F6^(-1 + γ6) L6^α6 P6 R6^η6 S6^β6 T6^ζ6 γ6 - L6 P6 r S6 ι6 == 0,       F7^γ7 L7^(-1 + α7) P7 R7^η7 S7^β7 T7^ζ7 α7 - λ -         P7 r (S7 θ7 + F7 S7 ι7 + S7 TV7 κ7 + RV7 S7 μ7) == 0,       -Cs + F7^γ7 L7^α7 P7 R7^η7 S7^(-1 + β7) T7^ζ7 β7 -          L7 P7 r (θ7 + F7 ι7 + TV7 κ7 + RV7 μ7) == 0,       -Cf + F7^(-1 + γ7) L7^α7 P7 R7^η7 S7^β7 T7^ζ7 γ7 - L7 P7 r S7 ι7 == 0,       -L1 - L2 - L3 - L4 - L5 - L6 - L7 + ℒ == 0},       {L1, L2, L3, L4, L5, L6, L7, S1, S2, S3, S4, S5, S6, S7, F1, F2, F3, F4, F5, F6, F7}]


Modify all the second elements of every pair in a list of pairs

I have a list in the form {{a, 1}, {b, 2}, {c, 3}}. Let's say I want to operate a transformation on all the second elements of each sublist, but this transformation is a function of them all together. As an example I want to Standardize them. At the moment I've implemented this with Transpose.               mylist = {{a, 1}, {b, 2}, {c, 3}};     newlist = Transpose[{mylist[[All, 1]], Standardize[mylist[[All, 2]]]}]      and the output is correctly               {{a, -1}, {b, 0}, {c, 1}}      I find this a little cumbersome, this approach can become complicated and hard to read sometimes. Isn't there a more natural way?


Wavelet transform order problem

I have a signal that I'm trying to study its time-frequency features by continuous wavelet transform. By choosing different wavelet order, I get some differences in the results.               data={2.9014*10^-6,2.90163*10^-6,2.90184*10^-6,2.90199*10^-6,2.90211*10^-6,2.90227*10^-6,2.90256*10^-6,2.90306*10^-6,2.90371*10^-6,2.90441*10^-6,2.90497*10^-6,2.90531*10^-6,2.9055*10^-6,2.90578*10^-6,2.90646*10^-6,2.90772*10^-6,2.90945*10^-6,2.91123*10^-6,2.91259*10^-6,2.91325*10^-6,2.91343*10^-6,2.91381*10^-6,2.91522*10^-6,2.91808*10^-6,2.92209*10^-6,2.92617*10^-6,2.92908*10^-6,2.93018*10^-6,2.93004*10^-6,2.93033*10^-6,2.93297*10^-6,2.93891*10^-6,2.94732*10^-6,2.95574*10^-6,2.9614*10^-6,2.96299*10^-6,2.96185*10^-6,2.96162*10^-6,2.96628*10^-6,2.97767*10^-6,2.99387*10^-6,3.00976*10^-6,3.01981*10^-6,3.02167*10^-6,3.01827*10^-6,3.0168*10^-6,3.02483*10^-6,3.04546*10^-6,3.07459*10^-6,3.10242*10^-6,3.11891*10^-6,3.12028*10^-6,3.11252*10^-6,3.10893*10^-6,3.12272*10^-6,3.15854*10^-6,3.20828*10^-6,3.25426*10^-6,3.27939*10^-6,3.27836*10^-6,3.26281*10^-6,3.25606*10^-6,3.27983*10^-6,3.34039*10^-6,3.4223*10^-6,3.49512*10^-6,3.53107*10^-6,3.52363*10^-6,3.49457*10^-6,3.48331*10^-6,3.52429*10^-6,3.62491*10^-6,3.75702*10^-6,3.86957*10^-6,3.91859*10^-6,3.89724*10^-6,3.84478*10^-6,3.82651*10^-6,3.89594*10^-6,4.06072*10^-6,4.27145*10^-6,4.44408*10^-6,4.50948*10^-6,4.46164*10^-6,4.369*10^-6,4.33805*10^-6,4.45164*10^-6,4.71689*10^-6,5.05039*10^-6,5.31582*10^-6,5.40427*10^-6,5.31103*10^-6,5.15072*10^-6,5.09455*10^-6,5.2712*10^-6,5.68762*10^-6,6.20894*10^-6,6.61828*10^-6,6.74349*10^-6,6.57916*10^-6,6.30884*10^-6,6.20238*10^-6,6.4596*10^-6,7.09078*10^-6,7.88788*10^-6,8.51491*10^-6,8.70166*10^-6,8.43447*10^-6,7.9931*10^-6,7.79107*10^-6,8.13561*10^-6,9.04922*10^-6,0.0000102271,0.0000111668,0.0000114527,0.0000110468,0.0000103528,9.98182*10^-6,0.0000103954,0.0000116448,0.0000133079,0.0000146643,0.0000150967,0.000014515,0.000013469,0.0000128233,0.000013247,0.0000148457,0.0000170679,0.0000189313,0.0000195583,0.0000187682,0.0000172645,0.0000162108,0.0000165364,0.0000184334,0.0000212252,0.0000236427,0.0000245012,0.0000234839,0.0000214325,0.0000198316,0.000019909,0.0000219786,0.0000252636,0.0000282157,0.0000293231,0.0000280882,0.0000254475,0.0000231909,0.0000228567,0.0000249121,0.0000285254,0.0000319176,0.0000332699,0.0000318712,0.0000286827,0.000025737,0.000024859,0.0000266879,0.0000303991,0.0000340713,0.0000356473,0.0000341925,0.0000306028,0.0000270451,0.0000255658,0.0000269767,0.0000305281,0.0000342767,0.0000360407,0.000034684,0.0000309405,0.0000269673,0.00002493,0.0000257916,0.0000289396,0.0000325431,0.0000344431,0.0000333581,0.0000297724,0.0000256719,0.0000232159,0.0000234769,0.0000260252,0.0000292689,0.0000312323,0.0000305725,0.0000274598,0.0000235556,0.0000208833,0.0000205699,0.0000223903,0.0000250907,0.0000270255,0.0000268888,0.0000245043,0.0000210875,0.000018415,0.0000176113,0.0000186525,0.0000206803,0.0000224893,0.0000229019,0.000021395,0.0000186677,0.000016177,0.0000149982,0.0000152855,0.0000165867,0.0000181916,0.0000191149,0.000018512,0.0000165548,0.0000143599,0.0000129276,0.000012555,0.000013165,0.000014534,0.0000158876,0.0000160998,0.0000148657,0.0000129981,0.0000114223,0.0000105418,0.0000105894,0.0000117571,0.0000134455,0.0000142913,0.0000136192,0.0000120292,0.0000103999,9.20804*10^-6,8.90906*10^-6,9.98279*10^-6,0.0000119153,0.0000131483,0.0000127878,0.0000113584,9.74472*10^-6,8.47082*10^-6,8.11189*10^-6,9.26401*10^-6,0.0000113633,0.0000126963,0.0000123374,0.0000109064,9.3632*10^-6,8.25912*10^-6,8.17564*10^-6,9.62188*10^-6,0.0000118203,0.000012945,0.0000122487,0.0000106348,9.21487*10^-6,8.54772*10^-6,9.09781*10^-6,0.0000110663,0.0000132919,0.0000138925,0.0000125211,0.0000105526,9.32172*10^-6,9.36753*10^-6,0.0000109027,0.0000135961,0.0000157529,0.0000155162,0.0000131626,0.0000107069,9.75865*10^-6,0.0000107928,0.0000136236,0.0000171774,0.0000191241,0.0000177518,0.0000141711,0.0000111629,0.0000106266,0.0000129044,0.0000172576,0.0000216974,0.0000232339,0.0000204642,0.0000155096,0.0000119739,0.0000120098,0.0000157303,0.0000216963,0.0000269007,0.0000277722,0.0000234185,0.0000170818,0.0000131483,0.0000139225,0.0000191729,0.0000266498,0.0000323315,0.0000322612,0.0000262685,0.0000187195,0.0000146189,0.0000162587,0.0000229503,0.0000316008,0.000037322,0.0000360748,0.0000285839,0.0000201923,0.0000162308,0.0000187689,0.0000265874,0.0000358375,0.0000410694,0.0000385343,0.0000299253,0.0000212457,0.0000177555,0.000021086,0.0000294887,0.0000385878,0.0000428113,0.0000390708,0.0000299529,0.0000216567,0.0000189327,0.0000228023,0.0000310861,0.0000392347,0.0000420573,0.0000374097,0.0000285341,0.000021288,0.000019523,0.0000235719,0.0000310124,0.0000375351,0.000038791,0.0000337031,0.0000258056,0.0000201218,0.0000193602,0.0000232043,0.0000292277,0.0000337383,0.0000335339,0.0000285325,0.000022157,0.0000182685,0.0000183955,0.0000217204,0.0000260417,0.0000285313,0.0000272103,0.0000227513,0.0000181274,0.0000159479,0.0000167255,0.0000193539,0.0000220184,0.0000228182,0.0000208507,0.0000172182,0.0000142504,0.0000134414,0.0000145815,0.0000164881,0.0000177985,0.0000174337,0.0000152762,0.0000125511,0.0000109148,0.0000110238,0.0000122648,0.0000135413,0.0000139169,0.0000129276,0.0000109173,9.01633*10^-6,8.30148*10^-6,8.89899*10^-6,0.0000100554,0.0000108503,0.0000106919,9.50391*10^-6,7.82257*10^-6,6.57486*10^-6,6.40567*10^-6,7.16874*10^-6,8.14135*10^-6,8.60627*10^-6,8.21702*10^-6,7.09626*10^-6,5.79527*10^-6,5.01389*10^-6,5.11097*10^-6,5.8423*10^-6,6.60103*10^-6,6.85917*10^-6,6.42795*10^-6,5.50012*10^-6,4.5507*10^-6,4.07673*10^-6,4.26498*10^-6,4.87088*10^-6,5.42821*10^-6,5.56594*10^-6,5.18801*10^-6,4.48472*10^-6,3.82361*10^-6,3.54108*10^-6,3.72838*10^-6,4.18349*10^-6,4.57192*10^-6,4.6435*10^-6,4.35255*10^-6,3.85484*10^-6,3.41314*10^-6,3.24569*10^-6,3.39435*10^-6,3.71047*10^-6,3.96784*10^-6,4.00462*10^-6,3.80047*10^-6,3.46885*10^-6,3.18544*10^-6,3.08611*10^-6,3.18886*10^-6,3.39344*10^-6,3.5553*10^-6,3.57424*10^-6,3.44177*10^-6,3.23332*10^-6,3.05918*10^-6,3.00022*10^-6,3.06376*10^-6,3.18717*10^-6,3.28334*10^-6,3.29322*10^-6,3.21342*10^-6,3.09013*10^-6,2.98825*10^-6,2.95355*10^-6,2.98889*10^-6,3.05797*10^-6,3.11154*10^-6,3.11673*10^-6,3.0722*10^-6,3.004*10^-6,2.94775*10^-6,2.92784*10^-6,2.94539*10^-6,2.98096*10^-6,3.00864*10^-6,3.01132*10^-6,2.98845*10^-6,2.95351*10^-6,2.92455*10^-6,2.91369*10^-6,2.92137*10^-6,2.93804*10^-6,2.95116*10^-6,2.95251*10^-6,2.94182*10^-6,2.92545*10^-6,2.91174*10^-6,2.90622*10^-6,2.90907*10^-6,2.91606*10^-6,2.92168*10^-6,2.92234*10^-6,2.9179*10^-6,2.91102*10^-6,2.90518*10^-6,2.90262*10^-6,2.90344*10^-6,2.90597*10^-6,2.90808*10^-6,2.90838*10^-6,2.90679*10^-6,2.90429*10^-6,2.90212*10^-6};          cwd = ContinuousWaveletTransform[data, GaborWavelet[6], {Automatic, 12}];     ListDensityPlot[Abs[cwd[All, "Values"]], PlotRange -> Automatic,        ClippingStyle -> Automatic, ColorFunction -> "TemperatureMap"]      ![enter image description here](http://i.stack.imgur.com/U0B4F.png) I'm interested in a weak frequency component in the signal. The zoom out of above figure looks like               ListDensityPlot[Abs[cwd[All, "Values"]],       PlotRange -> {{100, 400}, {20, 28}, {Min[Abs[cwd[All, "Values"]]],          0.02 Max[Abs[cwd[All, "Values"]]]}}, ClippingStyle -> Automatic,       ColorFunction -> "TemperatureMap", AspectRatio -> 1/GoldenRatio]      ![enter image description here](http://i.stack.imgur.com/xoXmJ.png) . From this plot, the weak signal is not easy to see because there are "stripes" from the other strong signal. However, if we use a higher order of wavelet, for the same region, we can see clearly the weak signal               cwd2 = ContinuousWaveletTransform[data, GaborWavelet[10], {Automatic, 12}];     ListDensityPlot[Abs[cwd2[All, "Values"]],       PlotRange -> {{100, 400}, {20, 28}, {Min[Abs[cwd2[All, "Values"]]],          0.02 Max[Abs[cwd2[All, "Values"]]]}}, ClippingStyle -> Automatic,       ColorFunction -> "TemperatureMap", AspectRatio -> 1/GoldenRatio]      ![enter image description here](http://i.stack.imgur.com/U9yDG.png) **Question** :   1. Why there are strong "stripes" in the low order wavelet case? Are those "stripes" a "true" feature of my signal or it's an artificial effect from the wavelet transform?   2. In general, what are the guide lines to choose the order of the wavelet?


FullSimplify inconsistent

I'm having problems using `FullSimplify` to simplify a differential equation. The expression is simplifying just as I would like when I express a variable `c` as a function, but not when I leave it by itself. It boils down to this:               FullSimplify[       1 - (4 H n (c[x]^(-1 + 2 n)) )/(K^n + c[x]^n)^2 + (4 H n (c[x]^(-1 + n)))/(K^n + c[x]^n)]      Gives the expected output: > >     1 + (4 H K^n n c[x]^(-1 + n))/(K^n + c[x]^n)^2 >   However, when I replace `c[x]` with just `c`, the output changes completely and refuses to simplify. The output then is: > >     (c^(1 + 2 n) + c K^(2 n) + 2 c^n K^n (c + 2 H n))/(c (c^n + K^n)^2) >   I don't understand why _Mathematica_ is behaving inconsistently, or what I am doing wrong. I've tried adding assumptions about `c`, using things like `Part`, and searching the web to no avail. Can anyone help?


Problem with Maximize

As $\\{p1,p2,p3,p4,p5\\}$ represents a probability distribution and $l1,l2$ are the eigenvalues of a stochastic matrix, the function $f$, as defined below, has to be maximized over a certain region.               L[p_List] := (p[[1]] - 0.2)*Log[p[[1]]] + (p[[2]] - 0.2)*     Log[p[[2]]] + (p[[3]] - 0.2)*Log[p[[3]]] + (p[[4]] - 0.2)*     Log[p[[4]]] + (p[[5]] - 0.2)*Log[p[[5]]]          CirculantMatrix[l_List?VectorQ] :=      NestList[RotateRight, RotateRight[l], Length[l] - 1]     CirculantMatrix[l_List?VectorQ, n_Integer] :=      NestList[RotateRight,      RotateRight[Join[Table[0, {n - Length[l]}], l]], n - 1] /;      n >= Length[l]          invFou[l_List] := 0.2*{1 + 2 l[[1]] Cos[2 Pi/5] + 2 l[[2]] Cos[4 Pi/5],      1 + 2 l[[1]] Cos[4 Pi/5] + 2 l[[2]] Cos[2 Pi/5],      1 + 2 l[[1]] Cos[4 Pi/5] + 2 l[[2]] Cos[2 Pi/5],      1 + 2 l[[1]] Cos[2 Pi/5] + 2 l[[2]] Cos[4 Pi/5],      1 + 2 l[[1]] + 2 l[[2]]}          m[l_List] := CirculantMatrix[invFou[l]]          f[p_List, M_List] := L[p.m[M]]/L[p]      We may assume that $l1=0.5$ and $0.37\leq l2 \leq 0.5$. If we try               Maximize[{f[{p1, p2, p3, p4, p5}, {0.5,      l2}], {p1 + p2 + p3 + p4 + p5 == 1 && p1 >= 0 && p2 >= 0 &&      p3 >= 0 && p4 >= 0 && p5 >= 0 && 0.37 <= l2 <= 0.5}}, {p1, p2, p3, p4, p5, l2}]      we get an error: > NMaximize::nrnum: The function value -0.206184-0.256075 I is not a real > number at {l2,p1,p2,p3,p4,p5} = > {0.446053,-0.0362605,0.263705,0.324533,0.369047,0.0789762}. >> Why doesn't _Mathematica_ take the maximum over the specified region?


How can I prevent these warnings while using ParallelTable

I have this code to find all the permutations of a set of letters that form legal words.               <<Combinatorica`     Module[{str = "abc", chars, len, r, check},      chars = Characters[str];      len = StringLength[str];      r = Range[len];      check[n_Integer] :=        DictionaryLookup[{"BritishEnglish",          StringJoin[chars[[UnrankPermutation[n, r]]]]}, 1];      DistributeDefinitions[check, chars, r];      ParallelTable[check[i], {i, 1, len!}]]      I've verified that, if I replace ParallelTable with Table, I get this:               {{}, {}, {}, {"cab"}, {}, {}}      With ParallelTable, however, in addition to that result, I also get warnings like these:               Part::pspec: Part specification Combinatorica`UnrankPermutation[1,{1,2,3}] is neither a machine-sized integer nor a list of machine-sized integers.          Part::pspec: Part specification Combinatorica`UnrankPermutation[2,{1,2,3}] is neither a machine-sized integer nor a list of machine-sized integers.          StringJoin::string: String expected at position 1 in StringJoin[{a,b,c}[[Combinatorica`UnrankPermutation[1,{1,2,3}]]]].          StringJoin::string: String expected at position 1 in StringJoin[{a,b,c}[[Combinatorica`UnrankPermutation[2,{1,2,3}]]]].      These warnings seem to come from kernel 7 and higher. My guess is that the computation reaches those kernels and there isn't any data left, since there are only 6 permutations, and causes them to spit out those warnings. Is my understanding correct? How do I prevent these warnings?


Is it possible to define a function in terms of a power series?

Is it at all possible to define a function in Mathematica in terms of a power series? For a specific example, I wish to write $x(\tau)$ as $x(\tau)=x_{0}(\tau)+\mu x_{1}(\tau)+\mu^{2}x_{2}(\tau)+\cdots$ (I'm okay with truncating terms, as long as I can determine how many terms I keep.) Thanks in advance. EDIT: I am looking to use these symbolically to plug into a differential equation and solve for each $x_i$ after grouping coefficients of powers of $\mu$. (Along with another power series $\omega = \omega_0 + \mu\omega_1+\mu^2\omega_2\cdots$ where each $\omega_i$ is constant.) It's important to note that each $x_i$ is a separate function of $\tau$, which is why the basic Mathematica tutorials I have seen have been of no help.


Checking powers of a matrix for zeros

I'm currently working on a project that deals with numerical semigroups and their connection to matrices. I'm pretty new to _Mathematica_ , so I wouldn't be surprised if my question has a simple solution; nevertheless I can't find it haha! I need code that will check the entries in a matrix to see if any of them are zero, and if there is at least one zero in the matrix, take the next power of the matrix and check it again until all of the entries are non-zero. All of the matrices I am working with **WILL** become completely non-zero, so I don't need to worry about an infinite loop or anything. I was thinking that I could just multiply all of the elements in the given matrix and if the product = 0, then loop back through. Either that or scan elements of the matrix individually since the matrices aren't any bigger than 5 x 5. Any help is greatly appreciated! P.S, -- If anyone has a method of then checking individual elements of a matrix to see if they are nonzero, and if they are, then adding the current power of that matrix to a set of numbers, I would be grateful to hear how it could be done. This is secondary to the above question though.