<jupyter_start><jupyter_text>NOTE: Videos and graphs do not display immediately on all devices.  If this is the case for you, click the "Cell" menu option, and select "Run All".  If you still do not see the videos/graphs, try a different browser.  If that also does not work, please let your instructor know by email. Improper IntegralsIn this notebook, we extend the concept of a definite integral, $\displaystyle \int_a^b f(x) \ dx$ (defined on a finite interval $[a,b]$), to the case where either1. the interval is infinite, or 2. the integrand approaches infinity at one or more points on the interval $[a,b]$.  Such integrals are called improper integrals. 1. Motivational Example Leading to an Improper IntegralSuppose that a chemical is produced at a rate of $e^{-t}$ moles/second.  At time $t=0$, this chemical is produced at a rate of 1 mole/second, after which the rate of production decreases exponentially.The amount of chemical produced up to time $t=3$ seconds is represented by the definite integral\begin{align}\int_0^{10} e^{-t} \ dt & = \left. \left( - e^{-t} \right) \right|_0^{3} \\ & = -e^{-3} - \left( -e^{0} \right) \\ & = -e^{-3} + 1 = 1 - e^{-3} \approx 0.95 \ \mbox{moles}.\end{align}What if the process runs forever?  Will the amount of chemical produced be infinite?  Or finite?  If the amount is finite, how much?  It seems that we need to evaluate the following improper integral:$$\int_0^{\infty} e^{-t}\ dt.$$But how do we do that? 2. Handling an Improper Integral of the Form $\displaystyle \int_a^{\infty} f(x) \ dx$In the following video, we will show how to deal with an improper integral of the form $\displaystyle \int_a^{\infty} f(x) \ dx$, and work through a couple of examples, including the example introduced above.<jupyter_code>from IPython.display import YouTubeVideo
YouTubeVideo('xOiCve1hQCE')<jupyter_output><empty_output><jupyter_text>3. Handling Improper Integrals of the Form $\displaystyle \int_{-\infty}^{a} f(x) \ dx$ and $\displaystyle \int_{-\infty}^{\infty} f(x) \ dx$Integrals of the form $\displaystyle \int_{-\infty}^a f(x) \ dx$ and $\displaystyle \int_{-\infty}^{\infty} f(x) \ dx$ also are improper integrals.In the following video, we show how to deal with these improper integrals and work through a few additional examples.<jupyter_code>from IPython.display import YouTubeVideo
YouTubeVideo('FOK__rFUqA4')<jupyter_output><empty_output><jupyter_text>4. Other Improper IntegralsThe improper integrals considered above have at least one infinite limit of integration.  These improper integrals are all referred to as improper integrals of the first kind.Improper integrals of the second kind are those where the integrand approaches infinity at least once on the interval of integration.  An example is $\displaystyle \int_{-1}^{2} \frac{1}{x^2} \ dx$.  Recall that the antiderivative of $1/x^2$ is $-1/x$.  If we were to proceed carelessly, we might write the following:\begin{align}\int_{-1}^2 \frac{1}{x^2} \ dx& = \left. \left( - \frac{1}{x} \right) \right|_{-1}^2 \\ & = -\frac{1}{2} - \left( - \frac{1}{-1} \right) \\ & = -\frac{1}{2} + \frac{1}{-1} = -\frac{1}{2} - 1 = -\frac{3}{2}.\end{align}We obtained a negative value.  But surely this cannot be right, since the function $\displaystyle f(x) = \frac{1}{x^2}$ is a positive function (it lies entirely above the $x$-axis), as shown in the following graph:<jupyter_code>%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-4, 4, 1000)
plt.plot(x, 1/(x*x), label=r'$f(x) = \frac{1}{x^2}$')
plt.xlim(-4,4)
plt.ylim(0,100)
plt.xlabel('x', fontsize=15)
plt.ylabel('y', fontsize=15)
plt.legend(loc='best', fontsize=15)
plt.show()<jupyter_output><empty_output><jupyter_text>Since $\displaystyle f(x) = \frac{1}{x^2}$ is a positive function, any definite integral must evaluate to a positive number.  The reason for the strange result (obtaining a negative number) lies in the fact that $\displaystyle \int_{-1}^{2} \frac{1}{x^2} \ dx$ is not a definite integral, but an improper integral whose integrand is undefined at $0$.In the following video, we show how to handle improper integrals of the second kind, and work through a couple of examples, including the example introduced above.<jupyter_code>from IPython.display import YouTubeVideo
YouTubeVideo('Hb8AIb92zxs')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1257471264367816, 'fraction_numerical': 0.019770114942528734, 'mean_word_length': 4.606958762886598, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '596465', 'license': 'Apache-2.0', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1305, 'n_words': 549, 'path': 'ImproperIntegrals.ipynb', 'repo_name': 'gerdadevries/MATH136Notebooks', 'size': '4350'}