Skip to content

expand() and simplify() implementation for QNumbers #70

@ChristophHotter

Description

@ChristophHotter

Currently, expand(x::QNumber) (and also simplify) is implemented like this

function Symbolics.expand(x::QNumber; kwargs...)
    expansion = average(x)
    expansion_ = SymbolicUtils.expand(expansion; kwargs...)
    return undo_average(expansion_)
end

This leads to problems if you apply it to expressions that contain QNumbers and Averages, e.g., for homodyne detection where one has terms like O*a + O*⟨a⟩. If such terms appear, you need to take the average before simplification.

In the future, we should try to get rid of the average - undo_average procedure.

using QuantumCumulants
using SymbolicUtils

h = FockSpace(:cavity)
a = Destroy(h, :a)

test = a + average(a) # a+⟨a⟩
expand(test) # 2*a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions