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
votes
0answers
29 views

A general question about speed of working with interpolating functions

Consider a grid {x,y,z,f(x,y,z)} Here, x,y,z are real numbers, and f is a function that first monotonically increases with its argument $z$, and then quickly ...
10
votes
2answers
253 views

NIntegrate: the order of singular points matters!

Consider the following integral: $$I = \int_{-5}^5 \frac{1}{(x(x-2))^{1/3}} dx.$$ The exact value is 6.30249 - 2.2405 I. I will perform ...
4
votes
2answers
85 views

Faster searching for subsets with pairwise conditions

I am looking for a faster way of finding large subsets of lists that obey pairwise conditions. In particular, I'm looking for a large (over 10k) set of quaternary words (i.e. ordered lists) of length ...
1
vote
1answer
34 views

NIntegrate With Singularity: Experiment With Various Parameters

I want to numerically evaluate the integral $$I = \int_{\mathbb R^2} dxdy f^*(x) f(y) K(x-y)dxdy,$$ where $$f(x) = \sqrt{\frac 2 \pi} e^{ikx} e^{-x^2}, \quad k\in\mathbb R$$ is an exponentially ...
0
votes
1answer
67 views

How to analyse the performance of Mathematica on this function?

Using f[n_] := Sum[1/(Sqrt[k] + Sqrt[k + 1]), {k, 1, n}] to analyze the well-know series... I noticed a sudden performance drop (on my outdated PC hardware ) ...
1
vote
1answer
41 views

Strange behavior of NIntegrate: small change of integration range give tremendous running time difference!

I have an integrand: integrand = E^((6*I)*x - x^2 - (6*I)*y - y^2)/(2 Pi (-I (I/100 + x - y))^(1/3)) This function decays as $\sim e^{-x^2-y^2}$ for $x,y \to \...
1
vote
1answer
43 views

Why each iteration takes longer than previous one when using VariationalD in this loop?

I have a function $f$, and I would like to modify it iteratively to approach another one called $a$ (not because I think this is the best way to do anything, but for experimentation). For this, I use <...
0
votes
0answers
43 views

Alternative for PowerRepresentations[n, x, 1]

I am looking for numbers $n$ that can be written as the sum of other numbers. So: PowersRepresentations[n, x, 1]. But is there a faster way of finding these numbers?...
1
vote
1answer
89 views

Explicit integration of PDE running very slowly

I would like to solve the PDE $\frac{\partial u}{\partial t}=(1-x)\frac{\partial u}{\partial x}$, in the interval $[0,1]$, with initial condition $u(0,x)=e^{-218(\frac{-2}{3}-ln(1-x))^2}$, by manually ...
3
votes
0answers
82 views

Solving or Minimizing the Norm of the matrix equation $M^TAM - M^TB - B^TM =C$

I am trying to solve the matrix equation $M^TAM - M^TB - B^TM=C$ where I know A, B and C. My unknown matrix is M which has the special form that all the rows and columns sum to zero. i.e. I have four ...
5
votes
2answers
144 views

ListDensityPlot with RegionFunction takes too long?

I am using ListDensityPlot with RegionFunction (MMA12.3 on Win 64) but it takes too long ...
0
votes
2answers
87 views

How can I exclude specific region in ListDensityPlot

I would like to exclude the region outside the yellow Polygon in this plot, how can I do that? ...
4
votes
1answer
147 views

How can I speed up processing with DeleteCases?

I would like to get points that are only inside a region. Here are the region and unfiltered points: ...
5
votes
2answers
129 views

How to guide Eliminate or GroebnerBasis to reduce a set of simple odes to a single ode (which can be done by Laplace Transform)

Recently, I am trying to use Eliminate or GroebnerBasis to simplify a system of ODEs. I don't want the solution of ODEs. What I ...
7
votes
1answer
126 views

Pick with Unitize vs Pick with Clip vs Compiled Select speed - anything faster?

Given a large list of $n$ dimensional sublists where each sublist has integer elements I am trying to find the quickest way of finding all sublists that satisfy some constraint on their elements. A ...
4
votes
1answer
59 views

How to accelerate numerial inverse laplace transform for pdes of Euler-Bernoulli beam problem

Happy new year! :) Recently, I am practicing laplace transform technique for solving pdes. In this extemely helpful post, @xzczd mentioned that "The last step is to transform the solution back, ...
0
votes
1answer
65 views

Trying to speed up finding solutions of quadratic form related to the weight of a matrix

Say I have an integer matrix of size $5 \times 5$ - I am trying to find the solutions to the equation $n^4 wtM = n w^2 + x1^2 + x2^2 +x3^2 +x4^2 + x5^2$ subject to the constraints $x1+x2+x3+x4+x5 = 0$ ...
27
votes
8answers
1k views

Speed up Do loops in MMA 13.0

How to speed up Do loop in MMA 13. We consider the following Benchmark test (4 kernels, i7, win10): In MMA 13: ...
0
votes
0answers
38 views
2
votes
0answers
90 views

Finding the sum of the product of factorials of the digits of numbers

I want to calculate the sum of the product of factorials of the digits of numbers. So for example, when $n=467$ I get: $$n=467\space\to\space\left(4!\right)\cdot\left(6!\right)\cdot\left(7!\right)=...
-3
votes
1answer
92 views

How to find the distances to all buildings quickly?

I would like to create an association by mapping the function GeoDistance[Here,#]& over all buildings without missing locations in a reasonable amount of time less than 30 minutes. I have the ...
13
votes
0answers
226 views

3D stable fluids algorithm to simulate transition from laminar to turbulent flow

This algorithm is 3D extension of our 2D algorithm published on this page and here. We suppose that with this code we can simulate transition from laminar to turbulent flow. In this example we compute ...
5
votes
2answers
241 views

Optimizing sequential computation

The following question came up in reading group discussion of paper -- imagine taking two vectors, multiplying each by a random matrix, then taking tanh pointwise. If you repeat this process forever, ...
0
votes
0answers
52 views

How to speedup the following evaluation?

Consider the following function: ...
4
votes
0answers
50 views

A WolframKernel (with PID) is created by a LocalSubmit. After the LocalSubmit finishes its job, the kernel remains. How to kill it within Mathematica?

When defining a task with LocalSubmit, a new subkernel is created. When you remove the task after the task is done, the task is removed but the subkernel remains ...
2
votes
2answers
76 views

Speeding up ComplexExpand

I have a code where I have to take the dot product of two lists, that contain some symbols, and then use ComplexExpand. For a long list it take a very long time and ...
3
votes
4answers
123 views

How more effectively solve problems with "FindInstance" when number of variables is significantly greater then number of equations

Can you help me with solving the following problem: There are 16 variables and 3 equations (constraints) on them; is it possible to effectively solve such problems in Mathematica? What is more, there ...
7
votes
4answers
294 views

How to join two tables column-wise simply and quickly?

Consider the following tables: ival = 10^6; Tab1 = Table[{x, y}, {x, 1, ival, 1}, {y, 1, 6, 1}]; Tab2 = Table[{x, y1}, {x, 1, ival, 1}, {y1, 7, 8, 1}]; The values ...
9
votes
2answers
342 views

How to parallelize and speedup AppendTo? [duplicate]

Say I have a list of original data (for now generating random list as follows): ...
1
vote
0answers
57 views

DSolve for large nearly sparse matrix

The following code creates a system of first order linear homogeneous differential equations and attempts to solve them. The time needed scales as the 4th power of the matrix size. Is there an ...
8
votes
2answers
153 views

How to compile matrix product?

Consider the following matrices: ...
1
vote
0answers
65 views

How to compile the following evaluation?

I have the following question. I want to generate three vectors p1Unrotated,p2Unrotated,p3Unrotated at some reference frame, then rotate them by some random angles $...
1
vote
1answer
73 views

Parallel Mathematica-code that runs too slow when running PowerRepresentations[] function

Well, I am a student in elementary number theory and trying to find natural numbers that can be written as the sum of integers to the power of an integer. The code I am using now is the following: <...
1
vote
1answer
72 views

I need to speed up this summation

I tried solving this problem on my own but I cant find a proper solution. I need to evaluate the following equation: $\sum\limits_{m=1\\m\neq i}^n{\left(\dfrac{v_m~(\lambda_i\cdot B-A)~u_i}{(\lambda_m-...
2
votes
0answers
58 views

use of small functions

I was wondering if it will slow down my code if I have a bunch of small functions like isNewRound[currentMove_] := Return[Mod[currentMove, 4] == 0]; which are ...
8
votes
1answer
267 views

How to compute RandomReal faster?

I have variables $E_{1},E_{3}$ that are bounded in the following way: $$ \tag 1 E_{1}>m_{1}, \quad E_{3}>m_{3}, E_{2}\equiv m-E_{1}-E_{3}>m_{2}, \\ -1 < \frac{E_{2}^{2}-m_{2}^{2}-(E_{1}^{2}...
6
votes
1answer
199 views

Producing a random Wang Tile tiling image more efficiently

I'm following along with this SIGGRAPH 2006 paper Recursive Wang Tiles for Real-Time Blue Noise - there's a video here too. Eventually I want to try to produce the blue noise results in the paper, and ...
0
votes
0answers
79 views

Import website "Source" slows down after a few iterations

I am using Import[link, "Source"] to import the source of several hundreds of thousands of webpages in a while loop to process them. Each iteration has ...
2
votes
2answers
250 views

Optimization for numerical integration of Airy function and using NIntegrate inside NDSolve

Sorry for the long post. I need to integrate a function which uses the trajectory data given by the Lorentz force equation. We have the electromagnetic field: $$ \vec{E}=E_0 \cos{\omega(t+\bar{z})}\...
3
votes
3answers
237 views

Solving for a unique set of solutions

I have the following code: ...
3
votes
1answer
110 views

Is it possible to improve a code related with iterative closest point (ICP) algorithm?

I am trying to write a code related with ICP algorithm. The purpose of the code is matching a target data with a reference data by translational operation in XYZ axes (3-degree-of-freedom (DOF) ...
4
votes
0answers
53 views

Accelerate the retrieval time for Entity data

I like to use Mathematica to answer questions related to cities such as how many cities in the United States have a population greater than 100,000 and what the distribution of them would look like on ...
5
votes
2answers
308 views

How can I speed up RandomVariate in the following case?

I would like to generate random values of some parameter with the weight being the Poisson distribution. An important point is that each time I generate the random number I need to consider the ...
0
votes
0answers
34 views

How to optimize Code for Wolfram Challenges?

I am wondering if anyone who has knowledge of optimizing programs in the Wolfram language has any advice on how to optimize the following quantities of programs written to solve Wolfram Challenges. I ...
9
votes
1answer
169 views

How to sort lines into continous paths efficiently

As part of my work I get a bunch of lines from my co-worker. (Background: I do electromagnetic designs, my co-worker does the mechanical design). These lines are in random order, but I need them in ...
0
votes
0answers
26 views

Optimizing an 2D-NIntegrate in terms of speed

I am trying to optimize the following function further in terms of speed while maintaining the given Precision and correctness. The function decribes the two dimensional convolution of a sum of Bessel ...
0
votes
0answers
49 views

Why is Clip so slow and how can I improve its performance?

The built-in function Clip is defined as a way to clip a value between a specified minimum and maximum. Another way to do this, is simply by utilizing ...
0
votes
2answers
61 views

How do I optimize a simulation containing both a While loop and a Do loop?

I have written a simulation of a rotating molecule that I was hoping to get help to optimize. Below you see the main function in the simulation. The function FlatPart calculates the angle θ and the ...
5
votes
1answer
469 views

Generating a list of integers that sums to zero

Given a pair of integers n and k, I want to generate all lists of integers of length n, ...
8
votes
0answers
94 views

Why is WeightedData slow?

I have been using WeightedData with Histogram, HistogramList, ...

1
2 3 4 5
52