title: Importing data to Mathematica

text: I exported the result on `NMinimize` with `.dat` format. The data looks like: ![enter image description here](http://i.stack.imgur.com/IF7nY.png) Then I imported the data using:               Import["data.dat"];      The data in MMA looks like: ![enter image description here](http://i.stack.imgur.com/iLQuM.png) There are two ( **,** ) in the data shown in MMA. Now I cannot use this because when I use:               Mymodel[t] /. data[[2]]      The parameters in `Mymodel` won't take the values in data. How can I import my data properly and use it again? The parameter $\Delta$ after importing changes to nonsense, however in the `dat` file it's fine. My data:               1.1719373597846176e6     Subscript[a, 1, 1] -> -39.07037581001687    Subscript[a, 1, 2] -> 32.839137392575736    Subscript[a, 1, 3] -> 47.04859760352587 Subscript[a, 1, 4] -> 85.54836344280284 Subscript[a, 1, 5] -> 89.3572784605761  Subscript[a, 1, 6] -> 112.72147714256346    Subscript[a, 1, 7] -> 141.1141100113585 Subscript[a, 1, 8] -> 161.5187350434043 Subscript[a, 1, 9] -> 175.7016855109587 Subscript[a, 1, 10] -> 171.55229014876858   Subscript[a, 1, 11] -> 154.25071538099695   Subscript[a, 1, 12] -> 125.05214808916814   Subscript[a, 1, 13] -> 100.80704192706914   Subscript[a, 1, 14] -> 64.08099482728616    Subscript[a, 1, 15] -> 33.038341794617224   Subscript[a, 1, 16] -> 9.569520817024989    Subscript[a, 1, 17] -> -16.266164560069445  Subscript[a, 1, 18] -> -28.891015617003045  Subscript[a, 1, 19] -> -35.31102040498092   Subscript[a, 1, 20] -> -34.82155634465738   Subscript[a, 1, 21] -> -26.40216271585209   Subscript[a, 1, 22] -> -22.137228450492998  Subscript[a, 1, 23] -> -19.939759086275554  Subscript[a, 1, 24] -> -4.529745755046207   Subscript[a, 2, 1] -> -8.262096251341937    Subscript[a, 2, 2] -> 39.93424658310768 Subscript[a, 2, 3] -> 59.17772856664775 Subscript[a, 2, 4] -> 85.11383147323797 Subscript[a, 2, 5] -> 103.73282166425444    Subscript[a, 2, 6] -> 130.11739931821623    Subscript[a, 2, 7] -> 152.23253250732932    Subscript[a, 2, 8] -> 175.64557869749953    Subscript[a, 2, 9] -> 201.14899323338128    Subscript[a, 2, 10] -> 198.63115865573573   Subscript[a, 2, 11] -> 185.72511180756692   Subscript[a, 2, 12] -> 161.4785551644416    Subscript[a, 2, 13] -> 118.62717529408515   Subscript[a, 2, 14] -> 82.79080925592181    Subscript[a, 2, 15] -> 49.50275889248166    Subscript[a, 2, 16] -> 26.751543115232693   Subscript[a, 2, 17] -> -2.903295814163817   Subscript[a, 2, 18] -> -15.706287304199819  Subscript[a, 2, 19] -> -26.95123031552248   Subscript[a, 2, 20] -> -16.55204465607971   Subscript[a, 2, 21] -> -15.63690068567017   Subscript[a, 2, 22] -> -18.445139467068348  Subscript[a, 2, 23] -> -12.659200223485469  Subscript[a, 2, 24] -> -5.962580128189138   Subscript[a, 3, 1] -> 37.444101946418606    Subscript[a, 3, 2] -> 23.21078669192909 Subscript[a, 3, 3] -> 35.80731556592555 Subscript[a, 3, 4] -> 49.50645735462091 Subscript[a, 3, 5] -> 69.65835497466128 Subscript[a, 3, 6] -> 90.05590337876777 Subscript[a, 3, 7] -> 107.54972407429175    Subscript[a, 3, 8] -> 134.58686959015793    Subscript[a, 3, 9] -> 152.62441781305003    Subscript[a, 3, 10] -> 165.1720495385376    Subscript[a, 3, 11] -> 162.84787173284377   Subscript[a, 3, 12] -> 150.95139348142118   Subscript[a, 3, 13] -> 137.0382860491445    Subscript[a, 3, 14] -> 133.65163910616894   Subscript[a, 3, 15] -> 131.81798473114085   Subscript[a, 3, 16] -> 133.75079745491237   Subscript[a, 3, 17] -> 143.23942955668883   Subscript[a, 3, 18] -> 141.56751697722737   Subscript[a, 3, 19] -> 132.28785624168043   Subscript[a, 3, 20] -> 113.36015200529705   Subscript[a, 3, 21] -> 86.37455010294536    Subscript[a, 3, 22] -> 65.42845023832571    Subscript[a, 3, 23] -> 46.312675399941256   Subscript[a, 3, 24] -> 27.932761709617406   Subscript[μ, 1] -> 69.64797135105368    Subscript[μ, 2] -> 137.44079092106227   Subscript[μ, 3] -> 137.16460450848953   Subscript[μ, 4] -> 136.99347697276175   Subscript[μ, 5] -> 136.86600458739028   Subscript[μ, 6] -> 137.66773316797602   Subscript[μ, 7] -> 138.71504826760085   Subscript[μ, 8] -> 137.86968038934324   Subscript[μ, 9] -> 139.59905621326638   Subscript[μ, 10] -> 140.25024135591553  Subscript[μ, 11] -> 140.2694453172227   Subscript[μ, 12] -> 140.25903056582487  Subscript[μ, 13] -> 140.76056107163038  Subscript[μ, 14] -> 140.57048134866926  Subscript[μ, 15] -> 141.2423932521736   Subscript[μ, 16] -> 142.58509714117514  Subscript[μ, 17] -> 142.51063755538405  Subscript[μ, 18] -> 143.13528607312404  Subscript[μ, 19] -> 142.18681058236535  Subscript[μ, 20] -> 143.6154398513785   Subscript[μ, 21] -> 142.91697372187775  Subscript[μ, 22] -> 136.6821951928868   Subscript[μ, 23] -> 130.45585729159586  Subscript[μ, 24] -> 139.79590440094432  Subscript[b, 1] -> 10.  Subscript[b, 2] -> 10.  Subscript[b, 3] -> 10.  Subscript[b, 4] -> 10.  Subscript[b, 5] -> 10.  Subscript[b, 6] -> 10.  Subscript[b, 7] -> 10.  Subscript[b, 8] -> 10.  Subscript[b, 9] -> 10.  Subscript[b, 10] -> 10. Subscript[b, 11] -> 10. Subscript[b, 12] -> 10. Subscript[b, 13] -> 10. Subscript[b, 14] -> 10. Subscript[b, 15] -> 10. Subscript[b, 16] -> 10. Subscript[b, 17] -> 10. Subscript[b, 18] -> 10. Subscript[b, 19] -> 10. Subscript[b, 20] -> 10. Subscript[b, 21] -> 10. Subscript[b, 22] -> 10. Subscript[b, 23] -> 10. Subscript[b, 24] -> 10. Δ -> 25.92287490310396  Subscript[τ, 1] -> 40.890610245193756   Subscript[τ, 2] -> 70.8818159449603 Subscript[τ, 3] -> 306.0431348497769


title: Importing Zip files

text: Mathematica can import zipped files automatically, but when the content of the zip file it's another zipped file, I just get the list of files in the second zip:               In[317]:= Import["http://www.meff.com/docs/Ficheros/Descarga/dRV/RV120312.zip","*"]     Out[317]={{TGENTRADES.M3,CCONTRGRP.C2,CCONTRTYP.C2,CCONTRACTS.C2,CCONTRSTAT.C2,CTHEORPRICES.C2,CDELTAS.C2,CINTRASPR.C2,CINTERSPR.C2,CVALARRAYS.C2,CYIELDCURVE.C2,CVOLATILITYSKEW.C2,MCONTRACTS.M3}}      How can I get the content of the last files ?


title: How to execute a function each time the slider is dragged?

text: I've created a function `f` and a slider:               Slider[Dynamic[y],{1,4}]      How to execute/call `f` each time the slider is dragged?


title: How to calculate this sum?

text: I want to find the sum $$S=f\left(\dfrac{1}{2012} \right) +f\left(\dfrac{2}{2012} \right) +\cdots + f\left(\dfrac{2011}{2012} \right), $$ where $$f(x) = \dfrac{4^x}{4^x + 2}.$$ I tried               f[x_] := 4^x/(4^x + 2)     Sum[f[i/2012], {i, 1, 2011}]      But I can't get the answer. How do I tell _Mathematica_ to do that? I know, $$f(x) + f(1 - x) =1.$$ I used               Simplify[f[x] + f[1 - x]]


title: About Compile Function

text: I have a function that take p as a parameter, p is a 2X3X3 list, ( a 2X3X3 list can like { {{2,3},{1,2.},{1,1.}}, {{2,3.},{1,2},{1,1}}, {{2,3},{1,2},{1,1}} } ) the function just as:               func[p_]:= Module[{}, {Main Fuction} ];      If I want to use Complie Function:               func= Compile[{p,_Real,???},     Module[{}, {Main Fuction} ]     ];          How do I define ??? (above)


title: Creating text using Table

text: I have a really trivial question. I want to create a table containing the text "this number = k" where k is the value of the iterator in the Table function. I tried               Table["This number = "  k, {k, 3}]      but the output is               {"This number = ", 2 "This number = ", 3 "This number = "}      when want I want is               {"This number = 1", "This number = 2", "This number = 3"}.      How can I achieve this?


title: Simplifying Complex Numbers that contain physical units

text: I am trying to evaluate the following:               Simplify[Meter Nano Re[(a + I b)/(Meter Nano)], Assumptions -> Element[{a, b}, Reals]]      However, Mathematica returns:               Meter*Nano*Re[(a + I*b)/(Meter*Nano)]      And if I try:               Convert[Meter Nano Re[(a + I b)/(Meter Nano)], 1]      I get the error:               Convert::incomp: "Incompatible units in Meter Nano Re[(a+I b)/(Meter Nano)] and 1."      How can I factor out the "Meter Nano" from within Re[] and simplify the above to: `a` One solution: As suggested by rcollyer, use ComplexExpand: ` ComplexExpand[Meter Nano Re[(a + I b)/(Meter Nano)]] ` which gives ` a ` Note: ComplexExpand, as written above, assumes `a` and `b` are `Reals`.


title: OpenGl Z-Order Equivalent in Mathematica?

text: I am trying to draw the arrows in this picture on top of the two parallel plates. In OpenGL I would just set the 4th coordinate the z-order to be closer. Any ideas how to draw them on top in mathematica? ![3D](http://i.stack.imgur.com/HGs5c.png)               R0 = .5;     Rl = 12;     Rw = 1;     or = {-0.5, 0, -0.}     ArrRad = 0.1;     ArrLen = 2;     (*vp=Options[Graphics3D,ViewPoint][[1,2]];*)     vp = {2.172860287784637`, -2.2696686904229137`, 1.2558989630867607`};     Graphics3D[{(*EdgeForm[Thickness[0.002]],*)       (*Top Plate*)       {Gray, Opacity[1],  Polygon[{{0, -Rw, R0}, {0, Rw, R0}, {Rl, Rw, R0}, {Rl, -Rw, R0}}]},       (*Bottom Plate*)       {Gray, Polygon[{{0, -Rw, -R0}, {0, Rw, -R0}, {Rl, Rw, -R0}, {Rl, -Rw, -R0}}]},       (*Arrow E*)       {Red, Arrow[ Tube[{or + {#, 0, 0}, or + {#, 0, ArrLen*Sin[(2 \[Pi])/Rl #]} }]] & /@          Table[x, {x, 0, Rl, Rl/12}]},       (*Arrow H*)       {Green,  Arrow[Tube[{or + {#, 0, 0}, or + {#, ArrLen*Cos[(2 \[Pi])/Rl #], 0} }]] & /@          Table[x, {x, 0, Rl, Rl/12}]}       }, Boxed -> False, ViewPoint -> Dynamic[vp], ImageSize -> 400]


title: Looking for documentation on code editor's color/style highlighting

text: Where can I find reference documentation (as opposed to, e.g., tutorials, etc.) on the meanings of the various color/style highlightings that _Mathematica_ automatically assigns to code as one types it? I don't have any particular question; I just want to see what _all_ these colors and styles mean.


title: Mathematica script - Using front end

text: I'm running _Mathematica_ on OS X and I want to create an Automator action that converts spreadsheet files. I have written this script:               #!/usr/local/bin/MathematicaScript -script          FORMATS = {"csv", "tsv", "dat", "xls", "xlsx", "odf"};     files = Rest @ $ScriptCommandLine;     data = Import /@ files;     {ext, delete} =        DialogInput[        DialogNotebook @ {          TextCell["Choose output format:"],           PopupMenu[Dynamic[x], FORMATS],           Row @ {Checkbox[Dynamic[y]], TextCell["Delete original files"]},           Row @ {CancelButton[], DefaultButton[DialogReturn[{x, y}]]}        }];     newNames = (FileNameJoin@{DirectoryName[#], FileBaseName[#]} <> "." <> ext)& /@ files;       MapThread[Export, {newNames, data}];     If[borrar, DeleteFile[files]];      When I run it, I get this error message when running `DialogInput`: > FrontEndObject::notavail: A front end is not available; certain operations > require a front end. Is there any work-around, or should I try a different approach?


title: Rolling Ball Image Background Subtraction

text: I am currently doing particle detection on some images and I wanted to do an Image Background Subtraction similar to what is available on ImageJ so as to even out the background tone. ImageJ uses a Rolling Ball algorithm which I believe is a type of Top-hat transform using a ball as a structuring element. I currently have to do the background subtraction in ImageJ and then import the file to Mathematica to do the rest of the particle detection. Could anyone help me write a rolling ball background subtraction algorithm in Mathematica, or does anyone know another way that I can flatten out/even out the background tone of my image? This is my first question, and I'm not well versed in image processing, so I'd be happy to provide any other information that might be useful if I can. Thanks!


title: How to fix BodePlot that comes with Mathematica?

text: I am using _Mathematica_ to go through the examples and exercises on the book _Modern Control Systems_ , 6th edition by Dorf. On page 605, there is a table (Table 8.5) with the Bode plot for several transfer functions. In what follows there is a piece of code that attempts to build the very same table. Here is the code:               With[{ τ1 = 20, τ2 = 2, τ3 = 0.4, τ4 = 0.05, τa = 10, τb = 1, k = 10},           Grid[            Partition[              Table[ BodePlot[ sys, PlotLabel->sys, GridLines -> Automatic], { sys,                      { k/(s τ1 + 1), (k(s τa + 1))/(s(s τ1 + 1)(s τ2 + 1)),                        k/((s τ1 + 1)(s τ2 + 1)), k/s^2, k/((s τ1 + 1)(s τ2 + 1)(s τ3 + 1)),                       k/(s^2 (s τ1 + 1)), k/s, (k(s τa + 1))/(s^2 (s τ1 + 1)),                        k/(s(s τ1 + 1)), k/s^3, k/(s(s τ1 + 1)(s τ2 + 1)),                       (k (s τa + 1))/s^3, (k (s τa + 1)(s τb + 1))/s^3,                       (k (s τa + 1))/(s^2 (s τ1 + 1)(s τ2 + 1)),                      (k (s τa + 1)(s τb + 1))/(s(s τ1 + 1)(s τ2 + 1)(s τ3 + 1)(s τ4 + 1)) }                                                                               }                   ],  2], Frame->All, Spacings->6] ]      ![a bunch of Bode plots](http://i.stack.imgur.com/DyGQX.gif) All the transfer functions with `1/s^n` `( n > 1 )` give the wrong result as far as the phase plot is concerned. Is there a simple way to fix this? _Wolfram_ does not have a time line to go through the problem and sort it out.


title: Problem with importing format of data from Excel?

text: I am trying to import data from Excel. It is located in a single column of the Excel file but each cell contains a comma separated pair of two values as a,b. When I am importing them I have this format {{"a,b"},{"c,d"},...,{"x,y"}, which means just one element not a pair of numbers. How can I have {{a,b},{c,d},...,{x,y}} instead?


title: KeyPress function in Java's Robot class, how to state parameter?

text: I am trying to use Java's Robot class to type. This is what I have done so far.               Needs["JLink`"];     InstallJava[];     robot = JavaNew["java.awt.Robot"]      The mouseMove command for the robot works fine, but when I try               robot@keyPress["KeyEvent.VK_Y"]      I am given this error:               Java::argx1: Method named keyPress defined in class java.awt.Robot was called with an incorrect number or type of arguments. The argument was KeyEvent.VK_Y.      Calling the function for a robot object using this parameter works fine in a Java IDE, but I can not get it to work in Mathematica. What am I doing wrong?


title: How to get (fg)' = f'g + g'f?

text: I am new to Mathematica so the my questions might be pretty much at the pupil's level. If I want to use differentiation to derive:                   (fg)' = f'g + g'f      How can I keep empty symbol `f, g` from been evaluated for derivative and get 0? For example if I use                   D[f g, x]      I immediately get 0 result. I guess it might be related to **hold** , but couldn't find out the correct way to get it work.


title: Edit Plot/Graphics after it's been drawn.

text: Sometimes I run into a situation when there are graphics objects (mostly plots) that take a while to draw. Good practice would suggest you do all your evaluation outside `Plot` or whatever other plotting function, but sometimes one forgets or it is the drawing process that takes so much time. So **the question is** whether it is possible to change things such as `PlotLabel` font, `PlotStyle` or other strictly aesthetic properties of the plot without asking Mathematica to recalculate all the points.


title: Edit plot after creation

text: I try to find a way to manipulate a plot I created before. (for full code take the fuction               x[t_]:=Sin[2t]      ) Let's say I have a plot:               plot1 = Plot[x[t], {t, 0, 10},        PlotStyle -> Purple,        ImagePadding -> 55,        Frame -> {True, True, True, False},        FrameStyle -> {Automatic, Purple, Automatic, Automatic},        FrameLabel -> {None, "Signal", None, None},        LabelStyle -> {16},        ImageSize -> 600        ];      And later I want to use the same plot with a point on the line. The complete code would be:               plot1 = Plot[x[t], {t, 0, 10},        PlotStyle -> Purple,        ImagePadding -> 55,        Frame -> {True, True, True, False},        FrameStyle -> {Automatic, Purple, Automatic, Automatic},        FrameLabel -> {None, "Signal", None, None},        LabelStyle -> {16},        ImageSize -> 600,        Epilog -> {Directive[{Purple}],PointSize -> Large,Point[{2,        x[2]}]}        ];      But is there another way? Something like               SetOptions[plot1,Epilog -> {Directive[{Purple}], PointSize -> Large,        Point[{2, x[2]}]}]      And what if I want to use this plot the second time in a Manipulate[] environment?               Manipulate[plot1,{dt,0,10}]      Till now I couldn't find a way to do this.


title: Combine a (2D)plot with an animation

text: I have a plot which is rather expensive to "present", and I want to create an animation on top of it. EDIT: "present" here does not just mean create the plot, but also to rasterize and present in on the Notebook. I tried to create the plot before by doing `plot=Plot[...]` and then use `Show[plot,Animate[...]]`, but _Mathematica_ does not allow to combine plots with Animations. If I put the plot inside the animation, it gets really slow as it re-renders the plot at each frame. * * * Another thing I tried was to present the plot as an background image of the animation, but I'm not being able to make backgrounds other than RGBColors (and I don't even know if this works). Is there any proper way of achieving this? * * * EDIT2: One example of such plot               plot = ContourPlot[Cos[x] + Cos[y], {x, 0, 4 Pi}, {y, 0, 4 Pi},      PlotPoints -> 200, MaxRecursion -> 2, Mesh -> None];      The number of `PlotPoints` is big because in my particular case the function to be plotted is non trivial, and requires a lot of resolution to see anything. (I'm not putting here the code because the function is obtained as an iterative process, and is out of the scope of this question)


title: Test if argument is inside domain of InterpolatingFunction

text: The documentation says _In standard output format, only the domain element of an InterpolatingFunction object is printed explicitly. The remaining elements are indicated by <>_ But this is not the same as the actual domain where it doesn't use extrapolated values, see this example with a $\mathbb{R}^2 \rightarrow \mathbb{R}$ function:               SeedRandom[1];     dat = RandomReal[1, {9, 3}];     paramdat = Map[{{#[[1]], #[[2]]}, #[[3]]} &, dat];          ip = Interpolation[paramdat, InterpolationOrder -> 1]     (* InterpolatingFunction[{{0.128821,0.825163},{0.11142,0.925275}},<>] *)          ip["Domain"]     (* {{0.128821, 0.825163}, {0.11142, 0.925275}} *)          {x, y} = {0.12887062309893396`, 0.11147780180592484`};          ip[[1, 1, 1]] < x < ip[[1, 1, 2]] && ip[[1, 2, 1]] < y < ip[[1, 2, 2]]     (* True *)          ip[x, y];     (* InterpolatingFunction::dmval:        "Input value {0.128871,0.111478} lies outside the range of data in the         interpolating function. Extrapolation will be used."     *)      Is there a way to get the actual domain of an `InterpolatingFunction`? (and can I see all possible `ip["something"]`, I only found "Domain" by chance)


title: Metric Parameters such as Pratt Figure of Merit (Pratt-FOM) for Edge Detection

text: I have developed a new algorithm in _Mathematica_ v9.0 for the Edge Detection and want to compare it with the existing Roberts, Sobel, Prewitt etc, operators in the presence of Noise. I have evaluated Mean Square Error (MSE) and Peak Signal to Noise Ratio (PSNR) for all operators and compared with my new algorithm. But, one more metric parameter I have to evaluate is, for example, Pratt Figure of Merit (Pratt-FOM) in Mathematica. I find it difficult to know how to go about evaluating this Pratt-FOM in Mathematica. Could anybody help me how to apply the (analytical/mathematical) logic in Mathematica to evaluate Pratt-FOM? I have to complete it for my homework assignment. I am good in Mathematica, but my friends switch over to MATLAB for coding. But I am sticking to Mathematica for this purpose and trying hard to apply the logic for this.


title: Preventing ColorFunction bleed in ListLinePlot

text: Given this dataset (~2100 year precipitation estimates in New Mexico, based on tree-ring data, courtesy of NOAA and Henri Grissino-Mayer)               MALPAIS[1] = ToExpression@StringSplit[#, " "] & /@       StringSplit[       StringTake[        Import["ftp://ftp.ncdc.noaa.gov/pub/data/paleo/treering/\     reconstructions/newmexico/malpais_recon.txt"], 18669 ;; 44215], "\n"]      The following:               ListLinePlot[#, Frame -> True, Axes -> False, Filling -> Axis,             AspectRatio -> 1/5, ImageSize -> 1000,             ColorFunction -> Function[{x, y}, If[y < 0, Red, Blue]],             ColorFunctionScaling -> False] & @(MALPAIS[1] -             15.3146`)      Results in color-bleed (note, I switched colors from above): ![enter image description here](http://i.stack.imgur.com/kggGq.jpg) Presumably due to interpolation, since it it's also there in smaller time windows: ![enter image description here](http://i.stack.imgur.com/gemp2.jpg) Is there any option to prevent this?


title: How can I make threading more flexible?

text: Threading automatically with `Listable` functions requires the argument expressions to have the same length (or for one of them to be atomic). For nested lists the threading will continue down through the levels, provided the lengths are the same at each level. So, for example, these all work because the `Dimensions` of the two lists are the same at the first $n$ levels:               Array[#&, {10, 5, 3}] + Array[#&, {10}];     Array[#&, {10, 5, 3}] + Array[#&, {10, 5}];     Array[#&, {10, 5, 3}] + Array[#&, {10, 5, 3}];      whereas this doesn't work because the outer `Dimensions` don't match ($10\neq 5$):               Array[#&, {10, 5, 3}] + Array[#&, {5, 3}];     (*  Thread::tdlen: Objects of unequal length ... cannot be combined. *)      But there _is_ an obvious interpretation of the above code, which is to map the addition over the outer level of the first argument, i.e. to add the second 5x3 array to each of the ten 5x3 arrays in the first argument. A more easily visualised example is adding an offset to a list of coordinates:               coords = {{1, 2}, {3, 4}, {5, 6}, {7, 8}};     offset = {0, 10};      One way is to explicity `Map` the addition over the coordinate list:               result = # + offset & /@ coords     (* {{1, 12}, {3, 14}, {5, 16}, {7, 18}} *)      If the coordinate list was very long, a more efficient approach using `Transpose` might be preferred:               result = Transpose[Transpose[coords] + offset]     (* {{1, 12}, {3, 14}, {5, 16}, {7, 18}} *)      Neither of these is particularly readable though. It would be nice to have a "smart" threading function that would identify that the second dimension of `coords` (length 2) matches the first dimensions of `offset` (also length 2), allowing the code to be written very readably:               result = smartThread[ coords + offset ]     (* {{1, 12}, {3, 14}, {5, 16}, {7, 18}} *)      How can I write such a `smartThread` function, which will take an expression of the form `func_[a_, b_]` and match up the various dimensions in `a` and `b` to do this kind of flexible threading?


title: Extending listability to coordinates

text: I noticed that one can subtract a since real number value from all elements in an array by writing something like               {5, 4, 3, 2, 1} - 5      which outputs `{0, -1, -2, -3, -4}`. However, this doesn't seem to extend to coordinates, where we get an "objects of unequal length" error for a command like               {{5, 4}, {5, 2}, {5, 1}, {5, -5}} - {2, 2}      Is there a way to easily do make something like above work so that `{2,2}` is subtracted from each list item automatically?


title: How to extend "List-of-numbers-with-number" arithmetic to "List-of-X-with-X" arithmetic?

text: I'll start with a couple of examples (since this is all one can get from the documentation anyway). First, adding lists of numbers equal length is done term-by-term. E.g. `{8, 2, 5} + {3, 0, 3}` evaluates to `{11, 2, 8}`. Second, adding a list of numbers to a single number is done by, effectively, "broadcasting" the single number into a list of the same size as that of the other addend, and then the same term-by-term addition as before is applied. For example `{1, 2, 3} + 5` evaluates to `{6, 7, 8}`. Conceptually, one could imagine extending this scheme to the case of adding a list `L` to a list-of-lists `L^2`. First "broadcast" `L` into a list of the appropriate number of copies of `L`, and then add the two lists-of-lists "term-by-term". For example, following this scheme, `{1, 2} + {{5, 9}, {9, 7}, {1, 7}}` would evaluate to `{{6, 11}, {10, 9}, {2, 9}}`. To my surprise, however, _Mathematica_ won't play along: The last sum would fail with an error beginning with `Thread::tdlen: Objects of unequal length ...` (The same goes for the remaining "basic operations", `-`, `*`, and `/`.) What's the simplest way to carry out this proposed extension of arithmetic between a single object of type _X_ and a `List` of objects of type _X_ (assuming that arithmetic between single objects of type _X_ is defined)?


title: Convert Graphics3D containing BSpline to polygon primitives for export to 3DS?

text: `Graphics3D[]` objects created with BSpline functions will not export to 3DS format, which only supports the more basic primitives. Is there any straightforward way to get at an underlying polygon representation of the `BSplineSurface[]` graphics "primitive" (in quotes because its not very primitive)? An example is the final 'pipe' example in the documentation ref/BSplineSurface. If you try `Export["Pipe.3ds", %]`, you get an error. In my particular case I'm creating arbitrary 'surface of revolution' objects as per the "Potter's Wheel" demonstration, where the cross section is determined by a BSpline with dynamic control points. That works fine, but then I need export the resulting objects to another program.


title: Unexpected behavior when using SortBy as a dataset filter

text: I am still experimenting with datasets. Recently I tried to query the Titanic example to get info on the oldest passengers. Here is what I tried               titanic = ExampleData[{"Dataset", "Titanic"}];     titanic[Select[#age > 65 &]]      ![oldest-1](http://i.stack.imgur.com/8iX52.png) That's fine, but I really wanted the data sorted by age. The documentation for datasets mentions that `SortBy` can be used as filtering operator, but gives no further details on it use that I could find. So I was left to experiment on my own. Here is my second attempt.               titanic[Select[#age > 65 &] /* SortBy["age"]]      ![oldest-2](http://i.stack.imgur.com/HQYpj.png) The result shows sorting, but the "age" category is only locally sorted within each "class" category. That is not what I wanted. I wanted the sort to treat the "age" category as if it were the major key of the dataset. Does anyone know how to dot that? I did find a work-around but it's weird.               titanic[Select[#age > 65 &], RotateLeft[#, 1] &][SortBy[42]]      ![oldest-3](http://i.stack.imgur.com/HhnFA.png) Note that the argument to `SortBy` is complete nonsense, but this last code works as I want. Can anyone explain this result? One last question. Since there is essentially no useful documentation on using `SortBy` in the way I have above, it's hard to dispute any behavior it shows. Nevertheless, I ask if you think I should report the behavior I have observed to Wolfram tech support as a possible bug?


title: How to use pattern matching to assign values to Subscript[f,x_]?

text: I want to define two subscripted functions `Subscript[f,1]` and `Subscript[f,2]`. To keep the assignments local, I would like to associate the definitions with `f` if possible. My current solution is to write the following.               f/:Subscript[f,1]:=Function[x,g[x]]     f/:Subscript[f,2]:=Function[x,h[x]]      The resulting definition is stored as an UpValue for `f`, which is acceptable for me. Is it possible to construct a similar definition using pattern matching? I am looking for an analog to the following pair of definitions.               f[x_]:=g[x] (*definition 1*)     f:=Function[x,g[x]] (*definition 2*)      In other words, I am currently using a definition akin to definition 2 above for my subscripted functions. Is it possible to write a definition analogous to definition 1 above?


title: Palette created by my code doesn't work

text: I think I am lost on some basic issue ... I created two CellTags, tagone and tagtwo If I create this palette inputting the following code by hand I get a beautifully working palette that makes me jump to these cells.                CreatePalette[{         Button["tagone", NotebookFind[InputNotebook[], "tagone", All, CellTags]],          Button["tagtwo", NotebookFind[InputNotebook[], "tagtwo", All, CellTags]]}]      If I do put this in a function like the following the palette gets created with right names shown in the buttons, but pressing the buttons nothing happens ... Apparently there is a problem in this code with the use of the counter variable in the `For`. In this examples it is called `celln` and in the error monitor I get > Part specification celln$53002 is neither a machine-sized integer nor a list > of machine-sized integers. I though the variables was fixed in the loop ... I am quite puzzled, any guess? Did I just made a rookie mistake? I think this functions was previously working when I originally developed it in December. Maybe my memory is failing.                Module[{nb, res, list, origlist, celln},        nb = InputNotebook[];        origlist = NotebookTools`NotebookCellTags[nb];        Print[origlist];        res = {};        For[celln = 1, celln <= Length[origlist], celln++,          Print[ToString[origlist[[celln]]]];          AppendTo[res,            Button[origlist[[celln]],             NotebookFind[nb, origlist[[celln]], All, CellTags, AutoScroll -> True]]];        ];        CreatePalette[res];      ]


title: Trying to fit an unknown extreme distribution

text: First up, I'm quite new to Mathematica so any hints on better code would be greatly appreciated. I have some histogram frequency data from an unknown distribution that I'm trying to fit. Here's the histogram and how I draw it:               Needs["Histograms`"]          (* Data in the form "rank count"*)     raw = ReadList["Desktop/data.txt", {Number, Number}];     (* I have some missing ranks that I want to set as having a count of 0 *)     fd = Table[0, {i, Max[raw[[All, 1]]]}];     Do[fd[[raw[[i, 1]]]] = raw[[i, 2]], {i, Length[raw]}]     Histogram[Log[fd], FrequencyData -> True]      ![enter image description here](http://i.stack.imgur.com/lwZ2H.png) `Needs["Histograms"]` seems to be deprecated but I couldn't find a nice way of plotting frequency data without it. The ranks are actually counts themselves, this is a histogram of the frequencies at which I've observed X number of things. Does that make sense? I'm slightly concerned that I'm confusing myself here :) Now I have the data and the log plot seems to show a nice continuous curve I thought I could find a line to fit it. I followed these instructions: FindFIt with BinCounts, for using FindFit over frequency data, so far so good. Let's try a power law distribution:               centers = MovingAverage[raw[[All, 2]], 2];     counts = raw[[All, 1]];     centered = Table[{centers[[i]], counts[[i]]}, {i, Length[centers]}];          xmin = 1;     model = ((a - 1)/xmin)*(x/xmin)^(-a)     pars = FindFit[centered, model, {a}, x]     nlm = NonlinearModelFit[centered, model, {a}, x];     nlm[{"BestFit", "ParameterTable"}]      I'm not particularly expecting a power law distribution to work but it demonstrates my method. Here's what I get:               (-1+a) x^-a     {a->1.16913}         | Estimate | Standard Error | t-Statistic   | P-Value     ----------------------------------------------------------     a   | 1.16913  | 122731.        | 9.52597*10^-6 | 0.999992      So, my questions. Is what I'm doing correct? If I managed to find a model that describes my data will FindFit estimate the parameters for me? Can anyone help with what that distribution might be? I've tried (grasping at straws):   * Zipf's law   * Power law   * Gumbel   * Laplace   * Frechet Some have been reported as having a very good fit (P-value ridiculously low) but the lines don't really match up and when I plug in some numbers I get really bad results. I feel like I'm being hopelessly naive in trying to do this. I've had my head stuck in these numbers for so long I don't really know what's going on :)


title: Symbolic manipulation with unevaluated sums

text: If I have two expressions with sums in them, like this: $$\begin{align*} b&=\frac{\sum_{i} (x_i - \bar{x})(y_i -\bar{y})}{\sum_{i}(x_i -\bar{x})^2}\\\ r&=\frac{\sum_{i} (x_i - \bar{x})(y_i -\bar{y})}{\sqrt{\sum_{i}(x_i -\bar{x})^2\sum_{i}(y_i -\bar{y})^2}} \end{align*}$$ and I wanted to produce a simplified expression of $\frac{b}{r}$, how would I do it? The problem is the sums. It seems Mathematica doesn't like the unspecified, unevaluated sums. **Edit:** I was expecting to end up with something like this: $$\sqrt{\frac{\sum_{i}(y_i -\bar{y})^2}{\sum_{i}(x_i -\bar{x})^2}}$$ I've been playing around with `Expand`, `Simplify`, `FullSimplify`. There may just be a way to apply it that I'm missing.


I'm reading/studying on my own a book about algebraic curves. I'm trying to find a way for _Mathematica_ help me with the following (the book, ISBN: 038731802X, allows me to use any CAS / program. Here is a question: > How many times do the two given curves intersect at the origin? > > $\quad(a)\quad y = x^3$ > > which I can rewrite as $y-x^3 = 0$ > > $\quad(b)\quad y^4 + 6x^3*y + x^8 == 0 $ I can view both curves using:               ContourPlot[{y^4 + 6 x^3*y + x^8 == 0, y - x^3 == 0}, {x, -5, 5}, {y, -5, 5}]      However, I have no idea how to find the the multiplicity of the zeros at the origin. I'm really stuck.


title: Importing file with UCS-2 Little Endian codification

text: I'm trying to import a text file with UCS-2 Little Endian codification but I can't read it correctly. There's any hidden option to read this files ?? I'd tried with `Import` (using `ByteOrdering` option) and `ReadList`. And example file can be find here Thanks !!


title: Weird vertical line when trying to plot a histogram

text: I'm trying to plot a histogram of a few data points and overlay a plot on it (it's a fit of a geometric distribution to my data). The weird thing is that a vertical line appears always next to the smallest datapoint of the histogram. As the distribution is continuous, I always get this vertical line in the middle of the plot, and I'd like to get rid of it.               p[s_] := 1/(1 + s); q[s_] := s/(1 + s);     Geom[s_, x_] := p[s] (q[s]^x);     SigmaC = 9114.738337867104`;     data = {4.566649578817866`, 4.1087341086023645`, 3.5448119117577757`, 4.191562787591725`, 3.7948364578145606`, 4.157517208532611`,    4.539966367996713`, 3.8003045775561977`, 2.60422605308447`,   4.220081924933814`, 4.166548514738755`, 3.879841055986562`,    3.673481697073347`, 3.310480891462675`, 4.680335513414563`};     Hist = Histogram[data, 10, "PDF"];     Pl = Plot[Log[10] 10^s Geom[SigmaC, 10^s], {s, 0, 5}, PlotRange -> {0, 1}, PlotStyle -> {Red, Thick}];         Show[Hist, Epilog -> First@Pl, PlotRange -> {{0, 5}, {0, 1.5}},  Frame -> True]      ![enter image description here](http://i.stack.imgur.com/sJdIc.png) When I set               Frame -> False      then the vertical line changes into y-axis. I'd like to have y-axis in the far-left side of the plot. Does anyone have an idea how to resolve this? This is probably really simple but I'd appreciate any insight! Thanks a lot!


title: TeXForm without simplification

text: I'd like to be able to feed an expression into Mathematica, and have Mathematica convert that expression to TeXForm WITHOUT ANY SIMPLIFICATION WHATSOEVER. As a trivial example, currently, if I enter               6/9 //TeXForm      MM returns               \frac{2}{3}      I'd like to be able to feed it 6/9 and have it return               \frac{6}{9}      Obviously there are solutions that would effectively involve writing my own parser, but I'm specifically looking for relatively short and clean solutions, if there are any.


title: Prevent Suppression of Superscript 1 in Print

text: I'm trying to print Christoffel symbols of the second kind for a surface in $\mathbb R^3$. I currently am using something along the lines of               Do[       Print[Subscript[Subscript[\[CapitalGamma]^k, i], j]],       {i, 2}, {j, 2}, {k, 2}     ]      Unfortunately the superscript '1' is suppressed. How do I force them to display?


title: Garbage collection for memoized functions on subkernels

text: I have a top-level function which operates on some data:               findBestIntegers[data_]:=ParallelMap[optimize,data]      which makes parallelized calls to an optimization routine which tries to find the best integers associated with the data point. The optimization function is shown here in highly simplified form:               optimize[dataPoint_]:=Module[{bestGuess,newGuess,bestCost,newCost},       bestGuess=RandomInteger[{1,20},3];       bestCost=cost[dataPoint,bestGuess];       Do[         newGuess=RandomInteger[{1,20},3];         newCost=cost[dataPoint,newGuess];         If[newCost<bestCost,bestCost=newCost;bestGuess=newGuess],         {i,1,bigNumber}       ];       Return[bestGuess]     ]      which itself makes many calls to a memoized cost function (the real optimization method I'm using makes a fair number of duplicate calls to the cost function, and achieves a ~2x performance boost from memoization):               cost[dataPoint_,{n1_,n2_,n3_}]:=cost[dataPoint,{n1,n2,n3}]=RHS      After running this for a long time on a large data set, I noticed the subkernels' memory footprints expanding to hundreds of megabytes, due to the memoized cost functions being cached locally, and I worry about slowdowns from the garbage piling up. However, I also know that `data` will never contain duplicate points, due to it being essentially random floating point numbers. That means if I write the top-level function as a loop which optimizes for a batch of `data`points in parallel, there should be no downside to clearing the memoized functions in all subkernels to free up memory before moving on to the next batch of `data`points. I have been unable to get this to work (referencing this question: Clearing distributed definitions from remote kernels). After a `ParallelEvaluate[Clear[cost]]`, I'm unable to refresh the function definition on the subkernels, and errors result. Furthermore, I'm not certain there is any speed to be gained by doing this. I suppose it depends on the data structure used for memoization within each subkernel. Hash tables, for example, have basically constant lookup time. Does anyone know if there is performance to be gained, and if so, how to implement this sort of parallel-memoized garbage collection?


title: Computing Ehrhart's polynomial for a convex polytope

text: Is there a _Mathematica_ implementation for computing the Ehrhart polynomial of a convex polytope which is specified either by its vertices or by a set of inequalities? I am interested in knowing this because I understand that Ehrhart's polynomial for a polytope will determine the number of integer points inside this polytope. Alternatively if someone knows of an existing method to count the number of integer points inside a convex polytope (described by its vertices or a set of inequalities), it would be equally helpful.


title: A fast way to calculate the median difference between pairs of elements

text: I have a list of coordinate pairs, take for example the following list of three pairs:               exampleList = {       {{151.335, 245.102}, {151.332, 245.187}},        {{41.435, 245.021}, {41.3617, 244.986}},       {{131.048, 243.364}, {131.046, 243.321}}     }      Assuming the list is very large, what is a fast one-liner to calculate the median difference between elements in each pair? The output should be the same as:               Median[exampleList[[All, 1]] - exampleList[[All, 2]]]      Is this the fastest way to proceed?


title: Doubts on scripting: error messages when trying to run and how to process lots of files

text: I have created my first mathematica 'program' as I think of it, to do some image processing. After reading in an image, it does a lot of stuff (including smoothing, fourier transform, functional representation, searching for critical points, outputing various files). Now, I have hundreds of images that I want to process: obviously a job for a script. But I am somehow not understanding the whole mess of CommandLine, ScriptCommandline, or even how to properly edit script files (am I supposed to do it in the notebook? Because I'm using a lot of mathematica symbols, so I'm not sure how I could edit otherwise) or how to get scripts to run! It seems part of the problem is that scripting has changed in Mathematica 9 and a lot of previous Q&A entries focus on solutions for prior versions. I have tried to get a basic script working on my system and I get really odd errors. E.g.,               #!/Applications/Mathematica.app/Contents/MacOS/MathematicaScript - script          (*generate "num" samples of a mixed distribution*)          num = ToExpression[$ScriptCommandLine[[2]]];     Print /@ RandomVariate[       MixtureDistribution[{1, 2}, {NormalDistribution[1, 0.2],          NormalDistribution[3, 0.1]}], num, WorkingPrecision -> 50]      I get: > $ ./test.m 10 > > ./test.m: line 1: F814W_knotD_ACSHRC_2.91772_J8L001031_50_.fits: command not > found > > ./test.m: line 3: F814W_knotD_ACSHRC_2.91772_J8L001031_50_.fits: command not > found > > ./test.m: line 4: > *#!/Applications/Mathematica.app/Contents/MacOS/MathematicaScript: No such > file or directory > > ./test.m: line 5: F814W_knotD_ACSHRC_2.91772_J8L001031_50_.fits: command not > found > > ./test.m: line 6: syntax error near unexpected token `*generate' > > ./test.m: line 6: `(*( _generate "num" samples of a mixed distribution_ )*)' (those fits files are in the same directory, and I have NO IDEA why it is talking about them) Apologies for the newbie questions... hopefully this will be the last one for a while!!


title: Historical Exchange Rates via FinancialData

text: `FinancialData["name"]` and `FinancialData["name", start]` return respectively; the last known price, and the daily closing values for dates from start until the current date, for the financial entity - `"name"`. One of the possible entities quoted is `"Currency exchange rates"` and while the Documentation's claims hold for the first case ...               Column[{     DateString[],     FinancialData[{"AUD", "USD"}],     WolframAlpha["AUD/USD", {{"Result", 1}, "Plaintext"},"PodStates" -> {"Result__More accuracy"}],     1/CountryData["Australia", "ExchangeRate"]     }]          (*     "Sat 26 Apr 2014 07:03:11"     0.9274     "$0.9282  (US dollars)"     $0.838801     *)      it doesn't appear to for the second ...               FinancialData[{"AUD", "USD"}, {2013}]     (*       Missing["NotAvailable"]      *)      The Wolfram | Alpha query included above graphs a handful of previous years so _some_ historical data can be extracted but clearly not in the systematic, fine-grained way one might expect from using `FinancialData`. There is no mention of this particular missing data in the Documentation although apparently there can be periodic issues with the data sources and while directly accessing these sources offers a possible workaround, this only applies if the sources themselves provide API's for this historical data (which _doesn't_ appear to be the case for one such source - _Yahoo! Finance_ ) The documentation goes on to say: > `FinancialData`provides gateways to external financial data sources. Its use > is subject to any restrictions associated with those sources, and may > require additional licensing. This is perhaps one such instance although few other claimed currency properties seem to be available and/or relevant (at least with my connection?)               With[{props = FinancialData[{"AUD", "USD"}, #] & /@ FinancialData[{"AUD", "USD"}, "Properties"]},      StringForm["`1` out of `2` of FinancialData's Currency Exchange properties available",      Count[props, Except[_Missing | _FinancialData | {_Missing, ___}]],Length@props]]          (*      4 out of 74 of FinancialData's Currency Exchange properties available     *)


title: Image Rotation, Line Symmetry

text: I'd like to import an image, superimpose it, reduce the opacity of the overlaid image, and then use a manipulate to rotate the top image to illustrate rotational symmetry. The image below is using image editing software,not Mathematica, but illustrates the effect I am after. ![example of the effect I am after](http://i.stack.imgur.com/ef00G.png) There are many nice images on the net that could be used to illustrate this concept. Can this be done using Mathematica and the image processing commands? I tried importing an image file, then used Show and ImageRotate for example,               g1 = Import[ graphic....]     Show [ g1,  ImageRotate[g1, pi/4]]    but that wasn't at all what I was looking for...      I'd appreciate any suggestions for commands that could achieve this effect. My goal would be to create several Manipulates with various images to illustrate various orders of symmetry with image files (I've already done this with line drawings),


title: Integrating polynomial functions over polytopes with an add-on package

text: There is a _Mathematica_ package to evaluate integrals over polytopes: http://library.wolfram.com/infocenter/Books/3652/ In the documentation (`Functions.nb` file) I find: > ipoly::usage = "ipoly[f[x1, x2, I, xn], {x1, x2, I, xn}, {{a11, a12, I, > a1n}, {a21, a22, I, a2n}, I, {aJ1, aJ2, I, aJn}}, {b1, b2, I, bJ}] is the > n-dimensional integral of f[I] over a finite volume bounded by an > n-dimensional convex polytope P. P is defined to be all points which satisfy > the J inequalities: aj1 x1 + aj2 x2 + I + ajn xn <= bj, 1 <= j <= J. Input > form is ipoly[f, x, {c1 <= c2, c3 <= c4, I}] where ci's are linear in x."; I am trying a very simple example (similar to the one presented in `AboutFunctions.nb`: to integrate the function: `f[x,y] = x + y` over the polytope described by the set of inequalities `{0 <= x, x <= 1 - y, -1 <= y, x + 2 y <= 2}` .               ipoly[         x+y,         {x,y},         {0 <= x, x <= 1 - y, -1 <= y, x + 2 y <= 2}     ]      > ipoly[x + y, {x, y}, ..] I am unable to understand how the output can be the result of an integral? It looks like it is just giving me back the input itself. If someone knows how to use this function `ipoly[...]`, please tell me.


The Wolfram blog post: Using Mathematica Enterprise Edition to Create Professional Apps, Tools, and Reports makes the following statement (emphasis mine): > Enterprise Edition allows you to create EnterpriseCDF files, which provide > enhanced capabilities that can be deployed via the free Wolfram CDF Player. > But what are these capabilities, and why are they important to the work that > you do? Let’s take a look. > > First, **Enterprise Edition allows you to encrypt your code** , so > recipients cannot see your proprietary algorithms. For consultants and > application developers, this was an absolute must. With Enterprise Edition, > you can deliver reports, updates, and full solutions to your potential > customers without revealing your intellectual property. Note that this statement says " **encrypt** " not " **encode** ". A great deal hinges on this distinction. In a comment to Albert Retey's answer to this question: What can webmathematica do that CDF cannot do?, Andreas Lauschke states: > With the CDF, the M code is included in the distribution. WRI shows you ways > to "encode" that, but it's a joke, you can hack that with 5 lines of code. Others on this site have expressed similar concerns. With these concerns in mind and knowing that promotion and marketing doesn't always represent things as accurately as one would like, a colleague contacted Wolfram to ask whether Enterprise Edition really could encrypt code or if it only relied on something akin to encoding of packages? Neither Premier Support or sales could supply a direct and immediate answer. I think anyone reading this who has an interest in deploying Mathematica applications that need to include proprietary code, would share the unsettling feeling this left us. Now, we appreciate that this may represent new functionality and that support and sales people need to get up to speed on such things. So we hope they clarify this. If we hear back from Wolfram, we'll share the information. But for now, it leaves the question... **Can Enterprise Edition really encrypt code for distribution via CDF?** If it does support real encryption, knowing a bit about what type of encryption would also provide some comfort. I recognize this falls a bit out of the normal range of questions, but I think it concerns many of us in this community and raises some other questions about using Mathematica and what one can and cannot reasonably do with it.


title: Complex Convolution

text: I am attempting to integrate a convolution variable using the following code. However, the program is taking too long to complete the integration. Does anybody have any coding tips that may make this run faster?               convolutionIntegralinEveryone =           Mean[convolutionIntegralinEachIndividual];          plottingDistributionofIntervals =           ParametricPlot[{x/(2*Pi), convolutionIntegralinEveryone},                {x, 0, longestDosingIntervalObserved*3}, AspectRatio -> Full,                 PlotRange -> All]          plottingCumulativeDistributionofIntervals = ParametricPlot[{y/(2*Pi),         NIntegrate[convolutionIntegralinEveryone, {x, 0, y}, MinRecursion -> 4,                AccuracyGoal -> 2]},        {y, 0, longestDosingIntervalObserved*8}, AspectRatio -> Full, PlotStyle -> {Blue, Thick},                PlotRange -> All]      The convolutionIntegalinEveryone is the mean of the convolution integrals in the all of the individuals (there are 100,000 simulated individuals with several intervals each) and the code is as follows: convolutionIntegralinEachIndividual=Table[Sum[(1/totalCountofIntervalsEachIndividual[[ii]])*distributionofIntervalsinEachIndividual[[ii,jj,2]]*diracVonmisesConvolution[[distributionofIntervalsinEachIndividual[[ii,jj,1]]+1]], {jj,1,Length[distributionofIntervalsinEachIndividual[[ii]]]}], {ii,1,Length[distributionofIntervalsinEachIndividual]}]; I would also like to add that the code has ran with other datasets containing different parameters.


title: How to solve a ParametricNDSolve issue when the system seems to be stiff?

text: I have a problem with `ParametricNDSolve[]`. Mathematica gives the warning that a stiff system is suspected. I have varied the methods but unfortunately I was not able to solve it. First some formulas that are used in the definition of the differential equation within the `ParametricNDSolve[]` statement:               r = 0.005; η = 1;     P[t_, T0_] := Exp[-r (T0 - t)]     Bx[x_, α_, γ_] := α/γ (1 - Exp[-γ x])     T1 = T0 + 1/365;      This is a list of test parameters:               testPars = {α -> 0.2563, γ ->      0.3753, ρ13 -> -0.2414, ρ12 -> -0.7369, ρ23 ->      0.1300, σv -> 2.5618, σS -> 0.6143, κ ->      5.7734, v0 -> 0.1559};      and finally the `ParametricNDSolve[]` statement as how I have entered it:               nfun = n /. ParametricNDSolve[{\!\(\*SubscriptBox[\(∂\), \(τ\)]\ \(n[τ, u]\)\) == n[τ, u] (-κ + u σv (ρ13 σS + ρ23 Bx[T1 - T0 + τ, α, γ])) + 1/2 n[τ, u]^2 σv^2 + 1/2 (u^2 - u) (σS^2 + Bx[T1 - T0 + τ, α, γ]^2 + 2 ρ12 σS Bx[ T1 - T0 + τ, α, γ]), n[0, u] == 0}, n, {τ, 0, 5}, {u, 0, 10^4}, {α, γ, ρ13, ρ12, ρ23, σv, σS, κ}, Method -> "StiffnessSwitching"]      I get an error when I plot the solution for the testparameter set:               Plot[nfun[α, γ, ρ13, ρ12, ρ23, σv, σS, κ][τ, 0] /. testPars, {τ, 0, 1}]      Does anyone have an idea on how to solve it? Your help is much appreciated.


title: Computing integral over explicit region

text: I need to integrate $f(x,y)=y^2-2x^2y+6x^3-3xy+2y-6x$ over $\\{y\geq 2x^2-2, y\leq 3x\\}$ Im using Boole in the following way;               Integrate[y^2-2x^2y+6x^3-3*x*y+2y-6 Boole[y >= 2*x^2 - 2 && y <= 3*x], {x, -2, 2}, {y, -2, 2}]      But i dont get a result, nor an error.


title: Correct slot assignment when mapping from different lists using pure function

text: Given               expr = u == a1 + a2 x + a3 y;      and               uRep = {u1, u2, u3};     xyRep = {{x1, y1}, {x2, y2}, {x3, y3}};      I'd like to generate 3 equations > >     {u1 == a1 + a2 x1 + a3 y1, >      u2 == a1 + a2 x2 + a3 y2, >      u3 == a1 + a2 x3 + a3 y3} >   By replacing `u` with `u1,u2,u3` at a time, and at same time, replace `x` with `x1,x2,x3` and the same for `y` Currently I do this using `MapThread` with explicit `Function` like this:               MapThread[Function[{z1, z2}, eq1 /. {u -> z1, x -> z2[[1]], y -> z2[[2]]}], {uRep, xyRep}]      But I was wondering what the syntax would be do it using pure function. I tried               MapThread[eq1 /. {u -> #1[[1]], x -> #2[[1]], y -> #2[[2]]} &, {uRepl, xyRepl}]       eq1 /. {u -> #1[[1]], x -> #2[[1]], y -> #2[[2]]} & @@@ {uRepl, xyRepl}      and few others. They all produce errors due to wrong slot `#` mapping. I am happy with the `Function` solution, but was wondering what the syntax will be using pure function. (I looked at many related questions, but could not find solution to apply for this case, I am sure I missed something)


title: Behavior of copy and paste with different image formats

text: Ok, let's say I create a 1x1 pixel image.               i = Image[{{0}}, "Byte"];      Now I `Export["image.png", i]` the image and import it into Libreoffice or Inkscape in Windows 7. Then I copy and paste the image back into _Mathematica_ 8.0.1 and calculate the `ImageDimensions`.               ImageDimensions[x = Rasterize[<image>]]      I would expect to receive the 1x1 but instead I get `{13, 17}` because of appended white borders around the image. Now If I save the copied output form LibreOffice and Inkscape and then `Import` the file into _Mathematica_ , I run into no problems. **What file formats have issues with _Mathematica_ so I can consistently paste from the clipboard? I know _Mathematica_ has multiple ways to copy files** `MetaFile` **and** `Bitmap` **under Edit->Copy As, but how do these relate to different way to paste objects?**


title: Import and file symbolic links

text: Can `Import` be forced to follow a file symbolic link (a.k.a. _alias_ (Mac) or _shortcut_ (Windows)) to the true file?


title: Finding the largest integer that cannot be partitioned in a certain way

text: I want to use _Mathematica_ to solve the problem: > Find the maximum $k$ such that $6x+9y+20z=k$ does not have a non-negative > solution. I tried `FrobeniusSolve`. But what is the elegant way to find the maximum? I know the theoretical background of this problem, and I know other ways of getting the solution. But I want to see how this can be done elegantly in _Mathematica_.


title: Solving one equation, then inputting the values into another for NonlinearModelFit

text: Considering the equation               a*x^3 + a*x^2 + x + b == 0      I'm looking to find the best value for `a` and `x` from the above polynomial (with `b` known) for which the second function using the same `a` and `x`               (65 + 103*a*x^2)/(1 + a*x^2)      gives me the closest `NonlinearModelFit` for an already determined set of (x,y) coordinates.


title: Symmetric function of the roots of a polynomial

text: First, I'm a beginner. I can compute the sum of roots with the follwing:               Roots[x^7 + 5 x^6 + x^5 + x + 1 == 0, x]     Plus @@ (x /. {ToRules[%]}) // Simplify      Of course I get, except the sign, the coefficient of x^6. Now, is there a way to compute more elaborate symmetric functions, for example the sum of xi/xj for all i,j ?


title: Plotting Complex Quantity Functions

text: Trying to plot with complex quantities seems not to work properly in what I want to accomplish. I would like to know if there is a general rule/way of plotting when you have complex counterparts in your function. I tried looking up `ContourPlot` and `DensityPlot` but I only have one single variable as `ContourPlot` asks for two variables in order to plot. The expression I am trying to plot is as so:               eqn := (25 Pi f I)/(1 + 10 Pi f I)     Plot[eqn,{f,-5,5}]      If there something else that is missing here?


title: When does the real part of Zeta vanish on the critical line?

text: This seems to be a quite a simple problem but I cannot make it work.   I am trying to find all values within a given range for which the real part of the Zeta function vanishes on the line: $\;z=\frac{1}{2} + i\;y$. Given the following plot:               Plot[{ Re[ Zeta[ 1/2 + I t]]}, {t, 14, 14.6}]      ![enter image description here](http://i.stack.imgur.com/msoer.gif) I would like to get the values: $14.13...\;, 14.5....$.


title: Plotting a complex valued function in mathematica

text: How can I plot a complex valued function like $f(z)=z^2, z=x+Iy$, in _Mathematica_? Can anyone help?


title: How to draw the plot of a function in the complex plane?

text: I'm new to _Mathematica_ , and I was wondering how to plot $x^n$ in the complex plane. Is there a dedicated function for this purpose?


title: Plotting a complex function

text: What does it mean if this message appears: > {Im[(1-E^Times[<<3>>] f)/(1-Power[<<2>>] f)]-0,Im[(1-E^Times[<<3>>] > f)/(1-Power[<<2>>] f)]-0} must be a list of equalities or real-valued > functions. >> while Iam trying to plot this complex function               (I α)/π (Log[(1 - E^(-((I π(1 - α))/α)) f) / (1 - E^((I π(1 - α))/α) f)])      How can I plot this function for the range {α, 0.1, 1} and {f, 0.2, 1}? ### Edit Corrected errors in the expression to be plotted.


title: How to plot image of a complex function with a given domain

text: I've been trying to figure out a way to either draw a curve in the domain of a complex function in one plane and then show the result in another plane (simultaneously?). Actually, just plotting circles and lines (any line, even just y=x) in the domain and showing their corresponding image in the other plane would be great too. For example, if the function were e^z, then this program would send horizontal and vertical lines in the domain plane to rays and circles in the other plane. I'm not sure where to even start with this...


title: Finding rings in a network

text: I am doing a research on networks which consist of polygons with different number of sides. Is there a way to find rings by               BreadthFirstScan      function. For example, in the following graph {1,2,3,4,5,6}, {3,4,11,12,13},{3,7,8,9,10,11} are rings of this network. ![enter image description here](http://i.stack.imgur.com/eYCQj.jpg) * * * W Community crosspost


title: How do I plot a variable against another variable in Mathematica?

text: I'm working on a system that has molecular interactions, for which I have the defined constants.               r=0.5;     a=1;     c=0.01;     d=0.1;     e=0.02;     k=500;      and my system of differential equations, which was solved numerically using `NDSolve` I put the following:               sol == NDSolve[{                 x’[t] == r*x[t]*(1-(x[t]/k)) – a*c*x[t]*y[t],                  y’[t] == a*c*x[t]*y[t] – d*y[t],                 x[0] == y[0] == 30                 }, {x,y}, {t,1000}            ]      and received the following:               {{xInterpolatingFunction[{{0.,1000.}},< >], yInterpolatingFunction[{{0.,1000.}} < > ] }}      Then, I put in               Plot[Evaluate[{y[t],x[t]}/.sol],{t,0,1000},PlotRange{0,500}]      for which I received a beautiful plot of both `y[t]` and `x[t]` over the course of time `t`. However, for purposes of stability, I want to plot `y[t]` on the y axis and `x[t]` on the x axis for a range of 0 to 250 on the y axis and about 0 to 1000 on the x axis. How would I go about doing this? I thought about               Plot[Evaluate[{y[t],x[t]}/.sol],{x,0,1000},PlotRange{0,500}]      ....but I received no success. Just a blank plot.


title: Can't plot rotated region

text: I was experimenting with the code from this question when I ran into another problem with regions.               Ω = RegionDifference[Rectangle[{0, 0}, {10, 10}], Rectangle[{4, 4}, {8, 8}]];     RegionPlot[Ω]      ![plot](http://i.stack.imgur.com/HkCCM.png)               Ω1 = TransformedRegion[Ω, RotationTransform[45 °, {5, 5}]];     RegionQ[Ω1]      > >     True >                 RegionPlot[Ω1]      > RegionPlot::invplotreg: TransformedRegion[RegionDifference[Rectangle[{0, 0}, > {10, 10}], Rectangle[{4, 4}, {8, 8}]], TransformationFunction[...]] is not a > valid region to plot. >> What is the difference between a "valid region to plot" and a region that satisfies `RegionQ`? Or, perhaps, to put it better, am I seeing a bug in `RegionPlot` or just an incomplete implementation? I note that               RegionPlot[TransformedRegion[Rectangle[], RotationTransform[45 °, {.5, .5}]],        PlotRange -> All]      works as expected, so it would seem `RegionPlot` can handle rotations for some class of inputs.


title: What is the mathematical meaning behind D[f]?

text: y = a + b x;      I can understand this output of the ordinary differentiation of `y` w.r.t. `x`               D[ y, x]      > >     b >   but I don't understand the mathematical meaning of this output               D[y]      > >     a + b x >   In fact there is no matching usage of `D[f]` (with only single argument) in the _Mathematica_ documentation. Usually _Mathematica_ will flag up argument count mismatch when running, e.g. > >     "... called with m argument; n arguments are expected" >   Can anyone help me to understand the meaning of `D[f]`? Is this a bug or undocumented behavior in _Mathematica_?


title: How to get correct numerical integration which should be zero?

text: I want to numerically integrate function `berrycur` over kx and ky. The definition of `berrycur` is given at the end of the question. The plot of `berrycur[kx,ky,1]` is shown as follows: ![enter image description here](http://i.stack.imgur.com/sJW5C.png) and numerical integration               NIntegrate[      berrycur[kx, ky, 1], {kx, -((2 \π)/Sqrt[3]), (2 \π)/Sqrt[3]}, {ky, 0, (4 \π)/3}]      gives error message > NIntegrate::slwcon: Numerical integration converging too slowly; suspect one > of the following: singularity, value of the integration is 0, highly > oscillatory integrand, or WorkingPrecision too small. >> The correct answer should be zero. Since the function is abnormal at some places, the error message is forgivable. Then I define another function `berrycurtmp` which is               berrycursum[kx_?NumericQ, ky_?NumericQ] =       berrycur[kx, ky, 1] + berrycur[kx, ky, 2]      the plot of `berrycursum` is smooth now as shown in ![enter image description here](http://i.stack.imgur.com/bhuwG.png) But the numerical integration               NIntegrate[          berrycur[kx, ky, 1], {kx, -((2 \π)/Sqrt[3]), (2 \π)/Sqrt[3]}, {ky, 0, (4 \π)/3}]      still gives error message > NIntegrate::slwcon: Numerical integration converging too slowly; suspect one > of the following: singularity, value of the integration is 0, highly > oscillatory integrand, or WorkingPrecision too small. >> **why? And how could we get the correct answer zero?? And how to speed up this numerical integration?** * * * The definition of `berrycur` is here               Clear[h]     h[kx_, ky_] := {{0.01` +           0.1` (-4 Cos[1.5` ky] Sin[0.8660254037844386` kx] +              2 Sin[1.7320508075688772` kx]),          1 + 2 Cos[0.8660254037844386` kx] Cos[1.5` ky] -           2 I Cos[0.8660254037844386` kx] Sin[1.5` ky], 0,          0}, {1 + 2 Cos[0.8660254037844386` kx] Cos[1.5` ky] +           2 I Cos[0.8660254037844386` kx] Sin[1.5` ky], -0.01` -           0.1` (-4 Cos[1.5` ky] Sin[0.8660254037844386` kx] +              2 Sin[1.7320508075688772` kx]), 0, 0}, {0, 0,          0.01` - 0.1` (-4 Cos[1.5` ky] Sin[0.8660254037844386` kx] +              2 Sin[1.7320508075688772` kx]),          1 + 2 Cos[0.8660254037844386` kx] Cos[1.5` ky] -           2 I Cos[0.8660254037844386` kx] Sin[1.5` ky]}, {0, 0,          1 + 2 Cos[0.8660254037844386` kx] Cos[1.5` ky] +           2 I Cos[0.8660254037844386` kx] Sin[1.5` ky], -0.01` +           0.1` (-4 Cos[1.5` ky] Sin[0.8660254037844386` kx] +              2 Sin[1.7320508075688772` kx])}};     dim = Length@h[1, 1];          Clear[hpar1, hpar2];     hpar1[kx_, ky_] = D[h[kx, ky], kx];     hpar2[kx_, ky_] = D[h[kx, ky], ky];          Clear[purifyeigs];     purifyeigs[eigs_] :=        Transpose@Sort@Transpose@{Re[eigs[[1]]], eigs[[2]]};          berrycur[kxkx_?NumericQ, kyky_?NumericQ, i_] := Module[{eigs},       eigs = purifyeigs@Eigensystem[h[kxkx, kyky]];       Im@Sum[((Conjugate[eigs[[2, i]]].hpar1[kxkx, kyky].eigs[[2,                 j]])*(Conjugate[eigs[[2, j]]].hpar2[kxkx, kyky].eigs[[2,                 i]]) - (Conjugate[eigs[[2, i]]].hpar2[kxkx, kyky].eigs[[2,                 j]])*(Conjugate[eigs[[2, j]]].hpar1[kxkx, kyky].eigs[[2,                 i]]))/(eigs[[1, i]] - eigs[[1, j]])^2, {j,           DeleteCases[Range[1, dim], i]}]]


title: Increasing the precision of a calculation

text: Clearly I have misunderstood how to do this: I seem unable to _understand_ how to get more digits out of a calculation and I can't see why - the following piece of code illustrates the issue.               Block[{γ, vx, vy, vz, t0, t1},      t0 = γ (t1 - vx Sin[θ] Sin[ϕ] -           vy Cos[θ] Sin[ϕ] - vz Cos[ϕ]);      vx = vy = vz = 0.9/Sqrt[3]; t1 = 0.;      γ = 1/Sqrt[1 - (vx^2 + vx^2 + vx^2)];      Print[Minimize[{t0,          0 <= θ < 2 Pi, -Pi <= ϕ < Pi}, {θ, ϕ},         Reals]];      Print[N[Minimize[{t0,           0 <= θ < 2 Pi, -Pi <= ϕ < Pi}, {θ, ϕ},          Reals], 30]];      ]      Results: both print statements give               {-1.68585,{θ->6.28319,ϕ->0.7854}}      Now by semi-random fiddling I did find that changing line 4 to               vx = vy = vz = 0.9`30/Sqrt[3]; t1 = 0.;      produced plenty of digits in _both_ print statements - but moving the backtick to after the 3 or the 0. did not have the same effect. I naively thought that if I specified a certain precision in the calculation, Mma would work backwards and do everything necessary. How should I approach such issues? Would somebody please enlighten me - or hit me with the stupid stick? **Update** I sitill don't have a clear rationale for this, so I am still hopeful of some insight, but I have discovered that if I were to type               Print[SetPrecision[        Minimize[{t0,           0 <= θ < 2 Pi, -Pi <= ϕ < Pi}, {θ, ϕ},          Reals], 30]];      then I would get               {-1.68585446084501100472152756993,        {θ->6.28318530717958623199592693709,ϕ->0.785399718782704869823874105350}}      which is much closer to what I am trying to achieve. How do I do this for all calculations in a block or module - surely I don't have to specify this for each one? (and why doesn't N[...., precision] achieve this result??)


title: Visualize fixed points and stable points in 4D

text: I have a list of 4 dimensional data points which are sum to one and always positive. These points are the fixed points of the 4 dimensional nonlinear ODE. I also found the stable points of the system using fixed point analysis. (I found the Jacobian at the fixed points and looked at the eigenvalues to decide the stability). Now, I am trying to visualize the fixed points and stable points in 4D. I am not sure whether this is doable but at least I am trying to get 3 dimensional phase planes, trajectories or basin of attractions type graphs if it is possible. Let say as an example, I have the following data points:               {{ 0,0,0,1}, {0,1,0,0}, {0,0,1,0}, {0.0740741, 0.925926, 0, 0},      {1,0,0,0}, {0.444444, 0, 0, 0.555556}, {0.333333, 0, 0.154762, 0.511905},      {0, 0.483592, 0.491029, 0.0253783}, { 0.10009, 0.431624, 0.468287, 0},      {0.137688, 0.283838, 0.389616, 0.188858},      {0, 0.5, 0.5, 0}}      After the fixed point analysis I found that {0,0,1,0} and { 0.0740741, 0.925926, 0, 0} are only stable fixed points. For now, I would like to plot these points as I explained above. Any help will be greatly appreciated. Thank you so much.


title: How can I close a gap in a bar chart?

text: I have the bar chart below: ![enter image description here](http://i.stack.imgur.com/0VoMc.jpg) My code:               BarChart[{Labeled[{a760, c760, b760, d760}, "760" ],        Labeled[{a780, c780, b780, d780}, "780" ]},       ChartStyle -> {Blue, Red, Green, Black},       ChartLegends ->        Placed[{"65.5 ps", "274 ps", "16.8 ps", "2040 ps" }, {Right}],       BarSpacing -> {0, 1}]      The third entry of 780 is missing, so I used `Missing[]`. I want to attach the forth entry of 780 to the second entry of 780. The point is that the color of the forth entry must remain black because each color indicates a quality such as lifetimes.


title: Distributing value of variable to specific kernel

text: I want to distribute the value of a variable to a specific kernel in a parallel computing setup. Using `DistributeDefinitions` of course does the job, but it distributes the value to every active kernel, which is unnecessary and takes too much time. In my case I do have an array `a` and a listable function `f` operating on this array. A simple test scenario would be:               a = Table[Random[],{i,1000}];     f[x_] = x^2;      now I want to manually split up this calculation so that that each kernel has the same amounts of function calls to `f`, which would look schematically like this (I assume 1000/$KernelCount is an Integer):               handle = {};     For[i = 1, i <= $KernelCount, i++,            AppendTo[handle,             ParallelSubmit[{i}, f[a[[(i - 1)*1000/$KernelCount + 1 ;; i*1000/$KernelCount]]]]        ];     ];     test = WaitAll[handle];      Of course this does not work, because the kernels do not have any knowledge about `a`. I could use `DistributeDefinitions[a]`. But this is as mentioned before exactly what I do not want to, because each kernel only has to know about a certain part of `a`, so distributing the whole array `a` would be a waste of time. This is of course only a test scenario, the real scenario consists of way more data bundled in the array `a` and a more complicated function `f`, but the task remains the same. I thought of using `ParallelEvaluate` to distribute part i of `a` to kernel i, but I did not come up with a solution. Any hints are appreciated.


title: Inconsistent DistributionFitTest results?

text: In pondering this question, I used Mariana's function to generate the following data.               data = {356, 403, 49, 677, 109, 566, 111, 233, 189, 395, 72, 103, 394,     108, 255, 201, 197, 101, 112, 144, 262, 231, 171, 349, 522, 262,      189, 128, 97, 188, 285, 459, 182, 220, 301, 154, 243, 250, 199,      293, 141, 302, 64, 196, 106, 560, 115, 172, 54, 236, 183, 133, 218,     614, 111, 161, 310, 224, 134, 427, 130, 200, 380, 87, 430, 183,      800, 368, 210, 221, 105, 104, 78, 213, 103, 586, 395, 312, 384,      203, 141, 224, 107, 106, 172, 304, 141, 298, 250, 226, 268, 288,      108, 116, 347, 123, 622, 135, 223, 229, 79, 74, 144, 88, 130, 284,      272, 500, 310, 325, 247, 149, 612, 41, 100, 257, 229, 400, 486,      142, 140, 136, 56, 411, 489, 83, 142, 59, 108, 264, 108, 160, 347,      129, 137, 120, 100, 247, 117, 188, 121, 132, 316, 280, 336, 227,      197, 156, 397, 144, 101, 317, 624, 171, 189, 72, 276, 261, 102, 92,     131, 384, 256, 87, 109, 390, 97, 62, 172, 311, 188, 506, 239, 269,     403, 356, 268, 397, 214, 202, 321, 148, 120, 169, 74, 75, 235,      129, 90, 423, 514, 63, 233, 61, 82, 104, 167, 251, 198, 203, 316,      309, 310, 305, 743, 334, 95, 169, 185, 1074, 126, 278, 343, 857,      119, 80, 102, 92, 223, 151, 309, 127, 253, 346, 286, 240, 251, 413,     101, 158, 462, 77, 138, 333, 275, 223, 224, 123, 129, 251, 72,      225, 174, 237, 530, 110, 295, 153, 136, 183, 137, 79, 182, 187,      177, 152, 293, 165, 124, 118, 163, 154, 222, 111, 110, 67, 96, 269,     255, 190, 297, 72, 216, 129, 166, 83, 52, 252, 168, 82, 491, 208,      427, 470, 462, 110, 365, 465, 135, 131, 165, 166, 420, 190, 511,      928, 246, 349, 274, 184, 291, 145, 298, 470, 232, 302, 212, 182,      209, 730, 106, 105, 761, 91, 124, 244, 351, 119, 462, 101, 262,      233, 146, 512, 156, 138, 155, 76, 385, 168, 146, 430, 172, 208,      121, 170, 271, 206, 120, 233, 210, 953, 353, 186, 199, 221, 272,      494, 136, 292, 107, 265, 162, 235, 185, 214, 90, 167, 315, 238,      109, 102, 425, 713, 149, 438, 41, 247, 233, 145, 268, 580, 174,      115, 132, 99, 136, 140, 223, 149, 371, 520, 300, 301, 117, 69, 403,     143, 941, 107, 126, 234, 212, 139, 197, 558, 133, 45, 82, 91, 118,     554, 457, 340, 239, 600, 222, 136, 211, 182, 359, 171, 96, 161,      68, 181, 118, 171, 226, 121, 309, 222, 149, 95, 304, 177, 204, 194,     123, 129, 126, 160, 353, 108, 249, 170, 326, 620, 83, 252, 104,      134, 246, 154, 268, 152, 303, 143, 168, 422, 298, 186, 128, 97, 92,     316, 100, 182, 230, 198, 140, 217, 823, 371, 457, 122, 257, 207,      53, 260, 112, 190, 66, 244, 267, 98, 210, 276, 189, 61, 107, 123,      180, 93, 213, 207, 233, 155, 541, 339, 95, 314, 77, 314, 219, 609,      354, 121, 208, 272, 244, 201, 134, 428, 45, 214, 254, 115, 223,      145, 155, 287, 60, 138, 382, 132, 124, 218, 256, 255, 221, 142,      246, 116, 184, 275, 147, 161, 378, 156, 149, 492, 91, 143, 325,      181, 301, 275, 255, 240, 249, 578, 136, 177, 160, 107, 395, 151,      233, 149, 386, 38, 214, 243, 188, 582, 513, 176, 234, 87, 70, 130,      321, 123, 450, 125, 145, 594, 164, 600, 54, 335, 124, 310, 262,      470, 442, 338, 219, 73, 951, 158, 229, 139, 129, 364, 257, 231,      392, 468, 136, 157, 222, 108, 351, 306, 78, 121, 137, 347, 128,      239, 219, 92, 259, 213, 98, 151, 170, 202, 446, 336, 293, 174, 183,     100, 345, 203, 194, 280, 330, 251, 335, 202, 198, 371, 399, 241,      588, 527, 305, 621, 101, 124, 516, 311, 192, 228, 281, 127, 351,      116, 468, 126, 155, 237, 282, 470, 427, 150, 80, 438, 232, 180,      128, 482, 169, 224, 105, 362, 136, 135, 94, 137, 172, 292, 186, 91,     109, 144, 304, 184, 239, 285, 232, 89, 131, 376, 153, 298, 60, 97,     83, 583, 187, 338, 196, 75, 125, 161, 294, 115, 182, 51, 328, 232,     68, 339, 322, 171, 57, 331, 235, 113, 127, 176, 165, 240, 213,      310, 96, 250, 171, 221, 140, 115, 145, 186, 343, 188, 146, 226,      559, 103, 348, 272, 157, 156, 296, 218, 143, 306, 435, 150, 380,      121, 163, 213, 283, 155, 290, 156, 372, 212, 172, 120, 336, 280,      152, 101, 202, 325, 160, 98, 91, 259, 135, 209, 385, 210, 147, 214,     644, 102, 76, 576, 133, 52, 424, 187, 628, 421, 147, 211, 276,      468, 592, 99, 391, 302, 191, 441, 164, 136, 223, 212, 101, 122,      274, 198, 161, 648, 243, 210, 346, 330, 311, 123, 484, 183, 215,      450, 255, 680, 532, 569, 102, 97, 151, 321, 151, 164, 198, 289,      171, 103, 118, 172, 101, 340, 176, 206, 70, 233, 170, 190, 448,      339, 387, 33, 239, 295, 200, 131, 322, 111, 516, 313, 365, 203, 85,     134, 134, 191, 228, 270, 125, 80, 145, 272, 229, 106, 151, 117,      289, 120, 644, 140, 247, 133, 525, 232, 109, 243, 74, 152, 516,      311, 179, 247, 191, 308, 355, 102, 598, 382, 153, 108, 77, 197,      210, 200, 83, 86, 315, 304, 243, 329, 397, 282, 140, 578, 129, 211,     293, 219, 113, 471, 260, 160, 179, 341, 622, 311, 187, 175, 403,      140, 239, 258, 193, 358, 83, 241, 320, 457, 111, 206, 96, 179, 152,     158, 574, 199, 217, 189, 663, 336, 388, 258, 351, 362, 369, 155,      66, 230, 501, 247, 330, 383, 202, 567, 349, 117, 161, 524, 349,      197, 162, 121, 1005, 343, 325, 255, 59, 303, 79, 203, 505, 337,      607, 272, 170, 190, 129, 503, 780, 304, 243, 272, 146, 135, 689,      105, 287, 406, 119, 58, 466, 90, 194, 111, 69, 113, 262, 145, 95,      79, 93, 154, 272, 245, 238, 135, 65, 90, 209, 154, 455, 77};     plot1 = Histogram[data, Automatic, "PDF", Frame -> True,      PlotLabel -> "Histogram PDF"]      Now I specify a candidate symbolic Gamma distribution and use DistributionFitTest               candidatedist = GammaDistribution[a, b, c, d];     fittestdatatable =      DistributionFitTest[data, candidatedist, "TestDataTable",      Method -> Automatic]      DistributionFitTest[data, candidatedist, "TestConclusion"]      dist2 = DistributionFitTest[data, candidatedist, "FittedDistribution"]      pdf2 = PDF[dist2, x]     plot2 = Plot[pdf2, {x, 0, 1500}, PlotStyle -> Thick, Frame -> True,      PlotLabel -> "dist2 PDF", MaxRecursion -> 2, PlotPoints -> 1000,      PlotRange -> All];     plot3 = Show[plot1, plot2,      PlotLabel -> "dist2 vs Histogram Comparison"]      The resulting output tells me that it failed to converge within 100 iterations and that the fit is _rejected_ at the 5% level presumably due to the low P-value of 0.0409 via Pearson Chi Square. Yet the PDF/Histogram plot and the ProbabilityPlot both look good. Q1. Is there a way to use something like MaxIterations to go beyond 100 ? Q2. Did it truly "not converge" ? Next, I use the very parameters found (a,b,c and d) by DistributionFitTest to define a specific numerical Gamma distribution and repeat the analysis.               a = 7.22667435871025;     b = 4.0245321518298836;     c = 0.5170201479394287;     d = 31.933431399237044;     dist3 = GammaDistribution[a, b, c, d]     DistributionFitTest[data, dist3, "TestDataTable", Method -> Automatic]      DistributionFitTest[data, dist3, "TestConclusion"]      pdf3 = PDF[dist3, x]     plot5 = Plot[pdf3, {x, 0, 1500}, PlotStyle -> Thick, Frame -> True,      PlotLabel -> "dist3 PDF", MaxRecursion -> 2, PlotPoints -> 1000,      PlotRange -> All];     plot6 = Show[plot1, plot5,      PlotLabel -> "dist3 vs Histogram Comparison"]      Now Mathematica appears quite happy with the numerically defined Gamma distribution and produces a P-value of 0.9625 via Cramer-von Mises and reports that the distribution is _not_ rejected at the 5% level. And as before (and as expected) the PDF/Histogram and ProbabilityPlots look good and identical to the previous plots. Q3. Why is the same distribution first _rejected_ at the 5% level and then subsequently _not_ rejected at the 5% level? Which is the truth ? Thanks for any insight.


title: project moving point onto a line

text: The following code displays three solutions to the logistic ODE with an animated points that follow the solutions.. My goal is to project the solutions on to a vertical phase line. I need to be able to create a phase line of exactly length as the x-axis and have the projected solutions move appropriately. As you can see my projections do not lie on a fixed length copy of the x-axis. Additionally, I want to plot fixed points at x=0 and x=1 and be able to set any color I want to the fixed and moving points. The phase line needs to be closer to the tx-plot as well. Finally, I'd like to be able vary the parameter r and the initial value x0 in the solution formula (see Initialization code) Please help relieve my frustration.               Manipulate[           y1[t_] = y[t, 0.2, 2];      y2[t_] = y[t, 0.2, 0.1];      y3[t_] = y[t, 0.2, -0.01];           If[s == 20, s = 0];           GraphicsRow[{        Plot[{y1[t], y2[t], y3[t], 0, 1}, {t, 0, 20},          ImageSize -> {600, 400}, PlotRange -> {{0, 20}, {-1, 2}},          PlotStyle -> {{Thick, Black}, {Thick, Black}, {Thick,             Black}, {Thick, Black, Dashed}, {Thick, Black, Dashed}},          BaseStyle -> {FontSize -> 16}, Frame -> True, Axes -> False,          FrameLabel -> {t, x}, RotateLabel -> False, AspectRatio -> 0.75,          PlotRangePadding -> 0.1,          Epilog -> {PointSize[0.02], Red,            Point[{{s, y1[s]}, {s, y2[s]}, {s, y3[s]} }]}],             Graphics[{PointSize[0.02], Red,           Point[{{0, y1[s]}, {0, y2[s]}, {0, y3[s]} }]}]}       ],           {{s, 0, "FLOW"}, 0, 20, .01, ControlType -> Trigger,        AnimationRate -> 3,        AppearanceElements -> {"StepLeftButton", "StepRightButton",          "PlayPauseButton", "ResetButton", "FasterSlowerButtons"}},           FrameLabel ->        Style["One dimensional flow associated with logistic equation", 16,         FontFamily -> "Helv"],           Initialization -> (y[t_, r_, x0_] := 1/(1 + (1/x0 - 1) Exp[-r t]))      ]      ![Mathematica graphics](http://i.stack.imgur.com/Luynw.png)


title: Implementation of a Hanning filter

text: I'm implementing a package for in-house signal processing. I wrote here a quite trivial function implementing a Hanning windowing of the signal.               HanningFilter[signal_List] := Module[{length},        length = Length[signal];        Table[signal[[k]] 2 Sin[π k/length]^2, {k, 1, length}]     ];      I know there is a `HannWindow[x]` built-in function that can be use. However the question I have can be applied to other filters as well: > What is the most performant implementation of such a function? Probably the use of a `Table[]` is not optimal.


title: how to distinguish clockwise from counterclockwise rotation

text: I need to distiguish the true rotation of a vector (time dependent, solution of a system of two coupled differential equation) respect a fixed vector. As showed in the follow,neither `VectorAngle` nor `ArcCos` work, because they yeld only positive results (i.e. as a counterclockwise rotation). I'm sure (from physical reasoning that the correct result is the opposite).               sol1 = FullSimplify[        DSolve[{y'[t] == -3 y[t] - z[t], z'[t] == -0.6 z[t] + y[t],         y[0] == 0, z[0] == 1}, {y[t], z[t]}, t]];          {{Gy[t_], Gz[t_]}} = {-z[t], y[t]} /. sol1;          sol2 = FullSimplify[        DSolve[{vy'[t] == -3 vy[t] - vz[t],       vz'[t] == -0.6 vz[t] +  vy[t], vy[T] == Gy[T],       vz[T] == Gz[T]}, {vy[t], vz[t]}, t]];          {{VY[t_], VZ[t_]}} = Simplify[{vy[t], vz[t]} /. sol2];          ang[T_]= VectorAngle[{Gy[0], Gz[0]}, {VY[0], VZ[0]}];          Plot[ang[T], {T, 0, 8}, PlotRange -> Full]      You can see, if you compile the code, that the plot result is: ![plot-output, but it'is incorrect](http://i.stack.imgur.com/vAEYS.jpg) I can obtain the correct result if I put an overall minus sign in `VectorAngle`, but obviously this is an incorrect procedure. I show her the output just for say you what is the "correct" output (as I said previously, I motivate it by physical reasoning)![correct plot- output](http://i.stack.imgur.com/ifbEC.jpg)


title: Pass Real32 to Mathlink

text: I've written a Mathlink program that is called from Mathematica 9. It works very well but currently uses double precision numbers in the C++ function. I've already replaced them with floats in C++ and corrected the .tm files ArgumentTypes to `:ArgumentTypes: { Real32List, Integer, Real32 }` But when calling the function within Mathematica like `MyFunction[{1.,2.,3.},100,99.]` it just returns the input - therefor a data type missmatch occurs. Can anyone tell me how to pass the numbers as Real32? It's quite important to use 32 bit floating point numbers since I am doing calculations on a GPU that has a significatly better single precision performance. Thanks //template file:               void calc P((float *, int, int, float));          :Begin:     :Function:       calc     :Pattern:        Calc[a_List, b_Integer, c_Real32]     :Arguments:      { a, b, c}     :ArgumentTypes:  { Real32List, Integer, Real32 }     :ReturnType:     Manual     :End:


title: Manipulate - Flickering graphics

text: I am new to mathematica and was experimenting with NDSolve and doing a simple demonstration of orbital motion and Newtons laws. I put together the following code which all seems to work except the Graphics object at the origin seems to flicker/move ? I tried moving the graphics object that displays this object to the initialisation section but that doesn't seem to help. I've also tried trackedsymbols but that doesn't work either. Any ideas/suggestions much appreciated.               Module[{t,tfinal=20,x0=1.5,y0=1.0,xv0=0.2,yv0=0.5,range = {{-3,3},{-3,3}},eqs,sol,fx,fy},     eqs = {y''[t]+y[t]/(x[t]^2+y[t]^2)^(3/2)==0,x''[t]+x[t]/(x[t]^2+y[t]^2)^(3/2)==0,x'[0]==xv0,y'[0]==yv0,x[0]==x0,y[0]==y0};     sol = Flatten @ NDSolve[eqs,{x,y},{t,tfinal}];     fx[t_]:=x[t] /. sol;     fy[t_]:= y[t] /. sol;     Manipulate[     g =Graphics[{Red,PointSize[0.02],Point@ {fx[t],fy[t]}},PlotRange->range];     Show[p,g,p1],     {t,0,tfinal},     Initialization :> {p=ParametricPlot[{{fx[k],fy[k]}},{k,0,tfinal},PlotRange->range,PlotLabel->"Planetary motion"],p1=Graphics[{Blue,PointSize[0.03],Point[{0,0}]},PlotRange->range]}     ]     ]      ![enter image description here](http://i.stack.imgur.com/xUuAV.gif) Here's an `ImageDifference` of two adjacent frames of a screen recording of the animation: ![image difference of two frames](http://i.stack.imgur.com/QeNfn.png) The central dot has moved sideways...


title: Can Mathematica do symbolic linear algebra?

text: For instance, is there some way I can say "let A and B be arbitrary real $m\times n$ and $k\times m$ matrices, `Simplify[Transpose[Transpose[A].Transpose[B]]]`" and Mathematica would simplify it to `B.A`? I know I can set A and B to be matrices containing symbols (e.g. `A = Table[Subscript[a,i,j],{i,m},{j,n}]`), but results can get quite messy if the problem is more complex than `Transpose[Transpose[A].Transpose[B]]` **EDIT** : To answer @Searke and @Artes questions in the comments: I'm currently watching this Stanford online machine learning course. If you look at the lecture notes, pages 8-11, you see a some matrix calculations. I can follow these calculations with pen and paper, but I haven't found a way to derive e.g. this result from page 11 using Mathematica: ![enter image description here](http://i.stack.imgur.com/Jvlcc.png)


title: NDSolve: Normalizing at every step

text: Suppose I have an transport equation with an initial conditions:               sol = NDSolve[{D[y[x, t], t] - 4 D[y[x, t], x] == 0,                    y[x, 0] == 1/Sqrt[2 \[Pi]] Exp[-(x)^2/2],                    y[10, t] == 0},                    y[x, t], {x, -10, 10}, {t, 0, 5},                    MaxStepSize -> 0.1];     Plot3D[Evaluate[y[x, t] /. sol], {x, -10, 10}, {t, 0, 2.5},             PlotRange -> All]      ![enter image description here](http://i.stack.imgur.com/Nq2mJ.png) Suppose the packet is actually a probability distribution. The packet is moving to the left, and at some later time, part of the probability density goes out of the left boundary such that the sum of the probability density in the domain [-10,10] is less than 1. My question is, what should I do such that, at every time step, the sum of the probability density in the domain [-10,10] is 1?


title: Iterating Reads From a Text File and Writing the Results of Operation

text: I have a very large text (TSV) file. I am able to now read single line, thanks to StackExchange. I am able to read a part of that line using the part operator. I want to iterate through the whole file, each line, test a part of that line if it is equal to one of 100 possible integers, and write the line number to a text file. So in essence I have a very large array, say 9 x 20000000. For each of the 20000000 rows, I want to test column 8 for one of 100 possible integer values, and write all the positions a distinct integer appears into another data file. For example, 22 may appear in column {8} 22222 times, but at various non- adjacent rows in the array. I want an ascending list of all rows that each possible number appears, by moving on to 23 and make an ascending list of all the places it appears up until I iterate all the possible integers in column {8}, say to 122. I tried a nested For loop to read through all the possible rows, and then try to test column 8 of each row by looping through all the possible values. Wash, rinse, repeat. It doesn't quite work and I'm not sure why, but MMA seems to discourage this otherwise common technique in other programming environments. I have looked a while now and do not find a way to this in MMA using any of its purpose built functions. Testing the file would be easy enough to do if I could import the file, but MMA chokes on it. For some reason importing a 1GB TSV file requires 20GB of Virtual Memory + all the remaining free memory of my 16GB DRAM machine and 30 minutes. **If** it is able to complete this without crashing, in apparently a new 'feature' for version 9, this may suddenly be inexplicably dumped and all the variables reset without telling MMA to do so. I've long been perplexed by MMA not being able to read and store a large text file when other programs like UltraEdit do this with ease. It is what it is I guess. On another note, if I do not know how many lines (delineated by a new line or line feed) are in a file, how do I find that value without manually opening it and checking?


title: Why is left NumberPadding always applied in NumberForm?

text: I would like to display numbers like `9.0001` and `10.0001` in the fixed-width form of `xx.xxxx`. This seems like a perfect job for:               NumberForm[#, {6, 4}, NumberPadding -> {"0", "0"}] & /@ {9.0001, 10.0001}      But this returns `{009.0001, 010.0001}`, which has one extra leading zero. Reducing the number of digits doesn't fix this.               NumberForm[#, {5, 4}, NumberPadding -> {"0", "0"}] & /@ {9.0001, 10.0001}          {09.0001,010.0000}      Why is at least one copy of the left NumberPadding always being added, even when this makes the total number of digits exceed `n`, the desired total number of digits?


title: On elegant use of Inner and Outer on tensors

text: I have a collection of 5-element vectors each of which corresponds to an {x,y} location from a (20 x 21) grid. Because of that I represent that data as a (5 x 20 x 21)-sized tensor called `W`. I also have a set of 128 (5 x 5)-sized matrices which I've packed as a (128 x 5 x 5) tensor called `R`. I then want to compute for each vector in `W` and each matrix in `R` the product `Transpose[w].r.w` (which is a scalar) and obtain a (128 x 20 x 21)-sized tensor. Finally, I only care about the sum over the 128 matrices, which will be a (20 x 21)-sized matrix. I can compute that operation with the following command which leaves me very unsatisfied since it seems somewhat inelegant:               Total[Outer[#1.#2.#1 &, TensorTranspose[W, {3, 2, 1}], R, 2, 1], {3}]      It seems to me that there should be a way to not use `TensorTranspose`, and that the `Total` should be redundant if I were to use `Inner`. However I don't see a clean way to use level specifications to get the answer I want. Any ideas? (preferably ones that are efficient too!). If you have to know, this implements a 5-sensor broadband delay-and-sum beamscanner. `W` holds the steering vectors for each location to scan, and `R` are the covariance matrices for each frequency band. Thanks!


title: The Jacobi-Davidson method

text: Does any implementation of the Jacobi-Davidson method for _Mathematica_ exist? A highly parallelized version for sparse matrices would be of special interest.


title: Side-effecting an array in an association?

text: I'm working on some classical data structures (stack, queue, etc.) and want to mimic oo style in MMA. As a first attempt, I want to store an array in an Association, like this:               q = <|elems -> ConstantArray[Null, 4]|>      > >     <|elems -> {Null, Null, Null, Null}|> >   Later, I want to side-effect my array, like this               q[elems][[2]] = 42;      > Set::setps: q[elems] in the part assignment is not a symbol. >> Ahh, yes, of course, I need a symbol... Next attempt is this:               q = Module[{storage = ConstantArray[Null, 4]},       <|elems -> Hold[storage]|>]      > >     <|elems -> Hold[storage$1987]|> >                 In[4]:= ReleaseHold[q[elems]][[2]] = 42      > During evaluation of In[4]:= Set::setps: ReleaseHold[q[elems]] in the part > assignment is not a symbol. >> >   >   >      42 >   Oh, yeah, that's not going to work. I could do the following, but it's going to copy the array every time and defeat the purpose of implementing classical algorithms (that being "efficiency"):               q = <|elems -> ConstantArray[Null, 4]|>;     SetAttributes[setQ, HoldFirst];     setQ[q_, slot_, item_] :=       Module[{newElems = q[elems]},        newElems[[slot]] = item;        q[elems] = newElems;        q[elems]];     setQ[q, 2, 42]      > >     {Null, 42, Null, Null} >   It looks like I need some kind of variant of `Part` that doesn't evaluate a held symbol on its left-hand side -- a `PartHoldFirst`. I don't see a way to do this with stuff I know.


title: Sequence of data in 3D, joining the points

text: Let me just first say I am not actually trying to find a function for these set of data. All I am doing is joining the points to make a line. Basically let's say I have some data, which I cleverly will call/name them as 'data' in Mathematica.               data:= {{1,0,0},{2,4,7},{2,6,7},{0,0,23}}      Now plotting them. (FYI, these data points are randomlly chosen)               ListPointPlot3D[data]      I should get a plot, but of course they are all disconnected. What I want to do is to join them. Unfortunately `'Joined -> True'` does not exists in `ListPointPlot3D`, so I do not know how to join them Any ideas? **EDIT** At the moment, I have a recursion. I will just show you the table For instance               Table[x[n, t], {n, 1, 10}]       prints out a list of 10 data points in 3D. It will not work with `Graphics3D` **EDIT** I will write out exactly what I have > x[1, t_] := {0,0,0}; > > A[t_] := {{1, -t, 1}, {t, 2, 0}, {0, 0,t}} > > B[t_] := Inverse[A[t]]; > > x[n_Integer, t_] /; n > 0 := B[t].x[n - 1, t]; > > Table[x[n, t], {n, 1, 10}] I want to plot the points and join them in a curve. If possilbe I would even like to manipulate the plot. The range for $t \in [0,1]$ Everything updated


title: Why function cannot be defined inside For loop?

text: I have a following code (which is simplified version of what I am doing):               For[i = 1, i <= 5, i++,      f[x_] := Sin[x]^2        Print[{i, f[i]}]      ]      And the question is simple: why such thing doesn't work at all. It does not write any output, nor it prints anything, nor it displays any error. Just nothing.


title: How to export data to a plain text file?

text: I am preparing data used by a command line program. It requires data in a simpliest possible format:               value_x1 value_y1     value_x2 value_y2     ...         value_xN value_yN      For now I always need to use Python to process a datafile created in Mathematica that format, because Mathematica always adds quotes " or multiple blank spaces or tabs. How can I create a file in a format:               <value_x1><single_space_sign><value_y1><end_of_line_sign>     <value_x2><single_space_sign><value_y2><end_of_line_sign>     ...         <value_xN><single_space_sign><value_yN><end_of_line_sign>      `OpenWrite[]`, `Write[]`, `Export[,"Table"]` etc. produce files with additional characters, and therefore are useless without processing in Python. Edit: What if I needed to create a file in a format:               <value_x1><single_space_sign><some string character><value_y1><end_of_line_sign>     <value_x2><single_space_sign><some string character><value_y2><end_of_line_sign>     ...         <value_xN><single_space_sign><some string character><value_yN><end_of_line_sign>      Edit 2: Proposed answer:               dat = Table[{i, Sin[i]}, {i, 4}] // N;     Export["test.dat", dat]      produces file containing following data:               {1., 0.8414709848078965}     {2., 0.9092974268256817}     {3., 0.1411200080598672}     {4., -0.7568024953079282}      Which is useless.


title: CDF won't work but NB works

text: I converted a .nb with the following content to a standalone CDF but I get an error that says: "An unknown box name (N) was sent as the BoxForm for the expression. Check the format rules for the expression.". What is causing this?               DrawOdds[outs_] := 46/outs - 1     MinImpliedOdds[bet_, pot_, remStack_, outs_] :=       Module[{immediateOdds, odds, impliedAmt, percPot, percStack},        immediateOdds = (pot + bet)/bet; odds = DrawOdds[outs];        impliedAmt = If[immediateOdds < odds, bet (odds - 1) - pot, 0];        percPot = impliedAmt/(pot + 2 bet);        percStack = impliedAmt/remStack; {impliedAmt, percPot, percStack}]     Needs["Units`"]     DynamicModule[{bet = 230, pot = 380, remStack = 870, outs = 9},       Deploy[Style[        Panel[Grid[          Transpose[{{Style["bet", Red], Style["pot", Red],              Style["smallest remaining stack", Red], Style["outs", Red],              "implied amount", "% pot",              "% remaining stack"}, {InputField[Dynamic[bet], Number],              InputField[Dynamic[pot], Number],              InputField[Dynamic[remStack], Number],              InputField[Dynamic[outs], Number],              InputField[              Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[1]] // N],               Enabled -> False],              InputField[              Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[2]] 100 //                 N], Enabled -> False],              InputField[              Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[3]] 100 //                 N], Enabled -> False]}}], Alignment -> Right],          ImageMargins -> 10],         DefaultOptions -> {InputField -> {ContinuousAction -> True,             FieldSize -> {{5, 30}, {1, Infinity}}}}]]]


title: How to build a grid of integrand points and numerically integrate?

text: If I have some function I know numerically only, say f(x) and each point $x$ takes significant time to compute so I have them all stored in some file as f(1)=0.232423, f(1.1)=0.3243432,....Then is it possible to tell NIntegrate only sample on the grid x=1,1.1,1.2,1.3...... and try to integrate this function? Then is the best method to keep refining my grid (gathering more and more data in my file) until the result of integration stops changing?