forked from Psychedelic-Geometry/OEIS-Mathematica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
293 lines (210 loc) · 8.22 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# Mathematica OEIS Package
When you go on computing: if you are doing repetitive and boring things, is
because you are not working in a proper way. So I decided to write some code to
help myself with the worst part of my projects. And as this code began to grow
and became more complex, thought it would be good idea to gather all together
in the same Mathematica Package and to share it on the internet.
This code includes functions that can make your life easier if you a using the
information from OEIS in your archives: for citation in documents or blogs,
for programming sequences, or for many other purposes.
* Author: Enrique Pérez Herrero
* Date: 24/Nov/2015
* Project Pages: http://psychedelic-geometry.github.io/OEIS-Mathematica
* Licence: GNU GENERAL PUBLIC LICENSE v3.0
* Blog: http://psychedelic-geometry.blogspot.com/
## Package Description:
**Version**:
* V 1.0, 26 August 2010, Testing...
* V 2.0, 28 November 2010, Old links are no longer valid.
**Changes**:
* 29/Aug/2010 - Added `OEISbFile` function and exporting to HTML
* 28/Nov/2010 - Code rebuilt due to changes in OEIS, old links are no longer valid.
* 04/Jun/2011 - Fixed Unicode LF, instead of Window's CRLF for bFiles.
* 25/Jan/2015 - Repository created at GitHub.
**Functions**
* `OEISTotalNumberOfSequences`
* `OEISValidateIDQ`
* `OEISImport`
* `OEISURL`
* `OEISFunction`
* `OEISExport`
* `OEISbFile`
## Download and Install OEIS.m
https://github.com/Psychedelic-Geometry/OEIS-Mathematica/archive/master.zip
* Loading Package into a Mathematica notebook:
```
<<OEIS`
```
## PROGRAMMING EXAMPLES
### IMPORTING DATA FROM OEIS
#### Importing Sequence Description
```
In[1]:= OEISImport["A014321", "Description"]
Out[1]= The next new gap between successive odd primes (divided by 2).
```
#### Importing Sequence Data:
```
In[2]:= OEISImport["A080321", "Data"]
Out[2]= {{0,0},{1,4},{2,428},{3,58747},{4,1758473969},{5,340760636747},
{6,14410746502617904},{7,673020037180959760871},
{8,1736622037158911219053381734718},
{9,400539731185759177060380684246324}}
```
#### Importing Sequence creation date:
```
In[3]:= OEISImport["A117321","Date"]
Out[3]= {Mar,07,2006}
```
#### Importing Sequence Author:
```
In[4]:= OEISImport["A014321", "Author"]
Out[4]= {Hynek Mlcousek}
```
#### Importing Image:
```
In[5]:= OEISImport["A030337","Image"]
Out[5]=
[[File:Sample for A030337-Image sample.gif|border|200px]]
```
#### Importing bFile:
```
In[6]:=ListPlot[OEISImport["A094358","bFile"],Joined->True]
Out[6]= (Plot Image)
```
#### Importing Range of Available data:
```
In[7]:= OEISImport["A094358","MinData"]
Out[7]= 1
In[8]:= OEISImport["A094358","MaxData"]
Out[8]= 1314
```
### EXPORTING DATA FROM OEIS:
* Exporting Formats:
| File Extension | Exported data: |
|----------------------------------------------------------------- |---------------------------------------- |
| \*.gp | Code to add help for PARI/GP functions |
| \*.m | Code to add help for Mathematica |
| \*.txt, \*.xls, \*.csv, \*.tsv, \*.dat | Data files with sequence values. |
| \*.jpg, \*.jpeg, \*.jp2, \*.j2k, \*.bmp, \*.pgn, \*.gif, \*.tiff, \*.tif | Image plot |
| \*.bib | BibTeX citation to OEIS Sequences |
| \*.htm, \*.html | HTML citation to OEIS Sequences |
#### Exporting BibTeX citation:
The input for the function can be a String or a List of Strings:
```
In[1]:=OEISExport[{"A026588", "A111084"}, "example.bib"]
Out[1]=example.bib
```
* Content of file: `example.bib`
```
@MISC{oeisA026588,
AUTHOR={},
TITLE={The {O}n-{L}ine {E}ncyclopedia of {I}nteger {S}equences},
HOWPUBLISHED={\href{http://oeis.org/A026588}{A026588}},
MONTH={},
YEAR={},
NOTE={Duplicate of A026572.}
}
@MISC{oeisA111084,
AUTHOR={N. J. A. Sloane},
TITLE={The {O}n-{L}ine {E}ncyclopedia of {I}nteger {S}equences},
HOWPUBLISHED={\href{http://oeis.org/A111084}{A111084}},
MONTH={Nov},
YEAR={2005},
NOTE={Where records occur in A111267.}
}
```
#### Exporting Help Code for PARI/GP:
```
In[2]:= OEISExport[{"A026588","A111084","A131473"},"code_for_PARIGP.gp"]
Out[2]= code_for_PARIGP.gp
```
* Content of file: `code_for_PARIGP.gp`
```
addhelp(A026588,"A026588: Duplicate of A026572.");
addhelp(A111084,"A111084: Where records occur in A111267.");
addhelp(A131473,"A131473: a(n)=n^6-n.");
```
#### Exporting Help Code for Mathematica:
```
In[3]:= OEISExport[{"A026588","A111084","A131473"},"code_for_Mathematica.m"]
Out[3]= code_for_Mathematica.m
```
* Content of file: `code_for_Mathematica.m`
```
A026588::usage="A026588[n]: Duplicate of A026572.";
A111084::usage="A111084[n]: Where records occur in A111267.";
A131473::usage="A131473[n]: a(n)=n^6-n.";
```
#### Exporting all available data
* Example with EXCEL:
```
In[4]:= OEISExport[{"A026588","A111084","A131473"},"data.xls"]
Out[4]= {A026588_data.xls,A111084_data.xls,A131473_data.xls}
```
#### Exporting citation to HTML code
```
In[5]:=OEISExport[{"A040414", "A050414", "A002323", "A026588"}, "test.html"]
Out[5]= test.html
```
* Content of file: `test.html`
```
<a name="oeisA040414">[1]-</a> N. J. A. Sloane, The On-Line Encyclopedia of Integer Sequences.
<a href=http://oeis.org/A040414">A040414</a>: Continued fraction for sqrt(435).<br/>
<a name="oeisA050414">[2]-</a> Jud McCranie, The On-Line Encyclopedia of Integer Sequences.
<a href=http://oeis.org/A050414">A050414</a>: Numbers n such that 2^n - 3 is prime.<br/>
<a name="oeisA002323">[3]-</a> N. J. A. Sloane, The On-Line Encyclopedia of Integer Sequences.
<a href=http://oeis.org/A002323">A002323</a>: Fermat remainders.<br/>
<a name="oeisA026588">[4]-</a> The On-Line Encyclopedia of Integer Sequences.
<a href=http://oeis.org/A026588">A026588</a>: Duplicate of A026572.<br/>
```
#### Exporting citation to Wiki code
```
In[6]:=OEISExport[{"A026518", "A111284"}, "example.wiki"]
Out[6]:=example.wiki
```
* Content of file: `example.wiki`
```
A026518: a(n) = length of n-th run of identical symbols in A026517.
A111284: Number of permutations avoiding the patterns {2143,2341,2413,2431,3142,3241,3412,3421,4123,4213,4231,4321,4132,4312};
number of strong sorting class based on 2143.
```
### FUNCTIONS CREATED AUTOMATICALLY:
Function: `OEISFunction[ID, Opts]`:
The options `Opts`, are `True` by default, and they can be modified as:
To skip the addition of help to the function:
`OEISFunction[ID,AddHelp->False]`
To skip the data from the bFile:
`OEISFunction[ID,bFile->False]`
To do not print on the screen the information outputed:
`OEISFunction[ID,Output->False]`
* Example of use:
```
In[5]:= OEISFunction["A094358"]
A094358(n): Squarefree products of factors of Fermat numbers (A023394).
Link-1: http://oeis.org/A094358
Link-2: http://oeis.org/b094358.txt
Help Added: True
Loaded data from bFile: True
Loaded data from Sequence: False
Data available: Table of n, A094358(n) for n=1..1314
```
From now on, we can use the function with all data already loaded on it:
```
In[6]:= A094358[1314]
Out[6]= 2917004348489729
```
### GENERATING b-Files:
Function: `OEISbFile[ID,Vmax,filename]`
* Example:
We can define the function first, but if we do not define it, the code creates
the function and preloads all available data from OEIS:
```
In[5]:=A040414[0]:=20;
A040414[n_]:=Part[{1,5,1,40},1+Mod[n-1,4}};
In[6]:=OEISbFile["A040414", 200]
Out[6]=b040414.txt
```
### Links:
* Todd Gayley, [1994 Mathematica Developer Conference, Wolfram Research, Inc., Tutorial](http://library.wolfram.com/infocenter/Conferences/184/ Mathematica Package Design)
* [OEIS Sequence Tools](http://oeis.org/wiki/Sequence_Tools)
* [GitHub Repository](https://github.com/Psychedelic-Geometry OEIS-Mathematica)