Using nquad for a double integral

Anna

Having a problem here. Here's my code so far:

from scipy import integrate
import math
import numpy as np

a = 0.250
s02 = 214.0
a_s = 0.0163

def integrand(r, R, s02, a_s, a):
        return 2.0 * r * (r/a)**(-0.1) * (1.0 + (r**2/a**2))**(-2.45)\\
*(math.sqrt(r**2 - R**2))**(-1.0) * (a_s/(1 + (R-0.0283)**2/a_s**2 ))

def bounds_R(s02, a_s, a):
        return [0, np.inf]
def bounds_r(R, s02, a_s, a):
        return [R, np.inf]

result = integrate.nquad(integrand, [bounds_r(R, s02, a_s, a), bounds_R(s02, a_s, a)])

a, s02 and a_s are constants. I need to perform the first integral over r, and then the second integral over R. The problem I think is the fact that R appears in the limits for the first integral (something called an Abel transform). Tried a few things and every time getting an error that there are either too few arguments in the boundary functions or too little.

Please help!

cromod

If you write integrate.nquad(integrand, [bounds_r(R, s02, a_s, a), bounds_R(s02, a_s, a)]), python is expecting you to affect a value to R. But you didn't because integration is carried out over R.

This syntax should work :

result = integrate.nquad(integrand, [bounds_r, bounds_R], args=(s02,a_s,a))

Take a look to the second example in the documentation of integrate.nquad.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Double integral using integral2, too many input arguments

From Dev

Evaluate double integral using trapezoidal rule (Matlab)

From Dev

efficiently calculating double integral

From Dev

Gaussian integral and double division

From Dev

Double integral of the equation in Matlab

From Dev

Solving double integral numerically in matlab

From Dev

Double integral expressed by a second variable

From Dev

Overlapping instances for between Double and Integral types

From Java

No instance for (Integral Double) arising from a use of ‘floor’

From Dev

Double integral in cartesian coordinate instead of (R,Theta)

From Dev

Double integral with function and sampled data Python

From Dev

Performing a double integral over a matrix of limits

From Dev

Wolfram alpha, double integral over a plot or region

From Dev

Integral using importance sampling formula

From Dev

Mathematica: Using 'Refine' with an unsolvable integral

From Dev

Integral using importance sampling formula

From Dev

Different integration results using Monte Carlo vs scipy.integrate.nquad

From Dev

Questions with integral2 , Double, Syms and Dot calucations

From Dev

Double integral with variable limits over implicit function in MATLAB

From Dev

Check if a passed double argument is "close enough" to be considered integral

From Dev

Discrete double integral in MATLAB if I know function value at each point

From Dev

Substitute placeholder function in integral using sympy

From Dev

Accurate multidimensional integral using boost odeint

From Dev

defining integral using trapezoidal rule(beginner)

From Dev

How to do this integral using tplquad, dblquad in python?

From Dev

Integral of an integral

From Dev

How to calculate an elliptic integral involving complexes using GSL?

From Dev

How to extract an Integral pattern out of a String using Regular Expressions

From Dev

Receiving integral sign when using confirm dialog in atom-editor

Related Related

  1. 1

    Double integral using integral2, too many input arguments

  2. 2

    Evaluate double integral using trapezoidal rule (Matlab)

  3. 3

    efficiently calculating double integral

  4. 4

    Gaussian integral and double division

  5. 5

    Double integral of the equation in Matlab

  6. 6

    Solving double integral numerically in matlab

  7. 7

    Double integral expressed by a second variable

  8. 8

    Overlapping instances for between Double and Integral types

  9. 9

    No instance for (Integral Double) arising from a use of ‘floor’

  10. 10

    Double integral in cartesian coordinate instead of (R,Theta)

  11. 11

    Double integral with function and sampled data Python

  12. 12

    Performing a double integral over a matrix of limits

  13. 13

    Wolfram alpha, double integral over a plot or region

  14. 14

    Integral using importance sampling formula

  15. 15

    Mathematica: Using 'Refine' with an unsolvable integral

  16. 16

    Integral using importance sampling formula

  17. 17

    Different integration results using Monte Carlo vs scipy.integrate.nquad

  18. 18

    Questions with integral2 , Double, Syms and Dot calucations

  19. 19

    Double integral with variable limits over implicit function in MATLAB

  20. 20

    Check if a passed double argument is "close enough" to be considered integral

  21. 21

    Discrete double integral in MATLAB if I know function value at each point

  22. 22

    Substitute placeholder function in integral using sympy

  23. 23

    Accurate multidimensional integral using boost odeint

  24. 24

    defining integral using trapezoidal rule(beginner)

  25. 25

    How to do this integral using tplquad, dblquad in python?

  26. 26

    Integral of an integral

  27. 27

    How to calculate an elliptic integral involving complexes using GSL?

  28. 28

    How to extract an Integral pattern out of a String using Regular Expressions

  29. 29

    Receiving integral sign when using confirm dialog in atom-editor

HotTag

Archive