Finish ps12-2

This commit is contained in:
orosmatthew 2024-03-20 14:01:19 -04:00
parent d480a46192
commit 02fa0ab955

View File

@ -35,8 +35,21 @@ for i in range(4):
print("==================")
print("Expectation Values")
print("==================")
for psi in psi_funcs:
pass # TODO
expect_xs = []
for i, psi in enumerate(psi_funcs):
expect_x = np.sum(np.conjugate(psi) * x_vals * psi)
expect_xs.append(expect_x)
print(f'expect_x_{i} = {expect_x}')
expect_x_sqrds = []
for i, psi in enumerate(psi_funcs):
expect_x_sqrd = np.sum(np.conjugate(psi) * x_vals ** 2 * psi)
expect_x_sqrds.append(expect_x_sqrd)
print(f'expect_x_{i} = {expect_x_sqrd}')
for i, psi in enumerate(psi_funcs):
sigma_x = np.sqrt(expect_x_sqrds[i] - expect_xs[i] ** 2)
print(f'sigma_x_{i} = {sigma_x}')
pl.rcParams['figure.dpi'] = 300
fig, axs = pl.subplots(2, 2, tight_layout=True)