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.

learn more… | top users | synonyms (2)

6
votes
1answer
113 views

Every second evaluation in notebook front end is slow

I'm having a rather baffling problem that Wolfram was unable to help me diagnose, and I'm hoping one of you geniuses in residence here can figure it out. (I don't get access to the Technical Support ...
21
votes
0answers
159 views

Why is StringExpression faster than RegularExpression?

Edit: as noted by Albert Retey the performance difference is only seen when sub expression extraction is performed. If this test is used below the timings are similar: ...
15
votes
0answers
367 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 ...
8
votes
0answers
182 views

Using Compile to speed up Function with PermutationProduct

I have the following fairly simple routine dot involving PermutationProduct that I wish to speed up using ...
7
votes
0answers
69 views

How to create internally optimized expression for computing with high WorkingPrecision?

I have large dataset and need to fit rather complicated function on it with different values of one of its parameters (this parameter must be fixed in every fit). I use the ...
6
votes
0answers
149 views

Faster simplification of linear combinations of some specific functions

After some profiling I've found that my program spends most of its time in the simplification step. The program uses my simplification function many times (over different data). My calculation is not ...
6
votes
0answers
234 views

Optimizing NIntegrate for higher PrecisionGoal

By default, NIntegrate works with MachinePrecision and its PrecisionGoal is set to ...
5
votes
0answers
51 views

Faster way to perform SameQ[Reduce[…], Reduce[…]]

I'm have some expressions that I need to confirm the equality of. SameQ[Reduce[...], Reduce[...]] works like a charm for the more simple expressions, however when ...
5
votes
0answers
118 views

Parallelizing is much slower than single kernel evaluation?

Starting with a vector of matrices, tVec, I would like to parallelize the multiplication of each element with the same matrix ...
5
votes
0answers
79 views

Compiled function crashes kernel when trying to list over different length arguments

I'm trying to speed up a tally/binning operation that I have to run many times. I have many lists of between 1 and 10 numbers from the range [1,5] and I want to ...
4
votes
0answers
80 views

What is the fastest way to maintain a large set of expressions?

In my algorithm I need to maintain a set (an unordered list of distinct elements) of expressions supporting two operations: Test an expression for membership in the set Adding a new expression to ...
4
votes
0answers
101 views

Speeding up multilinear PRA branch-and-bound algorithm with worst-case exponential time scenario with respect to basic events

The algorithm is a branch-and-bound algorithm that calculates dominances for PRA, probalistic risk assessment. The task was to find faster ways to do it in numerical software such as Matlab but we ...
2
votes
0answers
142 views

why version 9 is much slower than version 8 in producing these graphics

Consider this example(taken from Thomas's question here) ...
2
votes
0answers
68 views

Speeding up a numerical constrained quadratic optimization

I'm trying to solve a quadratic optimization problem in 35 variables, $\vec{α} = \left< α_1, \ldots, α_{35}\right>$: $$ \begin{aligned} &\operatorname*{maximize}_\vec{α}&&1.0\cdot ...
2
votes
0answers
59 views

Significant platform-dependent efficiency when importing data?

I'm curious, as I understand that answer this way: If you are using a Linux derivative or something like cygwin on Windows, then this is an efficient solution for reading only the third field ...
2
votes
0answers
150 views

MathKernel.exe capped to use only 13% of CPU?

I am using a Windows machine with 8 cores. No other process than Mathematica 8 is using CPU time right now - still the MathKernel.exe CPU usage does not go beyond 13%. My current computation takes ...
2
votes
0answers
97 views

Is there documentation on the comparative performance of Mathematica functions?

Recently I have been solving some Project Euler problems. I find there are always several ways to do the same thing. For example, one could join two lists like this: ...
2
votes
0answers
150 views

FindRoot - Speed and errors

I am using FindRoot[] to solve a complicated equation. It seems I get the correct answer even though I get errors about an ...
1
vote
0answers
50 views

Is the TCPIP link type compressed?

Since I'm already piping a MathLink connection in a ssh tunnel (connect back is a pain!), I wonder if it makes sense to compress the data in the stream (ssh -C). As ...
1
vote
0answers
154 views

Faster GCD Implementation

Is there any chance to write a faster GCD than the built-in one in Mathematica? @Mr.Wizard has written one in this question (although it's not for this purpose) which is 6 times slower on a 100k ...
1
vote
0answers
175 views

Vector computation instead of iterating over a list

I am 'Map'ping over a list. I would like to do the computation in one single iteration. Is it possible? Can 'Apply' be used here? In what way is it different from 'Map' especially in this case? ...
0
votes
0answers
99 views

Speeding up a for loop by removing a Sum command

I am attempting to create an array that has of order 1000 x 1000 entries. In the entry of the last column of each row, I have to carry out a sum that could contains 100s of terms (I only used 40 here ...
0
votes
0answers
86 views

Speeding up numerical computations

So, after seeing this and this post, I was thinking whether there were any general rules for speeding up numerical computations (not only NIntegrate or ...
0
votes
0answers
75 views

Complex Integration Optimization

The following code culminates in plots calculated for each value of t as given below. I have tried compiling one of the functions and adjusting the precision of both the integration and the plotting ...
0
votes
0answers
109 views

A simple For loop visibly slowing down. Advice to fix?

I have run into a unique problem. I am going to try and describe my code and what is happening as understandably as possible. I have a For loop that does the same set of calculations over and over ...
0
votes
0answers
150 views

Best Parallel Kernel Configuration

I wrote a code snippet which counts prime numbers in any given interval because the built-in PrimePihas a limited bounds. ...