It can take an integer or floating-point integer n.
laplacian(n) returns the n× n discrete Laplacian
matrix; namely the n × n tridiagonal matrix with 2s on the
main diagonal, −1s just above and below the main diagonal.
Input :
laplacian(3)
Output :
[[2,-1,0],[-1,2,-1],[0,-1,2]]
Input :
laplacian(2.0)
Output :
[[2.0,-1.0],[-1.0,2.0]]