Project

General

Profile

Feature #1723

New fn CoprimePart, OddPart: naming question

Added by John Abbott about 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
New Function
Target version:
Start date:
14 Feb 2023
Due date:
% Done:

100%

Estimated time:
1.80 h
Spent time:

Description

I am considering adding two new functions:
  • OddPart(N) or maybe OddFactor(N) which returns N/2^k where k is chosen so that the value is odd
  • CoprimePart(N,b) or CoprimeFactor(N,b) which returns N/gcd(N,b^infinity)*

In some sense these functions are like "ideal saturation".

Obviously OddPart(N) = CoprimePart(N,2). So does it make sense even to have a separate function OddPart?
Which names do you prefer?
Which order for the arguments of CoprimePart(N,b) or CoprimePart(b,N)?

Note that the similar function FactorMultiplicity(b,N) has the args in the order "small factor" then "big number" (but this is actually contrary to our guidelines).

History

#1 Updated by John Abbott about 1 year ago

I thought of OddPart first (because I needed it somewhere).
Then I found I wanted the more general version, but had trouble thinking of a good, mnemonic name.
Inspired by OddPart (which seemed natural to me at the time), I thought of CoprimePart but
admit that the name is not so mnemonic. I did also wonder about saturate (or similar), but that
frankly sounds weird.

Note that CoprimePart(b,N) is not in general the same as N/b^FactorMultiplicity(b,N):
for example N = 1800 = 2^3 * 3^2 * 5^2 and b = 10 = 2*5 give CoprimePart = 9
and FactorMultiplicity(b, N) = 2 because b^3 does not divide N.

Comments? Suggestions? Ideas?

#2 Updated by John Abbott about 1 year ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

Since I need the fn for something else, I'll proceed with CoprimePart.
But I still hope to get feedback, and perhaps a better idea/name!

#3 Updated by Anna Maria Bigatti about 1 year ago

John Abbott wrote:

Since I need the fn for something else, I'll proceed with CoprimePart.
But I still hope to get feedback, and perhaps a better idea/name!

I prefer CoprimeFactor. That makes me guess what it does.
I find "Part" a bit vague.

#4 Updated by John Abbott about 1 year ago

  • % Done changed from 10 to 40

Thanks for the feedback!
I must agree that it is probably easier to guess what the fn does if it is called CoprimeFactor.

I've already changed the code... must still do the doc (or even write the doc?)

#5 Updated by John Abbott about 1 year ago

Oops! I had meant to include Nico Mexis as a watcher for this issue.
I have just added him. Let's see if he has any good suggestions.

#6 Updated by Nico Mexis about 1 year ago

A quick thought I had about that: Two separate functions (or at least a if (b == 2) {...} else {...} inside CoprimePart) might be a good idea.
The implementation for b=2 could benefit by just utilizing bitshift operations since you only need to bit-shift N to the right until N&1 != 0.

Apart from that, I would agree that CoprimeFactor might be a bit more logical. However, ChatGPT will also suggest the name OddPart itself when prompted.

#7 Updated by Nico Mexis about 1 year ago

After looking a bit further into this, if b is prime, then CoprimePart(b,N) seems to usually be called b-free part of N.
However, then the only function name I could think of would be BFreePart(B,N) or something like that and it does not look that great...

#8 Updated by John Abbott about 1 year ago

  • Assignee set to John Abbott
  • % Done changed from 40 to 70

I have added b-free part as a keyword (or similar).
The fn name I have kept as CoprimePart, as it seems a reasonable compromise.
Will check in soon.

#9 Updated by John Abbott about 1 year ago

  • % Done changed from 70 to 90

#10 Updated by John Abbott about 1 year ago

  • Status changed from In Progress to Closed
  • % Done changed from 90 to 100
  • Estimated time set to 1.80 h

Also available in: Atom PDF