1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Help with loops in Mathematica (Hamiltonian)

  1. May 6, 2013 #1
    1. The problem statement, all variables and given/known data

    I have an assignment for my thesis to make Hamiltonian for Schrodinger equation. I won't go into physics part of it, because that is well understood.

    I need to somehow generate a specific matrix for Hamiltonian (H).

    Please see the attached file of what I need to get.

    2. Relevant equations

    See attached file

    3. The attempt at a solution

    I have thought of solution for this in C, but I don't know how to syntax this in Mathematica.

    The solution for this in C would be to generate 7x7 matrix where elements (i,j) would be made by:

    Ω(rf) complex conjugate

    Attached Files:

  2. jcsd
  3. May 7, 2013 #2


    User Avatar

    Staff: Mentor

    The best way I know is to create a 2D table and use KroneckerDelta to decide the value of each element in the table.
  4. May 9, 2013 #3
    In[1]:= H = Table[
    i == j, g*\[Mu]B*ToExpression["m" <> ToString]*B,
    i - j == 1, Conjugate[\[CapitalOmega]rf],
    i - j == -1, \[CapitalOmega]rf,
    True, 0
    ], {i, 7}, {j, 7}

    Out[1]= {{B g m1 \[Mu]B, \[CapitalOmega]rf, 0, 0, 0, 0, 0},
    {Conjugate[\[CapitalOmega]rf], B g m2 \[Mu]B, \[CapitalOmega]rf, 0, 0, 0, 0},
    {0, Conjugate[\[CapitalOmega]rf], B g m3 \[Mu]B, \[CapitalOmega]rf, 0, 0, 0},
    {0, 0, Conjugate[\[CapitalOmega]rf], B g m4 \[Mu]B, \[CapitalOmega]rf, 0, 0},
    {0, 0, 0, Conjugate[\[CapitalOmega]rf], B g m5 \[Mu]B, \[CapitalOmega]rf, 0},
    {0, 0, 0, 0, Conjugate[\[CapitalOmega]rf], B g m6 \[Mu]B, \[CapitalOmega]rf},
    {0, 0, 0, 0, 0, Conjugate[\[CapitalOmega]rf], B g m7 \[Mu]B}}
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted