Two-sided slider getting stuck

I'm implementing a two-sided slider to be able to set upper and lower bound in just one slider: ![enter image description here](http://i.stack.imgur.com/lx6DI.png) The problem is that it can get stuck when both locators are at the far left: ![enter image description here](http://i.stack.imgur.com/DtxmR.png) And I'm unable to grab the blue locator.               SetAttributes[TwoSidedSlider, HoldAll];     TwoSidedSlider[sliderMin_, sliderMax_, var1_, var2_,        maxIsInfinity_: False] := DynamicModule[       {pt = {{var1, 0}, {If[var2 == Infinity, sliderMax, var2], 0}}},       LocatorPane[        Dynamic[pt,         ((* Update while dragging \*)           pt = #1;           var1 = #1[[1, 1]];           var2 =             If[maxIsInfinity && #1[[2, 1]] == sliderMax,              Infinity, #1[[2, 1]]];           ) &         ],        Graphics[{          Gray, Line[{{sliderMin, 0}, {Dynamic[pt[[1, 1]]], 0}}],(* min to lower \*)          Black,           Line[{{Dynamic[pt[[1, 1]]], 0}, {Dynamic[pt[[2, 1]]], 0}}], (* lower to upper \*)          Gray,           Line[{{Dynamic[pt[[2, 1]]], 0}, {sliderMax, 0}}] (* upper to max \*)          }, AspectRatio -> 1/5],        { (* Locator Region and stepsize \*)         {{sliderMin, 0},          {Dynamic[pt[[2, 1]]], 0}, {1, 1}},         {{Dynamic[pt[[1, 1]]], 0},          {sliderMax, 0}, {1, 1}}         }        , Appearance -> {Style["[", Red, Larger, Bold],           Style["]", Blue, Larger, Bold]}]]      It is used something like this:               lower = 0; upper = Infinity;     {{Dynamic[lower], TwoSidedSlider[0, 5000, lower, upper, True],         Dynamic[upper]}} // TableForm      Any tips on how to get a two-sided slider or what causes this one to get stuck?


Orthogonalize method, keeping to binary vectors

The built in function: `Orthogonalize[m]` where m is a list of vectors returns a orthogonal basis for m. However, I want to stick to the binary field. However, I tried this: `Orthogonalize[m,Mod[#1.#2,2]&]` But this just still gives a set of vectors with negative coordinates. Can anyone please help. Thanks.


Span of a set of vectors over a given field

Could anyone help me find a function that takes as inputs: a set $S$ of vectors and an integer $q$ and outputs: the Span of $S$, where $Span[S]$ is a vector space over the field $F_q$. If its simpler, could someone tell a method for $q=2$ (binary vectors) case. Thanks.


Plotting two functions with dependent input function

I have defined a function:               myJ2[n_] := 1/n* Total[RandomVariate[NormalDistribution[0, 1], n]^2]      This is basically an approximation to the gaussian integral. I want to plot this and the error graph (difference between the approximation and the exact value) at the same time. Using a random variable makes this difficult. I tried this:               DiscretePlot[{myJ2[n], 1 - myJ2[n]}, {n, 1, 1000}, Filling -> None, Joined -> True]      However, this is not quite correct, since the myJ2 function is called twice and hence gives different values due to the randomness. I improved this by using:               DiscretePlot[{x, 1 - x} /. x -> myJ2[n], {n, 1, 1000}, Filling -> None, Joined -> True, PlotStyle -> {Red, Blue}]      This gives me the correct values but both in the same color. How can I get both the function and the error function displayed in two graphs or with two different colors? Thanks Charly


Area of a convex polygon with a set of points

I have a set of points               Pts[a_,b_,c_]:={{a, b}, {b, a}, {c, a}, {a, c}, {b, c}, {c, b}}      which define a convex polygon and I would like to find its area. There is a simple method but it requires listing the points in counterclockwise order, but I don't know (in general) how to put them in this order. (Leaving them in their given order produces a self-intersecting polygon with a too-small area.) What can I do here? I could imagine a sorting routine of some kind (find the middle and order by $\theta$? but probably there could be issues) or maybe there is some built-in method. In any case I certainly don't want to iterate over possible orders, since those grow very quickly and clearly it isn't the right thing to do. An answer addressing my special case is sufficient, but I would be interested in a general method that works with an arbitrary set of points defining a convex polygon.


Strange result when integrating BesselJ functions

Consider the following integral:               FullSimplify[Integrate[r BesselJ[m,BesselJZero[m,n]r /a]^2,{r,0,a}],      Assumptions->n\[Element]Integers&&n>=1&&m\[Element]Integers]     (* ConditionalExpression[1/2 a^2 BesselJ[-1+m,BesselJZero[m,n]]^2,m>-1] *)      This gives part of the orthogonality condition of `BesselJ` functions (see here, Eq. 53). What I can't figure out is the reason for the `ConditionalExpression`. Mathematica knows about the relationship:               FullSimplify[BesselJ[-m,x]==(-1)^m BesselJ[m,x],Assumptions->m\[Element]Integers]     (* True *)      and can even calculate the integral given `m=-1`, for example, explicitly:               Integrate[r BesselJ[-1, BesselJZero[-1, n] r /a]^2, {r, 0, a}]     (* 1/2 a^2 (BesselJ[0,BesselJZero[-1,n]]^2+BesselJ[1,BesselJZero[-1,n]]^2-      (2 BesselJ[0,BesselJZero[-1,n]] BesselJ[1,BesselJZero[-1,n]])/BesselJZero[-1,n]) *)      But, trying to force `Integrate` to assume `m<=-1` throws an error:               Integrate[r BesselJ[m,BesselJZero[m,n]r /a]^2,{r,0,a},      Assumptions->n\[Element]Integers&&n>=1&&m\[Element]Integers&&m<=-1]     (* Integrate::idiv: Integral of r BesselJ[m,(r BesselJZero[m,n])/a]^2      does not converge on {0,a}.*)      So, why can't it solve it for any (integer) `m` in the first (or negative integers in the last) scenario? * * * **Edit** Additional strangeness based on belisarius's comment. If you directly integrate something like:               Integrate[r BesselJ[15,BesselJZero[15,n] r/a]^2,{r,0,a},Assumptions->n\[Element]Integers&&n>=1]      it outputs a giant monstrosity. Yet, this monstrosity is (nearly) equivalent to the smaller expression:               N[(% /. n -> 1)]-      N[(1/2 a^2 BesselJ[-1 + 15, BesselJZero[15, n]]^2 /. n -> 1)]     (* 6.12357*10^-16 a^2 *)      It seems that it uses a different method for integrating these functions with an explicit value for `m` than without. And for some reason doesn't use the `(-1)^m` `BesselJ` identity for solving the `m<=-1` cases. * * * **Edit 2** Based on J.M.'s answer this gets stranger. First of all, integrating:               Integrate[r BesselJ[m,BesselJZero[m,n] r/a]^2,{r,0,a},      Assumptions->n\[Element]Integers&&Positive[n]&&m\[Element]Integers&&Negative[m]]      works fine. As does,               Integrate[r BesselJ[m,BesselJZero[m,n] r/a]^2,{r,0,a},      Assumptions->n\[Element]Integers&&n>=1&&m\[Element]Integers&&Negative[m]]      and even               Integrate[r BesselJ[m,BesselJZero[m,n] r/a]^2,{r,0,a},      Assumptions->n\[Element]Integers&&n>=1&&m\[Element]Integers&&m<0]      But,               Integrate[r BesselJ[m,BesselJZero[m,n] r/a]^2,{r,0,a},      Assumptions->n\[Element]Integers&&n>=1&&m\[Element]Integers&&m<=-1]      fails with the error from above. Furthermore, even though               Integrate[r BesselJ[m,BesselJZero[m,n] r/a]^2,{r,0,a},       Assumptions->n\[Element]Integers&&n>=1&&m\[Element]Integers&&Negative[m]]==      Integrate[r BesselJ[m,BesselJZero[m,n] r/a]^2,{r,0,a},       Assumptions->n\[Element]Integers&&Positive[n]&&m\[Element]Integers&&Positive[m]]          (* True *)      the timing to solve these are _way_ different. With               Integrate[ snip Positive[m]];//Timing     Integrate[ snip Negative[m]];//Timing          (* {15.538, Null}         {0.421, Null} *)      which is a _huge_ increase in time for essentially the same integral. Any further ideas?


Updating values in a Dataset

I'm starting to work with datasets. They seem like a useful addition to Mathematica. However, there's one fairly major stumbling block I can't get over. How do I update data in a dataset? I have a dataset created from JSON data. It uses a Month/Day/Year format, which I'd like to convert to YYYMMDD. Date format conversions are easy, but I don't know how to assign that data back into my dataset (or create a new one based on that if they're immutable).               Import["http://msi.nga.mil/MSI_JWS/ASAM_JSON/getJSON?typename=\     DateRange_AllRefNumbers&fromDate=19900101&toDate=20140801",         "JSON"];      Needs["GeneralUtilities`"]     asamdataset = Dataset[ToAssociations@asamjson];          td=asamdataset;      I would think something like this would work, but I get an error that Date is protected.               td[[2]]["Date"] =      DateList[{asamdataset[[2]]["Date"], {"Month", "Day", "YearShort"}}]      What am I missing here? The documentation on Dataset is extensive, except for updating values. Which I expect a lot of people will need to do when loading messy datasets.


How do I use a matrix that has a variable?

I seem to be getting an error whenever I try running this piece of code.                Matrix12[n_] := {{1, 0}, {0, {\[Kappa]1[n]}/{\[Kappa]2[n]}}}      I've already defined the n dependent functions kappa1 and kappa2 but it still doesn't work. I keep getting a 'Tag list in...... is protected'. Is it that this functionality is not supported by the program itself or is my code wrong in how it's written?


`Trigger` autorunning when not supposed to

Recently I was trying to make something where one could vary the parameters and press play to see how the animation changed. However, when I tried running the code it would just start automatically. Even if I pressed pause nothing would happen. I managed to narrow the problem down and have made a simple example to illustrate the issue. If I run the following code I get what I want. (i.e. press play and it starts. Press pause and it stops)               Clear[step,MyAnimation,dynamicVar]     step=0;     dynamicVar={1,2};     MyAnimation[nothing_,something_]:=Module[{},step++;something+{step,step}]     Manipulate[         dynamicVar=MyAnimation[time,{1,2}];         Dynamic@dynamicVar,         {{time,1,""},1,\[Infinity],1,ControlType->Trigger,AnimationRate->2}     ]      However, if I replace `dynamicVar=MyAnimation[time,{1,2}]; ` with `dynamicVar=MyAnimation[time,dynamicVar];` what I get is something which runs automatically and which one cannot not stop. (I know they give two different results, but the issue lies in the fact that I cannot stop it)               Clear[step,MyAnimation,dynamicVar]     step=0;     dynamicVar={1,2};     MyAnimation[nothing_,something_]:=Module[{},step++;something+{step,step}]     Manipulate[         dynamicVar=MyAnimation[time,dynamicVar];         Dynamic@dynamicVar,         {{time,1,""},1,\[Infinity],1,ControlType->Trigger,AnimationRate->2}     ]      Any advice on how to fix this problem?


Optimization of a portfolio of stocks

I would like to use _Mathematica_ to perform an optimization of a portfolio composed by 10 stocks. I did the first part to compute yields and expected yields, but I don't know how to finish the optimization.               portf = {"AAPL", "BA", "IBM", "BMW.DE", "DIS", "R", "PEP", "BRBY.L", "AXP", "BTI"}          priceShift = FinancialData[#, "Price", {{2004}, {2011}, "Month"}][[All, 2]] & /@ portf      I am interested in the minimization of the portfolio variance (i.e. risk) for a given return.


Is it possible to replicate the "magic" of OptionPatterns[] with DynamicModule's local variables?

Creating richer interactive interfaces that are generated by a `DynamicModule` invariably requires more complex data structures and in particular, a larger argument space as specified by `DynamicModule`'s local variables. Managing the extra functionality within `DynamicModule`'s body then inevitably involves the need for ongoing code modularization which in turn requires repeated passing down of this argument space. Here's an example for a 2-element argument space.               SetAttributes[Component1,HoldAll];     SetAttributes[Component2,HoldAll];     SetAttributes[Component3,HoldAll];     Component1[x_,y_]:=Button["Increase x",x++];     Component2[x_,y_]:=Button["Decrease y",y--];     Component3[x_,y_]:={Dynamic@x,Dynamic@y};          DynamicModule[{x=1,y=2},     Row[{Component1[x,y],Component2[x,y],Component3[x,y]}]]      This is not a problem for only 2 arguments but becomes a serious issue for larger argument spaces both for reading and writing code. For writing not only does the whole argument space need to be re-typed each time a new piece of modularization or functionality is added, but any changes to this argument space (as part of ongoing design changes for example) then requires changes throughout the code base. The reading issue revolves around a function's arguments clogging valuable space while distracting from the function's logic. Ideally what is needed is to replicate the "magic" of `OptionsPattern[]` but for local `DynamicModule` variables in which these variables can be modified in a single place and have the effects automatically cascade (a bonus would be for the syntax colouring to be maintained in the body of any function accessing variables in this space). Roughly - with `obj` denoting the variable space - something like:               (* not correct syntax *)          Component1[obj] := Button["Increase x", x++];     Component2[obj] := Button["Decrease y", y--];     Component3[obj] := {Dynamic@x, Dynamic@y};          obj = {x = 1, y = 2};          DynamicModule[obj,     Column[{Component1[obj], Component2[obj], Component3[obj]}]]


how to export nested list

I have a ListPlot where I extract my data again using `pts1 = Cases[(*I put my list plot here*), , x_Point :> First@x, Infinity];` which gives me the data as nested list                   { {{0.03, 2.21325*10^22}, {0.06, 3.64418*10^22}, {0.1, 4.778*10^22}, {0.4, 7.90494*10^22},            {1., 9.8882*10^22}, {3., 1.20734*10^23}}, {{0.03, 1.24205*10^22}, {0.06, 1.7829*10^22},            {0.1, 2.14653*10^22}, {0.4, 2.96566*10^22}, {1., 3.39166*10^22}, {3., 3.80355*10^22}},            {{0.03, 7.93772*10^21}, {0.06, 1.05402*10^22}, {0.1, 1.21384*10^22}, {0.4, 1.54018*10^22},            {1., 1.69508*10^22}, {3., 1.83693*10^22}}}      How can I export this data, so that I have a file with 3x2 colums for the three data sets, so something like               0.03, 2.21325*10^22,  0.03, 1.24205*10^22,0.03, 7.93772*10^21     0.06, 3.64418*10^22, etc.     0.1, etc.     etc.


What is the status of `::Usage` and Templates in Mathematica v10?

In Mathematica 9, a number of issues concerning the `::Usage` and templates were raised. In 9.0, there was a bug first reported here and better diagnosed here, where error messages were generated by simply moving the insertion point somewhere in the argument of a function for which a `::Usage` was defined. This was fixed in 9.0.1 In both 9.0 and 9.0.1, it was reported here and here that functions with formatted `::Usage` needed `?Function` to be called twice in order for messages to be rendered properly. A bandaid solution was given here. Certain inflexibility about the text in the templates was raised here, and inconsistencies reported here. The consensus I gather from the discussion in the comments above is that `::Usage` and templates are implemented in _Mathematica_ in a very kludgy way. This can be a source of major frustration for package developers. So the question I raise is which of the issues have been addressed in v10? Are there plans for a major overhaul of the `::usage` system?


Assigning an analytical approximation to the error function erf(x)

Working with some iterative integral equations I have Gaussian density functions involved therein. Integrating the gaussian function I obrain the error function. When I take the second integration, _Mathematica_ is not able to provide an analytical expression. Because apparently there is no closed- form expression for the integral of the error function. **Question:** Is it possible the tell Mathematica to consider the error function as some given exact expression which is analytically integrable? For example $$erf(x)=\frac{1}{(1+a_1x+a_2x^2+a_3x^3+a_4x^4)^4}$$ for some appropriate constants $a_1$, $a_2$, $a_3$, $a_4$?


How does GroupActionBase affect the order of elements in a group?

**Related (math.SE):** How does the base of a group determine the “sort” of the elements in the group The help page for `GroupActionBase` says: >   * A base of a group is a list of points of its domain of action such that > the only element in the group fixing them all is the identity. >   * Reordering the points in a base gives a different base. >   * The choice of base affects the ordering of group elements in the > functions `GroupElements` and `GroupElementPosition`. >   * If the list of points given is not a base, Mathematica will add more > points until obtaining a base. In particular, `GroupActionBase -> {}` will > make Mathematica choose an appropriate base. > It doesn't explain **how** the order of points in a base affects the order of the elements in a group. Since this is pretty much exactly what you need to know in order to use `GroupActionBase`, at a minimum should have been included in the help file. ;-) They do include a single example (that wasn't very illuminating for me), which I'll include below for easy reference. So bullet 1 specifies that a base needs enough points such that only the group identity will fix all the points in the base, and bullet 4 says if you don't provide a full base, Mathematica will add points (via some unspecified methodology) until it's a base, but this doesn't explain how the order of the points in the base relates to the order of the elements of the group. From bullet 1 and the example, it's apparent that a base is a flat list of the same positive integers that the `Cycles` notation operates on. However, the group $S_n$ (the example below is contained inside $S_4$) operates on a set of $n$ elements, and there are $n!$ ways to order them in a base. But $S_n$ itself has $n!$ group elements, meaning there are $(n!)!$ ways to order the elements of the group. **Can anyone clarify how specification of a base via`GroupActionBase` effects the order of the group elements reported by `GroupElements` and `GroupElementPosition`?**    **Basic Examples (1)**               Elements of a group in standard order:          In[1] := GroupElements[PermutationGroup[{Cycles[{{1, 2}, {3, 4}}], Cycles[{{1, 3}}]}]]     Out[1]:= {Cycles[{}], Cycles[{{2, 4}}], Cycles[{{1, 2}, {3, 4}}],               Cycles[{{1, 2, 3, 4}}], Cycles[{{1, 3}}], Cycles[{{1, 3}, {2, 4}}],               Cycles[{{1, 4, 3, 2}}], Cycles[{{1, 4}, {2, 3}}]}          In[2] := OrderedQ[%, Less]     Out[2]:= True          Sort them, specifying different priorities with a base:          In[3] := GroupElements[PermutationGroup[{Cycles[{{1, 2}, {3, 4}}], Cycles[{{1, 3}}]}],                GroupActionBase -> {4, 2}]     Out[3]:= {Cycles[{}], Cycles[{{1, 3}}], Cycles[{{2, 4}}],                Cycles[{{1, 3}, {2, 4}}], Cycles[{{1, 4}, {2, 3}}],                Cycles[{{1, 2, 3, 4}}], Cycles[{{1, 4, 3, 2}}],                Cycles[{{1, 2}, {3, 4}}]}


Splitting a list by specifying section headers

I have a list of strings called `mylist`:               mylist = {"[a]", "a", "a", "[b]", "b", "b", "[ c ]", "c", "c"};      I would like to split `mylist` by "section headers." Strings that begin with the character `[` are section headers in my application. Thus, I would like to split `mylist` in such a way as to obtain this output:               {{"[a]", "a", "a"}, {"[b]", "b", "b"}, {"[ c ]", "c", "c"}}      (The `a`s, `b`s, and `c`s represent _any_ characters; the string inside the section header does _not_ necessarily match the strings that follow in that section. Also, the number of strings in each section can vary. I have tried:               SplitBy[mylist, StringMatchQ[#, "[" ~~ ___] &]      But this is not correct; I obtain:               {{"[a]"}, {"a", "a"}, {"[b]"}, {"b", "b"}, {"[ c ]"}, {"c", "c"}}      Likewise, using `Split` (since it applies the test function only to adjacent elements) does not work. The command:               Split[mylist, StringMatchQ[#, "[" ~~ ___] &]      yields:               {{"[a]", "a"}, {"a"}, {"[b]", "b"}, {"b"}, {"[ c ]", "c"}, {"c"}}      Do you have any advice? Thanks.


How to get $x$ in terms of $y$ and $w$ from $w = a p x^{p-1} \left(a x^p+b y^p\right)^{\frac{1}{p}-1}$

I'm having trouble to solve the following equation for $x$ both manually and in _Mathematica_ : $\quad \quad w = a p x^{p-1} \left(a x^p+b y^p\right)^{\frac{1}{p}-1}$ In _Mathematica_ notation:               w == (((a (x^p) + b (y^p))^((1/p) - 1))*p*a*(x^(p - 1)))


Custom File Palette

I find the default Mathematica IDE lacking. I am missing a simple project file tree on the left (as in eclipse, visual studio etc.) The following would be very cool: All your files (in a given directory) would be displayed in a Mathematica Palette. Clicking them changes to the clicked file or opens it. Has anyone seen something like this? Can anyone put together a quick proof of concept? It should not be that difficult ...


kernel stops evaluation, clears variables

I am using the new Mathematica 10 student edition. As I am evaluating a table of integrals and calling NIntegrate repeatedly, the evaluation stops without error and the kernel clears all variables. I have no idea what is going on, is this a memory issue?


Transforming parametric representation of coordinates into cartesian coordinate system

Is it possible in Wolfram Mathematica to transform output of BSplineFunction so it returns results in cartesian coordinates not in parametric representation? * * * Thank you for your responce. I should have clarified the question better. The question is: can I find coordinates that corespond to a given value of function. For example, I have F(x,y,z,k). Let's say that substitution of several points such as (x1,y1,z1,k1),(x2,y2,z2,k2),(x3,y3,z3,k3),...,(xn,yn,zn,kn) gives the same value of fucntion F: F(x1,y1,z1,k1)=F(x2,y2,z2,k2)=...=F(xn,yn,zn,kn). I need to know all these points (x1,y1,z1,k1)... in cartesian coordinate system.


Keyboard shortcut to evaluate notebook

(If this is entirely trivial, although I couldn't find an answer as much as I searched the archives, I will delete the question.) How could I add a keyboard shortcut to evaluate the entire notebook instead of going to `Evaluation -> Evaluate Notebook` again and again ?


Fitting data to a Poisson distribution

I'm trying to fit a Poisson Distribution to data produced in a lab. I've successfully made a Histogram of the data, which looks like: ![enter image description here](http://i.stack.imgur.com/hWS4S.png) However, when I try to fit the Poisson Distribution using:               Show[       Histogram[poisson, {0, 9, 1}, "PDF",          ChartLegends -> {"Experimental Result"}, ChartStyle -> "Pastel"],       DiscretePlot[PDF[PoissonDistribution[2.2766917293233084`], x], {x, 0, 10},          PlotStyle -> {Red, Medium},          PlotLegends -> {"Theoretical Poisson"}],         AxesLabel -> {"Time (s)", "Counts"}]      I get a fit that alters the y-axis: ![enter image description here](http://i.stack.imgur.com/bkz0P.png) Where the red dots represent the Poisson fit. I have several questions:   1. Is my fit even representative of my data?    2. How can I change the y-axis of the Poisson distribution?    3. How can I get a $\chi ^2$ value for this distribution?  **Edit:** Here is the data for reference:               {1., 1., 1., 2., 1., 1., 2., 2., 1., 2., 1., 4., 2., 3., 6., 0., 0.,       3., 3., 3., 3., 0., 0., 0., 3., 1., 5., 3., 1., 3., 5., 2., 2., 1.,      0., 4., 2., 3., 4., 3., 3., 2., 0., 4., 0., 0., 0., 2., 2., 7., 0.,      2., 3., 2., 1., 4., 3., 7., 1., 1., 4., 5., 0., 2., 1., 1., 3., 2.,      3., 3., 3., 4., 0., 2., 2., 2., 5., 4., 2., 0., 0., 3., 2., 2., 2.,      0., 2., 1., 1., 1., 3., 4., 2., 2., 2., 1., 0., 3., 3., 1., 2., 5.,      0., 1., 2., 2., 4., 2., 2., 0., 2., 4., 4., 1., 2., 4., 1., 2., 1.,      1., 0., 5., 3., 4., 2., 2., 1., 1., 1., 7., 1., 1., 3., 3., 0., 4.,      2., 5., 4., 0., 1., 4., 0., 2., 3., 1., 4., 1., 1., 1., 1., 2., 0.,      4., 0., 2., 1., 4., 1., 4., 4., 2., 7., 3., 2., 3., 0., 0., 1., 2.,      0., 2., 2., 2., 3., 1., 4., 1., 3., 3., 2., 3., 1., 3., 2., 2., 6.,      0., 2., 1., 3., 1., 1., 3., 3., 4., 2., 0., 5., 3., 2., 2., 5., 5.,      1., 2., 2., 2., 8., 3., 2., 5., 2., 5., 3., 1., 8., 3., 1., 3., 3.,      2., 3., 3., 4., 2., 4., 2., 7., 2., 1., 1., 1., 4., 5., 2., 4., 2.,      3., 1., 2., 0., 1., 2., 2., 3., 3., 2., 3., 0., 1., 4., 0., 2., 2.,      1., 1., 4., 1., 1., 2., 2., 1., 1., 2., 0., 7., 1., 4., 2., 4., 2.,      6., 5., 2., 3., 1., 3., 5., 0., 2., 1., 2., 3., 1., 4., 2., 1., 2.,      2., 3., 2., 0., 2., 5., 2., 2., 1., 2., 1., 5., 2., 4., 2., 3., 0.,      2., 0., 4., 3., 2., 2., 1., 1., 1., 2., 4., 1., 4., 2., 0., 0., 6.,      4., 1., 2., 4., 0., 0., 0., 5., 3., 3., 1., 0., 1., 1., 4., 0., 0.,      1., 2., 5., 2., 0., 0., 3., 3., 4., 1., 3., 1., 4., 1., 0., 4., 2.,      1., 6., 0., 4., 1., 2., 3., 5., 3., 4., 3., 2., 2., 3., 3., 4., 3.,      1., 3., 2., 5., 1., 5., 4., 1., 2., 5., 1., 2., 2., 0., 1., 3., 1.,      3., 1., 3., 2., 3., 4., 0., 0., 2., 1., 5., 0., 2., 3., 3., 3., 1.,      3., 2., 8., 2., 1., 2., 2., 1., 1., 1., 4., 0., 1., 3., 3., 2., 2.,      2., 2., 2., 3., 2., 2., 4., 6., 3., 5., 4., 4., 4., 1., 2., 1., 3.,      4., 1., 3., 4., 0., 1., 1., 4., 3., 3., 1., 0., 2., 2., 0., 3., 1.,      2., 1., 1., 0., 1., 0., 1., 4., 0., 3., 1., 2., 4., 3., 1., 1., 4.,       1., 5., 2., 4., 1., 3., 2., 2., 2., 3., 3., 3., 0., 3., 2., 6., 1.,      8., 3., 3., 2., 2., 2., 3., 1., 2., 0., 6., 0., 2., 2., 0., 3., 4.,      1., 1., 2., 3., 3., 2., 0., 3., 2., 2., 5., 3., 5., 1., 2., 3., 1.,      3., 1., 2., 0., 3., 0., 3., 5., 4., 1., 2., 0., 0., 2., 5., 1., 1.,      3., 2., 4., 2., 3., 2., 2., 4., 2., 0., 1., 3., 4., 1., 3., 1., 2.,      3., 3., 1., 1., 3., 3., 2., 3., 4., 0., 2., 1., 3., 1., 1., 0., 1.,      2., 1., 2., 1., 3., 3., 6., 3., 4., 2., 1., 3., 1., 3., 3., 1., 7.,      1., 1., 4., 3., 3., 3., 3., 3., 3., 4., 4., 3., 3., 3., 1., 3., 3.,      1., 3., 0., 5., 3., 3., 1., 1., 1., 4., 2., 1., 2., 4., 2., 2., 3.,      4., 3., 2., 4., 2., 3., 1., 6., 1., 3., 2., 0., 3., 1., 2., 1., 2.,      5., 2., 2., 1., 3., 4., 1., 2., 3., 1., 3., 4., 5., 1., 1., 3., 0.,      1., 1.}


How can I get a running sum for a list?

I've got following data I'm reading from a file:               data = {{{2013, 1, 11}, 4},        {{2013, 1, 12}, 1},        {{2013, 1, 14}, 1},        {{2013, 1, 16}, 2},        {{2013, 1, 18}, 1},        {{2013, 1, 19}, -1, 16},        {{2013, 1, 20}, 2},        {{2013, 1, 21}, 2}        };      (notice that list elements may have an extra item.) Now I want a similar datelist with each time the accumulated sum (ignoring possible third elements after a data item, like the 16 in the example). Procedurally I'd do something like this:               tally = 0;     datelisttally = {};     For[i = 1, i <= Length[data],       tally = tally + data[[i]][[2]];        datelisttally = Append[datelisttally, {data[[i]][[1]], tally}]; i++];     DateListPlot[datelisttally, PlotRange -> {0, Automatic}, Joined -> True]      but I'd like to learn the best way to do this with functional programming, best being the fastest. (The file may hold several thousands of items.) **update**   I've benchmarked the 3 current solutions, and these are the results (list length = 1 million elements, averaged over 50 runs):   * Szabolc's: **0.33 s**   * PlatoManiac's: 0.54 s   * Leonid's: 3.33 s


Ways to compute inner products of tensors

One way to evaluate the following sums is combining Table and Sum: $u_{abcd} = \sum_{e=1}^3 v_{aeb}w_{ced}$ $q_{ab} = \sum_{d,e=1}^3 v_{d e a}w_{deb}$ It will look like               v = Table[Times[i, j, k], {i, 3}, {j, 3}, {k, 3}]     w = Table[Times[i+2, j-1, k+1], {i, 3}, {j, 3}, {k, 3}]          u = Table[Sum[v[[a, e, b]] w[[c, e, d]], {e, 3}], {a, 3}, {b, 3}, {c, 3}, {d,  3}]     q = Table[Sum[v[[d, e, a]] w[[d, e, b]], {d, 3}, {e, 3}], {a, 3}, {b, 3}]      Is there a more elegant way to evaluate sums like these?


How to dynamically name and date a file for export?

I have various functions that export Excel and text files, and need to have them named with a name based on the content of some variables in the function and the time and date. How can this be done with Mathematica?


Using variables in file names during import/export

I have 23 .csv files named as 0.csv, 1.csv.... I'd like to import those files one by one, perform some manipulation on the data and finally export it as "i+20".csv. "i" is the variable which in my case goes from 0 to 22.


How to set FindGraphCommunities Modularity's method option

It is possible to set 2 options for one of FindGraphCommunities's methods "Modularity". They are "Weighted" and "StopTest". The question is how can one use the second option "StopTest"? What values/pure functions does it take?


Integrate boundaries defined as equations

Have you guys ever needed to define Integrate boundaries as equations? I tried to submit the equation as was written in original text but it seems that mathematica can't understand it.               kb = 0.001872041; Na =  6.02214129*10^23;     ep = 10.22; p = 2.56;          pot2[r_] := 4 ep ((p/r)^12 - (p/r)^6)          f[r_, T_] := Exp[-pot2[r]/(kb T)] - 1         B3[T_] := -8 \[Pi]^2/3  Na^2 \!\(     \*UnderoverscriptBox[\(\[Integral]\), \(0\), \(\[Infinity]\)]\(     \*UnderoverscriptBox[\(\[Integral]\), \(0\), \(\[Infinity]\)]\(     \*UnderoverscriptBox[\(\[Integral]\), \(Abs[r12 - r13]\), \(r12 +             r13\)]f[r12, T]\ f[r13, T]\ f[r23,             T]\ r12\ r13\ r23\ \[DifferentialD]r12 \[DifferentialD]r13 \     \[DifferentialD]r23\)\)\)      Original Text ![enter image description here](http://i.stack.imgur.com/7xVkV.gif) ![enter image description here](http://i.stack.imgur.com/OQyGW.gif)


Calculate the covariance of a large matrix

I have to compute the covariance of 50 very large integer matrices (2500x2000 elements). However, according to my estimation this will take around 10 days. Do you have any ideas how to speed things up?


What is the best way to export a table of numerics with legends ready for Word?

I want to put my table output into an MS Word document without having to edit it in word after, so I want to export it ready for Word in final version with complete legends and title. Is it possible to do that in Mathematica 9? After getting table output, what procedure should I follow to put it into Word? I want to set alignment in my Math file and export in Word document. Here is example of what I to do when I have big matrix.                 Table[N[1/(i + j)], {i, 1, 10}, {j, 1, 10}] // MatrixForm


How find the first element of a list greater than zero (or another criterion) when there is a symbol in the list?

I need to find the position of the first element of a list that is either greater than zero (or some other criterion) or a symbol. Something like                lst={0,0,k,1,4}      and as result                position = 3      If there was no symbol the following command would do the job                First[Flatten[Position[lst, _?(Abs[#] > 0 &)]]]      If I add `|| MatchQ[_Symbol]` the answer will always be zero. Many thanks


Adding precision for the calculation of a function

I have some function $f(x)$ I wish to evaluate, which is yielding divide-by- zero errors for sufficiently large inputs. How do I increase the precision with which this function is evaluated in order to prevent this? Can I do this while also plotting the function?


Contour plots of a two-variable function depicting the values of its integral

Given a two-variable function `f[x,y]`, how to get the contour plots corresponding to several values of the integral of the original function. For example, I would like to plot the contours $C_j$ of the domains $S_j$, in the $xy$ plane, such that $$ \int_{S_j} dxdy f(x,y) = \alpha_j $$ for $\alpha_j = \alpha_{j-1} + \epsilon$, with a fixed step $\epsilon$. Additionally, I would like to be able to choose a value of $\alpha$ and plot the contour of the corresponding domain. **My difficulty is the following.** I don't know how to make a condition inside `ContourPlot` such that it tells that the contours should correspond to the values of the integrals. A possible application would be to determine the region corresponding to 68.3% of the events of a two-variable Gaussian distribution. This is called a 1-sigma region.


Correct way to generate large data sets (i.e.forward yield curve )

I would like to generate a set of forward yield curve matrix of size 1000 x 100. First I defined my SparseArray of 1000 x100:               (forwardYieldCurve=Normal[SparseArray[{{1,1}->0,{1000,100}-> 0}]])//MatrixForm;        then initial first row of forwardYieldCurve using:               Table[forwardYieldCurve[[1,j]]=tenor0[[1,j]]+driftM[[1,j]]tstep+       (volFit1[[1,j]]dX[[1,1]]+volFit2[[1,j]]dX[[1,2]]+volFit3[[1,j]]dX[[1,3]])Sqrt[tstep]       +((tenor0[[1,j+1]]-tenor0[[1,j]])/(dateArray[[1,j+1]]-dateArray[[1,j]]))tstep,{j,99}];//AbsoluteTiming        then for the second row and iterate with i (in BOLD) up to 100 rows of the forwardYieldCurve matrix:               Table[forwardYieldCurve[[i+1,j]]=forwardYieldCurve[[i,j]]+driftM[[1,j]]tstep+      (volFit1[[1,j]]dX[[i+1,1]]+volFit2[[1,j]]dX[[i+1,2]]+volFit3[[1,j]]dX[[i+1,3]])Sqrt[tstep]+       ((forwardYieldCurve[[i+1,j+1]]-forwardYieldCurve[[i+1,j]])/(dateArray[[1,j+1]]-dateArray[[1,j]]))tstep,{j,99},{i,**100**}];//AbsoluteTiming        takes around 4 minutes to do to obtain results of 100 x 100, which will be projected take it to around 40 minutes to run this single set of simulations. When I eventually set i to iterate up to 1000 x 100, and furthermore, I will repeat this many times to get a statistically monte-carlo simulation of distributions. How to optimize this to reduce run time. My input data dimensions:               forwardYieldCurve -> {1000,100}       tenor0={{0.0050399,0.00537318,0.00578648,0.00614997,0.00633987,0.00637105,0.00632311,0.00625459,0.00622594,0.00631663,0.0065289,0.00679745,0.00706621,0.00731132,0.0075159,0.00766905,0.00778107,0.00786696,0.00793966,0.00800508,0.00806759,0.00813158,0.00820143,0.00828151,0.00837543,0.00848368,0.00860596,0.00874199,0.00889147,0.00905412,0.00922964,0.00941775,0.00961814,0.00983054,0.0100546,0.0102902,0.0105368,0.0107941,0.0110615,0.0113385,0.0116248,0.0119197,0.0122228,0.0125336,0.0128516,0.0131763,0.0135073,0.013844,0.0141859,0.0145327,0.0148838,0.0152389,0.0155975,0.0159592,0.0163236,0.0166903,0.0170588,0.0174287,0.0177995,0.0181709,0.0203931,0.0225666,0.0246436,0.0265946,0.0283977,0.0300428,0.0315247,0.0328461,0.0340124,0.035033,0.0359187,0.0366814,0.0373332,0.0378862,0.0383519,0.0387395,0.0390575,0.0393143,0.0395184,0.0396782,0.0398011,0.0398898,0.0399458,0.0399704,0.0399652,0.0399316,0.039871,0.0397848,0.0396746,0.0395418,0.0393879,0.0392142,0.0390222,0.0388134,0.0385892,0.0383511,0.0381006,0.037839,0.0375678,0.0372885}}       driftM = {{4.29874*10^-6,8.59748*10^-6,0.0000128962,0.000017195,0.0000214937,0.0000257924,0.0000300912,0.0000343899,0.0000386887,0.0000429874,0.0000472861,0.0000515849,0.0000558836,0.0000601824,0.0000644811,0.0000687798,0.0000730786,0.0000773773,0.000081676,0.0000859748,0.0000902735,0.0000945723,0.000098871,0.00010317,0.000107468,0.000111767,0.000116066,0.000120365,0.000124663,0.000128962,0.000133261,0.00013756,0.000141858,0.000146157,0.000150456,0.000154755,0.000159053,0.000163352,0.000167651,0.00017195,0.000176248,0.000180547,0.000184846,0.000189144,0.000193443,0.000197742,0.000202041,0.000206339,0.000210638,0.000214937,0.000219236,0.000223534,0.000227833,0.000232132,0.000236431,0.000240729,0.000245028,0.000249327,0.000253626,0.000257924,0.000283717,0.000309509,0.000335302,0.000361094,0.000386886,0.000412679,0.000438471,0.000464264,0.000490056,0.000515849,0.000541641,0.000567433,0.000593226,0.000619018,0.000644811,0.000670603,0.000696396,0.000722188,0.000747981,0.000773773,0.000799565,0.000825358,0.00085115,0.000876943,0.000902735,0.000928528,0.00095432,0.000980113,0.0010059,0.0010317,0.00105749,0.00108328,0.00110907,0.00113487,0.00116066,0.00118645,0.00121224,0.00123804,0.00126383,0.00128962}}       tstep = 0.01       volFit1={{0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226,0.00718226}}       volFit2={{-5.97435*10^-6,-5.77847*10^-6,-5.58514*10^-6,-5.39435*10^-6,-5.20606*10^-6,-5.02029*10^-6,-4.83699*10^-6,-4.65618*10^-6,-4.47782*10^-6,-4.3019*10^-6,-4.12841*10^-6,-3.95734*10^-6,-3.78867*10^-6,-3.62238*10^-6,-3.45846*10^-6,-3.2969*10^-6,-3.13768*10^-6,-2.98078*10^-6,-2.8262*10^-6,-2.67392*10^-6,-2.52391*10^-6,-2.37618*10^-6,-2.23069*10^-6,-2.08745*10^-6,-1.94643*10^-6,-1.80762*10^-6,-1.671*10^-6,-1.53656*10^-6,-1.40429*10^-6,-1.27417*10^-6,-1.14618*10^-6,-1.02032*10^-6,-8.9656*10^-7,-7.74893*10^-7,-6.55303*10^-7,-5.37775*10^-7,-4.22296*10^-7,-3.08849*10^-7,-1.97421*10^-7,-8.79963*10^-8,1.94392*10^-8,1.249*10^-7,2.28402*10^-7,3.29958*10^-7,4.29584*10^-7,5.27294*10^-7,6.23103*10^-7,7.17026*10^-7,8.09077*10^-7,8.9927*10^-7,9.87622*10^-7,1.07415*10^-6,1.15886*10^-6,1.24177*10^-6,1.3229*10^-6,1.40226*10^-6,1.47986*10^-6,1.55573*10^-6,1.62987*10^-6,1.7023*10^-6,2.10178*10^-6,2.44338*10^-6,2.73027*10^-6,2.96562*10^-6,3.1526*10^-6,3.29436*10^-6,3.39409*10^-6,3.45494*10^-6,3.4801*10^-6,3.47271*10^-6,3.43596*10^-6,3.37301*10^-6,3.28703*10^-6,3.18118*10^-6,3.05863*10^-6,2.92256*10^-6,2.77613*10^-6,2.6225*10^-6,2.46485*10^-6,2.30635*10^-6,2.15015*10^-6,1.99943*10^-6,1.85736*10^-6,1.72711*10^-6,1.61183*10^-6,1.51471*10^-6,1.43891*10^-6,1.38759*10^-6,1.36392*10^-6,1.37108*10^-6,1.41223*10^-6,1.49054*10^-6,1.60917*10^-6,1.77129*10^-6,1.98008*10^-6,2.2387*10^-6,2.55031*10^-6,2.91809*10^-6,3.3452*10^-6,3.83481*10^-6}}       volFit3={{1.85601*10^-6,1.86013*10^-6,1.8634*10^-6,1.86583*10^-6,1.86742*10^-6,1.8682*10^-6,1.86815*10^-6,1.86729*10^-6,1.86563*10^-6,1.86316*10^-6,1.85991*10^-6,1.85587*10^-6,1.85105*10^-6,1.84546*10^-6,1.8391*10^-6,1.83199*10^-6,1.82412*10^-6,1.81551*10^-6,1.80616*10^-6,1.79608*10^-6,1.78528*10^-6,1.77375*10^-6,1.76152*10^-6,1.74858*10^-6,1.73494*10^-6,1.72062*10^-6,1.70561*10^-6,1.68992*10^-6,1.67356*10^-6,1.65653*10^-6,1.63885*10^-6,1.62052*10^-6,1.60154*10^-6,1.58193*10^-6,1.56169*10^-6,1.54082*10^-6,1.51934*10^-6,1.49724*10^-6,1.47454*10^-6,1.45125*10^-6,1.42737*10^-6,1.4029*10^-6,1.37786*10^-6,1.35224*10^-6,1.32607*10^-6,1.29933*10^-6,1.27205*10^-6,1.24422*10^-6,1.21586*10^-6,1.18697*10^-6,1.15756*10^-6,1.12763*10^-6,1.09719*10^-6,1.06625*10^-6,1.03481*10^-6,1.00289*10^-6,9.70481*10^-7,9.37598*10^-7,9.04246*10^-7,8.70433*10^-7,6.58225*10^-7,4.31082*10^-7,1.90459*10^-7,-6.21896*10^-8,-3.25408*10^-7,-5.97743*10^-7,-8.77739*10^-7,-1.16394*10^-6,-1.45489*10^-6,-1.74914*10^-6,-2.04524*10^-6,-2.34172*10^-6,-2.63713*10^-6,-2.93002*10^-6,-3.21893*10^-6,-3.50241*10^-6,-3.77901*10^-6,-4.04726*10^-6,-4.30572*10^-6,-4.55292*10^-6,-4.78742*10^-6,-5.00776*10^-6,-5.21248*10^-6,-5.40014*10^-6,-5.56927*10^-6,-5.71842*10^-6,-5.84613*10^-6,-5.95096*10^-6,-6.03144*10^-6,-6.08613*10^-6,-6.11356*10^-6,-6.11228*10^-6,-6.08084*10^-6,-6.01778*10^-6,-5.92165*10^-6,-5.791*10^-6,-5.62436*10^-6,-5.42028*10^-6,-5.17731*10^-6,-4.894*10^-6}}       randomWalkPCA[n_]:=  RandomVariate[NormalDistribution[0,1],n];       RandVarPCA[mcRun_]:=Table[randomWalkPCA[3],{mcRun}];        (dX:=RandVarPCA[1000])//MatrixForm;       dateArray={{0.0833333,0.166667,0.25,0.333333,0.416667,0.5,0.583333,0.666667,0.75,0.833333,0.916667,1.,1.08333,1.16667,1.25,1.33333,1.41667,1.5,1.58333,1.66667,1.75,1.83333,1.91667,2.,2.08333,2.16667,2.25,2.33333,2.41667,2.5,2.58333,2.66667,2.75,2.83333,2.91667,3.,3.08333,3.16667,3.25,3.33333,3.41667,3.5,3.58333,3.66667,3.75,3.83333,3.91667,4.,4.08333,4.16667,4.25,4.33333,4.41667,4.5,4.58333,4.66667,4.75,4.83333,4.91667,5.,5.5,6.,6.5,7.,7.5,8.,8.5,9.,9.5,10.,10.5,11.,11.5,12.,12.5,13.,13.5,14.,14.5,15.,15.5,16.,16.5,17.,17.5,18.,18.5,19.,19.5,20.,20.5,21.,21.5,22.,22.5,23.,23.5,24.,24.5,25.}}


How to transform the result of this integral into powers of $\sin\,x$?

I want to calculate the integral $I = \displaystyle\int{\cos ^5 x\, \mathrm dx}$. Using the variable $t = \sin x$, I get $$I = \sin x - \frac{2}{3}\sin^3 x + \frac{1}{5}\sin^5 x + C.$$ With _Mathematica_ , when I input                Integrate[Cos[x]^5, x]      I get               (5 Sin[x])/8 + 5/48 Sin[3 x] + 1/80 Sin[5 x]      How to format the result in the form? $$I = \sin x - \frac{2}{3}\sin^3 x + \frac{1}{5}\sin^5 x.$$ Similar questions with integral $I =\displaystyle \int{\dfrac{\mathrm{d}x}{1 + \sin x + \cos x}}$ by setting $t = \tan\dfrac{x}{2}$, we have $I = \ln \left|1 + \tan\dfrac{x}{2}\right|$. I tried               (Integrate[1/(1 + Sin[x] - Cos[x]), x] // TrigExpand) /. {Sin[x] ->           2*Tan[x/2]/(1 + Tan[x/2]^2),          Cos[x] -> (1 - Tan[x/2]^2)/(1 + Tan[x/2]^2)} //        Simplify // TraditionalForm      and get the result `log(sin(x/2)+cos(x/2))-log(cos(x/2)).` How to format the result in the form?   $$I = \ln \left|1 + \tan\dfrac{x}{2}\right|$$.


Making fractals with Mathematica

I recently saw this post on math.stackexchange and was curious as to how to generate the image in _Mathematica_. I tried the following naive approach; however, it is extremely slow.               Clear[check, GaussianIntegerQ]     GaussianIntegerQ[a_] := If[IntegerQ[Re[a]] && IntegerQ[Im[a]], True, False]     check[a_] := Block[{d = 0},Do[If[GaussianIntegerQ[c (1 + I)/a], d++], {c, 1, 100}]; d];     ArrayPlot[ParallelTable[If[a != 0 || b != 0, check[a + b I], 0], {a, -1, 1, 1/100},               {b,-1, 1, 1/100}], ColorFunction -> (GrayLevel[#] &)] // AbsoluteTiming          (*{22.5931794, img}*)      I tried making it faster, but the speed-up wasn't much:               Clear[check]     check[a_, b_] := Block[{d = 0},Do[If[IntegerQ[(a c + b c)/(a^2 + b^2)] &&          IntegerQ[(a c - b c)/(a^2 + b^2)], d++], {c, 1, 100}]; d]     ArrayPlot[ParallelTable[If[a != 0 || b != 0, check[a, b], 0], {a, -1, 1,1/100},                {b, -1, 1, 1/100}], ColorFunction -> (GrayLevel[#] &)] // AbsoluteTiming          (*{15.5660219, img}*)      Could anyone offer suggestions on how to make it faster? (for what it's worth, here is C-code from a comment on the blog post) The final result should look something like: ![enter image description here](http://i.stack.imgur.com/VpSTi.jpg)


Is it possible to use custom GUI magnifications?

I am running Mathematica 7 on Windows XP Pro. I often use the magnification feature to zoom in on `Plot`s, `ListPlot`s, and `Graphics` that I have created. If I go to the **Window** menu, there is a **Magnification** option, which gives a submenu with the following options:   * 50%   * 100%   * 125%   * 150%   * 200%   * 300% Is it possible to use a magnification of, for example, 110%?


How to modify MagnificationPopUp menu values in notebooks

The default options in a MagnificationPopUp menu (50, 75, 50, 100, 125, 200, 300) are sometimes not sufficient to meet all user's needs. This may have more applicability when creating user interfaces. Anyone knows how to modify this menu? In other words, I'm asking if it is possible to modify the Notebook's menu such that it contains other values than the listed above. I'm not asking how to modify the Magnification of a Notebook which is formally referenced as MagnificationPopUp in the WindowElements.


Alternative Math Font

Are there other fonts that can be used for mathematical symbols? I have noticed, that choosing another font (via Stylesheet) does not change the math font (e.g. for greek symbols). Symbols will just stay the same most of the time. I suspect that MMA is just substituting missing symbols in the new font with the ones from "Times" (or an internal one, surely it is "Mathematica1"). Choosing "Courier" will result in different greek symbols, this is the only one I found. Which fonts include the neccessary symbols?


How to set the timeout of the preemptive link?

I apologize if this is a RTFM question, but I couldn't find this in the docs. **How can I set the timeout of the preemptive link?** For example:               Button["TestShort", Pause[1]; Print["Result"], Method -> "Preemptive"]     Button["TestLong", Pause[10]; Print["Result"], Method -> "Preemptive"]      Clicking on `TestLong` times out on my system.


Plotting a sum as a function of its upper bound

Apologies if this is easy to find in the documentation, but is there a quick way of doing the following up to any given 'n'?               a=     Im[n^ZetaZero[1]] + Re[n^ZetaZero[1]] + Im[n^ZetaZero[2]] + Re[n^ZetaZero[2]] +      Im[n^ZetaZero[3]] + Re[n^ZetaZero[3]] + Im[n^ZetaZero[4]] + Re[n^ZetaZero[4]] +      Im[n^ZetaZero[5]] + ... ;          Plot[{If[a >= 0, (a^2)/n, -(a^2)/n]}, {n, 0, 30}]      For clarity, I include the plot for `n` up to `30`, for `ZetaZero` up to `100`: ![enter image description here](http://i.stack.imgur.com/4Mmgg.gif)


Changing GeometricBrownianMotionProcess function

Since the function `GeometricBrownianMotionProcess` is given by _Mathematica_ I have some technical questions. If we consider the following example:               ListLogPlot[Table[RandomFunction[     GeometricBrownianMotionProcess[0.5"(*" σ"*)",".4(*" μ"*)",10"(*" Startingvalue"*)"],     {0"(*" StartingTime"*)",14"(*" EndingTime"*)",".005(*" ΔTime"*)"}]["Path"],{1}],Joined→True]      whereas `S` constitutes the starting value. Does this given function consider the following dynamics: $dS(t+1)=μS(t)dt+ σS(t) dB(t)$ Whereas $S(t+1)$ is determined by $S(t+1)=S(t) e^{(r-1/2 σ^2 )t+σB(t)}$? If yes, is it possible to change the given `GeometricBrownianMotionProcess` which is represented by `Bt` and split it up into two processes such as, for example, $B_t= \sqrt{ ρ} W_{t0} + \sqrt{ (1-ρ)} W_{ti}$ Where $W_{t0}$ and $W_{ti}$ are independent standard Brownian motions Here $ρ$ is, for example, the mutual dependence among two variables created by the latent variable $W_{t0}$. So is it possible to change the `GeometricBrownianMotionProcess` function this way or do I have to generate two independent Brownian motions and merge them together into $B_t$?


Reading specific entries from a CSV file

This question is related to the following: Speeding up Import and Export in CSV format Stream CSV files Reading periodic elements from a large file I have a set of very large CSV files (a few hundred MB), a sample file is available here. RAM limitations make it quite cumbersome to use Import. I am only interested in a subset of data from the file:   * I want to read data from just a few columns   * I want to read data from every 256th row starting with the 3rd row                  columns = {3, 4, 5, 8, 12}; first = 3; step = 256;      I am interested in methods that minimize memory and speed up import.


Simulation of Circular plate vibrations

I'm trying to simulate the vibration of a circular plate with a free edge. The plate wave equation describes the vertical displacement of the middle surface of the plate $(\zeta)$ as a function of its position $(r,θ)$ and time $(t)$. $$ \rho \frac{\partial^2 \zeta}{\partial t^2} + \frac{Eh^2}{12(1-\nu^2)} \Delta^2 \zeta- \frac{E}{(1-\nu^2)} T \Delta \zeta = 0 $$ where $\Delta = \frac{\partial^2 \zeta}{\partial r^2} + \frac{1}{r}\frac{\partial \zeta}{\partial r}+ \frac{1}{r^2}\frac{\partial^2 \zeta}{\partial \theta^2}$ is the two dimensional Laplacian. The wave equation is solved through a method of separation of variables and produces the solution: $$ \zeta(r,\theta,t)=Acos(\omega_1t+\phi)[B_nJ_n(\lambda r) + D_nI_n(\lambda r)]cos(n\theta) $$ The boundary conditions at the edge of the plate $r=a$ have to satisfy $$ \frac{\lambda^2a^2J_n(\lambda a)+(1-\nu)[\lambda a J'_n(\lambda a) - n^2 J_n(\lambda a)]}{\lambda^2a^2I_n(\lambda a)-(1-\nu)[\lambda a I'_n(\lambda a) - n^2 I_n(\lambda a)]}=\\\frac{\lambda^3a^3J'_n(\lambda a)+(1-\nu)n^2[\lambda a J'_n(\lambda a) - J_n(\lambda a)]}{\lambda^3a^3I'_n(\lambda a)-(1-\nu)n^2[\lambda a I'_n(\lambda a) - I_n(\lambda a)]} $$ How can I simulate/plot this solution in Mathematica? Thanks in advance!


NDSolve accuracy related problem

I want to solve this equation:               sol = NDSolve[{10000 u'[r] (1+u'[r]) -       1.`*^-6 (r + u[r]) (u[r] + r u'[r]) +       10000 r u'[r] u''[r] +       10000 r (1 + u'[r]) u''[r] == 0, 10000 u'[1] == 3.001, 10000 u'[3] == 1}, u, r,        MaxSteps ->Infinity]      the error message is:               FindRoot::sszero: The step size in the search has become less than the tolerance       prescribed by the PrecisionGoal option, but the function value is still greater than       the tolerance prescribed by the AccuracyGoal option. >>      NDSolve::berr: There are significant errors {-0.000159873,0.000479427} in the boundary      value residuals. Returning the best solution found. >>      what option should I add into `NDSolve` to resolve the problem? thanks


Copying a symbol using a subpackage

In this question, there is a beautiful method to copy a symbol. However, i'm not able to use it as an addon to my package. So the main question is > How to rename/copy a function defined in a package by loading one of its sub > packages ? I'll try to explain that in an minimal example Let's say I have a package `A``               BeginPackage["A`"]     f::usage = "My function";     Begin["Private`"];     f[x_] := x^2;     End[]     EndPackage[];      Due to the fact, that `f` was earlier named `g` and I would like my old notebooks still to work (and though I can rewrite my package functions, I would like to have a kind of legacy package (okay I could also just copy my Package and load the old or the new one - despite debugging twice that works)), so I define something like               BeginPackage["A`Sub`"]     SetAttributes[copy,HoldFirst];     new_~copy~org_:=With[{prop={Attributes,UpValues,OwnValues,DownValues,SubValues,NValues,FormatValues,Messages,Options}},ClearAll@new;     Set[#@new,#@org/.HoldPattern@org:>new]&~Scan~prop;]     (* Start copying*)     g~copy~A`f;     EndPackage[];      (using the great idea of the copy from above). Here I'll use `A`f` to avoid shadowing problems (and put this `Sub.m` in the subdirectory `A/` of the `A.m`). But if I now try to use that, say in a notebook (`ATest.nb` inside the same directory as `A.m`)               $Path = Join[$Path, {NotebookDirectory[]}];     Needs["A`"];      Of course `f` works as intended, but loading               Needs["A`Sub`"];      does not make `g` available as a copy of `f` (and does neither report any error). Though, executing the cells of `Sub.m` directly one by one does. Of course, i don't want to specify `g::usage` because that should be obtained by copying from f. I think it might depend on the context, but I can't see why and how. What am I missing here? ## Update As Albert pointed out, rm -rf s solution below should be extended using a `Private`` area for the `copy` function. Then the sub package providing the old names looks like the following               BeginPackage["A`Sub`",{"A`"}];     Begin["Private`"];         SetAttributes[copy,HoldFirst];         new_~copy~org_:=         With[{prop={Attributes,UpValues,OwnValues,DownValues,SubValues,NValues,FormatValues,Messages,Options}},         ClearAll@new;         Set[#@new,#@org/.HoldPattern@org:>new]&~Scan~prop;         ];         (* Start copying*)         A`Sub`g~copy~A`f;     End[]     EndPackage[];      Then the right operand of copy (the original `f`) needs the context `A`` and the left one, `g` (in order not to be private) the context `A`Sub`` (due to the fact that `::usage` should also be copied from `f`.


Collapse a section of a huge function

Is there an elegant way of hiding/collapsing/folding only a portion of a function? If functions could span multiple cells, this would have been straight-forward!


Is it possible to enclose code into collapsible/expandable regions?

In some programming languages (e.g. C#, Visual Basic) there are language constructs that have no effect on the execution of code whatsoever, but exist solely to allow grouping fragments of code into regions (that can be nested, and can have captions). A region can be easily collapsed or expanded in most GUI code editors supporting these languages. The collapsed form displays only the caption of the region inline, but can also display the content summary in a tooltip when hovered by the mouse pointer. Regions sometimes are useful to see a high-level structure of code, while working on a particular piece within a single expanded region. * * * ![Expanded region in C#](http://i.stack.imgur.com/LhmSJ.png) * * * ![Collapsed region in C#](http://i.stack.imgur.com/UBALX.png) * * * > _Question:_ Is there a similar feature in _Mathematica_?


Specifying the size of open circle PlotMarkers in ListPlot

I would like to use `ListPlot` to plot some points. I would like the `PlotMarkers` to be open circles. I can use `PlotMarkers -> Graphics[Circle[]]`, as in the following example, but the circles are too large. Is there a way that I can specify the size of open circles to use in `PlotMarkers`? Thanks for your time.               myData = {{0, 3.0}, {10, 3.1}, {20, 3.2}, {30, 3.0}, {40, 3.0}, {90, 3.0}};          ListPlot[myData, PlotRange -> {{-1, 101}, {2.9, 3.3}}, Joined -> True,       Mesh -> Full, Frame -> True, PlotStyle -> Directive[Red, Thick],        PlotMarkers -> Graphics[{Red, Thick, Circle[]}]]      ![PlotMarkers](http://i.stack.imgur.com/YzEiw.gif)


Convert DelaunayTriangulation-> Graph->AdjacencyMatrix

Is there a way to convert a Delaunay Triangulation into a Graph structure so that one can generate an AdjacenyMatrix of the Delaunay?


Assumptions for RotationMatrix

I'm making C++ program, and in my program I need a rotation matrix around any vector. I wanted to extract `RotationMatrix[fi,{x,y,z}]` output and put it in my program. Unfortunately _Mathematica_ thinks I operate with imaginary components (x,y,z). Because of that the output that I get is in epic dimensions xD. I tried to fix this problem with `RotationMatrix[fi,{Re[x],Re[y],Re[z]}]` but no luck there. Apparently _Mathematica_ doesn't track what type of variable the user defined (real/imaginary). Is there a way to fix this?


Problem with numeric integration

I am having trouble with the `UnitStep` function as in the title. My problem is very simple, but I am not able to get a numerical result. I have               f1[y] = 1/(E^((-1 + y)^2/2)*Sqrt[2*Pi])          g1[y] = (1.0028877725946312*^6*UnitStep[-7.963235463105154 - y])/        E^((-1 + y)^2/2) + (0.12147136083763578*UnitStep[-7.963235463105154 + y])/           E^((-1 + y)^2/2) +               1.001393070562657*                 (0.3484061634773921*Sqrt[E^(-(-1 + y)^2/2)] +                      0.3484061634773921*Sqrt[E^(-(1 + y)^2/2)])^2*                 (-UnitStep[-7.963235463105154 + y] + UnitStep[7.963235463105154 + y])      and I want to solve the problem $$N\left[\frac{1}{2}\int_{-\infty}^{\infty}\left(\sqrt{f1[y]}-\sqrt{g1[y]}\right)^2dy\right]$$ However, I did not get any result although I waited for a long time. I can plot $g1$ without any problem as well as $f1$, but I can not calculate the simple integral.


Collecting terms of even exponents

Say I've got a polynomial of $4$ or $5$ variables (we'll say $d_1$, $d_2$, $d_3$, and $d_4$). How would you collect the terms where each $d$ is raised to an even power? It collects the terms of the polynomial that are of the form $$ d_1^{2 \cdot k_1} \cdot d_2^{2 \cdot k_2} \cdot d_3^{2 \cdot k_3} \cdot d_4^{2 \cdot k_4} $$ for $k_1,\dotsc,k_5$ being integers. Example: $$ d_1^2 \cdot d_2^4 \cdot d_3^2 \cdot d_4^0 + d_1^0 \cdot d_2^3 \cdot d_3^2 \cdot d_4^3 $$ would take the $$ d_1^2 \cdot d_2^4 \cdot d_3^2 \cdot d_4^0 $$ term and not the $$ d_1^0 \cdot d_2^3 \cdot d_3^2 \cdot d_4^3 $$ term.


Why is there a limit of 15 different instruments to be played simultaneously, with Sound / SoundNote?

It seems to be impossible to play more than 15 different instruments simultaneously with the `Sound[{Soundnote[...],...}]` construct. Any guesses why it is so? With up to 15 instruments it works well:               Sound[ Table[ SoundNote[ i, {i - 1, i}, i], {i, 1, 15}]]      (* I would put an image of the output here if it weren't for the "stackexchange reputation system" *) But with 16 or more different instruments this yields no playable result.               Sound[ Table[ SoundNote[ i, {i - 1, i}, i], {i, 1, 16}]]       Does anyone know whether there is any way to instruct the `Sound` function to play more than 15 instruments?


Generate a set of 3D coordinates subject to constraints

Generating a set of random 3D coordinates is ok, e.g.               positions = RandomReal[{0, 10}, {10, 3}];     radius = 1;     Graphics3D[{Red, Sphere[positions, radius]}, PlotRangePadding -> 2,       Lighting -> "Neutral"]      ![Some random 3D points](http://i.stack.imgur.com/zO45s.png) Now I want to add a constraint, so that the distance between any point and its nearest neighbour is fixed. A good way of thinking about it would be like generating a virtual molecule, where the atoms can't be too close to each other, but nor can they be too far apart otherwise they wouldn't be bonded. I had a prototype made in C++ a while back that just iterated over and over, adding a new point each time the randomly generated coordinates happened to fit the constraint. For example, first I placed a single point with random coordinates and called it `i`. Then I created a new point, `j`, with random coordinates. I then defined a distance between point `i` and point `j`:               euclideandistance = Sqrt[         (positions[[i,1]]-positions[[j,1]])^2 +          (positions[[i,2]]-positions[[j,2]])^2 +          (positions[[i,3]]-positions[[j,3]])^2     ]      Then if the constraint, based on `bondlength`,               0.9*bondlength < euclideandistance < 1.1*bondlength      was satisfied, I'd add point `j` and start over with a new point `k`, comparing the distance to its nearest neighbour (which of course could be `i` _or_ `j` now) and repeating... This seems somewhat inefficient...it was a quick-and-dirty prototype after all! Coming from a C++ background to Mathematica, is there a good way to do this in Mathematica that doesn't involve a `While` loop? **Update** Courtesy of Yves Klett, this question (in 2D and with only a lower bound) Efficient way to generate random points with a predefined lower bound on their pairwise Euclidean distance is what I had in mind, I didn't spot it in my search before posting this. I'll go away and have a play myself when I can tomorrow to apply it to my scenario, and post what I come up with when I've done so (though any answers in the meantime are fine! It all adds to the learning experience for me).


Differences between ParametricPlot3D and NIntegrate

I have a function $f : \mathbb{R} \rightarrow \mathbb{R}^3$ defined in a rather nasty way in mathematica however it's a smooth function and what not. I am interested in $f'[t]$ and when I run it through ParametricPlot3D, it shows me what I expect it to look like. When I try run $f'[t]$ or $f[t]$ through NIntegrate however, I always get a NIntegrate::inumr error saying the integrand has evaluated to non-numerical values. What could be the cause of this, why is it that something I can ParametricPlot3D and also manually set up a numerical integration function for isn't working for NIntegrate? Thanks in advance. **Additional information:**               FF[t_] = Sqrt[d2 E^(- 0.2 t) +  d1 E^(0.2 t) - (b5 / (2 * 0.01))]     GG[s_] := -NIntegrate[Sqrt[d2 E^(- 0.2 t) +  d1 E^(0.2 t) - (b5 / (2 * 0.01))], {t, 0, s}]          Asym[t_?NumericQ] :=  FF[t] * {1, 0, 0} - (Sqrt[0.01 b5 + c5])/(FF[t]^2 )     {0, Cos[GG[t] + Arg[beta5] + Pi], Sin[GG[t] + Arg[beta5] + Pi]}      Everything else is just a real number (beta5 a complex number but Arg[beta5] is a number) Both of these work fine (I see a nice smooth curve each time):               ParametricPlot3D[Asym[t], {t, 0, 1}]     ParametricPlot3D[Asym'[t], {t, 0, 1}]      Neither of these work:               NIntegrate[Norm[Asym'[t]], {t, 0, 1}]     NIntegrate[Norm[Asym[t]], {t, 0, 1}]      If I calculate the following, it shows me a value for the first entry but not the second two entries implying it is the GG[t] stuffing things up seeing as GG[t] is not used in the first entry of Asym[t] at all.               NIntegrate[Asym[t], {t, 0, 1}]


How to do memoization together with evaluation of a complicated function

**UPDATE 2** : much shorter version Given a list of paired indices {i, j}={{1,2}, {3,4}, …}, I need to first evaluate a rather complicated function `test[i,j,x]` (because it's too computationally costing) and then assign each copy to a function named after {i, j} with memoization. Specifically, I need an expression (as elegant as possible, though timing is more important) which effectively does the following things:               f12[x_]:=f12[x]=Evaluate[test[1,2,x]]     f34[x_]:=f34[x]=Evaluate[test[3,4,x]]     …       Note that in this example `Evaluate` has no effect (due to memoization), but **I want it to be done first!** * * * **UPDATE 1** Thank @SimonWoods for proposing a `Function` approach and @m_goldberg for proposing a replacement rule approach. However both approaches are not quite satisfying in their own ways. For the `Function` approach, I confirmed that in the simplest MWE (with no indices in `f`) it does assign `x^2` instead of `test[x]` to `f[x]`:               (f[x_] := f[x] = #) &[test[x]]     ?f      But when I want to create `{f12, f34, …}` I have no idea how to generalize this approach because the existence of the extra `#` ruins the function definition               (ToExpression["f" <> ToString[#1] <> ToString[#2]][x_] := ToExpression["f" <> ToString[#1] <> ToString[#2]][x] = #) &[test[x]] @@@ {{1, 2}, {3, 4}}     ?f12      The replacement rule approach does address this issue as shown in @m_goldberg's answer. However as I said the function `test` also depends on `{{1,2}, {3,4}, …}`. Specifically, one can think of this complicated function as either               test[i_, j_, x_]:=Module[{some stuff}, some complicated operations which use {i, j} and return an expression in x]      or               test12[x_]:=Module[{some stuff}, some complicated operations which return an expression in x]     test34[x_]:=Module[{some stuff}, some complicated operations which return another expression in x]      and so on. In other words, I would like to assign the evaluated result of `test12[x]` (or `test[1,2,x]`) to `f12[x]`, that of `test34[x]` (or `test[3,4,x]`) to `f34[x]`, so on so forth. **(I should have made this point more transparent. Apology.)** But the replacement rule approach seems to fail at this requirement: the code               ((ToExpression["f" <> ToString[#1] <> ToString[#2]][x_] :=         ToExpression["f" <> ToString[#1] <> ToString[#2]][x] =          expr;) /. expr -> test[#1, #2, x] &) @@@ {{1, 2}, {3, 4}}      does not give `f12[x_]:=ToExpression[f<>ToString[1]<>ToString[2]][x]=test[1,2,x]`; it gives `expr` instead. So both approaches still do not meet my need yet. * * * My goal is to create a bunch of functions `{f12, f34, …}` on the fly for later calculation. Those functions involve a pre-defined `Module` (let me call it `test`) which gives a rather complicated expression. For simplicity let us first consider the following example:               (ToExpression["f" <> ToString[#1] <> ToString[#2]][x_] :=      ToExpression["f" <> ToString[#1] <> ToString[#2]][x] = x^2;) & @@@ {{1, 2}, {3, 4}}      This example defines functions `f12[x]` and `f34[x]` to be `x^2` with memoization which can be easily seen by using `Downvalues`:               f12[#] & /@ Range[2]; DownValues[f12]          {HoldPattern[f12[1]] :> 1, HoldPattern[f12[2]] :> 4, HoldPattern[f12[x_]] :>      (ToExpression["f" <> ToString[1] <> ToString[2]][x] = x^2)}      The last element of `DownValues[f12]` is of crucial importance as it tells us the expression of `f12[x]` is `x^2`. Now let me use a different approach. I define a function using `Module`               test[x_] := Module[{a}, a = x; FullSimplify[Log[Exp[a^2]], Assumptions -> a > 0]]      which essentially gives me `x^2` upon evaluation. Follow the same strategy let us define `f12` and `f34`:               (ToExpression["f" <> ToString[#1] <> ToString[#2]][x_] :=       ToExpression["f" <> ToString[#1] <> ToString[#2]][x] = test[x];) & @@@ {{1, 2}, {3, 4}}      and look at again the `Downvalues` of `f12`:               f12[#] & /@ Range[2]; DownValues[f12]          {HoldPattern[f12[1]] :> 1, HoldPattern[f12[2]] :> 4, HoldPattern[f12[x_]] :>         (ToExpression["f" <> ToString[1] <> ToString[2]][x] = test[x])}      Note that now the last element of `DownValues[f12]` involves the function `test`. However this is not what I want! The reason is that as I mentioned above in my calculation `test[x]` is a rather complicated expression (which depends on the indices `{{1,2}, {3,4}, …}`) simplified within the `Module`, and I would like to assign the simplified expressions to `{f12, f34, …}` instead of computing them in situ. I tried               (ToExpression["f" <> ToString[#1] <> ToString[#2]][x_] :=       ToExpression["f" <> ToString[#1] <> ToString[#2]][x] =        Evaluate[test[x]];) & @@@ {{1, 2}, {3, 4}}       But `DownValues[f12]` simply gives me               {HoldPattern[f12[1]] :> 1, HoldPattern[f12[2]] :> 4, HoldPattern[f12[x_]] :>       (ToExpression["f" <> ToString[1] <> ToString[2]][x] = Evaluate[test[x]])}      which is not useful. In short, I would like to see any manipulation with `test[x]` that gives me the `DownValues` to be `HoldPattern[f12[x_]] :> (ToExpression["f" <> ToString[1] <> ToString[2]][x] = x^2`. In other words, **I need`test[x]` to be evaluated first and then assigned to `{f12, f34, …}` with memoization.** On this site I think (two of) the best articles talking about memoization are this one and this one, but I think neither solves my problem…


Is there any automatic method for rating function arguments importance?

If I have a function:               y = 2a + 5b + c      It can be easily seen that `b` is the most important parameter, next `a` and last `c`. More explaination: Let`s say we have a function $f(a,b,c,\dots,z)$. It doesn't matter what is the body of the function, but we consider only basic mathematical functions.   And the question is: How fast does $f(a,b,c,\dots,z)$ grow, when $a$ argument is growing?   How fast does $f(a,b,c,\dots,z)$ grows, when $b$ argument is growing? It's easy to rate arguments when we do it manually, we know how different functions grow and we can pick the most important argument easily (in finite time). Is there any automatic method to rate it?


Fitting Vogel's formula for phyllotaxis to the image of a flower

After having read this question I was inspired to investigate how we could take an image of a plant displaying phyllotaxis and fit Vogel's model of phyllotaxis to the image. The theory is very simple. The model is this: $r = c\sqrt{n}$ $\theta = 137.508 n$ And courtesy of shrx we have the original image of the sunflower in that other question, located here. To begin with I wanted to retrieve the positions of the florets in the image, which I did using `LocatorPane`: ![locatorpane](http://i.stack.imgur.com/rm0AS.png) These are the points:               florets = {{182.4,288.},{150.,286.},{166.6,274.5},{181.4,261.},{200.6,274.},{214.6,256.},{234.2,256.},{220.6,279.5},{196.2,247.5},{220.,237.},{238.,235.},{259.2,224.5},{257.8,252.},{261.8,202.5},{284.,193.},{256.8,183.},{274.2,169.5},{257.6,148.5},{247.2,166.5},{233.4,179.},{239.2,196.},{239.4,215.},{224.4,218.5},{223.8,198.},{212.,179.},{222.,163.5},{236.4,152.},{249.4,131.},{250.2,110.5},{268.6,127.},{227.4,82.5},{233.2,102.},{231.,125.},{221.6,142.5},{213.2,123.5},{213.2,102.},{207.4,82.},{196.2,64.},{183.2,84.},{169.4,72.},{194.6,105.},{194.4,122.},{204.,139.5},{203.6,161.},{194.8,178.},{201.4,195.5},{207.2,208.5},{204.2,228.5},{186.2,232.5},{172.,244.},{155.8,258.},{136.,264.},{116.8,259.5},{96.4,252.5},{74.8,246.5},{84.,226.},{102.4,235.},{105.6,215.5},{122.4,221.5},{118.6,239.5},{138.,242.5},{155.4,235.5},{167.6,223.5},{187.8,212.5},{186.4,194.5},{171.6,208.5},{153.2,212.5},{139.8,223.5},{134.,207.},{119.,201.},{120.8,182.},{137.2,185.5},{149.6,193.5},{165.2,193.5},{177.6,178.5},{161.,180.},{165.2,164.5},{184.4,163.5},{188.6,146.5},{178.,136.5},{177.6,114.5},{169.8,97.},{150.2,85.5},{130.4,74.5},{134.2,96.5},{151.8,105.5},{162.,125.},{156.4,140.},{172.4,150.},{149.4,155.5},{145.8,173.5},{130.8,166.5},{124.8,151.},{140.6,140.5},{143.,123.},{121.8,130.},{125.8,111.5},{106.4,110.5},{113.8,89.5},{102.8,129.},{102.4,149.},{110.6,168.},{102.,190.},{91.2,172.5},{80.8,158.},{84.6,136.},{84.8,112.5},{57.4,148.},{64.4,171.5},{48.2,193.5},{65.,210.},{76.2,188.5},{89.8,203.},{123.8,284.}};      Later I will use the fact that $n = (\frac{r}{c})^2$ such that to order the list according to index n, we can use `SortBy[florets,Norm]`. In order to fit Vogel's model to this data I will try to use the following degrees of freedom:   * The constant `c`   * The origin `{x0, y0}`   * Angular offset And I will use `NMinimize`. My _Mathematica_ code for this is as follows:               phi[n_, ang_] := ang n     r[n_, c_] := c Sqrt[n]     pos[phi_, r_, {x0_, y0_}, phi0_] := {x0, y0} + {r Cos[(phi + phi0) Degree], r Sin[(phi + phi0) Degree]}          NMinimize[{       Total[        Norm[#[[2]] - #[[1]]] & /@ Partition[          Riffle[           SortBy[Array[pos[phi[#, ang], r[#, c], {x0, y0}, phi0] &, Length@florets], Norm],           SortBy[florets, Norm]           ], 2]        ],       c > 0, 137 < ang < 138       }, {ang, c, x0, y0, phi0}]      `Riffle` and the `SortBy` trick puts the corresponding points with the same index `n` next to each other. `Partition` finds these pairs and then I measure the difference between them. When the points are almost on top of each other the difference should be very small, instead I get something quite large:               {8318.44, {ang -> 137.055, c -> 1.21577, x0 -> 169.497, y0 -> 176.741,        phi0 -> 41.2544}}      Now `Mean[florets]` gives `{168.811, 178.544}` so the `{x0, y0}` is probably correct. **But why is the fit as bad as it is?** I've worked through this problem using only _Mathematica_. If the problem could be for example precision in the way that I find the positions, please suggest a different way to do it using _Mathematica_. What you see is the best I could do...


how to show or find full path of file listed in the File->Open dialog?

This question was posted 2 days ago at community. I had a good answer but it does not quit do what I wanted. Hence I am trying here to see if someone might know of some other solution. Here is the question: I tend to name some files, which are in different folders, with the same name. Say source.nb But when going back to open a specific file from one folder, using File->Open dialog, it does not show the full path of the file. Even a right-click on the file name, or hovering the mouse over the name, has no pop-up menu to show the full path name. This makes it hard to know in which folder any of these files are in. So I end up opening the wrong file many times. Here is a screen shot: ![Mathematica graphics](http://i.stack.imgur.com/tc9UD.png) I looked at options and did not see a way to change this. It might be there and I have overlooked it. I searched for "file" options. Using V 9.01 on windows. Would any one know of a way to make it either display the full path name, or at least when hovering the mouse over the name, it will display the full path name in a small pop-up help display (which is the common way most applications handle this sort of thing).


Simplify with TransformationFunctions, Bug?

I want to use custom transformation functions in Simplify, but mathematica does not seem to use them properly. Consider the following               t1[a]:=1     t2[b]:=0     FullSimplify[a+b, TransformationFunctions->{t1,t2}]      As intended this evaluates to `1`. However, if I add the standard transformation functions nothing happens:               FullSimplify[a+b, TransformationFunctions->{Automatic,t1,t2}]      This gives `a+b`. Why did Mathematica forget about my custom functions? Ideas?


How to use FindFit to fit an implicit function?

Now I am trying to fit some data with a implicit model function. Firstly, I tried a toy example. # Toy example with input and output               data = {{1, 1}, {2, 1.4}, {3, 1.8}, {4, 2.4}, {5, 2.9}};     fitfunc[a_,b_,x_] := y /. FindRoot[a y + b Log[y] == x, {y, 1}];     FindFit[data, fitfunc[a, b, x], {a, b}, x]      Mathematica gives the following warning message and answer: > FindRoot::nlnum: The function value {0. +1. a-1. x} is not a list of numbers > with dimensions {1} at {y} = {1.}. >>   >  ReplaceAll::reps: {FindRoot[a y+b Log[y]==x,{y,1}]} is neither a list of > replacement rules nor a valid dispatch table, and so cannot be used for > replacing. >>   >  {a -> 0.986636, b -> 1.96879} The fit seems good.               Show[ListPlot[data], ContourPlot[Evaluate[a y + b Log[y] == x /. %], {x, 1, 5}, {y, 1, 4}]]      The fit result: ![enter image description here](http://i.stack.imgur.com/iDJ4l.png) I have read the documentation of Symbolic Evaluation, and tried to use **_NumberQ_** in the function declaration, but I got the same warning message. What am I doing wrong and how to solve this problem to avoid the warning message?


Using "With" outside a function on its parameters

I am making complex 3d graphics, and to clear up functions, I want to use `With` to remove a repeated action. This action occurs many times through many functions, so I want the `With` outside all of them, so I only declare it once. Except Mathematica doesn't seem to like having a `With` outside a function, if it is replacing parameters. A simplified version is shown below:               With[{y = x},      draw[x_] := Cylinder[{{y,0,0}, {y+1,0,1}}, 0.1]      ...(*other functions:See Bottom!!!!!!!!*)     ]      then:               Graphics3D[draw[3]]      If I do the above, it brings the error: ![The Error](http://i.stack.imgur.com/c2VB8.png) So it should go y -> x -> 3. But it only gets half-way. It has changed y to x but I think it is after when the parameters are put in, so x is not changed to 3. Is there a way to keep the `with` outside, so it is only declared once. Also, in case anybody says put the `With` before `cylinder`. No, I don't want to do that, as there are other functions using the values changed by "With" -----------------------EDIT----------------------------- The answers can replace the values for one function, as is shown in the code example, but it doesn't show (although I did say it), that it needs to work through many functions, as shown below. Sorry for the confusion, as causing the first two answers to not fully work.               With[{y = x},      draw1[x_] := Cylinder[{{y, 0, 0}, {y + 1, 0, 1}}, 0.1],       draw2[x_] := Cylinder[{{y, 0, 0}, {y + 1, 0, 1}}, 0.2]      ...(*more functions*)     ]


Visualizing data on a world map - flexible record format

I have a list of members of a team, and I want to create a visualization on a world map. I want to plot them on a map, to see some clustering. The fields are: `Person Name`, `City`, `State`, `Country` City and State may be blank. I'm envisioning using color intensity on the country to reflect how many of the members are on a given country, plus a circle on the cities, with circle size proportional to the count of people on that city. Appreciate any help from the Mathematica experts on this forum, as my last usage of Mathematica is quite dated (v4 or 5) Thanks! * * * **EDIT** The fields I was referring to on the original question are on a spreadsheet. After I started trying to work out a solution, I settled on the following format:               a = {{{"","","India"},25},{{"","","China"},22},{{"New York ", "NY", "United States"},     10}, {{"San Francisco ", "CA", "United States"},      8}, {{"Boston  ", "MA", "United States"}, 4}, {{"Arlington", "MA", "United States"},      2}, {{"Arlington", "VA", "United States"}, 1}, {{"Cambridge", "MA", "United States"},      1}, {{"Needham", "MA", "United States"}, 1}, {{"Acton", "MA", "United States"},      1}, {{"Brooklyn", "NY", "United States"}, 1}, {{"Los Altos", "CA", "United States"},      1}, {{"Miami", "FL", "United States"}, 1}}      As you can see, some records will come with a blank city and state, only country.


Hyperbolic numbers and their polar form

How can I implement Hyperbolic numbers in _Mathematica_? How could I express their polar form? How could I calculate their power?


How do I get the solutions of a cubic equation in trigonometric form?

I know $x^3-3 x+1=0$ has three roots that can be expressed in trigonometric form: $\{2\sin(10^\circ),\,-2\cos(20^\circ),\,2\cos(40^\circ)\}$. How can I get this result with _Mathematica_?


Simplistic Notation example

Notation package looks poorly documented. For example, `GridBoxDividers` option is not documented at all. Can someone give me a simplistic example of a Notation set up? For example, suppose I wish to represent               MyHead[a,b]      as $\frac{a}{b}$ with               GridBox[{{"a"}, {"b"}}, GridBoxDividers -> {"Rows" -> {{False, True}}}]      If I enter               Notation[GridBox[{{ToString[x_]}, {ToString[y_]}},         GridBoxDividers -> {"Rows" -> {{False, True}}}]     \[DoubleLongLeftRightArrow]     MyHead[x_, y_]]         I get an error > Notation::noexbtag: The external representation > GridBox[{{x_},{y_}},GridBoxDividers->{Rows->{{False,True}}}] does not have > an embedded TemplateBox with tag NotationTemplateTag. The Notation statement > Notation[GridBox[{{x_},{y_}},GridBoxDividers->{Rows->{{<<2>>}}}][DoubleLongLeftRightArrow]MyHead[x_,y_]] > may not have been entered using the palette, or the embedded TemplateBox may > have been deleted. The embedded TemplateBox ensures correct parsing and > retention of proper styling and grouping information. >>


Selecting terms containing some expression

Imagine I have an expression like               a*k + (a^2)*b*c + b*e      and I would like to obtain the term containing, for example, some power of a. In that case I would extract the two first terms. If I wanted to obtain the term b*e, I would extract the last. How can I do it? I guess I should use `Cases` or something similar, but I don't understand its syntax.


Plotting a region with polar axes

I want to plot the region of points who satisfy the following equation:               2 < r <= 5 && 3/4 π < θ <= 5/4 π      I have been able to plot region in cartesian coordinates:               h[r_, θ_] := 2 < r <= 5 && 3/4 π < θ < 5/4 π     RegionPlot[h[Sqrt[x^2 + y^2], ArcTan[x, y]], {x, -6, 6}, {y, -6, 6}, PlotPoints -> 100]      ![enter image description here](http://i.stack.imgur.com/pjksH.png) I would like to plot the region with polar axes, but I don't think I can make `PolarPlot` plot a region probably.


Composing two functions in Mathematica

> **Possible Duplicate:**   >  Composition of mappings not working as expected I am new to _Mathematica_ and I am having trouble defining a certain composition of functions. Let `m1` and `m2` be maps such that $m_1: \mathbb{R}^2 \to \mathbb{R}^2$ and $m_2: \mathbb{R}^2 \to \mathbb{R}^2$ where $\mathbb{R}$ is the real line               m1[eta_, zeta_] = {eta^3, zeta^3}      m2[x_, y_] = x^2 + y^2          m3[eta_, zeta_]  = Composition[m2, m1][eta, zeta]      On evaluating the last line, I get the output               (* m2[{eta^3, zeta^3}] *)      But the anwer to this should be `m3[eta,zeta]=eta^6 + zeta^6` How can I do this?


External file Sub Matrix Import

**Is there** a Built-In Mathematica Function to extract a Sub matrix from a huge **external** file? Functions getting pieces of internal nested Lists, (arrays) are in place. Example:               a = {{a1, a2, a3, a4},{b1, b2, b3, b4},{c1, c2, c3, c4}}          Part[a[[1;;2, 3;;4]]]      Give the partial section               {{a3, a4}, {b3, b4}}      Now one example external .csv text file:               a1, a2, a3, a4          b1, b2, b3, b4          c1, c2, c3, c4      The function Import["file",{1;;2, 3;;4} should read in               a3, a4          b3, b4      The external file is just a very large huge two dimensional Array of csv values.


How can I combine two plots that were created in different notebooks?

I have two different programs for simulating a system. when I get the results I have plotting result for each. now I want to combine both drawings so that I compare between them. I want to put both of them on the same picture. How I can do that? for example; I will attach two drawings. ![enter image description here](http://i.stack.imgur.com/YBpJR.jpg) ![enter image description here](http://i.stack.imgur.com/1b5Wc.jpg) my second question is that how to change the color of the line after drawing?


Plot a 2D vector path onto a surface

In my calculus 3 course, we're studying gradients and have a project that takes a combination of 3D Gaussian radial surfaces and a basic parametric path $r(t) = \{x(t),y(t)\}$ to see how the gradient changes and so forth with respect to the coordinates of $r(t)$ on the path. I need to figure out a way to plot the surface and path together. I've got both of them figured out, just can't combine them. Any ideas? So here's what I have so far: 6 Gaussian radials $\lambda e^{-(\epsilon r)^2}$ where $r=||x-x_i||.$ All six are added up to form a "mountain range". A group of hikers are hiking the path $$r(t)=(2.5 + 1.8 \sin(4t),2 - 1.2 \cos(4 t))$$ which is just a simple ellipse. I'm trying to figure out a way to "lay" the path on the surface.


Forest plot with Mathematica 9

Does anyone have experience with or a package for the creation of forest plots in _Mathematica_ 9? ![Grahics](http://2.bp.blogspot.com/--7YzQiUxYTI/TVSoUYwITeI/AAAAAAAALd0/M_OkY9Uc- LQ/s1600/forestplot.png) For instance for subgroup analyses of cox model or meta-analysis (e.g rmeta package in R)?


NDSolve and {C, K, Slot} and other built-ins as a variable name

The following problem is an exploration of what causes the error "Input is not an ordinary differential equation" in Mathematica as it seems to have changed from version 8 to version 9. Specifically I have found that in Mathematica 9 I have come across the issue that               NDSolve[{x'[t] == 5, C'[t] == 5, x[0] == 1, C[0] == 1}, {x, C}, {t, 0, 100}]      gives the error, whereas in version 8 it does not. So something is up, but my question has more to do with if this is a bug in v8 or a bug in v9, that is, I get that `C` is a built in symbol: so is this error a correct catching of an input mistake? If so then               NDSolve[{C'[t] == 5, C[0] == 1}, C, {t, 0, 100}]      Should also give an error and it does not. I really want to understand what is possibly going on, since as an ecologist I have to deal with equations that have `C` in them for "consumer" and I am forced to troubleshoot any issues that might come up with people not understanding the shadowing issue. **Clarification** It has been pointed out that it is bad coding style to use user defined symbols that start with a capital letter, as this will avoid clashes with Mathematica built-in definitions. That is fine, but does that matter? What I am trying to ask more generally is whether the issue is that Mathematica is _specifically_ checking for `C` and related symbols in `NDSolve`? Because I have no problems using symbols that have existing `UpValues/DownValues` as variable names (upper or lowercase) and even `Protected` in the exact same context. What I want to try and understand is are there **semantic** reasons that this fails, ie could I cause the same error with user generated code? Or is this just a hard coded one off that Wolfram is doing for this case? **Further Clarification** If this is just an issue of using built-ins why can I use `C` in `Solve` and even `DSolve`! if it is an error in `NDSolve`? Again seems more and more like a specific check in `NDSolve`. For example                DSolve[{x'[t] == 5, C'[t] == 5, x[0] == 1, C[0] == 1}, {x, C}, t]      Gives back an answer ... so suddenly this same input string is valid ODE again? Now there are other built-ins that have this behavior such as `K` and `Slot`. As a challenge to all that would just tell me to code differently (which I do ... this is a question of **why** Mathematica works this way) can you use any of the reasons that you given to make a user defined symbol that will trigger the same error? If not then I will conclude that Mathematica is specifically checking for such symbols and move on. But I want to be totally clear that this is not just a question about coding _style_ but if there are differences between system symbols and user defined symbols in this context. What if I make a package that has defined symbols in it, will I ever be able to cause the same problem if a naive user shadows some of my imported symbols into their global context? One interesting suggestion is that somehow `NDSolve` is introducing `C` or `K` or `Slot` when it processes the input and that is causing errors. If so then I should never be able to create this problem with user defined symbols, but I do not yet know if this is the correct idea.


Remove failed Solve[] attempts

I can't figure how to replace a failed evaluation with a null value. I am very new to Mathematica. I have an equation that are being processed using the `Solve[]` function and I then need to forward the results to other steps in my process. Some of the equations don't have solutions. This is desired and I want to eliminate those possibilities. After generating a list with all the solutions I process that list like this:               SillySyntax[Rule_] = Quiet[x /. Rule];     Quiet[Curve = Table[SillySyntax[Curves[[i]]], {i, 5}]]      This works fine, but sometimes when errors such as the following happen they break my workflow by not putting a null in there. Instead leaving a ghost of an equation. This is not desired because I know _a priori_ that these errors mean that the system is not physical. How can I remove these aberrations and ensure that `SillySyntax` will output only numbers or empties.               Greater::nord: "Invalid comparison with 0.347148 -1.5103810834566311` I"


Selective deletion of nested list elements centred around a certain value

I have a list which looks like:               test = {{0.01,3}, {0.001,3.1}, {0.002,3.2}, ..., {0.01,7}, {0.001,7.1}, {0.002,7.2}, ...,                  {0.01,10}, {0.001,10.1}, {0.002,10.2}, ..., {0.01,13}, {0.001,13.1}, {0.002,13.2}}      What I would like to do is for every value of the second coordinate that is close to a centre value (near `3`, `7`, `10` or `13`) I only want to keep the ones (pairs) that have the smallest value of the first coordinate. After this transformation the list would become:               {{0.001,3.1}, {0.001,7.1}, {0.001,10.1}, {0.001,13.1}}      Note that when I have entered a break in the test list there is also a spacing in the 2nd coordinate values, so the list runs from say `3 - 3.5` and then skips to `7 - 7.5` and so on; it is not a continuous count. Also, the values of the first coordinates are not equal, as those given in the example above, so the list may end up looking like               {{0.001, 3.1}, {0.005, 7.2}, {0.00001, 10.3}, {0.007, 13.4}}      which is still a correct result.


Functions vs. patterns

Every time I define a new function, I wonder which construct I should use: true functions obtained by using `Function`, or rule-based syntax. For example, these are two ways of defining a square function:               square = Function[x, x^2]     (* Alternatively: square = #^2& *)          square2[x_] := x^2      Is there some fundamental difference (e.g. execution efficiency) between the two approaches?


How to define a formula in FormulaData?

I am looking for a way to manage frequently used formulas in my research, in a organized way in Mathematica. It appears to me that using `FormulaData` would be a standard way to use formulas in Mathematica. Is there a way to define formulas ourselves in `FormulaData`?


Plotting a several variable complex valued function

Consider A function $f:\mathbf{C}^2\rightarrow \mathbf{C}$ defined as $$f_{\alpha, \beta}(z,w)=\frac{\alpha}{z}+\frac{\beta}{w}$$ where $\alpha$ and $\beta$ both are complex number. I want to plot this function for different parameter value $\alpha$ and $\beta$ the function $f_{\alpha, \beta}$. Can anyone help me in coding the same in Mathematica?


How to ask Mathematica to imitate Andy Warhol's pop-art painting?

I tried to ask Mathematica to imitate Andy Warhol, let it convert a Marilyn Monroe's portrait looks like Warhol's world famous pop-art painting. However, the result shown below is far from satisfactory. How to obtain a better result? Warhol's world famous pop-art painting: ![enter image description here](http://i.stack.imgur.com/kIpXd.jpg) Result from the code below: ![enter image description here](http://i.stack.imgur.com/OXwqw.jpg)               im = Import["http://i.stack.imgur.com/RSKpk.jpg"];     images = {{im, im, im, im}, {im, im, im, im}};      Do[images[[n, m]] = ImagePad[ (Colorize[Binarize[im ] ,            ColorRules -> {0 -> RandomColor[], 1 -> RandomColor[]}           ]  ), 6, White] , {n, 1, 2}, {m, 1, 4}] ;          ImageAssemble[images ]


Is it possible to get the transformation PrincipalComponents uses to transform data?

As far as I can see `PrincipalComponents[data]` just gives data in the principal component basis. The problem is that after this, I would like to transform new data into the same basis, which requires that I know the actual principal components. There is the option of calculating `Eigenvectors[Covariance[data]]` (given the data is centered on the origin) but for the eigenvectors I get this way the signs are usually different from the ones that the `PrincipalComponents[]` function uses. Is there an easy way of getting the actual transformation used or transforming new data into the PC basis of the previous dataset?


DateListPlot - ToolTip

I would like to plot some data in time and am trying to format it so that tooltips on mouse over gives the date and a value. Something of the form                   DateListPlot[Tooltip[data,         StringForm["Time: ``, ``= ``", DateString[data[[x, 1]],{"Month","/", "Day", " ", "Hour", ":", "Minute"}],Title, data[[x, 2]]]]]      Is similar to what I want except I need data[[x,1]] or data[[x,2]] to have x as a reference to the current position DateListPlot is in the list so that mouse overs give correct time/value. This example works when I just make x some number 1 <= x <= length(data).


When NSolve fails due to a differential situation?

c = 1.1111;      y[x_] = x - c Sin[x]      NSolve[y[x] == 0, x]      The method has procured no result. Successive derivatives were plotted in an attempt to fix the problem.               Plot[{y[x], y'[x], y'''[x]}, {x, -Pi, Pi}, PlotStyle -> {Thick}, GridLines -> Automatic]          {y[0], y'[0], y''[0], y'''[0]}      This function has a root, a small value of first derivative,and an inflection point respectively@ _x=0_. Method fails due to vanishing first and third derivatives. Is it correct? It appears Newton's iteration fails as derivative value @ _x=0_ is extremely small as next iteration value seeking tangents do not intersect x-axis, failing to converge to a root there. What workaround do we have here? Is (old fashioned) Regula Falsi option available to solve this? This relates to my comments the recent thread:"How to get a solution for the following equation?"


How can Mathematica help me to find a real radical expression for roots of this polynomial?

The polynomial `P(x)=x^4-4x^2-2x+1` has 4 real roots (this can be clearly checked by plotting). But solving `P(x)=0`, using `Solve[x^4-4x^2-2x+1==0,x]` leads to `x=-1` and `3` other roots which (however they're not) seems complex number as they are represented in terms of `i` (the imaginary unit): ![enter image description here](http://i.stack.imgur.com/CDbbm.jpg) But I want to have the roots represented in a real closed radical expression. I mean neither in trigonometric representation (such as the output of `ComplexExpand[]`) nor with any `i`'s in it. Is there any simplification function or procedure that can help?  I've tried `Simplify[]` and `FullSimplify[]` and their various options. Even I've combined them with some other expression manipulation functions such as `Expand[]`, `Refine[]` and `ComplexExpand[]`, but I could not reach my goal.


Is there a way to localize Off[some::message]?

Is there a way to _temporarily_ suppress certain messages, so that I could write for example (with made-up syntax for that feature):               WithOff[Pattern::patv, rule = (f[x_Integer|{x__Integer}] :> g[x])];     rule2 = x_[x__] :> x;      and get no `Pattern::patv` message for `rule`, but do get one for `rule2` iff the message was enabled at the beginning (that is, `WithOff` doesn't affect the on/off status of the message outside of its argument)?


How to plot results of Dsolve

I could not figure out how to get a plot of the results of my coupled differential equations. I am sure that the equations are written correctly. I tried solving a basic Lotka Volterra set of equations but could't figure out how to graph the results of that either. Please Help! a = 2; b = 1; c = 1; d = 2;               DSolve[{x'[t] == a x[t] - b x[t] y[t],        y'[t] == -c y[t] + d x[t] y[t]}, {x[t], y[t]}, t]      I haven't read anything that made sense for graphing... I tried variations of this: `Plot[y[t] /. s, {t, 0, 10}]`


RankedMax and Max do not behave identically

I have spent three hours debugging some code and at the end I think I found a bug. Otherwise I cannot explain what I am seeing: When I want to use `RankedMax` on nested sublists, Mathematica freaks out, but it works all smooth as I expect when I use `Max`. Try:               tab = Table[{i, j, k}, {i, 1, 2}, {j, 1, 3}, {k, 1, 4}] // TableForm     Map[Function[{x}, x/Max[x]], tab] // TableForm     Map[Function[{x}, x/RankedMax[x, 1]], tab] // TableForm      The last line will cause an error, and I do not understand why, because the documentation says: > RankedMax[{Subscript[x, 1],...,Subscript[x, m]},1] is equivalent to > Max[{Subscript[x, 1],...,Subscript[x, m]}]. Why is this happening? Do I understand something incorrectly?


Getting a String from a list of strings

Is there a way to write down `Mathematica` with a string such as:   `{"M","a","t","h","e","m","a","t","i","c","a"}`?


Cannot use CTRL + F and UN/COMMENT

I would like to ask a question with Mathematica 9.0.1. I find that both   1. FIND: CTRL + F    2. UN/COMMENT: ALT + / become unavailable. Pressing the shortkey or selecting from the menu could not activate the command. Previously with version 8.0.4.0, they were both fine. ![enter image description here](http://i.stack.imgur.com/lDlR2.jpg) Does anyone know how to fix it? Jimmy


Split a list of pairs at points with decreasing first element

I have a list in which the first index is mostly increasing, but dips sometimes. I need to split this list in two or more lists in this way: when the first element of a pair is smaller than the preceding first element, I need to split the list and create new separate lists. This is an explanatory example:               list = {{1, 10}, {2, 20}, {3, 30}, {4, 40}, {5,50},             {2, 20}, {3, 30}, {4, 40}, {5, 50}, {1, 10}, {2, 20}, {4, 40}};          newlist1 = {{1, 10}, {2, 20}, {3, 30}, {4, 40}, {5, 50}};     newlist2 = {{2, 20} {3, 30} {4, 40} {5, 50}};     newlist3 = {{1, 10}, {2, 20}, {4, 40}};


Any way to speed up evaluation in an Animate?

I have a self-defined function which is fairly complicated and gives the analytical form. The result contains two independent variables. I use `Animate` to plot the function by enumerating one parameter.               myfun[x_, y_] := ... (* here are some complicate calculation *)     Animate[Plot[myfun[x, y], {x, 0, 2.5}], {y, 0, 5.0, 0.5}]      Each plot in the `Animate` will call myfun each time it needs a value from it, that's why the animation runs slowly. I don't know how to speed up code. But now, I run myfun once, copy the resulting expression and paste it to make a new function               myfun[x_, y_] := ... (* here are some complicate calculation *)     (* here it returns some expression and I copy and paste it into myfun2 *)      myfun2[x1_, y1_] := EXPRESSION_FROM_PASTE /. {x -> x1, y -> y1}     Animate[Plot[myfun2[x, y], {x, 0, 2.5}], {y, 0, 5.0, 0.5}]      It runs pretty fast now. But if I change some parameter or math in myfun, I need to copy and paste the function again to make myfun2. Is that anyway to achieve that programatically? Thanks.