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.

Filter by
Sorted by
Tagged with
1
vote
0answers
22 views

Reduce the time of computation for $5$-dimensional numerical integration

I need to perform (numerically) the $5$-dimensional integral given in the code below for a large number of values of $\epsilon$. The code I have at the moment takes $\sim 11$ minutes and returns an ...
1
vote
0answers
13 views

DateInterval Min/Max performance issue

The performance of Min and Max on a list of DateInterval is ...
1
vote
0answers
45 views

Faster methods for performing repeated list manipulations?

I've done my best to pore over the other posts on this site, and to the best of my ability I can't seem to find a good solution to my problem, so I apologize in advance if elements of my question are ...
0
votes
1answer
26 views

Map of an expression in a 3D grid is very slow

I have a quite large expression as function of $R$, $\phi$ and $Z$ as you can see: ...
5
votes
1answer
76 views

Table vs. ConstantArray efficiency with compilation

I've been trying to optimize a bit of code the past couple of days, but think I might be misunderstanding how compilation on certain target functions works. As a most barebones example, I've attached ...
5
votes
1answer
100 views

Determine if the edges of a graph are distinguishable

Mathematica 12.1 introduces edge tagged graph (EdgeTaggedGraph), which is supposed to solve the problem of distinguishability of parallel edges. Unfortunately, the ...
7
votes
1answer
176 views
+250

Testing Turbulence Models

In the 90s, several turbulence models were proposed. Using Mathematica vv 10-12.1 we tested two models: 1) Spalart-Allmaras turbulence model (SA) for aerodynamic applications, published in AIAA ...
3
votes
0answers
41 views

speed up tensor expand

I am using the following code ...
12
votes
0answers
229 views

Why is MemoryInUse[] Very Different from the Actual Amount of Memory Being Used?

I call the MemoryInUse[] function, and it outputs about 256 Megabytes. MemoryInUse[] (*255979528*) However, my activity ...
1
vote
1answer
141 views

Help with solving an equation [closed]

Could anyone please help me find the real solution(s) to a system of equations, or could anyone please help me find an effective solver to solve it? The function ...
1
vote
1answer
67 views

Why can't I use FindInstance to find more than one solution when I know they all exist?

For example, it is easy to find one solution for this code: ...
4
votes
1answer
148 views

Optimization: Differences between Map and ParallelMap

I just was studying Map and ParallelMap in a MacBook Air of 2 kernels. So, I tried comparing the AbosoluteTiming of these input lines and the outputs sorprised me because I thought a ParallelMap would ...
2
votes
0answers
34 views

How to canonicalize UndirectedEdge with good performance?

When programming with graphs, it is sometimes important that UndirectedEdge[a,b] and UndirectedEdge[b,a] are treated as ...
4
votes
0answers
27 views

Why is listing files on a network share so slow? / How to speed it up?

I'm using I need to load data in some files on a windows network share (samba), mounted on OSX. When listing the relevant directory in a shell, the performance is acceptable: ...
0
votes
1answer
48 views

Find the two largest maximums of an interpolating function of a specific shape (fast)

I have an oscillating interpolating function f[x] and I would like to find the x values of the two largest maximums (or even ...
0
votes
0answers
43 views

Code optimization

I designed this Gillespie's algorithm by the First Reaction method, and I would like this runs faster. I mean, to reduce the absolute timing of the Do bucle. So, I was thinking what kind of ...
3
votes
1answer
75 views

How to speed up my code using Sparse-array possibly?

I created two loops using Parallel table and a table. The outer loop causes a (nstates by nstates) dimension matrix and the inner loop calculates the matrix elements based on their position in the ...
3
votes
1answer
56 views

Generating and analyzing an Interpolating function from many interpolating functions: speed up

Is there a clever way to speed up this code? ...
1
vote
0answers
44 views

Notebook is very slow [closed]

Recently I wrote an algorith in the notebook of mathematica and it worked fine. The next day I reopennedd the same file and realised that it went very very slow...it took more than 10 seconds to do a ...
5
votes
1answer
116 views

Eigensystem of arbitrary 4x4 Matrix

While doing a computation, I needed to take numerical derivatives of eigenvectors of a 4x4 hermitian matrix with respect to a parameter. I ran into the issue of phase jumps -- a random phase ...
5
votes
2answers
246 views

Is it possible to speed up this code by eliminating “For” loop?

I am finding how to speed up a code. The code and general equation are as below. ...
0
votes
1answer
47 views

Is using an If[] condition faster than KronckerDelta[]?

I have a code which has a term in a summation like: KroneckerDelta[M,0]*func[M] where func[M] is a time consuming numerical ...
3
votes
1answer
52 views

Matrix rank of triangular integer matrix powers. Can it be speed up?

I need to determine ranks of the powers of a triangular $0$-diagonal integer matrix of a high dimension. Doing this I noted that the time Mathematica needs to ...
0
votes
1answer
94 views

Parallel computations [closed]

I'm having some problems with memory use and speed of a parallel computation. I've searched through the answers but only found allusions to the existence of a solution, but nothing concrete. The ...
7
votes
1answer
125 views

Fastest way of numerically creating a list of dot products

I have a list of numerical complex 2x2 matrices list = {M[4,3],T[3],M[3,2],T[2],M[2,1],T[1]} (in reality this list contains over 1000 matrices and I have to do ...
4
votes
1answer
71 views

Why the difference in performance? Array vs List and `Delete` vs `Nothing`

In a previous question I was warned against the use of Nothing to delete elements from a list, and rather use Delete. Being of ...
3
votes
1answer
31 views

More efficiently access iterator values in subkernels?

I'm looking for more efficient ways of observing values in loops in subkernels. For example, take a standard Do loop: ...
0
votes
0answers
36 views

How can I rewrite this code so that it gives me the same result in less than one second? [duplicate]

For[i = 1; list = {}, i <= 23456, i++, l = AppendTo[list, i/Pi]]; Total@N@list
2
votes
2answers
77 views

Plotting function takes forever

I have this simple code, but it takes ages to plot the last function: FS12... how to speed it up? Thank you ...
3
votes
2answers
901 views

Improve speed with a double for loop

I am trying to calculate the Euclidean distance of pairs of points $(x_i,y_i)$ with $x$ and $y$ given as separate lists. ...
1
vote
1answer
79 views

Manage to save large arrays

Some time ago I asked the following question: Merge list repeating elements I was easily answered and I was satisfied by the answer. However in computing such combinatorics, I saturated the RAM very ...
3
votes
1answer
99 views

Efficiently finding spheres furthers apart along and perpendicular to a given direction

Setting I am dealing with a box of spheres, all having the same radius and inserted into a finite box size without any overlaps. Along a given direction $\mathbf v$, I am trying to find: (a) The two ...
1
vote
0answers
74 views

Help speeding up matrix exponent of $ 16 \times 16 $ symbolic matrix

I am trying to run the following script which involves the MatrixExp of t times a 16x16 matrix with one variable, ...
5
votes
1answer
208 views

How do I get this piece of code run faster?

Here is a piece of my code, in which I have a function that includes sums over the multiplication of ThreeJSymbols. I am using this function in a multiple loops to ...
6
votes
2answers
179 views

Effectively gather data with small differences

I frequently encounter themes where I have a set of data, then I need to gather up those identical ones. However, due to numerical error in data, GatherBy cannot be ...
2
votes
1answer
136 views

Function arguments are taking way too much RAM

I have to compute a function "func" with 24 arguments. Unfortunately when I apply the arguments the RAM fills up immediately. I even change the swap size of my Linux system to 100 G. I hope somebody ...
8
votes
3answers
429 views

How to make Minimize with Sqrt calculate faster?

This code ran a long time without getting a result (v12.0 & v11.3) Minimize[{Sqrt[3 + x] + Sqrt[3 - x*y], x^2 + y^2 == 9}, {x, y}] But with $x=3\cos t,y=3\...
3
votes
2answers
148 views

How to speed up this code with Bessel functions

I need to perform a ContourPlot on a function with BesselJ included. But my code is very slow, especially when I set the PlotPoints to be 100. I would like to know how to speed up this code. Any ...
0
votes
0answers
87 views

How to speed up Timing[4^(10^10)]

I have an old computer with a quad-core AMD Phenom II processor (3Ghz). When I run Timing[4^(10^10)]the computer takes hours to evaluate the expression. I'm not ...
4
votes
1answer
78 views
0
votes
0answers
43 views

Reduce taking a long time

I am delving into proving subspaces of polynomials. The following did not finish after several minutes on v.11.3, and took 23 seconds on v.12.0: ...
1
vote
1answer
66 views

Efficient way to evaluate numerically product sines functions

I'm trying to perform integration of the following matrix. ...
4
votes
4answers
190 views

Compute area between two ListPlot joined list (area filled by Filling -> {1 -> {2}})

Given two lists, how can I compute the area between their plots? (the blue region in the image below). The horizontal distance between points in the list can be assumed to be 1, as done by ...
2
votes
1answer
40 views

Fastest way to ArrayFlatten a 2D array of 2D arrays, both for Sparse and Dense

I am using Mathematica 12 and want to know what is the fastest way to transform a 2D array of 2D arrays both for dense and sparse arrays. I remember looking for this a few versions of Mathematica ago, ...
3
votes
2answers
80 views

Sorting a Collection of Lists by Comparing Different Parts

I am looking for a way to use Sort[] to sort a collection of lists by comparing different parts of these lists. For example, sorting by comparing the second part of ...
0
votes
0answers
26 views

Improvement of a method to plot values of a section of a line that moves with time

I have this code which animates a layer of fluid moving on the outside of an ellipse with a moving black point on the cylinder surface itself. I want to plot a line from the origin to the outer layer ...
0
votes
0answers
53 views

help with improving my code

I am fairly new to MMA-12 and have written the following code to calculate possible coordinates (for given constraints [see If[]] in the code) and get the ...
6
votes
2answers
68 views

How to tell (sub)kernels on a cluster not to try to access wolfram servers on startup?

Context I get inconsistent delays (from a fraction of a second to 10 seconds or more) in launching 'echo "Print[1+1]; Quit[]" | math' on different nodes ...
6
votes
3answers
486 views

How to make the computation of a minimum efficient?

I have a $80\times 80$ matrix $A$ and a vector $P$ and I want to compute efficiently the following minimum $$ \min\{n\in \Bbb N :\|A^nP\|_\infty < 1\} $$ Then I defined my matrix and vector in ...
2
votes
2answers
89 views

`Solve` Performance Tuning

I'm facing a Problem in Mathematica, where I have to solve a large number of equations generated by an AppendTo. ...

1
2 3 4 5
44