Finish ps12-2
This commit is contained in:
parent
d480a46192
commit
02fa0ab955
17
ps12-2.py
17
ps12-2.py
@ -35,8 +35,21 @@ for i in range(4):
|
|||||||
print("==================")
|
print("==================")
|
||||||
print("Expectation Values")
|
print("Expectation Values")
|
||||||
print("==================")
|
print("==================")
|
||||||
for psi in psi_funcs:
|
expect_xs = []
|
||||||
pass # TODO
|
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
|
pl.rcParams['figure.dpi'] = 300
|
||||||
fig, axs = pl.subplots(2, 2, tight_layout=True)
|
fig, axs = pl.subplots(2, 2, tight_layout=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user