Questions on writing non-trivial programs in Mathematica. Do not use this tag for questions on plotting/graphics or for questions on doing mathematics with Mathematica, where the focus is more on the math than the program.

learn more… | top users | synonyms

7
votes
2answers
415 views
5
votes
3answers
304 views

Question about modifying a Slider2D control

Background: I want to develop a custom control, based on a 2D slider. I currently have this ( working ) example. ...
6
votes
2answers
134 views

How do I access the name of a list in a function?

Background: bar := {1, 1, 1}; foo[var_] := {Hold[var], 2 var} SetAttributes[foo, HoldAll] foo[bar] Result, as expected: ...
30
votes
4answers
2k views

Finding a percolation path

I would like to examine percolation on a random lattice. To be exact, I wish to find the minimum length of a 'bond' needed such that the leftmost site can be connected to the rightmost site. Here is ...
8
votes
1answer
3k views

Mathematica Bifurcation

Continuing with the same question I have posted earlier I would like to find the equation of the stable fixed point curve using my graph, i.e. from the curve somehow find the equation for $x=f(x)$. I ...
27
votes
4answers
1k views

Question about collections of custom GUI controls for Mathematica

Background: I have only recently begun programming GUIs in Mathematica, so I have a continuous need for custom controls. I needed a scrollable list control and with the help of Google I found a ...
11
votes
1answer
312 views

Using Apply inside Compile

In this great answer a compiled version of the Nelder-Mead algorithm is presented. Since it works on arbitrary dimensions (i.e. arbitrary number of arguments), it has to use apply on the objective ...
4
votes
1answer
192 views

How to avoid conflicts between local variable names and symbolic arguments in Block constructs?

I am using Block inside the definition of some recursive functions. If the Block definitions use short variable names, like ...
1
vote
1answer
765 views

Iteration of a function

I have a function $f(x)=x^7+k$ I want to iterate $xn+1=g(xn)$, 50 times starting with $x0=1$ and keep the last 10 values I want to assign these values to a function ...
3
votes
3answers
361 views

How can I suppress Print in parallel evaluation?

When using a function that includes Print statements, one can suppress the output by ...
16
votes
1answer
326 views

Is pure pattern matching without PatternTest and Condition Turing-complete?

Note that this question is not a duplicate of that one. It is specifically about the pattern-matching engine, and explicitly excluding those patterns which call back into the full evaluation (i.e. ...
14
votes
2answers
978 views

Is Mathematica a Turing-complete language?

Is Mathematica a Turing-complete language? If so, how can that be proved? If not, why?
21
votes
2answers
354 views

What is the equivalent of a prototypical Manipulate in lower level functions?

Background: In the Mathematica tutorial 'Dynamic Interactivity' I read that there is a way of developing GUIs in Mathematica that do not use Manipulate. I want to ...
9
votes
1answer
287 views

How can I add row and column header images to my TableForm output?

I am experimenting with the Eigenfaces algorithm and have my notes and experimental data collected in a Mathematica notebook. The result of an experimental run is a table of scores, where the smallest ...
7
votes
2answers
192 views

Speed up Fourier for Booleans

I'm calculating a bit of the power spectrum of a two color cellular automaton using: ...
9
votes
3answers
412 views

Dealing with nested options

OptionValue allows for recent versions of Mathematica (I think as from 7) to easily access optional parameters if they are explicitely given to a function or their default values otherwise. For big ...
14
votes
3answers
741 views

Mathematica usage (success stories) for financial back-ends

I've been working for about 5 years in Java, developing financial back-offices (web-services, business logic, report generation etc.). I think Mathematica is very suitable for such calculations and ...
5
votes
2answers
476 views

Developing domain specific languages and computational knowledge engines using Mathematica

In one of Leonid Shifrin's excellent summaries, he mentioned that MMA capabilities include developing Domain Specific Languages (DSL). I'd like to develop a Health care IT application that can ...
26
votes
5answers
7k views

How to use Mathematica functions in Python programs?

I'd like to know how can I call Mathematica functions from Python. I appreciate a example, for example, using the Mathematica function Prime. I had search about MathLink but how to use it in Python ...
0
votes
1answer
394 views

How to solve a problem in relative motion?

I have a project due tomorrow that I have been struggling with for a month. I am utterly stumped, any help would be appreciated. The problem is: There is a ferris wheel, 30m in radius, set 80m ...
17
votes
2answers
2k views

Open Excel file with Mathematica

I would like to open an Excel file and manipulate it as a COM object. While I'm able to open an instance of excel with ...
10
votes
1answer
163 views

Figuring out how AbsoluteOptions works with Graphs

I am puzzled by how AbsoluteOptions works with Graph objects. I would have expected that one could use it to obtain all the ...
4
votes
1answer
90 views

How to take several values out of a large expression?

Background: Consider the following graphics directive. ...
56
votes
2answers
8k views

Is there an open source implementation of Mathematica-the-language?

I've seen questions before such as "What is the best open-source equivalent for Mathematica?", but that specific question (and that line of inquiry in general) cares more about the computer algebra ...
3
votes
2answers
91 views

How do Forms affect the interpretation of Expressions?

Below are three formats for representing an undirected edge between vertices a and b: ...
4
votes
1answer
397 views

Can a Table iterator “leak” into a Module?

I want to repeatedly call a module by using a Table statement. When I use an i iterator in the Table command calling the module, I receive the error message ...
8
votes
1answer
304 views

Why does Mathematica choose the second function definition?

While working on a solution to this question I've come across a case where I simply don't understand Mathematica's behaviour. I've got the following definitions: ...
19
votes
1answer
626 views

What is the proper method to load a Mathematica package inside a DynamicModule

I have a DynamicModule that requires loading of Mathematica packages. The usual methods do not seem to apply (...
13
votes
4answers
1k views

Is there a Mathematica/Lisp link?

I'd like to start learning Lisp as it sometimes leads to interesting answers on this site with concepts borrowed from this language, so I'm curious. As I already spend most of my programming time in ...
16
votes
2answers
352 views

When should I, and when should I not, set the HoldAll attribute on a function I define?

I have seen a number of examples on this site (such as in syntax highlighting and checking evaluation status) in which functions definitions are preceded with ...
21
votes
3answers
921 views

Finding a “not-shortest” path between two vertices

In designing a routine for making a simple three dimensional (5x5x5) labyrinth, I realized that my solutions (a solution is a labyrinth includes a single path from {1, 1, 1} to {5, 5, 5} in a 5 x5x5 ...
9
votes
1answer
457 views

GeoDirection and GeoDistance Memory Leaks: How to Recover the Memory?

The functions GeoDirection and GeoDistance have memory leaks. To see this, run the example functions below and watch as the Physical Memory Available in the Windows Task Manager, Performance tab, ...
9
votes
1answer
398 views

Mathematica implementation of Earth Movers Distance?

Has anyone implemented in Mathematica the Earth Mover's Distance (EMD)? A concept dating back to Monge 1871, used to compare histograms and images, e.g., the CIEDE2000 Color Difference algorithm. ...
8
votes
2answers
251 views

Cases[data,Colon[key,_]] vs. Cases[data,key:_] toward XPath, XQuery

Exploring methods to index and search tree-structured key:value pairs via named-entity index (key paths) as opposed to Position-based indexing. Using Rule as ...
4
votes
2answers
260 views

Repeatedly randomly redrawing part of a random sample that matches a certain criterion

I would need some (a lot of) help to improve/rewrite some code. Since my real problem is a bit too complicated to explain, I'll try to show a simplified scheme of what I want to achieve. I create ...
9
votes
1answer
361 views

Abort not aborting

I have a relatively simple bit of code that looks like the following: ---some code here--- If[statement, Abort[]]; ---more code following--- However, while ...
10
votes
1answer
585 views

Modifying a List in a function in place [duplicate]

An example will be most specific: func[list_, column_] := list[[All, column]] = Map[#*2 &, list[[All, column]]]; This throws errors. I want to avoid doing ...
50
votes
2answers
2k views

What is a Mathematica packed array?

A simple sounding question with a few sub questions: What is the difference between unpacked vs packed array? Are packed arrays more space efficent, how much so? Are packed arrays more time ...
20
votes
3answers
1k views

Does every Symbol in Mathematica induce a monad?

From my question about types in Mathematica, I assume that every Symbol in Mathematica is a type if it appears as a Head of some ...
21
votes
3answers
2k views

What is a type in Wolfram Mathematica programming language?

"Everything is an expression" is a popular citation from many Mathematica guidebooks. So, what is type in Mathematica? How does it relate to common types from Haskell, for example? I did some ...
15
votes
5answers
646 views

How do I generate the upper triangular indices from a list?

I have some list {1,2,3}. How do I generate nested pairs such that I get {{1,2},{1,3},{2,3}}? That is I'd like a way to ...
14
votes
3answers
812 views

Reading from STDIN, or: how to pipe data into Mathematica

Today I tried using Mathematica's plotting capabilities to display the output of a C++ program. This made me wonder whether it is possible to somehow tell a Mathematica script to read from STDIN and ...
27
votes
3answers
725 views

Is there a convenient way to copy/paste text-interspersed SE code snippets into Mathematica?

Is there a way to copy and paste code snippets from SE to Mathematica if these snippets are interspersed with text? Like e.g. in Morphing Graphics, color and location in both the question and answer, ...
4
votes
1answer
310 views

Path queries for tree-structured data

Can anyone suggest documentation or tutorials for developing path queries and indices for (XML-like) tree-structured data? Suppose data is organized hierarchically in key->value pairs, eg: ...
7
votes
1answer
804 views

Handling failed FindRoot calls

I want to handle FindRoot calls which did not converge (e.g "thrown" error message FindRoot::cvmit) ...
17
votes
2answers
804 views

Using a list of tuples in a pure function

I want to use a list of tuples within a function to make assignments. Say I want to make assignments of the form value[i,j] = val What I have is a list of ...
5
votes
3answers
2k views

Basic questions about running Mathematica

Is there a command window and an editor in Mathematica 8 similar to those in Matlab? In Mathematica GUI mode, all I saw is write code and run it in the same notebook. In my Ubuntu terminal, I ...
15
votes
1answer
396 views

Importing Zip files

Mathematica can import zipped files automatically, but when the content of the zip file it's another zipped file, I just get the list of files in the second zip: ...
78
votes
1answer
3k views

Programmatic formatting for Mathematica code - possible?

It seems to be both an interesting programming challenge and a very useful practical application to have a Mathematica program which would allow one to pretty-print Mathematica code, so that it is ...
12
votes
2answers
347 views

Listing subgraphs of G isomorphic to SubG

If I have an undirected graph G, how could I write a function in Mathematica to obtain a list of subgraphs of G that are isomorphic to some other undirected graph SubG? I'd like to learn how to ...