2 Commits d36bf1f9d5 ... f3f584d6dc

Author SHA1 Message Date
  Pjotir f3f584d6dc Progress on p1, still not done 4 weeks ago
  Pjotir 439f9c57a0 Add comment 4 weeks ago
2 changed files with 11 additions and 1 deletions
  1. 10 1
      Homework3/problem1_potentialwell.m
  2. 1 0
      Homework3/problem2_markovchain.m

+ 10 - 1
Homework3/problem1_potentialwell.m

@@ -6,4 +6,13 @@ m = 1;
 v1 = 30;
 v2 = 40;
 L = 1;
-N = 1000;
+N = 10;
+x_min = -5; x_max = 5; x = linspace(x_min, x_max, N);
+dx = x(2) - x(1);
+
+diagonal_k = 2*ones(N, 1)
+off_diagonal_k = -1*ones(N-1, 1)
+laplacian = diag(diagonal_k) + diag(off_diagonal_k, 1) + diag(off_diagonal_k, -1)
+laplacian = laplacian / dx^2
+kinetic = -(hbar^2 / (2*m)) * laplacian
+potential = spdiags(v1, 0, N, N)

+ 1 - 0
Homework3/problem2_markovchain.m

@@ -4,6 +4,7 @@ transition = [0.5 .25 .25;
               0.25 0.5 0.25;
               0.4 0.4 0.2]
 
+% This part was largely taken from code we wrote in class
 transition_transposed = transition';
 [V, D] = eig(transition_transposed)
 eigen_values = diag(D)