Skip to content

Complex exp coefficients get Euler-split (cos + i·sin) in operator expressions #218

Description

@oameye

A c-number coefficient like exp(1.0im*ωl*t) on an operator is expanded to cos(ωl·t)*exp(0) + exp(0)*im*sin(ωl·t) at construction time, so equations show sin/cos (plus a stray exp(0)) instead of e^{iω_l t}.

MWE:

using Symbolics
@variables ωl t
exp(1.0im*ωl*t)
# cos(t*ωl)*exp(0) + exp(0)*im*sin(t*ωl)

1.0im*ωl*t is a Complex{Num} (real 0, imag t*ωl), so exp dispatches to Julia Base's exp(::Complex) = exp(re)*(cos(im)+i*sin(im)). Current Symbolics (v7.x) represents every complex symbolic as Complex{Num}, so any exp of a complex argument is split. Older Symbolics kept it as a single node and printed e^{…}. Happens before any SQA/QC code runs.

Cosmetic only, e^{iθ} ≡ cos θ + i sin θ, numerics are identical. But it makes operator equations and docs (e.g. the heterodyne-detection example) hard to read.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions