Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
9 views

Resultant running too slow

I have a system of equations all linear in one variable X with many parameters. I am trying to separate the variable in these equations by taking the pairwise resultants of one of the equation with ...
0
votes
0answers
37 views

Why is this iterative process with matrix calculation so slow?

I am trying something similar to the following code with Ntime as large as 100 or so. Now it's very slow as shown by the Ntime=3 ...
0
votes
0answers
65 views

How to speed up FindRoot?

How can I speed up my FindRoot time, for the below code? It takes 25 seconds on my machine to find one single root for a set of $g$, $mx$, $m\psi$ values, I need to ...
0
votes
1answer
53 views

Memoization (or otherwise) for a recurrent definition of a (double) sequence of functions

Beside I've found answers to similar questions (e.g. this), I can't adapt them to my case. I am interested in the following sequence of functions $p_{m,n}(t)$, where $m$ and $n$ are integer: $$ \...
30
votes
0answers
280 views

New Compiler Technology in V12

I am wondering whether the speed of compilation for the new compiler can be improved. Here are the results from my test. Consider the following function for generating a random draw from a gamma ...
1
vote
0answers
25 views

Speeding up solving many coupled non-linear differential equations

I am currently working on a project that involves solving many coupled non-linear ODEs$^*$ I am using NDSolveValue and the time it takes to solve everything is (understandably) slow. But I was ...
2
votes
1answer
55 views

How to speed up summations with many list callings?

I am trying something similar to the following code with NN as large as a few hundred (at least 100). Now it's very slow and most time is spent on calculating the ...
6
votes
1answer
1k views

What computer would be fastest for Mathematica Home Edition?

I am planning the purchase of a new computer for use with Mathematica Home Edition, which is limited, as far as I understand, to two simultaneous kernels. Can anyone recommend particular hardware?
9
votes
2answers
203 views

Finding the path in a graph from A to B then back to A with a minimum of shared edges

the problem is to find cycle from A to B back to A, so that the path B-A would use minimum edges from path A-B. The graph is undirected and can have cycles. The paths don't have to be shortest, they ...
0
votes
0answers
30 views

Reading a chunk of data from a stream using Parallelization

I am trying to read a stream and perform some operations in parallel. Here is the logic of the code inside the ParallelDo: 1- Open stream 2- Read chunk of data 3- Close stream 4- Process the data ...
1
vote
0answers
59 views

Memory leak in simple program

I am trying to solve a simple optimization problem on the sphere, and for some reason, I got some memory leak that I am not able to solve. To decompose the problem in step, what I wan to do is Take ...
4
votes
1answer
548 views

Limit the amount of RAM Mathematica may access?

Trying to solve a differential equation numerically, I noticed that Mathematica used up all RAM to the extent that my operating system (Windows 10) lost responsiveness and hung up. As a result I had ...
1
vote
1answer
50 views

Efficiently find all values of parameter such that any of the eigenvalues of a matrix is equal to 1

I wish to find all values for a parameter such that my matrix has an eigenvalue of 1. Here is an example 16-by-16 matrix with elements depending on the parameter x ...
5
votes
0answers
91 views

Optimize Use of PeakDetect in Mathematica

I am quite new to Mathematica and I am looking for some advice in order to improve and optimize my code. Here is what I am trying to do: Open a stream Read the stream line by line and store it in "...
0
votes
0answers
42 views

How can I speed up my code finding the parameter which yields zero determinant for increasingly larger matrices?

I build a square matrix with matrix elements dependent on the parameter x. I need to find all values of x within a reasonable ...
1
vote
0answers
61 views

Fourier transform calculation never stops [closed]

I'm trying to calculate a Fourier transform and plot it, however the calculation is running for several hours now. I suspect that there is a mistake in my script. Or am I just not patient enough? Is ...
-1
votes
1answer
49 views

Plot of complicated expression takes very long time

I have some long expressions that I got from multiplication and addition of matrices and vectors of order 4: ...
3
votes
1answer
55 views

How to improve the rendering time of a plot

The following is a link my original question: I need List Plot points to have different color based on amount of neighbours? The question was answered, and I used the first answer with ...
11
votes
1answer
358 views

ls Ordering[Ordering[list]] optimal?

Given a list list with unique elements, the task is to replace each element by its position in Sort[list]. For example, ...
2
votes
1answer
89 views

Why won't nominally compilable function compile? (err Compile::cpintlt)

Context: I have millisecond timestamped sample data that I want to convert to a uniformly sampled series. This I do by padding each interval with repeated values (pbp ~ 'pad by position'}. The ...
8
votes
1answer
423 views

Ways to speed up user implemented RK4

So, I've implemented RK4, and I'm wondering what I can do to make it more efficient? What I've got so far is below. I wish to still record all steps. I think ...
2
votes
0answers
36 views

GeoRegionalValuePlot optimization

I have the following piece of code that plots a colormap by zipcode. Zips is an array of zip codes (All in the US mainland) and testscore is just some made up data for testing purposes. The list of ...
0
votes
1answer
38 views

DeleteDuplicates in FindRoot with more than one variable

I'm solving a system of 3 non-linear equations with FindRoot for the variables x, y and <...
12
votes
2answers
324 views

Terse Method to Swap Lowest for Highest?

I have built a solution to swap the lowest values with the highest values in a list. With ...
7
votes
2answers
292 views

How to diminish computation time when nonlinearity appears in 2D heat conduction equation?

I am trying to simulate heating and melting of the steel plate by means of FEM.The model is based on nonlinear heat conduction equation in axial symmetry case. The problem statement is the next: $$ \...
4
votes
2answers
59 views

Element-wise multiplication of matrices with different dimension

I am interested in efficient element-wise multiplication of matrices with different dimension. Here is my solution: Matrix 1 with dim = {3, 4, 4} ...
1
vote
0answers
64 views

Monitoring PolynomialReduce/Alternatives for other CAS packages

I have a large generic polynomial That looks like $N = \sum_{i_1,i_2\cdots}c_{i_1,i_2,i_3,\cdots} {x_{1}}^{i_1}{x_{2}}^{i_2}\cdots $ This could have anywhere between 3000-9000 terms with a maximum ...
4
votes
1answer
133 views

Imaginary part of expression too difficult to calculate

I am trying to calculate the imaginary part of a long expression. It's a long enough expression that Mathematica "hangs" when you run: ...
22
votes
1answer
1k views

Animating wave motion in water

Further to this question I found on MSE, I tried to replicate from here this is as far as I got: ...
6
votes
2answers
126 views

How to speed up Voigt profile fits?

Voigt profile fits in Mathematica seem terribly slow. For an example data set with 81 points a corresponding fitting procedures for Voigt fits is >1000 times slower than for Gaussian or Lorentzian ...
0
votes
0answers
55 views

Pixel-wise image manipulation

I downloaded an image from a website and imported it to Mathematica ...
0
votes
0answers
33 views

Efficient method to find consecutive products in table

Suppose I have a table of matrices, $[A,B,C,D,...,Z]$ and a vector $v$. I would like to efficiently compute both $ABCD...Zv$ and the table $[A,AB,ABC,ABCD,...,ABCD....Z]$. I know that to compute the ...
1
vote
0answers
75 views

How can I improve and accelerate my 2 D algorithm?

I implemented the algorithm descussed here in the 1 D case (when $g$ is one variable function). Using a relaxation parameter the algorithm became very fast and converges in few iterations (n = 5, 6, , ...
5
votes
3answers
911 views

How to speed up a process

I am wondering how to speed up the following code: Currently it takes more than two sec to be processed. ...
5
votes
2answers
219 views

Manipulating a general length function

As a minimal example, define a function like s[1,2,3]; this is a function of three arguments in this case, but I'd like to apply this general idea to functions like ...
2
votes
2answers
93 views

Removing fractions without a particular variable

As a very minimal example, consider a sum of fractions such as: $A=\frac{a}{s_{123}bc}+\frac{d}{e}$ In practice, I have many hundreds of thousands of these fractions generated from a recursion ...
9
votes
2answers
549 views

Quickly creating a sparse array

The motivation for my question is that I'm creating very large, very sparse symmetric matrices and finding the largest eigenvalue. (Think upwards of $10^5\times 10^5$ size matrices, with at most $10^...
0
votes
0answers
47 views

How to optimize the code [duplicate]

How can I write the following code using lesser number of characters? Table[Table[{y - x, y}, {y, 8}], {x, 8}] I tried using ...
0
votes
0answers
39 views

GUI performance on OS X Mojave

I am running Mathematica 11.3 on OS X Mojave and experiencing extremely slow GUI performance. Scrolling is worse than controlling Mathematica in Linux KDE over teamviewer half around the world away, ...
3
votes
1answer
75 views

Speed up Expectation-Maximization algorithm

I would like to implement the EM algorithm for parameter estimation of a bivariate poisson model from Karlis 2003. The code is able to run, but I'm not very satisfied with the speed. I would like to ...
0
votes
0answers
38 views

FindMinimum is running too slow

For defined a function h[x_?NumericQ], I can get a plot of the function from Plot function in about seven seconds. But when I ...
8
votes
2answers
387 views

How do I remove artifacts from my ContourPlot3D Valentine?

My version (below) of the "Valentine Formula" that appeared in today's New York Times, has some ugly artifacts that don't appear in the NYT (Java) version: How do I remove these artifacts? ...
1
vote
0answers
34 views

Generic symbols vs Generic functions arguments [closed]

I've got a lot recursion relation that takes multiple hours at a time to run. I'm looking for some subtle reasons why it takes so long, and hoping to be able to reduce the time it takes for the more ...
2
votes
1answer
51 views

Improving efficency in generating Tables with large numbers of values

I'm simulating some transient data for fast Fourier transform -- on the order of 20 million points. Understandably MM takes a while to do this. Are the any techniques in table generation optimisation ...
2
votes
1answer
35 views

A fast way to create a list with $A_i\cdot B_i^{-1}\cdot C_i$ in each component

Let us suppose I have to do the following computation $A_i\cdot B_i^{-1}\cdot C_i$, where $A_i,B_i,C_i$ are conformable matrices(dim=$50\times 50$). For that, I have 3 lists, each of size 1 by 10,000 ...
8
votes
0answers
50 views

Performance warning using TakeList and All on big lists

According to Mathematica's own documentation, TakeList can operate with lists containing All. For example: ...
3
votes
0answers
77 views

Hopcroft's Algorithm for Minimization of Deterministic Finite State Automaton

Background Given a deterministic finite state automaton, Hopcroft's algorithm is a $O(n \log(n))$ algorithm for finding an automaton that generates the same language with a minimal number of vertices....
2
votes
1answer
56 views

Fast and Listable Piecewise function

I am writing a simulation where I have an array with ten columns and on the order of millions of rows, for which I need to iterate on the order of ten thousand times, making computation time a major ...
5
votes
0answers
74 views

Efficient Image Export [closed]

I am trying to export around 10000 plots from Mathematica in order to compile them into an animation with another program. Using the following, where "frames" is the list of plots ...