# 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,659 questions
Filter by
Sorted by
Tagged with
327 views

### Grouping consecutive elements at specified positions

Let L1={1,2,4,6,8,9,10,14,15,17,21,22,72,76,80,96,106,116,117} Question1) Group from 10-th to 14-th elements in L1. So that the ...
• 2,877
1 vote
168 views

### Need to find a unique mathematical expression (not in documentation) that is as short as possible but takes a good amount of time to evaluate

I am writing a public ResourceFunction and I need a good clever use case that should not appear to emulate any examples in the official documentation but will ...
• 1,837
103 views

### Why is this 3D sine plot taking so much RAM?

I'm using the online version in the Wolfram Cloud. Whenever I attempt the following computation: ...
• 333
1 vote
20 views

### Why does Sparsearray diagonalization by Krylov technique become slower for very large sizes?

Here is an example sparse matrix, taken from example Hamiltonian, which was a question I asked before in this forum. ...
459 views

### How to quickly test if two regions intercept?

If I randomly generated two cylinders, how do I test if they intercept? For example: ...
• 123
253 views

### Applying f for a part of list (MapAt is slow)

Suppose that there are 2000 stones in a row. You should grind 1000 of them to make beads. The time loads(making beads) for each stone are similar. But which 1000 stones? case1) the first 1000 stones. ...
• 2,877
19 views

### How to apply NetDecoder on each element in output?

I try to apply the NetDecoder on each output element but get an error. ...
• 1,949
217 views

### Speediest Julia Set "By Hand"

While being aware of the built-in command, I would like to show my students how the Julia set is actually generated. The code I came up with is slow, even though I am quite happy with the picture it ...
• 293
247 views

### ParallelDo barely faster than Do

I am new to parallel computing, so I am trying to get a grasp as to how this works. Many posts seem to indicate that overhead (like here) is a common pitfall, but I do not see why this would be the ...
• 1,043
688 views

### Faster determination if two nodes are connected in a graph

In the code below connectedQ[g_,v1_,v2_] is a function to check if two nodes v1 and v2 in ...
• 2,084
74 views

### How To Compile The Computation Of Cumulative Returns

I'm trying to compile this function, specifically the second line which computes the cumulative return of 100 daily returns. ...
817 views

### Why does this take so long time to run?

How do you improve the speed of this? It took me more than 10 minutes and is still running. I want to gather them in pair of inverse elements. ...
• 2,084
349 views

### Multiplication of one big integer and a long list of integers - fast

This is an example of multiplying a big integer to a list of integers. ...
• 2,877
1 vote
74 views

### Theoretical Timing possible? (not changes for each evaluation)

Is there a method to measure theoretic time load (hope +theoretic memory load) of an evaluation? They should not change - always generate same value after pressing Enter key(=evaluation). Hope they ...
• 2,877
246 views

### Lazy vs strict evaluation approaches - performance comparison

In general, I think there are two methods of evaluating a variable in Mathematica. My question is about performance of the two methods. Suppose that our final goal is to evaluate ...
• 2,877
80 views

### Optimising eigenvalue matrix calculation

I'm quite new to mathematica and am trying to figure out how to optimise my code as currently it takes a very long time to compile and makes it hard to bug test. The first part that creates the graph ...
1 vote
389 views

### How To Make Monte Carlo Simulation Run Faster

I'm running a Monte Carlo simulation of stocks prices in which the data that is used to define the Skewed Normal Distribution updates after 1,000 simulations. Thus it is crucial that I get this code ...
42 views

### RegionMeasure works very slow for BooleanRegion

Consider two regions: ...
• 3,832
95 views

### Code refinement - bottleneck

In the code, I indicated a fragment (picker =...) where the program is slow for large m=n=dim (for example)=2000. Does anyone have any idea what to replace it with ...
• 969
133 views

• 923
1 vote
49 views

### Why each iteration takes longer than previous one when using VariationalD in this loop?

I have a function $f$, and I would like to modify it iteratively to approach another one called $a$ (not because I think this is the best way to do anything, but for experimentation). For this, I use <...
• 137
47 views

### Alternative for PowerRepresentations[n, x, 1]

I am looking for numbers $n$ that can be written as the sum of other numbers. So: PowersRepresentations[n, x, 1]. But is there a faster way of finding these numbers?...
• 1,723
1 vote
134 views

### Explicit integration of PDE running very slowly

I would like to solve the PDE $\frac{\partial u}{\partial t}=(1-x)\frac{\partial u}{\partial x}$, in the interval $[0,1]$, with initial condition $u(0,x)=e^{-218(\frac{-2}{3}-ln(1-x))^2}$, by manually ...
• 199
90 views

### Solving or Minimizing the Norm of the matrix equation $M^TAM - M^TB - B^TM =C$

I am trying to solve the matrix equation $M^TAM - M^TB - B^TM=C$ where I know A, B and C. My unknown matrix is M which has the special form that all the rows and columns sum to zero. i.e. I have four ...
• 495
154 views

### ListDensityPlot with RegionFunction takes too long?

I am using ListDensityPlot with RegionFunction (MMA12.3 on Win 64) but it takes too long ...
• 3,228
136 views

### How can I exclude specific region in ListDensityPlot

I would like to exclude the region outside the yellow Polygon in this plot, how can I do that? ...
• 3,228
151 views

### How can I speed up processing with DeleteCases?

I would like to get points that are only inside a region. Here are the region and unfiltered points: ...
• 3,228