Skip to main content

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
0 answers
54 views

Replacement rule runs for a long time [duplicate]

I have a simple expression that reads (some expression in b) q^(8/3): ...
Lelouch's user avatar
  • 543
2 votes
0 answers
81 views

How to push the performance of this compiled function

I have the function optvals solving for two variables. For the given example of variables, I need the program to run atmost in a millisecond. The main part of the ...
Dotman's user avatar
  • 456
1 vote
0 answers
54 views

How can I efficiently gather similar lists?

I want to gather similar lists by the function sameQ below. Gather works well here, but it's too slow for large data. My real <...
internet's user avatar
  • 793
0 votes
1 answer
73 views

How to speed up generating and filtering large lists of numbers?

I have the following code where I brute force search for two variables. list gives a list of 3 dimensional vectors, say {x,y,z}. ...
Dotman's user avatar
  • 456
3 votes
1 answer
115 views

Code for sampling and quantizing a signal running too slow

Below is the code for sampling a sine wave and quantizing it with negative feedback. It is running very slowly unless we reduce the sampling size ns. ...
metroidman's user avatar
4 votes
1 answer
106 views

Strategy to speed up two polygons (or region) intersection

Basically, I want to compare the overlap between two polygons (or regions). First, I have a reference particle ring that can form a simple polygon, but this type of ring is very thin and long, and its ...
J. W's user avatar
  • 71
0 votes
0 answers
29 views

Getting better answers by smaller working precision?

I have the following code ...
Dotman's user avatar
  • 456
1 vote
0 answers
46 views

Why is SymmetrizedArray taking so much memory?

The context is: I take the tensor product of 2 totally symmetric tensors of rank 8, in 2 dimensions(in this case there are only 9 independent components): ...
Felipe's user avatar
  • 499
1 vote
2 answers
110 views

Plotting with piecewise is slow

This drives me crazy. Why producing the first plot is so slow? It is exactly same as the second plot except that the colors are not the same. (The same slow it is with ...
azerbajdzan's user avatar
  • 18.8k
0 votes
0 answers
75 views

Can I reduce execution time of these NDSolve precision runs?

I'm working on an NDSolve project with high precision but the integration takes a lot of time and wondering if there's a quicker way to integrate the DEs ...
josh's user avatar
  • 2,412
0 votes
1 answer
71 views

Optimization for NSolve

I am trying to solve the system of n equations numerically. Basically, I am solving saddle point equations for eigenvalues of hermitean matrices and trying to reproduce Wigner's semicircle law: ...
Prokopii Anempodistov's user avatar
2 votes
1 answer
90 views

Fast sampling from Fermi-Dirac distribution under specific conditions

This question is a continuation of the following one. Let us assume a Fermi-Dirac (FD) distribution (times $p^{2}$): ...
John Taylor's user avatar
  • 5,827
2 votes
1 answer
91 views

Speeding up the nested NIntegration consisted of `Exp' and `Bessel' functions

I got stuck with optimizing the nested numerical integration of function with a high number of Bessel functions (first and second kinds) summed and several exponents. I will appreciate any suggestions ...
seva011's user avatar
  • 316
1 vote
1 answer
86 views

Most efficient way of defining the following sets for every step $n$

For each $n\in\mathbb{N}$, how do we compute sets $A_n$ and $B_n$ below: Let $A_1=[0,2/3)$. Let $B_1=(2/3,1]$. If $A_n$ is a union of intervals, then for each interval cut out the middle $1/2^{n+1}$ ...
Arbuja's user avatar
  • 71
2 votes
1 answer
72 views

Find disjoint subsets and their union is {1...9}

I have such a list sets = Select[IntegerDigits /@ (Range[Floor@Sqrt@987654321]^2), DuplicateFreeQ@# && FreeQ[#, 0] &] I want to pick all subsets of ...
vector's user avatar
  • 201
1 vote
0 answers
31 views

Efficient chain rule implementation

(there is a fair amount of context here) I am implementing a generalized chain rule to do some work, say for order 3 in derivatives ($\partial_i = \partial/\partial x_i$): \begin{align} \partial_i \...
Felipe's user avatar
  • 499
0 votes
0 answers
45 views

Memory-Efficient FFT of Sparse Array

I have to take the Fourier transform of quite a large 2D array (2^15 by 2^15, but I'll use 2^10 as an example here). My array is mostly zeros, and since Fourier can ...
az123p's user avatar
  • 239
5 votes
1 answer
148 views

How could I speed up this tensor product?

I have to take tensor products of lists of tensors and I want to include the possibility of tensors whose components have high working precision. The tensors are all totally symmetric, so the first ...
Felipe's user avatar
  • 499
0 votes
2 answers
106 views

NonlinearModelFit extremely slow performance with a single iteration

I have been experiencing very slow performance of NonlinearModelFit. The code that in my case causes that is below. The first part gets the data, the model and ...
atapaka's user avatar
  • 3,954
1 vote
0 answers
37 views

Performing difference in extracting coefficients from a sum

I have an expression ...
Lelouch's user avatar
  • 543
1 vote
0 answers
97 views

Speed up the evaluation of two million consecutive eigenvalues using `NDEigenvalues`?

$Version "13.0.1 for Linux x86 (64-bit) (January 29, 2022)" I have $28$GB of RAM. I need to calculate two million consecutive eigenvalues for a given ...
user444's user avatar
  • 2,446
4 votes
2 answers
80 views

Speed up sparse Hermitian matrix-vector product

I am interested in speeding up as much as possible the dot product in the specific case of a multiplication of a $n\times n$ sparse hermitian matrix $H$ (where $n$ is typically large, let's say $\...
Matteo's user avatar
  • 283
4 votes
2 answers
134 views

How to speed up the following algorithm?

I have some random combinations of numbers pairs (where numbers range from 1 to some ntest) ...
John Taylor's user avatar
  • 5,827
3 votes
0 answers
55 views

How to improve Burrows-Wheeler Transform performance?

I have implemented the Burrows-Wheeler Transform as below: ...
flinty's user avatar
  • 25.5k
0 votes
1 answer
76 views

How to select non-repeating pair of numbers?

Consider the following combinations of integers comb, where the integers range from 1 to n ...
John Taylor's user avatar
  • 5,827
4 votes
1 answer
169 views

Effective use of idle cores when using parallelization

Assume I have 10 cores in a CPU. And I run ParallelMap on them: LaunchKernels[10]; ParallelMap[F1,L1]; where L1 is a list of ...
seva011's user avatar
  • 316
4 votes
1 answer
98 views

Efficient way of creating matrices from a very large array while avoiding singular values

I need to create matrix from a large array (>>10000 elements) for further use. I have tried Outer and ParallelTable commands, among which Outer seems to be faster when the array size is not so ...
user91411's user avatar
  • 400
3 votes
1 answer
93 views

How to improve code speed for the large datasets?

How can I improve the speed of this code? It runs okay but is quite slow for large datasets, for example, 5 million elements. ...
hana's user avatar
  • 2,390
2 votes
2 answers
149 views

Compile does not boost the speed

I have these functions that are used to defineMyFun below ...
MMA13's user avatar
  • 4,732
4 votes
1 answer
147 views

How can we improve performance when passing data to a function?

I have a defined function $F(x,y,z)$ and data of $(x,y)$ and would like to evaluate the sum of F over data and at different z values. Here is a minimal example: ...
MMA13's user avatar
  • 4,732
-1 votes
2 answers
152 views

Is it possible to pass by reference at the system level?

I am reformulating the question since it was apparently unclear. One of the comments made me find the correct programming language "syntax" for what I wanted to do(Thanks Nasser). In this ...
Felipe's user avatar
  • 499
2 votes
1 answer
107 views

Fastest splitter?

Consider some dataset ...
John Taylor's user avatar
  • 5,827
5 votes
1 answer
229 views

List of built-in functions written in Wolfram Language

I was developing a program and noted that Grad[0,{x,y,..}] was taking too much time to return zero vector (I do this many times, so the performance matters to me). ...
Felipe's user avatar
  • 499
0 votes
1 answer
86 views

Solve constraints don't work properly

So in my previous question, I was trying to find two parameters kV and km for an implicit function using FindFit(FF) command and I did it but the problem is that it takes around an hour to do it. ...
Karen Simonyan's user avatar
4 votes
2 answers
143 views

How to efficiently duplicate and rotate a graphics object?

Consider the following code ...
sam wolfe's user avatar
  • 4,863
1 vote
0 answers
83 views

How to efficiently calculate matrix operations when the elements are defined as functions?

I'm trying to calculate the one-body density matrix of a system of particles as described in this article, given in equations 14 and 15. Here, is my code but it seems very slow. Is there any efficient ...
sudipta's user avatar
  • 63
5 votes
3 answers
338 views

How to speed up Outer[Subtract, vect1,vect2]?

My Nbody code use a lot of Outer[Subtract, vect1,vect2]. A lot means ten thousands to one hundred thousands times !! This is at the heart of my Nbody code, and I need to speed up this instruction. ...
Rémy Galli's user avatar
2 votes
2 answers
122 views

How can I enforce the use of Subtract and Divide?

It has been noted before, here and here, that when you enter a/b or a-b, Mathematica does not convert these to ...
Felipe's user avatar
  • 499
1 vote
0 answers
44 views

Why did my animated Graphics3D stop functioning after Nvidia GPU driver update? Now I have to end Mathematica process in the task manager

The following code used to work fine until just after a recent Nvidia driver update. Running the code causes Mathematica to completely hang and I must end the Mathematica process in the task manager. ...
Jeff Hunsaker's user avatar
1 vote
1 answer
170 views

How to improve the speed of this numerical integration which includes calculations of large matrix?

The integrand is Re[k^2*Sin[2*theta]*T], where k is constant, theta is a variable (x, y and fi are the other variables), and T includes calculation of large matrix ...
user59546's user avatar
  • 115
0 votes
0 answers
37 views

Compile constraints for NMinimize

I use complicated constraints for optimisation, something like Table[ EuclideanDistance[pts[[i]], pts[[j]]] >= 1 , {i, numPts - 1}, {j, i + 1, numPts}] ...
lesobrod's user avatar
  • 1,699
0 votes
0 answers
65 views

How do you rate Mathematica and Python in terms of numerical computation? [duplicate]

I often hear, in the physics community, that python is faster and overall better than mathematica for numeric calculations. But this seems very subjective since code badly written in one language can ...
Felipe's user avatar
  • 499
2 votes
2 answers
102 views

Analog of monitor which does not lead to freezes of the interface

I have some heavy computation wrapped by Monitor and ProgressIndicator. It is the template: ...
John Taylor's user avatar
  • 5,827
4 votes
1 answer
130 views

Why does Mathematica's interface freeze when scrolling to the evaluating cell?

I have some heavy computations in Mathematica that use parallelization. The CPU consumption is ~80-90%. I use ProgressIndicator to trace the progress of the ...
John Taylor's user avatar
  • 5,827
0 votes
0 answers
60 views

Recursion limit for NDSolve

I have a fairly complex equation containing many terms, I can use the NDSolve for solving the differential equation for lesser terms (6400ish). But can't do it for ...
Bravyi's user avatar
  • 21
0 votes
1 answer
64 views

How to Speed Up Piecewise Symbolic Integration

In Mathematica, I am attempting to integrate over 2-D $\phi$ "hat functions" for a FEM scheme. I suppose I am only observing "interior points" in the domain $\left( 0 , 2 \right) \...
Chloe's user avatar
  • 165
0 votes
0 answers
127 views

NDSolve gives High Oscillatory Solution [duplicate]

I want to solve a differential equation of second order with complex initial conditions. ...
Jules Alvarez's user avatar
2 votes
1 answer
158 views

Speeding up minimization problem related to a minimal surface

I am trying to find the minimum of the function $$f(x)=\int_0^1(1+t^x)\sqrt{1+x^2 t^{2(x-1)}}dt$$ which arises from trying to minimize the surface area of a function rotated around the $x$ axis. Here ...
Kamal Saleh's user avatar
1 vote
0 answers
96 views

The first step to Speed Up using GPU

If we run the following code, mathematica kernel uses only CPU : LinearOptimization[ x + y, {x + 2 y >= 3, x >= -1, y >= -1}, {x, y}] I want the ...
imida k's user avatar
  • 4,295
0 votes
1 answer
36 views

Map Integrate onto one single term

This is related to the question (Integrate many simple terms fast) I had before, where Nasser gave me an answer which worked 'most of the time' but not always. Context: ...
Confuse-ray30's user avatar

1
2 3 4 5
60