title: Implement settable properties

text: I am looking for advice on implementing the following. (It is possible that the answer is that it is simply not a good idea to do this.) I would like to have an object similar to `FittedModel`. Let's call its head `Obj`. Like `FittedModel`, it will have properties, e.g.               properties = {42}; (* properties stored here for the sake of this toy example *)          Obj[id_]["Property"] := properties[[id]]      Now let's define `obj = Obj[1]` and evaluating `obj["Property"]` will yield `42`. I am looking to make it possible to do `obj["Property"] = 137` to _set_ this property. Here's an attempt that doesn't quite work (let's ignore `SetDelayed` for now and stick to `Set`):               Obj /: (Obj[id_]["Property"] = value_) := setObjProperty[id, value]          setObjProperty[id_, value_] := properties[[id]] = value      Now `Obj[1]["Property"] = 137` will work as I want it to. However, `obj["Property"] = 256` will not. Instead of changing the property, it will associate the following definition with `Obj`: `Obj[1]["Property"] = 256`. ![enter image description here](http://i.stack.imgur.com/HZwzn.png) **Question:** Is there a way to implement this syntax for property setting in a reliable way? I realize that this isn't exactly in the spirit of Mathematica objects being immutable. In my case `Obj` represents a data structure implemented in C++ and `id` is a handle to it. * * * Note the following behaviour of `=` and `:=`: ![enter image description here](http://i.stack.imgur.com/rkAwI.png) The head of the expression to be set is evaluated by `Set` (or `SetDelayed`). * * * `Graph` has settable properties which are handled through `SetProperty`, `PropertyValue`, etc. I find this syntax very tedious, so I was looking for something simpler. For my application having mutable state seems very natural, and I think it's not worth avoiding. I have a simulation that has a complex internal state, _not fully exposed to Mathematica_. The simulation can be stopped and resumed. Parameters can be adjusted when the simulation is stopped. I think (I may be wrong) that in order to work only with immutable objects, in the natural Mathematica way, it would be necessary to expose the full simulation state to Mathematica and to store it as a pure Mathematica expression (instead of data on the C side). I would then store the _full_ state as an `Association`, and have a function that runs the simulation and returns a new `Association` (simulation state), along with data collected during the simulation process. Associations would also give me this easy property-setting syntax for free. However, exposing the full state may not be worth all the extra work.


title: Plotting Uncertainty for a Sample of Functions

text: I am trying to produce a plot showing the variation in a sample of functions. It should look like this plot or that plot. I tried to use `SmoothDensityHistogram`. Even for the following simple example this does not look right. Do you have other suggestions? My approach so far was:               dx = 0.01;     functionSample =      Table[noise = Random[NormalDistribution[0, 0.5]];      Table[ {x, x (1 - x) + noise}, {x, 0, 1, dx}], {i, 1, 60}];     var = Flatten[diff, 1];     ListPlot[functionSample[[All, All]], Joined -> True]     SmoothDensityHistogram[var,      ColorFunction -> (Blend[{White, Black}, #] &)]      Producing ![ListPlot](http://i.stack.imgur.com/wgDiy.jpg)![SmoothDensityHistogram](http://i.stack.imgur.com/ishQV.jpg) Maybe things can be improved by choosing a small bandwidth of the kernel in x direction and a larger in y direction of the underlying kernel smoother.


title: Cheat sheets or reference cards for Mathematica

text: In order to improve my workflow with _Mathematica_ , I'm looking for _cheat sheets_. The purpose of such reference cards is to be printed and to stay on the desk during the learning of a new programming langage. They are _not_ extensive lists. It should be   * printable,   * readable at a glance. It may be   * general,   * or specific to a given task (algebra, analysis, style, ...) I found a first list of such cheat sheets for _Mathematica_ at devcheatsheet.com, with a special thumb up for this one at the Wolfram Library Archive. They might be unpractical (referring mostly for programming instead of shortcuts) or outdated (as they are mostly for version 5.2). Any suggestion? **Edit:** I am asking for good reference cards or cheat sheets. For a extensive list of all keyboard shortcuts, please refere to Wolfram's documentation. **Edit2:** This good cheatsheet for git is a good example of what I'm looking for. As you may see, the way information is chosen, sorted and put together has much importance in the process. It is very usefull for people that have already understood the syntax but not yet memorized it. It is a speedy and smart summary. It is also a tool for beginners to detect what is important. Please see also the example from Wolfram's archive I gave above. I would be surprised it is the only one out there.


title: Load Mathematica packages from the network

text: Is it possible to load packages (.m) directly from the network (http, https) without installing it locally?


title: How to save (large) data generated from simulations

text: The following is a simple example of a much larger simulation that I want to run Define some processes               norTheta[mu_, sigma_] := Random[NormalDistribution[mu, sigma]];     norPi[mu_, sigma_] := Random[NormalDistribution[mu, sigma]];          thetaNext[thetaNow_] :=      thetaNow + (-lambdaTheta*(thetaNow - thetaBar)*deltaT +      sigmaTheta*norTheta[0, 1]*Sqrt[deltaT]);     piNext[piNow_, thetaNow_] :=      piNow + (-lambdaPi*(piNow - thetaNow)*deltaT +      sigmaPi*norPi[0, 1]*Sqrt[deltaT]);      Then define some parameters               lambdaTheta = 0.07;     thetaBar = 0.02;          sigmaTheta = 0.012;      lambdaPi = 1.0;             sigmaPi = 0.0125;      Then simulate the system               steps = 252;     T = 50;      deltaT = 1/steps; // N      Maturity = T*steps;          process = Transpose[NestList[{  piNext[#[[1]], #[[2]]],     thetaNext[#[[2]]]} &,{0.02, 0.02}, Maturity]];      I have two questions: (1) what is the best MMA of repeating the above 10,000 at each loop saving the output 'process' for use later; (2) what is the fastest way of doing this? Many thanks, Paul


title: Plot roots of B(z) according to angle small to large

text: I have the following function:                  B[z_]=((z*(z - 0.5)*(z + 0.5))/((1 - 0.5*z)*(1+0.5*z)))      I want to plot the roots this polynomial according to angel like below the picture with Mathematica. ![enter image description here](http://i.stack.imgur.com/34lwM.png)


title: What is wrong with my use of Flatten?

text: Why does               Flatten[f[g[a, f[b]], f[c, d]]]      result in > >     f[g[a, f[b]], c, d] >   I expected the answer to be > >     f[g[a, b], c, d] >   What is wrong in this code?


title: SetAccuracy behavior

text: I'm puzzled by the output I get from `SetAccuracy`. According to the documentation, when `SetAccuracy` is used to increase the accuracy of a number, the number is padded with zeros. But, let's take a look at a couple of examples:               SetAccuracy[1.2, 5]     (* 1.2000 *)     SetAccuracy[1., 5]     (* 1.0000 *)     SetAccuracy[0.2, 5]     (* 0.2000 *)      These examples seem to work properly, so why does it behave differently in this case?               SetAccuracy[0., 5]     (* 0.*10^-5 *)      What should I do to get a zero with four trailing zeros? **Update** I'm asking this question, because I need to export data to a txt file and I would like to avoid having `0.*10^-5` sort of numbers.


title: Workaround for Import not supporting the \leqslant TeX macro

text: $\{A\leqslant x\leqslant B\}$      Copy the code into Notebook, and you'll lose the `less sign`, this can be rendered well in Mathematica.StackExchange $\\{A\leqslant x\leqslant B\\}$ * * * And you can also `ImportString["$\{A\\leqslant x\\leqslant B\\}$","TeX"]//CreateDocument`, Here is the problem, the `leqslant` was removed, are there any options of `ImportString` or are there any other methods to Import some latex codes without losing some information?


title: In LineLegend, how do I force the legend entries to appear in a single column?

text: I want to create a **_single_** column `LineLegend` with at least 12 different entries. Suppose that I define lists `colors` and `names` as follows:               colors = {Red, Magenta, Pink, Orange, Yellow, Green, Darker[Green],         Cyan, Blue, Purple, Black, Gray};     names = Table["Color " <> ToString[i], {i, 1, Length[colors]}];      If I use `colors[[;; 10]]` to show only the first 10 entries in `LineLegend` with `LegendLayout -> "Column"`, I get a nice single column `LineLegend`:               LineLegend[colors[[;; 10]], names, LegendLayout -> "Column",       LabelStyle -> {20, FontFamily -> "Arial"}]      ![singleColumn](http://i.stack.imgur.com/T8yxR.png) However, if I show 11 or more entries, the legends become double-columned:               LineLegend[colors[[;; 11]], names, LegendLayout -> "Column",       LabelStyle -> {20, FontFamily -> "Arial"}]      ![doubleColumn1](http://i.stack.imgur.com/BMQNK.png)               LineLegend[colors, names, LegendLayout -> "Column",       LabelStyle -> {20, FontFamily -> "Arial"}]      ![doubleColumn2](http://i.stack.imgur.com/lOUPx.png) How can I force `LineLegend` to put the legend entries in a single column?


title: How can I program my own financial indicator to be plotted in a TradingChart?

text: FinancialIndicator["ind",par1,par2,...], represents a financial indicator "ind" with parameters par1,par2, etc. All available financial indicators can be displayed with FinancialIndicator[]. Is it possible to program my own financial indicator and to plot it in a TradingChart ? How can I do it?


title: Simplifying a trigonometric expression

text: I'm sure this has been addressed before, but I can't find it! I want _Mathematica_ to simplify               Sqrt[1 - Sin[π/6 - θ]^2]      to               Cos[π/6 - θ]      Just as               PowerExpand[FullSimplify[Sqrt[1 - Sin[θ]^2]]]      Does what you would expect. Maybe the polite question would be how to transform               Sqrt[1 - Sin[π/6 - θ]^2]      to               Sqrt[Cos[π/6 - θ]^2]


title: Poisson solver using Mathematica

text: I am looking for some help with a Poisson solver I am writing in Mathematica. The code is quite long with Arrays plugged in, so the full details can be found at http://pastebin.com/uSrSDcW6 I am calculating voltages given charge densities using the central difference method derived from Poisson's equation. After calculating the voltage, I test the data set for convergence. I am setting convergence thresholds on the order of 10^-1000+. I have the loop set up to kick out after 10000 iterations in case something goes awry, as a fail safe. I have a loop counter in place for sanity. The program seems to run fine as long as the convergence threshold is set to 10^-10. My question is this: No matter what I update the threshold to, for example, 10^-100 or 10^-150, the computation stops after 633 iterations and kicks out of the loop. I would appreciate any help with this, I am completely stuck. I've added comments to the program that should be explanatory for anyone on this forum. * ** _Update 10/9/12_ **** I've narrowed my problem down to Machine Precision. I need to expand the Machine Precision to my Max Machine Precision of ~10^-309. How do I set this globally within my program when Im using 10x10x34 arrays initialized at ~15 digit precision?


title: NIntegrate using Boole doesn't work

text: This doesn't want to work for me - I don't know why not. It usually gives me `0`, but sometimes also a different number. I know it should be a small, non- zero number.               myO[e1_, e2_] := (e1)/((e1) + (e2));     myU[e1_, e2_] := (1 - e2)/((1 - e1) + (1 - e2));     myV[p_, e1_, e2_] := p (e1)/(p (e1) + (1 - p) (1 - e2));     myW[p_, e1_, e2_] := p (1 - e1)/(p (1 - e1) + (1 - p) e2);          NIntegrate[ Boole[0 < e1 < e2 < 1/2 && 0 < e3 < 1/2 && e1 < p < 1 - e1 &&                        e3 < myV[p, e1, e2] < 1 - e3 < myW[p, e1, e2] &&                        myO[e1, e2] < e3 < myU[e1, e2]],                       {p, 0, 1}, {e1, 0, 1/2}, {e2, 0, 1/2}, {e3, 0, 1/2}]


title: What is the right way to write a function that includes other functions?

text: I want to include multiple **sub functions** : $b(x) = 10x$ $w(x) = s + b(x)$ $c(x) = x^2$ into two **main functions** : $ua(x) = w(x)-c(x)$ $ub(x) = w(x)-c(x)^2$ As a reaction to this answer, I wrote the following in mathematica:               b[x_] := 10 x     w[b_, x_] := s + b[x]     c[x_] := x^2          ua[w_,b_,c_,x_] := w[b,x] - c[x]     ub[w_,b_,c_,x_] := w[b,x] - (c[x])^2      My intention is to have those main functions that can be called with just x values (e.g. Plot functions with x as the dependent variable) I want subfunctions building my main function **because** :   * Easier control of the sub functions   * Main function looks "cleaner"   * No code duplication **Q:** What is the right way to achieve the desired behavior?


title: Removing edge weights from a Graph

text: How can I remove `EdgeWeight`s from a `Graph` without affecting any other properties of the graph? Let's construct a graph with weights:               g = RandomGraph[{10, 20}, EdgeWeight -> ConstantArray[1, 20]]      Based on the documentation I would expect the following to return `Automatic` (the same thing it returns for a graph that has no edge weights):               PropertyValue[RemoveProperty[g, EdgeWeight], EdgeWeight]          (* ==> {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} *)      However, it returns the weights that were originally set. The following seems to work, but it removes other properties as well               PropertyValue[RemoveProperty[g], EdgeWeight]          (* ==> Automatic *)      Extracting the edges and vertices, then re-building the graph will discard other properties as well. `Graph` objects are atomic, and they don't have a Mathematica-expression form, so trying to modify them at the expression level is not a possibility either. **How can one then remove`EdgeWeight`s from a `Graph` without modifying any other properties of the `Graph`?** **Update:** It turns out `WeightedGraphQ@RemoveProperty[g]` still returns `True`. So even though the weight values are removed, the system still considers the graph to be weighted.


title: What is the most effective way to setup a Notebook with transparent background but solid contents?

text: I know there is a Notebook option `WindowOpacity` can be used to adjust the opacity of a whole notebook. But what I want is keeping the text and graphics and so on being `Opacity[1]` while the other parts of the window being `Opacity[0.3]`, which may look like (the pic is roughly produced by photoshop): ![enter image description here](http://i.stack.imgur.com/OoFhr.jpg) I guess this effect might be achieved by capture the screen prior and set it as the background of a Cell/Cells. But even if that is applicable, it must be very inefficiency. My questions are: how to achieve this transparent effect in Mathematica (maybe with some help from external applications)? and how to do it effectively?


title: Solve returns a wrong answer

text: I'm afraid the following is rather localized questions, but I don't know how to simplify and generalize it. I have the following two points (in the real plane):               p = {Sqrt[b y1^2 + 4 ϵ], y1}     q = {(3 b y1^2 + 12 ϵ + Sqrt[5] y1 Sqrt[b (b y1^2 + 4 ϵ)])/(2 Sqrt[b y1^2 + 4 ϵ]),           (3 b y1 + Sqrt[5] Sqrt[b (b y1^2 + 4 ϵ)])/(2 b)}      In particular, I have also the following assumptions:               $Assumptions = b > 0 && y1 ∈ Reals && ϵ > 0;      Then I try to solve the following:               Solve[p[[2]] == -q[[2]] && p[[1]] == q[[1]], y1]      and obtain the answer               {{y1 -> -(Sqrt[ϵ]/Sqrt[b])}, {y1 -> Sqrt[ϵ]/Sqrt[b]}}      However, one can easily test that the second answer is wrong:               In: {p, q} /. % // Simplify      returns: $\left\\{\left\\{\left\\{\sqrt{5} \sqrt{\epsilon },-\sqrt{\frac{\epsilon }{b}}\right\\},\left\\{\sqrt{5} \sqrt{\epsilon },\sqrt{\frac{\epsilon }{b}}\right\\}\right\\},\left\\{\left\\{\sqrt{5} \sqrt{\epsilon },\sqrt{\frac{\epsilon }{b}}\right\\},\left\\{2 \sqrt{5} \sqrt{\epsilon },\frac{4 \epsilon }{\sqrt{b \epsilon }}\right\\}\right\\}\right\\}$ What am I missing?


title: Can one use Map during Expand?

text: Can one `Map` a simplifying function to the summands of an `Expand` before fully expanding the expression in question first? Consider the following example: I want to integrate the following product over `[0,1]` in the variable `t`.               imax = 30;     p1 = Product[a t^i + b t^(imax - i) , {i, imax}];      For that I define a custom integration (much faster than the general Integrate)               CustomIntegration[exp_] := exp /. t^k_. -> 1/(k + 1)      for which I have to use `Expand` first. The problem is that the expansion really eats a ton of memory, even though the final result is actually much smaller.               ByteCount@p1     ByteCount[p2 = Expand@p1]     ByteCount[CustomIntegration /@ p2]      gives               9376     1404216     13696      So, the expansion requires around 100-times as much memory as needed. My actual script currently needs around 70 GB of memory. So, how could I reduce that?


title: How can I calculate a combination of limit and sum?

text: ![enter image description here](http://i.stack.imgur.com/Ed7G5.jpg) How can I solve the above problem? I enter it as:               Limit[Sum[Sqrt[1 + i^2/n^2]/n, {i, n}], n -> Infinity]      but this is not working: ![enter image description here](http://i.stack.imgur.com/GWVw6.jpg)


title: Scoping inside of Module and Manipulate

text: This is driving me nuts: I'm trying to control the parameters for a relatively large system of ODEs using Manipulate.               With[{todo =       Module[        {sol, ode, timedur = 40},        ode = Evaluate[odes /. removeboundaries /. moieties];        sol = NDSolve[Join[ode, init], vars, {t, 0, timedur}];        Plot[Evaluate[c[1][t] /. parms] /. sol, {t, 0, timedur}]        ],      controls =        Sequence @@         Table[{{parms[[i]][[1]], parms[[i]][[2]]},           0, (3*parms[[i]][[2]])}, {i, 1, Length[parms]}]},     Manipulate[todo, controls, ContinuousAction -> False,       ControlPlacement -> Bottom]]      The solve step, in which sol is created, performs successfully. When trying to make a Plot from this however, I get all kinds of errors like               NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.`      Although NDSolve runs fine when Plot is commented out! Note that this code relies on global variables defined elsewhere in the script. I should also add that the code inside the Module[] works when copied to a fresh cell. Could someone help me out? Thanks!!


title: how to simplify symbolic integration

text: The following is the code:                   In[3]:= Simplify[Integrate[f[x]*c, {x, a, b}]/c, Assumptions -> c > 0]              Integrate[c f[x], {x, a, b}]         ----------------------------                     c      but obviously the right answer should be:                   Integrate[f[x], {x, a, b}]      how to solve it without placing c outside the integrate function?


title: Strange behavior of MemberQ, Position

text: After importing an array of latitudes and longitudes and trying to find the position of some latitudes I was encountered with an unexpected problem since certain values could not be found for some reason. Position and MemberQ behave the same. Everything works just fine if converted to strings. I work with _Mathematica_ Version 9. Example:               r = Range[39.7026, 39.703, 0.0001];     r == {39.7026, 39.7027, 39.7028, 39.7029, 39.703}      > >     True >                 MemberQ[r, #] & /@ r      > >     {True, True, True, True, True} >                 MemberQ[r, #] & /@ {39.7026, 39.7027, 39.7028, 39.7029, 39.703}      > >     {True, True, False, True, True} >                 Position[r, #] & /@ r      > >     {{{1}}, {{2}}, {{3}}, {{4}}, {{5}}} >                 Position[r, #] & /@ {39.7026, 39.7027, 39.7028, 39.7029, 39.703}      > >     {{{1}}, {{2}}, {}, {{4}}, {{5}}} >   Out of the 1001 values of the following list rr, this problem is encountered with 17 of them               rr = Range[39.69, 39.79, 0.0001];      Notice the spacings of 30 Positions: > >     {{92}, {122}, {199}, {229}, {259}, {336}, {366}, {443}, {473}, >      {503}, {580}, {610}, {717}, {747}, {824}, {854}, {884}} >   Values: > >     {39.6891, 39.6921, 39.6998, 39.7028, 39.7058, 39.7135, 39.7165, 39.7242, > 39.7272, >      39.7302, 39.7379, 39.7409, 39.7516, 39.7546, 39.7623, 39.7653, 39.7683} >


title: HoldForm and RandomChoice

text: I'm trying to get random expressions displaying. For that, I'm starting with addition, multiplication, substraction and division. When trying out this code                HoldForm[c e d] /. c -> RandomInteger[{1, 15}] /.       d -> RandomInteger[{1, 15}] /.       e -> RandomChoice[{"-", "+", "/", "*"}]      , I sometimes get indeed expressions as "11 "+" 6" as expected, but I also get                14 "-"      or                "-" 9.      Why is that? Perhaps anyone has another idea for making randomised arithmetic expressions? Thanks, once again!


title: Can Mathematica determine part-of-speech for each word in a text?

text: I've found that `WordData` has a database of English words and their possible parts of speech. But some words are ambiguous, e.g. _result_ can be a verb or a noun:               In[7]:= WordData["result", "PartsOfSpeech"]     Out[7]= {"Noun", "Verb"}      Such cases can, however, be distinguished based on context. So my question is: can one use _Mathematica_ to perform parts-of-speech tagging of a text, either through built-in functions or as an extension? There are many known algorithms and implementations available, yet I have not been able to find a way to leverage them in Mathematica.


title: Export to Excel gives error for large lists

text: This is my data mwedata.dat I do this:               mwe = Import["mwedata.dat"];     dataforexcel20 = DeleteCases[mwe, a_ /; a[[3]] > 20];     dataforexcel80 = DeleteCases[mwe, a_ /; a[[3]] > 80];          Dimensions[dataforexcel80]     Dimensions[dataforexcel20]          {48011, 6}     {2384, 6}          Export["mwe20.xlsx", dataforexcel20]     "mwe20.xlsx"          Export["mwe80.xlsx", dataforexcel80]     $Failed      The Export works for the smaller file but not the larger file. The error message says               Export::fmterr: "Invalid \!\(\"XLS\"\) format. "      When I do this               Table[dataforexcel[k] = DeleteCases[mwe, a_ /; a[[3]] != k], {k, 1,100}];     Table[Export["mwetest.xlsx", dataforexcel[k]], {k, 1, 100}]      I get               {"mwetest.xlsx", "mwetest.xlsx", "mwetest.xlsx",   "mwetest.xlsx" ....}      and so on a 100 times. So there is nothing wrong with the data when `a[[3]]>20` In a unrelated question, when doing an `Export` inside the Table.. would it have been possible to index the excel files with `k`?                Table[Export["mwetest[k].xlsx", dataforexcel[k]], {k, 1, 100}]      Ok.. back to my earlier problem, I thought that excel could handle up to 65,000 rows. I'd appreciate some help in figuring out what I am doing wrong here or what can I do to fix my `Export` of a large file.


title: Data interpolation and ListContourPlot

text: I am fairly new to _Mathematica_ and I have two quick questions on using it for a Hydrology and Hydrogeology class. One is about data interpolation and interpolating without any data defined in an area. First question: I have a set of data:                   data = {           {875, 3375, 632}, {500, 4000, 634}, {2250, 1250, 654.2}, {3000, 875, 646.4},           {2560, 1187, 641.5}, {1000, 750, 650}, {2060, 1560, 634}, {3000, 1750, 643.3},           {2750, 2560, 639.4}, {1125, 2500, 630.1}, {875, 3125, 638}, {1000, 3375, 632.3},           {1060, 3500, 630.8}, {1250, 3625, 635.8}, {750, 3375, 625.6}, {560, 4125, 632},           {185, 3625, 624.2}                 }      where $x$ and $y$ are coordinates in space and $z$ is the elevation of bedrock underground. What I want to do is to have a "smooth" and not jagged contour plot. I created the following code which is extremely cumbersome and inefficient, but works:               ListContourPlot[data,       Contours -> Function[{min, max}, Range[min, max, 2]],       ColorFunction -> "TemperatureMap",       Epilog -> {PointSize[.015],         Point[{{875, 3375}, {500, 4000}, {2250, 1250}, {3000, 875}, {2560,            1187}, {1000, 750}, {2060, 1560}, {3000, 1750}, {2750,            2560}, {1125, 2500}, {875, 3125}, {1000, 3375}, {1060,            3500}, {1250, 3625}, {750, 3375}, {560, 4125}, {185, 3625}}],         Text[GB2, {875, 3450}], Text[GB4, {500, 4070}],         Text[220, {2250, 1330}], Text[221, {3000, 940}],         Text[222, {2560, 1250}], Text[223, {1050, 820}],         Text[224, {2060, 1630}], Text[225, {3000, 1810}],         Text[226, {2750, 2630}], Text[227, {1125, 2580}],         Text[10, {875, 3190}], Text[15, {1000, 3430}],         Text[16, {1100, 3550}], Text[17, {1250, 3700}],         Text[18, {750, 3455}], Text[20, {630, 4125}],         Text[21, {185, 3690}],         Text[Style[626.2, Bold, Medium], {390, 3590}],         Text[Style[628.2, Bold, Medium], {600, 3590}],         Text[Style[630.2, Bold, Medium], {800, 3590}],         Text[Style[632.2, Bold, Medium], {1000, 3640}],         Text[Style[634.2, Bold, Medium], {1200, 3375}],         Text[Style[636.2, Bold, Medium], {1500, 3390}],         Text[Style[638.2, Bold, Medium], {1301, 1669}],         Text[Style[640.2, Bold, Medium], {1301, 1469}],         Text[Style[642.2, Bold, Medium], {1301, 1269}],         Text[Style[644.2, Bold, Medium], {1301, 1100}],         Text[Style[646.2, Bold, Medium], {1160, 1000}],         Text[Style[648.2, Bold, Medium], {1470, 1000}],         Text[Style[650.2, Bold, Medium], {1500, 850}],         Text[Style[652.2, Bold, Medium], {2000, 1070}]}]      The `ListContourPlot` only uses a linear interpolation for the data. I tried adding in               InterpolationOrder -> 5      Any other order does not really change the contour lines. I had a problem using               ContourLabels -> All      ; otherwise I would not manually place text for labeling each contour and similarly for labeling each data point. My second question: The contour plot does not extend contours out past where points are interpolated (I think). ![contour plot](http://i.stack.imgur.com/ApUZR.png) Is there any way to continue these contour lines and extend them to the graph's boundaries? Normally, one would hand draw these contours and extend them. Thanks so much!


title: how to solve second order nonlinear coupled differential equations using NDSolve with hyperbolic function

text: i have to solve some solitons scattering through this coupled equations. i need to get two different graph, but still the graph did not come out. and also the equations quite complicated containing hyperbolic trigo . (maybe just for me). i dont know whether the problems come from the hyperbolic equations that i used, or becoz of initial condition.the coding as below:                   u = 0.05;         g = 0.2;         s = NDSolve[{x''[t] == 4/(\[Pi]^2 x[t]^3) - 10/(\[Pi]^2 x[t]^2) - (80 g)/(3 \[Pi]^2 x[t]^3) - ((6 u)/(\[Pi]^2 x[t]^2))[1/Cosh[y[t]/x[t]]^2 - (2 y[t])/x[t] Sinh[y[t]/x[t]]/Cosh[y[t]/x[t]]^3],        y''[t] == u (y[t]/(x[t]^3))[Sinh[y[t]/x[t]]/Cosh[y[t]/x[t]]^3],       x[1] == -3, x'[1] == 0, y[0] == 1, y'[0] == 3}, {x, y}, {t, 0,100}]     Plot[Evaluate[{x[t], y[t]} /. %], {t, 0, 100}, PlotRange -> All, PlotPoints -> 200]


title: What am I doing wrong when using DSolve

text: I'm trying to solve a simple PDE in _Mathematica_. I just can't get _Mathematica_ to give me an explicit analytical solution. This is the code that I made and it basically repeats in the output what I have given in the input. Below are my input and output. What am I doing wrong?               pde = D[u[z, t], {t, 1}] + const* D[u[z, t], {z, 2}] == 0     DSolve[pde, u[z, t], {z, t}]      > >     (u^(0,1))[z,t]+const (u^(2,0))[z,t]==0 >     DSolve[(u^(0,1))[z,t]+const (u^(2,0))[z,t]==0,u[z,t],{z,t}] >


title: Single image import from stack via FTP connection

text: **Background** I would like to create a `CDF` document that is embedded on a webpage. The `CDF` will contain some image display elements and upon pressing a button a specific image from an image stack will be displayed. The data will be located on a FTP server where the images are loaded from. Unfortunately, I cannot provide access to the FTP since it is protected with password. **The problem** To speed up the process of importing single images from a stack I came across the option `"ImageList"` for `Import`:               Import["R:\\...Largetest1.1.tif", {"ImageList", 5}]      which does exactly what I want. It directly imports only the fifth image of the image stack. My test stack here is located on a local hard drive and contains 101 images of image dimensions 600x1000 pixels. The file size is about 118 MB. I checked for `AsboluteTiming` when importing the single image from the stack compared to the complete import. Depending on the current CPU load the timings differ a little bit.               First@AbsoluteTiming@Import["R:\\...Largetest1.1.tif", {"ImageList", 5}]      > 0.060000               First@AbsoluteTiming@Import["R:\\...Largetest1.1.tif"][[5]]      > 2.426500 Since the `Import` option works fine for image stacks on the local hard drive I want to use the same option when importing the same image via `FTP`. Unfortunately, this takes like forever which suggests that it doesn't import only a single image but rather the complete stack and then takes out the fifth image:               First@AbsoluteTiming@Import["ftp://...Largetest1.1.tif", {"ImageList", 5}]      > 242.915000 When I import a single image via `FTP` it works quite fast:               First@AbsoluteTiming@Import["ftp://...5Largetest1.1.tif"]      > 0.120000 **Attemps** I then tried to find out what is happening and came across the function `ImageReadTIFF`. It seems to be possible to also specify import of a single image from a stack. However, the function fails when importing via `FTP`:               AbsoluteTiming@Image`ImportExportDump`ImageReadTIFF["R:\\...Largetest1.1.tif", {5}]      > {0.070000, {Image}}               AbsoluteTiming@Image`ImportExportDump`ImageReadTIFF["ftp://...Largetest1.1.tif", {5}]      > {0., {{$Failed, 1}}} **Edit** Unfortunately, this is also an issue when importing a single file from compressed archives such as `ZIP`. I tried to pack the single `TIFF` files from the above mentioned stack into a `ZIP` archive and then checked whether importing a single file works when the `ZIP` file is on my local hard drive and on the `FTP` server. The file size is reduced to about 36 MB upon compression compared to the 118 MB of the original image stack. First@AbsoluteTiming[Import["R:\ ... .zip", "Image5.tif"]] > 0.160000 First@AbsoluteTiming[Import["ftp://... .zip", "Image5.tif"]] > 23.970000 It still semms to download the complete `ZIP` file first and then accesses the image when importing from `FTP`. **Questions**   * Is there a fast way to import a single image form a stack via `FTP`? I mean, importing only one image of about 1 MB instead of importing the whole stack of 118 MB and then having to wait until the whole data is transferred.   * Is there a possible workaround I could use such that I do not have to import complete files or archives?   * Is it even possible to do such an import via `FTP`?  **No solution but** After talking to some guys who know more about `FTP` protocols, I learned that the `FTP` protocol doesn't allow such operations. It is indeed necessary to download the whole `ZIP`/`TIFF` file and then access single files within the file afterwards. Unfortunately, I will have to find another solution for that. Anyhow, thanks for comments and ideas.


title: Slow plotting of trigonometric functions

text: I have two sets of solutions for `a` and `b`. I'm plotting solution only if it is positive for both `a` and `b`.                a = 2; b = 3;      solutionsA[x_, a_, b_] = {a Sin[b*x], a Sin[b*x + Pi/2], a Sin[b*x + Pi]};      solutionsB[x_, a_, b_] = {a Tan[b*x], a Tan[b*x + Pi/2], a Tan[b*x + Pi]};      Plot[Select[         Transpose[           {solutionsA[x, a, b], solutionsB[x, a, b]}         ]        , (#[[1]] > 0 && #[[2]] > 0 ) &]      , {x, 0, 10}, Exclusions -> {Cos[b*x] == 0, Sin[b*x] == 0}]      My output is very slow. Why?


title: Mathematica cannot calculate a limit

text: When I evaluate               Limit[E^(-n)*Sum[n^k/(k!),{k,0,n}], n -> ∞]      _Mathematica_ gives me the result               Limit[Gamma[1 + n, n]/(n Gamma[n]), n -> ∞]      Actually, the answer is exactly 1/2. Is there any way to coax _Mathematica_ to find the limit?


title: Display truncation of numerical values when writing to a file

text: I am trying to copy some numerical values of parameters from a plain text file into Mathematica, then arranging them in a list and exporting them to another text file, with .ini extension. My problem is that I want the exact same precision for the output file, as the one I have in the input, but Mathematica is truncating the output, no matter what I do. I am aware of this question Annoying display truncation of numerical results, but the methods there are not working for me. This is what I am trying:               a = 70.3029753444001     70.303     bparam = 0.225980870923660     0.225981     paramlist = {aparam, bparam}      This is my exporting function:               exportText[parlist_,      name_] := (outtext = {"a = " <> ToString[parlist[[1]]],     "b = " <> ToString[parlist[[2]]]};     Export["./" <> ToString[name] <> ".ini", outtext, "Text"])      And now I export:               exportText[paramlist, "param1"]      The output in my param1.ini file is of course: a = 70.303   b = 0.225981 I cannot use:               SetOptions[InputNotebook[], PrintPrecision-> 10]      Because I want for each number I copy into Mathematica, the same precision in the output, and all parameters have different precisions. Also using NumberForm as was suggested to me in the other post, ruins my output:               exportText[NumberForm[#, {10, 7}] &@paramlist, "param1"]      The file looks like: a = {70.303, 0.225981}   b = {10, 7} And anyway this is not dynamical, for any number I copy into Mathematica. I tried to create a dynamical function:               setPrecisionOfNumber =      SetPrecision[#, Length[RealDigits[#][[1]]] - RealDigits[#][[2]]] &;      But then this adds extra zeros at the end, for example:               setPrecisionOfNumber@bparam     0.2259808709236600          setPrecisionOfNumber@0.2541     0.2541000000000000      So what is the solution you propose? I have of course tried things like `N[aparam,10]` but it doesn't work. And anyway I need it to be dynamical. I would be grateful for ideas on how to solve this. **EDIT** Using @billisphere solution, I changed my exportText function definition to:               exportText[parlist_,      name_] := (outtext = {"a = " <>      ToString[parlist[[1]], InputForm, NumberMarks -> False],     "b = " <> ToString[parlist[[2]], InputForm]};     stringfile = ExportString[outtext, "Text"];     Export["./" <> ToString[name] <> ".ini", outtext, "Text"])      I still want to understand certain things of number representation. As you can see, if I don't use `NumberMakrs->False`, I get for a number like:               bparam = 0.225980870923660011      The following prints in my file:               FilePrint["./param1.ini"]            a = 70.3029753444001     b = 0.225980870923660011`17.35407167806817      Using `NumberMakrs->False` also for the bparam, I get:               FilePrint["./param1.ini"]     a = 70.3029753444001     b = 0.225980870923660011      I still want to understand why there are still truncations, if I have a number like:               bparam = 0.22598087092366001      The printed file is then:               FilePrint["./param1.ini"]            a = 70.3029753444001     b = 0.22598087092366      So, the 001 at the end of bparam was truncated. If I add another 1 at the end of bparam, I don't get any truncation. I know these numbers are quite large with many decimal digits, and in the praxis I don't need this. But I want to be sure that my output is the same as my input in all cases.


title: Mesh at Ticks positions

text: In a `ListPlot3D[ ]` I want to have the `Mesh` at the same positions as the ticks. For some reason this isn't default if both are chosen `Automatic`. So my question is if there is some function to read (or reproduce) the automatically generated `Ticks` as a list e.g. `xTicksList` and `yTicksList` and than use this like               Mesh-> {xTicksList,yTicksList}      Alternative solutions are of course also welcome. But no solutions with explicite values, this isn't what I want, because finally I want to use this in a more general recipe. Edit: Easy call:               SetDirectory["./"]     data = Import["file.dat"];     ListPlot3D[data, ViewPoint -> {0, -2, 4}]      Data to work on:                    -1.300000000000       0.210526315789       0.980235619886          -1.163157894737       0.210526315789       0.979505821537          -1.026315789474       0.210526315789       1.097953636927          -0.889473684211       0.210526315789       1.102989687180          -0.752631578947       0.210526315789       1.098700823572          -0.615789473684       0.210526315789       1.125990693356          -0.478947368421       0.210526315789       1.211353461701          -0.342105263158       0.210526315789       1.815613507388          -0.205263157895       0.210526315789       1.045807948880          -0.068421052632       0.210526315789       0.000001971641           0.068421052632       0.210526315789       0.000001971641           0.205263157895       0.210526315789       1.045807948880           0.342105263158       0.210526315789       1.815613507388           0.478947368421       0.210526315789       1.211353461701           0.615789473684       0.210526315789       1.125990693356           0.752631578947       0.210526315789       1.098700823572           0.889473684211       0.210526315789       1.102989687180           1.026315789474       0.210526315789       1.097953636927           1.163157894737       0.210526315789       0.979505821537           1.300000000000       0.210526315789       0.980235619886          -1.300000000000       0.421052631579       0.980942994071          -1.163157894737       0.421052631579       0.981933173223          -1.026315789474       0.421052631579       1.103154056150          -0.889473684211       0.421052631579       1.107281088495          -0.752631578947       0.421052631579       1.106941920492          -0.615789473684       0.421052631579       1.146919259544          -0.478947368421       0.421052631579       1.309678535944          -0.342105263158       0.421052631579       0.584224780318          -0.205263157895       0.421052631579       0.700847812228          -0.068421052632       0.421052631579       0.000006770074           0.068421052632       0.421052631579       0.000006770074           0.205263157895       0.421052631579       0.700847812228           0.342105263158       0.421052631579       0.584224780318           0.478947368421       0.421052631579       1.309678535944           0.615789473684       0.421052631579       1.146919259544           0.752631578947       0.421052631579       1.106941920492           0.889473684211       0.421052631579       1.107281088495           1.026315789474       0.421052631579       1.103154056150           1.163157894737       0.421052631579       0.981933173223           1.300000000000       0.421052631579       0.980942994071          -1.300000000000       0.631578947368       0.982279600261          -1.163157894737       0.631578947368       0.986279051512          -1.026315789474       0.631578947368       1.111702792051          -0.889473684211       0.631578947368       1.114982129224          -0.752631578947       0.631578947368       1.122873224846          -0.615789473684       0.631578947368       1.194737734850          -0.478947368421       0.631578947368       1.930464394003          -0.342105263158       0.631578947368       0.560661235292          -0.205263157895       0.631578947368       0.615345975499          -0.068421052632       0.631578947368       0.964754106066           0.068421052632       0.631578947368       0.964754106066           0.205263157895       0.631578947368       0.615345975499           0.342105263158       0.631578947368       0.560661235292           0.478947368421       0.631578947368       1.930464394003           0.615789473684       0.631578947368       1.194737734850           0.752631578947       0.631578947368       1.122873224846           0.889473684211       0.631578947368       1.114982129224           1.026315789474       0.631578947368       1.111702792051           1.163157894737       0.631578947368       0.986279051512           1.300000000000       0.631578947368       0.982279600261          -1.300000000000       0.842105263158       0.984506863561          -1.163157894737       0.842105263158       0.993017144639          -1.026315789474       0.842105263158       1.123329136135          -0.889473684211       0.842105263158       1.127086080172          -0.752631578947       0.842105263158       1.151323601756          -0.615789473684       0.842105263158       1.316936571158          -0.478947368421       0.842105263158       0.533092973179          -0.342105263158       0.842105263158       0.546076002707          -0.205263157895       0.842105263158       0.576957097781          -0.068421052632       0.842105263158       0.684846595150           0.068421052632       0.842105263158       0.684846595150           0.205263157895       0.842105263158       0.576957097781           0.342105263158       0.842105263158       0.546076002707           0.478947368421       0.842105263158       0.533092973179           0.615789473684       0.842105263158       1.316936571158           0.752631578947       0.842105263158       1.151323601756           0.889473684211       0.842105263158       1.127086080172           1.026315789474       0.842105263158       1.123329136135           1.163157894737       0.842105263158       0.993017144639           1.300000000000       0.842105263158       0.984506863561          -1.300000000000       1.052631578947       0.988041894481          -1.163157894737       1.052631578947       1.002844293634          -1.026315789474       1.052631578947       1.137460222080          -0.889473684211       1.052631578947       1.145431494008          -0.752631578947       1.052631578947       1.204639094902          -0.615789473684       1.052631578947       2.034283267433          -0.478947368421       1.052631578947       0.527426104920          -0.342105263158       1.052631578947       0.536322515501          -0.205263157895       1.052631578947       0.555643903601          -0.068421052632       1.052631578947       1.542776620591           0.068421052632       1.052631578947       1.542776620591           0.205263157895       1.052631578947       0.555643903601           0.342105263158       1.052631578947       0.536322515501           0.478947368421       1.052631578947       0.527426104920           0.615789473684       1.052631578947       2.034283267433           0.752631578947       1.052631578947       1.204639094902           0.889473684211       1.052631578947       1.145431494008           1.026315789474       1.052631578947       1.137460222080           1.163157894737       1.052631578947       1.002844293634           1.300000000000       1.052631578947       0.988041894481          -1.300000000000       1.263157894737       0.993507698008          -1.163157894737       1.263157894737       1.016663871059          -1.026315789474       1.263157894737       1.153029591526          -0.889473684211       1.263157894737       1.173527252601          -0.752631578947       1.263157894737       1.324259264609          -0.615789473684       1.263157894737       0.520310839569          -0.478947368421       1.263157894737       0.523127565540          -0.342105263158       1.263157894737       0.529437718570          -0.205263157895       1.263157894737       0.542365083073          -0.068421052632       1.263157894737       1.251779214963           0.068421052632       1.263157894737       1.251779214963           0.205263157895       1.263157894737       0.542365083073           0.342105263158       1.263157894737       0.529437718570           0.478947368421       1.263157894737       0.523127565540           0.615789473684       1.263157894737       0.520310839569           0.752631578947       1.263157894737       1.324259264609           0.889473684211       1.263157894737       1.173527252601           1.026315789474       1.263157894737       1.153029591526           1.163157894737       1.263157894737       1.016663871059           1.300000000000       1.263157894737       0.993507698008          -1.300000000000       1.473684210526       1.001780955507          -1.163157894737       1.473684210526       1.035419641030          -1.026315789474       1.473684210526       1.168300600319          -0.889473684211       1.473684210526       1.218742366781          -0.752631578947       1.473684210526       1.820497914358          -0.615789473684       1.473684210526       0.517801652652          -0.478947368421       1.473684210526       0.519782526335          -0.342105263158       1.473684210526       0.524378305806          -0.205263157895       1.473684210526       1.497512379500          -0.068421052632       1.473684210526       1.158442502764           0.068421052632       1.473684210526       1.158442502764           0.205263157895       1.473684210526       1.497512379500           0.342105263158       1.473684210526       0.524378305806           0.478947368421       1.473684210526       0.519782526335           0.615789473684       1.473684210526       0.517801652652           0.752631578947       1.473684210526       1.820497914358           0.889473684211       1.473684210526       1.218742366781           1.026315789474       1.473684210526       1.168300600319           1.163157894737       1.473684210526       1.035419641030           1.300000000000       1.473684210526       1.001780955507          -1.300000000000       1.684210526316       1.013974303940          -1.163157894737       1.684210526316       1.059492763356          -1.026315789474       1.684210526316       1.180869891090          -0.889473684211       1.684210526316       1.299514133592          -0.752631578947       1.684210526316       0.516453133533          -0.615789473684       1.684210526316       0.515737848476          -0.478947368421       1.684210526316       0.517124685004          -0.342105263158       1.684210526316       0.520545139810          -0.205263157895       1.684210526316       1.214149849511          -0.068421052632       1.684210526316       1.111669990419           0.068421052632       1.684210526316       1.111669990419           0.205263157895       1.684210526316       1.214149849511           0.342105263158       1.684210526316       0.520545139810           0.478947368421       1.684210526316       0.517124685004           0.615789473684       1.684210526316       0.515737848476           0.752631578947       1.684210526316       0.516453133533           0.889473684211       1.684210526316       1.299514133592           1.026315789474       1.684210526316       1.180869891090           1.163157894737       1.684210526316       1.059492763356           1.300000000000       1.684210526316       1.013974303940          -1.300000000000       1.894736842105       1.031151313623          -1.163157894737       1.894736842105       1.087145840815          -1.026315789474       1.894736842105       1.188079272660          -0.889473684211       1.894736842105       1.480552497483          -0.752631578947       1.894736842105       0.514891129597          -0.615789473684       1.894736842105       0.514017825943          -0.478947368421       1.894736842105       0.514975893386          -0.342105263158       1.894736842105       1.653213278836          -0.205263157895       1.894736842105       1.132316352893          -0.068421052632       1.894736842105       1.083852929370           0.068421052632       1.894736842105       1.083852929370           0.205263157895       1.894736842105       1.132316352893           0.342105263158       1.894736842105       1.653213278836           0.478947368421       1.894736842105       0.514975893386           0.615789473684       1.894736842105       0.514017825943           0.752631578947       1.894736842105       0.514891129597           0.889473684211       1.894736842105       1.480552497483           1.026315789474       1.894736842105       1.188079272660           1.163157894737       1.894736842105       1.087145840815           1.300000000000       1.894736842105       1.031151313623          -1.300000000000       2.105263157895       1.053263797252          -1.163157894737       2.105263157895       1.112054099666          -1.026315789474       2.105263157895       1.187887756512          -0.889473684211       2.105263157895       2.414939312234          -0.752631578947       2.105263157895       0.513547775105          -0.615789473684       2.105263157895       0.512568414028          -0.478947368421       2.105263157895       0.513214034428          -0.342105263158       2.105263157895       1.234630789787          -0.205263157895       2.105263157895       1.093026423469          -0.068421052632       2.105263157895       1.065649778360           0.068421052632       2.105263157895       1.065649778360           0.205263157895       2.105263157895       1.093026423469           0.342105263158       2.105263157895       1.234630789787           0.478947368421       2.105263157895       0.513214034428           0.615789473684       2.105263157895       0.512568414028           0.752631578947       2.105263157895       0.513547775105           0.889473684211       2.105263157895       2.414939312234           1.026315789474       2.105263157895       1.187887756512           1.163157894737       2.105263157895       1.112054099666           1.300000000000       2.105263157895       1.053263797252          -1.300000000000       2.315789473684       1.076657703675          -1.163157894737       2.315789473684       1.123492475408          -1.026315789474       2.315789473684       1.179776702031          -0.889473684211       2.315789473684       0.517636004512          -0.752631578947       2.315789473684       0.512380796022          -0.615789473684       2.315789473684       0.511335258693          -0.478947368421       2.315789473684       0.519172187319          -0.342105263158       2.315789473684       1.138037117826          -0.205263157895       2.315789473684       1.070113678169          -0.068421052632       2.315789473684       1.052968436145           0.068421052632       2.315789473684       1.052968436145           0.205263157895       2.315789473684       1.070113678169           0.342105263158       2.315789473684       1.138037117826           0.478947368421       2.315789473684       0.519172187319           0.615789473684       2.315789473684       0.511335258693           0.752631578947       2.315789473684       0.512380796022           0.889473684211       2.315789473684       0.517636004512           1.026315789474       2.315789473684       1.179776702031           1.163157894737       2.315789473684       1.123492475408           1.300000000000       2.315789473684       1.076657703675          -1.300000000000       2.526315789474       1.091865153557          -1.163157894737       2.526315789474       1.114876898745          -1.026315789474       2.526315789474       1.164983245160          -0.889473684211       2.526315789474       0.516400089510          -0.752631578947       2.526315789474       0.511360095534          -0.615789473684       2.526315789474       0.510277474936          -0.478947368421       2.526315789474       1.335414688817          -0.342105263158       2.526315789474       1.094672456667          -0.205263157895       2.526315789474       1.055241265973          -0.068421052632       2.526315789474       1.043728713057           0.068421052632       2.526315789474       1.043728713057           0.205263157895       2.526315789474       1.055241265973           0.342105263158       2.526315789474       1.094672456667           0.478947368421       2.526315789474       1.335414688817           0.615789473684       2.526315789474       0.510277474936           0.752631578947       2.526315789474       0.511360095534           0.889473684211       2.526315789474       0.516400089510           1.026315789474       2.526315789474       1.164983245160           1.163157894737       2.526315789474       1.114876898745           1.300000000000       2.526315789474       1.091865153557          -1.300000000000       2.736842105263       1.089274605713          -1.163157894737       2.736842105263       1.091729061725          -1.026315789474       2.736842105263       1.145851846320          -0.889473684211       2.736842105263       0.515298422848          -0.752631578947       2.736842105263       0.510461989727          -0.615789473684       2.736842105263       0.509366151457          -0.478947368421       2.736842105263       1.174696797334          -0.342105263158       2.736842105263       1.070314416559          -0.205263157895       2.736842105263       1.044899739158          -0.068421052632       2.736842105263       1.036763511509           0.068421052632       2.736842105263       1.036763511509           0.205263157895       2.736842105263       1.044899739158           0.342105263158       2.736842105263       1.070314416559           0.478947368421       2.736842105263       1.174696797334           0.615789473684       2.736842105263       0.509366151457           0.752631578947       2.736842105263       0.510461989727           0.889473684211       2.736842105263       0.515298422848           1.026315789474       2.736842105263       1.145851846320           1.163157894737       2.736842105263       1.091729061725           1.300000000000       2.736842105263       1.089274605713          -1.300000000000       2.947368421053       1.070982617491          -1.163157894737       2.947368421053       1.064870984592          -1.026315789474       2.947368421053       1.124857239675          -0.889473684211       2.947368421053       0.514306616086          -0.752631578947       2.947368421053       0.509667542587          -0.615789473684       2.947368421053       2.571106436571          -0.478947368421       2.947368421053       1.113772367051          -0.342105263158       2.947368421053       1.054892518975          -0.205263157895       2.947368421053       1.037352203431          -0.068421052632       2.947368421053       1.031369828620           0.068421052632       2.947368421053       1.031369828620           0.205263157895       2.947368421053       1.037352203431           0.342105263158       2.947368421053       1.054892518975           0.478947368421       2.947368421053       1.113772367051           0.615789473684       2.947368421053       2.571106436571           0.752631578947       2.947368421053       0.509667542587           0.889473684211       2.947368421053       0.514306616086           1.026315789474       2.947368421053       1.124857239675           1.163157894737       2.947368421053       1.064870984592           1.300000000000       2.947368421053       1.070982617491          -1.300000000000       3.157894736842       1.047866508842          -1.163157894737       3.157894736842       1.041164829929          -1.026315789474       3.157894736842       1.103940126372          -0.889473684211       3.157894736842       0.513409767406          -0.752631578947       3.157894736842       0.508961575187          -0.615789473684       3.157894736842       1.326407622207          -0.478947368421       3.157894736842       1.082011967173          -0.342105263158       3.157894736842       1.044357195862          -0.205263157895       3.157894736842       1.031641411387          -0.068421052632       3.157894736842       1.027100715053           0.068421052632       3.157894736842       1.027100715053           0.205263157895       3.157894736842       1.031641411387           0.342105263158       3.157894736842       1.044357195862           0.478947368421       3.157894736842       1.082011967173           0.615789473684       3.157894736842       1.326407622207           0.752631578947       3.157894736842       0.508961575187           0.889473684211       3.157894736842       0.513409767406           1.026315789474       3.157894736842       1.103940126372           1.163157894737       3.157894736842       1.041164829929           1.300000000000       3.157894736842       1.047866508842          -1.300000000000       3.368421052632       1.027707541691          -1.163157894737       3.368421052632       1.022670717601          -1.026315789474       3.368421052632       1.084322269326          -0.889473684211       3.368421052632       0.512595867665          -0.752631578947       3.368421052632       0.508332439171          -0.615789473684       3.368421052632       1.179765630236          -0.478947368421       3.368421052632       1.062774142729          -0.342105263158       3.368421052632       1.036767743753          -0.205263157895       3.368421052632       1.027197425050          -0.068421052632       3.368421052632       1.023659622763           0.068421052632       3.368421052632       1.023659622763           0.205263157895       3.368421052632       1.027197425050           0.342105263158       3.368421052632       1.036767743753           0.478947368421       3.368421052632       1.062774142729           0.615789473684       3.368421052632       1.179765630236           0.752631578947       3.368421052632       0.508332439171           0.889473684211       3.368421052632       0.512595867665           1.026315789474       3.368421052632       1.084322269326           1.163157894737       3.368421052632       1.022670717601           1.300000000000       3.368421052632       1.027707541691          -1.300000000000       3.578947368421       1.012740556267          -1.163157894737       3.578947368421       1.009098441749          -1.026315789474       3.578947368421       1.066618101119          -0.889473684211       3.578947368421       0.511854868108          -0.752631578947       3.578947368421       0.507778141612          -0.615789473684       3.578947368421       1.119870247076          -0.478947368421       3.578947368421       1.050022506614          -0.342105263158       3.578947368421       1.031080838687          -0.205263157895       3.578947368421       1.023660489456          -0.068421052632       3.578947368421       1.020842841204           0.068421052632       3.578947368421       1.020842841204           0.205263157895       3.578947368421       1.023660489456           0.342105263158       3.578947368421       1.031080838687           0.478947368421       3.578947368421       1.050022506614           0.615789473684       3.578947368421       1.119870247076           0.752631578947       3.578947368421       0.507778141612           0.889473684211       3.578947368421       0.511854868108           1.026315789474       3.578947368421       1.066618101119           1.163157894737       3.578947368421       1.009098441749           1.300000000000       3.578947368421       1.012740556267          -1.300000000000       3.789473684211       1.002490308916          -1.163157894737       3.789473684211       0.999480129131          -1.026315789474       3.789473684211       1.051031597371          -0.889473684211       3.789473684211       0.511178259186          -0.752631578947       3.789473684211       2.115303346236          -0.615789473684       3.789473684211       1.087590009962          -0.478947368421       3.789473684211       1.041038314858          -0.342105263158       3.789473684211       1.026687653195          -0.205263157895       3.789473684211       1.020792862745          -0.068421052632       3.789473684211       1.018506330614           0.068421052632       3.789473684211       1.018506330614           0.205263157895       3.789473684211       1.020792862745           0.342105263158       3.789473684211       1.026687653195           0.478947368421       3.789473684211       1.041038314858           0.615789473684       3.789473684211       1.087590009962           0.752631578947       3.789473684211       2.115303346236           0.889473684211       3.789473684211       0.511178259186           1.026315789474       3.789473684211       1.051031597371           1.163157894737       3.789473684211       0.999480129131           1.300000000000       3.789473684211       1.002490308916          -1.300000000000       4.000000000000       0.995814193962          -1.163157894737       4.000000000000       0.992838080577          -1.026315789474       4.000000000000       1.037528228234          -0.889473684211       4.000000000000       0.510558796548          -0.752631578947       4.000000000000       1.344611311368          -0.615789473684       4.000000000000       1.067648040164          -0.478947368421       4.000000000000       1.034420877924          -0.342105263158       4.000000000000       1.023210238365          -0.205263157895       4.000000000000       1.018431506605          -0.068421052632       4.000000000000       1.016545718957           0.068421052632       4.000000000000       1.016545718957           0.205263157895       4.000000000000       1.018431506605           0.342105263158       4.000000000000       1.023210238365           0.478947368421       4.000000000000       1.034420877924           0.615789473684       4.000000000000       1.067648040164           0.752631578947       4.000000000000       1.344611311368           0.889473684211       4.000000000000       0.510558796548           1.026315789474       4.000000000000       1.037528228234           1.163157894737       4.000000000000       0.992838080577           1.300000000000       4.000000000000       0.995814193962


title: How can I export aligned equations to $\LaTeX$?

text: Using Palettes -> Writing Assistant -> Math Cells, you can enter aligned equations such as:               Cell[TextData[Cell[BoxData[      FormBox[GridBox[{         {GridBox[{            {             RowBox[{              RowBox[{"f", "(", "x", ")"}], "=",               RowBox[{"expr", " ", "1"}]}]},            {             RowBox[{"=",               RowBox[{"expr", " ", "2"}]}]},            {             RowBox[{"=",               RowBox[{"expr", " ", "3"}]}]}           },           GridBoxAlignment->{"Columns" -> {{"="}}}]}        },        GridBoxItemSize->{"Columns" -> {{             Scaled[0.96]}}}], TraditionalForm]]]], "Text"]      But saving as $\LaTeX$ yields equations that are unaligned and uncentered! ![sample](http://i.stack.imgur.com/KLqH6.png) I'm looking for a `SaveAsLatex` function that would correctly export _human readable_ code for the following things:   1. (marker) Aligned Equations   2. Hyperlinks (refs, labels, etc...)   3. ItemNumbered cells   4. Centered math cells   5. Numbered and captioned tables/figures Here is a sample notebook to test your code.


title: How to get 2D graphics into 3D without background?

text: Consider the following code:               g=Graphics[{EdgeForm[{Black, Thick}],                 {Green,Opacity[0.5],Rectangle[{0,0.5},{1,1}]},                 Red, Polygon[{{0, 0}, {1, 0}, {1/2, Sqrt[3]/2}}],                 White, Disk[{1/2, 1/(2Sqrt[3])}, 1/(2Sqrt[3])]},                Background->None];     Graphics3D[{{Texture[g],                  Polygon[{{0,0,0},{0,1,0},{1,1,0},{1,0,0}},                          VertexTextureCoordinates->{{0,0},{1,0},{1,1},{0,1}}]},                 {Texture[g],                  Polygon[{{0,0,1},{0,1,1},{1,1,1},{1,0,1}},                          VertexTextureCoordinates->{{0,0},{1,0},{1,1},{0,1}}]}},                Lighting->{{"Ambient", White}},                ViewPoint->{1,4,7}]      This gives the following graphics: ![Mathematica graphics](http://i.stack.imgur.com/EObbv.png) As you can easily see, the part outside of the figures is opaque white, despite of the `Background->None` option. Also `Background->RGBColor[1,1,1,0]` didn't help, nor did passing the Graphics through `Rasterize` with the option `Background->None` Here's roughly what I'd want to get (any inaccuracies are caused by my lacking GIMP-fu :-)): ![What I would want it to look like](http://i.stack.imgur.com/s8HwY.png) Looking for a solution I found this code but couldn't get it work for my case. Also, if I understand it correctly, it doesn't derive the transparency from the graphics but just replaces a certain colour with fully transparent, which wouldn't work with the semi-transparent green rectangle. Combining the 2D graphics with another one using `Show` does respect `Background->None` and `Opacity` on the green rectangle, so it's not a problem with the graphics itself. Therefore my question: Is it possible to embed 2D graphics into 3D while keeping the transparency of the 2D image, and if so, how?


title: Overlapping Red and Green ArrayPlots to show yellow intersections

text: Let's say I have two `ArrayPlot[]`s. One is in redscale and the other is in greenscale, such that the lowest value is white and the highest value is pure red or green. How do I overlap the two `ArrayPlot[]`s such that intersections are a combination of red and green to give a yellow intensity dependent on the "red" and "green" values? **Edit** I understand that maybe the question is not so clear. I got my idea from a common technique in biology where red fluorescent and green fluorescent signals are captured separately, then merged together.   Areas of red and green together become yellow, but regions of red only or green only are just those colors in the merged image. I am aiming to translate this to data arranged in arrays such that the final merged image will show areas of red and green "signals" as yellow and red/green alone is still red/green alone. Example:   ![enter image description here](http://i.stack.imgur.com/DqbaY.png)


title: Nonlinear recurrence relation

text: I entered the following recurrence relation into RSolve and it just gave the question back to me. $$a_{n+1} = \frac{(1+a_n +(a_{n−1})^3)} 3$$ Is there another way to get a formula for the nth term?


title: Display Matrix of values with position

text: I want to find the table of values of $x^2 + y^2$ in steps of 1, from $0$ to $5$ for $x$ and $y$, together with the position $(x,y)$: something like this:![enter image description here](http://i.stack.imgur.com/N0zcF.png) I can only display the $x^2 + y^2$ value but not the position..               Table[x^2 + y^2, {x, 0, 4, 1}, {y, 0, 4, 1}] // MatrixForm


title: Decimal output from a simple equation

text: Let               x= 0.0000000000000000036;          y = 1 - x      If i type this in Mathematica the answer of `y` is 1. I want the answer to be as it is 0.9999999999999999964


title: Getting Arg[z] to go from $0$ to $2\pi$

text: I'm defining branch cut functions, and I'm using $arg(z)$ as a building block. So I just spent an hour at the whiteboard assuming that $arg(z)$ goes from $0$ to $2\pi$, and then I implement the code, and everything goes horribly wrong. I just realized that the problem is that the the `Arg` function built into _Mathematica_ goes from $-\pi$ to $\pi$. Is there anyway I can redefine `Arg` so that my code will work?


title: Variant of the cutting-stock problem in Mathematica

text: I'm pretty new to _Mathematica_ and am trying to learn to solve problems in a functional way. The problem I was solving was to list the ways in which I could sum elements from a list (with repetitions), so the sum is less-than-or- equal to some value. The code below solves my problem just fine.               i = {7.25, 7.75, 15, 19, 22};     m = 22;     getSum[l_List, n_List] := Total[Thread[{l, n}] /. {x_, y_} -> x y];     t = Prepend[Map[Range[0, Floor[m/#]] &, i], List];     Outer @@ %;     Flatten[%, ArrayDepth[%] - 2];     Map[{#, getSum[i, #]} &, %];     DeleteCases[%, {_, x_} /; x > m || x == 0];     TableForm[Flatten /@ SortBy[%, Last], 0, TableHeadings -> {None, Append[i, "Total"]}]      However, the code checks a lot of unneccesary cases, which could be a problem if `m` is bigger or the list is longer. My question is simply: what would be the most _Mathematica_ -esque way to solve this problem with regard to both efficiency and code elegance.


title: Intersecting/Overlapping Image Elements Counts?

text: I have what I believe should be a relatively easy problem to solve that I have not been able to find an elegant solution for. I need to compare two binary 2D images and count if any of the elements from either image intersect/overlap with the other.   1. I would like to count how many blobs intersect with quadrilaterals. A blob may intersect with multiple quadrilaterals and each intersection would count, but multiple intersections within the same quadrilateral by the same blob, only count once.   2. I would like to count the number of quadrilaterals not intersecting with any blobs.   3. I would like to count the number of blobs not intersecting with any quadrilaterals. These are the images ![Quadrilaterals](http://i.stack.imgur.com/kR71u.png) ![Blobs](http://i.stack.imgur.com/ppyhb.png) I created bounding boxes based on blob images with the following:                   CreatePolygon[image_] :=          Module[{BinarizedImage, BoundaryBoxesCoords, Polygons, size},     size = ImageDimensions[image];     BinarizedImage = Binarize[image];     BoundaryBoxesCoords =      Last /@ ComponentMeasurements[     MorphologicalComponents[BinarizedImage], "MinimalBoundingBox"];     Polygons =      Graphics[{Red, Polygon /@ BoundaryBoxesCoords}, ImageSize -> size,      PlotRange -> {{0, First@size}, {0, Last@size}}]]      I tried doing a count of image items by overlapping the elements and counting objects consisting of amalgamated colors, but this doesn't help with conditions where blobs intersect the same quadrilateral multiple times. Using the inverse is also not helpful in solving the other two problems as I had hoped.               CreateHits[QuadImage_, BlobImage_] :=      Module[{CompositeImage, GrayThreshold, Hits},     CompositeImage =      ColorConvert[     ImageCompose[Binarize[BlobImage], {QuadImage, .5}],      "Grayscale"];     GrayThreshold = {.6, .8};     Hits =      First@Last@     ComponentMeasurements[       MorphologicalComponents[        Binarize[CompositeImage, GrayThreshold]], "Count"]]          CreateHits[Image1, Image2]      I don't think the ideal solution lies with the approach I've tried, however, which is a visual solution. What I'd like is to extract the coordinates for each blob and each quadrilateral area and just compare these object lists to determine overlaps. E.g., Blob 3 shares coordinates with Quadrilaterals 2 & 4\. I can't figure out, however, how to use the output of MorphologicalComponents to find this information to retrieve the coordinates for each object or to store each cluster as a separate item. This is bothersome because MorphologicalComponents has clearly identified those things. I could brute force the code and create separate images for each blob and/or quadrilateral and do the comparison computation that way, but besides being much more computationally expensive it is, as I said, not particularly elegant.


title: Workbench fails to run on OSX. Reports "Front end could not be launched."

text: I've just installed Workbench 2.0 and I am trying to use it with Mathematica 10. Following the examples in the help I created the sample Test project. When I hit run it does the following.   * Spawns a new Mathematica app.    * Opens a blank notebook.    * Workbench sits on 19% for about a minute.  After that I get the following error message. ![The Mathematica Notebook front end could not be launched.](http://i.stack.imgur.com/CGbK5.png) I have reinstalled Mathematica + Workbench from scratch but still the same. Also the blank notebook spawned is not in the `Directory[]` for the code. So that's a bit pointless. * * * As a workaround I have Mathematica launched and I've manually SetDirectory[] to my project, but it just seems a bit annoying I can't just work out of the workbench.


title: Matrix Determinant

text: I have an N by N (N>3) matrix generated from fortran. I would like to find determinant of that matrix using mathematica? I could do this for a 3 by 3 matrix. I can also import the fortran output file to mathematica but how to write down the data in the prescribed format : Det[{{a1, a2, a3}, {a4, a5, a6}, {a7, a8, a9}}] for large N? Writing the data one by one is a tedious job.Kindly help. fortran output of a 5 by 5 matrix:               row1(0.600336   -0.169615    0.054516   -0.003712   -0.038923)     row2(0.637602    0.363638   -0.069266    0.006823    0.035388)     row3(-0.032774    0.876752    0.226435   -0.020353   -0.017496)     row4(-0.024340   -0.144815    0.950590    0.182733   -0.007234)     row5(0.024211    0.030092   -0.161703    0.966905    0.173151)


title: Creating a 2D meshing algorithm in Mathematica

text: As what is proving to be a difficult, but entertaining task, I am attempting to adapt a 2D meshing algorithm created for MATLAB and port it to Mathematica. I understand meshing functions already exist in Mathematica so this is purely for fun/learning. The paper here describes in great detail the algorithm created for MATLAB, in terms of the non code specific logic and each step of the code. I intend to modify this question as/if suggestions are made to show its progress. To start off simple, I have a box that I'm creating a random selection of meshing points within. I modify these using Delaunay's Triangulation Algorithm and then create an initial triangular mesh. Next, imagining all these points are joined my 'magic springs', if the length, L, of a spring is less than a certain chosen scale length, L0, then it exerts a force on each joining point in the direction of increasing separation, proportional to L-L0. Thus you create a new set of points at a later artificial timestep due to the effect of these psuedoforces. Then if any points are outside of the original box, you drag 'em back in and repeat this process until some sort of equilibrium condition is met. This is the code I've done so far:               SeedRandom[2];     bboxL = 10;     bboxH = 10;     Nnodes = 100;     p0 = Table[0, {i, Nnodes}, {i, 2}];     Do[       p0[[i, 1]] = RandomReal[{0, bboxL}];       p0[[i, 2]] = RandomReal[{0, bboxH}];       , {i, Nnodes}];          timeStep = 0.2;          Needs["ComputationalGeometry`"];     dt = DelaunayTriangulation[p0];     toPairs[{m_, ns_List}] := Map[{m, #} &, ns];     edges = Flatten[Map[toPairs, dt], 1];     Graphics[GraphicsComplex[       p0, {Line[edges], Red, PointSize[Medium], Point[p0]}]]          L0 = 1;     displacement[{m_, ns_List}] :=        Total[Map[         If[Norm[p0[[#, All]] - p0[[m, All]]] <             bboxL*bboxH/Nnodes, -p0[[#, All]] + p0[[m, All]], {0, 0}] &,          ns]];          Do[       p0 = p0 + timeStep*Map[displacement, dt];       Do[        p0[[i, 1]] = Max[p0[[i, 1]], 0];        p0[[i, 2]] = Max[p0[[i, 2]], 0];        p0[[i, 1]] = Min[p0[[i, 1]], bboxL];        p0[[i, 2]] = Min[p0[[i, 2]], bboxH];        , {i, Nnodes}];       dt = DelaunayTriangulation[p0];       edges = Flatten[Map[toPairs, dt], 1];            , {i, 400}];          Graphics[GraphicsComplex[       p0, {Line[edges], Red, PointSize[Medium], Point[p0]}]]       You start off with this mesh: ![](http://i.stack.imgur.com/szgd0.png) Then after some iterations you get: ![](http://i.stack.imgur.com/xhuvg.png) What I'd like to do next is instead of meshing to a boring old square I'd like to be able to mesh to any geometry whether its given in a functional form or an array of points. Can anybody suggest how to proceed? Maybe just a simple circle would be a nice next step for practice? Everyone feel free to edit my post and join in the fun. Many thanks for any help :) Also many thanks go to MarkMcClure for helping me on getting to this stage!


title: Normal Plot (visual test for normality)

text: I wish to construct a Normal Plot to visually test for normality of data. My data is: > {188,199,171,200,219,172,235,194,234,206} And needs to be plotted to look something like this: ![enter image description here](http://i.stack.imgur.com/BOPxa.jpg) Whereby the data points are sorted from low to high and then plotted against the mid-point of their probability bins. So, in this case there are 10 data points so 10 bins with mid points of 5%, 15%, 25% etc. For this data, you would then see the lowest value (171) plotted at (171,5%), the next value (172) plotted at (172,15%) and so on. Any ideas where I can find the answers?


title: How to make InputTable

text: There is InputField in mma but how to make InputTable? In MathCAD it`s possible to insert Excel spreadsheet with input and output variables.Input variables I use for filling of header row and column and output variable for output. How to make the same functionality in mma? Thanks in advance


title: Difference between Directory[] and NotebookDirectory[] .. a trailing /?

text: The following was the code:               Directory[]     NotebookDirectory[]      The output was               "/media/Dataholder/final"          "/media/Dataholder/final/"      In the second case, there is a trailing **"/"** (I am on Mathematica 8 on Ubuntu) Just curious, why is there a difference ? Is is specific to my machine ? I found this when this was breaking the code, wherein I wanted to change the working directory to another one relative to the current directory, i.e. using               simFldr = Directory[] <> "anotherSubDirectory"      Though this sounds trivial, the patchwork needed to get to that directory will be non trivial since I have a code which must work **both on Windows and Unix**. Any _smart_ solution to set the directory to a subdirectory ?


title: How to apply RootLocusPlot corectly

text: I have to analyze the complex regions of variable c which is define obtained with `InverseLaplace` help in the form               Re[c] + Im[c] == -10 s^2 - (1/(2 Pi)     NIntegrate[1/Q[k, s], {k, -∞, ∞}])^-1;          Q[k_, s_] := 5 k^4 - 3 (-k 2 + s)^2;      I applied the `RootLocusPlot` on this polynomial, but I am not sure what I got. Is this complex plane of `c` variable? I need to see what will happen with `c` when `s` goes to $∞$ or $0$, but in my figure I can not understand that? Is there another command to plot diagram depends on complex solutions?               RootLocusPlot[       TransferFunctionModel[Unevaluated[{{-10 s^2 - 5 k^4 - 3 (-k 2 + s)^2}}],                              s, SamplingPeriod ->None, SystemsModelLabels -> None],        {k, 0, 0.8}]      ![enter image description here](http://i.stack.imgur.com/9Rd5J.png)


title: Making a calculation with high precision

text: I would like to make the following calculation:               1/Sqrt[1 - (150^2 10^(-4))/(9 10^16.)] - 1      _Mathematica_ 8 returns 0. The result is obviously not 0, but my calculation must be losing precision. How can I compute this value with sufficient precision?


title: Collatz Tool Box --- any speed ups possible?

text: I have created a tool box for experimenting with the Collatz conjecture. Info here: Wolfram MathWorld and here: Wikipedia The patterns I have found allow us to make the conjecture jump through some hoops. **Final Edit** `countOrbit` has been re-cast as a `Do Until` loop because the logic behaves similar to a one-directional linked list and I don't think it can be improved. **Note: the number of sub orbits $\leq$ (total steps) / 6** **Edit for the down-voters:** the current maximum that collatz projects have reached is around $10^{18}$. The example below has two numbers $10^{301030}$ and $10^{477119}$ that my functions can use quickly and accurately. That is many magnitudes greater that what is currently being done. So, why the down- votes? This is one example: m is the count of numbers in an ascending sequence. uniqueRank[1,m] returns the first number of the first unique sub orbit of that length. omegaSubOrbit[x,m] returns the last number of that sub orbit. We display the digit counts of these numbers. Then we count the complete orbit down to 1. This takes a bit over 12 minutes on my AMD 1100T. The left-hand number is the count of multiplies (we don't count divisions by two) and the right-hand count is the number of sub orbits used to get the counts.               m = 1000000; x = uniqueRank[1, m];     y = omegaSubOrbit[x, m];     {IntegerLength[x], IntegerLength[y]}     countOrbit[1, x]      > {301030, 477119}   >  {4805005, 1903828}   >  {13420758, 1903828} 7.8 minutes to count all multiplies and divides My question: Since I'm using `For` and `While` in a few places, is there a way to speed up those functions? Especially, the countOrbit function?               ascendingQ[x_] := 3 == Mod[x, 4]     uniqueQ[x_] := 0 != Mod[2 x - 1, 3]     subOrbit[x_] :=       Block[{y = x},      Flatten[Join[     Table[y \[DirectedEdge] (y = 1/2 (3 y + 1)), {n, 1,        IntegerExponent[x + 1, 2] - 1}], {y \[DirectedEdge] (3 y + 1)/        2^IntegerExponent[3 y + 1, 2]}]]]     createSubOrbitGraph[n_] :=      Block[{j, v = {}},       For[j = 1, j <= n, j++,        If[uniqueQ[2 j + 1], AppendTo[v, subOrbit[2 j + 1]]];        ];       Flatten[v]       ]     uniqueRank[n_, m_] := Block[{a = If[1 != n && OddQ[n], n - 1, n]},        (n + IntegerExponent[a, 2]) 2^m - 1]       nonUniqueRank[n_, m_] := (2 n - 1)   2^m - 1     createOrbit[w_, x_] := Block[{u = subOrbit[x]},       While[w < u[[-1, 2]],         u = Flatten[AppendTo[u, subOrbit[u[[-1, 2]]]]]];        u]     createOrbitGraph[n_] :=      Block[{j, u = {}},       For[j = 1, j <= n, j++,        If[uniqueQ[2 j + 1], u = Union[u, createOrbit[2 j + 1, 2 j + 1]]];        ];       Flatten[u]       ]     omegaSubOrbit[x_, m_] :=       Block[{z = (-1 + (3/2)^m (1 + x))}, 2^(1 - IntegerExponent[2 z, 2]) z]     omegaSubOrbit[x_] :=       Block[{m = IntegerExponent[x + 1, 2], z = (-1 + (3/2)^m (1 + x))},        2^(1 - IntegerExponent[2 z, 2]) z]     countOrbit[w_, x_] :=       Block[{h = x, t, c, d = 0, s = 0, l = 0, m, n, a},       While[True,        m = IntegerExponent[h + 1, 2];        t = -1 + (3/2)^m (1 + h);        n = IntegerExponent[t, 2];        l += m;        d += n;        s += 1;        h = t/2^n;        If[h <= w, Break[]];        ];       c = 2 l + d;       a = If[1 == w, "Full ", "Extended Sub "];       Print["---Counts ", a, "Orbit---",        "\nNumber of Sub Orbits: ", s,        "\nMultiplications by 3: ", l,        "\nDivisions by 2:       ", l,        "\nExtra Divisions by 2: ", d,        "\nTotal for Orbit:      ", c]       ]          Some brief documentation:   **ascendingQ[x]** Returns True if odd x is ascending, False if descending   **uniqueQ[x]** Returns True if odd x is not embedded in any longer sequence   **subOrbit[x]** Returns graph data in the form {Head[DirectedEdge]Tail}   **createSubOrbitGraph[n]** Returns graph data of sub orbits up through n   **uniqueRank[n, m]** Returns the first number of the n-th unique occurance of a sub orbit of size m   **nonUniqueRank[n, m]** Returns the first number of the n-th occurance of a sub orbit of size m, which may not be unique.   **createOrbit[w, x]** Returns graph data for w=1 complete orbit or w=x extended sub orbit   Note: for a graph, both are equivalent. w=x produces fewer duplicates.   **createOrbitGraph[n]** Returns graph data of extended sub orbits up through n   **omegaSubOrbit[x]** Returns the last odd number of a sub orbit. (The one that required multiple divides.)   **omegaSubOrbit[x, m]** Same as above, but uses m to speed up the first step   **countOrbit[w, x]** Returns the count of multiply and division steps and the count of sub orbits processed, for w=1 complete orbit or w=x extended sub orbit **Edit** Replaced countOrbit[w,x] with refined version that counts divisions and multiplication. Reduced the time from 15 minutes to 7.8 minutes for the above example.


title: What type of solver does Mathematica use in LinearSolve

text: I have a question regarding linear equation solvers. For a specific 9x9 diagonal matrix, every method I tried in C++ (Gaus, GCC, BICGTAB ) wouldn't work, although these methods would work fine for different matrices. In Mathematica `LinearSolve` gave a solution for this matrix. So my question is: What type of solver does Mathematica use in `LinearSolve`?


title: Is it possible to import data from Google Analytics?

text: Using _Mathematica_ , is it possible to pull data directly from Google Analytics? Unfortunately, GA exports messy `csv` files, and I was wondering if there was a direct way of receiving this data. A quick Google search has shown that at one point Patrick Collison had devised a way, though perhaps due to copyright or other legal infringements, that knowledge has disappeared off the web. I'm very new to using _Mathematica_ , so any tips would be greatly appreciated. EDIT: As suggested, here is an example of the messy `csv` files:               All Web Site Data     Browser & OS     20130421-20130521               Browser,Visits,Pages / Visit,Avg. Visit Duration,% New Visits,Bounce Rate     Safari,534,4.57,00:03:31,59.36%,44.38%     Safari (in-app),426,5.21,00:02:54,97.65%,34.04%     Chrome,347,5.16,00:05:54,63.11%,28.24%     Internet Explorer,214,6.02,00:08:21,68.69%,20.56%     Android Browser,170,4.84,00:03:49,68.82%,37.65%     Firefox,156,5.44,00:05:02,67.95%,30.77%     IE with Chrome Frame,11,4.36,00:04:07,18.18%,18.18%     Maxthon,3,3.33,00:00:51,66.67%,0.00%     Opera Mini,2,1.00,00:00:00,100.00%,100.00%     BlackBerry,1,1.00,00:00:00,100.00%,100.00%     ,"1,865",5.08,00:04:31,71.31%,34.37%          Day,Visits     4/21/13,41     4/22/13,44     4/23/13,16     4/24/13,92     4/25/13,293     4/26/13,142     4/27/13,25     4/28/13,40     4/29/13,40     4/30/13,67     5/1/13,129     5/2/13,114     5/3/13,32     5/4/13,11     5/5/13,27     5/6/13,136     5/7/13,68     5/8/13,59     5/9/13,123     5/10/13,49     5/11/13,20     5/12/13,40     5/13/13,35     5/14/13,28     5/15/13,36     5/16/13,42     5/17/13,32     5/18/13,31     5/19/13,10     5/20/13,22     5/21/13,21     ,"1,865"


title: financial data behind Wolfram|Alpha and Finance Platform

text: I need to price 23,000 securities from 1999 to 2007, and they are surprisingly hard to find on subscription-based services, like Bloomberg LP, ThomsonReuters or S&P CapitalIQ offerings. Probably because deleted/expired/retired securities are dropped from the databases. Is there a good source on what financial information is available to/via Wolfram products, e.g. how much of my needs would be covered?


title: Forecast Future Stock Prices - Brownian Motion - Again

text: excuse me, I think I have here a technical problem with Mathematica yesterday I posted the question with the title: Forecast Future Stock Prices - Brownian Motion I am still not very experienced but when I copied your code and entered it, it worked perfectly. Today I reopened the Wolfram Finance Platform Quickstart Notebook, and tried to work further in a new notebook. Again it didn’t work. And when I opened the notebook with the code you sent me, and refreshed it, also the one that worked perfectly didn’t work anymore. Could it be that Mathenatica cannot distinguish between the two notebook, although they weren’t open at the same time? Or what could be the problem? Thank you for your help. So the whole code is here:               BrownianMotion[period_, "steps_Integer:" 1000, "init_:" 0] :=       Accumulate[Prepend[RandomVariate[NormalDistribution[0, Sqrt[period⁄steps]], steps], init]]     ListLinePlot[BrownianMotion[1, 1000], AxesLabel \[RightArrow] {"Time", B_t},       PlotLabel \[RightArrow] Style["Stochastic Brownian Motion", Bold]]          BrownianMotionPaths[period_, "steps_Integer:" 1000, paths_Integer,        init_List] /; (Length[init] == paths) ≔Transpose[        Accumulate[Prepend[          RandomVariate[NormalDistribution[0, Sqrt[period/steps]], {steps, paths}], init]]]     brownianPath =       ListLinePlot[BrownianMotionPaths[1, 1000, 50, ConstantArray[0.5, 50]],        AxesLabel \[RightArrow] {"Time", B_t},        PlotLabel \[RightArrow] Style["Stochastic Brownian Motion", Bold]]     GOOGExpRet = Mean[FinancialData["GOOG", "Return", DatePlus[-365], "Value"]]     GOOGPrice = FinancialData["GOOG"]     GOOGVol = FinancialData["GOOG", "Volatility50Day"]          ListLinePlot[      GOOGPrice*(1 + GOOGExpRetConstantArray[1, 251] + BrownianMotion[1, 250]*GOOGVol),       AxesLabel \[RightArrow] {"Time", B_t},       PlotLabel \[RightArrow] Style["Simulated Google Price", Bold]]     ListLinePlot[      GOOGPrice*(1 + GOOGExpRetConstantArray[1, {50, 251}] +          BrownianMotionPaths[1, 250, 50, ConstantArray[0.5, 50]]*GOOGVol),       AxesLabel \[RightArrow] {"Time", "St"},       PlotLabel \[RightArrow] Style["Simulated Google Price", Bold],       ImageSize \[RightArrow] 400]     Mean[(GOOGPrice (1 + GOOGExpRetConstantArray[1, {50, 251}] +             BrownianMotionPaths[1, 250, 50] GOOGVol))[[All, -1]]];          GOOGBMPlot =       Block[{meanGOOGPrice =          Mean[(GOOGPrice (1 + GOOGExpRetConstantArray[1, {50, 251}] +                BrownianMotionPaths[1, 250, 50] GOOGVol))[[All, -1]]]}, "         " simulatedGOOGPaths =         ListLinePlot[         GOOGPrice (1 + GOOGExpRetConstantArray[1, {50, 251}] +             BrownianMotionPaths[1, 250, 50] GOOGVol), AxesLabel \[RightArrow] {"Time", S_t},          PlotLabel \[RightArrow] Style["Simulated Google Prices\n(Brownian Motion)", Bold],          BaseStyle \[RightArrow] style, PlotRange \[RightArrow] {{0, 260}, {0, 1200}},          PlotStyle \[RightArrow] Directive[{Thin, Lighter@Gray}],          Epilog \[RightArrow] {{m8red[1], Point[{250, meanGOOGPrice}]},            Text[Style["Mean\n$" <> ToString[PaddedForm[meanGOOGPrice, {5, 2}]], m8red[1], Bold,              FontFamily \[RightArrow] "Verdana"], {215, meanGOOGPrice}], {m8red[1],             Line[{{245, meanGOOGPrice}, {255, meanGOOGPrice}}]}}]]      Hope you guys can help me. And one more question: how can I copy the mathematica code into a word file without having it in the formulae format? Thanks


title: How can I give graph required data with GUI?

text: Consider that I have the simple graph of               Graph[{"Uppsala" -> "Marsta", "Marsta" -> "Uppsala", "UpplandsVasby" -> "Sollentuna", "Sollentuna" -> "UpplandsVasby",        "UpplandsVasby" -> "Marsta", "Marsta" -> "UpplandsVasby",        "Stockholm" -> "Boo", "Boo" -> "Stockholm",        "Stockholm" -> "Lidingo", "Lidingo" -> "Stockholm",        "Stockholm" -> "Sollentuna", "Sollentuna" -> "Stockholm",        "Stockholm" -> "Taby", "Taby" -> "Stockholm"},       VertexLabels -> "Name"]      I want to add required data of the Graph such as `EdgeWeight, EdgeCapacity` or other required data with GUI. Preferably in Excel interactive data sheet . Could you please somebody help me on that?


title: NDsolve with variable end-point

text: I want to plot the solution a coupled ODEs as a function of the end point only. Mathematica code:               tmax = 5;     rr = 1;     p = 0;     x[r_, t_, p_] = r Cos[(2 \[Pi])/tmax t + p];     z[r_, t_, p_] = r Sin[(2 \[Pi])/tmax t + p];     g[r_, t_,         p_] = ((1 + z[r, t, p]) D[x[r, t, p], t] - (I + x[r, t, p]) D[          z[r, t, p], t])/(2 ((1 + z[r, t, p]^2) + (I + x[r, t, p]^2)));     b[r_, t_] = Sqrt[(1 + I) + r^2] t;     sol1 = NDSolve[{c1'[t] == -g[rr, t, p] Exp[-2 I b[rr, t] ] c2[t],          c2'[t] == g[rr, t, p] Exp[2 I b[rr, t]] c1[t], c1[0] == 1,          c2[0] == 0}, {c1, c2}, {t, 0, tmax}];     sol2 = NDSolve[{c1'[t] == -g[rr, t, p] Exp[-2 I b[rr, t] ] c2[t],          c2'[t] == g[rr, t, p] Exp[2 I b[rr, t]] c1[t], c1[0] == 0,          c2[0] == 1}, {c1, c2}, {t, 0, tmax}];      Then want to repeat this procedure for different `tmax` and plot `LogPlot[Evaluate[{{Abs[c2[t]/c1[t]]} /. sol1, {Abs[c1[t]/c2[t]]} /. sol2}], {t, 0, tmax}, PlotRange -> Full]` Many thanks to the helpers EDIT: In block diagram this is what I want: Given coupled ODEs that are dependent on `tmax` both as the end-point and as a parameter, find the solution for each `tmax`, `c1_tmax[t] c2_tmax[t]` define the functions:               c1[tmax]=c1_tmax[tmax]          c2[tmax]=c2_tmax[tmax]      plot `c2[tmax]/c1[tmax]` for `{tmax,0,20}` Here's what I finally did (I hope it actually does it):               rr = 0.8;     p = 0;     x[r_, t_, p_] = r Cos[(2 \[Pi])/tmax t + p];     z[r_, t_, p_] = r Sin[(2 \[Pi])/tmax t + p];     g[r_, t_,         p_] = ((1 + z[r, t, p]) D[x[r, t, p], t] - (I + x[r, t, p]) D[          z[r, t, p], t])/(2 ((1 + z[r, t, p]^2) + (I + x[r, t, p]^2)));     b[r_, t_] = Sqrt[(1 + I) + r^2] t;     sol1 = ParametricNDSolve[{c1'[           t] == -g[rr, t, p] Exp[-2 I b[rr, t] ] c2[t],          c2'[t] == g[rr, t, p] Exp[2 I b[rr, t]] c1[t], c1[0] == 1,          c2[0] == 0}, {c1, c2}, {t, 0, tmax}, {tmax}];     sol2 = ParametricNDSolve[{c1'[           t] == -g[rr, t, p] Exp[-2 I b[rr, t] ] c2[t],          c2'[t] == g[rr, t, p] Exp[2 I b[rr, t]] c1[t], c1[0] == 0,          c2[0] == 1}, {c1, c2}, {t, 0, tmax}, {tmax}];     LogPlot[Evaluate[{{Abs[c2[tmax][tmax]/c1[tmax][tmax]]} /.          sol1, {Abs[c1[tmax][tmax]/c2[tmax][tmax]]} /. sol2}], {tmax, 0,        20}, PlotRange -> {{0, 20}, {10^-3, 10^3}}]


title: Issue with NDSOlve while solving vector differential equation

text: I am trying to get solution of a vector differential equation               x'[t]= aa*x[s]       where aa is my 9X9 matrix               aa= {       {0, 0, 0, s, 0, 0, 0, 0, 0},       {0, 0, 0, 0, s, 0, 0, 0, 0},       {0, 0, 0, 0, 0, s, 0, 0, 0},       {-s, 0, 0, 0, 0, 0, 0.3, 0, 0},       {0, -s, 0, 0, 0, 0, 0, 0.3, 0},       {0, 0, -s, 0, 0, 0, 0, 0, 0.3},       {0, 0, 0, -0.3, 0, 0, 0, 0, 0},       {0, 0, 0, 0, -0.3, 0, 0, 0, 0},       {0, 0, 0, 0, 0, -0.3, 0, 0, 0}      }      This code               function1 =       NDSolve[{x'[s] == aa*x[s],         x[0] ==  {{1, 0, 0, 0, 1, 0, 0, 0, 1}}}, {x[s]}, {s, 0, 10}]      is giving me this error: > **NDSolve::deqn: "Equation or list of equations expected instead of True in > the first argument {True,True}"** Please help out how to solve this vector DE.


title: Finding all roots of the system of two complex equations

text: I need to find all roots for the system of two complex equations. Obviously I can rewrite them as 4 real however problem remains. I have looked through routines connected with using ContourPlot however in my case they cannot be applied I think. System is:               P1 x +I (A+a Abs[x]^2) x + I S y^2 Conjugate[x] == I F     P2 y +I (B+b Abs[y]^2) y + I S x^2 Conjugate[y] == 0      x,y are unknown variables, P1 , P2 some complex constants A,B,a,b S,F - real constants. However problem remains, do you know an algorithm for finding all roots of 4 equations?


title: Creating a PolyhedronData[] structure for custom polyhedra

text: The `PolyhedronData[]` structure is wonderfully rich. I would like to create data for my own polyhedra, not any of the many that Mathematica provides. Is this possible? I wouldn't need every property, but I would like it to function the same way, e.g., `PolyhedronData["MyPolyhedron", "VertexCoordinates"]` would return a list of vertex coordinates, etc. I can hack up `MyPolyhedronData[]`, but I would prefer to use `PolyhedronData[]` if possible. Thanks for ideas!


title: ParallelTable Works in Regular Notebook but Gives Error When Packaged

text: Consider the following:               grid = Tuples[Range[0, 3.3083, 0.08468], 3];     k = Length[grid]; vdw = {0.15, 0.19, 0.19, 0.195, 0.195};     PeriodicDistance =        Compile[{{x, _Real, 1}, {y, _Real, 2}, {r, _Real}},         Sqrt@Total[((x - y) - 3.3083*Round[(x - y)/3.3083])^2] - r,         CompilationTarget :> "C", RuntimeOptions -> "Speed"];      Now the following function:               Cavs[dat_?MatrixQ] := Module[{pos},       Do[        With[{tr = Transpose[dat[[v ;; -1 ;; 5]]]},         pos[v] =           ParallelTable[           Min[PeriodicDistance[grid[[i]], tr, vdw[[v]]]], {i, k}]         ],        {v, 1, 5}];       pos[2]       ]      with input file               dat = ReadList["filename.ext", {Word, Word} ~ Join ~ Table[Number, {4}]][[All, 4 ;; 6]];          Cavs[dat]      gives ![Mathematica graphics](http://i.stack.imgur.com/s0GPJ.png) This answer is exactly the same answer I get when I replace `ParallelTable` with `Table`. Now, if I include this function in a _Mathematica_ package I get all sorts of `Part Specification` errors. Here's a sample: ![Mathematica graphics](http://i.stack.imgur.com/1975y.png) I know `ParallelTable` is the culprit because if I replace it with `Table` in the package it works fine. I just don't know why it works in a normal _Mathematica_ notebook session but fails when packaged. Any ideas?