Created
April 17, 2025 11:49
-
-
Save abikoushi/ecd0c2442aa29b6488876227a2df78d0 to your computer and use it in GitHub Desktop.
Learn Schrödinger's equation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
makeLmat <- function (h){ | |
x = seq(0,1,by=h) | |
N=length(x) | |
invh2 <- 1/(h^2) | |
res = diag(invh2, N) | |
res[cbind(1:(N-1),2:N)] <- -0.5*invh2 | |
res[cbind(2:N,1:(N-1))] <- -0.5*invh2 | |
return(list(L=res,x=x)) | |
} | |
Lobj = makeLmat(0.01) | |
res_eigen = eigen(Lobj$L) | |
plot(Lobj$x, res_eigen$values, type = "l") | |
plot(Lobj$x, res_eigen$vector[,2], type = "l") | |
matplot(Lobj$x, res_eigen$vector, type = "l", col=hcl.colors(101), lty=1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment