# Spin S Hamiltonians with quadratic terms

Dear ITensor team,

apologises in advance for the quite trivial question : what is the easiest or/and fastest way to implement a spin Hamiltonian with autoMPO of the type
$$H = \sum_j c1 \vec{S}_j \dot \vec{S}_{j+1} + c2 [ \vec{S}_j \dot \vec{S}_{j+1} ]^2 + c_3 [ \vec{S}_j \dot \vec{S}_{j+1} ]^3 + ...$$
with $\vec{S}$ a spin S (for example spin 1) vector of operators ?

Thanks a lot for your time and the great service to the community!
Best,
Jacopo

Hi Jacopo,
Although it sounds tedious, the approach you'll need to take is to just expand the dot product into a sum of products of non-vector-operator terms. It should only make your AutoMPO input for loops a bit more complicated but AutoMPO will be able to handle this input well and give you an optimally compressed MPO.

Best regards,
Miles

commented by (650 points)
Hi, Jacopo.