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

Correct definition of lcm #37923

Merged
merged 1 commit into from
Oct 30, 2020
Merged

Correct definition of lcm #37923

merged 1 commit into from
Oct 30, 2020

Conversation

fingolfin
Copy link
Contributor

The old definition would imply that lcm always returns 0. This brings it more in line with that of gcd.

Actually, as an algebraist by profession, I am still unhappy with that documentation because I would not have been able to correctly guess what lcm and gcd return if given non-integer rational arguments -- after reading the source code, I understand the definition you implicitly are using here, and don't object to it; however, it contradicts the usual definition of gcd and lcm I would teach to my first year students and that one would find when picking up most (all?) books giving an introduction to Abstract Algebra. The confusion results from what exactly a "multiple" or a "divisor" is: here it means "integer multiple" resp. "number such that the quotient is an integer"; while in abstract algebra, the way to generalize would be to look at the gcd/lcm in the domain at rational numbers, and then allow rational multiples -- meaning that the gcd and lcm are always either 0 or 1.

Thus there is potential for confusion, and I think the documentation for gcd and lcm ought to be extended to state explicitly how they are defined for rationals.

Perhaps like this (I can update this PR if people are OK with it, also if there are better suggestions):

Greatest common (positive) divisor (or zero if all arguments are zero).
Being a common divisor here means that every argument is a multiple of the result by some integer.
The arguments may be integer and rational numbers.

Least common (positive) multiple (or zero if any argument is zero).
Being a common multiple here means that the result is a multiple of each argument by some integer.
The arguments may be integer and rational numbers.

The old definition would imply that lcm always returns 0. This
brings it more in line with that of gcd.
@rfourquet rfourquet added the docs This change adds or pertains to documentation label Oct 7, 2020
@fingolfin fingolfin closed this Oct 30, 2020
@fingolfin fingolfin reopened this Oct 30, 2020
@vtjnash vtjnash merged commit 719c4d0 into JuliaLang:master Oct 30, 2020
@fingolfin fingolfin deleted the mh/lcm branch October 30, 2020 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants