In a question I asked yesterday someone solved a definite integral by rearranging the equation using partial fractions and got the answer that seems correct (as someone in my group previously derived the same answer via a different method). However when I attempt to plot the intermediate equations some of them look completely different and I was wondering why this might be?
The original equation is: $$ \begin{align} &\frac1{\left(\omega_0^2-\omega^2\right)^2+(\Gamma_0\omega)^2}\\[12pt] \end{align} $$
He uses partial fractions to derive the form:
$$ \begin{align} =\frac1{2\omega_0^2}\left[\frac{1+\frac\omega{\sqrt{4\omega_0^2-\Gamma_0^2}}}{\left(\omega+\sqrt{\omega_0^2-\tfrac14\Gamma_0^2}\right)^2+\tfrac14\Gamma_0^2} +\frac{1-\frac\omega{\sqrt{4\omega_0^2-\Gamma_0^2}}}{\left(\omega-\sqrt{\omega_0^2-\tfrac14\Gamma_0^2}\right)^2+\tfrac14\Gamma_0^2}\right] \end{align} $$
Which he then rearranges to get:
$$ =\frac1{2\omega_0^2}\left[{\small\frac{\frac12+\frac\omega{\sqrt{4\omega_0^2-\Gamma_0^2}}}{\omega^2+\tfrac14\Gamma_0^2} +\frac{\frac12-\frac\omega{\sqrt{4\omega_0^2-\Gamma_0^2}}}{\omega^2+\tfrac14\Gamma_0^2}}\right]\,\\[6pt] $$
and finally:
$$ =\frac1{2\omega_0^2}\frac{1}{\omega^2+\tfrac14\Gamma_0^2}\\[12pt] $$
However when I plot these 4 equations in python like I get the following plots, where the blue is the original equation, the green the partial fractions form. Both of these agree well. However the red is the 3rd form listed here, which doesn't match the original and the light blue (cyan) is the last equation.
The code used to plot these is:
from scipy.constants import pi
import numpy as np
import matplotlib.pyplot as plt
Gamma0 = 100
w0 = 2*pi*175e3
def S_xx(w):
return 1/((w0**2 - w**2)**2 + Gamma0**2*w**2)
def S_xx_2(w):
return (1/(2*w0**2)*((1 + w/(4*w0**2-Gamma0**2)**0.5)/((w + (w0**2 - 0.25*Gamma0**2)**0.5)**2 +0.25*Gamma0**2) + (1 - w/(4*w0**2-Gamma0**2)**0.5)/((w - (w0**2 - 0.25*Gamma0**2)**0.5)**2 +0.25*Gamma0**2)))
def S_xx_3(w):
return 1/(2*w0**2)*( (0.5+(w/(4*w0**2 - Gamma0**2)**0.5))/(w**2 + 0.25*Gamma0**2) + (0.5+(w/(4*w0**2 - Gamma0**2)**0.5))/(w**2 + 0.25*Gamma0**2) )
def S_xx_4(w):
return 1/(2*w0**2)*1/(w**2 + 0.25*Gamma0**2)
w = np.linspace(0, 2*pi*500e3, 1000)
S = S_xx(w)
S2 = S_xx_2(w)
S3 = S_xx_3(w)
S4 = S_xx_4(w)
plt.semilogy(w/(2*pi), S)
plt.semilogy(w/(2*pi), S2)
plt.semilogy(w/(2*pi), S3)
plt.semilogy(w/(2*pi), S4)
Surely if this is just a rearrangement of the original equation these should all match?
