xmin = -2.
xmax = 4.
N = 10
b_position = PositionBasis(xmin, xmax, N)
b_momentum = MomentumBasis(b_position)

x0 = 1.2
p0 = 0.4
sigma = 0.2
psi = gaussianstate(b_position, x0, p0, sigma)

x = position(b_position)
p = momentum(b_position)

For particles QuantumOptics.jl provides two different choices - either the calculations can be done in real space or they can be done in momentum space by using PositionBasis or MomentumBasis respectively. The definition of these two bases types is:

type PositionBasis <: Basis

type MomentumBasis <: Basis

Since real space and momentum space are connected via a Fourier transformation the bases themselves are connected. The numerically inevitable cutoff implies that the functions $\Psi(x)$ and $\Psi(p)$ can be interpreted to continue periodically over the whole real axis. The specific choice of the cutoff points is therefore irrelevant as long as the interval length stays the same. This free choice of cutoff points allows to easily create a corresponding MomentumBasis from a PositionBasis and vice versa:

b_momentum = MomentumBasis(b_position)
b_position = PositionBasis(b_momentum)

When creating a momentum basis from a position basis the cutoff points are connected by $p_\mathrm{min} = -\pi/dx$ and $p_\mathrm{max} = \pi/dx$ where $dx = (x_\mathrm{max} - x_\mathrm{min})/N$. Similarly for the inverse procedure the cutoffs are $x_\mathrm{min} = -\pi/dp$ and $x_\mathrm{max} = \pi/dp$ with $dp = (p_\mathrm{max} - p_\mathrm{min})/N$.



All operators are defined for the position basis as well as for the momentum basis.

Transforming a state from one basis into another can be done efficiently using the transform:

Tpx = transform(basis_momentum, basis_position)
Psi_p = Tpx*Psi_x

This also works for composite bases, so long as at least one of them is a PositionBasis or MomentumBasis, respectively. For example:

b_fock = FockBasis(10)
b_comp_x = b_position^2 ⊗ b_fock
b_comp_p = b_momentum^2 ⊗ b_fock

Txp = transform(b_comp_x, b_comp_p)

The function will then automatically identify the first to bases of the composite basis b_comp_x as position basis and define a corresponding FFT from b_comp_p to b_comp_x. Note, that it is also possible to specify the indexes of the bases one wants to transform. The above FFTOperator is equivalent to writing transform(b_comp_x, b_comp_p; index=[1, 2]). This can be used if one does not want to FFT all position/momentum bases of a composite basis. Additionally, in order to save memory one can specify the option argument ket_only, for example transform(b_comp_x, b_comp_p; ket_only=true). The resulting FFTOperator is then of the subtype FFTKets and can only be applied to Ket states. This means, that this type of FFTOperator can only be used when calculating the time evolution according to a Schrödinger equation, as opposed to the more general FFTOperators, which can also handle operators. However, when treating large systems, the memory efficiency is much better.

Additional functions