Skip to content

Can I avoid expansion of complex exp? #1674

@leostenzel

Description

@leostenzel

Hi & thanks for developing this pretty cool tool!

I'm running into issues due to the expansion of exp(im * x) according to Euler's formula, i.e.,

using Symbolics
@variables x::Real
exp(im * x)
# cos(α) + im*sin(α)

exp(im * x) * exp(2im * x) |> expand |> simplify
# -sin(x)*sin(2x) + cos(x)*cos(2x) + im*(sin(x)*cos(2x) + cos(x)*sin(2x))

This probably makes sense, sometimes. But I'm multiplying a lot of exponentials, and thus get exponentially many terms.

As noted in the related issue #591, using @syms has the desired behavior, and keeps exp as is:

@syms y::Real
exp(im * y)
# exp((im)*y)

exp(im * y) * exp(2im * y) |> simplify
# exp((0 + 3im)*y)

PS: Unfortunately, just using @syms doesn't seem to work in my case, either, as some differentials don't get evaluated:

(Differential(y))(conj(exp(im * y))) |> expand_derivatives
# (0 + 1im)*exp((im)*y)*Differential(y)(conj(exp((im)*y)))

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