# How can I solve a Hamiltonian with numerical methods?

Hamiltonian in terms of two level atom's operator (0 is ground state and 1 is excited state) which are 2*2 matrices and cavity modes are given by $a$ and $a^\dagger$. Rest of the parameters are constant. I am looking for numerical simulation of the operator $(a)$ over a long duration of time. I want to see the evolution of the operator $(a)$.

• It might be useful to say, what you want to solve... If it is about time evolution, you should have a look at NDSolve and/or NDSolveValue – Lukas Mar 31 '16 at 14:36
• You should show what you have tried - otherwise not many people will even know what you're asking. I've added an answer using my interpretation of your question. – Jens Mar 31 '16 at 15:36

The main step is translating the notation of the question to a matrix problem that Mathematica can solve numerically. Once you know what the symbols in the question actually mean, the rest is quite straightforward. Here I define the matrices a and ketBra corresponding to the physical interpretation of your symbols, and then rewrite the Hamiltonian using these matrices.

a[dim_] :=
KroneckerProduct[IdentityMatrix[2],
SparseArray[{Band[{1, 2}] -> Sqrt[Range[dim - 1]]}, {dim, dim}]]

ketBra[dim_][i_, j_] :=
KroneckerProduct[
KroneckerProduct[UnitVector[i + 1], UnitVector[j + 1]],
IdentityMatrix[dim]]

h[dim_][Ω_, δ_] := -Ω (ketBra[dim][0, 0] +
ketBra[dim][1, 1].ConjugateTranspose[a[dim]].a[dim] +
ketBra[dim][0, 1].a[dim] +
ConjugateTranspose[ketBra[dim][0, 1].a[dim]]) - δ ketBra[dim][1, 1]

With[{δ = .1, Ω = 1},
Eigenvalues@h[10][Ω, δ]]


${-10.0901, -9.089, -8.08764, -7.08589, -6.08356, -5.08032, -4.07546, \ -3.0674, -2.05125, -1., -0.1, -0.0487508, -0.0326009, -0.0245371, \ -0.0196838, -0.0164377, -0.0141126, -0.0123646, -0.0110023, \ -0.00991072}$

The important ingredient is KroneckerProduct, which is needed here to construct the matrices in the direct-product space in which the objects $\vert i\rangle\,\langle j\vert$ and $a, a^{\dagger}$ live. For a numerical solution, the operators $a$ have been defined as finite matrices even though they are in fact the ladder operators of the harmonic oscillator and therefore infinite-dimensional. The truncated dimension is called dim.

To combine the operators $\vert i\rangle\,\langle j\vert$ and $a, a^{\dagger}$, I define the direct-product space such that the first component refers to the two-state system and the second factor is the state space of the harmonic oscillator. This determines the order of the factors in KroneckerProduct which combines the operators from the two component spaces. I also use KroneckerProduct to define the individual $\vert i\rangle\,\langle j\vert$ that correspond to outer products of two-dimensional unit vectors (this is why there are two KroneckerProducts in ketBra).

Since each operator acts only in one of the component spaces, I have to multiply it by an identity matrix for the respective other space. This is the reason for the IdentityMatrix[2] and IdentityMatrix[dim] above.

• Thanks sir...Shall i differentiate the hamiltonian to see the time evolution of operator a? I am looking for numerical simulation and i want to see the effect of this operator in long duration of time. – Ani Apr 1 '16 at 4:39
• It looks like your question is not about Mathematica but about physics. Unfortunately, the question has been closed because it wasn't clear what you want to calculate, and how the operators are defined. If you add more details, maybe it will be re-opened. For example, since the Hamiltonian is time-independent, the operator a will be easy to compute in the Heisenberg picture, but I don't know if that's what you mean. – Jens Apr 1 '16 at 4:49
• Ok Sir ..yes i want to see the effect of evolution of operator(a). Thanks... – Ani Apr 1 '16 at 5:03
• It would help if you explain what you mean by "effect" here. Do you just want to see a big matrix as a function of time? I answered based on the interpretation that "solving a Hamiltonian" means finding its spectrum. You will have to be more specific about the time-dependent information you're looking for. – Jens Apr 1 '16 at 16:21