Substitution
Integration by substitution (lesson 2.6.1)
0 of 6 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Integration by parts
Integration by parts (lesson 2.6.2)
0 of 6 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Improper integrals
Improper integrals and the Gaussian integral (lesson 2.6.3)
0 of 6 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Coding exercise
The normal distribution from its density
Write two functions without using scipy.stats.
normal_pdf(x)returns .normal_cdf(x)returns , computed withscipy.integrate.quadandmath.inf(lesson 2.6.3).
The tests compare your functions with scipy.stats.norm. They also check that is symmetric, that , that , and the far tails and .
is about , so the test asks for it to be within of 0. Case study 2.6.5 shows why such tiny tail areas need care.
See the tests
from scipy.stats import norm
def test_pdf_at_zero():
"""φ(0) = 1/√(2π), about 0.3989"""
expect_close(normal_pdf(0.0), norm.pdf(0.0), what="normal_pdf(0)")
def test_pdf_symmetric():
"""φ is symmetric: φ(1.5) = φ(−1.5)"""
expect_close(normal_pdf(-1.5), normal_pdf(1.5), what="normal_pdf(−1.5) vs normal_pdf(1.5)")
def test_cdf_middle():
"""N(0) = 0.5"""
expect_close(normal_cdf(0.0), 0.5, what="normal_cdf(0)", rel=1e-8)
def test_cdf_values():
"""N(x) matches scipy.stats.norm.cdf at several points"""
for x in (-2.0, -0.5, 1.0, 1.96):
expect_close(normal_cdf(x), norm.cdf(x), what=f"normal_cdf({x})", rel=1e-7)
def test_cdf_symmetry():
"""N(x) + N(−x) = 1: the two tails of the bell have equal area"""
for x in (0.4, 1.3, 2.5):
expect_close(normal_cdf(x) + normal_cdf(-x), 1.0, what=f"normal_cdf({x}) + normal_cdf(−{x})", rel=1e-8)
def test_cdf_tails():
"""N(−8) is nearly 0 and N(8) nearly 1"""
expect_close(normal_cdf(-8.0), 0.0, what="normal_cdf(−8)", abs_tol=1e-12, rel=0)
expect_close(normal_cdf(8.0), 1.0, what="normal_cdf(8)", rel=1e-9)