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

denominator for polynomials #1753

Open
SoongNoonien opened this issue Jul 17, 2024 · 6 comments
Open

denominator for polynomials #1753

SoongNoonien opened this issue Jul 17, 2024 · 6 comments

Comments

@SoongNoonien
Copy link
Contributor

I was again playing around with the universal polynomial rings and wondered why there is no denominator function for them. But then I noticed that with plain AbstractAlgebra there is not even a denominator function for univariate or multivariate polynomials:

julia> using AbstractAlgebra

julia> pkgversion(AbstractAlgebra)
v"0.41.9"

julia> R,(x,y)=QQ[:x,:y]
(Multivariate polynomial ring in 2 variables over rationals, AbstractAlgebra.Generic.MPoly{Rational{BigInt}}[x, y])

julia> denominator(1//2*x+1//3*x^2)
ERROR: MethodError: no method matching denominator(::AbstractAlgebra.Generic.MPoly{Rational{BigInt}})

Closest candidates are:
  denominator(::AbstractAlgebra.Generic.RationalFunctionFieldElem, ::Bool)
   @ AbstractAlgebra ~/.julia/packages/AbstractAlgebra/EYoda/src/generic/RationalFunctionField.jl:90
  denominator(::AbstractAlgebra.Generic.RationalFunctionFieldElem)
   @ AbstractAlgebra ~/.julia/packages/AbstractAlgebra/EYoda/src/generic/RationalFunctionField.jl:90
  denominator(::AbstractAlgebra.Generic.TotFrac, ::Bool)
   @ AbstractAlgebra ~/.julia/packages/AbstractAlgebra/EYoda/src/generic/TotalFraction.jl:73
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[3]:1

julia> R,x=QQ[:x]
(Univariate polynomial ring in x over rationals, x)

julia> denominator(1//2*x+1//3*x^2)
ERROR: MethodError: no method matching denominator(::AbstractAlgebra.Generic.Poly{Rational{BigInt}})

Closest candidates are:
  denominator(::AbstractAlgebra.Generic.RationalFunctionFieldElem, ::Bool)
   @ AbstractAlgebra ~/.julia/packages/AbstractAlgebra/EYoda/src/generic/RationalFunctionField.jl:90
  denominator(::AbstractAlgebra.Generic.RationalFunctionFieldElem)
   @ AbstractAlgebra ~/.julia/packages/AbstractAlgebra/EYoda/src/generic/RationalFunctionField.jl:90
  denominator(::AbstractAlgebra.Generic.TotFrac, ::Bool)
   @ AbstractAlgebra ~/.julia/packages/AbstractAlgebra/EYoda/src/generic/TotalFraction.jl:73
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[6]:1

julia> R=universal_polynomial_ring(QQ)
Universal Polynomial Ring over Rationals

julia> x=gen(R,:x)
x

julia> denominator(1//2*x+1//3*x^2)
ERROR: MethodError: no method matching denominator(::AbstractAlgebra.Generic.UnivPoly{Rational{BigInt}, AbstractAlgebra.Generic.MPoly{Rational{BigInt}}})

Closest candidates are:
  denominator(::AbstractAlgebra.Generic.RationalFunctionFieldElem, ::Bool)
   @ AbstractAlgebra ~/.julia/packages/AbstractAlgebra/EYoda/src/generic/RationalFunctionField.jl:90
  denominator(::AbstractAlgebra.Generic.RationalFunctionFieldElem)
   @ AbstractAlgebra ~/.julia/packages/AbstractAlgebra/EYoda/src/generic/RationalFunctionField.jl:90
  denominator(::AbstractAlgebra.Generic.TotFrac, ::Bool)
   @ AbstractAlgebra ~/.julia/packages/AbstractAlgebra/EYoda/src/generic/TotalFraction.jl:73
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[10]:1

julia> 

In all of these cases I would expect a value of 6.

@SoongNoonien
Copy link
Contributor Author

I think 1//content(f) should be what I thought of. But content is not defined for universal polynomials.

@lgoettgens
Copy link
Collaborator

I think 1//content(f) should be what I thought of. But content is not defined for universal polynomials.

#1970 will add it.

@SoongNoonien
Copy link
Contributor Author

Nice, thank you!

@fingolfin
Copy link
Member

fingolfin commented Jan 25, 2025

1//content(f) is not the same as denominator(f). Try e.g. 2//3*x.

@fingolfin
Copy link
Member

Perhaps denominator(f) = numerator(content(f)) might work as a definition. But this notion really only makes sense for polynomials over the rationals. But what are "rationals"? In the context of AA this means something else than in the context of Nemo and Oscar. We could add such dedicated methods for PolyRingElem{<:Rational} inside AA but in practice we'd hopefully never use them.

I suggest that instead we (or rather, you, @SoongNoonien ;-) ) add a bunch of specialized methods for certain UniversalPolyRingElem specializations to Nemo, say in a new src/UnivPoly.jl there. It could contain e.g. a method

denominator(f::UniversalPolyRingElem{QQFieldElem}) = denominator(data(f))

@SoongNoonien
Copy link
Contributor Author

1//content(f) is not the same as denominator(f). Try e.g. 2//3*x.

Yes, of course I missed that... My examples were a bit too simple.

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

3 participants