Questions on how to write code in a better or different style, using Mathematica's capabilities for coding in multiple styles.

learn more… | top users | synonyms

5
votes
1answer
120 views

How to find the name of the current function

I would like to know the name of the current function from within that function. For example, consider the following code ...
4
votes
3answers
183 views

More structure in Source Code/Notebooks

Mathematica is great for small and quick projects and has a great syntax. However as soon as a project grows I run into trouble. How do you scale and maintain projects in Mathematica? What is beyond ...
3
votes
0answers
78 views

How do I add options to a built in function, which only apply to a certain class of argument?

I'd like to add an option to a built-in function that only applies when it is given an argument of a certain form. For example, something like this approach to extending ...
7
votes
2answers
326 views

How to write data from Mathematica to an existing formated Excel file?

I have a sheet in an Excel file already formated: different colors, fonts, columns width and cells styles. I want to fill-out values from Mathematica into specific cells of that sheets, or use that ...
3
votes
0answers
114 views

Notebook function formatting

I've recently started a course in which I am learning how to solve different problems using Mathematica. A large part of the course covers creating your own functions. The thing is I don't like how my ...
9
votes
5answers
268 views

An elegant way to plot a numeric function that returns a list, and have each element in a different color

I have a function that takes a numeric argument and returns a list of numbers. I want to plot each element of the list in a different color. If I use this command, ...
1
vote
1answer
138 views

Lines with label in Plot options syntax

I wrote a little function to add lines with labels to plots. It just creates customized {GridLines -> ..., Epilog -> ...} code: ...
6
votes
4answers
379 views

Alternatives to While Loops?

I am using Mathematica to run a probabilistic simulation. Essentially, I have a list of members of a population (they only have one, numerical, attribute, so it's just implemented as a list of ...
8
votes
2answers
199 views

Notebook formatting - easier descriptions for equations and results?

When I do computations in mathematica, I generally try to make it readable for myself-in-the-future. This can be a cumbersome task in mathematica, where it often requires me to switch betwee a text ...
8
votes
1answer
146 views

What is the purpose of Dump contexts?

Motivation I've been trolling through some internal code, trying to glean design practices WRI developers employ when extending Mathematica using top-level code. During my ...
6
votes
2answers
387 views

Speed up Mathematica code involving Convolve

I'm trying to plot the averaged autocorrelation function of a random wire profile $\xi(x)$ which is build from unitsteps which are each L units long. To calculate the average I'm generating nMax ...
6
votes
0answers
110 views

What are some general strategies to avoid using For loops? [duplicate]

Possible Duplicate: Iterating over lists in Mathematica While there are some cases where a For loop might be reasonable, it's a general mantra – one I ...
11
votes
2answers
302 views

What's the most “functional” way to do Cholesky decomposition?

I can do Cholesky in a procedural style, such as: ...
9
votes
3answers
301 views

Generating an autoregressive time series

Find $X_t = c_1 X_{t-1} + \dots + c_n X_{t-n} + n_t$ for given $c_i$, initial conditions $(X_1, \dots, X_n)$, and distribution for i.i.d. $n_t$. I would like to know if there is a more efficient or ...
11
votes
2answers
537 views

Speeding up random walk for many particles

I am trying to speed up this code for many particles to take a random walk. I'm not sure why it is so slow for such a simple task. I got a few hints from colleagues to reduce the precision of the ...

1 2
15 30 50 per page