numberscope / backscope

Numberscope's back end: responsible for getting sequences and other data from the On-Line Encyclopedia of Integer Sequences, pre-processing it (factoring etc), and storing it.
MIT License
1 stars 9 forks source link

Backend should store and make available the factorizations of sequence entries #12

Closed gwhitney closed 2 years ago

gwhitney commented 3 years ago

The desire to easily look at sequence entries in terms of their prime factorizations is one of the primary motivations/justifications for having a Numberscope backend distinct from the OEIS. This information can be computed just once, and stored for easy access and manipulation in the frontscope, rather than burdening viewers' browsers with performing the factorizations on the client side.

gwhitney commented 3 years ago

This also begs the question of how the front end would allow users to access such information.

katestange commented 2 years ago

Some more specific suggestions.

(1) For a URL, we could use: http://[SERVER]/api/get_oeis_factored/[OEIS ID]/[NUM]

(2) In the vast majority of cases where you want the sequence factored for some purpose, you would want to treat -1 differently. But it would be convenient to be able to loop through a list of factors otherwise. So how about an object (dictionary) like

type Factorization = {
  sign: BigInt; // either 1 or -1
  factors: BigInt[][]; // list of two-element lists [p,e] indicating factor p**e, where p is prime, e is exponent, in increasing order of p
};

Then, someone who wants to iterate through the prime powers can do so easily, and the sign is also easy to call. Example: -40 becomes { sign: -1, factors: [[2,3],[5,1]] }

gwhitney commented 2 years ago

Kate also raised two related questions:

  1. How to fail gracefully when an entry is too big to factor?
  2. How to deal with the fact that factorization could be slow and browser might have to wait?
gwhitney commented 2 years ago

On 1 I think the answer should be as close to the same as possible for dealing with missing entries of base sequences (see issue 19 in frontscope), but we haven't settled on that yet.

gwhitney commented 2 years ago

On 2, I think that factorization should happen in the background on any base sequence that's been requested, and in the interval until that happens, the unfactored entries show up as missing just as if (1) were the case.