Background
I approached my physics professor with question 1 from this LibreTexts resource. (at the bottom of the page), to better understand the material via self-study.
Question
Using the Maxwell-Boltzman function, calculate the fraction of argon gas molecules with a speed of $305\ \text{m}/\text{s}$ at $500\ \text{K}$.
My attempt
We have argon molecules in the air at $500\ \text{K}$ and we'd like to know fraction of the gas molecules with a speed of $305 \text{m}/\text{s}$. So, we have
- $M=39.948 \ \text{g/mol}=0.039948\ \text{kg/mol}$
- $R=8.3145\ \text{J/mol}\cdot K (\text{as in SI units, the real gas constant, }\ R, \text{is equal to }\ 8.3145 \text{J/mol}\cdot K)$.
- $J=\text{Kg}\cdot\text{m}^2/\text{s}^2$
- $T=500\ \text{K}$
$$\int^{305.5}_{304.5} 4\pi \left(\frac{0.039948}{((2\pi)8.3145)500}\right)^{3/2}x^2\exp\left(-\frac{0.039948x^2}{(2\times 8.3145)500}\right)dx=0.00141405\ \square$$
My professor mentioned that I was correct in assuming that as we only want the atom with speed of $305 \text{m/s}$, the limits should be $304.5 - 305.5$. However, since this is such a small interval, we can just approximate the area under the curve with a simple rectangle with height $f(305)$ and width $1$. No integration is necessary.
My Attempt
$$\int^b_a f(x)dx \approx \Delta x\left(\frac{y_0}{2}+y_1+y_2+y_3+\cdots+\frac{y_0}{2}\right)$$ where $\Delta x=\frac{b-a}{n}$. We have $a=304.5, b=305.5, n=4$, and
$$y=4\pi \left(\frac{0.039948}{((2\pi)8.3145)500}\right)^{3/2}x^2\exp\left(-\frac{0.039948x^2}{(2\times 8.3145)500}\right)$$
Therefore, $$\Delta x=\frac{305.5-304.5}{4}=\frac{1}{4}.$$ We divide the interval $[304.5,305.5]$ into $n=4$ subintervals of the length $\Delta x=\frac{1}{4},$ with the following endpoints: $a=304.5,\frac{1}{4}, 0, \frac{3}{4}, 305.5=b.$
Now, we just evaluate the function at these endpoints \begin{align*} y_0&=f(a)=f(304.5)=0.00141148\\ y_1&=f(a+\Delta x)=f(304.75)=0.00141277\\ y_2&=f(a+\Delta 2x)=f(305)=0.00141405\\ y_3&=f(a+\Delta 3x)=f(305.25)=0.00141533\\ y_4&=f(a+\Delta 4x)=f(305.5)=0.00141661\\ \end{align*}
So, we have \begin{align*} &\frac{1}{4}\left(\frac{1}{2}\times0.00141148+0.00141277+0.00141405+0.00141533+\frac{1}{2}\times0.00141661\right)\\ &\approx 0.00141404875\\ \end{align*}
import numpy as np
import sympy as sy
from math import sin, pi
f=lambda x: (4*np.pi)*(0.039948/(((2*np.pi)*8.3145)*500))**(3/2)*x**2*np.exp((-0.039948*x**2)/((2*8.3145)*500))
a=304.5
b=305.5
n=4
h=(b-a)/n
S=0.5*(f(a)+f(b))
for i in range(1,n):
S+=f(a+i*h)
Integral=h*S
print('Integral=%f' %Integral)
## Integral=0.001414
The solutions appear to match, but is this method succinct? Can I improve this computation?