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

Improvement_of_dup_zz_mignotte_bound(f, K) #19254

Merged
merged 14 commits into from May 8, 2020
Merged

Improvement_of_dup_zz_mignotte_bound(f, K) #19254

merged 14 commits into from May 8, 2020

Conversation

lagamura
Copy link
Contributor

@lagamura lagamura commented May 4, 2020

So, this is our change in the dup_zz_mignotte_bound(f, K) method. Also, we have replace the old value in the test_factortools.py file. If it is asked, we can cite our test_file with the comparison of the bounds. As it was mentioned, we have not create a new method but just change the code in the dup_zz_mignotte_bound(f, K).

Fixes #19253

References to other Issues or PRs

Brief description of what is fixed or changed

dup_zz_mignotte_bound(f, K) implemented with Knuth-Cohen

Other comments

As it was mentioned in the issue, dmp_zz_mignotte_bound(f, u, K) should also be cared of.

Release Notes

  • polys
    • improvement of dup_zz_mignotte_bound(f, K) by Knuth-Cohen bound

So, this is our change in the `dup_zz_mignotte_bound(f, K)` method. Also, we have replace the old value in the test_factortools.py file. If it is asked, we can cite our test_file with the comparison of the bounds.
@sympy-bot
Copy link

sympy-bot commented May 4, 2020

Hi, I am the SymPy bot (v158). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • polys
    • improvement of dup_zz_mignotte_bound(f, K) by Knuth-Cohen bound (#19254 by @lagamura)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.7.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

So, this is our change in the `dup_zz_mignotte_bound(f, K)` method. Also, we have replace the old value in the test_factortools.py file. If it is asked, we can cite our test_file with the comparison of the bounds. As it was mentioned, we have not create a new method but just change the code in the `dup_zz_mignotte_bound(f, K)`.


Fixes #19253 
<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->


#### Brief description of what is fixed or changed
`dup_zz_mignotte_bound(f, K)` implemented with Knuth-Cohen

#### Other comments
As it was mentioned in the issue, `dmp_zz_mignotte_bound(f, u, K)` should also be cared of.


#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* polys
    * improvement of `dup_zz_mignotte_bound(f, K)` by Knuth-Cohen bound
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

n = dup_degree(f)

return K.sqrt(K(n + 1))*2**n*a*b
"""
Copy link
Member

Choose a reason for hiding this comment

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

It appears to be a public function. So, Parameters and Examples sections can be added in the doc strings.

@czgdp1807 czgdp1807 added the polys label May 4, 2020
@lagamura
Copy link
Contributor Author

lagamura commented May 4, 2020

Can someone help with the travis-ci test?

sympy/polys/factortools.py Outdated Show resolved Hide resolved
sympy/polys/factortools.py Outdated Show resolved Hide resolved
@divyanshu132
Copy link
Member

Can someone help with the travis-ci test?

You can click on details to know about the failures!

@lagamura
Copy link
Contributor Author

lagamura commented May 5, 2020

Managed to fix the basic errors of travis ci test. But now a bit more complex one occurred. Can anyone help with this?

@asmeurer
Copy link
Member

asmeurer commented May 5, 2020

This is the test failure

>>> expand(factor(expand(
...         (x - I*y)*(z - I*t)), extension=[I]))
x - I*y

As you can see, the answer is wrong (it should be -I*t*x - t*y + x*z - I*y*z, as in the test). So you will need to dig into the code to see what is happening.

@codecov
Copy link

codecov bot commented May 6, 2020

Codecov Report

Merging #19254 into master will decrease coverage by 0.045%.
The diff coverage is 100.000%.

@@              Coverage Diff              @@
##            master    #19254       +/-   ##
=============================================
- Coverage   75.667%   75.622%   -0.046%     
=============================================
  Files          651       651               
  Lines       169487    169466       -21     
  Branches     40021     40014        -7     
=============================================
- Hits        128247    128154       -93     
- Misses       35623     35707       +84     
+ Partials      5617      5605       -12     

from sympy import binomial

d = dup_degree(f)
delta = _ceil( d / 2 )
Copy link
Member

Choose a reason for hiding this comment

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

In SymPy, no space is added after ( and before ). So this could be _ceil(d/2).

eucl_norm = K.sqrt( sum( [cf**2 for cf in f] ) )

# biggest values of binomial coefficients (p. 538 of reference)
t1 = binomial( delta - 1, _ceil( delta / 2 ) )
Copy link
Member

Choose a reason for hiding this comment

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

I would consider defining something like delta2 = _ceil(delta/2) in addition to delta and using it on this and the next line.

t1 = binomial( delta - 1, _ceil( delta / 2 ) )
t2 = binomial( delta - 1, _ceil( delta / 2 ) - 1 )

lc = abs( dup_LC(f, K) ) # leading coefficient
Copy link
Member

Choose a reason for hiding this comment

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

In principle, this could probably have K.abs instead of abs.

t2 = binomial( delta - 1, _ceil( delta / 2 ) - 1 )

lc = abs( dup_LC(f, K) ) # leading coefficient

Copy link
Member

Choose a reason for hiding this comment

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

This, and the next two blank lines could be removed.

@@ -27,7 +27,7 @@ def test_dmp_trial_division():

def test_dup_zz_mignotte_bound():
R, x = ring("x", ZZ)
assert R.dup_zz_mignotte_bound(2*x**2 + 3*x + 4) == 32
assert R.dup_zz_mignotte_bound(2*x**2 + 3*x + 4) == 6
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps there could be a couple of more examples, preferable with comments on actual bounds for comparison.

@jksuom
Copy link
Member

jksuom commented May 7, 2020

I have some comments but otherwise this looks good.

Two examples also has been imported. I have not imported more as i am not so experienced in sympy's typing rules and mechanics. Your feedback is welcomed
One more example highlighting the difference between the old and the new method.
@jksuom
Copy link
Member

jksuom commented May 8, 2020

Thanks, this is ready to go.

@jksuom jksuom merged commit 2c3eb54 into sympy:master May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sympy.polys.factortools.dmp_zz_mignotte_bound improvement
7 participants