Gaussian Integral
import sympy as smp
from sympy import symbols, integrate, oo, exp
theta = [Link](r’\theta’, real = True, positive = True)
s = [Link]([Link](-theta**2),(theta, -oo, oo))
Compton Scattering:
import numpy as np
import [Link] as plt
from matplotlib import animation
from [Link] import PillowWriter
import sympy as smp
theta, alpha = [Link](r'\theta \alpha',real = True, positive = True)
dsdo = [Link](1,2)*(1+[Link](theta)**2)/(1+alpha*(1-
[Link](theta)))**2*\
(1+alpha**2 * ([Link](theta))**2/
((1+[Link](theta)**2)*(1+alpha*([Link](theta)))))
dsdt = 2*[Link]*dsdo*[Link](theta)
dsdt = [Link]()
dsdt
s = [Link](dsdt, (theta, 0, [Link]))
s = [Link]().simplify()
pdf_theta = dsdt/s
pdf_theta = pdf_theta.simplify()
pdf_theta
pdf_theta_f = [Link]([theta, alpha], pdf_theta)
the = [Link](0, [Link], 1000)
pdf_t = pdf_theta_f(the, 1)
fig, axes = [Link](1, 2, subplot_kw = {'projection':'polar'})
axes[0].plot(the, pdf_t)
axes[0].set_title(r'$f(\theta)$', fontsize = 20)
[Link]()
Animating for continuous values of alphas
theta = [Link](0, [Link], 1000)
alphas = 10.0**[Link](-3, 4, 300)
pdfs = [pdf_theta_f(theta, alpha) for alpha in alphas]
Make Animation
fig, ax = [Link](subplot_kw = {'projection':'polar'})
ln, [Link]([], [])
def animate(i):
[Link]()
[Link](theta, pdfs[i])
ax.set_title(r'$\alpha=$'+f'{alphas[i]: .2f}')
ani = [Link](fig, animate, frames = 299, interval = 50)
[Link]('[Link]', writer = 'pillow', fps = 30, dpi = 100)