# performance-tuning's questions - English 1answer

1.745 performance-tuning questions.

### Efficient way to make updates in a big List

I would like to know is there is a way to do this: ...

### 5 How can I find a more efficient solution to mapping characters to digits?

2 answers, 566 views performance-tuning functional-style
Given: ...

### 1 Toroidal metric in a random geometric graph

I have some code I've been using to generate some random geometric graphs as fast as possible. The boundary conditions on the rectangular domain I am using sometimes interferes with a clean ...

### 1 Optimisation of a loop

I've opened a question here, which was answered. The code works totally fine for a small set of data. However, for a large set and over many iterations, it will take a long time (in order of 24 hours)....

### 3 How can Distribution fitting be sped up?

The first line generates 1050 data points to fit. The second line fits this data to the same distribution. This takes about 100ms on my computer. Doing this with ...

### 1 Forming Kronecker products for “non-adjacent” vector spaces

1 answers, 116 views matrix performance-tuning
In quantum mechanics, we often want to build operators acting on multiple particles by simply "Kronecker-ing" operators from the single-particle spaces. That is, if I have some matrix $A$ acting on ...

### 4 Loopy Belief Propagation

I look for an efficient way to implement a Belief Propagation in Pairwise Markov Random Field. Each node is a binary random variable, and the unary potential function is ...

### 3 Predict[] Application Timing

I trained a Predict and when I look at PredictorInformation it says evaluation time is less than 1 millisecond per example. ...

### 8 Find positions of certain value in a big boolean list

I would like to know is it possible to find positions of False in t: ...

### 5 Perfomance in Position

I need to find the position of elements in list that are present in close. These are both 2D lists. The code is simple but not ...

### Table & complex exponential (Arbitrary‐Precision) operations efficiency issue [closed]

Below is the expression I want to optimize, ('I' represent the imaginary unit):ParallelTable[Flatten[Exp[I*n*list]], {n, -10, 10}];as you can see I already ...

### Table Creation Slow Performance

1 answers, 40 views matrix performance-tuning
The following is a question in regards to the matrix $A$ (originally the zero $4n \times 4n$ matrix) below: ...

### Loss of 1 to 1 mapping due to duplicate in Association

The main goal of this procedure is to first rotate an array of 3D coordinate leaving z untouched,finding the positions of tuples with z larger than some value, and then mapping those positions to the ...

### 2 Save a list as a value in the sparse matrix

1 answers, 53 views performance-tuning sparse-arrays
I am interested in save a list (the size of the list is two) of numbers in the sparse matrix, but this is not supported. Maybe you familiar with some workarounds or any suggestion on another data ...

### 7 DFT for Helium atom

I'm trying to solve this problem I'm not a Mathematica expert, but my program works perfect when vhartree={0,0,..,0}This is the program I wrote: ...

### 3 Increase Performance of WhenEvent in NDSolve

I'm trying to reset the value of functions $u_{i}$ when they reach a threshold $θ$. Below the threshold, they evolve according to a simple differential equation. The $r_{i}$ resets the derivative to ...

### 1 How to increase the speed on opening and playing gif?

I have a gif Example.gif, and would like to play it in a presentation. I used the following code:- ...

### 5 Replace values in sparse matrix

2 answers, 254 views matrix performance-tuning sparse-arrays
I am interested in updating the values of the sparse matrix. I have a list of matrix element which I am interested in updating and a list of new values. Currently, I do it in the following manner:<...

### 3 Find k smallest sum n-tuples

1 answers, 62 views performance-tuning combinatorics
Given a collection of sorted lists {l1, l2, ...} I need to find the smallest k index tuples taken from these lists by summed ...

### 3 Get the dimensions from the SparseArray properties

In the sparse matrix, we have a list of properties: specified elements, dimension, default, and density. I am interested in getting this data without calculating them again. For an example, the ...

### 3 Slow evaluation of Recurrence plot data from NDSolve: Performance Tuning

I am trying to use a recurrence plot to pinpoint the location when a system re-visits a previous point in its phase portrait. The system (a thin liquid film) is governed by a non-linear differential ...

### 4 Get the number of specified elements from the SparseArray properties

2 answers, 108 views matrix performance-tuning
In the sparse matrix, we have a list of properties: specified elements, dimension, default, and density. I am interested in getting this data without calculating them again. For an example, the ...

### 3 Evaluated Plots of mesh interpolating functions are very slow in 11.0

It is well known that we use // Evaluate or Evaluated -> True to get Plot to "see" that ...

### 1 Improving NDSolve computation speed for 3D stationary PDE

Continuing my last question, I am trying to solve 3D Schrodinger equation (with mass equals to 1) and with no potential (I will add a potential later). The analytical solution for this equation is ...

### 21 Select performance

3 answers, 1.229 views performance-tuning filtering
I am fairly new to mathematica and working my way thru Paul Wellins book on Mathematica programming so experimenting with various language constructs. I was experimenting with ...

### Fast way of finding diverging terms in a huge expressions

I have a huge expression called exp1 which is a function of rr. There are some terms in the huge expression which diverge when I put rr equal to zero. I want to find these terms. Does any one know an ...

### Simplifying a large expression (just for subtraction and addition) [closed]

Consider a large expression which contains terms like a/x+b/x^2+c x + d x^4 +...-b/x^2 +h x -a/x +...I want to find limit of the expression when x goes to zero....

### 19 Is it possible to Parallelize Select?

Given a large list of elements, is it possible to improve Select by parallelizing? An example: from a 10,000,000-element list of integers between 1 and 10, select ...

### 8 Replace diagonal elements in sparse matrix

4 answers, 267 views performance-tuning sparse-arrays
I am interested in replacing all elements in a diagonal of a sparse matrix with zero. Currently, I do it in the following manner: ...

### 1 Performance Tuning - How can I make Mathematica to use less than certain digits number?

I would like to know if there is a way to make Mathematica to use at most certain digit number. For example, Suppose I want to calculate 2*Pi.x=N[Pi] y=2*x...

### 32 Searching for still lifes in Conway's Game of Life

1 answers, 612 views performance-tuning cellular-automata
I'm trying to search for still lifes in Conway's Game of Life. An object in Conway's Game of Life can be represented by an array of booleans, say, Array[b, {w, h}]....

### 1 VectorPlot3D not working as expected (but other functions for same input are)

2 answers, 45 views plotting performance-tuning
This is a follow-up question from my previous question. What I was trying to do was to plot the contour plot of the following given scalar function. \Phi(x,y,z)=\int_{h=-a}^{a}\int_{k=-b}^{b}\int_{...

### 2 How to increase performance of this code for plotting a contour plot?

1 answers, 116 views plotting performance-tuning
I have an equation which I need to triple integrate over a unit cube. The equation is ...

### 1 What is the fastest way to make this table?

1 answers, 174 views list-manipulation performance-tuning
Context: As a possible approach to Goldbach's Conjecture, we create two lists of least/greatest prime factors of the odd numbers. The lists are A090368 lpf and A076565 gpf. We get symmetric ...

### 6 How to find k largest element and their position in a matrix?

I have a sparse matrix, and I am interested in find k largest elements and their positions in the matrix. I do it in the following manner: ...

### 10 Markov Random Field

I look for an efficient way to implement a Pairwise Markov Random Field. I have implemented a homogeneous (i.e., unary potential is a similar function in all nodes, and pairwise potential is a ...

### 2 Just typing Import[] tries to list folders in a directory, and it is slow over sshfs

It appears that Mathematica tries to list the folder that you're typing into an Import[] statement. Since I'm working with folders mounted over sshfs and they ...

### 6 Can this code be changed to run faster?

I've worked for several days trying to get this code to run faster. The imported data is 15MB. ...

### 1 Accelerate import of table of numbers

0 answers, 23 views performance-tuning import
I've been writing a ServiceConnection to the OEIS and one thing I need to do is import large sequences of numbers, like this one. My first though for this was to ...

### Speeding up Module

1 answers, 59 views performance-tuning sampling
I am working on the Ising 2D model in Mathematica and this is currently my Metropolis sampling function: ...

### 3 Cosine similarity calculation

I am interested in calculating the cosine distance between each pair of the element of a sparse matrix. I am using the built-in function DistanceMatrix with the ...

### Errors using FindRoot on slow numerical function

I would like to find the solution of an equation containing a slow functionFindRoot[func[x, onsideS, hoppingS, 0.01] - (1/E) == 0, {x, 1,10}]for different ...

### 3 PackedArray version of Chop

0 answers, 37 views performance-tuning packed-arrays
I'm a big fan of Chop. It's fast and useful in pre-rounding transforms and things Unfortunately it also necessarily unpacks a real ...

### 1 Optimization of a slow function - reason to why it is slow

Edit: Okay, my question was viewed quite a few times but not answered so I assume I phrased/presented in a confusing way. I'll try to rephrase my problem to make it more accessible because luckily I ...

### 2 Compile with “Listable” only on one argument

I would like to write a Compiled function which is listable only in the first argument, because this allow fast and easy parallelization. How is it possible to do it? In the following way it does not ...

### 1 How to control PerformanceGoal at ListContourPlot

1 answers, 23 views plotting graphics performance-tuning
I am using ListContourPlot to plot a list of points. I am using the PerformanceGoal option inside of ...

### 1 How to make the sliding of the Manipulate with GeoListPlot smoother?

I am working on some animations of geographic entities. I have a Manipulate with GeoListPlot as below: ...

### how to speed up this function?

0 answers, 128 views performance-tuning compile
in this code cumavg1,cumstd1,giuper1,gilower1 are compiled. however, i dont know how to compile ei and fi to further speed up the calculation. any help will be appreciated. ...

### 49 Adaptive sampling for slow to compute functions in 2D

EDIT: Although I have posted an answer based on my current progress, this in incomplete. Please see the "open issues" section in the answer. Most plotting functions in Mathematica adjust the ...

### 16 When to use Once for memoization?

1 answers, 237 views performance-tuning memoization
While watching Stephen Wolfram's twitch stream I saw him use Once for memoization, which surprised me since I thought of Once as ...