wolfram-mathematica

Using Array and Table Functions in Mathematica. Which is best when

六月ゝ 毕业季﹏ 提交于 2019-12-02 17:10:06
I have been mostly a Table functions user in mathematica. However I have noticed that in several examples where I used Array instead of Table to express the same result, it ran markedly faster, especially as the dimension of table grew larger. So my question is this: When speed of execution is the primary concern, when is it most appropriate to use table? What explains this difference? My guess is that because Arrays assume a functional relationship between the items in the list, it stores them more efficiently, therefore use less memory, thus facilitating storage and subsequent processing? Is

Way to deal with large data files in Wolfram Mathematica

半腔热情 提交于 2019-12-02 16:50:03
I wonder if there exists way to work with large files in Mathematica ? Currently I have a file about 500Mb with table data. Import["data.txt","Table"]; What is alternate way? Use OpenRead["file"] which gives you an InputStream object on which you can use Read[stream] . Depending on the formatting of the data file you may need to set custom option values in Read[] for RecordSeparators . Example: In[1]:= str = OpenRead["ExampleData/USConstitution.txt"] Out[1]= InputStream["ExampleData/USConstitution.txt", 24] In[2]:= Read[str, Word] Out[2]= "We" In[3]:= Read[str, Word] Out[3]= "the" In[4]:= Read

Doing probabilistic calculations on a higher abstraction level

老子叫甜甜 提交于 2019-12-02 16:46:36
To the downvoters: this isn't a question about mathematics, it's a question about the programming language Mathematica . One of the prime characteristics of Mathematica is that it can deal with many things symbolically. But if you come to think about it, many of the symbolic features are actually only halfway symbolic. Take vectors for instance. We can have a symbolic vector like {x,y,z}, do a matrix multiplication with a matrix full of symbols and end up with a symbolic result and so we might consider that symbolic vector algebra. But we all know that, right out of the box, Mathematica does

Subscripted variables

别来无恙 提交于 2019-12-02 16:26:07
Is there any way to force Mathematica to treat subscripted variables independently of their unsubscripted counterparts? More specifically. Say, I have the following definitions: Subscript[b, 1] = {{1, 2}} Subscript[b, 2] = {{3, 4}} b = Join[Subscript[b, 1], Subscript[b, 2]] Now when I use Subscript[b, 1] Mathematica will substitute it with Subscript[{{1, 2}, {3, 4}},1] when I want these to be three independent values, so changing b will not affect Subscript[b, ..]. Is it possible? Simon In an answer to a previous SO question, Mathematica Notation and syntax mods , telefunkenvf14 mentioned that

Mathematica: How to obtain data points plotted by plot command?

非 Y 不嫁゛ 提交于 2019-12-02 16:00:02
When plotting a function using Plot, I would like to obtain the set of data points plotted by the Plot command. For instance, how can I obtain the list of points {t,f} Plot uses in the following simple example? f = Sin[t] Plot[f, {t, 0, 10}] I tried using a method of appending values to a list, shown on page 4 of Numerical1.ps (Numerical Computation in Mathematica) by Jerry B. Keiper, http://library.wolfram.com/infocenter/Conferences/4687/ as follows: f = Sin[t] flist={} Plot[f, {t, 0, 10}, AppendTo[flist,{t,f[t]}]] but generate error messages no matter what I try. Any suggestions would be

How to insert a column into a matrix, the correct Mathematica way

佐手、 提交于 2019-12-02 15:37:45
I think Mathematica is biased towards rows not columns. Given a matrix, to insert a row seems to be easy, just use Insert[] (a = {{1, 2, 3}, {4, 0, 8}, {7 , 8, 0}}) // MatrixForm 1 2 3 4 0 8 7 8 0 row = {97, 98, 99}; (newa = Insert[a, row, 2]) // MatrixForm 1 2 3 97 98 99 4 0 8 7 8 0 But to insert a column, after some struggle, I found 2 ways, I show below, and would like to ask the experts here if they see a shorter and more direct way (Mathematica has so many commands, and I could have overlooked one that does this sort of thing in much direct way), as I think the methods I have now are

Abstract algebra and Programming [closed]

為{幸葍}努か 提交于 2019-12-02 14:04:58
I am going to start learning Abstract Algebra- Groups, Rings,etc. I am interested to know any programming language, if at all which can help me learn/try the concepts I learn in theory. EDIT: I am not really looking at implementing what I learn. I am interested to know any language which already supports them. jason The text that you want here is Abstract Algebra, A Computational Approach by Chuck Sims. The author will recommend that you use the APL programming language. The book is out of print, but you can probably find it in your library. There is also the GAP Computer Algebra System which

Mathematica Module versus With or Block - Guideline, rule of thumb for usage?

女生的网名这么多〃 提交于 2019-12-02 14:03:26
Leonid wrote in chapter iv of his book : "... Module, Block and With. These constructs are explained in detail in Mathematica Book and Mathematica Help, so I will say just a few words about them here. ..." From what I have read ( been able to find ) I am still in the dark. For packaged functions I ( simply ) use Module, because it works and I know the construct. It may not be the best choice though. It is not entirely clear to me ( from the documentation ) when, where or why to use With ( or Block ). Question. Is there a rule of thumb / guideline on when to use Module, With or Block ( for

Density plot in Matlab

折月煮酒 提交于 2019-12-02 11:44:57
What is the Matlab's comparable function to Mathematica's ListDensityPlot ? For example ListDensityPlot[Table[Sin[x y/100], {x, -50, 50}, {y, -50, 50}], DataRange -> {{-50, 50}, {-50, 50}}] will produce Thank you. Matlab is different than Mathematica in the sense of vectorized computations vs symbolic computation. You could do what you'd like by defining a grid of spatial samples for x & y and then sample your function accordingly. For example: dx = 0.1; dy = 0.1; x = -50:dx:50; y = -50:dy:50; [xx, yy] = meshgrid(x,y); imagesc(sin(xx.*yy/100)); 来源: https://stackoverflow.com/questions/37380750

Programmatically creating multivariate functions in Mathematica

萝らか妹 提交于 2019-12-02 10:44:58
问题 This is a split from discussion on earlier question. Suppose I need to define a function f which checks if given labeling of a graph is a proper coloring. In other words, we have an integer assigned to every node and no two adjacent nodes get the same answer. For instance, for {"Path",3}, f[{1,2,3}] returns True and f[{1,1,2}] returns False. How would I go about creating such a function for arbitrary graph? The following does essentially what I need, but generates Part warnings. g[edges_] :=