Skip to content

The integer functions reject a rational operand and stop at positive orders - #543

Open
enumeratio wants to merge 1 commit into
cortex-js:mainfrom
enumeratio:rational-integer-functions
Open

enumeratio wants to merge 1 commit into
cortex-js:mainfrom
enumeratio:rational-integer-functions

Conversation

@enumeratio

Copy link
Copy Markdown
Contributor

Fixes #542

NextPrime, DivisorSigma, FactorInteger, IsSquareFree, CatalanNumber and IsPerfect accept rational and non-positive operands:

  • NextPrime(7/2) is 5 (a non-integer real or rational; the integer forms and NextPrime(-10) = 2 are unchanged).
  • DivisorSigma(k, n) for k < 0 is the rational sigma_{-k}(n) / n^{-k}; a huge order stays unevaluated. Typed integer for k >= 0, rational otherwise.
  • FactorInteger(p/q) and IsSquareFree(p/q) factor numerator and denominator.
  • CatalanNumber takes a real: a positive half-integer is exact (8/(3*Pi)), other positive reals go through Gamma under a float or .N().
  • IsPerfect(n) is False for n < 1.

Existing tests that pin old behavior changed: none. Left alone because of documented rulings: GCD/LCM of rationals (symbolic under evaluate()), NextPrime(-10).

Known limit: .N() numericizes a rational operand before the signature check, so FactorInteger(12/35).N() and IsSquareFree(6/35).N() are still an incompatible-type error (as they were); evaluate() is exact.

…, CatalanNumber and IsPerfect accept rational and non-positive operands: NextPrime(7/2) = 5, DivisorSigma(-1, 12) = 7/3, FactorInteger(12/35), IsSquareFree(6/35), CatalanNumber(1/2) = 8/(3π), IsPerfect(-6) = False; add regression tests. Fix cortex-js#542
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

The integer functions reject a rational operand and stop at positive orders

1 participant