# QuTiP example: eseries¶

J.R. Johansson and P.D. Nation

In :
from numpy import pi

In :
from qutip import *


## Example eseries object: $\sigma_x \exp(i\omega t)$¶

In :
omega = 1.0
es1 = eseries(sigmax(), 1j * omega)

In :
es1

Out:
ESERIES object: 1 terms
Hilbert space dimensions: [, ]
Exponent #0 = 1j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 0.  1.]
[ 1.  0.]]

## Example eseries object: $\sigma_x \cos(\omega t)$¶

In :
omega = 1.0
es2 = eseries(0.5 * sigmax(), 1j * omega) + eseries(0.5 * sigmax(), -1j * omega)

In :
es2

Out:
ESERIES object: 2 terms
Hilbert space dimensions: [, ]
Exponent #0 = 1j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 0.   0.5]
[ 0.5  0. ]]
Exponent #1 = -1j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 0.   0.5]
[ 0.5  0. ]]

## Evaluate eseries object at time $t = 0$¶

In :
esval(es2, 0.0)

Out:
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True\begin{equation*}\left(\begin{array}{*{11}c}0.0 & 1.0\\1.0 & 0.0\\\end{array}\right)\end{equation*}

## Evaluate eseries object at array of times $t = [0, \pi, 2\pi]$¶

In :
tlist = [0.0, 1.0 * pi, 2.0 * pi]
esval(es2, tlist)

Out:
array([ Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 0.  1.]
[ 1.  0.]],
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 0. -1.]
[-1.  0.]],
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 0.  1.]
[ 1.  0.]]], dtype=object)

## Expectation values of eseries¶

In :
es2

Out:
ESERIES object: 2 terms
Hilbert space dimensions: [, ]
Exponent #0 = 1j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 0.   0.5]
[ 0.5  0. ]]
Exponent #1 = -1j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 0.   0.5]
[ 0.5  0. ]]
In :
expect(sigmax(), es2)

Out:
ESERIES object: 2 terms
Hilbert space dimensions: [[1, 1]]
Exponent #0 = 1j
1.0
Exponent #1 = -1j
1.0

## Arithmetics with eseries¶

In :
es1 = eseries(sigmax(), 1j * omega)
es1

Out:
ESERIES object: 1 terms
Hilbert space dimensions: [, ]
Exponent #0 = 1j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 0.  1.]
[ 1.  0.]]
In :
es2 = eseries(sigmax(), -1j * omega)
es2

Out:
ESERIES object: 1 terms
Hilbert space dimensions: [, ]
Exponent #0 = -1j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 0.  1.]
[ 1.  0.]]
In :
es1 + es2

Out:
ESERIES object: 2 terms
Hilbert space dimensions: [, ]
Exponent #0 = 1j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 0.  1.]
[ 1.  0.]]
Exponent #1 = -1j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 0.  1.]
[ 1.  0.]]
In :
es1 - es2

Out:
ESERIES object: 2 terms
Hilbert space dimensions: [, ]
Exponent #0 = 1j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 0.  1.]
[ 1.  0.]]
Exponent #1 = -1j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 0. -1.]
[-1.  0.]]
In :
es1 * es2

Out:
ESERIES object: 1 terms
Hilbert space dimensions: [, ]
Exponent #0 = 0j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 1.  0.]
[ 0.  1.]]
In :
(es1 + es2) * (es1 - es2)

Out:
ESERIES object: 2 terms
Hilbert space dimensions: [, ]
Exponent #0 = 2j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[ 1.  0.]
[ 0.  1.]]
Exponent #1 = -2j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True
Qobj data =
[[-1.  0.]
[ 0. -1.]]

## Expectation values of eseries¶

In :
es3 = eseries([0.5*sigmaz(), 0.5*sigmaz()], [1j, -1j]) + eseries([-0.5j*sigmax(),
0.5j*sigmax()], [1j, -1j])
es3

Out:
ESERIES object: 2 terms
Hilbert space dimensions: [, ]
Exponent #0 = (-0-1j)
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = False
Qobj data =
[[ 0.5+0.j   0.0+0.5j]
[ 0.0+0.5j -0.5+0.j ]]
Exponent #1 = 1j
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = False
Qobj data =
[[ 0.5+0.j   0.0-0.5j]
[ 0.0-0.5j -0.5+0.j ]]
In :
es3.value(0.0)

Out:
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True\begin{equation*}\left(\begin{array}{*{11}c}1.0 & 0.0\\0.0 & -1.0\\\end{array}\right)\end{equation*}
In :
es3.value(pi/2)

Out:
Quantum object: dims = [, ], shape = (2, 2), type = oper, isherm = True\begin{equation*}\left(\begin{array}{*{11}c}0.0 & 1.0\\1.0 & 0.0\\\end{array}\right)\end{equation*}
In :
rho = fock_dm(2, 1)
es3_expect = expect(rho, es3)

es3_expect

Out:
ESERIES object: 2 terms
Hilbert space dimensions: [[1, 1]]
Exponent #0 = (-0-1j)
(-0.5+0j)
Exponent #1 = 1j
(-0.5+0j)
In :
es3_expect.value([0.0, pi/2])

Out:
array([ -1.00000000e+00,  -6.12323400e-17])

## Versions¶

In :
from qutip.ipynbtools import version_table

version_table()

Out:
SoftwareVersion
QuTiP4.2.0
Numpy1.13.1
SciPy0.19.1
matplotlib2.0.2
Cython0.25.2
Number of CPUs2
BLAS InfoINTEL MKL
IPython6.1.0
Python3.6.1 |Anaconda custom (x86_64)| (default, May 11 2017, 13:04:09) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
OSposix [darwin]
Wed Jul 19 22:16:28 2017 MDT