Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Inherent slowness or just a bad approach?' topicStudent Support Forum > General > "Inherent slowness or just a bad approach?"

Next Comment >Help | Reply To Topic
Author Comment/Response
05/17/12 01:46am

I am having trouble with a little piece of code. It is working, although it is not of practical use. This because it takes too long time to compute. Why it takes this long time I do not understand, since all I want to retrive is a real numerical value from an interpolated function that is a solution given by NDSolve. Seems simple enough right?

How the relevant code is structured:

//I get a table of solutions

solutions = Table[NDSolve[... ...],...]

//Next I want to sample the solution functions with 4 datapoints per timestep

gSolutionPart =
Block[{t = v}, Subscript[y, k][t] /. Solution[[f, 1, k]]],
12], {f, 1, diffrentb}, {k, 1, 201}, {v, i,
i + (parttime - 1/4), 1/4}];

And here at the sampling is where the code computes like syrup. I narrowed the slowness down to the computation of a datapoint of a interpolated solution function given by NDSolve.

Now, is there any other, preferably better, way to sample points from an interpolated function?

Currently I am numerically solving a somewhat large nonlinear system of differential equations. So if the integration of the system takes, lets say half a minute, the sampling (just retriveing a few datapoints!) takes more than double the time. For example I had an integration for the solution span ~50 mins of computation time, then the sampling took several hours.

A restriction I am working under is that I want to avoid huge RAM spikes since the integration needs its space.

Is this slowness inherent in Mathematica? Can I get around it in some way? Please help a fellow out if you have some ideas. Much appriciated.

URL: ,

Subject (listing for 'Inherent slowness or just a bad approach?')
Author Date Posted
Inherent slowness or just a bad approach? Patrik 05/17/12 01:46am
Re: Inherent slowness or just a bad approach? Bill Simpson 05/17/12 1:47pm
Next Comment >Help | Reply To Topic