Questions tagged [wolfram-mathematica]

Wolfram Mathematica is a computer algebra system and programming language from Wolfram Research. Mathematica has its own Stack Exchange site at https://mathematica.stackexchange.com/ and that site is the preferred place to ask questions about it.

Wolfram Mathematica is a computer algebra system and programming language from Wolfram Research. The programming language is a term-rewriting functional programming language strongly influenced by . Not to be confused with mathematics ().

Mathematica has its own Stack Exchange site. That is the preferred site for asking questions on this topic.

Tips for asking Mathematica questions

  • Include self-contained source code or a link to a notebook that illustrates the issue
  • Include relevant image, for a graphics related question

A chat room for the tag is available here. It is intended for discussion of some meta-related problems and perhaps some social activity.

Free Mathematica Programming Book


Don't forget to check out our little Tool Bag and add your favorite tricks there.

4457 questions
21
votes
3 answers

Is right-to-left operator associativity in R possible?

I'm new to R, and I just discovered I suffer from Bracket Phobia (see comment in the link). I like the way magrittr notation %>% works, because it avoids nested parenthesis in some situations, and makes code more readable. I came from Mathematica,…
Murta
  • 2,037
  • 3
  • 25
  • 33
20
votes
5 answers

Efficiently Working with (and generating) Large Text Files

As part of my work, I am working with very large text files and, in part, analyzing them for word and phrase frequency. I am running into difficulties of computing time, memory restrictions, and in extracting relevant information. For this program,…
canadian_scholar
  • 1,315
  • 12
  • 26
20
votes
2 answers

How to draw the classic state diagram using Mathematica?

Is it possible and practical for Mathematica to draw something like this (being created by Graphviz): This is the best that I can get (but the shape and style are not satisfying): Code: GraphPlot[{{A -> C, "go"}, {C -> B, "gone"}, {C -> D, …
Ning
  • 2,850
  • 2
  • 16
  • 23
20
votes
4 answers

Monitoring progress of a parallel computation in Mathematica

I'm building a large ParallelTable, and would like to maintain some sense of how the computation is going. For a non parallel table the following code does a great job: counter = 1; Timing[ Monitor[ Table[ counter++ , {n, 10^6}]; ,…
20
votes
2 answers

The best way to construct a function with memory

Good day, I have some very slooooow and complicated function, say f[x,y]. And I need to construct detailed ContourPlot of it. Moreover the function f[x,y] sometimes fails due to lack of physical memory. In such cases I have to stop evaluation and…
Alexey Popkov
  • 9,355
  • 4
  • 42
  • 93
20
votes
4 answers

Checking if a symbol is defined

Is there an easy way to check if there's a definition for x? I need a function that takes something of the form f,f[_] or f[_][_] and returns True if there's a definition for it To be really concrete, I'm storing things using constructs like…
Yaroslav Bulatov
  • 57,332
  • 22
  • 139
  • 197
20
votes
4 answers

Stable Sorting, ie, Minimally-Disruptive Sorting

Suppose I have a list of things (numbers, to keep things simple here) and I have a function I want to use to sort them by, using SortBy. For example, the following sorts a list of numbers by last digit: SortBy[{301, 201}, Mod[#,10]&] And notice how…
dreeves
  • 26,430
  • 45
  • 154
  • 229
20
votes
2 answers

iPython: Manipulate-like command

In Wolfram Mathematica, I can interactively modify the value of a parameter by using the Manipulate[] command. For example, Manipulate[n, {n, 1, 20}] shows a slider through which is possible to vary the value of n. Is there any simple way (i.e.…
19
votes
2 answers

How to evaluate a notebook from the command line?

How can we evaluate a Mathematica notebook from the command line (i.e. when running the kernel in command line mode)? Suppose we're working on a remote machine. I know it is possible to convert the notebook to an m-file, and evaluate that, but…
Szabolcs
  • 24,728
  • 9
  • 85
  • 174
19
votes
2 answers

Doing probabilistic calculations on a higher abstraction level

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…
Sjoerd C. de Vries
  • 16,122
  • 3
  • 42
  • 94
19
votes
9 answers

What is the best way to find the period of a (repeating) list in Mathematica?

What is the best way to find the period in a repeating list? For example: a = {4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2} has repeat {4, 5, 1, 2, 3} with the remainder {4, 5, 1, 2} matching, but being incomplete. The algorithm should be fast enough…
Arnoud Buzing
  • 15,383
  • 3
  • 20
  • 50
19
votes
2 answers

Is there a way around using [[ and ]] for Part in Mathematica?

Is there a way to avoid having to do ⋮[[⋮ to obtain those great looking brackets for Part? Is there a way for this to be done automatically after you ran a function or a definition ?
500
  • 6,509
  • 8
  • 46
  • 80
19
votes
4 answers

How to combine two lists to plot coordinate pairs?

I have read x-data (from text files) into list1, and y-data similarly into list2: list1 = { 0.0, 0.172, 0.266, ..} list2 = {-5.605, -5.970, -6.505, ..} How do I combine the two lists in order to plot points {0.0, -5.605}, {0.172, -5.970},…
user2375856
  • 191
  • 1
  • 1
  • 3
19
votes
1 answer

Mathematica running out of memory

I'm trying to run the following program, which calculates roots of polynomials of degree up to d with coefficients only +1 or -1, and then store it into files. d = 20; n = 18000; f[z_, i_] := Sum[(2 Mod[Floor[(i - 1)/2^k], 2] - 1) z^(d - k), {k, 0,…
18
votes
6 answers

Extract information from HTML using Mathematica

Is there an easy way to extract data from specific HTML tables using Mathematica? Import seems to be pretty powerful, and Mathematica appears to be capable of handling formats such as XML pretty well. Here's an example:…
C. E.
  • 10,297
  • 10
  • 53
  • 77