# Tagged Questions

Questions on optimizing Mathematica code for higher performance. This may mean faster execution, lower memory usage or both. Not to be confused with mathematical optimization.

157 views

### Why FoldList 5 times faster than Apply for matrix multiplication? [duplicate]

Consider this list of $2\times 2$ matrices: list=RandomReal[{-2,2},{500,2,2}]; Now compare timings of Apply and ...
366 views

### Performance of calculation of means squared displacement

How can I improve the performance of the following code which calculates the mean squared displacement for coordinates stored in data? Here for each time difference ...
34 views

### Performance of Apart with complex numbers

Consider the following code ...
77 views

### How to compile code that involve sparse array?

I have the following code ...
145 views

### Fast way to evaluate the PDF of a multivariable distribution

I'm trying to evaluate the PDF of a truncated multi-normal distribution. My distribution has 8 dimensions and each value must be ≥ 0. ...
565 views

### Particles bouncing in a 3D box

I made this Manipulate code which shows a pack of particles randomly moving inside a box. It has a huge performance issue. What should be the best way in doing "...
66 views

### Estimating processing time for commands [closed]

I am trying to evaluate some equations by using Taylor series of expansion (Series[], ExpandAll[], and Normal[] command), and using n equation and n unknown (Solve). Following is not full command (if ...
117 views

### Efficiently strip off coefficients in front of variables?

I am working with multivariate polynomials and need a very efficient way to decompose monomials into coefficients and pure monomials. for instance consider variables ...
171 views

### How I can get faster code for computing a fractional integral?

I use of this code Fractional Integral and wrote the following code: ...
211 views

### Mathematica 10.X benchmark report for high-end surface pro 4/surface book?

Recently, I am seriously considering purchasing the high-end surface device (with intel i7 and maximal RAM). Mathematica will be one of the main applications. Since it is not a full or traditional ...
84 views

### How to speed up the construction of a large matrix

As a part of a physics problem that I'm working on, I need to construct a rather large matrix. The matrix is a real symmetric $2^{m}\times 2^{m}$ matrix for some integer $m$, which we would like to ...
91 views

### Perform matrix/tensor contractions more efficiently

Problem: explicit index contractions for matrices using the Sum command take too long, and I want to improve the performance for complicated computations. Let me ...
206 views

### ParallelTable behaves differently when it is run inside a package

I've been butting my head against some very weird behaviour by ParallelTable, and its interaction with packages, over the past few weeks, and making relatively ...
96 views

### Need help solving a polynomial system [closed]

I need help solving the following system of equations: ...
95 views

### Asymptotic form of the “strange” function

I want to find the asymptotic form of this function ...
108 views

### How to make AppendTo faster

Function AppendTo seems to be very slow for generating a lot of scenarios, is there any chance to change it and make it faster? ...
295 views

### What is the most efficient way to replace items in a list at periodic intervals?

For example, if I want a list of $\phi(n)$ for $1 \leq n \leq 100$ but if $n$ is a multiple of 3 I want to show a 3 instead of $\phi(n)$. I tried ...
43 views

### Finding minima of a function: Ways to speed up the code [duplicate]

I am quite new to Mathematica. I tried to calculate all minima of the function of interest as follows: ...
64 views

### Fast way to compute intersection of equivalence classes

There is a set $S=\{1, 2, \dots, m\}$ and $n$ equivalence relations on the set: $a \sim_i b$, where $a,b \in S$, $i=1, \dots, n$. Now we define $a \sim b$ iff $a \sim_i b$ $\forall i=1, \dots, n$. ...
77 views

### A custom function is too slow when I first time to run it

I make a function like this ...
470 views

### Radial distribution function

I have tried to rewrite my old IDL code to calculate the radial correlation function for a regular 2D crystal structure. The theory behind this function is given here: https://en.wikipedia.org/wiki/...
106 views

### Want Manipulate to be low resolution enough to render fast but no so low resolution that it is useless

When using Manipulate to graph a simple surface (sum of 2 sine waves) with Plot3D, setting PerformanceGoal->"Quality" makes it take about 1/3 second to render, while "Speed" sets it at such a low ...
62 views

### EvaluationMonitor slows down NDSolve considerably

Hi guys I'm solving a nonlinear system of ODEs with NDSolve. Since the dimension of the system ranges from 2700 to 20000 equations, depending on the parameters, the time required to solve the entire ...