<jupyter_start><jupyter_text>A) Using the expansion coefficients from n=1 up to n=20 (instead of worrying about the infinite sum), plot the regenerated initial wave function. Take hx = 1; m = 1; a= 1. Check if this indeed matches the given initial wave function.<jupyter_code># Setting up constants

h = 1
pi2 = math.pow(math.pi, 2)
m = 1
a = 1

omega = (pi2*h )/ (2 * m * math.pow(a,2))
T = 2 * math.pi / omega
A = (1/math.pow(a, 3/2)) * (math.sqrt((12*pi2)/2*pi2-3))

phix0 = []

for x in np.arange(0, 1, .0001 ):
    phix0.append( A * x * math.sin((math.pi * x) /a))
    
plt.plot(phix0)
plt.title("Initial Wave function")
plt.show()<jupyter_output><empty_output><jupyter_text>this plot shows the initial wave function of the initial wave function at time equals 0.<jupyter_code>phixPD0 = []

for x in np.arange(0, 1, .0001 ):
    phixPD0.append((math.pow(A,2)*
                   math.pow(x,2) *
                   math.pow(math.sin((math.pi * x) /a),2))/200)

plt.plot(phixPD0)
plt.title("Initial Probability distribution function")
plt.show()<jupyter_output><empty_output><jupyter_text>This plot shows the initial Probability Distribution function of the wave function at time 0.<jupyter_code>alpha = (1/2) * math.sqrt((6*pi2)/(2*pi2 - 3)) * math.sqrt(2/a)

beta = (1/pi2) * math.sqrt((24*pi2)/(2*pi2 -3)) * math.sqrt(2/a)

TotalSteps = 8

def a2 (pos1,time1):
    return math.pow((alpha * math.sin((math.pi*pos1)/a) *
                     math.cos(omega*(time1/TotalSteps))-
                     beta * sum1(pos1,time1)),2)

def sum1 ( pos, time):
    sum1 = 0
    for n in range(2,20,2):
        sum1 += ((1/(math.pow((n-1), 2)) - (1/(math.pow((n+1), 2))))*
                math.sin((math.pi*pos *n)/a) *
                math.cos(math.pow(n,2) * omega * (time/TotalSteps)))
    return sum1

def b2 (pos2, time2):
    return math.pow((alpha * math.sin((math.pi*pos2)/a) *
                     math.sin(omega *(time2/TotalSteps))
                     + beta * sum2(pos2,time2)),2)

def sum2 (pos,time):
    sum2 = 0
    for n in range(2,20,2):
        sum2 += ((1/(math.pow((n-1), 2)) - (1/(math.pow((n+1), 2))))*
                (math.sin(n*math.pi * pos)/a) *
                (math.sin(math.pow(n,2) *omega * (time/TotalSteps))))
    return sum2

for t in range(TotalSteps+1):
    phiPD = []
    for x in np.arange(0, a, .0001 ):
        phiPD.append((a2(x,t)+ b2(x,t))/2.5)

    #ax = fig.add_subplot(Rows,Cols,Position[t])
    #ax.plot(x,x%2)

    plt.plot(phiPD)
    plt.ylim(-0.1,1.1)
    plt.title("Wave function with T = " + str(t) + "T/" + str(TotalSteps))
    plt.show()<jupyter_output><empty_output><jupyter_text>C) These plots above are a plot of the probability density function at the specificed times in the titles.D) The density function is an even function about the midpoint when the values of the summation     The two times that give an even probiblity distribution about the mid-point is;        t/4 -> 1/pi = .3183$$        $$3t/4 ->  3/pi =.955$$        The reason for this is that it is a sum of two even wave functions is itself an even function.    The deeper reason is that the summation dies at this point and         the wave function is a odd wave function and since an odd function times an odd function        is an even functionE) The density function is a mirror reflection about the midpoint when the value is T/2.    This happens at T/2 (halfway point) where as          mult of pi - sin drops out and then you get a purely real wave function    our initial wave function is purely real anyway<jupyter_code># note to self multi thread or add timing
TotalSteps = 1000
for t in range(TotalSteps+1):
    phiPD = []
    for x in np.arange(0, a, .001 ):
        phiPD.append((a2(x,t)+ b2(x,t))/2.5)
    
    #ax = fig.add_subplot(Rows,Cols,Position[t])
    #ax.plot(x,x%2)
     
    plt.ylim(-0.1,1.1)
    plt.plot(phiPD, color='dodgerblue')
    plt.title("Wave function with T = " + str(t) + "T/" + str(TotalSteps))
    num = str(t).rjust(4,'0')
    plt.savefig("../pics/" + num +".png")
    plt.clf()
print("complete")
# Create gif<jupyter_output><empty_output><jupyter_text>Create the framesframes = []imgs = glob.glob("../pics//*.png")for i in imgs:    new_frame = Image.open(i)    frames.append(new_frame)  Save into a GIF file that loops foreverframes[0].save('../gif/P.gif', format='GIF',               append_images=frames[1:],               save_all=True,               duration=20, loop=0)print("complete")<jupyter_code># note to self multi thread or add timing
TotalSteps = 1000
for t in range(TotalSteps+1):
    phiPD = []
    for x in np.arange(0, a, .001 ):
        phiPD.append((a2(x,t)+ b2(x,t))/2.5)
    
    #ax = fig.add_subplot(Rows,Cols,Position[t])
    #ax.plot(x,x%2)
     
    plt.ylim(-0.1,1.1)
    plt.plot(phiPD, color='dodgerblue')
    plt.title("Wave function with T = " + str(t) + "T/" + str(TotalSteps))
    num = str(t).rjust(4,'0')
    plt.savefig("../pics/" + num +".png")
    plt.clf()
print("complete")
# Create gif
# Create the frames
frames = []
imgs = glob.glob("../pics//*.png")
for i in imgs:
    new_frame = Image.open(i)
    frames.append(new_frame)
 
# Save into a GIF file that loops forever
frames[0].save('../gif/P.gif', format='GIF',
               append_images=frames[1:],
               save_all=True,
               duration=20, loop=0)

print("complete")<jupyter_output>complete
{'fraction_non_alphanumeric': 0.15778688524590165, 'fraction_numerical': 0.036698956780924, 'mean_word_length': 2.835, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 22, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '84473', 'license': 'MIT', 'n_tokens_mistral': 2056, 'n_tokens_neox': 1954, 'n_words': 522, 'path': 'Project/ZQMProject.ipynb', 'repo_name': 'Cliftonz/Quantum-Visualizations', 'size': '5368'}