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

Dispersion #2679

Merged
merged 21 commits into from
Jan 25, 2014
Merged

Dispersion #2679

merged 21 commits into from
Jan 25, 2014

Conversation

raoulb
Copy link

@raoulb raoulb commented Dec 14, 2013

Dispersion computation

@raoulb
Copy link
Author

raoulb commented Dec 14, 2013

  • Complete references
  • Move to correct place in sympy tree
  • Include into documentation
  • What about polynomials over Q[a] instead of Q?

@raoulb
Copy link
Author

raoulb commented Dec 14, 2013

For point 2 I'll need some advise from the people working on the poly submodule.
I think this should go in polys.

@skirpichev
Copy link
Contributor

better names?

@raoulb
Copy link
Author

raoulb commented Dec 14, 2013

better names?

For what exactly?

The two functions are named like
the official mathematical things
they implement. (I'm not aware of
other names for the concept of
the "dispersion" of polynomials.)

@asmeurer
Copy link
Member

Add doctests.

..[3]: "Hypergeometric Summation: An Algorithmic Approach to Summationand Special Function Identities.
..[4]: "Fast Polynomial Dispersion Computation and its Application to Indefinite Summation"
"""
# Check for valid input
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first line should probably be something like p, q = Poly(p), Poly(q).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first line should probably be something like p, q = Poly(p), Poly(q).

Yes, probably. Depending on where we put the code in the end.

@asmeurer
Copy link
Member

If you put this in the polys, you can implement a low-level algorithm and implement the wrappers at the different layers (which do various levels of type checking). I'm not sure what the state of the polys is, though, i.e., using Poly vs. ring().


.. math::
J(f, g) & := \{a \in Z^{+} | gcd(f(x), g(x+a)) \neq 1\} \\
& = \{a \in Z^{+} | deg gcd(f(x), g(x+a)) \geq 1\}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So intuitively, the set of positive integers n where the root of one polynomial can be shifted to the left by n to get the root of another?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So intuitively, the set of positive integers n where the root of
one polynomial can be shifted to the left by n to get the root of
another?

To cite from W. Koepf's book:

"Note that the dispersion of two polynomials gives information about
their shift structure (answering the question: Does a shift generate
a common divisor?)."

I'd rather talk about factors than roots but the difference is small.
In fact if you compute the dispersion by using resultants and solving
the polynomial for the shifts, this gives exactly your statement.

@asmeurer
Copy link
Member

Is there a Wikipedia article for this?

@raoulb
Copy link
Author

raoulb commented Dec 17, 2013

If you put this in the polys, you can implement a low-level algorithm
and implement the wrappers at the different layers (which do various
levels of type checking). I'm not sure what the state of the polys
is, though, i.e., using Poly vs. ring().

That would be the idea. But for that I'd need some guide
from the people who wrote the poly module. I'm not sure if
there is enough difference for layers, the algorithms is
highly efficient per se.

I plan to do a p.dispersion() and p.dispersion(q) method
on poly objects and a free method dispersion(p, q).

@raoulb
Copy link
Author

raoulb commented Dec 17, 2013

Is there a Wikipedia article for this?

I did not check. But there are at least two good
descriptions in literature. (I did not finish
the references yet, adding authors and journals
etc.)

If I find some articles on wiki, mathworld or
enc. of mathematics, I'll add them too.

@raoulb
Copy link
Author

raoulb commented Dec 17, 2013

Add doctests.

Of course, the doc is not finished yet.

@asmeurer asmeurer mentioned this pull request Dec 21, 2013
@raoulb
Copy link
Author

raoulb commented Dec 21, 2013

Ok, this is in a state where we can move it to the poly module now.
Please help.

1 similar comment
@raoulb
Copy link
Author

raoulb commented Dec 21, 2013

Ok, this is in a state where we can move it to the poly module now.
Please help.

@asmeurer
Copy link
Member

Unfortunately, I don't even know what the state of the polys module is now, because of Poly vs. ring. @mattpap would have to comment. I know how to put this in Poly, but it probably would be better to put new code in ring.

Anyway, I don't think it's too bad to leave high-level algorithms like this as only using Poly (or ring). Ideally they should be fast enough to handle it. And that's kind of the whole point of having the objects in the first place. The Risch stuff for instance uses Poly for everything, and only at the highest level.

@raoulb
Copy link
Author

raoulb commented Dec 21, 2013

There seem to be no articles on:

  • Wikipedia
  • Mathworld
  • Encyclopedia of mathematics

If someone finds a reference, please tell.
The given literature should suffice anyway.
(At least the Journal of Symbolic computation is open archive I think.)

@asmeurer
Copy link
Member

I guess you'll have to write one :)

@asmeurer
Copy link
Member

Regardless, I would say this belongs in the polys module, not the concrete module.

@asmeurer
Copy link
Member

I'll leave it to you to verify that the LaTeX math renders correctly.

@raoulb
Copy link
Author

raoulb commented Dec 21, 2013

Regardless, I would say this belongs in the polys module, not the
concrete module.

Ok, then I'll move this file as it is to the poly
and adapt the imports. Unless someone else has
a better solution.

@raoulb
Copy link
Author

raoulb commented Dec 21, 2013

I'll leave it to you to verify that the LaTeX math renders correctly.

Sure. I'll test this once the docs are imported into sphinx.

@raoulb
Copy link
Author

raoulb commented Dec 21, 2013

Unfortunately, I don't even know what the state of the polys module
is now, because of Poly vs. ring. @mattpap would have to comment. I
know how to put this in Poly, but it probably would be better to put
new code in ring.

Oh, poly is out? I did not know that.
I've never heard of ring I think until now.

Anyway, I don't think it's too bad to leave high-level algorithms
like this as only using Poly (or ring). Ideally they should be fast
enough to handle it.

Probably the factorization is the slowest part anyway.

@raoulb
Copy link
Author

raoulb commented Jan 12, 2014

It seems travis had a timeout.

@raoulb
Copy link
Author

raoulb commented Jan 12, 2014

I'd like to integrate this deeper within the polys. Each poly instance should get a dispersion the same way they all have a discriminant method. But I do not know what and on which layers I have to add callbacks. So either someone guides me here or we make that part of another, future PR and review and merge this as it is.

@asmeurer
Copy link
Member

Do you want to implement it completely layered, or just at the Poly level? It didn't strike me as an algorithm that would benefit much from a low level implementation.

@asmeurer
Copy link
Member

Let's just fix this as it is. It needs a doctest. Otherwise, assuming you fixed the definitional issues I pointed out, it should be fine.

@raoulb
Copy link
Author

raoulb commented Jan 18, 2014

Do you want to implement it completely layered, or just at the Poly
level? It didn't strike me as an algorithm that would benefit much
from a low level implementation.

I'd like to have an additional OO public API like:

In [4]: P = poly(x**2 - 3*x, x)

In [5]: P.discriminant()
Out[5]: 9

We can then just call the functions
like P.dispersion() and P.dispersion(Q).

@asmeurer
Copy link
Member

In that case I wouldn't bother with all the lower levels (unless you find yourself needing it there too). Just implement the method on Poly.

@raoulb
Copy link
Author

raoulb commented Jan 18, 2014

Thanks. I added a high level OOP interface. Please review. There was a circular import, hence the imports inside the function definition.

4. [Man93]_
"""
J = dispersionset(p, q)
if len(J) == 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not J

@asmeurer
Copy link
Member

Just those comments.

if p.degree() < 1 or q.degree() < 1:
return set([0])

# Factor p and q over the rationals
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's only the case if the domain of p and q is QQ or ZZ. What if there's an algebraic domain? Or a symbolic one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it does look like you tested those cases, so maybe it works.

raoulb pushed a commit that referenced this pull request Jan 25, 2014
@raoulb raoulb merged commit 9874779 into sympy:master Jan 25, 2014
@raoulb raoulb deleted the dispersion branch January 25, 2014 14:17
@raoulb raoulb restored the dispersion branch March 26, 2015 22:42
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

Successfully merging this pull request may close these issues.

None yet

3 participants