# Questions tagged [performance-tuning]

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.

2,508 questions
Filter by
Sorted by
Tagged with
130 views

### Determining Mean Path Length

I'm interested in working out the average path length in a square. Assume at a single point within the square, photons are released in every direction. I'm interested in determining the average path ...
117 views

### How can I more quickly get the interchangeable variables in a function?

Let's say I have an expression like a b + c d e. This is equal to: a b + c d e, a b + c e d, ...
60 views

...
61 views

### Efficient way of iterating over satisfiability instances

I am working on a problem that involves searching through solutions to a boolean equation, to see if any have a specific property. As the computations are not particularly fast, I would like to ...
265 views

### Optimize molecule distance analyzing code

I have a very large dataset (31552000 lines) of xyz coordinates in the following format 1 2 3 4 5 6 7 8 9 . . . I have to take a distance using the special ...
200 views

### How to increase the speed of Collocation method to solve System of differential equations

all. Kindly suggest me a ways to improve the speed of computations. I recently came to know about collocation methods and their application to find solution for system of differential equations. Here ...
46 views

### Why is extracting values from an Association with 1 level slower than extracting values from a list of depth 1?

I am not looking for a solution or work-around, but an explanation. Here are six examples of doing a trivial operation on an association and a list. Initially, I was curious about the cost of calling ...
76 views

### Module inside With, With inside Module, or Just Module?

In general, if one wants to define local variables and local constants, which of the following is the best programming practice in terms of performance and code "safety"? (Assume ...
98 views

### Sowing Once into Each of Many Lists – Any Better than Append?

In general I know to try to use Reap and Sow over Append or AppendTo due to superior performance. However, Reap and Sow are notorious for being difficult to understand how to use and how they work ...
64 views

### What's the time / space complexity of pattern matching?

For example, in ReplaceAll[expression, pattern], what are the main algorithms used internally? How does the asymptotic time / space complexity scale with the length ...
29 views

### Keep Mathematica kernel for a script alive without having to initialize every time (Windows 10 .bat file)

I have a Mathematica script (ChristMetric.wls) that is plugged in to a python code which exports a list of geometrical data in .txt file. I plugged the script into the python by making a .bat file in ...
54 views

### How to find the regions for which the derivative of my function changes sign?

I have an energy function of the angles of the electrons' spins. th1 is vector with (2l+2) elements and each element represents the angle of an individual electron spin. I need to eventually find the ...
70 views

### What is the best optimization method for the following function?

I have calculated the energy of the electrons as a function of their angles. and I want to find the angles for which my function (energy) is minimized. I have used NMinimize, but the angles I get from ...