Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with substitution of a Complex{Float64} value in polynomial with complex coefficients #1109

Open
Paul-Roux-Phys opened this issue Apr 3, 2024 · 0 comments

Comments

@Paul-Roux-Phys
Copy link

Hi, thanks for the great package!

Here is my problem ; when I try to substitute a complex value in a polynomial with complex coefficients, I get an error

julia> using Symbolics
julia> @variables x
julia> p = 0.4 + 1.7im*x
julia> substitute(p, Dict( x => 0.2 + 1.0im))
ERROR: InexactError: Real(0.34 + 1.7im)
Stacktrace:
  [1] Real
    @ ./complex.jl:44 [inlined]
  [2] convert
    @ ./number.jl:7 [inlined]
  [3] Complex{Real}(re::Float64, im::ComplexF64)
    @ Base ./complex.jl:14
  [4] substitute(expr::Symbolics.ComplexTerm{Real}, dict::Dict{SymbolicUtils.BasicSymbolic{Real}, ComplexF64}; fold::Bool)
    @ SymbolicUtils ~/.julia/packages/SymbolicUtils/c0xQb/src/substitute.jl:28
  [5] substitute
    @ ~/.julia/packages/SymbolicUtils/c0xQb/src/substitute.jl:16 [inlined]
  [6] #16#17
    @ ~/.julia/packages/Symbolics/OrNx6/src/num.jl:84 [inlined]
  [7] (::Symbolics.var"#16#19"{Symbolics.var"#16#17#20"{Dict{SymbolicUtils.BasicSymbolic{Real}, ComplexF64}}})(expr::Symbolics.ComplexTerm{Real})
    @ Symbolics ~/.julia/packages/Symbolics/OrNx6/src/num.jl:84
  [8] substitute(expr::Complex{Num}, s::Dict{Num, ComplexF64}; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Symbolics ~/.julia/packages/Symbolics/OrNx6/src/Symbolics.jl:161
  [9] substitute(expr::Complex{Num}, s::Dict{Num, ComplexF64})
    @ Symbolics ~/.julia/packages/Symbolics/OrNx6/src/Symbolics.jl:161
 [10] top-level scope
    @ REPL[65]:1

Am I doing something incorrect, or is this a bug ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant