MethodError: ^(::Complex{Num}, ::Num) is ambiguous. ModelingToolkit, Symbolics - Complex symbolics, specifically exponentiation
Greetings everyone, I have recently started using ModelingToolkit.jl. I am facing the following error with exponentiation,
eqs_1 = [D(z1) ~ z1 * ( μ + im * ω_1 - abs(z1)) + A * ((cos(θ/ω_2) + im*sin(θ/ω_2)) * z2^μ),
D(z2) ~ z2 * ( μ + im * ω_2 - abs(z2)) + A * ((cos(θ/ω_2) + im*sin(θ/ω_2)) * z1) ]
The error is being caused by the term z2^μ, error message is given below
MethodError: ^(::Complex{Num}, ::Num) is ambiguous. Candidates:
^(a::Number, b::Num) in Symbolics at
julia/packages/SymbolicUtils/v2ZkM/src/methods.jl:71
^(z::Complex{T}, p::T) where T<:Real in Base at complex.jl:830
^(z::Complex{T}, p::S) where {T<:Real, S<:Real} in Base at complex.jl:843
Possible fix, define
^(::Complex{T}, ::Num) where T<:Real
Stacktrace:
[1] top-level scope
@ ~/Documents/Julia/Practice_modelling_tool_kit.jl:190
But, for example this works
eqs_1 = [D(z1) ~ z1 * ( μ + im * ω_1 - abs(z1)) + A * ((cos(θ/ω_2) + im*sin(θ/ω_2)) * z2^3),
D(z2) ~ z2 * ( μ + im * ω_2 - abs(z2)) + A * ((cos(θ/ω_2) + im*sin(θ/ω_2)) * z1) ]
However, if we replace the z2^3 to say z2^3.3 it doesn't, and gives the same error.
In addition, the exp() function doesn't work, fair to assume due to a similar reasons. Thanks. Note there is no error if complex numbers are not involved in the exponents.
Is this due to the fact that Symbolics.jl are still being developed for complex symbolics?
Thank you.
(Added 24 May 2022) I am using a "workaround" that was suggested in the following link, https://github.com/SciML/ModelingToolkit.jl/issues/1456#issuecomment-1039680030 .
(Added 27May 2022)
Greetings everyone,
I believe the function angle() doesn't work with the existing symbolic variables, especially with the work around method suggested in the above issue.
structural_simplify() requires ComplexTerm Metadata.