support for empty Pauli string(a string full of pauli I) ?
overshiki opened this issue · comments
overshiki commented
Hi,
I'm trying to use Yao.jl in the field of quantum chemistry. I just encountered a problem that I do not know how to write an empty Pauli string inside a Hamiltonian. More specifically, I need to write down the following Hamiltonian, for example:
H = 0.13*I1*I2*I3 + 0.6*X1*I2*Z3 + 0.3*I1*X2*Z3 ...
Following this example, I know that 0.6*X1*I2*Z3 + 0.3*I1*X2*Z3
could be defined in this way:
function hamiltonian()
X1 = put(3,1=>X)
X2 = put(3,2=>X)
Z3 = put(3,3=>Z)
0.6*X1*Z3 + 0.3*X2*Z3
end
But how about 0.13*I1*I2*I3
? I tried 0.13 + 0.6*X1*Z3 + 0.3*X2Z3
, however, it doesn't work.
I think it must be an easy task, but I could not find any related document.
Chen Zhao commented
Hi, overshiki.
Maybe you could try this:
function hamiltonian()
X1 = put(3, 1=>X)
X2 = put(3, 2=>X)
Z3 = put(3, 3=>Z)
I = put(3, 1=>I2)
return 0.13*I + 0.6*X1*Z3 + 0.3*X2*Z3
end
overshiki commented
Hi @ChenZhao44,
Yes, this solves my problem. Thanks!