Mathematica 10 'Formatting Notebook Contents'

Mathematica 10 freezes while 'Formatting notebook contents'. This happens already during the startup of Mathematica and it takes a long time for Mathematica to recover. It can also happen when I am editing a Notebook or browsing the documentation. Especially the documentation is very slow. Is this somehow related to the Mathematica FrontEnd? Is anybody else struggling with problems like this? EDIT: I'm using 64 bit Windows 7


Request: Create a planar graph using Mathematica (at least v9)

Can someone please copy/paste the planar `Graph` given by _Mathematica_ (at least _v9_ ) for this graph:               Graph[{{1, 7}, {1, 3}, {1, 5}, {1, 6}, {2, 6}, {2, 7}, {2, 4}, {4, 5}, {4, 8},            {8, 5}, {8, 3}, {3, 6}, {3, 7}, {6, 7}}, GraphLayout -> "PlanarEmbedding"]      I would only need the output. I would do it myself but my program keeps crashing. If someone could do this easy copy / paste & a few clicks, I'd be highly appreciative. I'm redownloading _Mathematica_ right now, but it's urgent and the file is 2GB.


ContourPlot is slow and unwieldy and generates a large-data graphic

I'm constructing a single contour showing the points in a plane that satisfy a function. The general form is               ContourPlot[f[x, y] == 0, {x, 0, .5}, {y, 0.2, .5}]      The function `f` is an explicit but complicated formula that was generated from operations involving analytic integration and differentiation applied to a large algebraic function. It evaluates quite rapidly though, given values of its arguments. My problem is that the plot takes an unduly long time to generate, perhaps 5 to 10 minutes. Also, and this may be related, the graphic object that it produces has a very large amount of data associated with it -- if I copy it as text and paste it into Word, it exceeds 10,000 pages! The text looks like it is describing how the function is evaluated (it includes function calls that are part of the definition of f), rather than a simple list of data points and formatting information. If I try to Show the output, to combine it with other graphics, it takes a long time to generate, as if it is recomputing the graph again. Also, I get a "Reformatting notebook" message any time I touch the object (e.g., to select it), and this takes maybe 15 or 20 seconds to go away. The plot itself isn't particularly complicated: ![contour plot](http://i.imgur.com/Up78AsX.png) I can make a ContourPlot of a simple function (e.g., `x^2+y^2==1`) and it plots quickly, and cut/paste it as text into Word occupies less than two pages.


Why does Mathematica not simplify this expression?

Consider this simple example:               mytrans[expr_] :=       expr /. Ω1^2 + Δ^2 :> Ω^2          f =        FullSimplify[Sqrt[-Δ^2 - Ω1^2],         TransformationFunctions -> {Automatic, mytrans}, Assumptions -> #] &;          f /@ {{Δ > 0, Ω1 > 0, Ω > 0},           {Δ > 0, Ω1 < 0, Ω > 0},           {Δ < 0, Ω1 > 0, Ω > 0},           {Δ < 0, Ω1 < 0, Ω > 0},          {Δ ∈ Reals, Ω1 ∈ Reals, Ω > 0}}               (* {I Ω, I Ω, I Ω, I Ω, Sqrt[-Δ^2 - Ω1^2]} *)      Isn't the last assumption equivalent to the first four? Why doesn't it work? Or why does it work in the first four cases?


Manipulating lists with uneven amounts of entries

So I have a list like so               list={{a},{b,c},{d,e,f},{g,h}}      and the basic logic I want is to be able to manipulate each of the nested lists individually. So If I wanted to take the average of each list I would do something like               avglist=Table[(1/3) Sum[list[[n,j]],{j,3}],{n,4}]      But the problem with this is when the program would call `list[[1,2]]` So the gist is I am trying to write a program that could average/in general manipulate each of the nested lists of uneven lengths without having to know how many entries are in the list with the most entries. I can't just add zeroes into the nested lists with fewer entries because if I want to manipulate them first then average it would affect the average. Thanks


Find components which have intersections with designated lines

I have an image with several disconnected components, and I want to find all the components which have intersections with some designated lines which I generated previously. The image: ![enter image description here](http://i.stack.imgur.com/Pq6JZ.png) And the line is `{{{37.7754, 1001.}, {38.862, 0.}}, {{0., 442.679}, {832., 437.26}}}` The combined image looks like this: ![enter image description here](http://i.stack.imgur.com/8wUem.png)


Combining two plots which are in two regions

I want to combine two plots which are in two regions. For an example, I want to plot following two figures in the same plot.               a = Plot[Cos[x], {x, 0, 60}]     b = Plot[Sin[x], {x, 60, 90}]      Could anyone please tell me how to do this without using Piecewise function?


Generating a list of all factorizations

What is the best way to generate a list of all factorizations of some number $n$? I'm quite new to Mathematica so this might be obvious. I have been trying some basic stuff with `For`-loops and `FactorInteger` and `Divisors` but I'm not really getting anywhere. There must be some elegant way of doing this. An example of the result I'm after, for $n=60$: $$\{\{2,2,3,5\}, \{4,3,5\}, \{2,6,5\}, \{2,3,10\}, \{2,2,15\}, \{12,5\}, \{2,30\}, \{3,20\}, \{4,15\}, \{6,10\}, \{60\}\}.$$


Executing a .m file from the Linux command line

I have some code in a file named `Demo-3.m`, It can be evaluated in Mathematica 9. The final expression in the file is               Export[NotebookDirectory[] <> "fintempimg.jpg", fintempimg];      How can I execute `Demo-3.m` in Linux using the command-line? Please give me a solution with an example.


Learning Resources for Data Science in the Wolfram Language

I'm delivering an upcoming course on Data Science with the programming/analysis done predominantly in the Wolfram Language. I created the following table to leverage students' familiarity with Lists by way of introducing Associations by way of introducing Datasets. Juxtaposing the various invocations one can't help but be struck with the foresight or "naturalness" of the original language design and subsequent integrations - (IMO an extraterrestrial would be hard-pressed to predict the chronology of sequentially added features, and in particular, to note that all three didn't emerge simultaneously). My sense is that programming expertise in the Wolfram Language starts with an awareness of its existing (or "likely") functionality followed by inculcating and memorising its basic functional forms. While the documentation is essential for understanding all the details and an overall coherency, for quick reference/comparison/contrast, I think _cheatsheets_ could be more commonly deployed (with no doubt improved visual design - the code follows which could potentially be improved/combined with other users' cheatsheets into a larger, more powerful "Demonstration"?) At any rate, while an introduction involves becoming familiar with the basic syntax and manipulating structured datasets, the next stage involves applying these to some real-life examples. While there are good texts/datasets available (e.g. Luís Torgo's Data Mining with R: Learning with Case Studies) I'm wondering if anyone has found useful, available datasets from a variety of contexts (health, business, economics, ecology, physics, learning analytics) that might be particularly suitable for showcasing some of the benefits of data science in the Wolfram Language (this might be due to their size, unusual analysis, parallelizability, integration with curated data etc). ![](http://i.stack.imgur.com/YraKE.gif)               SetAttributes[{IOCells, DefCells, InsertIOCells, InsertDefCells},        HoldAll];               DefCells[Set[lhs_, rhs_]] := Row[{         ExpressionCell[Defer@lhs, "Input", ShowStringCharacters -> True,           FontSize -> 16],         ExpressionCell[" = ", ShowStringCharacters -> False,           FontSize -> 16],         ExpressionCell[lhs = rhs, "Input", ShowStringCharacters -> True,           FontSize -> 16]}];          (* Need to split in this way since a Defer wrapper seems to produce \     unexpected formatting - compare:     ExpressionCell[Defer[lhs=<|"a"\[Rule]8,"b"\[Rule]9,"c"\[Rule]10|>],\     "Input"]      ExpressionCell[Defer[lhs=\[LeftAngleBracket]"a"\[Rule]8,"b"\[Rule]9,\     "c"\[Rule]10\[RightAngleBracket]],"Input"]      *)          DefCells[R : Set[dataset, Dataset[{_}]]] := (R; Row[{          ExpressionCell[Defer@dataset, "Input",            ShowStringCharacters -> True, FontSize -> 16],          ExpressionCell[" = ", ShowStringCharacters -> False,            FontSize -> 16],          ExpressionCell["Dataset"[HoldForm[{assoc}]], "Input",            ShowStringCharacters -> False, FontSize -> 16]}]);          IOCells[expr_] /; !          FreeQ[Hold@expr,           Histogram | ListPlot | ListLinePlot | BarChart3D | BarChart |            PieChart | SmoothHistogram] := Grid[{         {ExpressionCell[Defer@expr, "Input",            ShowStringCharacters -> True]},         {ExpressionCell[expr, "Output", Magnification -> 0.41]}         }, Frame -> True, Alignment -> Left,         Background -> {None, {1 -> GrayLevel[.9], 2 -> White}}];               IOCells[expr_] := Grid[{         {ExpressionCell[Defer@expr, "Input",            ShowStringCharacters -> True]},         {ExpressionCell[expr, "Output"]}         }, Frame -> True, Alignment -> Left,         Background -> {None, {1 -> GrayLevel[.9], 2 -> White}}];          (* For the same reason above need a specific definition when <|  |> \     notation is in input *)          IOCells[R : KeySelect[assoc_, assoc2_]] := With[        {t = ToExpression@ToBoxes[assoc2]}, Grid[{          {ExpressionCell[HoldForm@KeySelect[assoc, t], "Input",             ShowStringCharacters -> True]},          {ExpressionCell[ReleaseHold@R, "Output"]}          }, Frame -> True, Alignment -> Left,          Background -> {None, {1 -> GrayLevel[.9], 2 -> White}}]];          IOCells[R : Dataset[expr_][op_]] := Grid[{         {ExpressionCell["Dataset"[HoldForm@assoc][op], "Input",            ShowStringCharacters -> False]},         {ExpressionCell[ReleaseHold@R, "Output"]}         }, Frame -> True, Alignment -> Left,         Background -> {None, {1 -> GrayLevel[.9], 2 -> White}}];          (* Since Dataset outputs as grid in the input - means copying \     expression from the grid and evaluating won't work *)               InsertDefCells[defs_List] :=        ReleaseHold@With[{t = Hold@defs}, Map[DefCells, t, {2}]];     InsertIOCells[exprLs_] :=        Sequence @@         Map[Row,          ReleaseHold@With[{t = Hold@exprLs}, Map[IOCells, t, {4}]], {2}];          ColumnHeadStyle[cheads_List] :=        ExpressionCell[#, Style[#, {Bold, 18}],           ShowStringCharacters -> False] & /@ cheads;               Block[{$PlotTheme = "Minimal"}, Grid[{        {"List", "Association", "Dataset"} // ColumnHeadStyle,        {ls = {7, 8, 9}, assoc = <| "a" -> 7, b -> 8, "c" -> 9 |>,           dataset = Dataset[{assoc}]} // InsertDefCells,        {          {{ls[[All]]}, {Values[assoc], Keys[assoc], Normal[assoc],             Lookup[assoc, "b", "No-b"]}, {dataset[1, Values],             dataset[1, Keys]}},          {{(Query@1)[ls], ls[[1]], ls[[2]]}, {assoc[["a"]], assoc["a"],             assoc[[Key@b]], assoc@Key@b,             Query["a"][assoc]}, {Query[1, Key["a"]][dataset],             dataset[1, Key["a"]]}},          {{ls[[3]], ls[[-1]]}, {assoc[[3]], assoc[[-1]], assoc[a],             assoc["b"]}, {dataset[1, 3], dataset[1, -1],             dataset[1, Key["d"]]}},          {{ls[[1 ;; 3]], ls[[1 ;; 3 ;; 2]], Take[ls, {1, 3}],             Query[Take[{1, 3}]][ls]}, {assoc[[1 ;; 3]],             assoc[[1 ;; 3 ;; 2]], Take[assoc, {1, 3}],             Take[assoc, {1, 3, 2}],             Query[1 ;; 3][assoc]}, {dataset[1, 1 ;; 3],             Query[1, 1 ;; 3][dataset]}},          {{Query[{1, 3}][ls], ls[[{1, 3}]]}, {Query[{1, 3}][assoc],             assoc[[{1, 3}]], assoc[[{"a", "c"}]],             KeyTake[assoc, {"a", "c"}]}, {dataset[1, {1, 3}],             dataset[1, {"a", "c"}]}},          {{Cases[ls, _?OddQ], Cases[_?OddQ][ls]}, {Cases[assoc, _?OddQ],             Cases[_?OddQ][assoc]}, {dataset[1, Cases[_?OddQ]]}},          {{Query[Select[OddQ]][assoc], Select[ls, OddQ],             SelectFirst[ls, OddQ]}, {Select[assoc, OddQ],             Select[OddQ][assoc],             SelectFirst[assoc, OddQ]}, {dataset[1, Select[OddQ]],             dataset[1, SelectFirst[OddQ]]}},          {{Position[ls, _?OddQ],             FirstPosition[ls, _?OddQ]}, {Position[assoc, _?OddQ],             Position[_?OddQ][assoc],             FirstPosition[assoc, _?OddQ]}, {dataset[1, Position[_?OddQ]],             dataset[1, FirstPosition[_?OddQ]]}},          {{PositionIndex[ls],             Query[PositionIndex][ls]}, {PositionIndex[assoc],             Query[PositionIndex][assoc]}, {dataset[1, PositionIndex]}},          {{Select[Keys@assoc, MemberQ[{"a", "c"}, #] &]}, {KeySelect[             assoc, MemberQ[{"a", "c"}, #] &],             KeySelect[assoc, <| "a" -> True, "c" -> True |>]}, {dataset[1,              KeySelect[(# == "a" \[Or] # == "c") &]]}},          {{f[ls[[3]]], Query[3, f][ls]}, {f[assoc[["c"]]],             Query["c", f][assoc]}, {dataset[1, "c", f],             dataset[1, 3, f]}},          {{f /@ ls, Map[f][ls], Query[Map[f]][ls]}, {f /@ assoc,             Map[f][assoc]}, {dataset[1, Map@f], dataset[1, All, f]}},          {{MapIndexed[f, ls], MapIndexed[f][ls]}, {MapIndexed[f, assoc],             MapIndexed[f][assoc]}, {dataset[1, MapIndexed[f]]}},          {{MapAt[f, ls, 2], MapAt[f, 2][ls]}, {MapAt[f, assoc, 2],             MapAt[f, 2][assoc],             MapAt[f, Key[b]][assoc]}, {dataset[1, MapAt[f, Key@b]]}},          {{MapAt[f, Normal@assoc, {All, 1}]}, {KeyMap[f, assoc],             KeyMap[f][assoc]}, {dataset[1, KeyMap[f]]}},          {{Reverse /@ Normal@assoc,             Association[f /@ Normal@assoc]}, {AssociationMap[Reverse,              assoc], AssociationMap[f, assoc]}, {dataset[1,              AssociationMap@Reverse], dataset[1, AssociationMap[f]]}},          {{Sort@ls, Sort[ls, Greater],             Query[Sort[#1, Greater] &][ls]}, {Sort@assoc,             Sort[assoc, Greater],             Query[Sort[#1, Greater] &][assoc]}, {dataset[1, Sort],             dataset[1, Sort[#, Greater] &]}},          {{Total[ls]}, {Total[assoc], Query[Total][assoc],             Query[Values /* Total][assoc]}, {dataset[1, Total],             dataset[1, All /* Total], dataset[1, Total@*Values]}},          {{Through[{Min, Max, Total, Variance, Median}@              ls]}, {Query[{Min, Max, Total, Variance, Median}][             assoc]}, {dataset[1, {Min, Max, Total, Variance, Median}]}},          {{Through[{Histogram, BarChart, SmoothHistogram, PieChart,                ListLinePlot[#, Filling -> Axis] &}@ls]},           {Query[{Histogram, BarChart, SmoothHistogram, PieChart,                ListLinePlot[#1, Filling -> Axis] &}][             assoc]}, {dataset[              1, {Histogram, BarChart, SmoothHistogram, PieChart,                ListLinePlot[#1, Filling -> Axis] &}] // Normal}},          {{Thread[Keys[assoc] -> ls]}, {AssociationThread[             Keys[assoc] -> ls],             AssociationThread[Keys[assoc],              ls]}, {dataset[              1, {AssociationThread[Keys@#,                  Values@#] &, (Keys@# -> Values@#) & /*                 AssociationThread}] // Normal}},          {{Thread[Keys[assoc] -> f /@ Keys[assoc]]}, {AssociationMap[f,              Keys[assoc]],             Query[AssociationMap[f]@*Keys][assoc]}, {dataset[1,              Keys /* AssociationMap[f]]}},          {{(f[#1, #2, #3] &)[Sequence @@ ls]}, {(f[#a, #1[Key[b]], #c] &)[             assoc], (f[#1["a"], #1[Key[b]], #1["c"]] &)[assoc]}, {dataset[             1, All /* (f[#a, #1[Key[b]], #c] &)],             dataset[1, (Apply@f)@*Catenate]}},          {{(f[##1] &)[Sequence @@ ls], (f[##2] &)[             Sequence @@ ls]}, {((f[##] &)[Sequence @@ Values@#] &)[             assoc]}, {dataset[1,              Values /* (Sequence @@ # &) /* (f[##] &)],             dataset[1, (f[##] &)@*(Sequence @@ # &)@*Values]}}          } // InsertIOCells        }, Frame -> True,        Dividers -> {Thick, {Thick, {None}, Thick}, {3 -> Thick, 8 -> Thick,           13 -> Thick, 19 -> Thick, 23 -> Thick, 25 -> Thick}},        Alignment -> {Center, Center},       Background -> {Automatic, {ColorData[17, 4],           LightBrown, {LightBlue, LightGreen}}},        ItemStyle -> {Automatic, {19}}, Spacings -> {1, {1, 1, 1, {0.5}}}]]


Zeta[-13] == Zeta[-1] == -1/12        Why do these two different zetas produce the same value?


Histogram3D using sums instead of counts

I'm trying to create a 3d histogram/ matrix plot pair. My data is in the form               {{TTR1,TBF1},{TTR2,TBF2},....}      What I would like is to modify the Histogram3D so instead of having the counts of each bin on the z axis I would have the sum of TTR in that bin. I would also like the modify the matrix plot in the same way. I've hacked an example in the help to get this far;               hist := Histogram3D[Log[10, dateFilter[[All, 2]]], {-4, 4, 0.25},      Function[{xbins, ybins, counts}, Sow[counts]],      AxesLabel -> {Style["TTR (log(hours))", 16],      Style["TBF (log(hours))", 16]}, ImageSize -> Large,      PlotLabel -> Style["Dryer 1 TBF and TTR Counts", 18],      ChartStyle -> RGBColor[27/255, 121/255, 169/255],      ViewPoint -> {Pi, Pi, 2}];     {g, {binCounts}} = Reap[hist];     mPlot := MatrixPlot[First@binCounts, ImageSize -> Large]     Row[{g, mPlot}]      In this case my data list is               dateFilter[[All, 2]]={{TTR1,TBF1},{TTR2,TBF2}....}      I would also like to fix this axis on the MatrixPlot so it has the same range labels as the histogram. Also is there a better way to do the log axes on the Histogram? I've just taken the Log of the data but it would be better if I could just modify the axes to show 1,10,100,.... ![enter image description here](http://i.stack.imgur.com/iKfOC.png) **Edit** I've re-plotted by data using kgulers code. The function I used was               Histogram3D[Log[10, dateFilter[[All, 2]]], {-4, 4, 0.25},      heightF[dateFilter[[All, 2]]][Total, First], styles,      AxesLabel -> {Style["TTR (log(hours))", 16],      Style["TBF (log(hours))", 16], Style["Sum TTR (hours)", 16]},      ViewPoint -> {Pi, Pi, 2}]       ![enter image description here](http://i.stack.imgur.com/oTIUD.png) It looks like my data has stratified into 3 groups of TTR (which may be what is really going on). I was kind of expecting the same plot with different z values but if that's what's going on then that's what's going on. Thanks kguler and belisarius. Give me a day to check that this is all ok and I'll tick this one off.


Plotting many tables in a single plot

I have several lists.               HeapSort = {6046.315617631054, 10120.421973039713, 20443.896966227818, 39888.26738991704, 409953.65081967216, 822796.7730263158, 1668210.1566666667, 3417061.523809524, 7231431.842857143, 1.58387906875*10^7, 3.3356646333333332*10^7, 6.99283795*10^7};     InsertSort = {1271.5641210832696, 2687.027971840069, 7428.082168377579, 26163.114593689497, 3480848.111111111, 1.7492152862068966*10^7, 7.876655514285715*10^7, 4.397160115*10^8, 2.19177605*10^9, 9.608922293*10^9, 4.5711371557*10^10,  2.88336011071*10^11};     MergeSort = {705.8025660136586, 757.6872519529326, 712.2989003537274, 712.1736108341547, 1059.3028590671972, 1497.1111723262381, 2410.7281094659293, 4422.600003538069, 10639.153797050876, 21691.320766994926, 45971.68456375839, 91827.67235996327};     QuickSort = {780.2510673824163, 899.0357995655863, 1229.733878841987, 2115.2551030336876, 46303.74590239837, 115050.7630004602, 271829.77228260867, 603560.328106152, 1342529.6916890081, 2965269.349112426, 6622509.02631579, 1.5045565676470589*10^7};     SelectionSort = {1626.7971290340422, 5189.992121652481, 17446.351430565246, 63880.23454266735, 6390999.493670886, 2.6850240684210528*10^7, 1.068697138*10^8, 4.399030115*10^8, 1.784892424*10^9, 7.214766123*10^9, 3.0060269881*10^10,  1.35096492432*10^11};     Num = {10, 25, 50, 100, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 128000};      They are tests I have performed with different sorting algorithms. I have the following code to put all of them in a single plot.               ListLinePlot[      {       Table[{Num[[i]], HeapSort[[i]]}, {i, 12}],       Table[{Num[[i]], InsertSort[[i]]}, {i, 12}],        Table[{Num[[i]], MergeSort[[i]]}, {i, 12}],       Table[{Num[[i]], QuickSort[[i]]}, {i, 12}],        Table[{Num[[i]], SelectionSort[[i]]}, {i, 12}]       },      PlotLegend -> {"Heap Sort", "Insertion Sort", "Merge Sort",         "Quick Sort", "Selection Sort"}, LegendPosition -> {1, -0.25},      PlotMarkers -> Automatic,      PlotLabel -> "Average Time of Heap Sort",       AxesLabel -> {"Test Number", "Nano Seconds"},      ImageSize -> Large      ]      For some reason, I can't get the plots to show up correctly. The x axis only goes up to around 80000. This is fixed when I remove all but one of the Table lists in the above code. If you guys could help me debug this code and figure out what's wrong.


How can I speed up this code with multiple sum？

There are 4 variables in this multiple sum, therefore it may take a long time. I have run this program for _12 hours_ , but no result untill now. I want to know how to speed up this code. Any help or suggestion will be highly appreciated! the code is bellow:               data = Table[Exp[-((i + j - 100.)/10)^2] Exp[-((i - j)/10)^2], {i, 100}, {j, 100}];     data = Chop[data, 0.00001];     data = data/Sqrt[Sum[(data[[i, j]])^2, {i, 1, 100}, {j, 1, 100}]];     ListDensityPlot[data, InterpolationOrder -> 0, Mesh -> All,       PlotRange -> All, ColorFunction -> (Blend[{Hue[2/3], Hue[0]}, #] &)]      ![Mathematica graphics](http://i.stack.imgur.com/dg7nv.png)               S1[i_, j_, k_, m_,         t_] := (data[[i, k]] data[[j, m]])^2 + (data[[j, k]] data[[i,             m]])^2 -         2 data[[i, k]] data[[j, m]] data[[j, k]] data[[i,            m]] Cos[(2 \[Pi]*(3*10^8)/(1584 - 5 + j*0.1 - 0.05) -              2 \[Pi]*(3*10^8)/(1584 - 5 + i*0.1 - 0.05)) t];     S2[t_] := 1/4*\!\(     \*UnderoverscriptBox[\(\[Sum]\), \(i = 1\), \(100\)]\(     \*UnderoverscriptBox[\(\[Sum]\), \(j = 1\), \(100\)]\(     \*UnderoverscriptBox[\(\[Sum]\), \(k = 1\), \(100\)]\(     \*UnderoverscriptBox[\(\[Sum]\), \(m = 1\), \(100\)]S1[i, j, k, m, t]\)\)\)\);     ListPlot[Table[S2[i], {i, -0.01, 0.01, 0.0001}], Joined -> True,       PlotRange -> All, Frame -> True]


Creating new functions using the names of existing ones

I have a list of functions                 {G[x_, y_], F[x_, y_], C[x_, y_]}       how I can create the list of new functions such as                 {dG[x_, y_], dF[x_, y_], dC[x_, y_]}


Wolfram Workbench 2.0 on Xubuntu 14.04 LTS trusty

I'm trying to install Wolfram Workbench on Xubuntu 14.04 but the apptication doesn't start. Knowing that WWb is a 32 bit application, I installed the i386 requrements:               ii  gcc-4.8-base:i386                         4.8.2-19ubuntu1                        i386         GCC, the GNU Compiler Collection (base package)     ii  gcc-4.9-base:i386                         4.9-20140406-0ubuntu1                  i386         GCC, the GNU Compiler Collection (base package)     ii  libc6:i386                                2.19-0ubuntu6                          i386         Embedded GNU C Library: Shared libraries     ii  libc6-i386                                2.19-0ubuntu6                          amd64        Embedded GNU C Library: 32-bit shared libraries for AMD64     ii  libgcc1:i386                              1:4.9-20140406-0ubuntu1                i386         GCC support library     ii  libgpm2:i386                              1.20.4-6.1                             i386         General Purpose Mouse - shared library     ii  libncurses5:i386                          5.9+20140118-1ubuntu1                  i386         shared libraries for terminal handling     ii  libstdc++6:i386                           4.8.2-19ubuntu1                        i386         GNU Standard C++ Library v3     ii  libtinfo5:i386                            5.9+20140118-1ubuntu1                  i386         shared low-level terminfo library for terminal handling      but when I run /usr/local/bin/WolframWorckbench the process start and stop after 1 second ! So checked with ldd:               root@lua:/opt/WolframWorkbench/2.0# ldd WolframWorkbench         linux-gate.so.1 =>  (0xf777d000)         libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf774a000)         libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf7745000)         libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7595000)         /lib/ld-linux.so.2 (0xf777e000)      If I check the execution with strace I can see a lot of errors on some system call:               root@lua:/usr/local/bin# strace -c /usr/local/bin/WolframWorkbench      [ Process PID=18919 runs in 32 bit mode. ]     % time     seconds  usecs/call     calls    errors syscall     ------ ----------- ----------- --------- --------- ----------------      26.56    0.000192          21         9           clone      14.11    0.000102           6        18           read      13.42    0.000097          11         9           wait4      11.48    0.000083           4        21           close       5.67    0.000041           5         9           pipe       4.84    0.000035           5         7           mmap       4.01    0.000029           3         9           rt_sigreturn       2.77    0.000020           5         4           mprotect       2.63    0.000019           6         3           open       2.35    0.000017           2         7           rt_sigaction       2.07    0.000015           5         3         3 access       1.94    0.000014           5         3           brk       1.80    0.000013           4         3           stat       1.11    0.000008           8         1           munmap       1.11    0.000008           4         2           chdir       0.83    0.000006           3         2           fstat       0.83    0.000006           3         2           fcntl       0.83    0.000006           3         2           geteuid       0.55    0.000004           4         1           faccessat       0.41    0.000003           3         1           getpid       0.41    0.000003           3         1           arch_prctl       0.28    0.000002           2         1           getppid       0.00    0.000000           0         2           execve     ------ ----------- ----------- --------- --------- ----------------     100.00    0.000723                   120         3 total     System call usage summary for 32 bit mode:     % time     seconds  usecs/call     calls    errors syscall     ------ ----------- ----------- --------- --------- ----------------      43.11    0.034557           3     10561           gettimeofday      15.03    0.012050           4      2803           read      12.63    0.010124           3      3004           _llseek       8.84    0.007088          12       583        19 futex       5.88    0.004711           4      1103       197 stat64       4.77    0.003821           6       693       513 open       1.46    0.001173           5       255        11 close       1.18    0.000944           6       154           mmap2       1.10    0.000879           4       222           fstat64       1.00    0.000798          13        60           getdents64       0.97    0.000774           4       173         1 lstat64       0.96    0.000767          24        32           getdents       0.57    0.000458           7        63           munmap       0.57    0.000454           6        74           brk       0.41    0.000325           7        50         3 openat       0.23    0.000186          19        10           clone       0.22    0.000177          20         9         3 unlink       0.20    0.000157           7        23           mprotect       0.17    0.000140           5        30        27 access       0.17    0.000137           4        34           fcntl64       0.14    0.000111           4        28           rt_sigaction       0.06    0.000050          25         2           write       0.04    0.000035           5         7           dup2       0.04    0.000034           4         9           rt_sigprocmask       0.04    0.000029          10         3           socket       0.03    0.000021           5         4           getcwd       0.02    0.000020          10         2         2 connect       0.02    0.000019           5         4           uname       0.02    0.000018          18         1           ftruncate       0.02    0.000018           4         5           getrlimit       0.02    0.000016          16         1           execve       0.01    0.000010          10         1           socketpair       0.01    0.000009           5         2           set_robust_list       0.01    0.000008           4         2           set_thread_area       0.01    0.000008           4         2           set_tid_address       0.01    0.000007           4         2           clock_gettime       0.01    0.000006           6         1           sched_yield       0.01    0.000005           5         1         1 mkdir       0.01    0.000005           5         1           getuid32       0.00    0.000004           4         1           setrlimit       0.00    0.000004           4         1           geteuid32       0.00    0.000004           4         1           gettid       0.00    0.000004           4         1           clock_getres       0.00    0.000003           3         1         1 getsockname     ------ ----------- ----------- --------- --------- ----------------     100.00    0.080168                 20019       778 total      Perhaps I'm missing something? Do I need to install others i386 library? Please can someone help me?


Why are graphics rendered as MathML when I set $PrePrint = MathMLForm?

For external usage, I set output in `MathMLForm` by using `$PrePrint=MathMLForm` Everything goes well but makes graphics rendered in `MathMLForm` as well. How could I make graphics rendered as image? > ![enter image description here](http://i.stack.imgur.com/WClu4.png) * * * New added: Thanks for @Kuba, But I am facing another problem when execute script like:               Table[Plot[f[x], {x, -2 Pi, 2 Pi}, Exclusions -> {1/f[x] == 0}],            {f, {Tan, Cot, Csc, Sec}}]      The final result is not a type of graphics, but it contains graphics. So it rendered in MathML finally. > ![enter image description here](http://i.stack.imgur.com/qOMsT.png)


Fitting data using a differential equation

I have data generated from two functions given below. How can I go about finding a fit of the form:               y'[x] == -(a + b/(c + d  y[x] + e F[x] ))      where a,b,c,d,e are to be determined?               F[x_] := If[x < 37.5, 2.80 + 0.0036 x, 117.86 - 6.314 x + 0.0865 x^2]          s = NDSolve[{y'[x] == -(0.0595 + 3716/(11780 + y[x])) y[x],         y[0] == 650000}, y, {x, 0, 60}]               data = Table[{x, Evaluate[y[x] /. s], F[x]}, {x, 0, 60, 1}]


FindRoot to find numerical solution of a given index

I want to find solutions of a system of multivariate nonlinear equations of a specific index (i.e., the no. of positive eigenvalues of the Jacobian evaluated at the solution). I know the FindRoot command can find numerical solutions. But it doesn't restrict the search to specific index of the solution.


Mapping a function of two arguments where the 2nd arg has a fixed value

I create three random images:               i1 = Image[RandomReal[1, {8, 12, 3}]];     i2 = Image[RandomReal[1, {8, 12, 3}]];     i3 = Image[RandomReal[1, {8, 12, 3}]];      I can scale a single image with               ImageResize[i1, Scaled[50]]      How can I map `ImageScaled` to all of them               ImageResize /@ {i1, i2, i3}      using the `Scaled[50]` argument?


How to create .ico file in Mathematica?

How to create .ico file in Mathematica? I mean the favicon images used for web sites. Directly using `Export["file.ico", <some graphical expression>]` does not seem to work.


How to set magnification of image to 75%

Right click on an output image, choose magnification. There are 25%, 50%, 100% etc. But how can I set to 75%?


Find the centre of FindGeometricTransform

I'm interested in using `Solve[]` to find the centre point of rotation (as an $x,y,z$ coordinate point) and axis of rotation (as a vector) from a `TransformationFunction` obtained by using the `Mathematica` function `FindGeometricTransform`. eg:               pts1 = {{-21.365, -1.61273, 2.41973}, {-41.0366, -4.33682, 4.78811},             {-18.1104, -20.673, 7.53}, {-19.804, 3.79904, 21.6102}};          pts2 = {{-17.9409, -3.2446, -7.46078}, {-35.9907, -7.76684, -14.7927},             {-14.3971, -22.658, -4.21113}, {-25.7926, -1.61099, 10.8609}};      `FindGeometricTransform` gives the transformation:               t = FindGeometricTransform[pts2, pts1][[2]]      I posted a similar thread at Mathforum under the topic: How to calculate the 3-D centre point of rotation given the angle of rotation and got the answer: > Then Solve will give you the fixed point, i.e. the centre of rotation: >   >   >      {x, y, z} /. Solve[t[{x, y, z}] == {x, y, z}, {x, y, z}][[1]] >   But when I try and use this get the following message: > During evaluation of In[928]:= RowReduce::luc: Result for RowReduce of badly > conditioned matrix > {{-0.438289,-0.152175,-0.114141,1.80057},{-0.196422,-0.022041,0.0708135,0.32083},{-0.12289,0.142966,0.458519,0.443714}} > may contain significant numerical errors. >> >   >   >     Out[928]= {-5.22037*10^14, 1.37944*10^15, -3.42994*10^14} >   the output is also wrong as the answer should be close to my guesstimate of:               approxCenterOfRotation = {0.05418732005730931`,1.3533759077820666`, -0.1590650885642857`}      However, for some reason I cannot reply to the post on Math Forum to get say that this solution didn't work. This problem can be visualised with the following (NB: I calculated the `axisOfRotation` vector using a different method [i.e. not using `Solve]`, but am still interested in a method using `Solve` to calculate this if possible...):               axisOfRotation(*normalised*) = {0.347494, -0.904472, 0.247341}          viewVector = axisOfRotation*100          Show[          Graphics3D[{Black, PointSize[0.01], Point[approxCenterOfRotation]}],          ListPointPlot3D[{pts1, pts2, t /@ pts1},PlotStyle -> PointSize[0.01]],          Graphics3D[{Blue,Line[{{pts1[[1]], pts1[[2]]}, {pts1[[1]], pts1[[3]]}, {pts1[[1]],       pts1[[4]]}}]}],          Graphics3D[{Purple,Line[{{pts2[[1]], pts2[[2]]}, {pts2[[1]], pts2[[3]]}, {pts2[[1]],pts2[[4]]}}]}],          Graphics3D[{Brown,Line[{{(t /@ pts1)[[1]], (t /@ pts1)[[2]]}, {(t /@ pts1)[[1]], (t /@pts1)[[3]]}, {(t /@ pts1)[[1]], (t /@ pts1)[[4]]}}]}],          Graphics3D[{Orange, Thick, Dashed,Line[{(approxCenterOfRotation +(axisOfRotation*20)),(approxCenterOfRotation + (axisOfRotation*-20))}]}],              PlotRange -> All, BoxRatios -> Automatic, AspectRatio -> Automatic,              Axes -> True, ImageSize -> 700, ViewPoint -> viewVector]      Any suggestions ? * * * Thanks for your solution Sjoerd C. de Vries, but I'm still having problems using it for a similar case:               pts1 = {{-4.1703933347009725`,          1.4117161073762858`, -1.9926556291047952`}, {-22.189270524165632`,          6.791481789144898`, -8.802808787459966`}, {-10.82311078603393`,      -17.22865684593722`, 0.8844690943141205`}, {-9.74367022928643`,          6.269145198021164`, 16.59077697323315`}};          pts2 = {{4.170393334702319`, -1.4117161073741804`,          1.9926556291087356`}, {-10.018009366114274`,          2.942544547202209`, -11.413672837383066`}, {-3.8405873454718273`,      -19.553858138726234`, 4.578554129848027`}, {-7.427598618275446`,          5.792664273078895`, 16.607151377933118`}};          t = FindGeometricTransform[pts2, pts1][[2]]          centreOfRotation = t[{0, 0, 0}]          rotMat = {t[[1, 1, {1, 2, 3}]], t[[1, 2, {1, 2, 3}]],        t[[1, 3, {1, 2, 3}]]}          {rotVec} = NullSpace[rotMat - Transpose[rotMat]];     rotVec          viewVector = rotVec*100          Show[      Graphics3D[{Orange, PointSize[0.02], Point[centreOfRotation]}],           Graphics3D[{Green, PointSize[0.025], Point[pts1[[4]]]}],      Graphics3D[{Green, PointSize[0.025], Point[pts2[[4]]]}],           ListPointPlot3D[{pts1, pts2, t /@ pts1},        PlotStyle -> PointSize[0.01]],       Graphics3D[{Blue,         Line[{{pts1[[1]], pts1[[2]]}, {pts1[[1]], pts1[[3]]}, {pts1[[1]],            pts1[[4]]}}]}],       Graphics3D[{Purple,         Line[{{pts2[[1]], pts2[[2]]}, {pts2[[1]], pts2[[3]]}, {pts2[[1]],            pts2[[4]]}}]}],       Graphics3D[{Brown,         Line[{{(t /@ pts1)[[1]], (t /@ pts1)[[2]]}, {(t /@ pts1)[[1]], (t /@               pts1)[[3]]}, {(t /@ pts1)[[1]], (t /@ pts1)[[4]]}}]}],      Graphics3D[{Orange, Thick, Dashed,         Line[{(centreOfRotation + (rotVec*20)), (centreOfRotation +      (rotVec*-20))}]}], PlotRange -> All, BoxRatios -> Automatic,       AspectRatio -> Automatic, Axes -> True, AxesLabel -> {"X", "Y", "Z"},       ImageSize -> 700, ViewPoint -> viewVector]      The orange point is the point calculated by `centreOfRotation = t[{0, 0, 0}]`, but looking at the graphic, the center point of rotation should lie closer to the two green points. Also, the axis of rotation (`rotVec`) looks incorrect. Any further suggestions?


How to evaluate an integral involving normal distribution

I want to compute the following integral, in which 5 can be replaced by any natural number. But I found Mathematica keep running forever and cannot evaluate it. I want to ask for some help.               Integrate[      Sqrt[5]/Sqrt[2 Pi] Exp[-5 x^{2}/2] 1/Sqrt[2 Pi] Exp[-y^{2}/2],       {x, -Infinity, Infinity}, {y, x - 1.96/Sqrt[5], x + 1.96/Sqrt[5]}]


Is there a function for falling factorial in Mathematica

If I had to construct a function for falling factorial in mathematica I'd do something like that (hope I'm not mistaken): > fallfact[x_,k_]:=$\prod_{j=0}^{k-1}(x-j)$ But is there a built-in function for falling factorial in Mathematica?


Convolve two sets of (x,y) data sets

I have two sets of data in the form               a={{.1,2},{.2,3},{.3,4},{.5,6}}          b={{0,8},{.1,4},{.2,7},{.3,1},{.5,10},{.6,3}}      Both data sets have even spacing, although the `b` dataset has significantly many more data points at higher and lower values of `x`. How do I convolve these data sets? `Convolve[a,b]` only works if I use just the `y` values of the datasets. Is there a way to convolve this data while still keeping these `x` values?


Recursion when randomizing elements in a list

I want to randomize certain elements of a list; Since the code               list = {a, b, c, d, e, f, g};     list[[{1, 3, 5}]] = RandomSample@list[[{1, 3, 5}]];     list      works fine, I was trying to see if I could speed up things a little bit and have only one call to `list[[{1,3,5}]]` using a pure function The code               list = {a, b, c, d, e, f, g};     (# = RandomSample@#) &[list[[{1, 3, 5}]]];     list      will trigger an infinite recursion. I know that the function evaluates the argument before passing to the function, but the infinite recursion still confuses me. Any thoughts? Thanks


Make Plot look like Bloomberg terminal

I've always wanted to make my financial `Plot`s look like a Bloomberg terminal. How would I go about making my chart look like one? I am talking specifically about the chart gradient background, the gradient plot fill, the dashed horizontal and vertical markers, and the markers on the right y axis. Here is the image I am using as a template: ![Bloomberg terminal](http://i.stack.imgur.com/H9RrG.gif) Any pointers would be appreciated!


Plotting the components of a function that returns a list in different colors without redundant evaluations of the function

I have a function `f` which takes a number as input, and returns a list of numbers (the length of the list is constant). `f` is hard to calculate (each evaluation takes a long time). I want to plot the different components of `f` in _different colors_. If I use this command:               Plot[f[x], {x, -2, 2}]      all the lines are drawn in the same color.   If I use this command:               Plot[{f[x][[1]], f[x][[2]], f[x][[3]]}, {x, -2, 2}]      (assuming the list has three components) the lines are drawn in different colors, but the function is called three times the necessary amount. Note that this is a numeric function, it cannot be evaluated with a symbolic argument (i.e. the function definition begins with `f[x_Real]:=`), so there is no use in using `Evaluate` like in this question.


vectorized operations is not efficient?

Consider the following example:               4.*Mean@Table[ Boole[Random[]^2 + Random[]^2 < 1], {10^6}] // AbsoluteTiming     (*{0.408023, 3.14105}*)          With[{n = 10^6},       4. Mean@Boole@Thread[(RandomReal[1, n]^2 + RandomReal[1, n]^2) < 1]] // AbsoluteTiming     (*{1.460084, 3.14276}*)      I expected the second method to be more efficient since it used vectorized operations, but it works slowly, and I don't know why. Is it possible to make it faster? I used Mathematica 9 on Windows 7.


Need to parallelize function f in a iteration

I don't have experience using Mathematica for parallel calculation. I need to do something simple to parallelize the calculation of f which is calculate each time n iterates:               f[k_] := Sum[r[j], {j, k}];     SetSharedFunction[f]           r[1] = 1;     f[1] = 2;          Table[r[n] = 2 r[n - 1] + f[n - 1], {n, 2, 4}]      Thanks for your help.


Item Resizing when using Locators

I am having some difficulty in resizing a Stream Plot when using locators: Whenever I try to resize the Stream Plot, one of the locators instead moves to the cursor.               Manipulate[{StreamPlot[{(      q1 (x - p[[1]]))/((x - p[[1]])^2 + (y - p[[2]])^2)^(3/2) + (      q2 (x - q[[1]]))/((x - q[[1]])^2 + (y - q[[2]])^2)^(3/2), (      q1 (y - p[[2]]))/((x - p[[1]])^2 + (y - p[[2]])^2)^(3/2) + (      q2 (y - q[[2]]))/((x - q[[1]])^2 + (y - q[[2]])^2)^(3/2)}, {x, 0,      10}, {y, 0, 10}, PlotRange -> {0, 10}]},      {{p, {1, 1}}, Locator}, {{q, {1, 1}}, Locator}, {q1, -4, 4}, {q2, -4,4}]      How can I rectify this behaviour?


Speeding up TIF import

After trying to import a $\approx 2$ GB TIF file with the Import command, I noticed that the process takes $\approx 15$ minutes or so, which seems excessive, especially when compared to other software packages. Attempting to load TIF files $>10$ GB in size can take over an hour. Surely there must be some trick to accelerate the import procedure? If not, can anyone explain to me why this is occurring? Perhaps it is generating an index of the individual images in some inefficient manner? I have a 64-bit system and I'm happy to use an arbitrary amount of memory - speed is what matters to me.


find connectivity

Imagine a chain of 20 rings, labeled by 1-20 sequentially. We want to make random size sets of numbers randomly chosen from these 1-20 rings. No duplicate numbers are allowed. Example of a set: $\{16,7,11\}$. We want to count the links between the members of different sets. Rules:   1. If we have got one number $N$ in set $A$ and next successive number $N+1$ exists in set $B$ this is called link of length $1$.   2. If the next successive number $N+1$ is not member of any set, we look for the closest successive number $N+m$ existing in other sets, so this is called a link of length $m$.   3. If the next successive number is also in the set $A$, then is a loop, we ignore it.   4. The two ends of the chain, if not member of any set, are dangled, we ignore it. Output = {the number of links of length i}. Example:               clusters = {{2,3,4}, {16,7,11}, {9,20,12,18}}      In `clusters` we have: 1 link of length 1 : `11-12` 3 links of length 2 : `16-17-18, 7-8-9, 9-10-11` 1 link of length 3 : `4-5-6-7` 1 link of length 4: `12-13-14-15-16` and `18-19-20` is a loop to same cluster and `1` is a free end so ignore them. How can I count the links to have:               out1 = {{1,length1}, {3,length2}, {1,length3}, {1,length4}}      Also we need to know the total number of links between two given cluster. for above example we will have:               out2 = {{cluster1-2, 1links},{cluster2-3, 5links},{cluster1-3,0links}}


Extracting only complete records from two data sets and combining them

I have two data sets:               data1 =     {       {{2004, 1, 1}, 28.0774}, {{2004, 1, 2}, 33.0775}, {{2004, 1, 3}, 33.6817},        {{2004, 1, 4}, 31.41}, {{2004, 1, 5}, 31.6763}, {{2004, 1, 6}, 28.255},        {{2004, 1, 7}, 29.4663}, {{2004, 1, 8}, 28.8583}, {{2004, 1, 9}, 27.3979},        {{2004, 1, 10}, 26.2367}, {{2004, 1, 11}, 25.9692}, {{2004, 1, 12}, 28.7213},        {{2004, 1, 13}, 27.405}, {{2004, 1, 14}, 27.6808}, {{2004, 1, 15}, 29.0129},        {{2004, 1, 16}, 28.65}, {{2004, 1, 17}, 27.6096}, {{2004, 1, 18}, 27.1733},        {{2004, 1, 19}, 30.3533}, {{2004, 1, 20}, 32.5442}, {{2004, 1, 21}, 35.2171},        {{2004, 1, 22}, 35.7233}, {{2004, 1, 23}, 31.0108}, {{2004, 1, 24}, 27.9142},        {{2004, 1, 25}, 26.8617}, {{2004, 1, 26}, 30.0146}, {{2004, 1, 27}, 30.4133},        {{2004, 1, 28}, 29.8754}, {{2004, 1, 29}, 29.8067}, {{2004, 1, 30}, 29.7713},        {{2004, 1, 31}, 27.4904}, {{2004, 2, 1}, 28.6221}, {{2004, 2, 2}, 30.9058},        {{2004, 2, 3}, 28.1475}, {{2004, 2, 4}, 27.0221}, {{2004, 2, 5}, 26.9771},        {{2004, 2, 6}, 26.5542}, {{2004, 2, 7}, 25.5142}, {{2004, 2, 8}, 25.7975},        {{2004, 2, 9}, 28.3658}, {{2004, 2, 10}, 30.0617}     }     data2 =     {       {{2004, 1, 2}, ""}, {{2004, 1, 5}, 33.71}, {{2004, 1, 6}, 33.54},        {{2004, 1, 7}, 33.57}, {{2004, 1, 8}, 34.27}, {{2004, 1, 9}, 34.38},        {{2004, 1, 12}, 34.92}, {{2004, 1, 13}, 34.26}, {{2004, 1, 14}, 34.62},        {{2004, 1, 15}, 33.61}, {{2004, 1, 16}, 35.16}, {{2004, 1, 19}, ""},        {{2004, 1, 20}, 36.21}, {{2004, 1, 21}, 35.53}, {{2004, 1, 22}, 35.12},        {{2004, 1, 23}, 34.94}, {{2004, 1, 26}, 34.41}, {{2004, 1, 27}, 33.99},        {{2004, 1, 28}, 33.63}, {{2004, 1, 29}, 32.86}, {{2004, 1, 30}, 33.16},        {{2004, 2, 2}, 34.02}, {{2004, 2, 3}, 34.2}, {{2004, 2, 4}, 33.06},        {{2004, 2, 5}, 33.26}, {{2004, 2, 6}, 32.49}, {{2004, 2, 9}, 32.91},        {{2004, 2, 10}, 34.03}     }      Sometimes values are missing and sometime both values and dates are missing. I need just the records that are complete and common to both data sets.               data = Transpose[{data1value, data2value}];     mixeddata = {{Date}, data1value, data2value};      How could I write the code for this?


Help to solve exponential equation over positive integers

I am trying to solve the equation $\frac{4}{9} = \big( \frac{1}{3} \big) ^n + \big( \frac{1}{3} \big) ^m $ with $n$ and $m$ both positive integers. I type into Mathematica the following In:= Solve[4/9 == 1/3^m + 1/3^n && m > 0 && n > 0, n, Integers] which spits out "Solve::nsmet: This system cannot be solved with the methods available to Solve." The solution to the problem is $n=1\:\&\:m=2$ or $n=2\:\&\:m=1$. How can I change my input to have Mathematica come up with this?


How do I test for the occurrence of an error message and act on it?

I want to see how well some curves fit a data set. If a curve doesn't fit after 100 iterations, I get the error `cvmit`. How do I test for and handle this error within my code?


Strange Behavior in Barchart LabelingFunction

BarChart formatting algorithm make me loose some time today in V10. Now, `LabelingFunction` do not work beyond some number of Labels. See example:               RandomSeed[1]     barchart[n_]:=         BarChart[RandomInteger[10,{n,3}]                 ,LabelingFunction->(Placed[#1,Center]&)                 ,AspectRatio->0.2,ImageSize->700                 ,ChartLayout->"Percentile"         ]          barchart[33]     barchart[34]      ![enter image description here](http://i.stack.imgur.com/kjN9m.png) After 33, labels disappear! Witch magic parameter can I change to get my labels back? The problem is the same in V10.0.0 for Mac and Win. I wrote to support. If I get some clue I'll post here.


How to properly substitute values into variables?

I have an array of functions in terms of a[0] through a[n] and I wish to replace the a[]'s with previously calculated values p[0] through p[n], as in below:               p = Table[Chop[NIntegrate[f[t]*wt[t]*Tn[t], {t, 0, 1}]/(Pi/2)], {n, 0, k}];     p[[1]] = p[[1]]/2;          s = Table[Coefficient[pmult[j], tstar[i], 1], {j, 0, k}, {i, 1, k}]          q3=s/.p      What is the best way of doing this? I have tried the Replace[], ReplaceAll[], and /. commands but none seem to be giving me what I want. I just want a[0] replaced with the number contained in p[0], a[1] replaced with p[1], etc. Thanks in advance!


Unknown limit of an array of area integrals

Could someone explain why Mathematica can't finish computing this limit (this is a limit of an array, when `n -> Infinity` (`n` is an integer), whose elements are area-integrals as shown):                Limit[Integrate[(x^(2n) + y^(2n)) Boole[x^(2n) + y^(2n) < 1], {x, -1, 1}, {y, -1, 1}], n -> Infinity]      In the case when `n=2`, the integral is `Pi/2`, for `n=4` it is `(2 Gamma[1/4] Gamma[5/4])/(3 Sqrt[\\[Pi]])` Thanx


Why is Query so much slower than Part?

Time for another of these(1),(2) as yet another new-in-10 function appears to have poor performance compared to older alternatives. This time: `Query` appears to be orders of magnitude slower than `Part` when used for simple extraction. For example:               Needs["GeneralUtilities`"]          x = RandomInteger[99, 1*^6];     spans = Span @@@ Partition[Sort @ RandomInteger[{1, 1*^6}, 5000], 2, 1];          Do[x[[s]], {s, spans}]      // AccurateTiming     Do[Query[s][x], {s, spans}] // AccurateTiming      > >     0.00447013 >   >     3.586205 >   Here `Query` is 800 times slower than `Part`. I know that `Part` is well optimized for packed arrays. Perhaps `Query` hasn't been similarly optimized yet. Let's try unpackable data:               x = "a" ~CharacterRange~ "z" ~RandomChoice~ 1*^6;          Do[x[[s]], {s, spans}]      // AccurateTiming     Do[Query[s][x], {s, spans}] // AccurateTiming      > >     0.0106673 >   >     3.594706 >   Alright, that seems to account for some of the difference as `Part` is only 337 times faster than `Query` here, but that is still a huge difference. The reason I was interested in `Query` is that by default it will not fail on out- of-bounds span ranges as `Part` will:               a = Range[9];          a[[5 ;; 11]]          Query[5 ;; 11][a]      > Part::take: Cannot take positions 5 through 11 in {1,2,3,4,5,6,7,8,9}. >> >   >   >     {1, 2, 3, 4, 5, 6, 7, 8, 9}[[5 ;; 11]] >   >     {5, 6, 7, 8, 9} >   It also returns a `Missing` expression for a single part that is out-of- bounds:               Query[12][Range@9]      > >     Missing["PartAbsent", 12] >   This feature is controlled by `PartBehavior`. Perhaps its overhead is high so let's turn it off and try again:               SetOptions[Query, PartBehavior -> None];     Do[Query[s][x], {s, spans}] // AccurateTiming      > >     3.568204 >   Well that doesn't seem to be the case. Thankfully Szabolcs's post in Why is Dataset upset by division by zero? made me take a look at the other options for `Query`. With `MissingBehavior` set to `Automatic` `Query` will apply special rules for certain operators when there are `Missing[]` expressions:               Query[Total] @ {1, 2, 3, Missing[]}       > >     6 >   This should have no role for `Span` however:               Query[2 ;; 4] @ {1, 2, 3, Missing[]}      > >     {2, 3, Missing[]} >   Let's turn it off and time again just to be sure:               SetOptions[Query, MissingBehavior -> None];     Do[Query[s][x], {s, spans}] // AccurateTiming      > >     0.355520 >   It seems we have found the cause of most of the slow-down, yet it makes no sense to me for this to have any effect as there is no special behavior to apply for `Missing` elements in a `Span` operation. With `FailureAction -> None` this comes down to `0.285016` second, or ~27 times slower than `Part` on unpacked data. ### Questions   1. Why would `MissingBehavior` affect the speed of a `Span` operation?   2. Why is `Query` still many times slower than `Part`, even with all special handling turned off?


Intersection of any triangle with a circle in Cartesian coordinates

I started a notebook dealing with metrics in a triangle and its intersection points by a circle. Up to know I reached the point of having plotted a triangle, a circle with an arbitrary centre and I know the coordinates where they intersect.   Before going further with adding more meaningful circles and more lines I would like to know if there is a better way of finding the coordinates of the points where the triangle intersects the circle.   Here is my code:               eqc[c_, r_] := {(x - c[[1]])^2 + (y - c[[2]])^2 -      r^2}  (*   c: {x,y} coord.centre  r: radius *)      a = {2, 4}; b = {7, 1}; c = {-1, -4}; (* triangle vertices *)     c1 = eqc[{5/2, 4/7}, 3]; (* expression for plotting the circle *)          fctline[a_, b_] :=      Reduce[Det[{{x, y, 1},  (*  Finds equation of a line between 2 points a{x,y} b{x,y) *)                  {a[[1]], a[[2]], 1},                 {b[[1]], b[[2]], 1}}] == 0, y];          lineA = fctline[c, b];  (* fct of line oposite vertex A *)     lineB = fctline[c, a];     lineC = fctline[a, b];          coordpts[c_, line_] :=      Module[{eqns},   (* module computing coords.      intersection of a line with a circle *)       eqns = {c == 0, y - line[[2]] == 0};       {x, y} /. Solve[eqns, {x, y}]];     trpts = Flatten[{coordpts[c1, lineA], coordpts[c1, lineB],      coordpts[c1, lineC]}, 1];          symbolsI = FromCharacterCode /@ (Range[Length@trpts] + 944);     symbolsV = {A, B, C};          plotA = Plot[{Transpose[(y /. Solve[# == 0, y]) & /@ c1]}, {x, -5,      15},  (* triangle to be added next step *)     PlotStyle -> {Black, Black, Black, Blue},     PlotRange -> {{-3, 8}, {-6, 6}}, PlotRangePadding -> 0.5,      AspectRatio -> Automatic,     Epilog -> {     {Red, PointSize[0.01], Point[trpts],      (Text[Style[#, 15], #2 + {-0.2, .2}] & @@@         Transpose[{symbolsI, trpts}])},     {Black, PointSize[0.001], Point[{a, b, c}],      (Text[Style[#, 20], #2 + {-0.3, .3}] & @@@         Transpose[{symbolsV, {a, b, c}}])}}]       To plot the sides of the triangle with lines strictly limited to the sides of the triangle I anticipated a rather repetitive process (ie plot nine segments of lines, six of them with a `Transparent` graphics attributes) but I found in Stack Exchange question 8199 a nice solution to deal with that with less code.               SetAttributes[splitplot, HoldAll];  (* thanks to Simon Woods *)     splitplot[pieces__] := Piecewise[{#}, I] & /@ Unevaluated@pieces     splitplot[{v_, c_}] := splitplot[{v, c}, {v, ! c}]     splitstyle[styles__] :=      Module[{st =      Directive /@ {styles}}, {{Last[st = RotateLeft@st], #}} &]          sideA = Plot[{splitplot[{lineA[[2]],        x < -1 || x > 7}, {lineA[[2]], -1 <= x <= 7}]} ,       {x, -2, 8},      PlotStyle ->      splitstyle[{Transparent, Black}, {Transparent, Black}, {Black}]];     sideB = Plot[{splitplot[{lineB[[2]],        x < -1 || x > 2}, {lineB[[2]], -1 <= x <= 2}]} ,       {x, -2, 8},      PlotStyle ->      splitstyle[{Transparent, Black}, {Transparent, Black}, {Black}]];     sideC = Plot[{splitplot[{lineC[[2]], x < 2 || x > 7}, {lineC[[2]],        2 <= x <= 7}]} ,       {x, -2, 8},      PlotStyle ->      splitstyle[{Transparent, Black}, {Transparent, Black}, {Black}]];          Show[plotA, sideA, sideB, sideC, Axes -> None, ImageSize -> 600]      As you can see I considered the triangle as a set of three lines. That's certainly not elegant but a triangle is not a locust of points than can be determined by a general function as for any conics, function that you can integrate or differentiate. There is perhaps a function for it in higher mathematics and if so may be a built-in (undocumented) in MMA is available.


Forcing Interpolation to be smooth at its boundaries

I'm looking at a piecewise function of two lines, which has a kink, such as:               f1[p_] := 1.41 * p + 2*^8;     f2[p_] := 1.45 * p + 1.9584*^8;     f3[p_] := Piecewise[{{f1[p], p <= 1.04*^8}, {f2[p], p > 1.04*^8}}];      I want to work with a function which is linear on both sides of the kink like above, but is smooth in a small region around the kink as an approximation to the above function. I'd like to use Interpolation[] to find a smooth function to approximate a region of width delta p around the kink, p = 1.04 * 10^8. However Interpolation can give me a function which will just introduce more kinks out the boundaries with f1 and f2. Is there a way I can enforce boundary conditions on Interpolation[] so that it can give me a smooth function in this region? Edit to clarify: The boundary I'm considering is arbitrary; it is just centered around 1.04*10^8. For example, I tried using a region of width .01*10^8 centered around this value, so my code was:               region = Interpolation[{{1.03*^8, f1[1.03*^8]}, {1.035*^8, f1[1.035*^8]}, {1.045*^8, f2[1.045*^8]}, {1.05*^8, f2[1.05*^8]}}];      But if you plot this, it will not be smooth with the rest of the function (i.e., it doesn't have a slope of 1.41 at p=1.03*^8, and 1.45 at p=1.05*^8. I want to enforce those slopes at those values, or any other arbitrary value).


Why does GraphicsGrid rescale 3d plots?

In the documentation for `GraphicsGrid`, it says > By default, GraphicsGrid will display graphics at their specified sizes So why does it rescale the 3d plots even if I have set the ImageSize option? For example:               GraphicsGrid@Table[Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, ImageSize -> 200], {2}, {2}]      gives the scaled 3d plots, regarding I have set the image size ![enter image description here](http://i.stack.imgur.com/NhhWM.png) while it doesn't rescale the 2d plots ![enter image description here](http://i.stack.imgur.com/Yh4hf.png) So why does GraphicsGrid rescale 3d plots?


How to define a nestable Baseform function, BaseForm output becomes BaseForm input

Mathematica won't change a number's BaseForm recursively:               63969 // BaseForm[#, 16] & // BaseForm[#, 8] & // BaseForm[#, 2] &      Well, I inspected former answers, most of them treated formatting problems, but none of the anwers given treated the nestable aspect. Maybe I'm wrong, and I risk a duplicate. (1) I would like to have a nestable function which allows constructs of the form               63969 // base@16 // base@8 // base@2      This feature might be adopted advantageously within iterative functions : NestList, FoldList, ... * * * ## Edit1 To explain my interest for seamless changes of baseforms               2 ArcCot[GoldenRatio^2^^1111] == ArcCot[2^^1010101010]     2^^1010101010 // BaseForm[#, 4] &      ![curiousSinCosMindmap](http://i.stack.imgur.com/b70Ms.gif) * * * ## Edit2 I tried myself another approch, but it has an disadvantage: `HoldForm` isn't respected               ClearAll@base     base[b_] := Function[# // ReplaceAll[#, BaseForm[x_, _] :> BaseForm[x, 10]] & //           ToString // ToExpression // BaseForm[#, b] &]          testsuite = {5555, BaseForm[5555, 8], HoldForm@Plus[5000, 555],5*BaseForm[1111, 2]}     base@10 /@ testsuite


Is there a built-in function to map a list of heads to a list of data?

Assume that this built-in function is called `func`. What I want is               func[{f,g},{a,b,c}]      will return the following result:               {{f[a],f[b],f[c]},{g[a],g[b],g[c]}}      I can achieve this by defining a function myself:               myfunc[functions_List, data_] :=          Table[Map[fn, data], {fn, functions}];      But is there some built-in function to achieve the same result? (I have to admit that, after months intermittent reading of `The Mathematica Book` my knowledge is still very limited compared with what exist unknown in the sea.)


InputField as part of a Graphics

I am building a model for which the user can enter parameter values. I would like to create a "graphical layout" of the model in which I display several InputField-s to enter the numerical parameters, arranged to be shown at the appropriate x-y-locations in my "graphical layout". However, InputFields appear to become non-editable when part of a Graphics object. For example, the following works (of course):               InputField[Dynamic[x]]      However, the next command creates an InputField that cannot be accessed, although the dynamic value still correctly updates when you change the InputField created by the previous command:               Graphics[Inset[InputField[Dynamic[x]]]]      How can I place InputFields at specific coordinates in (or on top of) a Graphics?


Functions returns Command Completion Output

Is there a function that returns the output as if you invoked Command Completion. To help clarify I am looking for a function that returns the Cell Data as if you invoked `Ctrl`+`Shift`+`K`.


How do I append a graph to last column of a table?

rmsdata= Partition[ReadList["RMStabledata.txt", Number],29]        > >     {{0, 2.96142, 36.7357, 9.05539, 9, 0, 0, 1, 1, 0, 2, -1, 1, -2, 2, -4, >      2, -3, 1, -5, 1, -7, 1, -6, 0, -7, -1, -9, -1}, {1, 2.68942, >     30.2974, 8.24621, 8, 0, 0, -2, 0, -4, 0, -5, 1, -7, 1, -6, 2, -8, >     2, -9, 1, -10, 0, -8, 0, -7, -1, -8, -2}, {2, 3.04704, 38.8905, 10., >     5, 0, 0, 1, 1, -1, 1, -2, 2, -4, 2, -3, 3, -2, 4, -3, 5, -5, 5, -6, >     6, -7, 7, -6, 8}, {3, 2.0943, 18.3723, 4.24264, 14, 0, 0, 1, -1, >     0, -2, -2, -2, -1, -1, -2, 0, -1, 1, 1, 1, 0, 2, -1, 3, -2, 4, -3, >     3}, {4, 2.97999, 37.1979, 10., 9, 0, 0, 2, 0, 4, 0, 3, 1, 5, 1, 4, >     2, 5, 3, 7, 3, 8, 4, 9, 5, 7, 5, 8, 6}, {5, 2.48083, 25.7801, >     7.61577, 7, 0, 0, 2, 0, 4, 0, 3, 1, 2, 2, 0, 2, 1, 3, 2, 4, 4, 4, 6, >     4, 5, 3, 7, 3}}   >                 sortedrmsdata = SortBy[rmsdata, #[[5]] &]            xydata = Partition[Flatten[Take[sortedrmsdata, All, {6, 29}]], 2]            gridedvalues = Take[sortedrmsdata, All, {1, 5}]            col = {SpanFromBelow, SpanFromBelow, SpanFromBelow, SpanFromBelow,         SpanFromBelow, SpanFromBelow};            Table[AppendTo[gridedvalues[[i]], col[[i]]], {i, 6}]  grided = Prepend[       gridedvalues, {"Number", "RMS displacement", "Volume",         "RMS end-end", "Interactions", "Graph"}]            Grid[AppendTo[       grided, {SpanFromAbove, SpanFromAbove, SpanFromAbove, SpanFromAbove,         SpanFromAbove,         ListPlot[Partition[xydata, 12], Mesh -> All,          MeshStyle -> PointSize[Large], Joined -> True,          PlotLegend -> Take[sortedrmsdata, All, 1]]}], Frame -> All]      Worked:               col ={ListPlot[Partition[xydata, 12], Mesh -> All,      MeshStyle -> PointSize[Large], Joined -> True], SpanFromAbove, SpanFromAbove, SpanFromAbove, SpanFromAbove, SpanFromAbove};     gridedvalues = Take[sortedrmsdata, All, {1, 5}];Table[AppendTo[gridedvalues[[i]], col[[i]]], {i, 6}];     grided = Prepend[gridedvalues, {"Number", "RMS displacement", "Volume", "RMS end-end", "Interactions", "Graph"}];     Grid[grided, Alignment -> Center, Frame -> All]


Exporting graphics without X server

I have a Mathematica installation on a Linux server that is intended to be used for batch processing. Some of the things that will be processed will include rendering of graphics. However, if I use `Export["/file/name.gif", graphicsobject]`, Mathematica wants to connect to an X server. Yes, I can run Xvfb or similar, but this seems like inordinate overkill. Is this really the only option? Is there no way to get Mathematica to render to GIF (or PNG, or BMP, or TIFF, or whatever; I don't really care) without having an X server running? _**Update:**_ I just ran this small program without an X server available:               s=Graphics[Sphere[]];     Do[         Print[fmt];         TimeConstrained[             Export["/tmp/img-"<>fmt, s, fmt],               10, Print["Timeout"] ],       {fmt, $ExportFormats} ]      and found that the only files created that contained something other than just the text `Graphics[Sphere[0, 0, 0]]` or `-Graphics-` were DXF and JVX, both of which were very simple renderings without axes or labels or anything once anything remotely more complex was rendered.


Solving a linear fourth-order fractional integro-differential equation

**Definition:** A real function $f(x)$, $x>0$ is said to be in space $C_\mu$, $\mu\in \Bbb R$ if there exists areal number $p$ ($>\mu$), such that $f(x)=x^pf_1(x)$, where $f_1(x)\in C[0,\infty]$, and it is said to be in the space $C^m_\mu$ iff $f^{(m)}\in C_\mu$, $m\in\Bbb N$. The Riemann-Liouville integral fractional operator of order $\alpha\geq 0$, of function $f\in C_\mu$, $\mu\geq -1$, is defined as $$J^\alpha f(x)=\frac{1}{\Gamma(\alpha)}\int_o^x(x-t)^{\alpha-1}f(t)dt,\quad \alpha>0,x>0,$$ $$J^0f(x)=f(x). $$ The fractional derivative of $f(x)$ in the Caputo sence is defined as $$D^\alpha_{*x}f(x)=\frac{1}{\Gamma(m-\alpha)}\int_0^x (x-t)^{m-\alpha-1}f^{(m)}(t) dt $$ for $m-1<\alpha\leq m$. $m\in\Bbb N$ and $f\in C^m_{-1}$. I wanna solve the following linear forth-order fractional integro-differential equation $$D^\alpha_{*x}y(x)=x(1+e^x)+3e^x+y(x)-\int_0^x y(t)dt,\quad 0<x<1, 3<\alpha\leq 4,$$ subject to the boundary conditions $$y(0)=1,\quad y''(0)=2.$$ $$y(1)=1+e,\quad y''(1)=3e.$$ For instance, the exact solution, when $\alpha=4$ is $y(x)=1+xe^x$. The recursive Adomian decomposition algorithm is $$y_0=1+Ax+x^2+\frac{1}{3!}Bx^3+J^\alpha(x+xe^x+3e^x),$$ $$y_{n+1}=J^\alpha y_n(x)-J^\alpha\left(\int_0^x y_n(t)dt\right).\quad n\geq 0. $$ where the constants $A=y'(0)$ and $B=y'''(0)$ are to be determined. I don't know how to write the code.               a=4     DSolve[{1/Gamma[m - a]*     Integrate[(x - t)^(m - a - 1)*D[y[t], {t, m}], {t, 0, x}] ==      x (1 + Exp[x]) + 3 Exp[x] + y[x] - Integrate[y[t], {t, 0, x}],      y[0] == 1, y''[0] == 2, y[1] == 1 + E, y''[1] == 3 E}, y[x], {x,0,1}]


How to remove a break line in coding

MySum[p_List, iMin_] := Module[{printOuput, i, iMax},        iMax = iMin + Length[p];        printOuput = "";        For[i = iMin, i < iMax, i++,         printOuput =           printOuput <> " + " <> ToString[i, TraditionalForm] <>            " \[CenterDot] " <>            ToString[Part[p, i - iMin + 1], TraditionalForm]];        Print[printOuput <> " = "];        Sum[Part[p, i - iMin + 1]*i, {i, iMin, iMax - 1}]];     p = 1/7 {3, 2, 0, 2};     MySum[p, 0]      This is my code.   1. I would like to have it in one separate line.   2. I would also like to remove the first "+", So the output will look exactly like this: $$0 \cdot \frac{3}{7} + 1 \cdot \frac{2}{7} + 2 \cdot 0 + 3 \cdot \frac{2}{7}= \frac{8}{7}$$


Triple fractional part-related integral

The evaluation with _Maple_ suggests the triple integral is around $1$, but Mathematica tells   it's $0.0958758$. When using the code               N[Integrate[FractionalPart[x/y] FractionalPart[y/z] FractionalPart[z/x], {x, 0, 1}, {y, 0, 1}, {z, 0, 1}]]      it returns: "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. >> NIntegrate::eincr: The global error of the strategy GlobalAdaptive has increased more than 2000 times. The global error is expected to decrease monotonically after a number of integrand evaluations. Suspect one of the following: the working precision is insufficient for the specified precision goal; the integrand is highly oscillatory or it is not a (piecewise) smooth function; or the true value of the integral is 0. Increasing the value of the GlobalAdaptive option MaxErrorIncreases might lead to a convergent numerical integration. NIntegrate obtained 0.09587582633950331`and 0.004696948831748114` for the integral and error estimates. >>" I'd like to know if Mathematica's approximation is correct, and if there is a possible closed form.


How can I get the exact solution of this equation (inequality equation)?

I want to solve the equation and inequality equation $$\sqrt{8\cdot 16^x - \dfrac{1}{2}\cdot 9^x }= 3\cdot 4^x - 3^x$$ and $$\sqrt{8\cdot 16^x - \dfrac{1}{2}\cdot 9^x } \leqslant 3\cdot 4^x - 3^x.$$ The correct of the given equation is $$-\log_{\dfrac{3}{4}}\left (3+\dfrac{\sqrt{30}}{2}\right ).$$ I tried               Reduce[Sqrt[8 16^x - 1/2 9^x] == 3 4^x - 3^x, x, Reals]      > >     x == Root[{2 + Sqrt[2] 3^-#1 Sqrt[2^(4 (1 + #1)) - 3^(2 #1)] - >      6 E^(2 Log[2] #1 - Log[3] #1) &, 6.0734320063313606675}] >   With inequality, I tried               Reduce[Sqrt[8 16^x - 1/2 9^x] <= 3*4^x - 3^x, x, Reals]      > >     x >= Root[{2 + Sqrt[2] 3^-#1 Sqrt[2^(4 (1 + #1)) - 3^(2 #1)] - >      6 E^(2 Log[2] #1 - Log[3] #1) &, 6.0734320063313606675}] >   How can I get the correct solution?


How can I make a heatmap of a days in year?

I know Mathematica has a ListPlot for time series but does it have a function for visualizing a list of dates as a heat map like this: ![enter image description here](http://i.stack.imgur.com/1Og85.png) This idea is from D3, check it out here.


Since installing mathematica 9 I can't import certain tiffs

I have a notebook written in Mathematica 8 in which I imported Tiff images and everything worked fine. Since I installed Mathematica 9, I get the error:               In[14]:= Files[[1]][[1]]     Import[Files[[1]][[1]],"TIFF"]     Out[14]= Growth_1_130124_1353/Growth_1_130124_1353_T0001.tif     During evaluation of In[14]:= Image::imgcsmis: The specified color space ColorProfileData[<>,Description->sRGB IEC61966-2.1,DeviceColorSpace->RGB,IndependentColorSpace->XYZ] and the number of channels 1 are not compatible. >>     Out[15]= Image[RawArray[Byte,<1024,1360>],Byte,ColorSpace->ColorProfileData[<>,Description->sRGB IEC61966-2.1,DeviceColorSpace->RGB,IndependentColorSpace->XYZ],Interleaving->None]      How can I solve it? Cheers, Andrea


Moving the location of the branch cut in Mathematica

According to the documentation, _Mathematica_ chooses the branch cut for $\log(z)$ to lie along the negative real axis. It it possible to change this so that it lies along the positive axis or elsewhere in the complex plane?


Installing Mathematica's package in Linux

I copied the package folder (ProPac, http://www.pages.drexel.edu/~hgk22/software/ProPac/ProPac.html) in `$UserBaseDirectory/Applications` in Linux mint. But when I called it by               <<ProPac`      the ouput is               Get::noopen: Cannot open ProPac`. >>     $Failed      I tried install it from File menu but appears the same error. But in Windows OS I have no problem with installation of this package and using it.


Finding face vertices from the face adjacency graph

I have a question about face adjacency graphs. Suppose that I have an adjacency matrix               M = {{0, 1, 0, 0, 1, 1, 0, 0},           {1, 0, 1, 0, 0, 0, 0, 1},            {0, 1, 0, 1, 0, 0, 1, 0},           {0, 0, 1, 0, 1, 0, 1, 0},           {1, 0, 0, 1, 0, 1, 0, 0},           {1, 0, 0, 0, 1, 0, 0, 1},           {0, 0, 1, 1, 0, 0, 0, 1},           {0, 1, 0, 0, 0, 1, 1, 0}}      that is known to be a planar graph. So I use the command `GraphPlot[M]` and give vertex labeling. The result is ![enter image description here](http://i.stack.imgur.com/UlwEa.jpg) There are 5 faces in the figure (exclude the outer face). The set of vertices of the faces is `{{1,6,8,2}, {1,6,5},{4,5,6,8,7},{3,4,7},{2,3,7,8}}`. I don't know how to find this list of vertices automatically if I enter any adjacency matrix (I'm sure that all picked matrices are planar graphs due to `PlanarGraph[M]`)


NSolve: Mathematica 9 issue

In _Mathematica_ 8 the following expression evaluates and returns a result in terms of `InverseFunction`:               NSolve[Integrate[x^(1/2)/(Exp[x - μ] - 1), {x, 0, ∞}] == C, μ]      where `C` is a constant. But in _Mathematica_ 9 the expression does not evaluate: > NSolve::nsmet: This system cannot be solved with the methods available to > NSolve. >> Is this a bug, a regression, or a feature? And how can this equation can be solved in V9? Particular, trying to solve this:               NSolve[PolyLog[3/2, 20 x] == 2, x]      In _Mathematica_ 8 and _Mathematica_ 9 gives different results: _Mathematica_ 8 (correct result):               NSolve::ifun: Inverse functions are being used by NSolve, so some solutions may not be found; use Reduce for complete solution information. >>     {{x -> 0.05 InverseFunction[PolyLog, 2, 2][3/2,       2.0000000000000000000000000000000]}}      _Mathematica_ 9:               NSolve::nsmet: This system cannot be solved with the methods available to NSolve. >>     NSolve[PolyLog[3/2, 20 x] == 2, x]      * * * **UPD:** That's a confirmed bug with `NSolve`, that I already reported to developers of Wolfram Mathematica long time ago.


Why I get the "Set::write: "Tag Times in is Protected." error?

Why I get the error below with this code:               Needs["VectorAnalysis`"]          ρ = 1000;     g = 9.80665;     μ = 0.001;     p[x_, y_, z_, t_] = {x^2, Sqrt[y], -z, t^3};     f[x_, y_, z_, t_] = {-x^2, Sqrt[y]/2, z, t^2};          ρ Dt[v, t] = -Gradient[p] + μ Laplacian[v] + f      * * * ## Error:               Set::write: "Tag Times in 1000\ Dt[v,t] is Protected."


Why does WordData fail to find "PartsOfSpeech" when given a list of two words?

I have the following sample code.               StringSplit["a test string", " "]     Thread[WordData[%, "PartsOfSpeech"]]      The output I get is:               {a, test, string}     {{Noun, Preposition, Determiner}, {Noun, Verb}, {Noun, Verb}}      If I change `"a test string"` to `"test string"`, then my code fails, giving the following:               {test, string}     {}      Can anyone tell me why this is and how to solve it?


Is there a Break[] equivalent for short-circuiting in Table?

I am running _Mathematica_ 7. The following is admittedly a silly example, but suppose that I have a list `list` whose entries are either `True` or `False`. Suppose that I have some function `truthFun[]` which evaluates randomly to either `True` or `False`. I would like to call `truthFun[]` and print `False` until `truthFun[]` evaluates to `True` for the first time. One way to do this is using a `For` loop. We can exit the loop "early" using `Break[]`. (As the documentation states, `Break[]` exits the nearest enclosing `Do`, `For`, or `While` loop.) For example, the following works:               truthFun[] := RandomChoice[{True, False}]          For[i = 1, i <= 10^8, i++,        If[truthFun[] === False, Print[False], Break[]]];     Print["Finished"]      > False > > False > > Finished However, it is often recommended that _Mathematica_ users avoid using loops (which are relatively slow in _Mathematica_ , I think). Is it possible to accomplish the above using `Table`, which is probably faster? I tried the following, but unfortunately it appears that `Break[]` does not work with `Table`:               truthFun[] := RandomChoice[{True, False}]          Table[If[truthFun[] === False, Print[False], Break[]], {i, 1, 10^8}];      > False > > False > > False > > Hold[Break[]] Also, _Mathematica_ gives me this error message: > Break::nofwd: No enclosing `For`, `While`, or `Do` found for `Break[]`. Is there an analogue to `Break` in `Table`? Thanks for your time.


Using NumberString, DigitCharacter, or a similar directive to find all string representations of integers in a string

I have a text file containing many, many lines of text like `test` in the following:               test = "word  123  456    7890.000      0.12000";      I would like to extract all of the "string representations of integers." However, I need to be clear about what I would like. In `test` above, I would like the output to be:               {"123", "456"}      since I am only interested in _actual_ , _isolated_ (delimited by spaces) string representations of integers. Yes, `7890` is an integer, but in `test` above, it is not isolated, so I do not want my function to return it (since `7890.000` is a decimal). In the case of `test`, I could use this:               StringCases[test, Repeated[DigitCharacter, 3]][[1 ;; 2]]      which returns               {"123", "456"}      However, this is not general, because my string may contain more than two string representations of integers. So I would like my function to also take this input:               test = "word  123  456  123    7890.000      0.12000";      and return:               {"123", "456", "123"}      I have thought about using `StringSplit` followed by `ToExpression` and `IntegerQ`, but this seems like it would be very (unnecessarily?) complicated. Perhaps Mathematica has something better built in that I can use? Do you have any advice? Thanks!


Text to speech in notebooks?

Mac OS, MMA 10 -- I accidentally discovered that typing `Ctrl``V` between cells reads out the cell below, or, if you have text selected, reads out the text. `Ctrl``V` would be _Edit > Paste_ on Windows, so the text-to-speech feature would be triggered differently on Windows, if it's present at all. I know there is a global Mac text-to-speech function ( _System Preferences > Dictation & Speech_), but I have it turned off. Just to be sure, I changed the global Mac text-to-speech voice to "Vicky", but the voice in MMA stayed on "Alex." That is evidence that I'm triggering a MMA special. Where is this text-to-speech configured; in particular, can I change the keyboard shortcut for it? It would be nice to explore if it has any other configurable features. I trolled the menus and the _Preferences_ dialog box for a hint, but didn't find one. MMA has a `Speak` built-in function, but that appears to be something else altogether.


Read a binary file to an image in memory then analyze it

Is it possible to read a whole file (~100 MBs) into memory, and then use BinaryRead[] function on the data loaded into memory to read/cast it to the types I need with a proper StreamPosition pointer? I need this because the process is very slow if I do it directly to files, so I prefer to have all manipulations done in memory, especially that I require many memory accesses with many BinaryRead[] calls. Thank you for any efforts.


FiniteFields package is very slow. Any fast substitute for Mathematica?

I want to compute the inverse of matrix, say with dimensions $100 \times 100$, defined over a large finite field extension such as $GF(2^{120})$. I am using the package **FiniteFields** , but Mathematica's computation time is exponential with respect to matrix dimensions. The following code illustrates the problem:               << FiniteFields`;     Table[         With[{ext = 12},            First@AbsoluteTiming@                Inverse[                    Array[GF[2, ext][RandomInteger[{0, 1}, ext]] &, {n, n}]                ]         ],         {n, 1, 11}     ]      I am using an Intel Xeon X5680 @ 3.33GHz (64-bit OS) and Mathematica v8.0.4.0. I have received the following timing results:               {0.0030, 0.0080, 0.0210, 0.0630, 0.1860, 0.5110, 1.3350, 3.3840, 8.9340, 23.0090, 57.4660}      I believe the source of the problem is that the **FiniteFields** package defines many UpValues, DownValues and SubValues of `Times` and `Plus` for head GF and, consequently, the pattern matching of arguments is degraded. Does anyone know if a patch for the **FiniteFields** package or a faster substitute providing a similar interface? Many thanks!


SyntaxForm not correctly parsed by FrontEnd

When using `TagBox` with `SyntaxForm`, I noticed sometimes it is not well parsed by the `FrontEnd`. Here is a minimal example. First input               TagBox["f", "test", SyntaxForm -> "^"] // DisplayForm      Then copy the output `f` to new input, and do some prefix or postfix operations. There is an error message. A screenshot is attached. ![enter image description here](http://i.stack.imgur.com/9ooAD.png) To debug further, one note that where there is a problem, in the saved file the cell is broken into more than one `RowBox`, for example:               Cell[BoxData[      RowBox[{       TagBox[        TagBox["f",         "test",         SyntaxForm->"^"],        DisplayForm],        RowBox[{"//", "ToBoxes", " ",         RowBox[{"(*", " ",          RowBox[{         "this", " ", "f", " ", "is", " ", "copied", " ", "and", " ", "pasted",           " ", "from", " ", "the", " ", "above", " ", "line"}], " ",          "*)"}]}]}]], "Input",      CellChangeTimes->{{3.618418507443947*^9, 3.618418516513115*^9}},      EmphasizeSyntaxErrors->True]      I am using Mathematica 10.0 on Linux x64. I have also tried `SyntaxForm->"a^b"`, or other operators. None of them work well. Am I doing anything wrong or is it a bug? **Edit:** As @WReach commented, I should have provided more details about my goal, otherwise why not go without SyntaxForm? And here is what I wanted (still a simplified version of the realistic case): typeset derivative in a good- looking way. The simplest implementation is               MakeBoxes[d[f_], StandardForm] :=       TagBox[GridBox[{{"\[PartialD]", ToBoxes[f]}}], "d"]      However, if I evaluate               d[f]^2      > ∂ f² This is not what I want (it evaluates correctly but does not look correct). Instead I want `(∂ f)²`. Note that here I could use `RowBox` instead of `GridBox` and then there is no such problem. But I do need `GridBox` in the realistic case because it is more feature-rich (I could use `RowBox[{GridBox[...], ""}]` to replace `GridBox[...]` as a workaround. But I hope there is a cleaner and less hacky way). Also the `Notation` package is not powerful enough for my actual need so I want to do it myself. I think the logical move to solve this problem is to use `SyntaxForm`. Indeed, if I define               MakeBoxes[d2[f_], StandardForm] :=       TagBox[GridBox[{{"\[PartialD]", ToBoxes[f]}}], "d2", SyntaxForm -> "^"]          MakeExpression[TagBox[GridBox[{{"\[PartialD]", f_}}], "d2", ___],        StandardForm] := With[{g = ToExpression@f}, HoldComplete@d2@g]      I get the desired `(∂ f)²` appearance for `d2[f]^2`. However, now the problem that I have described appears. If I evaluate `d2[f]`, and copy the output to new input and use, say, post-fix form of operators, it ends up with an error.


Label cell goes away with SelectionEvaluate

When a given cell has a label (given with the CellLabel->"label" option of the cell), then this label disappears after calling               SelectionEvaluate[ nb ]      when the contents of the cell is selected. Why is that? Is it possible to keep the label after evaluating its content (without making a new cell, so not using the               SelectionEvaluateCreateCell[]      command? Thanks for all help!


Creating a function with integral zeroes of the 0th, 1st, and 2nd derivatives

I would like to be able to randomly generate functions, each of which satisfies   1. $f : [-10, 10] \rightarrow [-10, 10]$   2. All the zeroes, critical points, and inflection points have an integral $x$-value   3. Some of the critical points -- $x$-values where $f'(x) = 0$ -- are local extrema, but some aren't   4. Some of the zeroes are also at local extrema (like $x=0$ in the function $y=x^2$), and some aren't It's easy to draw such a function by hand and then define a piecewise function that looks similar. The hard part, for me, is finding an algorithm that generates these functions with some randomness. I was approaching this by taking functions of the form $y=a (x-b)^2 + c$ and gluing them together so that the points and derivatives match up. (If the second derivatives don't match up, that's ok -- my Mathematica method will still identify the "gluing" points as inflection points.) This works fine if I'm only worried about critical points and inflection points, but seems to become very difficult when trying to respect the zeroes condition. Can anyone think of a tractable algorithm for this? EDIT: the randomness needs to be present beyond just, say, a scalar multiple. The goal is to show graphs of these functions to students and ask them to visually identify zeros / critical points / inflection points, and so different functions should correspond to usefully-different problems.


Treat list as cyclic

I am considering the following case. Say that `T={p1,p2,p3}` represents a triangle. In addition, I want to parameterize the edges of the triangle `T`. What I currently do is:               edgesT = {        t T[[1]] + (1 - t) T[[2]],        t T[[2]] + (1 - t) T[[3]],        t T[[3]] + (1 - t) T[[1]]};      This seems to be very naive, and I would like to learn how can I improve this. One, somehow obvious, way would be to have a cyclic list. Thus the question's title. **Is there a (smart) way to treat a list as cyclic?** Obviously, `T[[i]] = pi` for `i={1,2,3}`. It could be useful, for example in the example above, to enter `T[[4]]` and expect to have `p1` as an output. Is there some way to do it? **If not, how can I improve the definition above?**


Relative performance of the Julia language

I was just reviewing the _Mathematica_ benchmark code linked from the Julia language home page http://julialang.org/. The stated goal of the benchmarks is to test the performance of specific algorithms, expressed in a _reasonable idiom_ in each language, and all languages use the same algorithm. In particular, the Fibonacci benchmarks are all recursive, and the _Mathematica_ code reads               ClearAll[fib];     fib = Compile[{{n, _Integer}},          If[n < 2, n, fib[n - 1] + fib[n - 2]],         CompilationTarget -> "WVM"     ];      Now, dynamic programming is certainly a _reasonable idiom_ in _Mathematica_ :               fib[n_Integer]:= fib[n]= If[n < 2, n, fib[n - 1] + fib[n - 2]]      and this dynamic _uncompiled_ code will be much faster than the benchmark code, especially for large n (unless the WVM compiler is smart enough to do automatic memoization). The test only computes fib[20] and it would be most interesting to try say fib[100] in the various languages (the times for R, MATLAB, and OCTAVE are excessive even for n=20). It would also be useful, I think, for better coding of all the benchmark examples, if someone has the time and energy ...


Efficient way to build a certain quadratic matrix

For odd `n` I'm looking for a short and swift way to construct with (f.e.)               n = 3      ![enter image description here](http://i.stack.imgur.com/Z2DHG.jpg)               n = 11      ![enter image description here](http://i.stack.imgur.com/VHDYp.jpg)               n=1111      ![enter image description here](http://i.stack.imgur.com/Vk3zT.jpg)


How to make an efficient difference of sets function?

How to write a nice code that removes all elements from given set A, that occur also in set B? I would like to use `DeleteCases[]` for this purpose, but have no good idea how to make it efficient.               SetDifference[A_,B_]:=DeleteCases[A, ??? ]      Or to find out if theres a ready to use function already, as in Lists as Sets there is nothing like that mentioned.


Zero-dimensional matrices

In a recent _Mathematica_ project, $(n \times 0)$- and $(0 \times n)$-dimensional matrices have suddenly become a frustratingly common edge case for me. For instance, consider the following two situations, both common in linear algebra programming:   1. Suppose we have a matrix $A$, presenting a linear transformation $\newcommand{\R}{\mathbb{R}}\R^n \to \R^m$. The kernel of $A$ is a particular subspace of the source, $\R^n$, and if $A$ has a kernel of dimension $d > 0$, then `NullSpace[A]` produces a new matrix presenting a map $\R^d \to \R^n$ whose image is $\ker A$. This mode of thought is very useful; it lets you, for instance, restrict the action of some other map $B: \R^n \to \R^l$ to the kernel of $A$ by multiplication: `B.Transpose[NullSpace[A]]`.   2. Suppose we have a pair of matrices $A$ and $B$, presenting a pair of linear transformations $\R^n \xrightarrow{A} \R^l \xleftarrow{B} \R^m$ with a common target. The _pullback_ or _generalized intersection_ of these two maps is defined to be the collection of pairs of vectors $(x, y) \in \R^n \times \R^m$ with $Ax = By$. This, too, is easy enough to model in _Mathematica_ : the `NullSpace` of the block matrix $\left[\begin{array}{c|c}A & -B\end{array}\right]$ splits into a block matrix itself $\left[\begin{array}{c}P \\ \hline Q \end{array}\right]$. The matrices $P$ and $Q$ present the "largest nontrivial" maps into $\R^n$ and $\R^m$ respectively with the property that $AP = BQ$. While the mathematics continues to make sense, both of these run into serious difficulties when $0$-dimensional vector spaces get involved. This happens all the time in both situations (and, generally, in any situation where you might be applying `NullSpace` to a matrix with trivial kernel): because _Mathematica_ models matrices as lists of lists (with some exceptions, like `SparseArray`s, which have to support conversion to lists of lists anyway), it has real trouble modeling an $(n \times 0)$-dimensional matrix. For instance, `NullSpace[ IdentityMatrix[n]]` returns `{}`, which at first glance is reasonable enough but is totally unsuited for uniformly handling the above procedures. The expression `{}` is not $(n \times 0)$-dimensional in any sense, and so matrix multiplication, transposition(, inversion in the case $n = 0$), and so on all balk at using this as input. This is surmountable, of course, by riddling my _Mathematica_ code with conditionals that check for this failure output and handle it separately. This is uglier than it sounds (and it already sounds ugly); oftentimes this means passing around extra information to keep track of the `n` involved, since it's not recoverable from `{}`. > **My question is:** Is there a cleaner solution than a sea of conditionals? > Is there an idiomatic way to model $(n \times 0)$- and $(0 \times > n)$-dimensional matrices in _Mathematica_ , ideally in a way that's near- > seamlessly compatible with standard routines like `Times`, `Transpose`, > `ArrayFlatten`, ...? (P.S.: I eventually intend to offer this thing I'm writing as a package, and so I'd prefer not to modify the behavior of built-in functions directly.)


Intersecting graphics

Does the _Mathematica_ graphics system have any concept of intersecting graphics? I've not found much in the documents so far. For example, if I want to show the intersection of two shapes:               Graphics[{Rectangle[], Disk[{0.2, 0}, .5]}]      ![graphics without intersection](http://i.stack.imgur.com/Or0Ov.png) I know I can use `Opacity`:               Graphics[{Opacity[0.8], Red, Rectangle[], Green, Disk[{0.2, 0}, .5]}]      ![graphic with intersection](http://i.stack.imgur.com/hEOji.png) But is there a way of specifying the colours of intersecting areas directly? It doesn't seem to be possible to 'address' the intersecting shapes any other way. In the same vein, is is possible to 'extract' the graphical intersection of arbitrary shapes, without returning to the original geometry and calculating it? Could you obtain this type of entity easily given the above specification (these are just examples...!): ![the intersection](http://i.stack.imgur.com/YwZZ1.png) I think it might be easier with raster images, but am interested for now in vector graphics.


GatherBy Option to group results?

How can `GatherBy` be programmed to take an option to group results as follows:               data = {T0->1993-09-29,T1->1993-10-04,T10->1993-09-29,T11->1993-10-01,T12->1993-10-02,T13->1993-10-04,T14->1992-10,T3->1991,T4->1991,T7->1992-10,T8->1992-10,T9->1993-09-26}      `Column@(data2 = GatherBy[data, #[[2]] & ])` gives:               {T0->1993-09-29,T10->1993-09-29}     {T1->1993-10-04,T13->1993-10-04}     {T11->1993-10-01}     {T12->1993-10-02}     {T14->1992-10,T7->1992-10,T8->1992-10}     {T3->1991,T4->1991}     {T9->1993-09-26}      It's desired to optionally group into lists based on the common right-hand sides: `Column[ ((First /@ #) -> #[[1, 2]]) & /@ data2]`, which gives:               {T0,T10}->1993-09-29     {T1,T13}->1993-10-04     {T11}->1993-10-01     {T12}->1993-10-02     {T14,T7,T8}->1992-10     {T3,T4}->1991     {T9}->1993-09-26      And to do this not just for `Rule` expression arguments but for any argument and `GatherBy` test functions.


Mathematica "prelude"

Is there any way to have the functions from a mathematica file be loaded on startup? For example, in this excellent answer, Jens helps me out and gives me some functions for creating legends for plots. Instead of loading a file with those functions in it every time I load mathematica, can I instead put all the functions in a file and have them load every time I load mathematica?


Print documentation (or front end) with all Openers open?

From the online reference: http://reference.wolfram.com/mathematica/ref/Opener.html a JS function javascript:open_ES() is invoked to open all Openers within a section. Note (1) this feature is absent in the built-in MMA documentation center; (2) even online it selectively opens the EXAMPLES section (for Opener). Often I need to quickly overview all the sections including More Information, Options, Properties & Relations &c. Is there a way to program the documentation or even the Front End that contains Opener and Toggler to map them all to True? Perhaps a palette selection.


Strange behavior when using Row with packed arrays

Today I lost a lot of time with a strange behavior and I narrowed it down to this small piece of code:               a = {1, 2};     ToString@Row[DeleteDuplicates[a], ","]     ToString@Row[Union[a], ","]      > >     "Row[{1, 2}, ,]" >     "1,2" >   Can someone explain this bizarre behavior? Is this a bug? This is interesting too:               a = {1, 2};     l1 = DeleteDuplicates[a];     l2 = Union[a];     l1==l2     s1 = ToString@Row[l1, ","]     s2 = ToString@Row[l2, ","]     s1==s2      > >     True >     "Row[{1, 2}, ,]" >     "1,2" >     False >   There is some "memory" in `l1` created using `DeleteDuplicates`. **UPDATE** This bug was fixed in V10.0.0


Wolfram language from batch or py

I would like to automate the commands in this website into a batch file, so when the batch file it runs these commands in sequence. http://community.wolfram.com/groups/-/m/t/157461 Do any of you have any ideas. I know that you can just type in wolfram in a batch file like this:               #!/bin/bash     wolfram      It will give you this output:               Wolfram Language (Raspberry Pi Pilot Release)     Copyright 1988-2013 Wolfram Research     Information & help: wolfram.com/raspi          In[1]:=      How would you enter commands in the In[1]:= from a batch script? Thanks in advance. Ahmad EDIT I think this could help from http://reference.wolfram.com/language/guide/RaspberryPi.html               wolfram -script file.wl


Plotting and ContourPlot

> Make a `Plot` and a `ContourPlot` that gives the same diagram and use > `ContourPlot` on a quadruple of equations to make ![plot](http://i.stack.imgur.com/GvFwc.png) I am thinking that I need to show a parabola reflected across the x-axis, and two sideways parabolas, but I don't know how to create this picture.


Show List of HighlightGraph Objects in Matrix

I'm new to _Mathematica_ and can't get my problem solved. I want to display a list of `HighlightGraph` objects in `MatrixForm` like `GraphicsGrid`. This is my current tryout create a 3xn matrix               GraphicsGrid[      Table[# &, {3}, {(Length[graphLst] / 3) + Mod[Length[graphLst], 3]}]      ] /@ graphLst      This is the output. > ![Output](http://i.stack.imgur.com/oLyr8.png) I can't figure it out how to get this thing going. Can you lend me some help?


Text with specified FontSize looks smaller than expected

The simplest way to see what the post's title is trying to convey is to evaluate:               {"-0.5",       Text[Style["-0.5", FontFamily -> $DefaultFont[[1]],                FontSize -> $DefaultFont[[2]]]]}      On my Windows 7 laptop, at least, the first `0.5` looks larger than the second one. (The first one looks "right" to me somehow). My understanding is that `$DefaultFont` specifies the default output font, so I'm puzzled by the obvious difference (illustrated by this example) between text using the default output font, and text using a font explicitly set to match `$DefaultFont` (i.e., the first and second elements in the output of the evaluation above). Clearly my understanding is wrong somewhere, but I can't figure it out. Ultimately, I'm looking for a reliable way to specify the font size and font family of text elements in `Graphics` generated by `Plot`, etc. FWIW, I'm using version 9.0.1.0.


Confused about scoping, not sure what to ask

I'm grading for a class using Mathematica right now, and one of the students ran into a weird issue. When he ran code like this:               examplefun[n_] :=         SetDirectory["/Users/"];         Module[{output = ""},         Do[output = output <> RandomInteger[{1, 4}], {i, n}];         Print[output]]      He get's an error: Do::iterb: "Iterator {i,n} does not have appropriate bounds. " But if he moves Module up:               examplefun[n_] :=         Module[{output = ""},         SetDirectory["/Users/"];         Do[output = output <> RandomInteger[{1, 4}], {i, n}];         Print[output]]      The error disappears. I'm not sure what the problem is, though I suspect it has something to do with scoping. Could someone provide me with some insight here? Thanks! Edit: Ohhhhhhhh, that makes sense! Thanks for the prompt responses, everyone! I hadn't considered that his code didn't use the proper syntax for a multi- line function since I haven't used multi-line syntax before. I've accepted an answer, but thanks for all the responses!


Eastern European alphabet conversion from nb to PDF

When converting Eastern European alphabet written article from .nb to pdf, certain letters convert to empty rectangle like shapes or constructs, also hacek like letters (č,ć,ž,š,""...). Has anybody suggestion how to correct this?


How do I type boxtimes?

How do I type boxtimes in Mathematica, for example $a\boxtimes b$? This symbol is used a lot in mathematics, but I found no corresponding part in Mathematica. In TeX form, I can type \boxtimes. Can I make one in Mathematica, and type it in a simple way, like the following?               \[EscapeKey]b*\[EscapeKey]