[SciPy-User] scipy integration question

Pauli Virtanen pav at iki.fi
Fri Jan 14 12:23:25 EST 2011


Tue, 11 Jan 2011 13:21:11 -0800, Robert Thompson wrote:
[clip]
> def k_integrand(k,W,P):
>      return k**3*W**2*P
[clip]
>      sigmaresult, err = quad(k_integrand,0,kmax,args=(W,P))

That integral can be done analytically. The result is

	kmax**4*W**2*P/4.

Perhaps the Python code you wrote does not correspond to what you intend 
to do?

It's difficult to help more without knowing in more detail what it is 
that you want to compute --- if you post the mathematical description of 
the problem, maybe someone can show how to translate that to Scipy.

-- 
Pauli Virtanen




More information about the SciPy-User mailing list