# Tagged Questions

Questions about optimizing code for faster results, or how to do faster computations.

260 views

### Choose between Apply and Map

Even though this might be too general question(or not answerable), I want to get some advice here. I apologize in advance if it is not a relevant question. I frequently have to process large list of ...
124 views

### Speed up NIntegrate, which takes eigenvalues from another function

I have simplified my problem here, in my actual problem the matrix is much bigger which makes it impossible to find eigenvalues analytically. So, I chose standard BCS problem (2x2 matrix) to ...
99 views

### How to speed up execution of this function?

How can I speed up the execution of following function, specifically for larger values of n? ...
107 views

### Why is C-compiled (but not WVM-compiled) code so slow in Manipulate?

Here is a small section of code from this SE question which computes the real part of the dilogarithm (the upper limit of the sum is increased for demonstration purposes): ...
105 views

### Optimizing alphametrics code

First of all, thank you all in this great community. I have been reading a lot of threads about Mathematica optimization learning things like using Compile ...
113 views

### How do I understand this big difference in speed:

A friend of mine found a huge difference in runtime speed between these two ...
269 views

### Mathematica 10 issue: working with Entities slows down recurrence equations [duplicate]

I was looking at the Mathematica code given at http://community.wolfram.com/groups/-/m/t/326240 where example code is given to simulate the spreading of a supposed Ebola outbreak in Nigeria: ...
226 views

### Help at speeding up simplification/nested symbolic integration

I have the following problem: I want to compute an integral of the form $$\int\limits_0^{t_g}\mathrm{d}t_2\int\limits_0^{t_2}\mathrm{d}t_1\left[A(t_1),A(t_2)\right],$$where $\left[B,C\right]=BC-CB$ is ...
107 views

### How to make Graphics3D with multiple lighting sources being rendered faster

I have a very "precise"(through setting "SpherePoints") Sphere illuminated by hundreds of random color lighting sources. The ...
72 views

### Duplicate values n-times [closed]

I already asked how I can take the list {1,2,3} and get {1,1,1,2,2,2,3,3,3} out of it, adding degeneracy to the problem. So far ...
49 views

### More on performance of Sum[]

There is an interesting discussion on performance of Sum[] in this question. I actually wanted to reproduce findings from this answer. So, I entered: ...
53 views

### Speed optimization of Mean calculation in a previous calculated data range

I have following problem: My calculations work quite well with the shown testdata, the only problem is the speed of it. My original dataset is about 64000 datapoints, and it takes several minutes to ...
258 views

### The speed of Sum[] varies strangely

I was curious about the difference in speed between Total and Sum. I found out Total was ...
79 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. ...
481 views

### Over 30mins to generate the first eigenvector?

Is it normal for Mathematica to take over 30mins to try to compute the first eigenvector of a 100x100 matrix? The matrix is reasonably sparse - about 90% of the cells are 0s and each column sums to ...
87 views

### Improve on timing of NMinimize

I got a little performance problem with the function NMinimize (it takes mathematica approximately 10 minutes to compute the results). Here i s my sample code: ...
137 views

### Neighbourhood - Calculations

SeedRandom[0]; n = 5; (m = N @ RandomInteger[{1, 3}, {n, n}]) // MatrixForm result1 = MeanFilter[m, 1] // MatrixForm ...
66 views

### Speed up numerical optimization (for plotting and solving)?

Briefly speaking, I want to plot a function PIfun[], which its value is based on numerical optimization using NMaximize. It ...
350 views

### Why some built-in functions are slow

I just wonder why some built-in functions are slower compared to some other ways using more than one built-in functions for doing same job. consider this example: ...
451 views

### Colorize Grayscale Image

I have a grayscale image that contains two objects. The grayscale pixel values can be divided into three intervals where two of them represent objects and the third represents the background. The ...
472 views

### Total much slower in version 10

Issue introduced in version 10, fixed in 10.0.2 Compilation nowadays may give very fast functions. Here is an example for finding the sum of a list of machine numbers, just as the built-in function ...
156 views

### 2D Fourier transform of a few (4) disjoint discs on a plane

I'd really appreciate some advice. Short Version I'm trying to calculate the following  ...
376 views

### Collision detection algorithm (discrete) with sweep and prune algorithm

For a more complex collision detection approach, I need an efficient (aka fast) algorithm to prune the elements by using boundary boxes. A classical algorithm is the so called sweep and prune (SAP) ...
332 views

### Faster Integer Approximation of pi

I'd like to speed up this calculation: First[Sort[Table[{k,Abs[Round[k/Pi]Pi - k]1.{k,1,100000}],#1[[2]]<#2[[2]] &]] The code above generates a list of ...
125 views

### NSolve for complicated equation involving double cross product

I have the following issue. I am trying to solve a 3-vector equation for the vector slx, sly, and ...
227 views

### Speed of ConvexHullMesh

Pick $N$ random points on the surface of the sphere, then use ConvexHullMesh[] to compute their convex hull. Empirically, this takes time quadratic time in $N,$ ...
313 views

### Replacing matrix values

I want to find the n largest values in a matrix and replace all others with zero. The solution I found uses ReplaceAll and becomes very slow as the size of ...
230 views

### Extracting values with multiple keys

I want to extract sorted data from a huge database based upon two (or more) keys in a very timely manner. Here is a reproducible toy example for two keys only: ...
1k views

### How to speed up my Project Euler code

The evaluation speed of Mathematica often depresses me. It did it again when I wrote a code to solve a Project Euler problem. https://projecteuler.net/problem=206 Here's my code: ...
298 views

### Speed up Schwarz-Christoffel mapping

I would like to ask your advice how to speed up Contour and Parametric plots in the following example. Let as start by defining a function ...
57 views

### Speeding up ReplaceRepeated while truncating to desired order

I need to program in an algorithm that recursively makes algebraic replacements which leads to an utterly complicated algebraic function of $x$, but whose final result is only needed at fixed order in ...
82 views

### An efficient way to merge a pair of 4d arrays of non regular length lists

Question I have two 4 dimensional non regular length lists of complex values. I have working code however it seems quite slow and I am not sure how I could improve this. Mathematically I am trying ...
169 views

### How do I speed up a plotting of NIntegrate when repeated multiple times inside Plot?

I am studying a set of functions (many of which I know only as a definite integral) and I have assembled into a list. Here is a sample: ...
371 views

### Slow work of SQLInsert with SQLite

I want to store my data in SQLite database, but writing large numbers of data its too slow. For example: ...
110 views

### Improving the speed/efficiency of multiple (finite range) convolutions for a causal response plot

So I am looking at modelling the response of a system that is excited by multiple pulses over a period of time. The way to find the response at time t is to take the convolution between the impulse ...
196 views

### Time-efficient creation of matrix

I have expressions like xx1=FF[1, 1] GG[1, 1] + FF[1, 1] GG[2, 2] + FF[2, 2] GG[2, 2] xx2=2*FF[1, 2] GG[1, 1] + FF[1, 1] GG[1, 2] + FF[2, 2] GG[2, 2] and I want ...
119 views

### Time-efficient manipulation (zeroing) of expression

I have huge matrices in the form of ...
229 views

278 views

### Porting code from MATLAB

I'd like to switch from MATLAB to Mathematica for my research in digital signal processing. I used Mathematica a lot during the '90s but I haven't used it since then, so I might as well be a complete ...
126 views

### Mathlink program with low cpu usage on linux machines only

Question I am incorporating some c++ code via Mathlink into my simulations in Mathematica. My questions involves the execution efficiency of the c++ code on different machines. For example, on my ...
199 views

### Why is AllTrue much slower than VectorQ?

This seems to be a theme with V10, a new function dedicated to a specific task doesn't live up to expectation performance-wise. Mr. Wizard has already uncovered 2 such functions here and here. So how ...
825 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 ...
910 views

### Why is the new PositionIndex horribly slow?

This issue has largely been mitigated in 10.0.1. New timings for the final test below are: ...