title: inverse function not working -- but providing values for some arguments, a symbol otherwise?

text: Could you help me with what Mathematica is doing here, in the last lines? (The rest is here for context.) I removed the output to let you simply run this. Thanks.               k=10/3     u[c_,l_]:=Log[c]-Log[1+l^(1+k)/(1+k)]     T[z_]:=(1-0.84/1.3) * z     lType[n_]:=ArgMax[{u[n l-T[n l],l],l>=0},l]     zType[n_] := n lType[n]     Type := InverseFunction[zType]     Type[5345]     Type[2]     Type[4324424]      With a much longer version with some context, you can also switch to http://stackoverflow.com/questions/10641713/mathematica-define-inverse-only- where-it-exists Or please reconsider the same code with some output to see what my problem is with the inverse:               k=10/3     10/3     Utility function as in Saez 2001 allowing for income effects:     u[c_,l_]:=Log[c]-Log[1+l^(1+k)/(1+k)]     Actual tax schedule (approximate)     T[z_]:=(1-0.84/1.3) * z     Equation 14:     lType[n_]:=ArgMax[{u[n l-T[n l],l],l>=0},l]     zType[n_] := n lType[n]     Type := InverseFunction[zType] does not seem to work.     Type := InverseFunction[zType]     Type[5345]     5030.985810589009`     Type[2]     (zType^(-1))[2]     Type[4324424]     (zType^(-1))[4324424]


title: Infinite expression 1/0. encountered - caused by precision?

text: Planck's law dependent on frequency rho is as follows:                  B[T_, h_, rho_, k_, c_] := (2 h rho^3)/c^2 1/(Exp[h rho/(T k)] - 1)      As you can see, the denominator can only be zero for rho = 0. All the rest are nonzero constants. Curiously if we try to plot it               Plot[B[5800, 6.626 10^-34, rho, 1.38 10^-23, 299792458], {rho,        0.1 10^-6, 3 10^-6}]      It will return "Infinite expression 1/0. encountered" and the plot will be blank. In fact, substituting any value for rho appears to result in this error (out = ComplexInfinity). I have no experience with precision, but I don't see any other possible reason. Anyway to solve this?


title: Integrating with multiple indicator functions

text: I am trying to calculate an integral involving multiple indicator functions, such as: $$ h(u,v,w) = -\int_0^1 J^{\prime\prime}(s) (I_{(0,s]}(u) - s)(I_{(0,s]}(v) - s)(I_{(0,s]}(w) - s)\, dF^{-1}(s)$$ where $0 < u, v, w < 1$ and $$\begin{align} J(s) &= 6s(1-s)\\\ F(s) &= 1/[1 + \exp[-s]]\\\ F^{-1}(s) &= -\log[-1 + 1/s]\\\ \end{align} $$ Here is my code:               Js = 6 s (1 - s) (*weight function*)     FDJs = D[Js, s] (*first derivative of Js*)     SDJs = D[FDJs, s] (*second derivative of Js*)     Fs = 1/(1 + Exp[-(s)]) (*Fs*)     Finv = -Log[-1 + 1/s] (*F inverse*)     DFinv = D[Finv, s] (*derivative of F inverse*)     h = -Integrate[         SDJs*(Boole[u <= s] - s)*(Boole[v <= s] - s)*(Boole[w <= s] -          s) DFinv, {s, 0, 1},          Assumptions -> {0 < u < 1 , 0 < v < 1, 0 < w < 1}]      I get some output, but I am not sure if the syntax is correct especially for the indicator function.


title: Is it possible to construct a topological map of road network of Bangalore?

text: I saw this example wherein the `CityData` gives the map of a city. But this is available for a relatively small set of curated regions. Is it possible to extract such map, say the topologically connected roadmap (with edges representing edgelengths) of an arbitrary city?


title: ParallelEvaluate for function minimization

text: Is there a parallelized version of a minimization routine available in _Mathematica_? The objective function is non-linear and the gradients have to be numerically computed. Every function evaluation is compute-intensive and hence parallelization of numerical gradient computation will be beneficial. Simple attempts to wrap `Parallelize` around `FindMinimum` or `NMinimize` says it: > `cannot be parallelized; proceeding with sequential evaluation. >>` **Edit : 1** Here is an toy example               objFn[coeff_, xMin_, xMax_, n_] := (        Pause[5];         Total[(Cos[#] -               Sum[coeff[[i]] #^(i - 1), {i, 1, Length@coeff}]) & /@            Range[xMin, xMax, (xMax - xMin)/n]]^2);          NMinimize[      N@objFn[{x1, x2, x3, x4}, \[Pi]/3, 2 \[Pi]/3, 10], {x1, x2, x3, x4},       EvaluationMonitor -> Print[{x1, x2, x3, x4}]]      The `Pause[5]` is a placeholder for a long computation. This attempts to find a polynomial fit for the function using the coefficients list `{x1,x2,x3,x4}`. `Parallelize@Nminimize` resorts to sequential evaluation in this case. **Edit : 2** This question is inspired from an analogous possibility in Matlab as described here and here.


title: Numerical evaluation of ChebyshevT

text: When I evaluate the following Chebyshev series of the first kind in two different ways, I get two very different results:               N[ChebyshevT[100, Cos[Pi/7]], 8]     N[ChebyshevT[100, Cos[Pi/7]]]          Out[1] = 0.62348980     Out[2] = 3.71097*10^18      Clearly the first result is the correct one. Could someone please explain why the difference occurs e.g. is it perhaps because of a peculiar way that the long Chebyshev polynomial is numerically evaluated? The problem does not arise for shorter length Chebyshev polynomials.


title: Construct a function that can generate a geometry by extruding a section

text: Toady I want to construct a geometry shown as below: ![enter image description here](http://i.stack.imgur.com/qJio6.png) I know the Mathematica has the functions like `Cylinder`, `Sphere` and so on,but it lacks of a function to construct my geometry,so I have a trial as below: **_TengentLine_**                lineCofficient[x1_, y1_, r1_, x2_, y2_, r2_, style_] := Block[      {},        First@Solve[        {(k x1 - y1 + b)/Sqrt[1 + k^2] == r1  style,          (k x2 - y2 + b)/Sqrt[1 + k^2] == r2 style},        {k, b}]      ]      **tangentPoint**                tangentPoint[x1_, y1_, r1_, x2_, y2_, r2_, style_] := Block[       {k, b},      {        Solve[         {y == k x + b /.lineCofficient[x1, y1, r1, x2, y2, r2,style],         (x - x1)^2 + (y - y1)^2 == r1^2}, {x, y}],        Solve         [{y == k x + b /. lineCofficient[x1, y1, r1, x2, y2,r2,style],         (x - x2)^2 + (y - y2)^2 == r2^2}, {x, y}]      } // Flatten[#, 1] &     ]      **_My geometry_**                 FinalGeometry[x1_, y1_, z1_, r1_, x2_, y2_, z2_, r2_, h_] := Block[       {x, y, one, two, three, four},       Graphics3D[       {Cylinder[{{x1, y1, z1}, {x1, y1, h}}, r1],        Cylinder[{{x2, y2, z2}, {x2, y2, h}}, r2],            one = Flatten[         List[           Join[{x, y} /.tangentPoint[x1, y1, r1, x2, y2, r2, -1], {{z1}, {z1}}, 2],          Join[{x, y} /.tangentPoint[x1, y1, r1, x2, y2, r2, -1], {{h}, {h}}, 2]], 1];                     two = Flatten[          List[          Join[{x, y} /.tangentPoint[x1, y1, r1, x2, y2, r2, 1], {{z1}, {z1}}, 2],           Join[{x, y} /. tangentPoint[x1, y1, r1, x2, y2, r2, 1], {{h}, {h}}, 2]], 1];            three = Flatten[         List[          Join[{x, y} /.tangentPoint[x1, y1, r1, x2, y2, r2, -1], {{z1}, {z1}}, 2],          Join[{x, y} /.tangentPoint[x1, y1, r1, x2, y2, r2, 1], {{z1}, {z1}}, 2]], 1];            four = Flatten[         List[           Join[{x, y} /.tangentPoint[x1, y1, r1, x2, y2, r2, -1], {{h}, {h}}, 2],            Join[{x, y} /.tangentPoint[x1, y1, r1, x2, y2, r2, 1], {{h}, {h}}, 2]], 1];            Sequence @@         (Polygon /@            Flatten[{Partition[one, 3, 1], Partition[two, 3, 1],             Partition[three, 3, 1], Partition[four, 3, 1]}, 1])       },         BoxRatios -> Automatic       ]      ]      **Using my function:**                FinalGeometry[0, 0, 0, 3, 12, 0, 0, 2, 2]      ![enter image description here](http://i.stack.imgur.com/GyOUa.png) However, I feel my method is _tedious and ingeneral_ , well as owning surface intersection. In addition there many other geometry "by extruding a section" like in 3D software Autodesk Inventor. So my question is: Is there a good and easy method to realize my function `FinalGeometry`? Is there possible to construct a function that can generate **a geometry that can rotate freely** **(not a static image)** by extruding a section?


title: Plot groups based on unique tag

text: I have a .csv file that has 12 columns and 511 rows.               data = Import["C:\\Users\\Documents\\data\\AllResults\\result1.csv"];      The first two columns are id tags. I want to plot the last 10 columns of each row as a separate step function.               Do[Print[DiscretePlot[data[[i, k + 2]], {k, 1, 10}, AxesOrigin -> {0, 0}, ExtentSize -> All,     PlotRange -> {{0, 10}, {0, 10}}]], {i, 511}]      (Please feel free to make it prettier) Now I want to create multiple plots for each unique id in column 1. For example, The first 3 rows of the data have the same column 1 id ("1000_0.01"). I want 4 plots for this id, all in one row, side by side. The first 3 plots are the `DiscretePlot`s of each of the 3 rows in the data and the 4th plot is the summary plot that contains all the 3 plots earlier. **Note:** The data is sorted by the first column, so there is no need for searching.


title: First 10 digits of $\pi$ without rounding

text: I need to have $\pi$ with an accuracy of $10$ digits. My first guess would be               N[Pi, 10]       However, this rounds to the last digit instead of just chopping of any additional digits and hence the last digit is $4$ (and not $3$, as it actually is). I could do               N[FromDigits[RealDigits[Pi, 10, 10]], 10]      but I am pretty sure that there are nicer solutions.


title: Speeding Up Image Processing Functions

text: I am working with stacks of 1024x1024 timelapse microscopy images that I am performing a series of image processing functions on to help segment each image. These functions include `Sharpen`, `Erosion`, `Dilation`, `RidgeFilter`, `FillingTransform` and `WatershedComponents` (with hand- selected markers). After some trial and error it seems I need to at least use the following functions to arrive at a generally acceptable segmentation:               watershedLabelMatrix = WatershedComponents[RidgeFilter[image],markersForWatershed]      I would like to know if there is anyway to speed up these image processing steps (particularly the bit of code above). I have not had success with use of `Compile` or `Parallelize`. I am not sure if it is possible to Compile a function that takes an image as its argument. Here's one example of what failed for me:               watershedCompile1 = Compile[{{imageIn, _Real}, {markersIn, _Real}},                           WatershedComponents[imageIn, markersIn]]      I get this message after evaluating: > Compile::extscalar: "WatershedComponents[imageIn,markersIn] cannot be > compiled and will be evaluated externally. The result is assumed to be of > type Real." Similarly, when I try to `Parallelize` I am told `WatershedComponents` cannot be parallelized. When I try to use `WatershedComponents` "on the fly" within a little `DynamicModule` interactive notebook I have written that iterates through a stack of images and allows me to save acceptable `WatershedComponent` masks, I get a long (maybe 5 to 10 seconds) pause while I wait for the `WatershedComponents` result and usually see the dreaded _Progress: Formatting Notebook Contents_ dialog window popup. Any suggestions on improving the performance of these image processing functions or suggestions for how to improve performance within a `DynamicModule` (or alternatives to `DynamicModule`) would be greatly appreciated.


title: Plotting Voxel in mathematica

text: I am developping a 3D reconstruction application. I recuperate the voxels coordinates (the coordinate of each voxel) of the object that I need to reconstruct. Each voxel have a dimensions like this 5cm*5cm*5cm. I need to reconstruct this volume. I try to use `Image3D` function by put just a 3d binary table representing the voxels that belongs to volume but I could not change the size of each voxel. Any help please?


title: How do I represent a system dynamics feedback loop?

text: In System Dynamics, if I want represent the relationship between Speed and Distances, I create a Flow (Speed) and a Stock (Distance) as you can see in this Insight Maker Sample . Heres an Image of how it looks like: ![enter image description here](http://i.stack.imgur.com/dLHaq.png) Now, keeping a constant speed of 20 results in this nice Graph: ![enter image description here](http://i.stack.imgur.com/gPz7Z.png) I know how to represent that in Mathematica, it is easy:               speed = 20     distance = Integrate[speed, time]     Plot[distance, {time, 0, 20}]      That will get me this nice graph: ![enter image description here](http://i.stack.imgur.com/22paN.png) Now I want to do something more complex, I want to add a **feedback loop** , I have already done it in InsightMaker too, it looks like this: ![enter image description here](http://i.stack.imgur.com/aTvlB.png)   * The flow Reproduction is configured as: 20*[Reproduction Rate]   * The stock E. Coli Bacteria is configured as: Initial Value: 1    * The variable Reproductino Rate is configured as: [ E. Coli Bacteria] So I get exponential growth : ![enter image description here](http://i.stack.imgur.com/ge40N.png) My question is: how do I represent this kind of system dynamics model with a feedback loop in Mathematica? **UPDATE** : Here is a table with the values generated by InsightMaker   * Hour 0 E. Coli Bacteria: 1   * Hour 1 E. Coli Bacteria: 21   * Hour 2 E. Coli Bacteria: 441   * Hour 3 E. Coli Bacteria: 9,261   * Hour 4 E. Coli Bacteria: 194,481 Would you be so kind as to please configure your answers to match this results? ( _I am learning as a hobby system dynamics & mathematica and my goal with this question is to understand how to translate a system dynamics diagram to mathematica, so I want to be sure I correctly understad how each part of a system dynamics diagram matches an equivalent mathematica code_)


title: How create true reflect movement disk in the ellipse?

text: Help me please. Task: Disk movement inside the Ellipse so that naturally Disk reflected from the walls and continued to move. Thanks. My friend was able make a move on the square only:               x = 0.5;     y = 0.5;          vx = 1;     vy = Pi/2;          step = 0.01;     radius = 0.05;          Animate[           x = x + vx*step;      y = y + vy*step;                If[Abs[x - 1] <= radius || Abs[x] <= radius , vx = -vx];      If[Abs[y - 1] <= radius || Abs[y] <= radius, vy = -vy];           Graphics[       {        Cyan,        Rectangle[{0, 0}, {1, 1}],        Gray,        Disk[{x, y}, radius],         Point[{0.0, 0.0}],         Point[{1.0, 1.0}]        }       ],           {t, 0, Infinity}           ]      P.S. Sorry for my bad english =)


title: Rounding only coefficients

text: does Mathematica have built in functionality to round the coefficients of a polynomial to a certain accuracy. Say, we do               Print[0.2134320980x^2+0.0023432x]      Can we wrap a function around the expression in the print so that the output is > >     0.213x^2+0.002x >   I tried `NumberForm` but this rounds messes with the exponent. Thank you!


title: Button with for loop

text: How can I call a function that has a for loop inside a button? If I just write               button[{"name", function[]}]      nothing happens.


title: Interpolation of an upper-triangular list

text: I have 2d list which is upper triangular. I would like to interpolate it, but I cannot unless I set the interpolation order to 1. I tried making the list rectangular by filling the bottom half with `Null`. This does allow me to interpolate with higher order. However, the interpolation function ends too early; that is, it does not return values when the distance from the boundary (the diagonal elements of the list) is relatively small. I would like to have a full interpolation up to (or very close to) the boundary. any advice? Here is the list that I would like to interpolate.               {{0.103974, 0.103971, 0.103953, 0.103899, 0.103786, 0.103597,        0.103316, 0.102925, 0.102414, 0.10177, 0.100988, 0.100062,        0.0989872, 0.0977656, 0.0963984, 0.09489, 0.0932473, 0.0914792,        0.089597, 0.0876143, 0.0855483, 0.0834163, 0.0812392, 0.0790409,        0.0768409, 0.0746749, 0.0725479, 0.0703533, 0.068163,        0.0666494}, {0.10394, 0.103939, 0.103922, 0.103868, 0.103755,        0.103567, 0.103285, 0.102896, 0.102385, 0.101742, 0.10096, 0.100033,        0.0989584, 0.0977364, 0.0963682, 0.0948584, 0.093214, 0.0914444,        0.0895606, 0.087576, 0.0855068, 0.0833692, 0.0811831, 0.0789712,        0.0767541, 0.0745556, 0.0723645, 0.0701298, 0.0680141}, {0.10387,        0.103868, 0.10385, 0.103795, 0.103683, 0.103495, 0.103214, 0.102825,        0.102314, 0.10167, 0.100887, 0.0999592, 0.0988834, 0.0976591,        0.0962884, 0.0947757, 0.0931276, 0.091353, 0.0894624, 0.0874687,        0.0853863, 0.0832311, 0.0810217, 0.0787762, 0.076513, 0.0742205,        0.0718546, 0.0695221}, {0.103748, 0.103745, 0.103724, 0.103669,        0.103558, 0.103371, 0.10309, 0.102699, 0.102187, 0.101542, 0.100757,        0.0998263, 0.0987467, 0.0975176, 0.0961414, 0.0946217, 0.0929642,        0.0911773, 0.089271, 0.0872567, 0.0851463, 0.0829572, 0.0807012,        0.0783843, 0.0760088, 0.0734579, 0.0706321}, {0.103554, 0.103551,        0.103531, 0.103476, 0.103366, 0.103178, 0.102896, 0.102504,        0.101989, 0.101341, 0.100553, 0.099617, 0.0985308, 0.0972933,        0.0959062, 0.0943723, 0.0926975, 0.0908894, 0.0889562, 0.0869069,        0.0847519, 0.0825056, 0.0801589, 0.0777, 0.0750337,        0.0716811}, {0.103276, 0.103275, 0.103256, 0.103202, 0.10309,        0.102901, 0.102618, 0.102223, 0.101704, 0.101052, 0.100256,        0.0993117, 0.0982145, 0.0969632, 0.0955586, 0.0940032, 0.092303,        0.0904624, 0.0884869, 0.0863832, 0.0841579, 0.081807, 0.0792933,        0.0765284, 0.0728391}, {0.102903, 0.102902, 0.102884, 0.10283,        0.102718, 0.102528, 0.102241, 0.101843, 0.101318, 0.100658,        0.0998522, 0.0988945, 0.0977811, 0.0965098, 0.0950807, 0.0934955,        0.0917577, 0.0898677, 0.0878288, 0.0856427, 0.0832993, 0.0807647,        0.0779256, 0.0740117}, {0.102422, 0.102422, 0.102405, 0.10235,        0.102237, 0.102044, 0.101754, 0.101349, 0.100817, 0.100146,        0.0993255, 0.09835, 0.0972144, 0.0959158, 0.0944531, 0.0928257,        0.091033, 0.089073, 0.0869434, 0.0846283, 0.0820913, 0.0792068,        0.0751356}, {0.101822, 0.101823, 0.101806, 0.101752, 0.101637,        0.10144, 0.101144, 0.100732, 0.100188, 0.099502, 0.0986628,        0.097664, 0.0964989, 0.0951639, 0.0936555, 0.0919695, 0.090102,        0.0880447, 0.0857767, 0.083259, 0.0803534, 0.0761756}, {0.101097,        0.101098, 0.101081, 0.101026, 0.100909, 0.100708, 0.100405,        0.0999814, 0.0994228, 0.0987171, 0.0978542, 0.0968249, 0.0956215,        0.0942383, 0.0926684, 0.090904, 0.0889336, 0.0867302, 0.0842497,        0.0813519, 0.0771066}, {0.100239, 0.10024, 0.100224, 0.100167,        0.100048, 0.0998402, 0.0995268, 0.0990894, 0.0985123, 0.0977829,        0.0968891, 0.0958205, 0.0945678, 0.0931211, 0.0914701, 0.0895987,        0.0874762, 0.0850528, 0.0821852, 0.0779089}, {0.0992445, 0.0992461,        0.0992294, 0.0991719, 0.099048, 0.0988324, 0.0985062, 0.0980515,        0.0974514, 0.0966918, 0.0957588, 0.0946403, 0.0933235, 0.0917941,        0.0900337, 0.0880059, 0.0856582, 0.0828417, 0.0785649}, {0.0981125,        0.0981144, 0.0980973, 0.0980374, 0.0979076, 0.0976814, 0.09734,        0.096864, 0.0962348, 0.0954372, 0.0944552, 0.093273, 0.0918731,        0.0902326, 0.0883131, 0.0860581, 0.0833127, 0.0790662}, {0.0968426,        0.0968454, 0.096828, 0.0967645, 0.0966264, 0.0963876, 0.0960279,        0.0955252, 0.0948597, 0.0940148, 0.0929701, 0.0917054, 0.0901945,        0.0883946, 0.0862476, 0.0835918, 0.079405}, {0.0954383, 0.0954419,        0.095424, 0.0953556, 0.0952077, 0.0949537, 0.0945706, 0.0940344,        0.0933241, 0.0924188, 0.0912934, 0.0899197, 0.0882514, 0.0862242,        0.083675, 0.0795756}, {0.0939058, 0.0939098, 0.09389, 0.0938154,        0.0936557, 0.093382, 0.092969, 0.0923913, 0.0916245, 0.0906417,        0.0894103, 0.0878829, 0.0859885, 0.0835615, 0.0795752}, {0.0922516,        0.0922556, 0.0922334, 0.092151, 0.0919761, 0.0916776, 0.0912276,        0.0905977, 0.0897577, 0.088673, 0.0872931, 0.0855428, 0.0832538,        0.0794039}, {0.0904849, 0.0904886, 0.0904629, 0.0903703, 0.090176,        0.0898463, 0.0893496, 0.0886522, 0.0877159, 0.0864893, 0.0848929,        0.0827551, 0.0790643}, {0.0886172, 0.0886199, 0.0885891, 0.0884833,        0.0882643, 0.0878948, 0.0873377, 0.0865514, 0.0854815, 0.0840469,        0.0820716, 0.078562}, {0.08666, 0.086662, 0.0866252, 0.086502,        0.0862506, 0.0858294, 0.0851927, 0.0842826, 0.0830158, 0.0812123,        0.0779048}, {0.0846302, 0.0846316, 0.0845855, 0.0844381, 0.084145,        0.0836566, 0.0829073, 0.0818115, 0.0801893, 0.0771012}, {0.0825462,        0.0825452, 0.082486, 0.0823086, 0.0819616, 0.081374, 0.0804515,        0.0790206, 0.0761684}, {0.0804289, 0.0804223, 0.0803448, 0.0801253,        0.0796932, 0.0789504, 0.0777197, 0.0751256}, {0.0783023, 0.078285,        0.0781783, 0.0778938, 0.0773324, 0.0763055, 0.0739972}, {0.0761874,        0.0761545, 0.0760065, 0.0756224, 0.074797, 0.0728167}, {0.0741274,        0.0740638, 0.0738307, 0.0732125, 0.0716426}, {0.0721374, 0.0720111,        0.071612, 0.0705599}, {0.0701032, 0.0699286, 0.0694193}, {0.0680611,        0.0679384}, {0.0666374}}      and here is the code I am using               temp1 = ConstantArray[Null, {30, 30}];      Table[temp1[[ixa, ixb]] = data[[ixa, ixb]], {ixa, Range[1, 30]}, {ixb, 30 - ixa + 1}];      F = ListInterpolation[temp1, {{0, 1}, {0, 1}}]


title: Multiple Forms of Transportation Between Cities

text: I want to be able to show different connections between cities based on modes of transportation. For instance, you could walk to any city, but it would take a long time, you could take a train, but only to/from certain cities. Is it possible to display all of this on the same graph? Here is what I tried:               Coords = {{40.6642738`, -73.9385004`}, {34.0193936`, -118.4108248`},     {41.8375511`, -87.6818441`}, {29.7804724`, -95.3863425`}};           foot =     {{"NewYork", "NewYork", "UnitedStates"} -> {"LosAngeles",          "California", "UnitedStates"}, {"NewYork", "NewYork",          "UnitedStates"} -> {"Chicago", "Illinois",          "UnitedStates"}, {"NewYork", "NewYork",          "UnitedStates"} -> {"Houston", "Texas",          "UnitedStates"}, {"LosAngeles", "California",          "UnitedStates"} -> {"NewYork", "NewYork",          "UnitedStates"}, {"LosAngeles", "California",          "UnitedStates"} -> {"Chicago", "Illinois",          "UnitedStates"}, {"LosAngeles", "California",          "UnitedStates"} -> {"Houston", "Texas",          "UnitedStates"}, {"Chicago", "Illinois",          "UnitedStates"} -> {"NewYork", "NewYork",          "UnitedStates"}, {"Chicago", "Illinois",          "UnitedStates"} -> {"LosAngeles", "California",          "UnitedStates"}, {"Chicago", "Illinois",          "UnitedStates"} -> {"Houston", "Texas",          "UnitedStates"}, {"Houston", "Texas",          "UnitedStates"} -> {"NewYork", "NewYork",          "UnitedStates"}, {"Houston", "Texas",          "UnitedStates"} -> {"LosAngeles", "California",          "UnitedStates"}, {"Houston", "Texas",          "UnitedStates"} -> {"Chicago", "Illinois", "UnitedStates"}};          car = {{"NewYork", "NewYork", "UnitedStates"} -> {"Chicago",           "Illinois", "UnitedStates"}, {"Houston", "Texas",           "UnitedStates"} -> {"LosAngeles", "California",           "UnitedStates"}, {"LosAngeles", "California",           "UnitedStates"} -> {"Houston", "Texas",           "UnitedStates"}, {"Houston", "Texas",           "UnitedStates"} -> {"Chicago", "Illinois", "UnitedStates"}};          plane = {{"NewYork", "NewYork", "UnitedStates"} -> {"LosAngeles",           "California", "UnitedStates"}};     train = {{"LosAngeles", "California", "UnitedStates"} -> {"Chicago",           "Illinois", "UnitedStates"}, {"Chicago", "Illinois",           "UnitedStates"} -> {"Houston", "Texas",           "UnitedStates"}, {"Houston", "Texas",           "UnitedStates"} -> {"NewYork", "NewYork", "UnitedStates"}};          Graph[foot, VertexCoordinates -> Reverse[Coords, 2],       VertexStyle -> Red, VertexSize -> .1, ImageSize -> 650]      If it helps, the overall goal I'm working towards is not just to display the modes of transportation visually, but to run calculations based on the modes of transportation and routes you could take.


title: How to find out if invisible notebooks are still open

text: If I create a notebook `CreateDocument` and I set options such that `Visible -> False`, is there any way to tell if it's still open without setting it back to visible?               outputNotebook = CreateDocument[{}, Visible -> False]      Complication: The initial notebook object reference is reassigned, i.e. I create another document with the same notebook object reference symbol: `outputNotebook = CreateDocument[...]` and then later run the same code. How can I figure out if my first `outputNotebook` (which is invisible) is still open?


title: What is the proper way to verify that two expressions are equivalent?

text: First of all, it appears to me that $$\left|\frac{1}{x} + x^2\right| \Leftrightarrow \frac{|1 + x^3|}{|x|}$$ is true. I don't know why, but my attempt to verify it in _Mathematica_ failed.               In[1]:= Abs[1/x + x^2] === Abs[1 + x^3]/Abs[x]     Out[1]= False      It's weird because _Mathematica_ is unable to find a counterexample.               In[2]:= FindInstance[Abs[1/x + x^2] != Abs[1 + x^3]/Abs[x], x, Complexes]     Out[2]= {}


title: Image correlation

text: I have two images from motor scan, Image1 is shifted by MxN pixels from Image2. How can I find the shift between Image1 and Image2 ? Image -1 ![1](http://i.stack.imgur.com/laZeT.png) Image -2 ![2](http://i.stack.imgur.com/LAHyF.png) If we compare the shift between the images in terms of {X,Y} I will be able to tell how many steps of the motor scan corresponds to the pixel shift on the image array sensor.


title: StringForm and NotebookWrite

text: I'm trying to get my head around NotebookWrite for the last few days. I can't understand why               NotebookWrite[nb,       Cell[        StringForm["some text = ``", 3]       , "Text"        ]]      doesn't seem to produce what I would expect: some text = 3 in the newly defined notebook nb. Why is this? How can this be achieved? Thanks all, once again!


title: Is there a more Mathematica-y way to label these plots?

text: I am studying an infinite square well in the context of quantum mechanics.               ClearAll["Global`*"];          (* Length of the well *)     L = 1;          (* The eigenfunctions, n=1,2,3,... *)     u[n_, x_] := Sqrt[2/L] Sin[n π x / L]          (* Probability density function, ρ[x] = |u[n,x]|^2 *)     ρ[n_, x_] := Simplify[u[n, x]\[Conjugate] u[n, x], {n ∈ Integers, x ∈ Reals}]          (* Plots of ρ[n,x] for various values of n *)     Table[ Plot[ρ[n, x], {x, 0, L}, PlotLabel -> "ρ[" <> ToString@n <> ",x]"], {n, 1, 4}]      And here is the output: ![enter image description here](http://i.stack.imgur.com/LpGgM.png) **My questions is** : Can I use Mathematica pattern magic to rewrite `PlotLabel -> "ρ[" <> ToString@n <> ",x]"` ? For instance, I tried (although I knew it wouldn't work): `PlotLabel -> HoldForm@ρ[n,x]`, but that of course leaves `n` unevaluated as well, although I would like `n` to be evaluated and then the result to be held.


title: How does Mathematica find a series expansion of expressions containing logarithms when there is a singularity at the expansion point?

text: I am looking for a good approximation to a function containing logarithms, especially at values close to zero. When I used _Mathematica_ 's `Series` command I found something unexpected. _Mathematica_ seems to expand expressions containing a logarithm differently when there is a singularity at the expansion point. For example, the function $(a+\log[x^3+x^7])/(b+x)$ has a singularity at $x=0$. If I use `Series` with an expansion point greater than zero, I get the expected Taylor expansion. However, at the expansion point zero I get $$ \frac{a + 3 \log(x)}{b} + \frac{(-a - 3 \log(x)) x}{b^2} + O(x)^2. $$ It strikes me that the logarithm is retained as a function in $x$. And this result approximates the function much better than that of a simple Taylor series. _Mathematica_ somehow separates the logarithm from the expansion, which I find quite intelligent. I would like to know what technique _Mathematica_ uses and how it is called. I never came across such a thing and would be interested in learning more about it. I understand that `Series` can use several expansions and choses an appropriate one depending on the problem, so maybe this is a special procedure to treat expressions with logarithms. I also found (with some trial and error) that Mathematica's result equals the one I would get if I first did a Taylor expansion of the expression, but treating all logarithms as constants, and then reduced all logarithmic arguments to the lowest power of $x$. Why is this justified?


title: How to apply compiled function on list

text: Compile function output error: How to apply compiled function on list?                   mkCompileCode[vars_, code_, idx_] :=          With[{fVars = Flatten[vars]},          Compile[{{in, _Real, idx}}, Block[fVars, fVars = Flatten[in];         code], RuntimeAttributes -> Listable]]              vars = {x, y, z};         df = Function[{x, y, z}, Sqrt[x^2 + y^2 + z^2] - 1];      Compiling the above function                   cdfs = mkCompileCode[vars, df, 1]      Compiled function does nt work on following list:                   p = {{-1.`, -1.`, -1.`}, {-1.`, -1.`, -0.75`}, {-1.`, -1.`, -0.5`},               {-1.`, -1.`, -0.25`}};              cdfs[p]      out:                  During evaluation of In[236]:= CompiledFunction::cfse: Compiled expression                  Function[{x,y,z},Sqrt[x^2+y^2+z^2]-1] should be a machine-size real number. >>            {Function[{x, y, z}, Sqrt[x^2 + y^2 + z^2] - 1],        Function[{x, y, z}, Sqrt[x^2 + y^2 + z^2] - 1],        Function[{x, y, z}, Sqrt[x^2 + y^2 + z^2] - 1],        Function[{x, y, z}, Sqrt[x^2 + y^2 + z^2] - 1]}      What's missing?


title: Parsing output from FindHamiltonianCycle to recover an ordered list of vertex positions for a discovered path

text: After applying `FindHamiltonianCycle` to a graph, one generates output that looks like the following:               {{1<->2,2<->3,3<->4,4<->5,5<->6,6<->7,7<->8,8<->9,9<->10,10<->11,11<->12,12<->13,13<->14,14<->15,15<->16,16<->17,17<->18,18<->19,19<->20,20<->21,21<->22,<<3670>>,77<->75,75<->73,73<->71,71<->69,69<->67,67<->65,65<->63,63<->61,61<->59,59<->57,57<->55,55<->53,53<->51,51<->49,49<->47,47<->45,45<->43,43<->41,41<->39,39<->36,36<->1}}      I've replaced `\[UndirectedEdge]` with "<->" here to deal with formatting. How can I quickly return an ordered list of vertices in the path, and an ordered list of their (previously specified) coordinates?


title: What domain does Resolve assume by default?

text: Consider the statement: $\forall x\left(x<7\Rightarrow \exists a\exists b\exists c(a^2+b^2+c^2=x)\right)$ This is true provided the universe of discourse is $\mathbb{N}$ Now I use `Resolve` as follows to assess the validity of this statement:               Resolve[ForAll[x, Implies[x < 7, Exists[{a, b, c}, a^2 + b^2 + c^2 == x]]]]      and _Mathematica_ returns `True`. Why? If I did not specify $\mathbb{N}$ as the domain how does _Mathematica_ justify returning `True`? Is there a way to specify $\mathbb{N}$ as the domain?


title: Reverse-order Negative BarSpacing

text: Suppose I have some data for a bar chart:               testdata = Map[{1, #} &, RandomReal[{-0.5, 4}, {3, 2}], {2}]     (* {{{1, 3.30023}, {1, 3.814}}, {{1, -0.353959}, {1, -0.364447}}, {{1,           1.82514}, {1, 2.56824}}} *)          RectangleChart[testdata, BarOrigin -> Left, Frame -> True,        ChartStyle -> {Red, Blue}, BarSpacing -> {-0.2, 0.6}]      ![enter image description here](http://i.stack.imgur.com/05mW9.png) But what I really want is for the shorter, red bars to overlap _on top_ of the blue bars, not underneath.               RectangleChart[Reverse /@ testdata, BarOrigin -> Left, Frame -> True,        ChartStyle -> {Blue, Red}, BarSpacing -> {-0.2, 0.6}]      ![enter image description here](http://i.stack.imgur.com/jRbXf.png) That works, but the red bars only overlap if they are _above_ the blue bars. If I had set `BarOrigin->Bottom`, the red bars would then be on the right.               RectangleChart[Reverse /@ testdata, Frame -> True,        ChartStyle -> {Blue, Red}, BarSpacing -> {-0.2, 0.6}]      ![enter image description here](http://i.stack.imgur.com/yMs9p.png) Conceptually this is because later data prints after earlier data, so groups of bars on the right or at the top are "later" and print on top of the "earlier" bars on the left or below. This makes sense to me, but not to the person I am drawing the graph for. Is there any way to reverse the bar ordering such that the bars at the bottom of the group overlap on top of the upper bars when one has negative `BarSpacing`?


title: What is the Missing code in this Wolfram Blog article?

text: Here's a very cool Wolfram Blog Article with incomplete code, that can apply the Droste Effect to an image is various interesting ways. Copying this code, in the journal doesn't provide a working solution. What's missing here to get this code to work?               InitializeSources[source_, p1_, p2_] :=       Quiet[Block[{imgbytes = Import[source, "Byte"],     sourcebytestream},     If[imgbytes === $Failed, $Failed,       sourcebytestream = FromCharacterCode[imgbytes];       LaunchKernels[];       DistributeDefinitions[OriginalValueFns,        DrostifyRegion, ReplicateRegion, TransformCoordinates,        CropData];       ParallelEvaluate[$ImageInterpolationFn =          OriginalValueFns[CropData[           Reverse@Developer`ToPackedArray[             N[ImportString[#, {"JPG", "Data"}]]], p1, p2]/255.];] &[     sourcebytestream]]]     ]          OriginalValueFns[data_] :=      ($AspectRatio = 1/Apply[Divide, Most[Dimensions[data]]];       Apply[Function, {{x, y},          If[Abs[x] > 1 || Abs[y] > $AspectRatio, {1., 1., 1.}, #] &[          Table[ListInterpolation[             data[[All, All, channel]], {{-1, 1}, $AspectRatio {-1, 1}},         InterpolationOrder -> 1][x, y], {channel, 1, 3}]      ]}]);          DrostifyRegion[start_, end_, res_, opts : OptionsPattern[]] :=           Image[Table[      Apply[$ImageInterpolationFn,          TransformCoordinates[{x, y}, opts]], {x, end,          start, -2/(res - 1)}, {y, -$AspectRatio/$AspectRatio, 2/res}]     ];          DrosteImage[resolution_, opts : OptionsPattern[]] :=     ImageAssemble[     ParallelTable[      {DrostifyRegion[-1 + 2 (slice - 1)/#, -1. + 2 slice/#,        resolution, opts]},      {slice, #, 1, -1}]] &[Max[Length[Kernels[]], 1]     ];          (*Find the center of the selected rectangle*)     $DrosteScale = Max[Flatten[{Abs[r2 - center]/(center - {1, 1}), Abs[r1 - center]/      Abs[Reverse@Take[Dimensions[data], 2] - center]}]];     CropData[data_, r1_, r2_] := Block[{center, xlo, xhi, ylo, yhi, innerdims},     center = Mean[{r1, r2}];          (*Find the scaling of the cropped image to the rectangle*)          innerdims = Abs[r1 - r2]/$DrosteScale;     {{ylo, xlo}, {yhi, xhi}} = Round[{center - innerdims/2, center + innerdims/2}];     Return[data[[xlo ;; xhi, ylo ;; yhi, All]]]];          TransformCoordinates[{x_, y_}, opts : OptionsPattern[]] := FixedPoint[     ReplicateRegion, {Re[#],        Im[#]} &@((OptionValue[          Zoom] E^(I OptionValue[Rotation])) (OptionValue[XShift] +           I OptionValue[YShift] + x +           I y)^(OptionValue[CopiesPerRotation] +           OptionValue[Spirals] I  Log[$DrosteScale]/(2 \[DoubledPi]))),     OptionValue[MaxRecursion]];     Options[TransformCoordinates] =     {Zoom -> 1, XShift -> 0, YShift -> 0, Rotation -> 0,     CopiesPerRotation -> 1, MaxRecursion -> 10, Spirals -> 1};          ReplicateRegion[{x_, y_}] := Which[     (*If outside the image area, move closer*)          Abs[x] > 1 || Abs[y] > $AspectRatio,         {x, y} $DrosteScale,     (*If inside the frame move out to the main image*)          Abs[x] < $DrosteScale &&         Abs[y] < $DrosteScale $AspectRatio,         {x, y}/$DrosteScale,     (*otherwise use the calculated coordinates*)     True, {x, y}     ];


title: How to transform this matrix & swap its columns in a simple way?

text: I would like to transform matrix $\mathbf A = \begin{pmatrix} a&b&i&j\\\ c&d&k&l \\\ e&f&m&n \\\ g&h&o&p \end{pmatrix}$ into matrix $\mathbf B = \begin{pmatrix} -p&o&-h&g\\\ -n&m&-f&e \\\ -l&k&-d&c \\\ -j&i&-b&a \end{pmatrix}$. If possible I would like to generalize this to $\\{n\times n,\ n>4\\}$ size matrices. Is there a simple way to do this in Mathematica? Thanks in advance.


title: Is there a faster way to Map an Association?

text: Consider mapping an existing `Association` in a manner such as this:               asc = AssociationThread[Range @ 26, CharacterRange["a", "z"]];          Map[asc, {{11, 13, 2}, {19, 23, 16}}, {2}]      > >     {{"k", "m", "b"}, {"s", "w", "p"}} >   Is there a more efficient way perform this generic operation?


title: Duplicated output from chemical curated data

text: I just discovered something rather odd while using chemical curated data in _Mathematica_. I tried to extract `EdgeRules` for some molecules and some molecules gave me several copies of said `EdgeRules` as a list. Is this a bug? Have any of you found similar things happening with other curated data? Example:               ChemicalData[#, "EdgeRules"] & /@ {"Glutamine", "Alanine", "Serine"}      This input gives me 1, 3 and 2 copies of the `EdgeRules` of the given molecules.


title: Map 2 list to a function

text: Im playing around with `CountryData` and I want to pass it 2 lists as argument, `listCountries = {...}` and `data = {"GDP","ExternalDebt"}` If I do `CountryData[#, "GDP"]& /@ listCountries` it works well, but I want something like               CountryData[#1, #2]& /@ {listCountries,data}      I read something about `MapThread` but can make it.


title: Memory management and speed for Fast GCD

text: Let's say that we have some $300\,\text{K}$ digits (arbitrary function) and want to trial factor with $100{,}000{,}000$ first prime numbers.               PRP = {};           Func[Q_] := 77^Q + 2;          Do[If[TimeConstrained[PrimeQ[Func[i]], 1, True], AppendTo[PRP, i]], {i, 160000, 161000}]      PRP: ($64$ numbers out of $1000$ test samples)               {160001,160025,160037,160041,160045,160053,160065,160097,160101,160133,160137,160141,160161,160177,160181,160201,160241,160253,160257,160261,160285,160297,160305,160317,160321,160361,160393,160397,160405,160413,160421,160425,160441,160485,160541,160557,160577,160581,160601,160621,160633,160637,160645,160657,160685,160693,160713,160721,160725,160753,160761,160801,160821,160833,160845,160853,160857,160861,160881,160897,160921,160933,160945,160965}      Then I use the following to compute product of primes in $5$ part ($20{,}000{,}000$ range)               Pro = Product[i, {i, Prime[Range[1, 20000000]]}]; // about 170 million digits      And for each product I run:               Output ={};          Do[If[GCD[Func[i], Pr] == 1, AppendTo[Output, i]], {i, PRP}]      Currently each product (of $20{,}000{,}000$ primes) take $1\,\text{GB}$ of RAM and nearly $30$ seconds for each GCD               In[86]:= Timing[GCD[Func[160001], Pr]]          Out[86]= {28.562500, 117414067}      Is my configuration and setup the best possible one in memory management and speed? **Update** I modified the @tchronis answer a little to remove composite as early as possible. Not the best code (can be much better using `Reap` and `Sow`), but it works:               ClearAll[gcd2];     gcd2[list_, noprimes_: 20000000, noclusters_: 1] :=       Module[{clusters, n, pro},        clusters =         Table[{(i - 1)*noprimes/noclusters + 1, i*noprimes/noclusters}, {i,           noclusters}];       innerList = list;       Do[        pro = Product[i, {i, Prime[Range @@ clusters[[j]]]}];        newList = {};        Do[         If[GCD[func[m], pro] == 1, AppendTo[newList, m]],         {m, innerList}         ]; innerList = newList,        {j, 1, noclusters}        ]; newList       ]      **Result**               Timing[gcd[list, 5000000, 4]]          {327.9706, { .... 54 out of 64 ... } }          Timing[gcd2[list, 5000000, 4]]          {290.328125, { .... 54 out of 64 ... } }      The higher the number of primes and the larger the list, the speedup by stopping computation upon first non-one GCD gains more.


title: Why does Mathematica return a Fourier transform for a function for which it is not defined?

text: The following function $$g(x) = (1 + x^{1/a} )^a $$ should NOT have a Fourier transform, as far as I am aware, for any real values of $a$ since $g(x)$ is not nice in the sense of decays quickly enough to $0$ at infinity. However, doing:               g[x_, a_] := (1 + x^(1/a))^(a);     Plot[g[x, 2], {x, 0, 1000}]     FourierTransform[g[x, 2], x, ω]       _Mathematica_ somehow comes up with the result: $$\frac{\left(\frac{1}{2}+\frac{i}{2}\right) (\left| \omega \right| -\omega )}{\omega \left| \omega \right| ^{3/2}}$$ What is going on here?


title: How to implement nested With as a single construct using functional programming (Fold)?

text: It is possible to define my own `With` construct where each _local constant_ can depend on the previous defined _local constants_? I wish to replace something like this               With[{m=10},       With[{h=1/m},         Table[{i h}, {i, 0, m}]       ]     ]      with something like this               WithMany[{m=10, h=1/m},         Table[{i h}, {i, 0, m}]     ]      The very basic idea is to use `Fold`:               Attributes[WithMany] := {HoldAll};     WithMany[{vars___}, body_] := Fold[With[{#2}, #1] &, body, {vars}]      but we need to properly evaluate the argumens in a non-standard way, possibly using `Hold` and related constructs. I'm not so fluent with this. An improvement would be to use the minimum number of With constructs depending on the dependencies between variables. Any help will be appreciated. **EDIT** As several people pointed out the original question has already been answered. This solve my immediate needs but I'm still interested to other implementation. @Leonid Shifrin think the referred answer already use the best approach, the simplest, the most elegant, the most efficient and so, but, even if true, I consider an interesting programming exercise to try different approach, like the one in my original question, using functional programming and `Fold` The sketch of a possible implementation is the following:               Attributes[WithMany] := {HoldAll};     WithMany[vars : {__}, body_] :=      Block[{With},       Attributes[With] = {HoldAll};       ReleaseHold@Fold[         With[{#2}, #1] &,         Hold[body],         Reverse@Thread@Hold@vars         ]       ]      I don't understand if there is some limit or issue with this implementation, or if it is fully equivalent to the one in the referred answer and to nested `With` costruct (after adding Syntax coloring and handling `SetDelayed`)? At a first sight I like more my approach (if it works properly of course) and I think is cleaner. It also appears slightly faster, according to some very basic tests. But I recognize that some people might prefer a different approach.


title: Bug in PositiveDefiniteMatrixQ?

text: This seems like a bug in `PositiveDefiniteMatrixQ` to me:               m = {      { 2, -1},       {-3,  2}     };          PositiveDefiniteMatrixQ[m]     (* => False *)          PositiveDefiniteMatrixQ @ SparseArray[m]     (* => True *)      This is for version 9 and above; older versions (6-8) don't seem to be affected.


title: Is it possible to use Compile on a function with optional arguments?

text: My _Mathematica_ is a little rusty, so apologies in advance. I think my problem is quite simple, but I can't seem to find the answer on my own! Simple example : `j[x_, y_: 1] := x + y` where x and y are integer numbers. How would you go about implementing Compile using this function?


title: How can I get rid of extra commas in Export/Import?

text: Consider the following example of trying to export the following table:               Export["test.dat", {{{1, 1}, {2, 2}}, {{3, 3}, {4, 4}}}, "Table"];      Now I import to see what I get:               Import["test.dat", "Table"]     {{{1,,1}, {2,,2}}, {{3,, 3}, {4,,4}}}      which contains extra undesirable commas. I've trying making the data type a "List" but that possessing an issue in which elements are not separated by commas. How can I fix this problem so the the imported table is the same as I exported?


title: Problems with NIntegrate

text: I'm having trouble to do the following numerical integrations:               iEAs[Q_?NumericQ, m1_?NumericQ, m2_?NumericQ, mh_?NumericQ, V_?NumericQ, Vc_?NumericQ, A_?NumericQ, Ac_?NumericQ] := m1 Q NIntegrate[ x (A Ac (m2 + m1 (-1 + x)) + V Vc (m1 + m2 -          m1 x))/(8 \[Pi]^2 (-mh^2 (-1 + x) + (m2^2 + m1^2 (-1 + x)) x)), {x, 0, 1}, MaxRecursion -> 100, WorkingPrecision -> 13];          iEAf[Q_?NumericQ, m1_?NumericQ, m2_?NumericQ, mh_?NumericQ, V_?NumericQ, Vc_?NumericQ, A_?NumericQ, Ac_?NumericQ] := m1 Q NIntegrate[-(  (A Ac (12 m2 (1 + x) + m1 (1 - 9 x - 12 x^2)) + V Vc (12 m2 (1 + x) + m1 (-1 + 9 x + 12 x^2))))/(96 \[Pi]^2 (-m2^2 (-1 +x) + (mh^2 + m1^2 (-1 + x)) x)), {x, 0, 1}, MaxRecursion -> 100, WorkingPrecision -> 13];          iVAv[G_?NumericQ, m1_?NumericQ, m2_?NumericQ, M_?NumericQ, V_?NumericQ, Vc_?NumericQ, A_?NumericQ, Ac_?NumericQ] := G m1 NIntegrate[- (A Ac (-3 m2 (1 + x) + m1 (-3 + x + 2 x^2)) +      V Vc (3 m2 (1 + x) + m1 (-3 + x + 2 x^2)))/(8 \[Pi]^2 (M^2 (-1 + x) - (m2^2 + m1^2 (-1 + x)) x)), {x, 0, 1}, MaxRecursion -> 100, WorkingPrecision -> 13];          iVAf[Q_?NumericQ, m1_?NumericQ, m2_?NumericQ, M_?NumericQ, V_?NumericQ, Vc_?NumericQ, A_?NumericQ, Ac_?NumericQ] := m1 Q NIntegrate[ -( (V Vc (m1 - 2 m2 + m1 x) + A Ac (m1 + 2 m2 +      m1 x))/(4 \[Pi]^2 (M^2 + (m1^2 + m2^2) (-1 + x)))), {x, 0, 1}, MaxRecursion -> 100, WorkingPrecision -> 13];      Then when I try to calculate my other function, that is just a sum of several of those integrals taken with diferent arguments, I get the following errror: > During evaluation of In[1]:= NIntegrate::zeroregion: Integration region > {{1.000000000000,0.999999999999999999999999999972752437499605743914855469900697130}} > cannot be further subdivided at the specified working precision. NIntegrate > assumes zero integral there and on any further indivisible regions. >> > > During evaluation of In[1]:= NIntegrate::inumri: The integrand > -((3.94734084367020280294200477311377373096717807463275517933069283*10^-10 > (1.2679004580000000000 (1+x)+0.10565837150000000000 (1-9 x-12 > x^2)))/(-0.0111636914680320122499999999999999999999999999999999999999121163 > (-1+x)+0.011163691468032012250 (-1+x) x)) has evaluated to Overflow, > Indeterminate, or Infinity for all sampling points in the region with > boundaries > {{0.999999999999999999999999999972752437499605743914855469900697130,0.999999999999999999999990130457402984116116415865423076016809530}}. > >> > > > During evaluation of In[1]:= NIntegrate::zeroregion: Integration region > {{1.000000000000,0.999999999999999999999999999972752437499605743914855469900697130}} > cannot be further subdivided at the specified working precision. NIntegrate > assumes zero integral there and on any further indivisible regions. >> > > During evaluation of In[1]:= NIntegrate::inumri: The integrand > -((3.94734084367020280294200477311377373096717807463275517933069283*10^-10 > (1.2679004580000000000 (1+x)+0.10565837150000000000 (1-9 x-12 > x^2)))/(-0.0111636914680320122499999999999999999999999999999999999999121163 > (-1+x)+0.011163691468032012250 (-1+x) x)) has evaluated to Overflow, > Indeterminate, or Infinity for all sampling points in the region with > boundaries > {{0.999999999999999999999999999972752437499605743914855469900697130,0.999999999999999999999990130457402984116116415865423076016809530}}. > >> > > > During evaluation of In[1]:= NIntegrate::slwcon: Numerical integration > converging too slowly; suspect one of the following: singularity, value of > the integration is 0, highly oscillatory integrand, or WorkingPrecision too > small. >> > > During evaluation of In[1]:= NIntegrate::eincr: The global error of the > strategy GlobalAdaptive has increased more than 400 times. The global error > is expected to decrease monotonically after a number of integrand > evaluations. Suspect one of the following: the working precision is > insufficient for the specified precision goal; the integrand is highly > oscillatory or it is not a (piecewise) smooth function; or the true value of > the integral is 0. Increasing the value of the GlobalAdaptive option > MaxErrorIncreases might lead to a convergent numerical integration. > NIntegrate obtained -1.102332818474*10^-28 and 1.773650837526`13.*^-29 for > the integral and error estimates. >> > > During evaluation of In[1]:= NIntegrate::slwcon: Numerical integration > converging too slowly; suspect one of the following: singularity, value of > the integration is 0, highly oscillatory integrand, or WorkingPrecision too > small. >> > > During evaluation of In[1]:= NIntegrate::eincr: The global error of the > strategy GlobalAdaptive has increased more than 400 times. The global error > is expected to decrease monotonically after a number of integrand > evaluations. Suspect one of the following: the working precision is > insufficient for the specified precision goal; the integrand is highly > oscillatory or it is not a (piecewise) smooth function; or the true value of > the integral is 0. Increasing the value of the GlobalAdaptive option > MaxErrorIncreases might lead to a convergent numerical integration. > NIntegrate obtained > 1.68427508260603075850603189688997779553482730498560866417565317`63.*^-25 > and > 6.25652496229563136928773273149849536309587019886986176252873178`63.*^-26 > for the integral and error estimates. >> > > During evaluation of In[1]:= NIntegrate::slwcon: Numerical integration > converging too slowly; suspect one of the following: singularity, value of > the integration is 0, highly oscillatory integrand, or WorkingPrecision too > small. >> > > During evaluation of In[1]:= General::stop: Further output of > NIntegrate::slwcon will be suppressed during this calculation. >> > > During evaluation of In[1]:= NIntegrate::eincr: The global error of the > strategy GlobalAdaptive has increased more than 400 times. The global error > is expected to decrease monotonically after a number of integrand > evaluations. Suspect one of the following: the working precision is > insufficient for the specified precision goal; the integrand is highly > oscillatory or it is not a (piecewise) smooth function; or the true value of > the integral is 0. Increasing the value of the GlobalAdaptive option > MaxErrorIncreases might lead to a convergent numerical integration. > NIntegrate obtained -1.343930509261*10^-26 and 7.504336838898`13.*^-27 for > the integral and error estimates. >> > > During evaluation of In[1]:= General::stop: Further output of > NIntegrate::eincr will be suppressed during this calculation. >> > > During evaluation of In[1]:= NIntegrate::zeroregion: Integration region > {{1.000000000000,0.999999999999999999999999999972752437499605743914855469900697130}} > cannot be further subdivided at the specified working precision. NIntegrate > assumes zero integral there and on any further indivisible regions. >> > > During evaluation of In[1]:= General::stop: Further output of > NIntegrate::zeroregion will be suppressed during this calculation. >> > > During evaluation of In[1]:= NIntegrate::inumri: The integrand > -((3.94734084367020280294200477311377373096717807463275517933069283*10^-10 > (1.2679004580000000000 (1+x)+0.10565837150000000000 (1-9 x-12 > x^2)))/(-0.0111636914680320122499999999999999999999999999999999999999121163 > (-1+x)+0.011163691468032012250 (-1+x) x)) has evaluated to Overflow, > Indeterminate, or Infinity for all sampling points in the region with > boundaries > {{0.999999999999999999999999999972752437499605743914855469900697130,0.999999999999999999999990130457402984116116415865423076016809530}}. > >> > > > During evaluation of In[1]:= General::stop: Further output of > NIntegrate::inumri will be suppressed during this calculation. >> > > Out[56]= -0.1054127670153 - 0.10565837150000000000 > NIntegrate[-(0.0006115582135884999042 \ 0.0006115582135884999042 (12 > 0.10565837150000000000 (1 + x) + 0.10565837150000000000 (1 - 9 x - 12 x^2)) > + 0 0 (12 0.10565837150000000000 (1 + x) + 0.10565837150000000000 (-1 + 9 x > + 12 x^2)))/(96 [Pi]^2 (-0.10565837150000000000^2 (-1 + x) + (0^2 + > 0.10565837150000000000^2 (-1 + x)) x)), {x, 0, 1}, MaxRecursion -> 100, > WorkingPrecision -> 13] I have tried many methods of integration. For most of them I get the kind of error above, for local adaptive methods I don't get any error, but I left Mathematica running for a whole afternoon and it didn't finish the calculation (it just kept running). I need the WorkingPrecision->13 because I'm going to compare this result with the electron anomalous magnetic moment (which has got 12 significant digits for it's experimental value). My final goal is to use thse integrals for several values of it's parameters, and then make RegionPlots comparing my calculations with the experimental value. EDIT: If I get divergences it is fine for me to discard the parameter values (m2, mh and M) where they happen. So, if anyone can find a way to solve my problem, I would be very grateful.


title: Why don't some functions work in trial versions of Mathematica?

text: I currently use the trial version before I decide to upgrade. However, a number of expressions don't work, i.e. it results in some errors that I don't know how to interpret. For example, if I use the simple `GeoGraphics[]` expression from the help menu, it results in the error message               General::unavail: ExportString is not available in this version of the Wolfram Language.      This error pops up in multiple contexts (e.g. other Geo-expressions, `CloudDeploy`, etc.) and I have no clue why.


title: Plot data as TradingChart

text: Does anyone know how to make a two data plot such that one of the data samples is showed as the volume transactions in `TradingChart` function? Thanks. EDIT: Sorry the english. So, I have two data samples. I want to plot one of them in a ordinary plot using, for example, `ListLinePlot`, but the second data sample to be showed bellow in the same way the volume is ploted in `TradingChart`. ![enter image description here](http://i.stack.imgur.com/qRV9h.gif) EDIT2: In resume I have 2 data samples. I want the first to be ploted in the main graph, and the second bellow. EDIT3:               Data1 = {{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}, {7, 1}, {8, 4}, {9, 6}, {10, 4}, {11, 5}, {12, 4}, {13, 6}, {14, 11}, {15, 6}, {16, 9}, {17, 15}, {18, 18}, {19, 24}, {20, 5},{21, 9}, {22, 8}, {23, 15}, {24, 12}, {25, 12}, {26, 8}, {27, 6}, {28, 0}, {29, 0}, {30, 1}, {31, 0}, {32, 0}, {33, 8}, {34, 3}, {35, 6}, {36, 1}, {37, 1}, {38, 1}, {39, 0}, {40, 0},{41, 0}, {42, 0}, {43, 0}, {44, 0}, {45, 0}, {46, 0}, {47, 0}, {48, 0}, {49, 0}, {50, 0}, {51, 0}};               Data2 = {{0, 2.509410662937836}, {1, 2.4808803466341955}, {2, 2.540569347654955}, {3, 2.547132749506656}, {4, 2.5608766053468215}, {5, 2.581673613536808}, {6, 2.604984165739864},{7, 2.6278553420965545}, {8, 2.6503872000749418}, {9, 2.6752177853363124}, {10, 2.7057947186702784}, {11, 2.745031662921106}, {12, 2.7943757324055767}, {13, 2.853013933116065},{14, 2.917745974429515}, {15, 2.983839933241766}, {16, 3.0465660811621076}, {17, 3.102516932682284}, {18, 3.1500203982948363}, {19, 3.188703244889767}, {20, 3.218713885646367},{21, 3.240043336569459}, {22, 3.252119187906068}, {23, 3.2536542495812055}, {24, 3.242674122710854}, {25, 3.2167232385868556}, {26, 3.17342632177792}, {27, 3.1117145450146624},{28, 3.0337272881633637}, {29, 2.9463165559593465}, {30, 2.860119427488097}, {31, 2.7856903736887726}, {32, 2.72960093847454}, {33, 2.693619848357109}, {34, 2.676505085841342},{35, 2.675912875804714}, {36, 2.688928643855797}, {37, 2.711270365853601}, {38, 2.7362623567711375}, {39, 2.7552236175724216}, {40, 2.760135480832154}, {41, 2.7472510017985674},{42, 2.7188819751432343}, {43, 2.6851673012886823}, {44, 2.6583557887909524}, {45, 2.640803683563485}, {46, 2.632087208191991}, {47, 2.6237017095679587}, {48, 2.59890527467275};


title: Mesh for points in 3D

text: I've got a set of Eisenstein integers (triangle lattice points in the complex plane), and I've selected them to be above a line, so that they form a triangle: ![eisenstein triangle above line](http://i.stack.imgur.com/wR8il.png) I then took these 2D points and embedded them in 3D space, with the z-axis chosen randomly:               points3d = Map[{#[[1]], #[[2]], RandomReal[]} &, eisensteinIntegers]     Graphics3D[Point /@ points3d, Boxed -> False]      ![3d points](http://i.stack.imgur.com/BOLJi.png) I would like to have those points form a triangular mesh, similiar to the Delaunay mesh for the eisenstein integers: ![Delaunay mesh](http://i.stack.imgur.com/NhJUf.png) Except that the Delaunay mesh on the 3D points forms a solid, not a surface. How can I form a mesh surface from these points?


title: Why does Mathematica appear to change the head of certain expressions?

text: I don't know if the question trivial or not (if so I will delete it), but here is what I have: I know that               x x     (*  x^2  *)      Looking at the full form gives               FullForm[Times[x, x]]     (* Power[x, 2] *)      It is clear that the `Times` head has been changed to `Power` head. I just wonder how does this happen. Can I control this behavior to stop this conversion between heads?


title: How to programmatically replace an expression in a .m file

text: I'm trying to write some code to programmatically replace a particular expression in my `init.m` file with a different expression. (It'll probably be some multi-line construct wrapped in a `Module[{someTag}, ...]` (where `someTag` is chosen to be unique and descriptive).) I was naively thinking `Import["init.m", "HeldExpressions"]` was going to be just what I needed, and would roundtrip nicely with an `Export[]`, but `Import[]` doesn't seem to help me preserve white space or comments. So I think I'm going to have to do this as text, and not as a list of expressions. I'm prepared to write my own (simple) expression splitter, but I'd be thrilled if there's some way for me to avoid going down that path. This might be crazy talk, but is there any good way to enlist the help of Mathematica's parser to spot where an expression begins and ends?


title: How to copy code out of notebook to an external text editor without extra line feeds being added?

text: I am simply trying to copy code from a cell (input cell) in a notebook, to paste the code into a plain text editor, and not have some lines wrap in the middle. I need to copy the code, as is, to a text editor, so I show it verbatim in there. I copy the code by selecting the cell, and then do COPY AS, and select INPUT TEXT. Then paste it into the other text editor. (if I try COPY AS PLAIN TEXT, then things are worst, I lose all formatting, so that is not an option) For some reason, some lines that are longer than some length, will end up wrapping in the text editor when pasted. The LF are inserted in different places depending on the length of the line. I see a CRLF added where this was not in the notebook. Here is a screen shot, where I have 2 cells, and the result of copying each cell to the text editor. You can see that the first cell, which is the same as the second cell, except one line in there is a little tiny bit longer than what is in the second cell (I added `+ x` to that line to make it little longer). Now that line was wrapped in the copy in 2 places. When the second cell, the line wrapping was in one place. ![enter image description here](http://i.stack.imgur.com/KIuGL.png) Here are the 2 cells shown in the image above, so you can try that yourself:               foo {z_} := Module[{x, y},       If[z < 1,        x + y/2 + Sin[3 x] - 43453488362 Cos[x]/Pi - (343^4 - Sin[34 - x]) + 34 Sin[x y]/(x y) + x,        x - y        ]       ]      second cell               foo {z_} := Module[{x, y},       If[z < 1,        x + y/2 + Sin[3 x] - 43453488362 Cos[x]/Pi - (343^4 - Sin[34 - x]) + 34 Sin[x y]/(x y),        x - y        ]       ]      Here is a screen shot showing the locations of the CRLF characters that are added during the copy of both cells to the text editor. ![enter image description here](http://i.stack.imgur.com/I84Qq.png) I would like to be able to copy the code from the cell to a text editor, without any extra LF being inserted during the copy. I think this problem is due to the notebook itself, but not sure. I tried different text editors, and they are show the same problem. So the LF is added during the copy, and not during the paste. I am on windows 7, using version 9. **Update** I have just found a work around !! But this can be done for the whole notebook, and not individual cells. But that is ok. I could always copy the cell to its own notebook. ## Here are the steps to copy code out of a notebook without extra CRLF   1. select File->SAVE AS ->Rich Text format (.rtf)   2. Using MS WORD (or any other program that can read .RTF), open the .rtf file   3. Select and Copy the text from word using the mouse.   4. Paste, using the mouse, into the other text editor (notepad, etc...) Now no line wrapping appear! No extra CRLF are seen. ![enter image description here](http://i.stack.imgur.com/ORbqH.png) So, I am happy now. This works for me, as a work around. It would be nice to know though if it is possible why this happens. **Update** Well, the excitement did not last for long. Even though the above solution fixes the extra CRLF problem, it introduces new problems. Many of Mathematica symbols in the code do not show up correctly in .rtf (all the 2D math symbols for examples. So this solution does not work. So I still need to find a way around this. More research is needed.


title: Why does Evaluate[a[[1]]]=0 assign a value to a variable while a[[1]]=0 doesn't?

text: I'm trying to do a small page counter with Mathematica, for leting me know about my reading progress on some books. I'm stuck on a problem:               Clear["Global`*"]     a = {v1, v2, v3, v4, v5, v6}     a[[1]] = 0     v1      With this, I'm trying to give 0 as a value to v1, but it seems that it swaps the v1 for 0 instead. I was expecting the evaluation of v1 to give me 0 as a value, but it still gives me v1, I've managed to partialy solve this with the following addition:               Clear["Global`*"]     a = {v1, v2, v3, v4, v5, v6}     Evaluate[a[[1]]] = 0     v1      When the v1 is evaluated, it gives me 0 as output, but it's not working in my program and I have no idea why this is happening. I've also managed to perform a separate test by evaluation both:               Clear["Global`*"]     a = {v1, v2, v3, v4, v5, v6}     Evaluate[a[[1]]] = 0     v1          Clear["Global`*"]     a = {v1, v2, v3, v4, v5, v6}     a[[1]] = 0     v1      In this case, it the outputs for both v1's are v1. Why is this happening? > My program(If needed): >   >   >     Clear["Global`*"] >     g = 1; i = 1; l = {}; ln = {}; pi = {}; m = 1; >     r1 := AppendTo[l, ToExpression["p" <> ToString[i++]]] >     r2 := AppendTo[ln, n] >     r3 := Clear[n] >     r4 := AppendTo[pi, np] >     r5 := Clear[np] >     r6 := Evaluate[l[[m]]] = 0 >     r7 := m++ >   >     o1 = Button["+1", r1; r2; r3; r4; r5; r6; r7, ImageSize -> {30, 19}]; >     o2 = InputField[Dynamic[n], String, FieldSize -> {15, 1}]; >     o3 = InputField[Dynamic[np], Number, FieldSize -> {4, 1}]; >     o4 = {o1, o2, o3}; >     o5 = Style["Book", 12]; >     o6 = Style["Book Title", 12]; >     o7 = Style["# Pages", 12]; >     o8 = {o5, o6, o7}; >   >     Grid[{o8, o4}, Frame -> True] >   >     t = Table[Button[ToString[x], Delete[l, {x}]], {x, 1, Length[l]}] // >       Dynamic >     l // Dynamic >     ln // Dynamic >     pi // Dynamic >


title: how can I generate a sequence of assignments?

text: I want to make a sequence like follows               r[1]=     r[2]=     r[3]=     r[4]=     ....     r[n]=      The above `r[i]` represents coordinates which I have to type in manually one by one. So I make such a sequence to make the typing easier and more confortable. (even without having to type the `=`, I am so lazy, I admit). If the problem involve n coordinate, I just generate a sequence of length n. So I naively write as follows               Table[r[i]= ,{i,1,n}]//TableForm      But with `=` there, I can't make such a list. So how could I generate a sequence of such incomplete expressions (like the above expressions, the `=` has no right side, this makes _Mathematica_ can't table it)?


title: Show does not combine the plots

text: i've the following problem: because it's not possible to plot complex numbers (or is it?) i created my own "function":                   complexPlot[cn_] :=            Plot[0, {x, -100, 100},                 PlotRange -> {-500, 500},                AspectRatio -> 1,                  AxesLabel -> {Re, I },                Epilog -> {Background -> None, PointSize[0.03],                 Point[{{Re[cn[[1]]], Im[cn[[1]]]}, {Re[cn[[2]]],                       Im[cn[[2]]]}, {Re[cn[[3]]], Im[cn[[3]]]}}]}       ]      with complexPlot, I can plot my complex Numbers, but i want to have one graphic for all my number pairs.                   myPlots = Table[                         complexPlot[linPolesAll[[n]]],                         {n, 1, 16}]              Show[myPlots]      Does not work, it overlays all Plots with the last one (tried it with Show[myPlots[[1]],myPlots[[10]]]) any ideas? Thanks!


title: Display function value on hover?

text: I have used Manipulate in conjunction with Plot to draw a function's graph and I would like to show the current x-axis value and function value while hovering over the function's plot. How can I achieve this? Thanks.


title: Include Headers on first page

text: I know it is possible to check the box "Include headers on first page" in the "Headers and Footers" dialog box of the Print Settings menu item, but is it also possible to check this using commands in the Notebook itself? It would be for the current notebook. Thanks for all help, as always!


title: Problem setting up edge rendering function

text: I have a graph, and I want my `EdgeRenderingFunction` to colour the edges based on the vertex they originate from. In this toy example, I'm trying to get the edge originating from vertex 1 to be red:               GraphPlot[{1 -> 2, 2 -> 3, 3 -> 4, 5 -> 1, 5 -> 2, 5 -> 3, 5 -> 4,        1 -> 4, 3 -> 5, 3 -> 3},       EdgeRenderingFunction -> (If[First[#1] === 1, {Red, Line[#1]},           Line[#1]] &), VertexLabeling -> True]      ![bad](http://i.stack.imgur.com/04rky.jpg) What am I doing wrong? I was following the (slightly more complicated) model given in the _Mathematica_ documentation:               GraphPlot[{1 -> 2, 2 -> 3, 3 -> 4, 5 -> 1, 5 -> 2, 5 -> 3, 5 -> 4,        1 -> 4, 3 -> 5, 3 -> 3},       EdgeRenderingFunction -> (If[          Length[#1] > 2, {Red, Line[#1],            Text[If[First[#1] === Last[#1], "loop", "multiedge"],             LineScaledCoordinate[#1, .7], Background -> White]},           Line[#1]] &), VertexLabeling -> True]      ![good](http://i.stack.imgur.com/caVav.jpg)


title: How can I define a function that takes a list of reals?

text: I'm trying to define a function `f` which takes a list of reals. My purpose is to build a function which I can give a list of reals, integers or strings and have it build an appropriate probability distribution for. So I'd like to do something like               f[{samples_Real}]:=makeRealDist[samples];     f[{samples_Integer}]:=makeInteger[samples];     f[{samples_String}]:=makeCategoricalDist[samples];      I can easily match on `Real`/`Integer`/`Strings`. The part I can't figure out is how to match on a list of `Real`/`Integer`/`String`.


title: What is the most convenient way to change options for Graph[] objects?

text: What is the most convenient way to change options such as `VertexLabels` in existing `Graph` objects? (Version 7 users note: `Graph` is new in Mathematica 8.) * * * With graphics, we can use `Show` for this, not matter what function was originally used to produce the graphic:               g = Plot[Sin[x], {x, 0, 10}]     Show[g, Axes -> False, Frame -> True]      Is there an analogous function for `Graph`s? Suppose we already have a graph, and now we need to show vertex labels in a different way. Here's a workaround using `HighlightGraph`:               g = Graph[{1 -> 2}]     HighlightGraph[g, {}, VertexLabels -> "Name"]      While it works, this is not really what `HighlightGraph` is meant for. * * * Please note that `Graph` objects are atomic before trying to take them apart. Also, I'm looking for the safest and most robust solution. I'm hoping there's a function I overlooked.


title: Integral of integral — it takes too much time

text: When I evaluate the following expression in _Mathematica_ , it takes so much time that I don't want to wait for the evaluation to complete. So I think that there must be a better approach.               wewint[lx_?NumericQ, ly_?NumericQ] := NIntegrate[         Cos[lx]*Cos[qx] + Sin[lx]*Sin[qx], {qx, -Pi, Pi}, {qy, -Pi, Pi},          Method -> Automatic];     NIntegrate[wewint[lx, ly], {lx, -Pi, Pi}, {ly, -Pi, Pi}, Method -> Automatic]      If I use `Cos[lx-qx]` instead of `(Cos[lx]*Cos[qx] + Sin[lx]*Sin[qx])`, the effect is the same. In reality, the expression I am working with is much more complicated and it couldn't be calculated analytically.


title: How to speed up the function DelaunayTriangulation?

text: First define a function `meshGrid` to generate some points:               meshGrid[{x1_, x2_, y1_, y2_}, h0_] :=        With[{yh0 = h0*Sqrt[3.]/2},          Array[{(#1 - 1)*h0 + x1 + (1 + (-1)^#2) h0/4, (#2 - 1)*yh0 +              y1} &, Ceiling@{(x2 - x1)/h0, (y2 - y1)/yh0}]]~Flatten~1;          p = meshGrid[{-1, 1, -1, 1}, 0.05];      The computing time of `DelaunayTriangulation`:               Needs["ComputationalGeometry`"];     DelaunayTriangulation[p] // Timing // First      In my computer it gives `18.533s` Matlab saves much time if does the same thing: ![enter image description here](http://i.stack.imgur.com/5s0vV.png) **====================================Update=====================================** @halirutan really made a great attempt to point the way, but I failed to compile and didn't get the right answer, maybe I should learn something before. Here I find another way in this blogpost, which also relates to Qhull but easier to implement. You can get more infomation from here. Before changing anything, two files need to be downloaded, one is mPower, from which we need is mPower.m, another one is Qhull. You can get the rest steps from that blog, only step two is worthy of note: step 2: download qhull for windows, you may need to change the name, and put it into the folder C:\qhull. **Then Copy all the *.exe files in bin folder and paste them in folder qhull, errors will occur without this step.**


title: Make a scatter plot

text: Considering I have weather data for last 10 years for London, how can I make a scatter plot that will show the previous day's temperature as a function from today's temperature?


title: Custom ticks in distribution chart

text: I am trying to just get simple logarithmic ticks to the distribution chart, and failing... It is unhappy with any `FrameTicks` format I try (sparing `-> Automatic`). What am I doing wrong?               DistributionChart[       Log[RandomReal[ExponentialDistribution[100], 50]],        Frame -> True, ChartStyle -> LightBlue,        FrameTicks -> {{{{Log[0.001], "0.001"}, {Log[0.01],"0.01"}}, None}, {None, None}},       ChartElementFunction -> "HistogramDensity",       ChartLabels -> {"s "}, BaseStyle -> {FontSize -> 14, FontFamily -> "Helvetica"}]


title: How to implement hive plot for graphs in Mathematica?

text: I'm trying to implement a version of the _hive plot_ advocated in [Kryzywinski, _et al._ , 2012]. There are many examples of such graphs on the author's webpage. It would be good enough for me to have three axes. I'm now able to project the coordinates onto three axes and style my graph like this via `VertexCoordinates`: ![basic hive](http://i.stack.imgur.com/TbdEK.png) First of all, is there any way to make edges be arcs and not straight lines?   1. Krzywinski M, Birol I, Jones S, Marra M (2012). _Hive Plots — Rational Approach to Visualizing Networks_. Briefings in Bioinformatics 13(5), 627-644.


title: Alternating Axis Labeling between Left and Right Axis

text: I'm using the following to label a MatrixPlot: `FrameTicks -> {{yticks, None}, {None, xticks}},` I'm labeling these ticks with text. It is impossible to get the graph to a reasonable size while maintaining legibility of the text all on a single axis. So what I'm attempting to do is sub-divide my label list, alternating the label that goes to one of two tick expressions: `FrameTicks -> {{leftyticks, rightyticks}, {None, xticks}},` But I have no idea how to do that. As of right now I am sorting the labels alternatively by hand and pasting them in to 'leftyticks' and 'rightyticks'. There has got to be a faster way to drag a list from a file, split it in alternating sequence, and dump the products in to the two tick-label groups, right?


title: Loading custom notation on startup without showing the Notation palette

text: I was creating some custom notations using the Notation package and it works fine. I put it in my default personal package, and it loads fine on _Mathematica_ 's startup. To make it complete I need just one more thing. How can I suppress the Notation palette from appearing every time I launch _Mathematica_? Is there some command that I can put into my package?


title: Correctly set up FindMinimum

text: I am trying to setup the following minimization to align two astronomical images.               scfac =        FindMinimum[         Log[AlignCriterion3[imTargetFM*SC, imRefFiltFM*SC, alpha]], {alpha, 1},          PrecisionGoal -> 6, AccuracyGoal -> 10];      where,               AlignCriterion3[im_, imRef_, scfac_] :=        Plus @@ Plus @@ ((im - ImRescale[imRef, scfac])^2)      and               ImRescale[Im_, ScFac_] :=        Module[{n, res},          n = Dimensions[Im][[1]];         Print[ScFac];         res = Resize[ImageData[ImageResize[Image[Im], {n*ScFac, n*ScFac}]], n]       ]      Clearly, I do not know how to setup the `FindMinimum` since I keep getting the following error: > ImageResize::imgrssz: The size {120 alpha,120 alpha} is not a valid image > size specification. How do I set it up so that the value of alpha is actually passed to the Rescaling code I've written. ![example of an image that I am trying to align. I have the x & y shifts pegged down pretty accurately - the idea is to scale the image size to try and fix what I think is some kind of scale based alignment issue.](http://i.stack.imgur.com/awjfW.png) Example of an image that I am trying to align. I have the x & y shifts pegged down pretty accurately - the idea is to scale the image size to try and fix what I think is some kind of scale based alignment issue.


title: How do I convert from NAD 83 State Plane Coordinates to Latitude and Longitude?

text: I am trying to convert NAD 83 State Plane New York Long Island coordinates to Latitude/longitude. Below is my code - what am I doing wrong?               LatitudeLongitude[GeoPosition[{172248, 1002321, 0}, "SPCS83NY04"]]


title: RSolve Lotka-Volterra: A Closed Form Solution to this Difference Equation?

text: I would like to solve a difference equation, a Lotka-Volterra difference equation. I tried a model from http://www.stolaf.edu/people/mckelvey/envision.dir/nonDE.lotka-volt.html Using their parameters:               a = 0.04; b = 0.0005; c = 0.2; d = 0.1;      I obtain the following:               eqs = {r[n + 1] == r[n] + a*r[n] - b*r[n]*f[n], f[n + 1] == f[n] + b*d*r[n]*f[n] - c*f[n]}     RSolve[eqs, {r[n], f[n]}, n]          (* RSolve[{r[1 + n] == 1.04 r[n] - 0.0005 f[n] r[n],                f[1 + n] == 0.8 f[n] + 0.00005 f[n] r[n]}, {r[n], f[n]}, n] *)      Mathematica does not give any clue, what is wrong. Can anyone help me find out where the problem is?


title: Fast integration of 2D distribution across lines parallel to y-axis

text: I'm struggling with a small data set and a slow calculation. I have _hundreds_ of small 2D data arrays and need to integrate across several lines parallel to the y-axis. Let me start with the data array:               data={{51.6,10},{16.52,18},{48.835,12},{72.975,7},{61.085,19},{78.362,11},{24.312,25},           {26.818,5},{37.336,5},{70.647,18},{48.783,35},{40.379,35},{75.926,8},{23.226,8},           {54.727,18},{116.046,12},{20.597,20},{21.973,28},{74.821,7},{56.408,51}};      After rescaling and truncating the distribution, it looks like this:               dnorm=Transpose[Rescale/@Transpose[data]];     pdf[x_,y_]=PDF[TruncatedDistribution[{{0,∞},{0,∞}},                    SmoothKernelDistribution[dnorm,Automatic,{"Radial","Gaussian"}]],{x,y}];     ContourPlot[pdf[x,y],{x,0,1},{y,0,1}]      ![plot of distribution](http://i.stack.imgur.com/V4vOR.png) I am interested in the profile across a line parallel to the y-axis (say e.g. $x=0.5$) and do handle this profile as a distribution for this specific x-value. I need the 95% quantile for this specific distribution at the specific x-value. Finally, I am interested in all the quantile-values for all x-values between 0 and 1 (in the rescaled domain) and do rescale them back afterwards. I have written the following function, which works but need approx. 10 seconds (even without the line plot and sampling at 20 data points between 0 and 1). I have to evaluate _hundreds_ of data sets with this function, so I **need to speed it up**.               myquantile[d_List,q_]:=Block[{dnorm,pdf,x,y,func,int,ξ,ψ,sol,invx,invy,lp},       dnorm=Transpose[Rescale/@Transpose[d]];       pdf[x_,y_]=PDF[TruncatedDistribution[{{0,∞},{0,∞}},                      SmoothKernelDistribution[dnorm,Automatic,{"Radial","Gaussian"}]],{x,y}];       func[ξ_]:=Block[{},         int=NIntegrate[pdf[ξ,y],{y,0,1}];         ψ/.FindRoot[NIntegrate[pdf[ξ,y],{y,0,ψ}]/int==q,{ψ,0.8,0.9},Evaluated->False]];         {invx[x_],invy[x_]}=Rescale[x,{0,1},#]&/@({Min[#],Max[#]}&/@Transpose[d]);         sol=Interpolation[Table[{invx[x],invy[func[x]]},{x,0,1,0.05}]       ];       lp=Plot[sol[x],{x,invx[0],invx[1]},AxesOrigin->{invx[0],invy[0]}];       {sol,lp}     ];     myquantile[data, 0.95] // Timing      The final `InterpolatingFunction` looks like this (in the regular domain): ![plot of interpolant](http://i.stack.imgur.com/Yrkl1.png) Can anybody point me in the right direction? Is it possible to get the line distribution in a different and faster way? A `MarginalDistribution` is pretty much what I want, but it is the distribution for all x-values and it gives me no information on individual x-values. Thanks!


title: Eigenvectors for a large symbolic matrix

text: I'm trying to compute the eigenvectors for a 42x42 symbolic matrix (with one variable) in Mathematica. I get the following error: Eigenvectors::eivec0: Unable to find all eigenvectors. >> and the answer is:zero What could be a possible way to proceed? Thanks. my matrix is in this form: Matrix= {{-2.74685 + (11 j)/2, 0, -0.390857, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, -1.72219 + (11 j)/2, 0, -1.32891, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {-0.390857, 0, -1.01642 + (11 j)/2, 0, -2.79771, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, -1.32891, 0, -0.528246 + (11 j)/2, 0, -4.66286, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, -2.79771, 0, -0.204268 + (11 j)/2, 0, -6.72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, -4.66286, 0, -0.00765149 + (11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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0., 0, -5.808 - 5 j}} //MatrixForm


title: Integrate does not accept my integrand expression

text: I want to calculate the symbolic integral, but I could not obtain the final results from Mathematica.               $Assumptions = R > 0 && f > 0 && m ∈ Integers;     a1[a_] := Log[R Sqrt[2 (1 - Cos[a])]];     b[a_] := R (1 - Cos[a]);     c[a_] := R Sin[a];     d2[a_] := 2 R R (1 - Cos[a]);     d4[a_] := d2[a]^2;     Ebb[a_] := -a1[a] + b[a]^2/d2[a];     Ebc[a_] := b[a] c[a]/d2[a];     Ecc[a_] := -a1[a] + c[a]^2/d2[a];     fb[a_] := f Cos[m a];     fc[a_] := f Sin[m a];      when I calcualted wb ingetral as follows:               wb = Integrate[Ebb[a] fb[a] + Ebc[a] fc[a], {a, 0, 2  π}]      I found the result was not calculated -- I got the output: ![output](http://i.stack.imgur.com/Jf4Ff.png) Where did I make a mistake? Could you tell me how to do one bit more complicated integral by your method, please? I used the same method as you provided, but failed this time. Here I just introduced another angle u besides the angle a, and made fb and fc a little more complicated. But I guess that these minor changes should not affect your method to be applied.               a1[a_, u_] := Log[R Sqrt[2 (1 - Cos[u - a])]];     b[a_, u_] := R (1 - Cos[u - a]);     c[a_, u_] := R Sin[u - a];     d2[a_, u_] := 2 R R (1 - Cos[u - a]);     d4[a_, u_] := d2[a, u]^2;     Ebb[a_, u_] := -a1[a, u] + b[a, u]^2/d2[a, u];     Ebc[a_, u_] := b[a, u] c[a, u]/d2[a, u];     Ecc[a_, u_] := -a1[a, u] + c[a, u]^2/d2[a, u];     fb[a_] := Refb Cos[m a] - Infb Sin[m a];     fc[a_] := Refc Cos[m a] - Infc Sin[m a];               $Assumptions = True;     wb = Integrate[Ebb[a, u] fb[a] + Ebc[a, u] fc[a], {a, 0, 2 \[Pi]},      Assumptions -> R > 0 && Refb > 0 && Infb > 0 && Refc > 0 && Infc > 0 && m \[Element] Integers && {u, 0, 2 \[Pi]}]      > >     1/2 (-((2 Infb Sin[m \[Pi]]^2)/m) + (Refb Sin[2 m \[Pi]])/m + > (1/(m^2))Infb (-Hypergeometric2F1[1, -m, 1 - m, E^(-I u)] + >       Hypergeometric2F1[1, m, 1 + m, E^(-I u)] - >       Cos[2 m \[Pi]] Hypergeometric2F1[1, m, 1 + m, >         Cos[u] - I Sin[u]] + 2 m Log[R] - 2 m Cos[2 m \[Pi]] Log[R] + >       m Log[2 - 2 Cos[u]] - m Cos[2 m \[Pi]] Log[2 - 2 Cos[u]] + >       Hypergeometric2F1[1, -m, 1 - m, >         Cos[u] - I Sin[u]] (Cos[2 m \[Pi]] - I Sin[2 m \[Pi]]) + >       I Sin[2 m \[Pi]] - >       I Hypergeometric2F1[1, m, 1 + m, Cos[u] - I Sin[u]] Sin[ >         2 m \[Pi]]) + (1/(m^2)) I Refb (1 - Cos[2 m \[Pi]] - >       Hypergeometric2F1[1, -m, 1 - m, E^(-I u)] - >       Hypergeometric2F1[1, m, 1 + m, E^(-I u)] + >       Cos[2 m \[Pi]] Hypergeometric2F1[1, m, 1 + m, >         Cos[u] - I Sin[u]] + >       Hypergeometric2F1[1, -m, 1 - m, >         Cos[u] - I Sin[u]] (Cos[2 m \[Pi]] - I Sin[2 m \[Pi]]) + >       I Hypergeometric2F1[1, m, 1 + m, Cos[u] - I Sin[u]] Sin[ >         2 m \[Pi]] + 2 I m Log[R] Sin[2 m \[Pi]] + >       I m Log[2 - 2 Cos[u]] Sin[2 m \[Pi]]) - (Refb (m Cos[u] Sin[2 m \[Pi]] > - 2 Sin[m \[Pi]]^2 Sin[u]))/(-1 + >     m^2) + (Infb (2 m Cos[u] Sin[m \[Pi]]^2 + >       Sin[2 m \[Pi]] Sin[u]))/(-1 + m^2) + (1/(-1 + m^2)) 2 Sin[m \[Pi]] > (Sin[m \[Pi]] (Refc Cos[u] - Infc m Sin[u]) + >       Cos[m \[Pi]] (Infc Cos[u] + m Refc Sin[u]))) >   The help of `Limit` failed this time:               Limit[wb, m -> #] & /@ Range[-2, 2]      The final result is too long, so I do not copy it here. I am not sure where I made a mistake.


title: Remove linear trend from data

text: I have a large data set with 150k lines and two data columns. I noticed that there is a linear trend, which I want to remove. So, I do the following: first fit with a linear model               model = LinearModelFit[data, x, x]      then, I substract the fit from the data               data1 = data;     data1[[All, 2]] = data[[All, 2]] - model[data[[All, 1]]] + model[0];      This, however, takes unacceptable amount of time. Is there any way I can speed things up.


title: How do I visualize the result of EdgeColoring[g]?

text: Combinatorica has a heuristic edge-coloring function `EdgeColoring`. When I execute it on a graph, the result is a list of integers. My guess is that an integer $i$ at position $j$ in the list corresponds to coloring the edge $e$ at position $j$ with the color $i$. The Combinatorica documentation is helplessly scarce, and it's hard for a beginner to understand how to visualize the colored graph. Am I supposed to use `ShowGraph`, or `Highlight`, or something else? For example, consider the following.               << Combinatorica`     g = CompleteGraph[4];     c = EdgeColoring[g];      The output is now `{1, 2, 3, 3, 2, 1}`. How do I print out the graph with the colors on the edges showing?


title: Fitting a function

text: I defined and evaluated a function               Max2[t_?NumericQ] := Log[Abs[-1 + First[Maximize[sol1[[2]][x, t], 0 <= x <= L, x]]]];      Now, I expect this to be close to a straight line as a function of $t$, so I would like to get the best slope from a fit. Looking at the reference website, I don't understand how to linearly fit a function.


title: Finding all instances of length $N$ common subwords in two strings

text: Given a pair of strings, I'd like to return a list of all common subwords of a fixed length of "n" characters (i.e. contiguous subwords of length "n" that occur in both strings), allowing for overlaps. Is there a built-in or close- to-built-in way to do this in Mathematica?


title: Linear regression in a chosen range of points

text: Hi I'm absolutely newbie in Mathematica and have following problem: My list looks like `{{50, 0.75}, {51, 0.76}, ...`, and I want to choose a range out of my x-values (I don't want so say: _from point 150 to ..._ , I want to choose with values like _from x value 50 to 60_ ), with only these points a linear regression has to be done. I tried with `LinearModelFit[data, x, x]`, and Mathematica made a linear regression with all values, now I want to choose a range but I can't find a solution =( Has somebody an idea?


title: How can I get better control over StreamPlot?

text: I'm having some difficulties with the command `StreamPlot` in _Mathematica 7.0_. Here's the basic plots I'm doing :               StreamPlot[{x, -y}, {x, -2, 2}, {y, -2, 2}, Axes -> True,     AxesOrigin -> {0, 0}, FrameTicks -> None,      StreamPoints -> 12, StreamScale -> 0.15, PerformanceGoal -> "Quality"]          StreamPlot[{y, x}, {x, -2, 2}, {y, -2, 2}, Axes -> True,      AxesOrigin -> {0, 0}, FrameTicks -> None, StreamPoints -> 12,      StreamScale -> 0.15, PerformanceGoal -> "Quality"]      Here's the output, which I find ugly : ![Ugly output](http://i.stack.imgur.com/IvJw2.jpg)   * How can I define the number of arrows heads to be drawn on each curve? Currently, there are too many arrows on the curves. I would prefer a maximum of two (or maybe three) arrows per stream curve.   * How can I make the output perfectly symetric? Look for example at the second picture, which is terrible.   * How can I remove the straight stream lines?


title: Efficient way to generate random points with a predefined lower bound on their pairwise Euclidean distance

text: Using Mathematica what is an efficient way to generate a list of $n$ **random** two dimensional points $\\{x_i,y_i\\}$ where $i=1,...,n$ so that **no** two points $p_1$ and $p_2$ in the list has an Euclidean distance lower than say $d$ meaning $\|p_1-p_2\|\leq d$. I came up with the following solution. Though it works I wanted to know if some better method exists. **Code**               NodeGenetrator[LowerBound_, UpperBound_, DistanceBound_,SampleLength_] :=      Block[{list},           list = RandomReal[{LowerBound, UpperBound}, {1, 2}];           For[i = 0, Length@list <= SampleLength - 1, i++,               list = Module[{NewVal, dist},                             NewVal = RandomReal[{LowerBound, UpperBound}, 2];                             (*NewVal=RandomVariate[NormalDistribution[                             Mean@{LowerBound,UpperBound},DistanceBound],2];*)                             dist = Map[EuclideanDistance[NewVal, #] &, list];                             If[Min[dist] >= DistanceBound,                                 AppendTo[list, NewVal],                                 list                               ]                            ];              ];           list          ];     (* Define function parameters *)     LowerBound = 0;     UpperBound = 100;     DistanceBound = 5;     SampleLength = 60;     sample = NodeGenetrator[LowerBound, UpperBound, DistanceBound,SampleLength];     (ListPlot[#, Frame -> True, Axes -> False,PlotStyle -> PointSize[Large],     AspectRatio -> 1] &)@sample      **Output** ![enter image description here](http://i.stack.imgur.com/gLa0e.png)   1. As one can see this code uses `For` loop and also keeps on iterating until number of points requested is not met. This somehow makes the _execution time_ for this function unpredictable!    2. As expected the parameter `DistanceBound` has a important effect on the function behavior. If we try `DistanceBound=12.5` function evaluation becomes very _time consuming_.   3. Here we check only one mutual distance condition but is it possible to use a more _general test function_ that checks for more than one mutual characteristics involving those requested number of points that are to be generated. BR


title: Defining an integer-valued function on an integer domain

text: This should be an easy question! I want to define a function with domain = the 12 integers `{1,12}`, with the values `f[1]=31`, `f[2]=28`, `f[3]=31`, etc. (number of days in the month). This will be a part of nested `Do[]` loops running through the days of a non-leap year for a particular data set I am working with.


title: How can one define a custom data object?

text: In _Mathematica_ there are different objects like `InterpolatingFunction` or `SparseArray`? How can I define a custom data object with special data structure? **Example:**               f = Interpolation[{1, 2, 3, 5, 8, 5}];     f // InputForm      returns us               InterpolatingFunction[{{1, 6}}, {4, 3, 0, {6}, {4}, 0, 0, 0, 0, Automatic},      {{1, 2, 3, 4, 5, 6}}, {{1}, {2}, {3}, {5}, {8}, {5}}, {Automatic}]      But if one evaluates the above output one gets back               InterpolatingFunction[{{1, 6}}, <>]      I could not find any documentation how to do it for any custom data object that I want to define for my program.


title: Count number of sublists with a total not greater than a given max

text: Suppose I have a list of positive integers:               data={1, 1, 2, 3, 3, 3, 5, 5, 5, 7, 7, 8, 8, 9, 10, 10, 12, 16, 23}      I want to count the number of subsets up to length _t_ (including an empty set) whose total doesn't exceed the value _t_. The naive approach would be:               sumZaehl[t_, data_] :=       Length@Select[Total /@ Subsets[data, t], # <= t &]      But this would not work for larger list, because of the rapidly increasing number of subsets. I have an iterative method which works for larger list too:               sumZaehlIter[t_, data_] :=     Module[{n = Length[data], v, d, i, j},       For[i = 0, i <= t, i++, v[i] = 1];       For[i = 1, i <= n, i++,         d = data[[i]];         For[j = t, j >= d, j--,             v[j] = v[j] + v[j - d];       ]];     v[t]]      Is there a functional way to realize this?