0
0
SciPydata~10 mins

Double integral (dblquad) in SciPy - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the function for double integration from scipy.

SciPy
from scipy.integrate import [1]

result, error = dblquad(lambda x, y: x*y, 0, 1, lambda x: 0, lambda x: 1)
print(result)
Drag options to blanks, or click blank then click option'
Adblquad
Bquad
Ctrapz
Dsimps
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'quad' instead of 'dblquad'.
Using 'trapz' or 'simps' which are for numerical integration but not double integrals.
2fill in blank
medium

Complete the code to set the limits of integration for y as functions of x.

SciPy
from scipy.integrate import dblquad

result, error = dblquad(lambda x, y: x + y, 0, 2, [1], lambda x: 3)
print(result)
Drag options to blanks, or click blank then click option'
Alambda x: 0
Blambda y: 3
Clambda x: 2
Dlambda y: 0
Attempts:
3 left
💡 Hint
Common Mistakes
Using lambda with y instead of x for limits.
Using a constant instead of a function for limits.
3fill in blank
hard

Fix the error in the order of variables in the integrand function for dblquad.

SciPy
from scipy.integrate import dblquad

result, error = dblquad(lambda [1], 0, 1, lambda x: 0, lambda x: 1)
print(result)
Drag options to blanks, or click blank then click option'
Ax, y: y*x
By, x: x*y
Cx, y: x*y
Dy, x: y*x
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of variables in the lambda function.
Using y first instead of x.
4fill in blank
hard

Fill both blanks to correctly compute the double integral of f(x,y) = x^2 + y^2 over x in [0,1] and y in [0,2].

SciPy
from scipy.integrate import dblquad

result, error = dblquad(lambda [1]: x**2 + y**2, 0, 2, [2], lambda y: 1)
print(result)
Drag options to blanks, or click blank then click option'
Ax, y
By, x
Clambda y: 0
Dlambda x: 0
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping x and y in the lambda function.
Using a constant instead of a function for limits.
5fill in blank
hard

Fill all three blanks to compute the double integral of f(x,y) = x*y over x in [0, y] and y in [0, 1].

SciPy
from scipy.integrate import dblquad

result, error = dblquad(lambda [1]: x*y, 0, 1, [2], [3])
print(result)
Drag options to blanks, or click blank then click option'
Ax, y
Blambda y: 0
Clambda y: y
Dlambda x: 1
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of variables in the lambda function.
Using incorrect limits for the inner integral.