# Tagged Questions

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.

73 views

### Manipulate get stuck when ConvexHullMesh get transparent

Version 10.3 The followinng Manipulate is a bit slow, but quite OK ...
118 views

### default RGB coloring

I am playing with some basic genetic algorithms to recreate input images by transparent plane figures (similar like here:). Everything would work great but the speed is terrible. I was looking for a ...
119 views

### strange timing result of LinearAlgebraBLAS in mathematica?

BLAS is short for "Basic Linear Algebra Subprograms". It is a famous collection of routines for doing linear algebra. I just know from Oleksandr R. that mma can directly call BLAS under the context ...
28 views

### Multivariate remainder of polynomial in respect to a set of polynomials

I would like to have a really fast routine that computes the so called Normal Form of a multivariate polynomial f in respect to a set of other multivariate ...
60 views

### Exceeding time constraint of 300 seconds when taking coefficients of some expressions from schur polynomial [on hold]

I have written a code that takes coefficients of some expressions from schur function, but it seems to take a lot of time, and Mathematica will stop after 300 seconds saying that it's over the time ...
125 views

### My introduction to Compile

I am reading Fractals from the Newton-Raphson method from Peter Young's page [http://young.physics.ucsc.edu/115/]{http://young.physics.ucsc.edu/115/}. I've tried: ...
74 views

### Finding matrix given null space

Suppose I input a very large $n$ integer vectors and I wish to compute the matrix whose nullspace is spanned uniquely by these vectors. Is there an appropriate command/module to do this using ...
107 views

### How to be more efficient/faster with this MatrixExp-vector multiplication?

I am looking for expertise that helps to improve speed of the code below. First, a little bit of background: There is some system of differential equations $\dot{\vec{m}}(t)=S(t)\vec{m}(t)$. In order ...
43 views

### Minimization of linear combination of vectors

Suppose I have a vectors in $\mathbb{R}^{6}$. For example, take the vector $v = k(-2,2,4,6,2,2)$. I would like to find some $k$ with the constraint that the last two components are necessarily ...
39 views

### Performance of different Count patterns

The two pieces of code below are functionally equivalent, and I would have expected similar performance. (The only difference between the two is the form of the pattern used.) But the second piece of ...
280 views

### Efficient way to perform local Otsu thresholding on image

I have images of cell nuclei that have locally varying intensity distributions. Therefore, I need a robust local threshold algorithm. LocalAdaptiveBinarize works ...
156 views

### Speeding up generation of block diagonal matrix

I'm struggling with the following problem. I have $48$ square matrices (full, filled with real machine precision numbers, thus are packed, all different) of size $128$. I wolud like to place them on a ...
62 views

### Efficient solution of huge sparse linear system

I'm trying to improve efficiency of my code in which main task is a solution to huge (~$10^4\times 10^4$) but sparse linear system $$Ax=b$$ (In fact my aim is to solve nonlinear equations $F(x)=0$, ...
67 views

### How to increase speed of iterations with nonlinear functions

Let me ask about part of a problem which I have in solving of a nonlinear DE (numerically). I am working with vectors of length $xN$. I have an initial vector $v$, a given $xN\times xN$ matrix $A$ and ...
665 views

### Terrifying performance decrease for contour/density plots in v10.1 -> 10.3

I setup for download a test dataset at http://www.inrim.it/~magni/cm.dat.gz (a set of 64800 triplets x,y,z). The behavior can be reproduced with the following code: ...
68 views

### Deleting isomorphic graphs efficiently

I'm trying to delete isomorphic graphs from a large list. My solution is as follows: DeleteIsoG1[gl_List]:= Module[{}, DeleteDuplicates[gl,IsomorphicGraphQ]]; ...
96 views

### Is there a good way to check, whether a small value produced numerically is a symbolic zero?

I have a complicated 4x4 matrix and need to know the eigenvalues. I expect a zero eigenvalue for physical reasons. Giving numerical values first gives me an eigenvalue of $\mathcal O(10^{-15})$. Now ...
83 views

### Count degrees of freedom of a polynomial

I want to count the independent degrees of freedom of a polynomial in three variables $(z_0,z_1,z_2)$. Therefore I take the coefficients of $f$ and compute the rank Jacobian with respect to the ...
178 views

### Finding large Collatz Sequences, trying to improve speed

Background: I am already very much in love with Mathematica but I am also a novice. So far I have only gathered experience in procedural programming in Python. Generally speaking I am trying to ...
135 views

### precision and speed inefficiency issues of Nearest function with sqrt expression [closed]

Recently, Nearest has been attacked for many bugs. Some are already fixed. I am going to show some issues when Nearest applied ...
139 views

### How to handle Indeterminate TimeConstrain

I have to use Timeconstrained[aux] first for avoid some bigs calculation that dont need and it use a lot of time of calculate, so i can't do this. ...
298 views

### Smallest element distance between two lists

I have a problem, where I generate two lists of points, and I want to see which points are the closest. If I just want to find which ones are exactly the same, I can use ...
49 views

### MySQL insert statement over remote server is extremely slow. How can I speed it up?

I need to insert values to a remote MySQL server. However it is extremely slow compared to a local MySQL server. This is my timing for the local MySQL server ...
2k views

### Difference between AbsoluteTiming and Timing

I need to evaluate the efficiency of my code. Therefore I would like to evaluate the time the code need for some calculations. Mathematica gives me two possibilities for this kind of evaluation: ...
89 views

### Efficient and fastest way to execute 4 nested loops

I have a question regarding the use of ParallelDo. I tried to parallelize the following code involving four nested do loops by using paralleldo to make it as fast ...
307 views

### Why is multidimensional Reverse slow?

Bug introduced in 6.0 or earlier and persisting through 10.3 I have found that multidimensional Reverse is ~10 times slower than exact ...
124 views

### can this code be faster?

Below is a lattice point generation code I write ...
81 views

### Expensive MeshRefinementFunction

I want to discretize a region using DiscretizeRegion. Now, I want the mesh to be more refined, when the curvature of a certain function ...
366 views

### Highlighting pattern strings in a large text

I would like to apply Style to strings that are matched, for example, with one or more specified patterns or regular expressions, a string or a list of both, ...
60 views

### Can not understand this timing result

I set a=1. tmptmp = Tuples[Range /@ {1000, 100}].{{3 a, 0}, {0, Sqrt[3] a}} And then run ...
37 views

### NMinimize error

I want to use NMinimize in the following way: ...
55 views

### Long delays before showing the result in a notebook

I'm new to Mathematica. I have Version 10.3.0 running under Windows 10, 64-bit. If I open the 10.3.0 kernel and type 2 + 2 Shift Return I get an immediate answer. If I open the main program and ...
936 views

### DeleteDuplicatesBy is not performing as I'd hoped. Am I missing something?

Déjà vu: a new-in-v10 function should provide a better solution to an old problem, but my enthusiasm is curbed when I run timings. This time the function is ...
2k views

### Fastest way to measure Hamming distance of integers

I am looking for a fast and robust way to calculate the Hamming distance of integers. The Hamming distance of two integers is the number of matching bits in their binary representations. I expect that ...
484 views

### Riffle and Partition

At some point I noticed that I was using Riffle and Partition together a lot. I would do things like ...
85 views

### integration of a list of gaussian type orbitals (GTO)

I am currently trying to integrate various components of a current density (j={jx,jy,jz}) over space. The problem is that the current j is extracted from a quantum chemical computation and is a sum of ...
212 views

### Number of divisors visualized with the QPochhammer function, how to improve performance of code?

I have this code that is originally Jeffrey Stopple's code for the Riemann zeta function in the complex plane. Because I discovered yesterday that the number of divisors can be generated with the ...
120 views

### Speed matrix multiplications

I am trying to run this function ...
205 views

### Gamma function computation efficiency?

I wonder what kind of algorithm is used to compute the values for the gamma function. Specifically, I am interested in how the computational load increases when the complexity of the input grows. So, ...
84 views

### Efficiently traversing a list

Suppose I have a large list of algebraic expressions, sorted by their equivalent numerical value (under a certain set of assumptions). Some of these expressions are identical, but commands like ...
1k views

### Fast Spherical Harmonics radiative transfer

This is a rather specific question and I apologize for spamming you with some lengthy code. But it could be interesting for some reader and maybe you can help out, so please bear with me. I am using ...
80 views

### Parallel function evaluation for minimal value

I am asking myself, if the evaluation of a function f looking for a minimal value over a discrete set of values can be parallelize (brute scan for a potential ...
190 views

### Timing problem with ReplaceRepeated

I have the following data: ...
76 views

### Overlap between lists of sublists with different dimensions

I have two lists of sublists. The sublists in the first list contain three elements while the points in the second list contain four e.g.: ...
113 views

### Efficiently generating plots from lists of differing lengths

I guess this is more of an informatic question. A quite complicated function of mine generates me a list of valid points, depending on a parameter, like this: ...
77 views

### Why does Timing return different times for the same calculation?

I did an experiment in which I calculated the same quantity two different ways to see which method was faster. To my surprise, the kernel time was different in different runs. In fact, which method ...
3k views

### What is a Mathematica packed array?

A simple sounding question with a few sub questions: What is the difference between unpacked vs packed array? Are packed arrays more space efficent, how much so? Are packed arrays more time ...
75 views

...