Mathematica Efficient sampling of function. [Mathematica]

Inve

Hey there PF.
I wanted to ask here if someone had any input as to why a tiny part of my code is "slow".

I have sloved a somewhat big eq.system numerically with Mathematica. Now, I do not really need the
actual integrated functions and so I sample them.

Below: I sample (picks out only 4 datapoints within each time unit) numerical values of the actual integrated functions through the use of Block and with
digits 12. I put these values into a table for interpolation later. "Solution" contains these functions
that I wish to sample, part "f" is present because I want to store for some different parameter values and "k"
denotes the index of solution function. (If you'd like, nevermind the "Joining"-part)

Print["Sampling..."];
gSolutionPart =
Table[SetAccuracy[
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}];
Print["Joining..."];
If[i == 0, gSolution = gSolutionPart,
gSolution =
Table[Join[gSolution[[f, k]], gSolutionPart[[f, k]]], {f, 1,
diffrentb}, {k, 1, 201}]];

I was keeping track of the time things in my code take, and then I noticed that this sampling takes a vast
majority of time. Example: I integrate for a solution that spans a measly 10 time units. Integration took not
even 1 minute. Sampling took 9 minutes. Yay. And when I sought a solution for something more accurate over a
larger intervall, integration took ~50 minutes. I waited hours on the sampling but..

Can anyone give some tips on how to improve this without having some huge RAM spike?
I am quite the noob when it comes to coding, but I wish to learn.

Related Math Software Workshop News on Phys.org

"Efficient sampling of function. [Mathematica]"

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving