CINXE.COM
Sequence Tools - OeisWiki
<!DOCTYPE html> <html class="client-nojs" lang="en" dir="ltr"> <head> <meta charset="UTF-8"/> <title>Sequence Tools - OeisWiki</title> <script>document.documentElement.className = document.documentElement.className.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );</script> <script>(window.RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"Sequence_Tools","wgTitle":"Sequence Tools","wgCurRevisionId":1661200,"wgRevisionId":1661200,"wgArticleId":201253,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Sequence Tools"],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgMonthNamesShort":["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"wgRelevantPageName":"Sequence_Tools","wgRelevantArticleId":201253,"wgRequestId":"37048e60c1fc3255ca242c06","wgIsProbablyEditable":false,"wgRelevantPageIsProbablyEditable":false,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgFlaggedRevsParams":{"tags":{"style":{"levels":2,"quality":2,"pristine":4}}},"wgStableRevisionId":1661200});mw.loader.state({"site.styles":"ready","noscript":"ready","user.styles":"ready","user":"ready","user.options":"loading","user.tokens":"loading","ext.flaggedRevs.basic":"ready","mediawiki.legacy.shared":"ready","mediawiki.legacy.commonPrint":"ready","mediawiki.sectionAnchor":"ready","mediawiki.skinning.interface":"ready","mediawiki.skinning.content.externallinks":"ready","skins.monobook.styles":"ready"});mw.loader.implement("user.options@0bhc5ha",function($,jQuery,require,module){mw.user.options.set([]);});mw.loader.implement("user.tokens@0jlvv7z",function ( $, jQuery, require, module ) { mw.user.tokens.set({"editToken":"+\\","patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"});/*@nomin*/ });mw.loader.load(["site","mediawiki.page.startup","mediawiki.user","mediawiki.hidpi","mediawiki.page.ready","mediawiki.toc","mediawiki.searchSuggest","ext.flaggedRevs.advanced"]);});</script> <link rel="stylesheet" href="/w/load.php?debug=false&lang=en&modules=ext.flaggedRevs.basic%7Cmediawiki.legacy.commonPrint%2Cshared%7Cmediawiki.sectionAnchor%7Cmediawiki.skinning.content.externallinks%7Cmediawiki.skinning.interface%7Cskins.monobook.styles&only=styles&skin=monobook"/> <script async="" src="/w/load.php?debug=false&lang=en&modules=startup&only=scripts&skin=monobook"></script> <!--[if IE 6]><link rel="stylesheet" href="/w/skins/MonoBook/IE60Fixes.css?303" media="screen"/><![endif]--><!--[if IE 7]><link rel="stylesheet" href="/w/skins/MonoBook/IE70Fixes.css?303" media="screen"/><![endif]--> <meta name="ResourceLoaderDynamicStyles" content=""/> <meta name="generator" content="MediaWiki 1.30.0"/> <link rel="shortcut icon" href="/favicon.ico"/> <link rel="search" type="application/opensearchdescription+xml" href="/w/opensearch_desc.php" title="OeisWiki (en)"/> <link rel="EditURI" type="application/rsd+xml" href="https://oeis.org/w/api.php?action=rsd"/> <link rel="license" href="/wiki/The_OEIS_End-User_License_Agreement"/> <link rel="alternate" type="application/atom+xml" title="OeisWiki Atom feed" href="/w/index.php?title=Special:RecentChanges&feed=atom"/> <!--[if lt IE 9]><script src="/resources/lib/html5shiv/html5shiv.min.js"></script><![endif]--> </head> <body class="mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Sequence_Tools rootpage-Sequence_Tools skin-monobook action-view"><div id="globalWrapper"> <div id="column-content"> <div id="content" class="mw-body" role="main"> <a id="top"></a> <div id="siteNotice" class="mw-body-content"><div id="localNotice" lang="en" dir="ltr"><div class="mw-parser-output"><p>This site is supported by donations to <a rel="nofollow" class="external text" href="http://oeisf.org/">The OEIS Foundation</a>. </p></div></div></div> <div class="mw-indicators mw-body-content"> </div> <h1 id="firstHeading" class="firstHeading" lang="en">Sequence Tools</h1> <div id="bodyContent" class="mw-body-content"> <div id="siteSub">From OeisWiki</div> <div id="contentSub"><div id="mw-fr-revisiontag" class="flaggedrevs_basic flaggedrevs_stable_synced plainlinks noprint nomobile"><img class="flaggedrevs-icon" src="/w/extensions/FlaggedRevs/frontend/modules/img/2.png" alt="This is a checked version of this page" title="This is a checked version of this page" />This is the latest <a href="/wiki/Help:Page_validation" title="Help:Page validation">approved</a> revision (<a rel="nofollow" class="external text" href="https://oeis.org/w/index.php?title=Special:Stableversions&page=Sequence_Tools">list all</a>), <a rel="nofollow" class="external text" href="https://oeis.org/w/index.php?title=Special:Log&type=review&page=Sequence_Tools">approved</a> on <i>5 October 2024</i>.<a id="mw-fr-revisiontoggle" class="fr-toggle-symbol" style="display:none;" title="show/hide details" >(+)</a><div id='mw-fr-revisiondetails'> <span class='fr-marker-40'><strong>Readability</strong>: <span class='fr-text-value'>Reviewed </span> </span> </div></div> </div> <div id="jump-to-nav" class="mw-jump">Jump to: <a href="#column-one">navigation</a>, <a href="#searchInput">search</a></div> <!-- start content --> <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><div class="mw-parser-output"><p>This page is dedicated to links and code snippets for <a href="/w/index.php?title=Sequence_checking&action=edit&redlink=1" class="new" title="Sequence checking (page does not exist)">checking</a> and <a href="/w/index.php?title=Sequence_formatting&action=edit&redlink=1" class="new" title="Sequence formatting (page does not exist)">formatting sequences</a>. </p> <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#Restricting_a_list_to_a_fixed_number_of_characters"><span class="tocnumber">1</span> <span class="toctext">Restricting a list to a fixed number of characters</span></a> <ul> <li class="toclevel-2 tocsection-2"><a href="#Mathematica"><span class="tocnumber">1.1</span> <span class="toctext">Mathematica</span></a></li> <li class="toclevel-2 tocsection-3"><a href="#Maple"><span class="tocnumber">1.2</span> <span class="toctext">Maple</span></a></li> <li class="toclevel-2 tocsection-4"><a href="#Pari.2FGP"><span class="tocnumber">1.3</span> <span class="toctext">Pari/GP</span></a></li> <li class="toclevel-2 tocsection-5"><a href="#Haskell"><span class="tocnumber">1.4</span> <span class="toctext">Haskell</span></a></li> <li class="toclevel-2 tocsection-6"><a href="#Sage"><span class="tocnumber">1.5</span> <span class="toctext">Sage</span></a></li> <li class="toclevel-2 tocsection-7"><a href="#GAP"><span class="tocnumber">1.6</span> <span class="toctext">GAP</span></a></li> </ul> </li> <li class="toclevel-1 tocsection-8"><a href="#Formatting_a_b-file"><span class="tocnumber">2</span> <span class="toctext">Formatting a b-file</span></a> <ul> <li class="toclevel-2 tocsection-9"><a href="#Julia"><span class="tocnumber">2.1</span> <span class="toctext">Julia</span></a></li> <li class="toclevel-2 tocsection-10"><a href="#Maple_2"><span class="tocnumber">2.2</span> <span class="toctext">Maple</span></a></li> <li class="toclevel-2 tocsection-11"><a href="#Mathematica_2"><span class="tocnumber">2.3</span> <span class="toctext">Mathematica</span></a></li> <li class="toclevel-2 tocsection-12"><a href="#PARI.2FGP_2"><span class="tocnumber">2.4</span> <span class="toctext">PARI/GP</span></a></li> <li class="toclevel-2 tocsection-13"><a href="#Python"><span class="tocnumber">2.5</span> <span class="toctext">Python</span></a></li> </ul> </li> <li class="toclevel-1 tocsection-14"><a href="#Reading_b-files"><span class="tocnumber">3</span> <span class="toctext">Reading b-files</span></a> <ul> <li class="toclevel-2 tocsection-15"><a href="#PARI.2FGP_3"><span class="tocnumber">3.1</span> <span class="toctext">PARI/GP</span></a></li> <li class="toclevel-2 tocsection-16"><a href="#Various_tools"><span class="tocnumber">3.2</span> <span class="toctext">Various tools</span></a></li> </ul> </li> <li class="toclevel-1 tocsection-17"><a href="#Guess_generating_function"><span class="tocnumber">4</span> <span class="toctext">Guess generating function</span></a> <ul> <li class="toclevel-2 tocsection-18"><a href="#PARI.2FGP_4"><span class="tocnumber">4.1</span> <span class="toctext">PARI/GP</span></a></li> </ul> </li> <li class="toclevel-1 tocsection-19"><a href="#Formatting_a_linear_recurrence_signature"><span class="tocnumber">5</span> <span class="toctext">Formatting a linear recurrence signature</span></a> <ul> <li class="toclevel-2 tocsection-20"><a href="#AutoHotKey"><span class="tocnumber">5.1</span> <span class="toctext">AutoHotKey</span></a></li> </ul> </li> </ul> </div> <h2><span class="mw-headline" id="Restricting_a_list_to_a_fixed_number_of_characters">Restricting a list to a fixed number of characters</span></h2> <p>Historically, the <a href="/wiki/Style_Sheet#Data" title="Style Sheet"><span class="smallcaps" style="font-variant: small-caps;">Data</span> OEIS sequence entry field</a> had enough terms to fill about three lines on the screen—maybe 260 characters including [decimal] digits, signs, commas and whitespaces (spaces and newlines; tabs NOT ALLOWED). For a larger number of terms, the contributors can submit a <a href="/wiki/B-files" title="B-files">b-file</a> containing an index and a term on each line and as many lines as needed. </p> <h3><span class="mw-headline" id="Mathematica">Mathematica</span></h3> <p><i>(From: <a href="/wiki/User:T._D._Noe" title="User:T. D. Noe">T.D. Noe</a>)</i> </p> <pre> OEISTrim[lst_List, maxLen_Integer: 260] := Module[{newLst = {}, len = 0}, Do[len = len + 2 + Length[IntegerDigits[term]] + Boole[term < 0]; If[len <= maxLen, AppendTo[newLst, term], Break[]], {term, lst}]; newLst] </pre> <p>It defaults to a length of 260 characters, which seems perfect. Example: the sequence of numbers 1 to 100 is trimmed by </p> <pre> OEISTrim[Range[100]] </pre> <p>producing a list of just the first 67 numbers. </p> <h3><span class="mw-headline" id="Maple">Maple</span></h3> <p><i>(From <a href="/wiki/User:Peter_Luschny" title="User:Peter Luschny">Peter Luschny</a>)</i> </p> <pre> OEIStrim := proc(f, offset) local L, n, len, fn, s, islist; L := NULL; len := 0; islist := whattype(f) = list; n := `if`(islist, 1, offset); do fn := `if`(islist, f[n], f(n)); s  := `if`(fn <= 0, 1, 0); len := len + s + length(fn); if len > 260 then break fi; len := len + 2; L := L, fn; n := n + 1; od; L end: </pre> <p>Usage: </p> <pre> OEIStrim(n -> n, 0); f := n -> -n: OEIStrim(f, 0); F := [seq(n, n = 0..100)]: OEIStrim(F, ignore); </pre> <h3><span class="mw-headline" id="Pari.2FGP">Pari/GP</span></h3> <p><i>(from <a href="/wiki/User:Robert_Gerbicz" title="User:Robert Gerbicz">Robert Gerbicz</a>)</i> </p> <pre> { OEISTrim(v) = L=260; len=0; w=[]; for(i=1,length(v), len+=3+(v[i]<0); x=abs(v[i])\10; while(x,len++;x\=10); if(len>L,break); w=concat(w,v[i]); ); return(w) } </pre> <p>Usage: </p> <pre> OEISTrim(vector(100,i,i)) </pre> <p>returns the first 67 positive integers. </p><p><b>Alternate code:</b> </p><p><i>(from <a href="/wiki/User_talk:M._F._Hasler" title="User talk:M. F. Hasler">MFH</a>)</i> </p><p>Allows to specify the desired length as optional 2nd argument. (Notes: (1) The order of the arguments in <code>select()</code> has changed in PARI/GP version 2.4.2; for older versions, change <code>select(vector, function)</code> to <code>select(function, vector)</code>. (2) The <code>local</code> declaration makes the modifications of <code>L</code> in the function persistent.) </p> <pre> OEIS_trim(v, L=260)=local(L=L); select(t->-3<L-=#Str(t)+2, v) \\ (correct syntax for PARI/GP version 2.4.3 and later) </pre> <h3><span class="mw-headline" id="Haskell">Haskell</span></h3> <p><i>(from <a href="/wiki/User:Reinhard_Zumkeller" title="User:Reinhard Zumkeller">Reinhard Zumkeller</a>)</i> </p> <pre> import Data.List (unfoldr) oeisTrim xs = take (length $ unfoldr t (260, xs)) xs where t (_, []) = Nothing t (still, u:us) | len > still = Nothing | otherwise = Just (len, (still - len, us)) where len = length (show u) + 2 </pre> <p>Usage: </p> <pre> oeisTrim [] == [] oeisTrim [1..] == [1..67] oeisTrim [1..10] == [1..10] oeisTrim [1..100] == [1..67] oeisTrim [10..1000] == [10..74] </pre> <h3><span class="mw-headline" id="Sage">Sage</span></h3> <p><i>(from <a href="/wiki/User:Peter_Luschny" title="User:Peter Luschny">Peter Luschny</a>)</i> </p> <pre> def OEIStrim(L) : n = 0 leng = 0 T = [] for l in L : s = 1 if l < 0 else 0 leng = leng + s + len(str(l)) if leng > 260 : break leng += 2 T.append(l) n += 1 print n, "terms" return T </pre> <p>For example: </p> <pre> OEIStrim(range(100)) </pre> <h3><span class="mw-headline" id="GAP">GAP</span></h3> <p><i>(from <a href="/wiki/User:Eric_M._Schmidt" title="User:Eric M. Schmidt">Eric M. Schmidt</a>)</i> </p> <pre> OEISTrim := function(seq) local i, len; i := 0; len := -2; while len <= 260 do i := i + 1; if i > Length(seq) then break; fi; len := len + Length(String(seq[i])) + 2; od; return seq{[1..i-1]}; end; </pre> <p>Example: </p> <pre> OEISTrim([1..100]); </pre> <h2><span class="mw-headline" id="Formatting_a_b-file">Formatting a b-file</span></h2> <p>An important point is the format of line ends, which should be Unix (single <tt>LF</tt>). </p> <h3><span class="mw-headline" id="Julia">Julia</span></h3> <p><i>(from <a href="/wiki/User:Peter_Luschny" title="User:Peter Luschny">Peter Luschny</a>)</i> </p> <pre> using Dates function write_oeis_bfile(anum, range, seq, comments, targetdir) if !occursin(r"^A[0-9]{6}$", anum) @warn("Not a valid A-number! Exiting.") return end filename = joinpath(targetdir, "b" * anum[2:end] * ".txt") @info("Writing " * anum * " to " * filename) file = open(filename, "w") timestamp = Dates.format(now(), "yyyy-mm-dd HH:MM") println(file, "# ", timestamp) for c in comments println(file, "# ", c) end for n in range val = seq(n) if length(string(val)) > 1000 @error("Term too long, exiting.") break end println(file, n, " ", val) end print("\n") close(file) end </pre> <p>Example use: </p> <pre> path = "C:/Users/Home/" comments = ["Author: Julia Verona", "The divergent series par excellence."] a(n) = factorial(BigInt(n)) R = 11:200 write_oeis_bfile("<a href="http://oeis.org/A000142">A000142</a>", R, a, comments, path) </pre> <p>Example use: </p> <pre> write_oeis_bfile("<a href="http://oeis.org/A000290">A000290</a>", 0:100, n -> n * n, "", path) </pre> <h3><span class="mw-headline" id="Maple_2">Maple</span></h3> <p><i>(from <a href="/wiki/User:Robert_Israel" title="User:Robert Israel">Robert Israel</a>)</i> </p><p>This will output a time-stamped <a href="/wiki/B-file" class="mw-redirect" title="B-file">b-file</a> given an <a href="/wiki/A-number" class="mw-redirect" title="A-number">A-number</a>, either a procedure or a list, an offset, and a final index value. In the case of a procedure, the file will be truncated before producing a number of more than 999 digits. </p> <pre> Makebfile := proc(anumber, A, offset, N) local bfile, n, v, dn; bfile := StringTools:-SubstituteAll(sprintf("b%6d.txt",anumber)," ","0"); fopen(bfile, WRITE); fprintf(bfile,StringTools:-FormatTime("# Produced using Maple, %B %d %Y\n")); if type(A,procedure) then for n from offset to N do v := A(n); if length(v) > 999 then break end if; fprintf(bfile,"%d %d\n",n,v); end do else for n from offset to N do fprintf(bfile,"%d %d\n",n,A[n+1-offset]) end do end if; fclose(bfile) end proc: </pre> <p>Example usage: </p> <pre> Makebfile(217, n -> n*(n+1)/2, 0, 10000); </pre> <h3><span class="mw-headline" id="Mathematica_2">Mathematica</span></h3> <p><i>(from <a href="/wiki/User:Charles_R_Greathouse_IV" title="User:Charles R Greathouse IV">Charles Greathouse</a>)</i> </p><p>This is a basic implementation that needs polishing, but it will output a <a href="/wiki/B-file" class="mw-redirect" title="B-file">b-file</a> given an <a href="/wiki/A-number" class="mw-redirect" title="A-number">A-number</a>, a List, and an optional offset. </p> <pre> bFile[aNum_Integer, v_List, offset_Integer: 1] := Module[{s = OpenWrite[ "b" <> StringTake["00000", 6 - IntegerLength[aNum]] <> ToString[aNum] <> ".txt"]}, For[i = 1, i <= Length[v], i++, WriteString[s, i + offset - 1, " ", v[[i]], "\n"]]; Close[s]] bFile::usage = "bFile[aNum, v] writes a b-file with terms given in the List v, \ using offset 1.\nbFile[aNum, v, offset] writes a b-file with the \ specified offset."; </pre> <h3><span class="mw-headline" id="PARI.2FGP_2">PARI/GP</span></h3> <p><i>(from <a href="/wiki/User:Charles_R_Greathouse_IV" title="User:Charles R Greathouse IV">Charles Greathouse</a>)</i> </p><p>This <a href="/wiki/PARI/GP" title="PARI/GP">GP</a> script takes a name (as a string or as a number, e.g. "b000000.txt" or 0) and a vector, plus an optional offset. It outputs a <a href="/wiki/B-files" title="B-files">b-file</a> along with boilerplate text for inclusion into the OEIS. The created b-file follows the strict format, including the recommendation that numbers not exceed 1000 digits. </p> <pre> bfile(name, v, offset=1, limit=1000)={ my(cur=offset-1,F); name = Str(name); while(#name < 6, name = Str(0,name)); name = Str("b"name".txt"); F=fileopen(name, "w"); for(i=1,#v, if (#Str(v[i]) > limit, print("Next term has "#Str(v[i])" digits; exiting."); break ); my(s=Str(cur++, " ", v[i])); filewrite(F, s); ); fileclose(F); } addhelp(bfile, "bfile(name, v, offset=1): Creates a b-file with the values of v for A-number name (given as a number or a filename)."); </pre> <h3><span class="mw-headline" id="Python">Python</span></h3> <p><i>(from <a href="/wiki/User:Peter_Luschny" title="User:Peter Luschny">Peter Luschny</a>)</i> </p> <pre> import re from datetime import date def write_oeis_bfile(anum, range, seq, comments, targetdir): if not re.match("^A[0-9]{6}$", anum): print("Not a valid A-number! Exiting.") return filename = targetdir + "b" + anum[1:] + ".txt" print("Writing " + anum + " to " + filename) file = open(filename, "w+") file.write("# OEIS: " + anum + "\n") today = date.today() timestamp = today.isoformat() file.write("# " + timestamp + "\n") for c in comments: file.write("# " + c + "\n") for n in range: val = seq(n) if len(str(val)) > 1000: print("Term too long, exiting.") break file.write(str(n) + " " + str(val) + "\n") file.write("\n") file.close() </pre> <p>Usage: </p> <pre> comments = ["Author: Pythia Delphi", "Software: SageMath 9.2", "The divergent series par excellence." ] def a(n): return factorial(n) path = "C:/Users/Home/" write_oeis_bfile("<a href="http://oeis.org/A000142">A000142</a>", range(11), a, comments, path) </pre> <p><br /> </p> <h2><span class="mw-headline" id="Reading_b-files">Reading b-files</span></h2> <h3><span class="mw-headline" id="PARI.2FGP_3">PARI/GP</span></h3> Unfortunately, PARI has very limited power for handling files and even strings. The following may be used to get a vector of values from a b-file, using <pre>#Axxx=b2v(readstr("/tmp/bxxx.txt"));</pre> in particular it supports empty and comment lines (starting with "#") in the b-file. The argument <i><b>v</b></i> is a vector of strings as it results from <pre>readstr("bxxx.txt")</pre>. <pre> b2v(v)=apply(s->for(i=2,#s=Vecsmall(s),s[i-1]>=48&&s[i]<48&&return(eval(Strchr(s[i+1..#s])))),select(s->#s>2&&Vecsmall(s)[1]!=35,v)) \\ (c) 2014 by [[User:M. F. Hasler|M. F. Hasler]]. </pre> <h3><span class="mw-headline" id="Various_tools">Various tools</span></h3> <ul><li> <a rel="nofollow" class="external text" href="https://codegolf.stackexchange.com/q/89376">Automate the OEIS</a>, CodeGolf StackExchange, 2016. A collection of methods for retrieving terms of OEIS sequences with various tools and/or programming languages.</li></ul> <h2><span class="mw-headline" id="Guess_generating_function">Guess generating function</span></h2> <p><i>See also <a href="/wiki/User:Charles_R_Greathouse_IV/Pari#Recurrences" title="User:Charles R Greathouse IV/Pari">User:Charles_R_Greathouse_IV/Pari#Recurrences</a> for snippets to detect linear recurrences.</i> </p> <h3><span class="mw-headline" id="PARI.2FGP_4">PARI/GP</span></h3> <p><i>(From <a href="/wiki/User:M._F._Hasler" title="User:M. F. Hasler">M. F. Hasler</a>. <a href="/wiki/IIRC" class="mw-redirect" title="IIRC">IIRC</a>, this was originally inspired by code from <a href="/wiki/User:Max_Alekseyev" title="User:Max Alekseyev">Max Alekseyev</a>, but as of today I'm unable to trace back, e.g. via his page of <a rel="nofollow" class="external text" href="http://www.cse.sc.edu/~maxal/gpscripts/">GP scripts</a>.)</i> </p><p>This <a href="/wiki/PARI/GP" title="PARI/GP">PARI/GP</a> script takes a vector of at least 8 elements and looks for a (rational) generating function. In case of failure, it returns various error messages. It also does some additional checks: In particular, after computation of the g.f., it checks whether this indeed reproduces all terms of the vector. </p> <pre> ggf(v)={ my( p, q, B=#v\2 ); if( B<4, "Need at least 8 values!", if( !#q=qflll(matrix(B,B,x,y,v[x-y+B+1]),4)[1], "QFLLL returned empty result.", polcoeff(p=Ser(q[,1]),0)<0 && p=-p; /* adjust sign */ q=Pol(Ser(v)*p); if( Ser(v)==q/=Pol(p), q, Str("I guessed ",q,", but it doesn't reproduce the last value!") )))} </pre> <p>A drawback of this code is PARI's representation of numerator and denominator as polynomials printed in order of decreasing powers. They can be reformatted using the following snippets: </p> <pre> p( P )=concat( vecextract( Vec(Str( P+O(x^99) )), "..-11")) /* write polynomial with increasing powers */ pgf( f )=Str/*or: print*/("(",p(numerator(f)),")/(",p(denominator(f)),")") /* prettyprint rational g.f. */ </pre> <h2><span class="mw-headline" id="Formatting_a_linear_recurrence_signature">Formatting a linear recurrence signature</span></h2> <h3><span class="mw-headline" id="AutoHotKey">AutoHotKey</span></h3> <p><i>(from <a href="/wiki/User:Harvey_P._Dale" title="User:Harvey P. Dale">Harvey P. Dale</a>)</i> </p><p>This script runs in the background, and when you type "indexp " it replaces those characters with a link to the recurrence index page. You can either install <a rel="nofollow" class="external text" href="http://www.autohotkey.com/">AutoHotKey</a> and run this script or use the executable. </p> <!-- NewPP limit report Cached time: 20250223203504 Cache expiry: 86400 Dynamic content: false CPU time usage: 0.020 seconds Real time usage: 0.022 seconds Preprocessor visited node count: 329/1000000 Preprocessor generated node count: 663/1000000 Post鈥恊xpand include size: 69/2097152 bytes Template argument size: 4/2097152 bytes Highest expansion depth: 2/40 Expensive parser function count: 0/100 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 2.826 1 Template:Small_caps 100.00% 2.826 1 -total --> </div> <!-- Saved in parser cache with key wikidb:stable-pcache:idhash:201253-0!canonical and timestamp 20250223203504 and revision id 1661200 --> </div><div class="printfooter"> Retrieved from "<a dir="ltr" href="https://oeis.org/w/index.php?title=Sequence_Tools&oldid=1661200">https://oeis.org/w/index.php?title=Sequence_Tools&oldid=1661200</a>"</div> <div id="catlinks" class="catlinks" data-mw="interface"><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/wiki/Special:Categories" title="Special:Categories">Category</a>: <ul><li><a href="/wiki/Category:Sequence_Tools" title="Category:Sequence Tools">Sequence Tools</a></li></ul></div></div> <!-- end content --> <div class="visualClear"></div> </div> </div> </div> <div id="column-one"> <h2>Navigation menu</h2> <div id="p-cactions" class="portlet" role="navigation"> <h3>Views</h3> <div class="pBody"> <ul> <li id="ca-nstab-main" class="selected"><a href="/wiki/Sequence_Tools" title="View the content page [c]" accesskey="c">Page</a></li> <li id="ca-talk"><a href="/wiki/Talk:Sequence_Tools" rel="discussion" title="Discussion about the content page [t]" accesskey="t">Discussion</a></li> <li id="ca-viewsource"><a href="/w/index.php?title=Sequence_Tools&action=edit" title="This page is protected. You can view its source [e]" accesskey="e">View source</a></li> <li id="ca-history"><a href="/w/index.php?title=Sequence_Tools&action=history" title="Past revisions of this page [h]" accesskey="h">History</a></li> </ul> </div> </div> <div class="portlet" id="p-personal" role="navigation"> <h3>Personal tools</h3> <div class="pBody"> <ul> <li id="pt-login"><a href="/w/index.php?title=Special:UserLogin&returnto=Sequence+Tools" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o">Log in</a></li> <li id="pt-createaccount"><a href="/wiki/Special:RequestAccount" title="You are encouraged to create an account and log in; however, it is not mandatory">Request account</a></li> </ul> </div> </div> <div class="portlet" id="p-logo" role="banner"> <a href="/wiki/Main_Page" class="mw-wiki-logo" title="Visit the main page"></a> </div> <div class="generated-sidebar portlet" id="p-navigation" role="navigation"> <h3>Navigation</h3> <div class="pBody"> <ul> <li id="n-OEIS"><a href="http://oeis.org/">OEIS</a></li> <li id="n-mainpage-description"><a href="/wiki/Main_Page" title="Visit the main page [z]" accesskey="z">Wiki Main Page</a></li> <li id="n-portal"><a href="/wiki/OeisWiki:Community_portal" title="About the project, what you can do, where to find things">Community portal</a></li> <li id="n-status"><a href="/wiki/OeisWiki:System_Status">System Status</a></li> <li id="n-recentchanges"><a href="/wiki/Special:RecentChanges" title="A list of recent changes in the wiki [r]" accesskey="r">Recent changes</a></li> <li id="n-randompage"><a href="/wiki/Special:Random" title="Load a random page [x]" accesskey="x">Random page</a></li> <li id="n-help"><a href="https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents" title="The place to find out">Help</a></li> </ul> </div> </div> <div id="p-search" class="portlet" role="search"> <h3><label for="searchInput">Search</label></h3> <div id="searchBody" class="pBody"> <form action="/w/index.php" id="searchform"> <input type="hidden" name="title" value="Special:Search"/> <input type="search" name="search" placeholder="Search OeisWiki" title="Search OeisWiki [f]" accesskey="f" id="searchInput"/> <input type="submit" name="go" value="Go" title="Go to a page with this exact name if it exists" id="searchGoButton" class="searchButton"/> <div><a href="/wiki/Special:Search" rel="search">Advanced search</a></div> </form> </div> </div> <div class="portlet" id="p-tb" role="navigation"> <h3>Tools</h3> <div class="pBody"> <ul> <li id="t-whatlinkshere"><a href="/wiki/Special:WhatLinksHere/Sequence_Tools" title="A list of all wiki pages that link here [j]" accesskey="j">What links here</a></li> <li id="t-recentchangeslinked"><a href="/wiki/Special:RecentChangesLinked/Sequence_Tools" rel="nofollow" title="Recent changes in pages linked from this page [k]" accesskey="k">Related changes</a></li> <li id="t-specialpages"><a href="/wiki/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q">Special pages</a></li> <li id="t-print"><a href="/w/index.php?title=Sequence_Tools&printable=yes" rel="alternate" title="Printable version of this page [p]" accesskey="p">Printable version</a></li> <li id="t-permalink"><a href="/w/index.php?title=Sequence_Tools&oldid=1661200" title="Permanent link to this revision of the page">Permanent link</a></li> <li id="t-info"><a href="/w/index.php?title=Sequence_Tools&action=info" title="More information about this page">Page information</a></li> </ul> </div> </div> </div><!-- end of the left (by default at least) column --> <div class="visualClear"></div> <div id="footer" role="contentinfo"> <div id="f-poweredbyico"> <a href="//www.mediawiki.org/"><img src="/w/resources/assets/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" srcset="/w/resources/assets/poweredby_mediawiki_132x47.png 1.5x, /w/resources/assets/poweredby_mediawiki_176x62.png 2x" width="88" height="31"/></a> </div> <ul id="f-list"> <li id="lastmod"> This page was last edited on 5 October 2024, at 10:35.</li> <li id="copyright">Content is available under <a href="/wiki/The_OEIS_End-User_License_Agreement" title="The OEIS End-User License Agreement">The OEIS End-User License Agreement</a> unless otherwise noted.</li> <li id="privacy"><a href="/wiki/OeisWiki:Privacy_policy" class="mw-redirect" title="OeisWiki:Privacy policy">License Agreements, Terms of Use, Privacy Policy</a></li> <li id="about"><a href="/wiki/OeisWiki:About" class="mw-redirect" title="OeisWiki:About">About OeisWiki</a></li> <li id="disclaimer"><a href="/wiki/OeisWiki:General_disclaimer" class="mw-redirect" title="OeisWiki:General disclaimer">Disclaimers</a></li> </ul> </div> </div> <script>(window.RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgPageParseReport":{"limitreport":{"cputime":"0.020","walltime":"0.022","ppvisitednodes":{"value":329,"limit":1000000},"ppgeneratednodes":{"value":663,"limit":1000000},"postexpandincludesize":{"value":69,"limit":2097152},"templateargumentsize":{"value":4,"limit":2097152},"expansiondepth":{"value":2,"limit":40},"expensivefunctioncount":{"value":0,"limit":100},"timingprofile":["100.00% 2.826 1 Template:Small_caps","100.00% 2.826 1 -total"]},"cachereport":{"timestamp":"20250223203504","ttl":86400,"transientcontent":false}}});});</script><script>(window.RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgBackendResponseTime":428});});</script></body></html>