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

square root with all=True should not return ValueError but empty list #9466

Closed
mstreng opened this issue Jul 9, 2010 · 17 comments
Closed

square root with all=True should not return ValueError but empty list #9466

mstreng opened this issue Jul 9, 2010 · 17 comments

Comments

@mstreng
Copy link

mstreng commented Jul 9, 2010

With Sage 4.4.4 and no relevant patches, I got the following:

sage: FiniteField(3)(2).sqrt(all = True)
[]

sage: 2.sqrt(extend = False, all = True)
ValueError: square root of 2 not an integer

sage: FiniteField(next_prime(2^100))(2).sqrt(extend = False, all = True)
ValueError: self must be a square

sage: _.<a>=FiniteField(9)
sage: a.sqrt(extend = False, all = True)
ValueError: must be a perfect square.

At sage days 23 we agreed that square root with all=True should not raise an error. If no square roots exist, then it should return an empty list.

Right now, it returns an empty list for elements of small prime finite fields, but raises an error for integers, elements of large prime finite fields, and elements of non-prime finite fields.

apply

CC: @koffie @sagetrac-ruckers

Component: algebra

Keywords: sd23 sd51 sqrt all

Author: Marco Streng, Sonseeahray Rucker

Reviewer: Alejandro Argaez, Angelos Koutsianas

Merged: sage-5.12.beta3

Issue created by migration from https://trac.sagemath.org/ticket/9466

@mstreng mstreng added this to the sage-5.11 milestone Jul 9, 2010
@mstreng

This comment has been minimized.

@sagetrac-ruckers
Copy link
Mannequin

sagetrac-ruckers mannequin commented Feb 8, 2012

Fixes the code: sage: 2.sqrt(extend = False, all = True)

@sagetrac-ruckers
Copy link
Mannequin

sagetrac-ruckers mannequin commented Feb 8, 2012

Attachment: my1.patch.gz

Attachment: my2.patch.gz

Fixes the code: sage: FiniteField(next_prime(2^100))(2).sqrt(extend = False, all = True)

@sagetrac-ruckers
Copy link
Mannequin

sagetrac-ruckers mannequin commented Feb 8, 2012

comment:3

I was not able to fix this code.

sage: _.=FiniteField(9)

sage: a.sqrt(extend = False, all = True)

ValueError: must be a perfect square.

@mstreng
Copy link
Author

mstreng commented Feb 8, 2012

comment:4

Thanks! That bug has been around for too long :)

Why were you not able to fix the FiniteField(9) case?

Unfortunately, the patches need some more work, for the following three reasons.

  • With my2.patch:

    sage: Zmod(7)(3).sqrt(extend=True)
    sqrt3
    sage: Zmod(7)(3).sqrt(all=True, extend=True)
    []
    

    The second one should either output [sqrt3, -sqrt3] or raise NotImplementedError, but never an empty list.

  • Patches must have your name and email address in them. This is done by putting your email address and name in your .hgrc file as specified here

  • Add an example of the new functionality to the documentation:

If you have any questions, let me know!

@mstreng
Copy link
Author

mstreng commented Jul 25, 2013

Attachment: 9466.2.patch.gz

@mstreng
Copy link
Author

mstreng commented Jul 25, 2013

Attachment: 9466.3.patch.gz

@mstreng
Copy link
Author

mstreng commented Jul 25, 2013

Changed keywords from none to sd23 sd51 sqrt all

@mstreng
Copy link
Author

mstreng commented Jul 25, 2013

comment:5

Attachment: 9466.patch.gz

Does anyone know who user "ruckers" is? (s)he should be added to the list of authors

apply 9466.patch

@mstreng

This comment has been minimized.

@mstreng
Copy link
Author

mstreng commented Jul 25, 2013

Author: Marco Streng

@mstreng
Copy link
Author

mstreng commented Jul 25, 2013

comment:6

please review!

@mstreng
Copy link
Author

mstreng commented Jul 25, 2013

Changed author from Marco Streng to Marco Streng and the person with trac account ruckers

@sagetrac-akoutsianas
Copy link
Mannequin

sagetrac-akoutsianas mannequin commented Jul 26, 2013

Reviewer: Alejandro Argaez, Angelos Koutsianas

@sagetrac-akoutsianas
Copy link
Mannequin

sagetrac-akoutsianas mannequin commented Jul 26, 2013

comment:7

The patch passed all the tests for sage 5.11 version.

@jdemeyer
Copy link

Merged: sage-5.12.beta3

@kcrisman
Copy link
Member

Changed author from Marco Streng and the person with trac account ruckers to Marco Streng, Sonseeahray Rucker

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

No branches or pull requests

4 participants