P-Adic numbers, basic: Difference between revisions

changed the intro and a few examples.
(Added Wren)
(changed the intro and a few examples.)
Line 17:
If we convert a natural number, the familiar p-ary expansion is obtained:
10 decimal is 1010 both binary and 2-adic. To convert a rational number a/b
we perform p-adic long division modulo powers of p. If p is actually prime, this is always possible
this is always possible if first the 'p-part' is removed from b (and the p-adic point shifted accordingly).
The inverse of b modulo p is then used in the conversion.
(and the p-adic point moved to the left accordingly). The inverse of
b modulo p is then used in the conversion.
 
'''Recipe:''' at each step the most significant digit of the partial remainder
(initially a) is zeroed by subtracting a proper multiple of the divisor b.
Shift out the zero digit (divide by p) and repeat until the remainder is zero
or the precision limit is reached. NoteBecause thatp-adic thedivision 'properstarts multiplier'from isthe alwaysright,
the 'proper multiplier' is simply
d = partial remainder * 1/b (mod p).
The d's are the successive p-adic digits to find.
 
p-Adic additionAddition proceeds as usual, with carry from the right to the leftmost term,
where it has least magnitude and just drops off. We can work with approximate rationals
and obtain exact results. The routine for rational reconstruction demonstrates this:
Line 315:
cls
 
'rational reconstruction limits
'aredepends relative toon the precision: -
'until the dsum-loop overflows.
data 2,1, 2,4
data 1,1
Line 329 ⟶ 330:
data 4,9, 5,4
data 8,9
 
data -7,5, 7,4
data 99,70
 
data 26,25, 5,4
Line 345 ⟶ 343:
data -101,384
 
'threetwo 'decadic' pairs
data 6,7, 10,7
data -5,7
 
data 2,7, 10,7
data -31,7
 
data 34,21, 10,9
Line 359 ⟶ 354:
data 679001,207
 
data 11-8,49, 323,279
data 679001302113,20792
 
data 11,4, 11,13
data 679001,207
 
data -22,7, 2,37
data 46071,379
 
data -22,7, 3,23
data 46071,379
 
data -22,7, 732749,133
data 46071,379
 
data -10135,10961, 25,4020
data 5833769400,6649109
 
data -101,109, 61,7
data 583376,6649
 
data -10125,10926, 327497,313
data 5833765571,6649137
 
data 1,4, 7,11
data 9263,2837
 
data 122,407, 7,11
data -517,1477
 
'more subtle
data 5,8, 7,11
data 353,30809
 
data 0,0, 0,0
Line 447 ⟶ 446:
3 1 3 3
4/3
 
 
-7/5 + O(7^4)
2 5 4 0
99/70 + O(7^4)
0 5 0. 5
+ =
6 2 0. 5
1/70
 
 
Line 494 ⟶ 484:
 
 
62/7 + O(10^7)
5 7 1 4 2 8 5 86
-51/7 + O(10^7)
5 7 1 4 2 8 5 7
+ =
2 8 5 7 1 4 3
1/7
 
 
2/7 + O(10^7)
5 7 1 4 2 8 6
-3/7 + O(10^7)
1 4 2 8 5 7 1
+ =
7 1 4 2 8 5 7
-1/7
 
 
Line 530 ⟶ 511:
 
 
11-8/49 + O(323^279)
2 12 17 20 10 5 2 12 17
2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 1 2
679001302113/20792 + O(323^279)
5 17 5 17 6 0 10 12. 2
1 1 0 2 2 0 1 2 2 1 2 1 1 0 2 2 1 0 1 1 0 0 2 2 2. 0 1
+ =
18 12 3 4 11 3 0 6. 2
0 2 0 0 1 1 1 0 1 2 1 2 0 1 2 0 0 1 0 1 2 1 2 1 1. 0 1
2718281/828
 
 
11/4 + O(11^13)
8 2 8 2 8 2 8 2 8 2 8 3 0
679001/207 + O(11^13)
8 7 9 5 6 10 6 3 6 4 2 10 9
+ =
5 10 6 8 4 2 3 6 3 7 0 2 9
2718281/828
 
 
-22/7 + O(2^37)
1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0
46071/379 + O(2^37)
1 1 1 1 1 1 0 1 0 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 1 1 0 0 0 1 0 1 1 0 1 0 1
+ =
1 0 0 0 1 1 1 1 1 0 0 1 0 1 0 1 0 1 1 1 1 0 0 0 0 1 0 1 0 1 1 1 1 1 0 1 1
314159/2653
 
 
Line 566 ⟶ 529:
 
 
-22/7 + O(732749^133)
28070 18713 23389
6 6 6 6 6 6 6 6 6 6 6 3. 6
46071/379 + O(732749^133)
4493 8727 10145
6 4 1 6 6 5 1 2 2 1 3 2 4
+ =
32563 27441 785
4 1 6 6 5 1 2 2 1 3 2 0. 6
314159/2653
 
 
-101 35/10961 + O(25^4020)
02 13 12 1 1 1 13 0 12 1 04 1 03 0 1 13 0 1 1 0 04 0 02 0 02 1 02 0 12 0 1 1 0 0 1 0 0 1 1 1
5833769400/6649109 + O(25^4020)
1 03 1 04 04 1 02 13 14 14 03 0 0 0 0 0 04 1 0 1 0 0 03 1 0 1 0 1 0 0 0 1 0 1 0 1 02 04 0 0
+ =
0 0 1 0 02 12 02 0 1 0 03 1 0 03 1 14 12 0 13 13 03 0 04 1 12 0 0 1 1 1 0 0 0 1 1 1 0 1 1 1
577215/6649
 
Line 593 ⟶ 556:
 
 
-10125/10926 + O(327497^313)
2 6 5 0 5 4 4 0 1 6 1 2 2
5107 21031 15322
5833765571/6649137 + O(327497^313)
3 2 4 1 4 5 4 2 2 5 5 3 5
5452 13766 16445
+ =
6 2 2 2 3 3 1 2 4 4 6 6 0
10560 2048 31767
141421/3562
577215/6649
 
 
1/4 + O(7^11)
1 5 1 5 1 5 1 5 1 5 2
9263/2837 + O(7^11)
6 5 6 6 0 3 2 0 4 4 1
+ =
1 4 1 4 2 1 3 5 6 2 3
39889/11348
 
 
122/407 + O(7^11)
6 2 0 3 0 6 2 4 4 4 3
-517/1477 + O(7^11)
1 2 3 4 3 5 4 6 4 1. 1
+ =
3 2 6 5 3 1 2 4 1 4. 1
-27584/90671
 
 
5/8 + O(7^11)
4 2 4 2 4 2 4 2 4 2 5
353/30809 + O(7^11)
2 3 6 6 3 6 4 3 4 5 5
+ =
6 6 4 2 1 2 1 6 2 1 3
47099/10977
 
</pre>