# Tag Info

### Improve performance of DeleteDuplicates for list of matrices

Depends on the dimension of the matrix class. The fastest way of deleting without deleting for small matrices is to use Union. The EqualTest may be streamlined eg by comparing simple features like ...
• 135
1 vote
Accepted

### Compiling a function that uses MapThread

It appears MapThread is so optimized that there's no point in using compilation in this case. Every modification I tried makes code slower. ...
• 6,857

### How to express the argument through the function?

No chance for mix of exponentials and powers: Solve[a==f[d,B],d] This one is working at least with implicit roots ...
• 135

### How to produce the following table faster?

Have you checked if the RAM memory is sufficient large to hold the complete imported data sets? In windows start the task manager via Ctrl+Alt+Del and check the performance tab for storage access. ...

...
• 140k
Accepted

### How can I speed up calculation of the integral?

Using for general: $$\text{Psi1}(r,z)=\exp \left(-a z^2\right) \left(\exp \left(-b r^2\right)+\exp \left(-c r^2\right)+\exp \left(-d r^2\right)\right)$$ then we have: ...
• 12.7k

### Values of counting functions

You can use Sort with Split. This method works for both positive and negative integers. With ...
• 40.7k

### Values of counting functions

accumulatedBinCounts = Rest @ Accumulate @ BinCounts[#, 1] &; Using Daniel's input examples: ...
• 356k

### Minimizing computational time for a quantum walk problem

With inclusion of changes based on earlier comments, and Normalization of state, and few changes, rapid computational time is noted. The amended code is as follows: ...
• 3,128

### Values of counting functions

Here is an alternative method which should work well even if negative numbers are present. Let's generate some input data. Note this is about 8GB of data just for the starting list, so if you have ...
• 9,243

### Values of counting functions

Here is another way to go if the list is only nonnegative integers. ...
• 57.3k

### Values of counting functions

You can use SparseArray and Accumulate to assemble a vector cvec so that ...

...
• 11.5k
Accepted

### How to speedup integration of interpolated function with logarithmized data?

I suggest that you try to use the substitution formula:  \int_a^b \int_c^d f( \varphi(x),\psi(y)) \, \varphi'(x) \, \psi'(y) \, \mathrm{d}x \, \mathrm{d}y = \int_{\varphi(a)}^{\varphi(a)} \int_{\psi(...
Accepted

### Why does Mathematica take so long to produce this sound?

Creating the audio signal as a vector first allows us to use more efficient ways to sample the function: ...

### Why does Mathematica take so long to produce this sound?

The way you have created the function you are forcing MMA to keep evaluating your expression, which although lightweight on its own, is rather heavy when it needs to be repeated for different values ...
• 1,019

### Speeding up Gaussian sampling

This is my LibraryLink take on this. I use one of the random number generators of the standard library in conjunction with OpenMP. This will only work on Apple Silicon with OpenMP installed via ...
Accepted

### Speeding up Gaussian sampling

We can achieve noticeable speedup with Intel's MKL random number generator, which leverages hardware accelerated code. m = 1000000; d = 100; Default behavior: <...
• 34.5k

### Speeding up Gaussian sampling

Watching Activity Monitor, I don't think RandomVariate is multithreaded. Luckily random samples from a normal distribution can be compiled. We can exploit ...
• 34.5k
1 vote

### Fastest way to check if array is zero

You can try the following AA = {{0, 0}, {0, 0}}; AllTrue[Flatten[AA], PossibleZeroQ]
1 vote

### How to speedup calling the interpolation function?

Try purefunctionas Interpolation object ...
• 43.1k

### What is the fastest way to count square-free words?

This has come round again. The latest would appear to be https://arxiv.org/pdf/2012.03926v2.pdf

### Arrange 1-n^2 in n×n grid satisfy products of rows equal to products columns

The brute-force method you used works great for $n=3$ but there are too many permutations for values of $n$ greater than 3. Because you've stated that you don't necessarily need all solutions, another ...
• 37.1k
Accepted

### How to assign a new value to the table inside Compile?

Not sure if this is a toy example, but here's a way: ...
• 226k
Accepted

### Why the ugly code is faster than the pretty code?

The issue seems to be that you use coordx1 = coordx[Tab1[[i]][[indexE]], M, Tab2[[j]][[indexE1]]]; instead of ...
Accepted

### Solving $\sum_i a_i p_i^k=b_0$ for $k$

Writing your own "Newton's Method" is even faster (although that likely has fewer guardrails than FindRoot). ...
• 37.1k
### Solving $\sum_i a_i p_i^k=b_0$ for $k$
Taking advantage of @BobHanlon 's comment and using interpolation, one can determine the minimum and maximium possible values of $k$ to get a quicker approximation (maybe 15 to 20 times faster). Basic ...