0
0
SciPydata~10 mins

Triple integral (tplquad) 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 triple integration from scipy.

SciPy
from scipy.integrate import [1]
Drag options to blanks, or click blank then click option'
Atplquad
Bnquad
Cdblquad
Dquad
Attempts:
3 left
💡 Hint
Common Mistakes
Using dblquad which is for double integrals.
Using quad which is for single integrals.
2fill in blank
medium

Complete the code to define the function f(x, y, z) = x * y * z for integration.

SciPy
def f(x, y, z):
    return [1]
Drag options to blanks, or click blank then click option'
Ax + y + z
Bx / (y + z)
Cx - y - z
Dx * y * z
Attempts:
3 left
💡 Hint
Common Mistakes
Adding variables instead of multiplying.
Using division which is not the function defined.
3fill in blank
hard

Fix the error in the integration call by completing the limits for z from 0 to 1.

SciPy
result, error = tplquad(f, 0, 1, lambda x: 0, lambda x: 1, [1], lambda x, y: 1)
Drag options to blanks, or click blank then click option'
A0
Blambda x: 0
Clambda x, y: 0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a lambda with only one argument for z limits.
Using fixed numbers instead of functions for limits.
4fill in blank
hard

Fill both blanks to complete the integration limits for y from 0 to x and z from 0 to y.

SciPy
result, error = tplquad(f, 0, 1, [1], [2], lambda x, y: 0, lambda x, y: y)
Drag options to blanks, or click blank then click option'
Alambda x: 0
Blambda x: x
Clambda x, y: 0
Dlambda x, y: x
Attempts:
3 left
💡 Hint
Common Mistakes
Using lambdas with two arguments for y limits.
Swapping the lower and upper limits.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps x to the integral of f over y and z with limits y:0 to x, z:0 to y.

SciPy
results = { [1]: tplquad(f, 0, [1], lambda x: 0, lambda x: x, [2], [3])[0] for [1] in [0.1, 0.5, 1]}
Drag options to blanks, or click blank then click option'
Ax
Blambda x, y: 0
Clambda x, y: y
Dy
Attempts:
3 left
💡 Hint
Common Mistakes
Using y as the dictionary key instead of x.
Incorrect lambda functions for z limits.