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

Arithmetic functions should be methods of Sage integers #14401

Open
kedlaya opened this issue Apr 2, 2013 · 3 comments
Open

Arithmetic functions should be methods of Sage integers #14401

kedlaya opened this issue Apr 2, 2013 · 3 comments

Comments

@kedlaya
Copy link
Sponsor Contributor

kedlaya commented Apr 2, 2013

One common use model of Sage is to use tab completion to identify methods of a given object. For Sage integers, this will currently fail to reveal many standard functions such as the following.

number_of_divisors # d(n)
moebius            # mu(n)
euler_phi          # phi(n)
partitions         # tau(n)

I propose to add methods to the class of Sage integers. In the process, perhaps one can add a few standard functions which are missing even from the class of bare functions, like sum_of_divisors ("sigma(n)").

CC: @kcrisman

Component: number theory

Keywords: arithmetic functions

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

@kedlaya kedlaya added this to the sage-5.11 milestone Apr 2, 2013
@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@rwst
Copy link

rwst commented Jan 28, 2014

comment:3

I doubt the general usefulness of such an undertaking. The notion that functions that take an object as parameter should be equivalent to member functions of that object is too broad.

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@kedlaya
Copy link
Sponsor Contributor Author

kedlaya commented Mar 21, 2016

comment:7

I agree that the notion is too broad, but not in the way you have in mind: in Python, one generally tries to avoid clogging up the global namespace with things that really should be member functions of a particular class. So if I were starting from scratch, I would strongly consider implementing these functions exclusively as member functions of Sage integers; but I don't think it's appropriate to move in that direction now.

In any case, this case is much more special than the general discussion, because arithmetic functions are distinguished by the property of multiplicativity: if gcd(m,n) == 1 then f(m*n) = f(m)*f(n). So in a sense, they are more deeply linked to the class of integers than, say, the binomial or factorial functions.

@kedlaya
Copy link
Sponsor Contributor Author

kedlaya commented Aug 16, 2020

comment:8

Given that this discussion has gone dormant, I propose to mark this ticket as wontfix and close it.

@mkoeppe mkoeppe removed this from the sage-6.4 milestone Dec 29, 2022
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

5 participants