P-Adic numbers, basic: Difference between revisions

m
no edit summary
(Conversion and addition of p-adic Numbers.)
 
mNo edit summary
Line 8:
Convert two rationals to p-adic numbers and add them up.
Rational reconstruction is needed to interpret the result.
 
 
p-Adic numbers were introduced around 1900 by Hensel. p-Adic expansions
Line 187 ⟶ 186:
'Horner's rule
function padic.dsum () as long
dim i as integer i, t = min(v, 0)
dim as long r, s = 0
dim i as integer
 
for i = k - 1 + vt to vt step -1
r = s: s *= p
if r andalso s \ r - p then
Line 238 ⟶ 237:
 
else
'p-correction
for i = 1 to v
x *= p: next
'negative powers
for i = v to -1
Line 337 ⟶ 333:
data 99,70
 
data 2726,925, 35,84
data 20-109,17125
 
data -349,2, 37,106
data 243-4851,1662
 
data 25-9,265, 53,118
data -12627,1257
 
data -22,7, 2,20
data 355,113
 
data 5,19, 2,12
Line 465 ⟶ 458:
 
 
2726/925 + O(35^84)
0 0 0 0 01. 0 1 0
20-109/17125 + O(35^84)
0 1 1 24. 0 2 23 1
+ =
0 1 1 2 1 0 0 1
71/17
 
 
-3/2 + O(3^10)
1 1 1 1 1 1 1 1 1 0
243/166 + O(3^10)
1 2 0 2 1 0 0 0 0 0
+ =
0. 0 2 0 24 1 1 1 1 0
21/125
-3/83
 
 
2549/262 + O(57^116)
03 43 4 0 03 4 4 0 1 0 0
-1264851/1252 + O(57^116)
43 42 4 4 4 4 43 3. 4 40 40
+ =
6 6 0 0 4 4 0 0 4 3. 4 4 4
-2401
-151/3250
 
 
-229/75 + O(23^208)
02 1 0 0 1 0 02 1 0 0 1 0 0 1 0 0 0 1 1 0
35527/1137 + O(23^208)
1 1 0 0 0 0 02 0 1 0 0 1 0 0 0 1 0 0 1 1
+ =
0 0 0 0 1 0 0 1 1 0 1 1 0 1 0 1 1 0 0 1
72/35
-1/791