| Karim Belabas on Mon, 01 Jan 2024 15:15:01 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: gp_oeis_search (Search integer sequence specified by short PARI/GP script on oeis.org) |
Dear Hermann,
Another interesting option is to do it all from gp:
oeis(v)=
{ my(s = ""); for (i=1, #v, s = concat(s, Str(v[i]",")));
extern(Str("$BROWSER https://oeis.org/search?q=", s))
}
v = vector(40, i, qfbclassno(-4*i)); /* some sequence of interest */
oeis(v);
I happen to have a BROWSER environment variable, but you could of course
replace $BROWSER by a hardcoded path to your favourite browser.
The above used all known terms; OEIS recommends using about 6 terms for
searches, omitting the first term in the sequence. This is easily done as
oeis(v[2..7])
which doesn't quite work in our example: 2004 matches ... But
oeis(v[2..14])
does produce a single match (as well as oeis(v[20..26]), etc.).
Cheers,
K.B.
P.S. My browser is firefox, always opened in a specific virtual desktop; in my
setting, the oeis() command opens a new tab in the existing browser window
and I can quickly switch desktops to check the result and go back to my
gp session (using keyboard shortcuts).
* hermann@stamm-wilbrandt.de [2024-01-01 09:58]:
> Often I search for integer sequences on the on-line encyclopedia for integer
> sequences.
> I create a short script that prints the sequence I am interested, separated
> by commas.
> Then I copy that sequence into oeis.org search field to find the sequence.
>
> Lately I always create the sequences with PARI/GP scripts, and they are
> typically short.
> So I created script gp_oeis_search to automate this process:
> https://gist.github.com/Hermann-SW/3112d25ede6052df738d8d96651f6d5d
>
> Yesterday I was interested in the -4*n classnumber sequence and did:
>
> $ gp_oeis_search 'for(i=1,40,print1(qfbclassno(-4*i),","))'
>
> That opened this URL in the browser (works without commas being percent
> encoded in URL):
>
> https://oeis.org/search?q=1,1,1,1,2,2,1,2,2,2,3,2,2,4,2,2,4,2,3,4,4,2,3,4,2,6,3,2,6,4,3,4,4,4,6,4,2,6,4,4,
>
>
> I work with PARI/GP on my Android smartphone under termux.
> And wanted to be able to use above script under termux as well.
> After installing termux-x11 that was possible, details here (gist comment
> shows screenshot as well):
>
> https://gist.github.com/Hermann-SW/3112d25ede6052df738d8d96651f6d5d?permalink_comment_id=4813538#gistcomment-4813538
>
>
> Regards,
>
> Hermann.
>
K.B.
--
Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/