title: Can mathematica solve this equation?

text: I have the following _Mathematica_ code to solve an equation coming from isoparameteric finite element for quadratic tetrahedron element. I need to get the iteroplation fast and accurate. I only find articles by iterative method and I want to know whether it is possible to get an analytical solution:               sol = Solve[ ( 2(1 - xi - eta - zeta)^2 - (1 - xi - eta - zeta)) x1 + (2xi^2 - xi) x2                   + (2eta^2 - eta) x3 + (2zeta^2 - zeta) x4 + 4(1 - xi - eta - zeta) xi x5                   + 4xi eta x6 + 4(1 - xi - eta - zeta) eta x7 + 4eta zeta x8                   + 4(1 - xi - eta - zeta) zeta x9 + 4xi zeta x10 == x  &&                  ( 2(1 - xi - eta - zeta)^2 - (1 - xi - eta - zeta)) y1 + (2xi^2 - xi) y2                  + (2eta^2 - eta) y3 + (2zeta^2 - zeta) y4 + 4(1 - xi - eta - zeta) xi y5                  + 4xi eta y6 + 4(1 - xi - eta - zeta) eta y7 + 4eta zeta y8                  + 4(1 - xi - eta - zeta) zeta y9 + 4xi zeta y10 == y  &&                   ( 2(1 - xi - eta - zeta)^2 - (1 - xi - eta - zeta))z1 + (2xi^2 - xi) z2                 + (2eta^2 - eta) z3 + (2zeta^2 - zeta) z4 + 4(1 - xi - eta - zeta) xi z5                 + 4xi eta z6 + 4(1 - xi - eta - zeta) eta z7 + 4eta zeta z8                  + 4(1 - xi - eta - zeta) zeta z9 + 4xi zeta z10 == z, { xi, eta, zeta}];     xx =   xi /. sol;     yy =  eta /. sol;     zz = zeta /. sol;      by collecting the coefficient of `xi`, `eta` and `zeta`, the original equation can be transformed to the following:               sol = Solve[{  a1 xi^2 + a2 xi + a3 eta^2 + a4 eta + a5 zeta^2 + a6 zeta                   + a7 xi eta + a8 eta zeta + a9 zeta xi == a0,                    b1 xi^2 + b2 xi + b3 eta^2 + b4 eta + b5 zeta^2 + b6 zeta                   + b7 xi eta + b8 eta zeta + b9 zeta xi == b10,                    c1 xi^2 + c2 xi + c3 eta^2 + c4 eta + c5 zeta^2 + c6 zeta                   + c7 xi eta + c8 eta zeta + c9 zeta xi == c10}, { xi, eta, zeta}];     xx =   xi /. sol;     yy =  eta /. sol;     zz = zeta /. sol;      where               {a1 b1 c1} = 2( {x1 y1 z1} + {x2 y2 z2} - 2{x5 y5 z5})      and so on. However, it seems to hang there for tens of minutes and it maybe impossible to get the analytical solution. I noticed that in real engineering, not all facets are curve facets. By this fact, we can suppose that               2x5 = x1 + x2     2x7 = x1 + x3     2x9 = x4 + x1      and so on. Therefore, the above equation is simplified as follows:                   sol = Solve[{ a2 xi + a4 eta + a6 zeta + a7 xi eta + a8 eta zeta + a9 zeta xi == a10,                       b2 xi + b4 eta + b6 zeta + b7 xi eta + b8 eta zeta + b9 zeta xi == b10,                        c2 xi + c4 eta + c6 zeta + c7 xi eta + c8 eta zeta + c9 zeta xi == c10},                      { xi, eta, zeta}];     xx =   xi /. sol;     yy =  eta /. sol;     zz = zeta /. sol;      Is there any good method to solve this equation?


title: Vertical "fractions" with more than 2 parts

text: Standard `FractionBox` syntax allows only 2 arguments and creates 2-part fraction for numerator and denominator. Is it possible to draw similar construction, but with more than 2 parts? Some sort of column with separators only between inner parts? The following code               Column[{"x", 200, Integrate[Sin[x^2], x]}, Alignment -> Center, Dividers -> Center]      draws best what I found but it does dividers of similar length in entire column. I would like dividers to accommodate two adjacent parts only.


title: Grid layout problems: different sizes when rendering on Mac and Windows

text: From the documentation for `ItemSize`: > {w,h} make all items the specified width and height and > In Grid, w is measured in ems, and h in line heights. This implies that a specification `ItemSize->{4,2}` means the item is 4ems wide and 2 line heights high, which in turn suggests that the item size in pixels will be `CurrentValue["FontMWidth"]*4` wide and `CurrentValue["FontLineHeight"]*high`. Therefore to make grids that render to a fixed number of pixels across various platforms you presumably should do (for an item of pixel dimension w,h = 100,20):               ItemSize:>{100/CurrentValue["FontMWidth"],20/CurrentValue["FontLineHeight"]}      **If this is not correct stop reading now and let me know!** The problem I have is that from Mac to Windows I am unable to get the same dimensions:               img1 = Rasterize[Grid[RandomInteger[{1, 100}, {10, 8}],        Alignment -> {Center, Center},        Background -> None,        BaseStyle ->          Directive[FontFamily :> CurrentValue["PanelFontFamily"],           FontSize :> CurrentValue["PanelFontSize"],           RGBColor[0, 0, 0.25]],        Frame -> All,        FrameStyle -> Directive[AbsoluteThickness[0.5], GrayLevel[0.7]],        ItemSize :> {{80, 260, {130}}/CurrentValue["FontMWidth"],           22/CurrentValue["FontLineHeight"]},        Spacings -> {0, 0}]]      ![enter image description here](http://i.stack.imgur.com/oBdd4.png)               ImageDimensions[img1]      Mma 8.0.4 on Mac 10.6.8               (* {751, 224} *)      Mma 8.0.4 on on Windows 7               (* {983, 274} *)      And when we check the em widths and line heights on both systems: Mma 8.0.4 on Mac 10.6.8               {CurrentValue["FontMWidth"], CurrentValue["FontLineHeight"]}     (* {12.9621, 9.875} *)      Mma 8.0.4 on Windows               {CurrentValue["FontMWidth"], CurrentValue["FontLineHeight"]}     (* {12.6, 10} *)      In other words similar em widths and line heights. The upshot is that I have had problems creating a grid on a Mac that doesn't go offscale when viewed on Windows. The screen resolutions (`SystemInformation["Devices", "ScreenInformation"]`) are 72 for Mac and 96 for Windows. The ratio of Windows image width for Mac width is close to 96/72 but the heights are not close to that ratio at all -- but in any case there is no mention of screen resolutions in the documentation. Does anyone have any thoughts on what is happening here and how I can get a grid of the same size on both Mac and Windows? **Edit** I think this example by @SjoerdC.deVries nails it:               Grid[{{"MMMMMMMMMMM", "MMMMMMMMMMMMMMMMMMMM"}}, ItemSize -> 5,      Spacings -> {0, 0}]      If the item size is in ems then you should expect only 5 "M" characters to fit in a grid cell ...right? Following the comment from @Silvia I have tested Serif, Sans-serif and monospace fonts: Sans-serif -- Helvetica gives 4Ms ![enter image description here](http://i.stack.imgur.com/uWTsi.png) Serif -- Times gives 4Ms ![enter image description here](http://i.stack.imgur.com/fihqL.png) Monospace -- Monaco gives many Ms ![enter image description here](http://i.stack.imgur.com/KdcPa.png) Note that using lower case "m" made no difference. Note that further investigation shows that the word wrapping has an effect here. With _just_ 5Ms the item size almost works. ![enter image description here](http://i.stack.imgur.com/7OGLO.png) Initial summary: So either the documentation is wrong, or it is incomplete, or the implementation is broken. Subsequent summary: the problem seems to reside with how Mathematica determines the font being used when doing the size calculations. It clearly responds when StandardForm is changed but does not respond to local font usage (apparently). Otherwise an item size of x/CurrentValue["FontMWidth"] should surely deliver an item xMs wide. **Edit #2** Confirmed as a bug by WRI tech support.


title: Use of Mathematica to generate report

text: I would like to generate a report for codes written in Mathematica, but I don't see basic features such as:   1. Table of Content generator   2. List of Figures   3. Abstract   4. Bibliography and other standard report generators like LaTex?


title: Importing web page data

text: I tried importing a webpage using `Import`: `Import["http://ultrasignup.com/m_results_participant.aspx?fname=Troy&lname=Siemers"];` which should give some info about a runner friend of mine (he gave permission to have his name shown here). Using `Import` as shown above gives generic HTML information but the table containing the data I want. Using the options `"Data"` and `"FullData"` do not give anything useful, either. However, in my web browser I can see the HTML code for the table when I "View Source." Is there an option for importing a web page in _Mathematica_ that I am overlooking? How do I import the data from the page?


title: Fast code to generate large random graph with fixed degree sequence

text: I'm trying to create a function so to generate large random graph with a fixed degree sequence $\\{v_1,v_2,\dots,v_N\\}$, where $N$ is the number of vertices in the graph. The _Mathematica_ function that should do the work is:               RandomGraph[DegreeGraphDistribution[{v1,v2,...vN}]]      but unfortunatly, it is useless for large graph, as it is extremely slow as the number of nodes increases. I have tried to build my own function, where instead of generating a new graph with a given degree sequence, I start from a non random matrix m, that has the desidered degree sequnce $\\{v_1,v_2,\dots,v_N\\}$ and then I rewire the links so to keep the degree fixed. Here is my code:               partM[m_, {a_, b_}] := m[[a, b]]          confmodel0[m_] :=      Module[{x, y, old, pos, pick}, {x, y} = Dimensions[m];      pos = Position[m, x : _ /; x > 0.]; pick = RandomChoice[pos, 2];     old = m;     While[m[[pick[[1, 1]], pick[[2, 2]]]] != 0 ||      m[[pick[[2, 1]], pick[[1, 2]]]] != 0 ||      pick[[1, 2]] - pick[[2, 2]] == 0 ||      pick[[1, 1]] - pick[[2, 1]] == 0, pick = RandomChoice[pos, 2]];     ReplacePart[      m, {pick[[1]] -> 0,       pick[[2]] -> 0, {pick[[1, 1]], pick[[2, 2]]} ->       partM[old, pick[[1]]], {pick[[2, 1]], pick[[1, 2]]} ->       partM[old, pick[[2]]]}]]          confmodel[m_] := Nest[confmodel0, m, 10*Total[Boole[Positive[m]], 2]];      However, also this function is too slow for large graph and I cannot generate real randomized graphs. In network theory, this model is called configuation model. It would be nice to have a function for both directed and undirected graph. Here you find a test matrix. I would like to generate a random matrix with the same degree sequence of this matrix: https://dl.dropboxusercontent.com/u/62056077/TestMatrix.m Thanks for any suggestion


title: Discrete ContourPlot3D with restrictions

text: I have the follow simple condition between integers: `k - 2 h - l == 0`, which describe a plane that I plot with:               ContourPlot3D[x - 2*y - z == 0, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}]      Now the problem I have is: How can I plot the same plane under these restrictions:   * plot only discrete numbers (x = 1, 2, 3, ...; y = 1, 2, 3, ...; z = 1, 2, 3, ...);   * _Mathematica_ should observe rules on the integers (e.g.: plot only the positive integers for which `k ≠ h`)


title: When using NMinimize[...,Method->"DifferentialEvolution"] is an "iteration" different than a "step"?

text: Hopefully this question has a simple answer. I have the following bit of code:               fits = Quiet[     Check[     NMinimize[     {ssd, And @@ cons}, vars,      AccuracyGoal -> accur,      PrecisionGoal -> Infinity,      Method -> {"DifferentialEvolution", "ScalingFactor" -> 1.0, "CrossProbability" -> 0.0},      MaxIterations -> maxIter,      StepMonitor :> (fitStep++)     ], {}     ]     ];      where the variables _accur_ and _maxIter_ are set elsewhere. I've noticed that _fitStep_ sometimes exceeds _maxIter_ during the minimization, which seems to indicate that an "iteration" and a "step" are not the same thing in this context. If they're different, is there a way to monitor the "iteration" and not the "step"? I just want to be able to limit the fit to a certain number of iterations (to prevent it from going on too long) and monitor the progress against that limit. EDIT: 16 May 2013 Alright I've put together a self-contained chunk of code to demonstrate the `MaxIterations` issue. I know it's not the most basic example but it's sure to reproduce what I'm seeing. The chunk of code below is commented, but just to summarize: I have some spectral data that I'm trying to fit with a sum of Logistic Power Peak functions using the Differential Evolution method. The important variables here are `vars`, `cons`, `args`, and `ssd`, as those are the arguments fed to `NMinimize[]`. The `ssd` variable contains a very large expression so evaluate it with caution. Evaluate the following expression first in a separate cell to watch the progress of the minimization.               (* Watch the progress here. *)          Dynamic["Iterating: " <> ToString[fitStep] <> " / " <> ToString[maxIter] <> " ..."]      Change `maxIter` and the `"PostProcess"` option inside `NMinimize[]` (bottom) to see the various behaviors.               (* Set the number of iterations. *)          maxIter = 500;          (* Here's some data I'm trying to fit. *)          pts={         {525,  3.95}, {527,  5.07}, {529,  5.15}, {531,  5.58}, {533,  5.85},         {535,  6.53}, {537,  7.01}, {539,  6.79}, {541,  7.01}, {543,  7.43},         {545,  7.18}, {547,  6.92}, {549,  6.34}, {551,  7.21}, {553,  7.75},         {555,  7.65}, {557,  8.71}, {559,  8.89}, {561,  9.02}, {563,  9.72},         {565,  9.62}, {567,  9.88}, {569, 10.50}, {571,  9.65}, {573,  9.71},         {575,  8.52}, {577,  7.70}, {579,  8.15}, {581,  8.29}, {583, 10.00},         {585, 10.00}, {587,  9.28}, {589, 10.80}, {591, 11.90}, {593, 13.80},         {595, 14.90}, {597, 14.30}, {599, 15.30}, {601, 16.20}, {603, 16.30},         {605, 17.90}, {607, 17.70}, {609, 19.20}, {611, 20.40}, {613, 20.80},         {615, 21.40}, {617, 20.30}, {619, 18.40}, {621, 19.80}, {623, 19.90},         {625, 20.70}, {627, 19.80}, {629, 18.60}, {631, 19.40}, {633, 20.40},         {635, 20.50}, {637, 23.10}, {639, 22.50}, {641, 25.20}, {643, 26.40},         {645, 26.10}, {647, 25.60}, {649, 25.20}, {651, 23.30}, {653, 23.10},         {655, 23.00}, {657, 24.00}, {659, 22.70}, {661, 22.00}, {663, 21.70},         {665, 21.30}, {667, 19.60}, {669, 20.30}, {671, 17.60}, {673, 18.20},         {675, 17.40}, {677, 16.10}, {679, 15.60}, {681, 14.10}, {683, 12.20},         {685, 12.10}, {687, 13.50}, {689, 13.90}, {691, 12.50}, {693, 12.00},         {695, 11.60}, {697, 11.10}, {699,  9.41}, {701,  8.56}, {703,  6.69},         {705,  6.50}, {707,  7.20}, {709,  7.03}, {711,  6.75}, {713,  6.01},         {715,  6.97}, {717,  7.54}, {719,  7.76}, {721,  7.47}, {723,  7.33},         {725,  6.93}, {727,  6.64}, {729,  6.25}, {731,  4.93}, {733,  4.67},         {735,  4.06}, {737,  4.17}, {739,  4.90}, {741,  4.64}, {743,  4.63},         {745,  5.11}, {747,  4.75}, {749,  4.45}         };          (* This is the Logistic Power Peak (LPP) function. *)     (* I'm fitting with a sum of these (the sum is handled below). *)     (* #1 = a = height *)     (* #2 = b = center *)     (* #3 = c = width *)     (* #4 = d = asymmetry *)     (* #5 = s = reflection *)          LPP = (#2/#5)(#5+1)^((#5+1)/#5)         * (1+Exp[(#6(#1-#3)+#4*Log[#5])/#4])^(-((#5+1)/#5))Exp[(#6(#1-#3)+#4*Log[#5])/#4]&;          (* These are just labels for each of the five peaks being fitted. *)          pkIndx = {121101022, 121111022, 121121022, 121131022, 121141022, 121151022};          (* For each of the five peaks, set initial values for the parameters a, b, c, d, and s. *)     (* #1 = a = height *)     (* #2 = b = center *)     (* #3 = c = width *)     (* #4 = d = asymmetry *)     (* #5 = s = reflection *)          MapThread[(a[#1] = #2) &, {pkIndx, {4.26, 6.41, 3.68, 11.70, 3.87, 15.38}}];     MapThread[(b[#1] = #2) &, {pkIndx, {534.67, 559.62, 583.72, 607.08, 629.76, 651.83}}];     MapThread[(c[#1] = #2) &, {pkIndx, {5.02, 5.49, 5.96, 6.43, 6.91, 7.39}}];     MapThread[(d[#1] = #2) &, {pkIndx, {5.94, 6.16, 6.38, 6.59, 6.79, 6.98}}];     MapThread[(s[#1] = #2) &, {pkIndx, {1, 1, 1, 1, 1, 1}}];          (* Set lower constraints for each peak parameter. *)          MapThread[(daMins[#1] = #2) &, {pkIndx, {3, 5, 2, 5, 0, 5}}];     MapThread[(dbMins[#1] = #2) &, {pkIndx, {10, 10, 10, 10, 10, 10}}];     MapThread[(dcMins[#1] = #2) &, {pkIndx, {3, 3, 3, 3, 3, 3}}];     MapThread[(ddMins[#1] = #2) &, {pkIndx, {3, 3, 3, 3, 3, 3}}];          (* Set upper constrainsts for each peak parameter. *)          MapThread[(daPlus[#1] = #2) &, {pkIndx, {5, 5, 5, 5, 5, 5}}];     MapThread[(dbPlus[#1] = #2) &, {pkIndx, {10, 10, 10, 10, 10, 10}}];     MapThread[(dcPlus[#1] = #2) &, {pkIndx, {3, 3, 3, 3, 3, 3}}];     MapThread[(ddPlus[#1] = #2) &, {pkIndx, {3, 3, 3, 3, 3, 3}}];          (* In my larger program, this checks to see which peak parameters are being fitted. *)     (* Here we're fitting all but s, which always takes the value 1. *)          bool = {     (daPlus[#] != 0 || daMins[#] != 0),     (dbPlus[#] != 0 || dbMins[#] != 0),     (dcPlus[#] != 0 || dcMins[#] != 0),     (ddPlus[#] != 0 || ddMins[#] != 0)     } & /@ pkIndx;          aPos = Flatten[Position[bool[[All, 1]], True]];     bPos = Flatten[Position[bool[[All, 2]], True]];     cPos = Flatten[Position[bool[[All, 3]], True]];     dPos = Flatten[Position[bool[[All, 4]], True]];          (* Make a table of variables for NMinimize[]. *)          vars = Join[     a0[#] & /@ pkIndx[[aPos]],     b0[#] & /@ pkIndx[[bPos]],     c0[#] & /@ pkIndx[[cPos]],     d0[#] & /@ pkIndx[[dPos]]     ];          (* Make a table of constraints for NMinimize[]. *)          cons = Join[     (a[#] - daMins[#] < a0[#] < a[#] + daPlus[#]) & /@ pkIndx[[aPos]],     (b[#] - dbMins[#] < b0[#] < b[#] + dbPlus[#]) & /@ pkIndx[[bPos]],     (c[#] - dcMins[#] < c0[#] < c[#] + dcPlus[#]) & /@ pkIndx[[cPos]],     (d[#] - ddMins[#] < d0[#] < d[#] + ddPlus[#]) & /@ pkIndx[[dPos]]     ];          (*     Make a table of arguments to be fed to the LLP[] function in the Sum below.     Normally this table contains numerical values for the parameters that aren't being fitted         and variables for the ones that are.     Here we're fitting everything except s so the table contains only variables.     *)          args = MapThread[     {     aDum -> #2[[1]] /. {True -> a0[#1], False -> a[#1]},     bDum -> #2[[2]] /. {True -> b0[#1], False -> b[#1]},     cDum -> #2[[3]] /. {True -> c0[#1], False -> c[#1]},     dDum -> #2[[4]] /. {True -> d0[#1], False -> d[#1]}     } &,     {pkIndx, bool}     ];          (*     Create the sum of squared deviations for NMinimize[] to minimize.     The inner Sum[] sums over the 5 LLP[] functions at a given x, and each LLP[] gets its          arguments from the "args" table.     The outer Sum[] sums the squared deviations over all the data points.     *)          ssd = Sum[     (     Sum[     LPP[pts[[i, 1]], aDum, bDum, cDum, dDum, s[pkIndx[[j]]]] /. args[[j]],     {j, Length[pkIndx]}     ]     - pts[[i, 2]]     )^2,     {i, 1, Length[pts], 1}     ];          (* Run the fit. *)          fitStep = 0;          fits = NMinimize[{ssd, And @@ cons}, vars,     AccuracyGoal -> 3,     PrecisionGoal -> Infinity,     Method -> {     "DifferentialEvolution",      "ScalingFactor" -> 1.0,      "CrossProbability" -> 0.0,      "PostProcess" -> False     },     MaxIterations -> maxIter,     StepMonitor :> (fitStep++)     ];      My observations:   * with `"PostProcess->False"`:     * `MaxIterations` = 300 ---> # iterations = 220     * `MaxIterations` = 500 ---> # iterations = 250     * `MaxIterations` = 1000 ---> # iterations = 500     * `MaxIterations` = 1200 ---> # iterations = 600   * with `"PostProcess->FindMinimum"`     * `MaxIterations` = 300 ---> # iterations = 221     * `MaxIterations` = 500 ---> # iterations = 251     * `MaxIterations` = 1000 ---> # iterations = 501   * with `"PostProcess->True"`     * `MaxIterations` = 300 ---> # iterations = 286     * `MaxIterations` = 500 ---> # iterations = 316     * `MaxIterations` = 1000 ---> # iterations = 566     * `MaxIterations` = 1500 ---> # iterations = 816 Lastly, I did find a comment in _The Mathematica Guidebook for Numerics_ by Michael Trott claiming that (paraphrasing) in `FindMinimum[]`, `MaxIterations` determines the _effective_ number of evaluations in _each_ search direction. I believe it was on page 371 but I'll have to double-check.


title: Concerning ShowLegend in Mathematica

text: I found a code for Mie Scattering from 2007, written for Mathematica. I have edited it quite a bit, since there are package definitions that we don't need, etc. But I am having difficulties figuring out why the plot with ShowLegends does not work. The command is               CLegend = {{{RGBColor[1, 0, 0],       "\!\(\*SubscriptBox[\(C\), \(scat\)]\)"}, {RGBColor[0, 0, 1],       "\!\(\*SubscriptBox[\(C\), \(abs\)]\)"}, {RGBColor[0, 0, 0],       "\!\(\*SubscriptBox[\(C\), \(ext\)]\)"}},      LegendPosition -> {-.55, 0.3}, LegendSize -> {0.25, 0.25},      LegendShadow -> {0, 0}};          ShowLegend[     Show[CScatPlot, CAbsPlot, CExtPlot,      DisplayFunction -> Identity], DisplayFunction,      CLegend -> $DisplayFunction ]      It only outputs this with no legends present. ![ShowLegends](http://i.stack.imgur.com/rvogQ.png) ![showleg](http://i.stack.imgur.com/4bGgH.png)


title: Changing Wolfram command line output into copyable text

text: I generated a long polynomial using the Wolfram command line, with divisions and exponents. But the divisions look like this:               4     -     5      And the exponents are on a different line:                 -6     10      And I need to copy the output to GeoGebra, so I need to have the output format like this:               4/5      And:               10^-6      How can I do this?


title: Create new file, based on 500 articles

text: I've got a folder with 500 newspaper articles. Each article is saved in a seperate file with a number in the title like "1.txt", "2.txt". Each article has a date but it is not clear in which line the date is printed. I would like to seperate the date from the article and put them in two columns. The purpose is that I can make selection of articles based on periods of time. A article looks like this: The Light of Truth ENORMOUS IPO MAKES THE BILLIONAIRE 2013/12/18 CENTRUM, Tethys - the president and PRESIDENT international Sten can add another description to its name:.......               fname = FileNameJoin[{"E:\\data\\MC1 Data\\MC1 Data\\articles\\",      "testfile3.txt"}];          s = OpenWrite[fname]     For[i = 1, i < 20, i++,     test1 = Import["E:\\data\\MC1 Data\\MC1 Data\\articles\\" <> ToString[i] <>".txt","Text"];          test2 = {       StringCases[test1, DatePattern[{"Year", "Month", "Day"}]],StringCases[ToLowerCase[test1], RegularExpression["\\w(?<!\\d)[\\w'-]*"]]};          WriteString[s, test2, "\n"];      ] When I open the file,               test1 = Import["E:\\data\\MC1 Data\\MC1 Data\\articles\\testfile3.txt"]      I will see this:               {{2013/12/18}, {the, light, of, truth, enormous, ipo, makes, the,      billionaire, of, sanjorge, centrum,}}     {2009/06/21}, {news, online, today, protest, turns, violent, in,      abila, abila, kronos, a, rally, of, hundreds, of, protestors, allied,      with, the, protectors, of, kronos, movement, turned, to, violence}      The structure of this file is like this :{{..},{..}} and I can't make a selection like               Select[file[All,{1,2}]], #[[1]]<"2009/06/21"&]      Anyone a suggestion how to solve this?


title: Is it possible to position ticklabels on the negative y axis on its right side?

text: Is it possible to position ticklabels on negative $y$ axis on its right side? Ticklabels on positive $y$ axis should remain as usual: ![enter image description here](http://i.stack.imgur.com/Yi6Jm.png)


title: How to change the position of numbers on plot

text: ![Example of problem](http://i.stack.imgur.com/Sgyvg.jpg) How to change the position of numbers in axes on plot? I want to see the numbers on the x-axis over it, not under it as it is now to have them clearly visible.


title: Importing multiple tables within a single file

text: Suppose I have a file with multiple tables, each separated by a line beak, like this:               banana yellow     apple red     grape purple          fire red     water blue     sky blue          parrot green     whale blue     cat yellow      I need to create three lists of ordered pairs out of this single file. If I had just a single table, I'd simply use `data = Import["file.dat", "Table"]`, but in this case I don't know how to tell _Mathematica_ to split into three tables and that I need a `data1`, a `data2` and a `data3`.


title: Problem With 3D Contour Plot

text: So I am very new to Mathematica and I'm using version 9. I need to plot a function $f(x,y)$ such that $f(x,y)$ is equal to $y^2$ when $x > y$ and equal to $10 \sin(x)$ when $x < y$. I want two contour plots, one in 2D and one in 3D. So far, I have plotted the 2D version without a problem in the following way:               f3[x_, y_, z_] := If[x > y, y^2, If[x < y, 10*Sin[x]]];     ContourPlot[f3[x, y, z], {x, -5, 5}, {y, -5, 5}, Contours -> 20, ColorFunction -> "Rainbow", PlotRangePadding -> None]      ![2D Plot](http://i.stack.imgur.com/Px8pn.jpg) Attempting to plot the 3D version, I tried entering this:               ContourPlot3D[f3[x, y, z], {x, -5, 5}, {y, -5, 5}, {z, -5, 20}]      and sadly received this monstrosity: ![3D Plot](http://i.stack.imgur.com/m0ocN.jpg) Any idea why? Any and all help would be greatly appreciated, I'm hoping it's a simple fix considering I've only been using the software for a few days. EDIT: In response to some of the comments, this is the example that was provided (e.g. what it's supposed to look like): ![3D Plot 2](http://i.stack.imgur.com/A1N7F.gif) I understand that my function depends only on x and y, I only added the z to make the plot work. To clarify my question, how do I make it look like the second plot? Thanks for the help so far by the way


title: MarginalDistribution with Symbolic range in ProbabilityDistribution

text: Given the following joint density: ![Mathematica graphics](http://i.stack.imgur.com/3TnJI.png) for 10 < x < 20, x/2 < y < x. To find the marginal density for X we do:               PDF[MarginalDistribution[ProbabilityDistribution[1/25 ((20 - x)/ x),                                                       {x, 10, 20}, {y, x/2, x}], 1], x]      But this does nothing because the range of values for `y` is dependent on `x` and non-numeric. But the marginal density w.r.t `x` is just the value of the following integral:               Integrate[1/25 ((20 - x)/x ), {y, x/2, x}]      Which correctly gives               (20 - x)/50      If we now change the same for a different distribution with a numerical range:               PDF[MarginalDistribution[ProbabilityDistribution[2/3 (x + 2 y),                                                       {x, 0, 1}, {y, 0, 1}], 1], x]      we get ![Mathematica graphics](http://i.stack.imgur.com/tp0TV.png) Which is correct since:               Integrate[2/3 (x + 2 y), {y, 0, 1}]      gives:               2/3 + (2 x)/3      So my question is why doesn't the symbolic range work, if internally _Mathematica_ is just doing the same integration I did above.?


title: Highlight Pie in PieChart

text: `PieChart` has the nice functionality of highlighting a single pie when you click on it. It is then sticking out a little. See the following example:               PieChart[{1, 2, 3}]      ![enter image description here](http://i.stack.imgur.com/KyWA5.jpg) Now, if I click on the green Pie it starts to stick out. ![enter image description here](http://i.stack.imgur.com/XiKzF.jpg) Is there any way of achieving this programmatically? I browsed through the Options of `PieChart` but couldn't find anything. I want to automatically create a number of plots with highlighted sections and save them automatically without having to click on them manually each time.


title: Setting plot size within vector; dynamic slider (two part question)

text: I have a question about the size of a plot in mathematica. I'm working on some differential equations (a simplified model of heat transfer in a building). I've programmed it so that you can set initial temperatures using a slider. These initial temperatures then go through a series of calculaions, resulting in a graph with the sliders next to them, which looks like this: ![Plot 1](http://i.stack.imgur.com/eMKTS.png) Now this is great, but the plot is a little small. Do you guys know if there's a way to make it show bigger by default? I can do it manually, but I would really like it to do so by itself, mainly because that way I can be sure it's always the same size, which looks neater in reports. Also, even though I've used dynamic sliders, the graph doesn't change instantly. Presumably because the parameters are first used in a Solve- function, the results of which are used in the plot. Is there a way to make this graph plot the changes instantly? The complete code looks like this.                   A := 3.8*10^-3 ( {      {-6, 1, 1, 4},      {1, -4, 1, 2},      {1, 1, -4, 2},      {0, 0, 0, 0}     } );         (*Heat transfer coëfficient matrix, mostly dependant on wall area*)         EVe = Eigenvectors[A];         EVa = Eigenvalues[A];         (*T1=;         T2=;         T3=;         T4=;*)         (*Use this part to manually enter initial temperatures if you want to overrule the slider*)         s = Solve[            EVe[[1, 1]] c1 + EVe[[2, 1]] c2 + EVe[[3, 1]] c3 +                EVe[[4, 1]] c4 == T1 &&              EVe[[1, 2]] c1 + EVe[[2, 2]] c2 + EVe[[3, 2]] c3 +                EVe[[4, 2]] c4 == T2 &&              EVe[[1, 3]] c1 + EVe[[2, 3]] c2 + EVe[[3, 3]] c3 +                EVe[[4, 3]] c4 ==  T3 &&              EVe[[1, 4]] c1 + EVe[[2, 4]] c2 + EVe[[3, 4]] c3 +                EVe[[4, 4]] c4 == T4, {c1, c2, c3, c4}] ;         (*Uses eigenvectors to solve for the needed coëfficients. There's probably a way to do this more efficiently using a for loop of some sort, but I don't know how.*)         cc1 = c1 /. %;         cc2 = c2 /. %%;         cc3 = c3 /. %%%;         cc4 = c4 /. %%%%;         (*Assigns the values from Solve so they may be used later*)              {{{VerticalSlider[Dynamic[T1], {0, 30}], Dynamic[T1]},           {VerticalSlider[Dynamic[T2], {0, 30}], Dynamic[T2]},           {VerticalSlider[Dynamic[T3], {0, 30}], Dynamic[T3]},           {VerticalSlider[Dynamic[T4], {0, 30}], Dynamic[T4]}} ,           Plot[{cc1*EVe[[1, 1]]*E^(EVa[[1]] t) +              cc2*EVe[[2, 1]]*E^(EVa[[2]] t) + cc3*EVe[[3, 1]] E^(EVa[[3]] t) +              cc4*EVe[[4, 1]] E^(EVa[[4]] t),             cc1*EVe[[1, 2]]*E^(EVa[[1]] t) + cc2*EVe[[2, 2]]*E^(EVa[[2]] t) +              cc3*EVe[[3, 2]] E^(EVa[[3]] t) + cc4*EVe[[4, 2]] E^(EVa[[4]] t),             cc1*EVe[[1, 3]]*E^(EVa[[1]] t) + cc2*EVe[[2, 3]]*E^(EVa[[2]] t) +              cc3*EVe[[3, 3]] E^(EVa[[3]] t) + cc4*EVe[[4, 3]] E^(EVa[[4]] t),             cc1*EVe[[1, 4]]*E^(EVa[[1]] t) + cc2*EVe[[2, 4]]*E^(EVa[[2]] t) +              cc3*EVe[[3, 4]] E^(EVa[[3]] t) +              cc4*EVe[[4, 4]] E^(EVa[[4]] t)}, {t, 0, 500}, PlotRange -> All]}         (*Plots results. Once again this could probably be done with a for loop, but I don't know how*)      Any help is greatly appreciated. Thanks in advance!


title: A list containing zero elements

text: I have a list containing zero and nonzero elements. How can I throw away zero elements and just keep non zero ones.


title: Visible (or selectively visible) multiplication operator in output

text: I don't like the way that Mathematica hides the multiplication symbol when two variables appear adjacent in the multiplication, because the space between them isn't always sufficient to clearly see that there are in fact two variables there. Therefore, I would like to either increase the space between the adjacent variables, or to **make the multiplication operator explicit in my output**. Note that `InputForm` does not suffice because I still want other parts of the expression formatted as usual, and most of the other things I've seen erroneously remove parentheses, thus changing the meaning of the expression, which I would like to avoid. Here's as far as I have got so far (I've not edited `Times` to make it easier to see the difference, and because I don't necessarily want to apply this everywhere):               SetAttributes[visibleTimes, Orderless]          MakeBoxes[visibleTimes[a_], StandardForm] :=       MakeBoxes[a, StandardForm]          MakeBoxes[visibleTimes[a_?NumericQ, b__], StandardForm] :=       MakeBoxes[Times[a, visibleTimes[b]], StandardForm]          MakeBoxes[visibleTimes[a__], StandardForm] :=       MakeBoxes[Interpretation[Infix[Hold[a], "*"], Times[a]], StandardForm]      which tries to hide the operator if one of the arguments is numeric. I then test with               a$$1*b (c - 2d)*Exp[10]          Block[{Times = visibleTimes}, a$$1*b (c - 2d)*Exp[10]]      which gives me the not particularly satisfactory ![output](http://i.stack.imgur.com/Y3p8a.png) I think you'll agree that in the first expression (`Out[5]`), it is not easy to notice the multiplication between `a$$1` and `b`. It would also be nice if the resulting output cell could be copied and pasted and evaluated back as input similar to the original. I also suspect that `PrecedenceForm` may be able to help here, but I haven't figured out how to get it to work in this context yet.


title: NIntegrate piecewise vector function

text: Is there a way to numerically integrate a vector function defined via `Piecewise`? Example:                test[s_] := Piecewise[{                           {{s, s^2, s^3}, s < -2},                           {{0, s - 1, Sin[s]}, -2 <= s < 1},                            {{1 - s^2, Exp[s], 0},1 <= s}}]      NIntegrate[test[s],{s,-2,2}]      This gives `NIntegrate::inum: Integrand … is not numerical at …` as error.


title: Does RuleDelayed work inside MessageName?

text: using : Mathematica 9.0.1.0 Hello ! Does RuleDelayed work inside MessageName ? This code:               myFunction[x_]:= x + 1;     myFunction::test = test /. test :> StringJoin[{DateString[], " message"}];     Message[myFunction::test]      gives               myFunction::test: 2014 04 10 15 10 51 781 message      on a pc and               myFunction::test: -- Message text not found --      on another one, and I can not get a sens of the underlying general rule. Presumably, I messed up some Global Preferences in Options Inspector, but I can not imagine which one. Thanks !!


title: how to use Manipulate changing the values of a List?

text: How can I "change" the values in the list h={2,4,6} using Manipulate? (Next line was edited after hte first Alexi´s comment) I WANT to choose real values in h[[1]], h[[3]] , h[[3]] between 0 and 8. I was trying, typing at the final line {h[[1]],1,8},{h[[2]],1,8},{h[[3]],1,8},{zmax, Range[8]} instead               {zmax, Range[8]}      But I obtain this error: Manipulate::vsform: "Manipulate argument {h[[1]],1,8} does not have the correct form for a variable specification" * * *               Manipulate[           h = {2, 4, 6};           Column[{        Row[{               TableForm[Table[h^z, {z, 1, zmax}],            TableHeadings -> {None, {"Number", "Square", "Cube"}}]          }         ],             Row[{          PieChart[Table[i^2, {i, 1, zmax}], ChartLabels -> Range[zmax],            ImageSize -> 200],               PieChart[Table[i^3, {i, 1, zmax}], ChartLabels -> Range[zmax],            ImageSize -> 200],               PieChart[Range[zmax], ChartLabels -> Range[zmax],            ImageSize -> 200]          }         ]        }]      , {zmax, Range[8]}]


title: Solving a system consisting of an ODE and a non-differential equation

text: I would like to solve the following system of equations:               y'[t] == x[t]*y[t] - x[t];     10 == x[t]*y[t]/(x[t] + y[t]) + x[t]/(x[t] + y[t]^2)      Is there any way to solve this equations with _Mathematica_?


title: Expressions with Boolean variables and simplification

text: I have some familiarity with Mathematica, but have no experience with any Boolean computation. Suppose we have the Boolean formula $(x_1 \lor x_2) \land (x_2 \lor x_3)$. This can be simplified by applying rules of Boolean logic, as follows. $$\begin{align} &(x_1 \lor x_2) \land (x_2 \lor x_3) \\\ &= (x_1 \land x_2) \lor (x_1 \land x_3) \lor (x_2 \land x_2) \lor (x_2 \land x_3) \\\ &=x_2 \lor (x_1 \land x_2) \lor (x_2 \land x_3) \lor (x_1 \land x_3) \\\ &=x_2 \lor (x_1 \land x_3) \end{align}$$ Can formulas of Boolean variables be computed in Mathematica 9? Can Mathematica apply rules of Boolean logic to make simplifications like as shown above?


title: Cropping a non-cubic lattice unit cell

text: I would like to crop the hexagonal close-packed system as a hexagon and not as a cube. I would like to use the following `volumetricPlot` already given on this exchange by Jens.               volumetricPlot[latticeType_] := Module[       {        img = LatticeData[latticeType, "Image"],        r = LatticeData[latticeType, "PackingRadius"]        },       Show[        img /. Sphere[pt_, r_] :> {},        Map[         RegionPlot3D[(EuclideanDistance[{x, y, z}, #] < r),           {x, -1, 1}, {y, -1, 1}, {z, -1, 1},           Mesh -> False,           PlotStyle -> Opacity[.5]           ] &, Cases[img, Sphere[pos_, _] :> pos, Infinity]]        ]       ]            volumetricPlot["HexagonalClosePacking"]      However as a newbie to _Mathematica_ I am not sure how to change `RegionPlot3D` to crop at the hexagon boundaries. Any thoughts?


title: DSolve cannot solve for certain branches of the solution help pls

text: I get an error message while trying to compute this code.. help pls                   DSolve[{ A'[t] + 1/2 B[t]^2 a + ρ B[t] C[t] a + 1/2 a C[t]^2 == 0,                  -B'[t] + 1/2 B[t]^2 b + ρ B[t] C[t] b + 1/2 b C[t]^2 == 1,                  -C'[t] + 1/2 B[t]^2 c + ρ B[t] C[t] c + 1/2 c C[t]^2 == 0                  A[T] == B[T] == C[T] == 0}, {A[t], B[t], C[t]},  t]      i get this "DSolve::bvfail: For some branches of the general solution, unable to solve the conditions." why?


title: How to obtain the number of Markov Chain transitions in a simulation?

text: I would like to obtain the number of transitions from each state in a Markov Chain simulation to other states, including back to itself so I can compare the simulation results to the transition matrix. I’m fairly new to Markov Analysis so please be gentle. From the help we have this relatively simple example involving weather.               weather = DiscreteMarkovProcess[1, {{0.7, 0.3}, {0.4, 0.6}}];     Graph[weather, VertexLabels -> {1 -> "rain", 2 -> "no rain"},      VertexSize -> Small,      EdgeLabels ->      With[{sm = MarkovProcessProperties[weather, "TransitionMatrix"]},      Flatten@Table[DirectedEdge[i, j] -> sm[[i, j]], {i, 2}, {j, 2}]],      ImageSize -> Medium]      ![enter image description here](http://i.stack.imgur.com/clget.png) The transition matrix is obtained by               transitionmatrix =      MarkovProcessProperties[weather, "TransitionMatrix"] // MatrixForm      Now I simulate and plot 1000 days of behavior.               days = 1000;     data = RandomFunction[weather, {1, days}]     ListPlot[data, Filling -> Axis, Ticks -> {Automatic, {1, 2}},      PlotRange -> {{0, days + 200}, {0, 2.5}}, Frame -> True,      FrameLabel -> {"Time (days)", "Weather Condition"},      FrameTicks -> {Automatic, {1, 2}, None, None},      PlotLabel -> "Simulation Results",      Epilog -> {Text["Rain", {days + 100, 1}],      Text["No Rain", {days + 100, 2}]}]      ![enter image description here](http://i.stack.imgur.com/3JibY.png) So far, so good (I think). I can also determine the number of times we arrived in a state of rain (State 1) or in a state of no rain (State 2)               rainstates = Count[data["PathStates"], 1]     norainstates = Count[data["PathStates"], 2]      But from the simulation data, how can I determine a) the number of times we arrived to State 1 from State 1 ? b) the number of times we arrived to State 1 from State 2 ? c) the number of times we arrived to State 2 from State 1 ? d) the number of times we arrived to State 2 from State 2 ?


title: random Poisson process over multiple variables (state vector) for chemical kinetics

text: Has anyone figured out how to coerce ContinuousMarkovProcess to work with a state vector, transition matrix, and rate (propensity) vector, and RandomFunction to return pairs of state vector and time, so one can model chemical kinetics? The state vector contains the number of molecules of each species, and there are an infinite number of states in the traditional sense, so the state graph is infinite. I have code for version based on version 8, but would like to make use of the new functions in version 9. Here is a simple example of Lotka-Voltera system: ![LT reactions](http://i.stack.imgur.com/sD1uF.png) ODES:               {Derivative[1][Subscript[Y, 1]][t] ==        Subscript[c, 1] Subscript[Y, 1][t] -         Subscript[c, 2] Subscript[Y, 1][t] Subscript[Y, 2][t],       Derivative[1][Subscript[Y, 2]][        t] == -Subscript[c, 3] Subscript[Y, 2][t] +         Subscript[c, 2] Subscript[Y, 1][t] Subscript[Y, 2][t]}      Initial conditions:               {Subscript[Y, 1][0] == 4, Subscript[Y, 2][0] == 10}      Parameters:               {Subscript[c, 1] -> 1., Subscript[c, 2] -> 0.1,       Subscript[c, 3] -> 0.1}      Transition Matrix:               {{1, 0}, {-1, 1}, {0, -1}}      Propensities:               {Subscript[c, 1] Subscript[Y, 1][t],       Subscript[c, 2] Subscript[Y, 1][t] Subscript[Y, 2][t],       Subscript[c, 3] Subscript[Y, 2][t]}      Initial state vector:               {4, 10}      Thanks, Bob


title: how to simplify large expression with lots of special functions in it (BesselY, Hypergeometric, MeijerG etc...)

text: I saw this DE in Maple forum. When solving it using Mathematica 9.01, even though the result was correct (both solutions gave the same numerical answer for some random values), Mathematica's answer was much larger in size. Using `Simplify` or `FullSimplify` did not help much (expression was still order of magnitude larger than Maple's result). I think special simplification rules might be needed? I'd like to ask if there are other special simplifications to use, or commands I might be missing to reduce this result more. Below is the ODE and Maple and Mathematica results. Mathematica:               ClearAll[y, x];     ode = y'''[x] + (1/x) y'[x] - (1/x^2) y[x] == 0;     ic = {y[1] == 1, y'[1] == 0, y''[1] == 1};     sol = y[x] /. First@DSolve[{ode, ic}, y[x], x];     Simplify[sol]      Result is too large fit in the margin of this answer, so I zoomed in ![Mathematica graphics](http://i.stack.imgur.com/7bEyP.png) Maple:               ode:=diff(y(x),x$3)+(1/x)*diff(y(x),x)-y(x)/x^2=0;     dsolve({ode, y(1)= 1, D(y)(1)=0, (D@@2)(y)(1)=1});     simplify(%,wronskian);          y(x) = 2*x-(BesselY(0, 2)-2*BesselY(1, 2))*Pi*sqrt(x)*            BesselJ(1, 2*sqrt(x))+Pi*(-2*BesselJ(1, 2)+BesselJ(0, 2))            *sqrt(x)*BesselY(1, 2*sqrt(x))      ![Mathematica graphics](http://i.stack.imgur.com/YGysF.png) **Update** Here is Maple result written using Mathematica notation in case someone wants to use to help find simplification to Mathematica solution. Also tried `Simplify[mma == maple]` suggested in the comments below.               ClearAll[y, x];     ode = y'''[x] + (1/x) y'[x] - (1/x^2) y[x] == 0;     ic = {y[1] == 1, y'[1] == 0, y''[1] == 1};     mma = y[x] /. First@DSolve[{ode, ic}, y[x], x];     maple = 2 x - (BesselY[0, 2] - 2 BesselY[1, 2]) Pi Sqrt[x] BesselJ[1,           2 Sqrt[x]] + Pi (-2 BesselJ[1, 2] + BesselJ[0, 2]) Sqrt[x] BesselY[1,           2 Sqrt[x]];          N[mma /. x -> 3]     (*3.33870606057436*)          N[maple /. x -> 3]     (*3.33870606057435*)          Simplify[mma == maple]     (* too large to post *)      Related question here


title: Export LocatorPane as image by button

text: How to Export LocatorPane as image by button or at least by something else? Kuba, thank you! Your method works in a simple case:               DynamicModule[{pt = {{1, 1}/2, {-1, 1}/2, {1, -1}/2}}, {Dynamic@LocatorPane[Dynamic[pt],     Graphics[{Gray, Disk[]}],     Appearance -> Graphics[{Red , Disk[Scaled[{.5, .5}], .2], Inset["a", Scaled[{.1, .1} + 0.5]]}, PlotRange -> {{0, 10}, {0, 10}}]]}]          Button["Export", Export[FileNameJoin[{$HomeDirectory, "Desktop", "expimg.png"}], Rasterize@ToExpression@First@NotebookRead@Experimental`PreviousCell[]]]      But in my case need to fix something. This code results an image with initial positions of locators:               hkl = {-1, 2, 3};          Manipulate[Pane[       DynamicModule[{pt = {{1000, 1059}/2, {1000, 1059}/2.2}},        Column[         {Dynamic@           LocatorPane[Dynamic[pt],             Image[Import[              "http://download.hdd.tomsk.ru/preview/warpaheh.jpg"],              ImageSize -> Zoom],                      Appearance -> {              Graphics[{Red,                 Disk[Scaled[{1000, 1059}/(2*{1000, 1059})],                  Dynamic[PointRadius]]},                PlotRange -> {{0, 1000}, {0, 1059}},                ImageSize -> Dynamic[Zoom]],              Dynamic[               Style[Row[hkl], RGBColor[TextColor, TextColor, TextColor],                 Zoom*PointRadius/100]]              }]               }]]       , ImageSize -> {1000, 1000}, Scrollbars -> True,        ScrollPosition -> {150, 200}],      Row[{        Column[{          Row[{Control[{{TextColor, 0.5}, 0,                1}] Control[{{TextColor, 0.5, ""}, {0, 0}, {1, 1},                InputField[#, FieldSize -> {4, 1}] &}]}],           Row[{Control[{{Zoom, 1000}, 100, 3000,                100}] Control[{{Zoom, 1000, ""}, {100, 100}, {3000, 3000},                InputField[#, FieldSize -> {4, 1}] &}]}],           Row[{Control[{{PointRadius, 3}, 1,                20}] Control[{{PointRadius, 3, ""}, {1, 1}, {20, 20},                InputField[#, FieldSize -> {4, 1}] &}]}],          }, Right]        }, Spacer[50]]      ]     Button["Export",       Export[FileNameJoin[{$HomeDirectory, "Desktop", "expimg.png"}],        Rasterize@        ToExpression@First@NotebookRead@Experimental`PreviousCell[]]]      How to implement the export of this picture? How to export an image with modified locators? Please, look at my code. Why it still doesn't work? https://drive.google.com/file/d/0B_R6abD1r7RXU0NrZS1GdGF3U1E/edit?usp=sharing


title: Transform elements in list from form {x_} to form {x_, 0}

text: I have the following list               l1 ={{{-1.342}, {-0.28}, {1.372}}, {{-1.34266}, {-0.278541}, {1.37156}}, \       {{-1.34459}, {-0.274215}, {1.37026}}, {{-1.34769}, {-0.267169}, \        {1.36807}}, {{-1.35177}, {-0.257626}, {1.36499}}, {{-1.35661}, \        {-0.245864}, {1.36101}}, {{-1.36197}, {-0.232184}, {1.35611}}, \        {{-1.3676}, {-0.216888}, {1.35026}}, {{-1.37326}, {-0.200263}, \        {1.34346}}, {{-1.37875}, {-0.182564}, {1.33567}}}      I'd like to take it and transformit into the following form               newList = {{-1.34266, 0}, {-0.278541, 0}, {1.37156, 0}}      I have tried               {{#1, 0}, {#2, 0}, {#3, 0}}  & @@ {#1, #2, #3} & @@  l1      Which does not work. It gives the output: which is almost correct               {{{-1.34266}, 0}, {{-0.278541}, 0}, {{1.37156}, 0}}      I want to feed this data into the following function to animate the data:               Animate[ListPlot[{{l1[[n]][[1]], 0}, {l1[[n]][2]], 0}, {l1[[n]][3]], 0}},        PlotStyle -> PointSize[0.1], PlotRange -> {{-2, 2}, {-1, 1}}], {n,        1, 750, 1}]      I thought It would be easiest to first construct the list we want and then pass it directly to ListPlot.


title: How to obtain the GIF by Mathematica?

text: Is it possible to create such GIF illustration amination by Mathematica? and the rendering effects of each trigonometric function curve. ![enter image description here](http://i.stack.imgur.com/IG9Es.gif) **UPDATE** I have mainly two puzzles: 1) how to obtain the rendered trigonometric curves (unnecessarily animated);- So I want to know what kind of mathematica commands can create `3D rendered tube` like curves per the parametric equations? -- I mean curves look like below the picture: ![enter image description here](http://i.stack.imgur.com/KOQ8F.png)![enter image description here](http://i.stack.imgur.com/jGMx4.png) 2) how to make sure these curves are **smoothly** continuous even after being refracted; I also need some clues in representing the equations of the curves (in parametric form or other forms), before and after being refracted; In order to handle the refraction smoothly and continuously, I think parametric equation forms of the curves are necessary since some of the curves may have only implicit form. For example: ![enter image description here](http://i.stack.imgur.com/ilYo3.png) This photo was found from internet; I need such clues to create similar GIF animations by Mathematica; Before creating similar GIF animation, I need to solve the two puzzles; I think there is no other obstacle for me to create it; **Update$^{(2)}$** I am not simply requesting code, answers resolve the two questions mentioned and illustrated with photos above will be accepted. I hope this can be made clearer. However, there is no reason that I refuse answers with codes which can create similar GIF photos. Now there is already acceptable answer. I will try to work on it.


title: How to plot ternary density plots?

text: How can I get a ternary density plot just like the plots from OriginLab? ![enter image description here](http://i.stack.imgur.com/Rhgn6.png) `ContourPlot` and `DensityPlot` seemingly can solve the `[f,{x},{y}]`-style，but cannot solve the `[f,{x},{y},{z}]`-style


title: Relative paths for portable notebooks in Mathematica

text: I cannot find how to use relative paths in Mathematica. My directory structure is simple.               Import["G:\\Research\\Acc and Vel Runs\\5-24\\Mathematica\\Data\\250 \     Acc.xls"][[1]] // TableForm        That demonstrates the absolute path by using the insert path from the menus. I want this notebook to be portable. I want to give someone the "Mathematica" directory and I want them to be able to run the code. I don't want the paths to break because It will be run on a different machine. Basically I just want to use a relative path starting at the Mathematica level shown above.


title: SetDirectory - predefined directory possible?

text: > **Possible Duplicate:**   >  Relative paths for portable notebooks in Mathematica I have a deep subdirectory structure, and the calculations should always be done in one of the deepest subdirectories. Instead of clicking through it using the `SetDirectory` command, is it possible to predefine somehow at the very first beginning of the notebook the second deepest subdirectory as a working directory, so that I can choose with `SetDirectory` just one of the deepest subdirectories?


title: Reading in Huge Text Files

text: I would like to read in really large text files (about 2GB) into _Mathematica_. The structure of the file is such that the first row and the first column are text i.e strings. Rest is all numbers. Is it possible to take advantage of this and make the `Import` faster? Currently I do `Import["file.txt","Table"]`. It takes a long time. I would like the output list to be same as that returned by the previously mentioned `Import` command. Thanks for your help.


title: How to select only NotebookObjects that are referring to ordinary notebooks? (not palettes etc.)

text: There is of course function               Notebooks[]      > ![enter image description here](http://i.stack.imgur.com/6xcmu.png) But, unfortunatelly it hasn't got useful options in this context. **My question is how to pick`Notebooks` excluding:**   * Help,    * Palettes,   * Packages,   * Messages,   * Text notebooks. * * * Parsing `Notebook/CellInformation` functions, I've found `Patterns`, e.g.:               ClearAttributes[Developer`CellInformation, ReadProtected]     DownValues @ Developer`CellInformation      > >     [...]  (_FrontEnd`SelectedNotebook | _FrontEnd`InputNotebook | >      _FrontEnd`ButtonNotebook | _FrontEnd`EvaluationNotebook | >      _FrontEnd`MessagesNotebook | _FrontEnd`HelpBrowserNotebook | >      _FrontEnd`ClipboardNotebook) | (_CellObject | _FrontEnd`CellObject) > [...] >   Those patterns seem to be what I need but I've not managed to use them. Any tips or another solution?


title: Is there is a design problem or documentation problem with FirstCase?

text: In version 10 the new function `FirstCase` can take up to 4 arguments (plus option). The third argument is a default value to be returned if there is no match: ![enter image description here](http://i.stack.imgur.com/VPrYY.png) Toward the end of the examples in Scope is an example is given in which the third argument is actually the level spec and all matches to the pattern are returned, not just the first match: ![enter image description here](http://i.stack.imgur.com/fAmRR.png) However when you evaluate the docs you actually get what is expected based on the function definition, namely that since there are no matches at the default first level a default value of `{2}` (presumably intended to be a level spec) is returned: ![enter image description here](http://i.stack.imgur.com/9Eq0x.png) The very next example in the docs also has a level spec as the third argument. I'm not sure how the docs output was obtained but would others agree that there is a bug in the documentation? (I'm on OS X 10.9.4 using 10.0.0.0)


title: How can I plot the integral of a unit tangent vector?

text: The questions states: Let               r[t_]:= {E^(-t), 3t^2, 4 Sin[t]}      Plot and compare `r[t]` and the integral of `T[t]`, `T[t]` being the unit tangent vector.


title: Creating a Sierpinski gasket with the missing triangles filled in

text: I'm creating some questions for my math classes. The one below refers to the Sierpinski gasket. ![question](http://i.stack.imgur.com/BwFud.png) I found some great demonstrations to create the gasket. So that's good. Solving the problem is easier to do if the diagram has all the triangles shown, eg. as below... ![triangles](http://i.stack.imgur.com/hAtlw.png) I'm wondering if someone could create a function to create the gasket and then switch to a version where all the "little" triangles are shown? I'd like to be able to ask similar questions with the gasket at different levels. The reason for having ALL the triangles is it lets the student find the fraction of the shaded triangles compared to the total number of small triangles.


title: Why does Solve and Sum give different answers when according to Table it is the same sequence?

text: I have been thinking about a piece of code today, but I don't understand why I get different outputs from two in my mind similar Mathematical sums. First I observe that the Table command for this:               Clear[n, s, a];     s = 1/2;     Table[Total[{1, -a, 1, -a,          1, -a}*{1, 1, -2*a, 1,           1, -2*a}/{(n + 0)^s, (n + 1)^s, (n + 2)^s, (n + 3)^s, (n + 4)^           s, (n + 5)^s}], {n, 1, 36, 6}]      and this:               Clear[n, s, a];     s = 1/2;     Table[Total[{1, -a, 1, -a,          1, -a}*{1, 1, -2*a, 1,           1, -2*a}/{(6*n + 1)^s, (6*n + 2)^s, (6*n + 3)^s, (6*n + 4)^           s, (6*n + 5)^s, (6*n + 6)^s}], {n, 0, 5}]      gives the same output starting: $$\displaystyle \left\\{1+\frac{1}{\sqrt{5}}-\frac{a}{2}-\frac{a}{\sqrt{2}}-\frac{2 a}{\sqrt{3}}+\sqrt{\frac{2}{3}} a^2,\frac{1}{\sqrt{7}}+\frac{1}{\sqrt{11}}-\frac{2 a}{3}-\frac{a}{2 \sqrt{2}}-\frac{a}{\sqrt{10}}+\frac{a^2}{\sqrt{3}},\frac{1}{\sqrt{13}}+\frac{1}{\sqrt{17}}-\frac{a}{4}-\frac{a}{\sqrt{14}}-\frac{2 a}{\sqrt{15}}+\frac{\sqrt{2} a^2}{3},\frac{1}{\sqrt{19}}+\frac{1}{\sqrt{23}}-\frac{a}{2 \sqrt{5}}-\frac{2 a}{\sqrt{21}}-\frac{a}{\sqrt{22}}+\frac{a^2}{\sqrt{6}},\frac{1}{5}+\frac{1}{\sqrt{29}}-\frac{2 a}{3 \sqrt{3}}-\frac{a}{2 \sqrt{7}}-\frac{a}{\sqrt{26}}+\sqrt{\frac{2}{15}} a^2,\frac{1}{\sqrt{31}}+\frac{1}{\sqrt{35}}-\frac{a}{4 \sqrt{2}}-\frac{2 a}{\sqrt{33}}-\frac{a}{\sqrt{34}}+\frac{a^2}{3}\right\\}$$... Then I did these two sums:               Clear[n, s, a];     s = 1/2;     Sum[Total[{1, -a, 1, -a,          1, -a}*{1, 1, -2*a, 1,           1, -2*a}/{(n + 0)^s, (n + 1)^s, (n + 2)^s, (n + 3)^s, (n + 4)^           s, (n + 5)^s}], {n, 1, Infinity, 6}]     Clear[n, s, a];     s = 1/2;     Sum[Total[{1, -a, 1, -a,          1, -a}*{1, 1, -2*a, 1,           1, -2*a}/{(6*n + 1)^s, (6*n + 2)^s, (6*n + 3)^s, (6*n + 4)^           s, (6*n + 5)^s, (6*n + 6)^s}], {n, 0, Infinity}]      which Mathematica 8 evaluates to: $$\displaystyle \text{Sum}\left[\frac{1}{\sqrt{n}}-\frac{a}{\sqrt{1+n}}-\frac{2 a}{\sqrt{2+n}}-\frac{a}{\sqrt{3+n}}+\frac{1}{\sqrt{4+n}}+\frac{2 a^2}{\sqrt{5+n}},\\{n,1,\infty ,6\\}\right]$$ $$\displaystyle \sum _{n=0}^{\infty } \left(\frac{1}{\sqrt{1+6 n}}-\frac{a}{\sqrt{2+6 n}}-\frac{2 a}{\sqrt{3+6 n}}-\frac{a}{\sqrt{4+6 n}}+\frac{1}{\sqrt{5+6 n}}+\frac{2 a^2}{\sqrt{6+6 n}}\right)$$ respectively. So far I did not know if these sums are equivalent. Then I wanted to set these sums equal to zero and solve for $a$:               Clear[n, s, a];     s = 1/2;     Solve[Sum[        Total[{1, -a, 1, -a,            1, -a}*{1, 1, -2*a, 1,             1, -2*a}/{(n + 0)^s, (n + 1)^s, (n + 2)^s, (n + 3)^s, (n + 4)^             s, (n + 5)^s}], {n, 1, Infinity, 6}] == 0, a]     Clear[n, s, a];     s = 1/2;     Solve[Sum[        Total[{1, -a, 1, -a,            1, -a}*{1, 1, -2*a, 1,             1, -2*a}/{(6*n + 1)^s, (6*n + 2)^s, (6*n + 3)^s, (6*n + 4)^             s, (6*n + 5)^s, (6*n + 6)^s}], {n, 0, Infinity}] == 0, a]      which outputs: $\left\\{\left\\{a\to \left(4 \sqrt{2} \text{HurwitzZeta}\left[\frac{1}{2},\infty \right]-4 \text{Zeta}\left[\frac{1}{2}\right]+2 \sqrt{2} \text{Zeta}\left[\frac{1}{2}\right]-\sqrt{2} \text{Zeta}\left[\frac{1}{2},\frac{1}{3}\right]-\sqrt{2} \text{Zeta}\left[\frac{1}{2},\frac{2}{3}\right]-\surd \left(\left(-4 \sqrt{2} \text{HurwitzZeta}\left[\frac{1}{2},\infty \right]+4 \text{Zeta}\left[\frac{1}{2}\right]-2 \sqrt{2} \text{Zeta}\left[\frac{1}{2}\right]+\sqrt{2} \text{Zeta}\left[\frac{1}{2},\frac{1}{3}\right]+\sqrt{2} \text{Zeta}\left[\frac{1}{2},\frac{2}{3}\right]\right)^2-4 \left(2 \sqrt{2} \text{HurwitzZeta}\left[\frac{1}{2},\infty \right]-2 \sqrt{2} \text{Zeta}\left[\frac{1}{2}\right]\right) \left(2 \sqrt{2} \text{HurwitzZeta}\left[\frac{1}{2},\infty \right]-\sqrt{2} \text{Zeta}\left[\frac{1}{2},\frac{1}{6}\right]-\sqrt{2} \text{Zeta}\left[\frac{1}{2},\frac{5}{6}\right]\right)\right)\right)/\left(2 \left(2 \sqrt{2} \text{HurwitzZeta}\left[\frac{1}{2},\infty \right]-2 \sqrt{2} \text{Zeta}\left[\frac{1}{2}\right]\right)\right)\right\\},\left\\{a\to \left(4 \sqrt{2} \text{HurwitzZeta}\left[\frac{1}{2},\infty \right]-4 \text{Zeta}\left[\frac{1}{2}\right]+2 \sqrt{2} \text{Zeta}\left[\frac{1}{2}\right]-\sqrt{2} \text{Zeta}\left[\frac{1}{2},\frac{1}{3}\right]-\sqrt{2} \text{Zeta}\left[\frac{1}{2},\frac{2}{3}\right]+\surd \left(\left(-4 \sqrt{2} \text{HurwitzZeta}\left[\frac{1}{2},\infty \right]+4 \text{Zeta}\left[\frac{1}{2}\right]-2 \sqrt{2} \text{Zeta}\left[\frac{1}{2}\right]+\sqrt{2} \text{Zeta}\left[\frac{1}{2},\frac{1}{3}\right]+\sqrt{2} \text{Zeta}\left[\frac{1}{2},\frac{2}{3}\right]\right)^2-4 \left(2 \sqrt{2} \text{HurwitzZeta}\left[\frac{1}{2},\infty \right]-2 \sqrt{2} \text{Zeta}\left[\frac{1}{2}\right]\right) \left(2 \sqrt{2} \text{HurwitzZeta}\left[\frac{1}{2},\infty \right]-\sqrt{2} \text{Zeta}\left[\frac{1}{2},\frac{1}{6}\right]-\sqrt{2} \text{Zeta}\left[\frac{1}{2},\frac{5}{6}\right]\right)\right)\right)/\left(2 \left(2 \sqrt{2} \text{HurwitzZeta}\left[\frac{1}{2},\infty \right]-2 \sqrt{2} \text{Zeta}\left[\frac{1}{2}\right]\right)\right)\right\\}\right\\}$ and the empty set: $\\{\\}$ respectively. For numerical reasons (setting infinity to a large number and evaluating) I believe that the complicated Zeta function expression is incorrect and that this is bug. But I have a feeling though that the fault might have been made by me and not Mathematica. Where did I go wrong? Should the two sums give the same answer?


title: Passing unquoted strings (poor man's enumeration)

text: I would like to be able to pass an unquoted string as a parameter to a Mathematica function [that I am writing] and have it show up without evaluation if the string happens to be defined. Thus I would like               Clear["Global`*"]     f[x_] := Print[ToString[x]];     f[Middle] (* prints the string Middle *)     Middle = 3     f[Middle] (* prints the string Middle *)      Obviously this cannot work the way I've written it. Yet it is legal to write               Plot[g[x],{x,0,3}, PlotStyle->Black]      and `Black` happens to be a protected variable, so it will never be defined. How can I emulate, or come close to emulating, this behavior. I'm willing to put up with some compromises in the function invocation syntax (in particular, the option syntax opt->Middle would be fine). Apologies if this is somewhere in the docs. I couldn't find it... Thanks. Addendum: While J.M.'s solution answers the question I posed above, I would also like the following to work:               Clear["Global`*"]     SetAttributes[foo,HoldAll];     foo[x_] := Print[ToString[Unevaluated[x]]];     Table[foo[i],{i,{a,b,c}}] (* prints {i,i,i}, as expected *)     Table[foo[Evaluate[i]], {i,{a,b,c}}] (* prints {a,b,c} as expected *)     a = 3     Table[foo[Evaluate[i]], {i,{a,b,c}}] (* prints {3,b,c} *)      I would like the last line to print {a,b,c} just like the one before it - that is, I'd like `i` evaluated only once. Am I asking too much? For context: this is part of a larger function that computes something, but does so in different ways depending on the setting of a mode parameter. I want to be able to pass in that mode parameter without evaluation; hence the original question. But I also want to be able to invoke the function inside a Table function as above. Here's a simple example:               Clear["Global`*"]     SetAttributes[foo,HoldAll];     foo[x_] := Block[{z=ToString[Unevaluated[x]]}, If[x == "square", x^2, x+1]];     Table[Integrate[foo[Evaluate[i]],{x,0,3}],{i,{"square", "xyzzy"}}];         {9, 45/2}     a=3     Table[Integrate[foo[Evaluate[i]],{x,0,3}],{i,{"square", "xyzzy"}}];         {45/2, 45/2}      since in the second invocation the parameter to foo has the value 3, not the value a. How can I achieve both of these behaviors?


title: Returning a value from a Module

text: In the following simple example               MyMod := Module[{i},       Do[         Return[1],         {i, 3}       ];       Print["test"]     ]      I expected the module to exit on `Return` and never reach the `Print`, instead I have               In[1]:= a = MyMod            test      I am sure I always used the former expected logic in the past.   I lost my memory or is it changed something in the way `Return` works?


title: create function that behaves like continuedFraction

text: I'm just starting to learn _Mathematica_ and I got stuck at this question. This a noob question but please help. I need to define a function named continuedFraction that takes user input of type list as this `continuedFraction[{a,b,c,d}]` that will output               a / (1 + b/ (1 + c/ (1 + d)))      this is just any other continued fraction like on this page http://mathworld.wolfram.com/ContinuedFraction.html what I had done so far after 383 inputs in notebook (now you know how hard this is for me)               fx[x_] := Fold[x/(1 + #) &, x, {a, b, c,}]          fx[{a, b, c, e}]           {a/(1 + a/(1 + a/(1 + a/(1 + a)))),        b/(1 + b/(1 + b/(1 + b/(1 + b)))),        c/(1 + c/(1 + c/(1 + c/(1 + c)))),        e/(1 + e/(1 + e/(1 + e/(1 + e))))}      which is of course, not the correct answer. ps: this is under functional programming-> pure function and a hint to use Fold.


title: Combine two DateListPlots and retain a time axis

text: I am trying to combine two DateListPlots to produce a single chart with 2 y-axis. There is an example here with regular Plots and I have tried to adapt it for time based data https://reference.wolfram.com/mathematica/howto/GeneratePlotsWithTwoVerticalScales.html The code below creates smallMeasurements and bigMeasurements, plots each on its own graph, rescales one so they can be seen on the same chart, and then combines them. The problem I cannot fix is that on combining the charts the X-Axis no longer displays time. Does anyone know some magic to fix this?               timesSteps = Map[Function[AbsoluteTime[{2014, 1, 1, 9, #, 0}]], Range[0, 480, 10]];     values = 1 + N[Sin[2*Pi *Mod[timesSteps/60, 360]/360]];          smallMeasurements = ArrayReshape[Riffle[timesSteps, values], {Length[values], 2}];     bigMeasurements = ArrayReshape[Riffle[timesSteps, 1000*(2 - values)], {Length[values], 2}];          smallPlot = DateListPlot[smallMeasurements]     bigPlot = DateListPlot[bigMeasurements];          smallRange = ReplaceAll[PlotRange, AbsoluteOptions[smallPlot, PlotRange]][[2]];     bigRange = ReplaceAll[PlotRange, AbsoluteOptions[bigPlot, PlotRange]][[2]];          leftTicks = N[FindDivisions[smallRange, 5]];     rightTicks = Quiet[Transpose[{leftTicks, Map[Function[ToString[NumberForm[#, 2], StandardForm]], Rescale[leftTicks, smallRange, bigRange]]}]] ;          bigPlotRescaled = ReplaceAll[bigPlot, Graphics[graph_, s___] -> Graphics[GeometricTransformation[graph, RescalingTransform[{{0, 1}, bigRange}, {{0, 1}, smallRange}]], s]]          Show[smallPlot, bigPlotRescaled, Axes -> False, Frame -> True,     FrameStyle -> {ColorData[1] /@ {1, 2}, {Automatic, Automatic}},     FrameTicks -> {{leftTicks, rightTicks}, {Automatic, Automatic}}]      ![smallPlot](http://i.stack.imgur.com/2fWpv.png) ![bigPlotRescaled](http://i.stack.imgur.com/9R0Ol.png) ![Combined](http://i.stack.imgur.com/414GU.png)


title: How can I embed a Manipulate (or other interactive graphics) in my website using CDF?

text: The new CDF (computable document format) lets you embed a `Manipulate` or other interactive graphics on your website, and users can play around with your little script using the free player. What steps do I need to follow to   1. Create the CDF file correctly so that it displays a static picture (that I choose) if the user doesn't have the player and fires up the player if they do?   2. Make the necessary changes to my website/server to enable this?


title: Grid snap for drawing tools

text: Is it possible to extend the _Drawing Tools_ palette and add a grid snap feature? Drawing points with discrete intervals would make it a _lot easier_ to draw nice free body diagrams, and other simple problem sets without needing to page out of _Mathematica_. ![enter image description here](http://i.stack.imgur.com/4Oaac.gif) **Image 1** : Typical situation where I page out of _Mathematica_ to _Illustrator_. Grid snap makes it much easier and quicker than snapping to elements. Grid that I snap to is shown in the background. New students are intimidated by learning yet another tool. And frankly I can and do write these in code as well, but students take time to learn to do so.


title: Poincaré Section

text: I have encountered somewhat the same problem as here. But with the equations, $x'(t) = p(t), p'(t) = - x(t) - y(t), y'(t) = q(t), q'(t) = - y(t) - x(t)$ My code is,               abc = {x'[t] == p[t], p'[t] == -x[t] - y[t], y'[t] == q[t], q'[t] == -y[t] - x[t]};          psect[{x0_, p0_, y0_, q0_}] :=          Reap[NDSolve[{abc, x[0] == x0, p[0] == p0, y[0] == y0, q[0] == q0,      WhenEvent[x[t] == 0 && p[t] > 0, Sow[{y[t], q[t]}]]}, {x[t], p[t],     y[t], q[t]}, {t, 0, 1000}, MaxSteps -> \[Infinity]]][[-1, 1]]          abcdata = Map[psect, {{1, 1, 1, 2}, {2, 1, -1, 2}, {3, 2, -1, 1}}];          ListPlot[abcdata, ImageSize -> Medium]      I got such an error: Mathematica Kernel for Windows has encountered a problem and needs to close. I appreciate any help.


title: Findfit doesn't give the good fit; Changing the starting values will not change the results

text: I have some complex data:               data={{0.45, 0. + 0.0119333 I}, {0.46, 0. + 0.0100877 I}, {0.47, 0. + 0.00584566 I}, {0.48, 0.00829149 + 0.0000687535 I}, {0.49, 0.0146198 + 0.000213785 I}, {0.5, 0.0202219 + 0.000409093 I}, {0.51,0.0257641 + 0.000664232 I}, {0.52, 0.0314458 + 0.000989817 I}, {0.53, 0.0373584 + 0.0013976 I}, {0.54, 0.0435542 + 0.00190058 I}, {0.55, 0.0500677 + 0.00251309 I}, {0.56, 0.0569241 + 0.00325092 I}, {0.57, 0.0641438 + 0.0041315 I}, {0.58,0.0717442 + 0.005174 I}, {0.59, 0.0797407 + 0.00639954 I}, {0.6, 0.0881481 + 0.00783143 I}, {0.61, 0.0969803 + 0.00949535 I}, {0.62, 0.106251 + 0.0114197 I}, {0.63, 0.115974 + 0.0136358 I}, {0.64, 0.126162 + 0.0161785 I}, {0.65, 0.136829 + 0.0190864 I}, {0.66, 0.147988 + 0.0224023 I}, {0.67, 0.159653 + 0.0261742 I}, {0.68, 0.171837 + 0.0304556 I}, {0.69, 0.184553 + 0.0353065 I}, {0.7, 0.197814 + 0.0407944 I}, {0.71, 0.21163 + 0.0469957 I}, {0.72, 0.226011 + 0.0539967 I}, {0.73, 0.240966 + 0.0618958 I}, {0.74, 0.2565 + 0.0708055 I}, {0.75, 0.272612 + 0.0808548 I}, {0.76, 0.289298 + 0.0921927 I}, {0.77, 0.306543 + 0.104992 I}, {0.78, 0.324321 + 0.119453 I}, {0.79, 0.342588 + 0.135812 I}, {0.8, 0.361278 + 0.154344 I}, {0.81, 0.380289 + 0.175377 I}, {0.82, 0.39947 + 0.199295 I}, {0.83, 0.418604 + 0.226557 I}, {0.84, 0.43737 + 0.257703 I}, {0.85, 0.455307 + 0.293371 I}, {0.86, 0.471745 + 0.3343 I}, {0.87, 0.485713 + 0.381328 I}, {0.88, 0.495804 + 0.435363 I}, {0.89, 0.499993 + 0.497286 I}, {0.9, 0.495388 + 0.567757 I}, {0.91, 0.477963 + 0.646802 I}, {0.92, 0.442359 + 0.733064 I}, {0.93, 0.382045 + 0.822555 I}, {0.94, 0.290457 + 0.906983 I}, {0.95, 0.163934 + 0.972362 I}, {0.96,0.00673389 + 0.999955 I}, {0.97, -0.16425 + 0.972252 I}, {0.98, -0.320906 + 0.883431 I}, {0.99, -0.435064 + 0.746414 I}, {1., -0.492227 + 0.587822 I}}      which want to fit the following function to them:               function=b + a/((-0.977727 + 0.0601085 I) + s);      Without Using any starting values:               ans = FindFit[data, function, {a, b}, s]          {a -> -0.0650086 - 0.0165728 I, b -> -0.0131795 - 0.0513961 I}      The results for the real part of the fitted function is:                Show[Plot[Re[Evaluate[function /. ans]], {s, 0.45, 1.008},        PlotStyle -> Directive[Red, Thickness[0.003]],        PlotRange -> {{0.45, 1.1}, {-0.5, 0.53}}, Frame -> True,        BaseStyle -> FontSize -> 16],       ListPlot[Re[data], PlotStyle -> Black]]      ![enter image description here](http://i.stack.imgur.com/lDBdn.jpg) which is not good enough. Using Manipulate for choosing good starting values doesn't change the result:               func[s1_, a1_, b1_] := function /. s -> s1 /. a -> a1 /. b -> b1          Manipulate[      Show[ListPlot[Re[data]],        Plot[Re[func[s1, a1, b1]], {s1, 0.45, 1.008}, PlotStyle -> Red],        Frame -> True, Axes -> None], {a1, -0.2 - 0.1 I,        0.3 + 0.2 I}, {b1, -0.2 + 0.2 I, 0.2 - 0.2 I}]                FindFit[data,        function, {{a, -0.10951986312866213` -           0.04571191787719727` I}, {b, -0.10639984130859376` +           0.10639984130859376` I}}, s]          {a -> -0.0650086 - 0.0165728 I, b -> -0.0131795 - 0.0513961 I}      How can I find a better fit?


title: Coloring vertices using GraphPlot

text: I have the following problem: I used `GraphPlot` to plot my adjacency matrix. I divided my nodes in three groups: `A = {...}, B={...} and C={...}`. I would like to color the nodes conditioning on them belonging to group A (Blue), B (Red), C (Grey). How do I do that? Example: I have $12$ nodes distributed in three groups as follows: $ A=\\{1,4,5,8\\}, B=\\{2,3,6,7,9,10\\},C=\\{11,12\\}$. I want to color the nodes in $A$ blue, the ones in $B$ red and the ones in $C$ grey. I have of course a $12$x$12$ adjacency matrix $M$ and I use `GraphPlot[M]` to plot the graph. Thank you.


title: Optimization Algorithm: ideas wanted

text: EDIT: Lets assume a random matrix:               m = RandomInteger[25, {5, 5}] // MatrixForm     m= {{8, 23, 1, 3, 19}, {25, 4, 21, 7, 15}, {5, 9, 17, 21, 12}, {10, 3, 5,15, 15}, {17, 15, 10, 16, 11}}      The wanted algorithm should do the following: Pick a random element from the given table and change the order of the matrixelements that small gaussian- like clusters are generated. The constraint is that either the row-wise or the coloumn-wise sum should remain constant upon swapping the elements. Suggestions are very welcome!


title: ListPlot does not recognize my list

text: I have created a list in Mathematica and for some reason it does not want to Plot my list in pairs {x1,y1}, but instead does {y1,y2} even though I partitioned the list to make it in the correct format. Here is the code:               Dynamic[h = w[1.1][[All, 2]] + w[2.1][[All, 2]] + w[3.1][[All, 2]] +         w[4.1][[All, 2]] + w[5.1][[All, 2]] + w[6.1][[All, 2]] + w[7.1][[All, 2]] +         w[8.1][[All, 2]] + w[9.1][[All, 2]] + w[10.1][[All, 2]]]     k = Table[l + Pi/50, {l, -Pi/50, 49 Pi/50, Pi/50}]     Dynamic[List[p = Riffle[k, h/g]]]     Dynamic[Partition[p, 2]]     Dynamic[ListPlot[p]]      The first line takes previously made lists and adds the value of their second column -> (x1, y1) and (x2,y2) returns y3 where y3 = y1+y2. Then a new table from 0 to Pi is created. Then a new list is made, p, with riffle to make x-values go from 0 to Pi and y values are the values from table h. Then the values are partitioned into pairs (x1,y1). Finally, the list should be plotted. But again, Mathematica does (y1,y2,...) and not in pairs. Little help? Thanks. g is a constant between 1 and 10. Below is Full Form p.               List[0,1.`,Times[Rational[1,50],Pi],1.`,Times[Rational[1,25],Pi],0.7507598383409988`,Times[Rational[3,50],Pi],0.7507598383409988`,Times[Rational[2,25],Pi],0.7507598383409988`,Times[Rational[1,10],Pi],0.7507598383409988`,Times[Rational[3,25],Pi],0.7507598383409988`,Times[Rational[7,50],Pi],0.7507598383409988`,Times[Rational[4,25],Pi],0.7507598383409988`,Times[Rational[9,50],Pi],0.7507598383409988`,Times[Rational[1,5],Pi],0.7515548444052627`,Times[Rational[11,50],Pi],0.7599302324995563`,Times[Rational[6,25],Pi],0.7691783335090264`,Times[Rational[13,50],Pi],0.779262649404044`,Times[Rational[7,25],Pi],0.7901433819968573`,Times[Rational[3,10],Pi],0.8017775900068562`,Times[Rational[8,25],Pi],0.8141193585301891`,Times[Rational[17,50],Pi],0.8271199802449125`,Times[Rational[9,25],Pi],0.8407281476365374`,Times[Rational[19,50],Pi],0.8548901554853492`,Times[Rational[2,5],Pi],0.8695501128163745`,Times[Rational[21,50],Pi],0.8868534924648825`,Times[Rational[11,25],Pi],0.9050207506466612`,Times[Rational[23,50],Pi],0.9235628485337459`,Times[Rational[12,25],Pi],0.9424066089368552`,Times[Rational[1,2],Pi],0.9614776641425731`,Times[Rational[13,25],Pi],0.9807007494087392`,Times[Rational[27,50],Pi],1.`,Times[Rational[14,25],Pi],1.0192992505912608`,Times[Rational[29,50],Pi],1.0385223358574267`,Times[Rational[3,5],Pi],1.0575933910631448`,Times[Rational[31,50],Pi],1.076437151466254`,Times[Rational[16,25],Pi],1.0949792493533388`,Times[Rational[33,50],Pi],1.1131465075351175`,Times[Rational[17,25],Pi],1.1115136239813286`,Times[Rational[7,10],Pi],1.126173581312354`,Times[Rational[18,25],Pi],1.140335589161166`,Times[Rational[37,50],Pi],1.1539437565527906`,Times[Rational[19,25],Pi],1.166944378267514`,Times[Rational[39,50],Pi],1.1792861467908469`,Times[Rational[4,5],Pi],1.1909203548008458`,Times[Rational[41,50],Pi],1.201801087393659`,Times[Rational[21,25],Pi],1.2118854032886768`,Times[Rational[43,50],Pi],1.2211335042981468`,Times[Rational[22,25],Pi],1.2295088923924404`,Times[Rational[9,10],Pi],1.`,Times[Rational[23,25],Pi],1.`,Times[Rational[47,50],Pi],1.`,Times[Rational[24,25],Pi],1.`,Times[Rational[49,50],Pi],1.`,Pi,1.`]


title: Differentiate the product of some terms

text: How can I compute the following derivative, $$ \frac{\partial}{\partial \lambda_j} \prod_{i=1}^k (1+\lambda_i)e^{\lambda_i} \quad \text{for }\; 1\le j \le k $$ for some positive integer $k$ which is not known? Note that it is simple to compute the derivative by hand, but I just wonder how such equations can be input in _Mathematica_. **Edit:** After halirutan's answer, I decided to update the question. What I understand from his answer is that: there is no simple straight forward way to express such an example. Now, my question is that: is it possible to add some rewriting rules to _Mathematica_ 's built-in `D` and `Simplify` functions such that, running               Assuming[1<=j<=k&&j\[Element]Integers,        Simplify[D[Product[(1 + l[i]) Exp[l[i]], {i, k}], l[j]]]     ]      Returns the desired output: $$ \frac{2+\lambda_i}{1+\lambda_i}\prod_{i=1}^k (1+\lambda_i)e^{\lambda_i} $$


title: Installing Android ADT and Aptana studio plugins into Workbench

text: My question is a _dual_ to this one. I use Workbench 2.0, but I am now interested in developing some Android Apps and Html projects. In order to do that, I need to install Android ADT and Aptana studio plugins into Eclipse. Questions:   * Since Workbench is based on Eclipse I wonder if I can install these plugins into WB.   * Is it possible and/or wiser to simply install a (newer) version of Eclipse in a parallel folder and install the plugins into this Eclipse? Would this interfere somehow with the existing Workbench? I realize this question is not strictly about Mathematica, but I believe it might be of some interest for many Workbench users, as they explore other languages.


title: Communication between parallel kernels

text: **Greetings.** This is my first post here, also, I am not a seasoned programmer, so any advice pertaining to coding that is not directly related to the problem (stated below) is welcome. I am having trouble with a piece of code that, seemingly, does not compute as I intend it to do. In fact, it seems to do nothing at a certain line. My question here actually contain two parts; (i) My specific problem is located in that I am trying to make a computation on kernel C involving data gathered in kernel A and kernel B. The data gathered in A and B are complex numbers which I "send" to C so it can form a table of differences modulus squared, so the table of data _that should result_ from the computation in C is just real numbers. Some structure: ( _Defining relevant tables. Purpose will become clear as we go._ )               datalist1={};     datalist2={};     datalist11={};     datalist22={};     dataC={};      ( _Letting kernels be aware of the definitions. Also, only letting certain tables be shared among kernels_ )               DistributeDefinitions[datalist1,datalist2,datalist11,datalist22,dataC];     SetSharedVariables[datalist11,datalist22];      ( _My code uses 3 parallel kernels as it is now. Two of them runs some rather heavy numerical integration, and the third kernel has been given the purpose as to control (when to stop them) these integrations via some control object. It is in NDSolve's StepMonitor that I gather data (complex numbers) in a table "datalist1" (and also "datalist2") from the integrations at points chosen to occur regularly. Further, at points in time, I pass this data over to the tables "datalist11" and "datalist22" which are shared among kernels. I want to use these tables of data in kernel C. I run into problems on kernel C when I want to make said table which will contain real numbers._ ) ( _This "While" acts as a stop, not letting the code progress until conditions are met. "go1" and "go2" are shared real numbers that acts as control parameters, being set from kernels A and B. Piece of code below occurs in kernel C._ )               While[go1 < 1 || go2 < 1, Pause[1/100000]];          Do[     AppendTo[dataC,         Sqrt[Sum[          Abs[(datalist22[[h, k]] - datalist11[[h, k]])]^2, {k, 1,            201}]]],      {h, 1, 8}];          Print["Broke through!"];      ( _In the above, the computation halts at the "Do" command, as in; Nothing more comes out of kernel C. I never get to see the message "Broke through!"._ ) I checked that, yes indeed, kernel C _does get the data_ ("datalist11" and "22") as intended since I could let it print some numbers for me on screen which were ok. **_But then, why does kernel C halt itself at that point mentioned?_** The computation of the Do-loop in kernel C is usually a fast one, and no changes to the tables of data is done for a length of time which is more than enough (Do-loop take < second and changes are made to "datalist11" and "22" after about 40 or more seconds), so nothing should be lost in parallel. The way I am doing the entire thing in parallel is through "ParallelTable". That is, each kernel I mention is set to work under ParallelTable. Three kernels are active because I have set three spaces on the table for computing (two for NDSolve and one for control computation). Is this perhaps a bad way to do it? I thought it was desirable from the standpoint of NDSolve. (ii) Regarding parallel computing, communication/sharing of data between kernels seems rather stable with the tool SetSharedVariable[] (or the likes), but when incorporating data gathered in "kernel A" to be used in a computation in a parallel "kernel B" the situation seem to get more delicate. What are the "do's and dont's" in any such situation? I know I say that "things seem to be..", so a more concrete example would be my specific problem. Thanks in advance for any advice. //Patrik **EDIT(1):** (Response to Jagra) @Jagra Hey there and thanks for the input. I am looking into the post you linked (although your link was "incomplete" with a missing "m", I'm guessing it was this post :)). The data I am gathering should indeed be gathered in the master kernel since no direct communication between kernel A and kernel B is made. I am under the impression that the function of SetSharedVariable[] is, that kernel A and B can read and alter any shared variable but that the alteration is made in the master kernel (aswell as parallel kernels?). The power in this should be that, in my case, kernel A and B produce tables of data that is set as shared variables, and with this, kernel C can read the data gathered in A and B from the master kernel; thus in kernel C there should be no hindrance to create new tables of data with this data from A and B. But this is where my code get stuck... It just won't create a simple table. **EDIT(2):** Found it out. I found out what was going wrong in this instance. I had in the problem details above written that the Do-loop concerned was not evaluating. On that I was wrong, it was evaluating, although in a subtle manner! The problem was it was taking _too long_ so that the whole parallel process gave nothing useful because of kernels clashing in "which kernel made what changes and when". Why it was taking so long was because _each time_ the Do-loop wanted to insert a value into a table (as specified) it had to get the **whole** list of data and then just pick the current one to go in. It takes considerably longer time to ask for the whole list of data in evaluated form, and I noticed that the time to go through the Do-loop approximately doubled each time (no good) since the lists of data kept growing. A solution here was to simply use Unevaluated[], so each time I wanted to write into said table I took _only the element in interest_ in evaluated form. This reduced computing time back to constant each time the Do-loop computed. The subtle part to this was that when the Do-loop was to be computed the processor usage went down to almost zero, jumping around somewhere in the interval 0-3%. This is why I naturally thought something died in the computation. But I guess the kernels were just communicating real slow through Master. So, a tip when coding for parallelism, use Unevaluated[] to increase speed in instances like these. You do not read every book in the library each day you go there just to get to read the one book you actually wanted to read that day, but merely acknowledging the rest of the books and that they will be available some other day when you do want to read them.


title: Ranking a vector containing ties

text: How can I rank a vector such that the ties are replaced by their middle ranks. For example, `{1, 2, 2, 3}`. I want to rank this vector but the ties must be replaced by their mid-rank; i.e., given `{1, 2, 2, 3}`, I want to get the vector `{1, 2.5, 2.5, 4}`. Does there exist any fast command or function to do this?


title: Hiding certain user-defined functions in front-end autocompletion

text: I have written an elaborate code that contains a collection of functions for the user and a bunch of auxiliary functions whose existence I would like to hide away from the user. I've written my code in a separate .nb file which I run. I intend the user to do work on a separate clean notebook. But in v9, when I (the user) starts typing something that resembles one of these auxiliary functions, it appears in Mathematica's autocompletion bar. Is there a way for me to 'hide' these functions, while keeping the ones that are intended for the user? For example, I have defined:               fooAuxiliary[n_] := (-1)^n*HarmonicNumber[n+1];          foo[x_] := fooAuxiliary[Floor[x]]*Sin[x]      with the user given access to call `foo` but not `fooAuxiliary`.


title: in v9, backspace causes cell to become section style

text: In the front end of v9, in any given cell that contains content, if I hit backspace to clear the content until there is nothing left, and then hit backspace one more time, the cell becomes a 'section'. Is this a new feature? How do I use it? **Edit** Would someone verify this effect in the comments?


title: How to sum up large number of elements in a table quickly?

text: I have been using _Mathematica_ for some time now but I have a feeling that I am not using it as efficiently as it could be. I have the following problem which I am unable to figure out and it would be great if someone could point me in the right direction: I have a function which is of the following form:               f[x_]:= Total[A1/(A2+x),Infinity];       where `A1` and `A2` are very large arrays (2500x2500 real numbers) (Sorry for the way I wrote the function but I haven't figured out how to insert code into the question (not very good at this type of typesetting)) The problem is when I want to create another list (large list) of values of `f[x]`. It seems that Total is what slows things down here and I was wondering if there is a way to replace Total with something faster. Any clues?


title: Backward compatibility for plugins

text: Are plugins normally backward comatible? I would like to buy a plugin ready for Mathematica 7 and use it on Mathematica 8.


title: How to create a block diagonal matrix by repeating a submatrix $n$ times?

text: If there is a submatrix, let's call $P$: $P=\begin{pmatrix} 1 & 1 \\\ 1 & 1 \end{pmatrix}$ And I want to have $n$, let's say $n=2$, such submatrices placed on the diagonal. The result is expected to look like: $Q=\begin{pmatrix} 1 & 1 & 0 & 0 \\\ 1 & 1 & 0 & 0 \\\ 0 & 0 & 1 & 1 \\\ 0 & 0 & 1 & 1 \end{pmatrix}$ How do I write the code in Mathematica?


title: Wrapping Interval Notation for Take

text: I'm trying to implement the solution to a math problem in Mathematica, but my code can't handle a particular boundary case. I think that I could implement a function that would do what I want it to, but it would be kind of ugly. Here is the problem: ![Here is the Math Problem \(Mathematical Proofs, Chartrand, Polimeni, and Zhang\)](http://i.stack.imgur.com/4mjO9.jpg)               letters = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l",     "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};          GetIndexInAlphabet[letter_String] := Position[letters, letter][[1, 1]];          GetIndexInAlphabet["a"] (* 1 *)          AofAlpha[letter_String] := Module[{startIndex, endIndex},       startIndex = GetIndexInAlphabet[letter];       endIndex = startIndex + 2;       Take[letters, {startIndex, endIndex}]     ];          AofAlpha["a"] (* {a, b, c} *)          AofAlpha["z"] (* {z, a, b} *)      Does anyone have a clean way to implement the wrapping behavior that the function should have?


title: How to manipulate with external data?

text: I have a .txt file which contains a lot of triples (a, b, c) (one per row) which should be coefficients of my equation ax^2+bx+c=0. I want to include each triple in .nb file and solve each equation. Can anyone help me with my problem? Thanks!


title: Simpler input for the new unit support

text: I've been playing with the new unit support in _Mathematica_ 9\. It seems very useful, but the syntax is very verbose. Instead of typing:               UnitConvert[Quantity[1, "Meters"/"Seconds"^2]*Quantity[1, "Minutes"]^2, "Kilometers"]      I would much rather type and read something like:               UnitConvert[1 m/s^2*(1 min)^2, km]      My first idea was to simply define variables for the units I'm going to use:               m = Quantity["Meters"];     km = Quantity["Kilometers"];     s = Quantity["Seconds"];     min = Quantity["Minutes"];      but unfortunately, this doesn't really work: The term `0 [any unit]` is always simplified to `0`, and following computations won't work because the units don't match. So for example `UnitConvert[1 m/s^2*(1 min)^2, km]` works fine, but `UnitConvert[1 m/s^2*(0 min)^2, km]` doesn't work, because the first argument to `UnitConvert` evaluates to 0 Are there other ways to achieve this? For example,   * is it possible to prevent the simplification `0 * 1 Meters -> 0`   * is it possible to adjust generalized input so that entering "5 s" would evaluate to `Quantity[5, "Seconds"]`, (like entering $d_x y$ evaluates to `Dt[y,x]` or `n!` evaluates to `Factorial[n]`) Of course, I've tried the `Ctrl``=` input form first. It's a great way to learn new syntax by example, but I don't think it's practical for day-to-day use, for a number of reasons:   * I can't use notebook expressions in the freeform input. For example: ![enter image description here](http://i.stack.imgur.com/HIiAB.png)   * I can't use 2D input, so I can't even type e.g. $\partial _t$ or $\int _a^b$ within a freeform expression   * Which means that for a longer expression I might have to enter several freeform-input in a single line, which doesn't make it more readable.   * If I do use 2D input like $\int _a^b$, I can't enter freeform-input for _a_ and _b_ ( **EDIT** : Turns out I can. I just have to enter a space before `Ctrl``=`. Thanks @Itai Seggev)   * I've been playing with it for an hour. It hung several times and crashed once (Not reproducible) and I had to restart it once.   * This may be a bit philosophical: I'm using a programming language because I want to express an idea unambiguously. I don't _want_ it to guess whether the symbol _t_ means a variable for time or metric tons.    * The freeform-boxes look weird in a presentation or publication. Of course, I can convert them to input or display form easily, but (in the right context) an expression like `1920*1080 Bytes*24/s` might mean something to the reader, but `2.0739999999999998*^6B*(24/1s)` doesn't, even if it's the same value. **UPDATE** : Based on @Leonid's code, this is the best solution I've come up with so far:               ClearAll[withUnits];     SetAttributes[withUnits, HoldAll];     withUnits[code_] := ReleaseHold[(Hold[code] /.           {            m -> Quantity["Meters"],            s -> Quantity["Seconds"],            km -> Quantity["Kilometers"]            })         //.         {          Power[Quantity[m_, u_]^i_, j_] :> Quantity[m^(i*j), u^(i*j)],          Times[x_, Quantity[m_, u_]^(i_: 1)] :> Quantity[x*m^i, u^i]          }];      It works for the (few) examples I've tried, like               withUnits[a m/s^2 * (3s)^2] /. a -> {0, 1, 2}      but I'm not sure if the `Power`/`Times` replacement really covers all cases. Maybe someone can find counterexamples or improve it. * * * Using @Leonid's answer and this answer by rm -rf, I started a package `MyUnits` that looks like this:               BeginPackage["MyUnits`"]          Unprotect/@{Quantity,Times};     Quantity/:(0|0.) Quantity[_,unit_]:=Quantity[0,unit]     Protect/@{Quantity,Times};          meter=Quantity["Meters"];     second=Quantity["Seconds"];     hertz=Quantity["Hertz"];     minute=Quantity["Minutes"];     hour=Quantity["Hours"];     byte=Quantity["Bytes"];     kilobyte=Quantity["Kilobytes"];     megabyte=Quantity["Megabytes"];          EndPackage[ ]      Using that, I get the simple input I had with the old `Units` package (including command completion) and things like `0 second + 1 hour` still work.


title: Simplifying to different units

text: Is there a way to force Mathematica to `UnitSimplify` to a different unit? For example, I would like `kg m^2/s^2` to simplify to `N m` but it always simplifies to `J`. Is there a way to specify a units preference?


title: How can one use differential boundary conditions with helmholzSolve?

text: I can not get the helmholzSolve function provided by Mark McClure and user21 to work for a case that I want to constrain the spacial derivative of a boundary. In particular, I am looking at the vibration modes of a rectangle with one edge fixed but would also like to fix the slope of the edge as if it were welded rather than hinged. Is it possible to use helmholzSolve in this way? [EDIT] Sorry if I wasn't clear with my question. This was my first attempt at using StackExchange. The code I am trying to run is: First I defined helmholzSolve as per Mark McClure. The only difference is that I added the ability to define the region as a RegionDifference. I also set the boundary condition to fix the left edge of a to-be-defined rectangular region with the statement               dirichletCondition = DirichletCondition[u[t, x, y] == 0, x <= 0];      With these changes helmholzSolve becomes:               Needs["NDSolve`FEM`"];     helmholzSolve[g_, numEigenToCompute_Integer,      opts : OptionsPattern[]] :=      Module[{u, x, y, t, pde, dirichletCondition, mesh, boundaryMesh, nr,      state, femdata, initBCs, methodData, initCoeffs, vd, sd,      discretePDE, discreteBCs, load, stiffness, damping, pos, nDiri,      numEigen, res, eigenValues, eigenVectors,      evIF},(*Discretize the region*)     If[Head[g] === ImplicitRegion || Head[g] === ParametricRegion ||      Head[g] === RegionDifference,       mesh = ToElementMesh[DiscretizeRegion[g], opts],      mesh = ToElementMesh[DiscretizeGraphics[g], opts]];     boundaryMesh = ToBoundaryMesh[mesh];     (*Set up the PDE and boundary condition*)     pde = D[u[t, x, y], t] - Laplacian[u[t, x, y], {x, y}] +       u[t, x, y] == 0;     dirichletCondition = DirichletCondition[u[t, x, y] == 0, x <= 0];     (*Pre-process the equations to obtain the FiniteElementData in \     StateData*)nr = ToNumericalRegion[mesh];     {state} =      NDSolve`ProcessEquations[{pde, dirichletCondition,       u[0, x, y] == 0}, u, {t, 0, 1}, Element[{x, y}, nr]];     femdata = state["FiniteElementData"];     initBCs = femdata["BoundaryConditionData"];     methodData = femdata["FEMMethodData"];     initCoeffs = femdata["PDECoefficientData"];     (*Set up the solution*)vd = methodData["VariableData"];     sd = NDSolve`SolutionData[{"Space" -> nr, "Time" -> 0.}];     (*Discretize the PDE and boundary conditions*)     discretePDE = DiscretizePDE[initCoeffs, methodData, sd];     discreteBCs = DiscretizeBoundaryConditions[initBCs, methodData, sd];     (*Extract the relevant matrices and deploy the boundary conditions*)     load = discretePDE["LoadVector"];     stiffness = discretePDE["StiffnessMatrix"];     damping = discretePDE["DampingMatrix"];     DeployBoundaryConditions[{load, stiffness, damping}, discreteBCs];     (*Set the number of eigenvalues ignoring the Dirichlet positions*)     pos = discreteBCs["DirichletMatrix"]["NonzeroPositions"][[All, 2]];     nDiri = Length[pos];     numEigen = numEigenToCompute + nDiri;     (*Solve the eigensystem*)     res = Eigensystem[{stiffness, damping}, -numEigen];     res = Reverse /@ res;     eigenValues = res[[1, nDiri + 1 ;; Abs[numEigen]]];     eigenVectors = res[[2, nDiri + 1 ;; Abs[numEigen]]];     evIF = ElementMeshInterpolation[{mesh}, #] & /@ eigenVectors;     (*Return the relevant information*){eigenValues, evIF, mesh}]      Then I simply defined the region as a rectangle and called helmholzSolve               rect = Rectangle[{0, -1}, {2, 1}];     {ev, if, mesh} = helmholzSolve[rect, 6];      I would like to add a constraint to the helmholzSolve function               (D[u[t,x,y],x]/.x->0)==0      but adding that constraint to the equations to solve doesn't seem to work. A number of errors are returned starting with               NumericalRegion::femtemnbb: The bounds for FullRegion[1] are {{0.,NumericalRegion[None, {{0.,2.},{-1.,1.}}]}}. It is suggested to specify explicit numeric bounds. >>          NDSolve`ProcessEquations::femimvr: The number of independent variables 2 ({x$538,y$538}) does not match the embedding dimension 1      Is there any way to add such a constraint?


title: Histogram3D frame ticks with bin text labels rendered in x-y plane?

text: Is it possible in `Histogram3D` to substitute frame ticks text labels and have the layout in x-y plane? Starting with a `Histogram3D` such as ![enter image description here](http://i.stack.imgur.com/SSh8Z.jpg) Then combining with additional `Graphics3D` text elements, eg:                Text[Style[lbl, Medium], {-1, pos + 1/2, 0}, {1, 0}, {1.5, -1}]      Text orientation changes with histogram rotations, and they look awful. Any ideas?