[SciPy-User] [SciPy-user] Accessing calculated function values of scipy.interpolated.quad
Mon Oct 26 12:01:22 CDT 2009
Mon, 26 Oct 2009 11:51:57 -0400, josef.pktd wrote:
> On Mon, Oct 26, 2009 at 10:40 AM, Richard Pfeifer
> <firstname.lastname@example.org> wrote:
>> Hi Scipy-Users,
>> I've got a question concerning scipy.integrate: I'm interessted in
>> (1) the Integral F = Int(f, a, b) of the function f(x) in the range
>> (2) the values f(x_i) used for the integration (to plot f(x) in the
>> scipy.integrate.quad can do the first job very well but I did not find
>> a way to get the values f(x_i). I could let scipy.integrate.quad do
>> it's job and then evaluate f(x) again for the plotting but this would
>> need twice the time...
>> Is there any way to get the [x_i, f(x_i)] scipy.integrate.quad
>> calculated for the integration?
> I think the answer is no.
> Looking at the source of scipy.integrate.quad, the python function
> returns all the return values of the fortran routine. So the actual
> points of evaluation seem to be temp variables inside the fortran
There's no pre-made solution, but you can cook one yourself:
return ...long computation...
values = 
y = func(x)
ig = integrate.quad(wrapfunc, 0, 1)
values = np.array(values)
values = values[np.argsort(values[:,0])]
More information about the SciPy-User