Opened 7 years ago
Last modified 4 years ago
#14401 new enhancement
Arithmetic functions should be methods of Sage integers
Reported by: | kedlaya | Owned by: | was |
---|---|---|---|
Priority: | minor | Milestone: | sage-6.4 |
Component: | number theory | Keywords: | arithmetic functions |
Cc: | kcrisman | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
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)").
Change History (7)
comment:1 Changed 7 years ago by
- Cc kcrisman added
comment:2 Changed 6 years ago by
- Milestone changed from sage-5.11 to sage-5.12
comment:3 Changed 6 years ago by
comment:4 Changed 6 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:5 Changed 6 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:6 Changed 5 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:7 Changed 4 years ago by
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.
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.