Project

General

Profile

Design #1309

SmoothFactor: allow limit = 1?

Added by John Abbott over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Improving
Start date:
10 Sep 2019
Due date:
% Done:

100%

Estimated time:
1.01 h
Spent time:

Description

The SmoothFactor function tries to factorize integers by dividing by all primes up to a specified limit.

Currently that limit must be at least 2, otherwise an error is reported.

Should the limit be lowered to 1?

One motivation: let p be a prime, then one would expect SmoothFactor(p, FloorSqrt(p)) to return an empty factorization (and the RemainingFactor would be just p). With the current limit of 2 this will not work for the primes 2 and 3 because the FloorSqrt is below 2.

History

#1 Updated by John Abbott over 4 years ago

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

The original reason for imposing the limit was to help users detect "obviously silly" function calls. Now I think that SmoothFactor(n,1) is not always "obviously silly".

I encountered the problem in another program I have written. In this program I wanted to compute something like SmoothFactor(n,FloorSqrt(n)); just occasionally n can be small, so the program triggers a BadArg error.

Of course, I could change my program so that it detects if n is smaller than 4 and then handles that case specially; but that makes my program more complicated and less readable.

Comments? Opinions?

#2 Updated by John Abbott over 4 years ago

There are two separate impls for SmoothFactor (one for MachineInt and one for BigInt). One allowed the limit 1, the other did not.

#3 Updated by John Abbott over 4 years ago

I have just changed the code to allow limit=1. All tests and examples pass (which suggests that the tests were not very thorough... oh).

#4 Updated by John Abbott over 4 years ago

  • Status changed from In Progress to Closed
  • Assignee set to John Abbott
  • % Done changed from 10 to 100

#5 Updated by Anna Maria Bigatti over 4 years ago

  • Target version changed from CoCoALib-0.99700 to CoCoALib-0.99650 November 2019
  • Estimated time set to 1.01 h

Also available in: Atom PDF