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

Improve efficiency of multiplicative_order() for number field elements #5518

Closed
JohnCremona opened this issue Mar 14, 2009 · 4 comments
Closed

Comments

@JohnCremona
Copy link
Member

The attached patch vastly improves the efficiency of the multiplicative_order() function for number field elements. Before, this example:

 sage: x = polygen(QQ)
            sage: K.<a>=NumberField(x^40 - x^20 + 4)
            sage: u = 1/4*a^30 + 1/4*a^10 + 1/2
            sage: u.multiplicative_order()
            6
            sage: a.multiplicative_order()
            +Infinity

would have required raising a to the power 2**40 (I'm serious). Now it just works (fast).

Component: number theory

Keywords: number field multiplicative order

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

@JohnCremona
Copy link
Member Author

comment:1

Attachment: multiplicative_order.patch.gz

@sagetrac-fwclarke
Copy link
Mannequin

sagetrac-fwclarke mannequin commented Mar 17, 2009

comment:2

This is excellent. A great speed up, and it gives the right answer!

I would suggest adding the doctest

sage: K.<a, b> = NumberField([x^2 + x + 1, x^2 - 3])
sage: z = (a - 1)*b/3
sage: z.multiplicative_order()
12

because sage-3.4 says the order is +infinity.

@sagetrac-fwclarke sagetrac-fwclarke mannequin changed the title Improve efficiency of multiplcative_order() for number field elements Improve efficiency of multiplicative_order() for number field elements Mar 17, 2009
@JohnCremona
Copy link
Member Author

comment:3

Attachment: trac_5518.patch.gz

I added a small patch with the additional doctest as suggested.

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Mar 25, 2009

comment:4

Merged both patches in Sage 3.4.1.alpha0.

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Mar 25, 2009
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

2 participants