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

learn more… | top users | synonyms

2
votes
1answer
65 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. ...
14
votes
0answers
153 views

Exp is slower for some number ranges

I get a hit on performance with the Exp function depending on the range of my inputs. for example, with: ...
8
votes
0answers
96 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 ...
6
votes
0answers
98 views

Efficient image stacking

I have a list of lists of images that I would like to stack and create mean images for each list of images. Images are .jpg files 2592x1944 pixels large. Each list ...
5
votes
0answers
223 views

Problems extending NelderMeadMinimize into 2D

Update The eventual route I followed was to adapt a version of the NM-simplex written in C and link to it with MathLink. Once I've tested this out fully I'll post it here. I've been playing around ...
5
votes
0answers
86 views

Is there something like MaxProcessorUsed?

For standard procedures it is easy to test if the implementation is better or worse than other by using Timing etc. It does not help us with creating ...
3
votes
0answers
193 views

Module in numerical model for NonlinearModelFit is slow and leaks memory

I am trying to make a NonlinearModelFit where the model is the result of a numerical calculation. My code works, but it is very slow and also seems to have a memory ...
3
votes
0answers
324 views

Taking real and imaginary parts of indexed functions and speeding up ComplexExpand

I am setting up a large system of ODEs and in order to use the IDA method (which is sig. faster for my system and thus attractive), I must split my equations into real and imaginary parts. I am ...
2
votes
0answers
47 views

How to speed up solution of system of recurrence equations

I was wondering how I can improve the speed on this method for solving a particular system of coupled recurrence equations. The system is $$ \begin{align*} &V(m)=\alpha + \beta V(m+1)+\beta ...
2
votes
0answers
68 views

StreamPlot slow in version 10

In version, 10 StreamPlot seems to calculate many more points along each streamline than necessary, compared to version 7. For example, from Mathematica ...
2
votes
0answers
79 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 ...
2
votes
0answers
116 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 ...
2
votes
0answers
116 views

Frontend cursor movement speed depends on the position in large notebook file

I run Mathematica v9 on my Atom laptop (don't ask) and I got used to the fact that everything is slower. Except for one annoying thing: cursor movement (in text) is slower than the keyboard key repeat ...
2
votes
0answers
226 views

Project Euler (memory and speed issues)

Let n be a positive integer. An integer triple (a, b, c) is called a factorisation triple of n if: 1 ≤ a ≤ b ≤ c a·b·c = n. Define f(n) to be a + b + c for the factorisation triple (a, b, c) of n ...
1
vote
0answers
37 views

Speeding Up the Numerical Integration of a Product of Numerical Integrands with NIntegrate

I need to solve a set of coupled integral equations within a self-consistent cycle. The final result will be functions, say $A(x)$ and $B(x)$, which are related to each other by some integrals which ...
1
vote
0answers
78 views

Collision detection algorithm (discrete) with sweep and prune algorithm for periodic boundary conditions

EDIT: Question Updated with solution approach, but solution much slower than original implementation. Any ideas to speed up implementation? In the discussion on collision detection (see here) I asked ...
1
vote
0answers
97 views

Speeding up the numerical integration of a certain function

I'm using the following function f[t_] := 3/4 t^-3 NIntegrate[(x^4*Csch[x/2]^2), {x, 0, t}, Method -> {Automatic, "SymbolicProcessing" -> 0}]; I ...
1
vote
0answers
96 views

Increase optimization processing speed

As you know, sometimes numerically solving of optimization problems takes several minutes. For this reason 2 question came up to me: 1 - When one is abort the optimization procedure, how it is ...
1
vote
0answers
159 views

Is there a way to speed up Simplify and/or PolynomialReduce Modulus-> 2?

I'm trying to simplify a series of equations with at most 64 input terms. As the number of terms involved in the equations increase, the runtime seems to grow exponentially. Does anyone know of ways ...
1
vote
0answers
736 views

Speed up Numerical Integration

EDIT: I need to evaluate a very complicated multi-dimensional Integral. The dimension of the Integral depends on a variable j. Let's make my point clear with the ...
0
votes
0answers
42 views

Computing the coefficients for Gaussian integral

I wrote a small script to find the Gaussian integral points and weights: ...
0
votes
0answers
97 views

How can I speed up this NM optimization? Most delay seems to be due to long analytic expression

I am struggling with computational speed of a NelderMead optimization. Nevertheless my impression is that I lose lots of speed not only due to the NM optimization itself but rather to for instance ...
0
votes
0answers
57 views

Optimising prime number test code

Is it possible to speed-up this code ? Also, It would be great if people could test this algorithm. I only have a Raspberry Pi to test it on, so I can't be certain it's not a strong probable prime ...
0
votes
0answers
44 views

Broad Phase Collision Detection with Mathematica and using CUDA

In this and this post, I asked the question about a fast sweep and prune algorithm implementation for broad phase collision detection. To further speed up things a CUDA implementation would be even ...
0
votes
0answers
29 views

FindMaximum slow for fixed parameters

I hope my problem can be solved by just showing you this tiny part of my code which does not run on its own. I have an optimization problem and want these functions to work on various data sets. ...
0
votes
0answers
99 views

Low CPU usage. How to increase it? Should I?

I'm running a programme, and below are some graphics from the resources monitor from windows 8, while running my programme in version 9 of mathematica. Sorry for the foreign writings in the pics, but ...
0
votes
0answers
28 views

Tricks to speeding up optimisation of a function involving a heavy integration

This is the code, and energycoeffs[] is the function that takes in a dxd matrix and spits out a scalar value. ...
0
votes
0answers
38 views

Retrieving a Portion of Webpage Code using URLFetch

The URLFetch command is very useful for pulling the entire html source of a given webpage, however, if one wanted to speed up the process, by only requesting a ...
0
votes
0answers
122 views

CPU usage ~18%, but Mathematica is fully running

I run some very long Mathematica code, and the CPU usage of the kernel is 18% only. Why is not all of the CPU used, can I find the reason easily? Are there known ways to tell Mathematica to use more ...
0
votes
0answers
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: ...
0
votes
0answers
68 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: ...
0
votes
0answers
60 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 ...
0
votes
0answers
96 views

Timing: how make a program to work faster using built in functions and tables

I want to improve my code to make it working faster even for very large numbers. ...
0
votes
0answers
79 views

Timing Differences

In More efficient implementation for comparing coefficient lists in a Do-loop link, george2079 posts in his first answer a piece of code that takes 352 seconds to compute. When I run this same piece ...
0
votes
0answers
93 views

How to save the results in an identical Excel file (.xls) in each iteration of a Do loop

Assume the following code (Below code is just an example to clearly illustrate my problem): ...
0
votes
0answers
163 views

Speeding up inversion of symbolic matrices by invoking caching

Is it possible to reduce the computation time taken to find inverse of symbolic matrices USING CACHING TECHNIQUES accessible (if any)? I am trying to compute inverse of symbolic matrices of size ...
0
votes
0answers
70 views

Is there a faster way to do Normal[SparseArray[{{1,1,1}→1.2, {1,1,2}→20.2, …, {m,n,p}→0.3}]]?

I have a list of the form {{1,1,1}→1.2, {1,1,2}→20.2, ..., {m,n,p}→0.3} and I want to create an $m \times n \times p$ array, $A$, where the value of $A[[i,j,k]]$ is ...
0
votes
0answers
83 views

Speeding up Integrate and the numerical solution

I want to compute the drag of a plate Below is the code I am using to integrate the function ...
0
votes
0answers
147 views

Code performance problem

Could anyone help me with the attached code? How would you speed up my attached code in some degree? Your comments are highly welcome. ...
0
votes
0answers
138 views
0
votes
0answers
335 views

Performance in parameter estimation from ParametricNDSolve using varied initial conditions

I have 250 data points from a timecourse exeriment in a list, with columns specifying (1) time, (2-4) initial conditions, (5) absorbance reading. I want to fit 4 parameters (k1, k2, k3, k4) in a DAE ...
-1
votes
0answers
25 views

How could I speed up a code including a Module with many functions

I have implemented a big formula through the mathematica function Module. Within this module a lot of definitions are made (i.e. function[x_]:=). The code are working well but it is too slow. I am ...