excuse me for the long introduction. let me try to motivate my approach before I ask my question.
I need to produce a lot of graph like this
My problem is that on my i7 it take a lot of time to produce it: 95 seconds.
I'm not so expert in Mathematica optimizations, so I tried another approach: plot a discrete list of numbers instead of a continuous (complex valued and complicated) function.
The x axis has to be logarithmic (it's a problem related to audio), so, instead of discretizing my functions using a Table I built my base with a logarithmic table
logspace[a_, b_, n_] := 10.0^Range[a, b, (b - a)/(n - 1)];
and calling it as
base = logspace[1, 3, 400];
Function[\[Nu], Abs[pL[2 \[Pi] \[Nu]]]] /@ base
In this way I have 400 points to put in a graph, denser at low frequencies and less dense at high frequencies. I don't know if there is a better way to get that. Then I need to use the Level
Level[Function[\[Nu], Abs[pL[2 \[Pi] \[Nu]]]] /@ base, {-1}]
because sometimes I get (from the Function) something like
{{0.0606642}, {0.145157}, {0.175131}, {0.467571}, {0.658209}}
and something like that
{{{0.0656241}}, {{0.189852}}, {{0.61917}}, {{0.457474}}, {{0.203275}}}
I don't want to investigate and the solution seems appropriate. The final table to be used by the ListLogLogPlot is
T1 = Transpose[{base,
Level[Function[\[Nu], Abs[pL[2 \[Pi] \[Nu]]]] /@ base, {-1}]}];
Now comes the question.
Yes, the solution works fairly well. I can control the speed vs/ the precision, but now putting this new piece of code into the existing one is cumbersome and prone to errors, then hard to read.
Is there a way to encapsulate the
so that it works on another generic function?
Thanks for the patience.
I checked all the combinations, and this one looks promising:
