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

symbolic_solve for symbolic arrays fails #1291

Open
karlwessel opened this issue Oct 3, 2024 · 0 comments
Open

symbolic_solve for symbolic arrays fails #1291

karlwessel opened this issue Oct 3, 2024 · 0 comments

Comments

@karlwessel
Copy link
Contributor

When using normal variables in an equation symbolic_solve works fine:

julia> using Groebner
julia> using Symbolics

julia> @variables a b
2-element Vector{Num}:
 a
 b

julia> symbolic_solve([1 + 5a, a + 5b + 10a^2], [a, b])
1-element Vector{Any}:
 Dict{Num, Any}(a => -1//5, b => -1//25)

but when trying to solve the same equation with variables defined in a symbolic array it fails:

julia> @variables c[1:2]
1-element Vector{Symbolics.Arr{Num, 1}}:
 c[1:2]

julia> symbolic_solve([1 + 5c[1], c[1] + 5c[2] + 10c[1]^2], Symbolics.scalarize(c))
ERROR: DomainError with Lex{Num}(Num[c[1], c[2], _T], false):
The given monomial ordering is inconsistent with the input.
The variable c[1] does not seem to belong to the ring: DynamicPolynomials.Variable{DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder}, MultivariatePolynomials.Graded{MultivariatePolynomials.LexOrder}}[getindex_15908837152376642251, getindex_2270112243685334339, _T].

Variable mapping: Dict{DynamicPolynomials.Variable{DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder}, MultivariatePolynomials.Graded{MultivariatePolynomials.LexOrder}}, Int64}(getindex_15908837152376642251 => 3, getindex_2270112243685334339 => 2, _T => 1)
Ordering: Lex{Num}(Num[c[1], c[2], _T], false)
Stacktrace:
  [1] __throw_monomial_ordering_inconsistent(msg::String, var_to_index::Dict{…}, ord::Lex{…})
    @ Groebner ~/.julia/packages/Groebner/5Ez16/src/monomials/internal_orderings.jl:14
  [2] check_ordering_consistency(var_to_index::Dict{…}, ordering::Lex{…}, ring_vars::Vector{…}, ordering_vars::Vector{…}; part_of_a_product::Bool)
    @ Groebner ~/.julia/packages/Groebner/5Ez16/src/monomials/internal_orderings.jl:127
  [3] check_ordering_consistency
    @ ~/.julia/packages/Groebner/5Ez16/src/monomials/internal_orderings.jl:101 [inlined]
  [4] io_convert_to_internal_monomial_ordering(var_to_index::Dict{…}, ordering::Lex{…}; part_of_a_product::Bool)
    @ Groebner ~/.julia/packages/Groebner/5Ez16/src/monomials/internal_orderings.jl:159
  [5] io_convert_to_internal_monomial_ordering
    @ ~/.julia/packages/Groebner/5Ez16/src/monomials/internal_orderings.jl:153 [inlined]
  [6] io_set_monomial_ordering!(ring::Groebner.PolyRing{…}, var_to_index::Dict{…}, monoms::Vector{…}, coeffs::Vector{…}, params::Groebner.AlgorithmParameters{…})
    @ Groebner ~/.julia/packages/Groebner/5Ez16/src/input_output/input_output.jl:361
  [7] _groebner1(ctx::Groebner.Context, polynomials::Vector{…}, kws::Groebner.KeywordArguments{…}, representation::Groebner.PolynomialRepresentation)
    @ Groebner ~/.julia/packages/Groebner/5Ez16/src/groebner/groebner.jl:43
  [8] _groebner0(polynomials::Vector{DynamicPolynomials.Polynomial{…}}, kws::Groebner.KeywordArguments{Lex{…}})
    @ Groebner ~/.julia/packages/Groebner/5Ez16/src/groebner/groebner.jl:16
  [9] groebner(polynomials::Vector{DynamicPolynomials.Polynomial{…}}; options::@Kwargs{ordering::Lex{…}})
    @ Groebner ~/.julia/packages/Groebner/5Ez16/src/interface.jl:130
 [10] groebner_basis(polynomials::Vector{Num}; kwargs::@Kwargs{ordering::Lex{Num}})
    @ SymbolicsGroebnerExt ~/.julia/packages/Symbolics/rtkf9/ext/SymbolicsGroebnerExt.jl:38
 [11] solve_zerodim(eqs::Vector{Num}, vars::Vector{Num}; dropmultiplicity::Bool, warns::Bool)
    @ SymbolicsGroebnerExt ~/.julia/packages/Symbolics/rtkf9/ext/SymbolicsGroebnerExt.jl:202
 [12] solve_zerodim
    @ ~/.julia/packages/Symbolics/rtkf9/ext/SymbolicsGroebnerExt.jl:167 [inlined]
 [13] solve_multivar(eqs::Vector{Num}, vars::Vector{Num}; dropmultiplicity::Bool, warns::Bool)
    @ SymbolicsGroebnerExt ~/.julia/packages/Symbolics/rtkf9/ext/SymbolicsGroebnerExt.jl:304
 [14] solve_multivar
    @ ~/.julia/packages/Symbolics/rtkf9/ext/SymbolicsGroebnerExt.jl:303 [inlined]
 [15] symbolic_solve(expr::Vector{Num}, x::Vector{Num}; dropmultiplicity::Bool, warns::Bool)
    @ Symbolics ~/.julia/packages/Symbolics/rtkf9/src/solver/main.jl:204
 [16] symbolic_solve(expr::Vector{Num}, x::Vector{Num})
    @ Symbolics ~/.julia/packages/Symbolics/rtkf9/src/solver/main.jl:145
 [17] top-level scope
    @ REPL[8]:1
Some type information was truncated. Use `show(err)` to see complete types.
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