1

Lets say i define my function G,

def G(k, P, W):
    return k**2*P*W**2

Where P and W are two functions that have independent variables of k and k is a defined number.

I am trying to integrate this from 0 to infinity

I = scipy.integrate.quad(G, 0, np.Inf)

inputting this into my console gives me the error, G() takes exactly 3 arguments (2 given)

I tried using the arg() command, but it does not seem to change it and code remains stubborn. What am i doing wrong and what am i missing?

2
  • 1
    It would be helpful to mention what integrate.quad function you are talking about. Commented Dec 5, 2015 at 22:46
  • So P = P(k) and W = W(k) but you don't want to integrate over these? Commented Dec 6, 2015 at 0:40

1 Answer 1

2

If I understand correctly, k is a constant. Then you can write:

k = 10
I = integrate.dblquad(lambda p,w: G(k,p,w), 0, np.Inf, lambda x: 0, lambda x: np.Inf)

Found it in the scipy documentation.

Besides, your integral looks divergent.

For symbolic integrals see sympy.integrate. It is a different library.

import * from sympy

k,P,W = symbols('k P W')
integrate(G(k,P,W),P,W)
Sign up to request clarification or add additional context in comments.

1 Comment

Very interesting, thank you. I would not have known to use that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.