Discussion:
[Bug-apl] rational experimental feature: 'float' issue
Ala'a Mohammad
2017-08-14 19:12:12 UTC
Permalink
Hi,

I was playing with the sum of the series 1/3, 1/9, 1/27 ..etc
(1÷3⋆⍳x), and found that If I'm using the rationals experimental
feature (⎕ps ← 1 0), then it the following were found:

1)

1÷3⋆⍳5
1÷3 1÷9 1÷27 1÷81 1÷243

+/1÷3⋆⍳39
2026277576509488133÷4052555153018976267

+/1÷3⋆⍳40
0.5

Shouldn't the above be 1÷2?

2) creating a table for the sums of the above series until 39

n,⍪{+/1÷3⋆⍳⍵}¨n←⍳39
1 1÷3
2 4÷9
3 13÷27
4 40÷81
5 121÷243
6 364÷729
7 1093÷2187
8 3280÷6561
9 9841÷19683
10 29524÷59049
11 88573÷177147
12 265720÷531441
13 797161÷1594323
14 2391484÷4782969
15 7174453÷14348907
16 21523360÷43046721
17 64570081÷129140163
18 193710244÷387420489
19 581130733÷1162261467
20 1743392200÷3486784401
21 5230176601÷10460353203
22 15690529804÷31381059609
23 47071589413÷94143178827
24 141214768240÷282429536481
25 423644304721÷847288609443
26 1270932914164÷2541865828329
27 3812798742493÷7625597484987
28 11438396227480÷22876792454961
29 34315188682441÷68630377364883
30 102945566047324÷205891132094649
31 308836698141973÷617673396283947
32 926510094425920÷1853020188851841
33 2779530283277761÷5559060566555523
34 8338590849833284÷16677181699666569
35 25015772549499853÷50031545098999707
36 75047317648499560÷150094635296999121
37 225141952945498681÷450283905890997363
38 675425858836496044÷1350851717672992089
39 2026277576509488133÷4052555153018976267

Is fine, but after 39 (when we starting getting 0.5, the numerators of
the above cases in the table have 'float' numerators, and the last 0.5
at the end of the table is float and written using the E notation.

n,⍪{+/1÷3⋆⍳⍵}¨n←⍳40
1 1.0÷3
2 4.0÷9
3 13.0÷27
4 40.0÷81
5 121.0÷243
6 364.0÷729
7 1093.0÷2187
8 3280.0÷6561
9 9841.0÷19683
10 29524.0÷59049
11 88573.0÷177147
12 265720.0÷531441
13 797161.0÷1594323
14 2391484.0÷4782969
15 7174453.0÷14348907
16 21523360.0÷43046721
17 64570081.0÷129140163
18 193710244.0÷387420489
19 581130733.0÷1162261467
20 1743392200.0÷3486784401
21 5230176601.0÷10460353203
22 15690529804.0÷31381059609
23 47071589413.0÷94143178827
24 141214768240.0÷282429536481
25 423644304721.0÷847288609443
26 1270932914164.0÷2541865828329
27 3812798742493.0÷7625597484987
28 11438396227480.0÷22876792454961
29 34315188682441.0÷68630377364883
30 102945566047324.0÷205891132094649
31 308836698141973.0÷617673396283947
32 926510094425920.0÷1853020188851841
33 2779530283277761.0÷5559060566555523
34 8338590849833284.0÷16677181699666569
35 25015772549499853.0÷50031545098999707
36 75047317648499560.0÷150094635296999121
37 225141952945498681.0÷450283905890997363
38 675425858836496044.0÷1350851717672992089
39 2026277576509488133.0÷4052555153018976267
40 0.5E0

I tried to replicate it using another simpler example below:

⎕←x←0.5, 1÷1 2 3
0.5 1 1÷2 1÷3

x,x
0.5 1 1÷2 1÷3 0.5 1 1÷2 1÷3

x,[.5]x
0.5 1 1÷2 1÷3
0.5 1 1÷2 1÷3

x,⍪x
0.5E0 0.5E0
1.0E0 1.0E0
1.0÷2 1.0÷2
1.0÷3 1.0÷3

Notice that numerators are floats in the last example.

Hope this helps.

Regards,

Ala'a
Ala'a Mohammad
2017-08-14 20:09:48 UTC
Permalink
Adding other cases found

3⋆39
4052555153018976267
1÷3⋆39
1÷4052555153018976267
3⋆40
1.215766546E19
1÷3⋆40
8.22526334E¯20

Another example which does not have a large denumerator

(1÷3)×1÷3
1÷9
(1÷1)×1÷3
0.3333333333
1×1÷3
0.3333333333
2×1÷3
0.6666666667
3×1÷3
1
5×1÷3
1.666666667
6×1÷3
2
1×1÷2
0.5
2×1÷2
1


Regards,

Ala'a
Post by Ala'a Mohammad
Hi,
I was playing with the sum of the series 1/3, 1/9, 1/27 ..etc
(1÷3⋆⍳x), and found that If I'm using the rationals experimental
1)
1÷3⋆⍳5
1÷3 1÷9 1÷27 1÷81 1÷243
+/1÷3⋆⍳39
2026277576509488133÷4052555153018976267
+/1÷3⋆⍳40
0.5
Shouldn't the above be 1÷2?
2) creating a table for the sums of the above series until 39
n,⍪{+/1÷3⋆⍳⍵}¨n←⍳39
1 1÷3
2 4÷9
3 13÷27
4 40÷81
5 121÷243
6 364÷729
7 1093÷2187
8 3280÷6561
9 9841÷19683
10 29524÷59049
11 88573÷177147
12 265720÷531441
13 797161÷1594323
14 2391484÷4782969
15 7174453÷14348907
16 21523360÷43046721
17 64570081÷129140163
18 193710244÷387420489
19 581130733÷1162261467
20 1743392200÷3486784401
21 5230176601÷10460353203
22 15690529804÷31381059609
23 47071589413÷94143178827
24 141214768240÷282429536481
25 423644304721÷847288609443
26 1270932914164÷2541865828329
27 3812798742493÷7625597484987
28 11438396227480÷22876792454961
29 34315188682441÷68630377364883
30 102945566047324÷205891132094649
31 308836698141973÷617673396283947
32 926510094425920÷1853020188851841
33 2779530283277761÷5559060566555523
34 8338590849833284÷16677181699666569
35 25015772549499853÷50031545098999707
36 75047317648499560÷150094635296999121
37 225141952945498681÷450283905890997363
38 675425858836496044÷1350851717672992089
39 2026277576509488133÷4052555153018976267
Is fine, but after 39 (when we starting getting 0.5, the numerators of
the above cases in the table have 'float' numerators, and the last 0.5
at the end of the table is float and written using the E notation.
n,⍪{+/1÷3⋆⍳⍵}¨n←⍳40
1 1.0÷3
2 4.0÷9
3 13.0÷27
4 40.0÷81
5 121.0÷243
6 364.0÷729
7 1093.0÷2187
8 3280.0÷6561
9 9841.0÷19683
10 29524.0÷59049
11 88573.0÷177147
12 265720.0÷531441
13 797161.0÷1594323
14 2391484.0÷4782969
15 7174453.0÷14348907
16 21523360.0÷43046721
17 64570081.0÷129140163
18 193710244.0÷387420489
19 581130733.0÷1162261467
20 1743392200.0÷3486784401
21 5230176601.0÷10460353203
22 15690529804.0÷31381059609
23 47071589413.0÷94143178827
24 141214768240.0÷282429536481
25 423644304721.0÷847288609443
26 1270932914164.0÷2541865828329
27 3812798742493.0÷7625597484987
28 11438396227480.0÷22876792454961
29 34315188682441.0÷68630377364883
30 102945566047324.0÷205891132094649
31 308836698141973.0÷617673396283947
32 926510094425920.0÷1853020188851841
33 2779530283277761.0÷5559060566555523
34 8338590849833284.0÷16677181699666569
35 25015772549499853.0÷50031545098999707
36 75047317648499560.0÷150094635296999121
37 225141952945498681.0÷450283905890997363
38 675425858836496044.0÷1350851717672992089
39 2026277576509488133.0÷4052555153018976267
40 0.5E0
⎕←x←0.5, 1÷1 2 3
0.5 1 1÷2 1÷3
x,x
0.5 1 1÷2 1÷3 0.5 1 1÷2 1÷3
x,[.5]x
0.5 1 1÷2 1÷3
0.5 1 1÷2 1÷3
x,⍪x
0.5E0 0.5E0
1.0E0 1.0E0
1.0÷2 1.0÷2
1.0÷3 1.0÷3
Notice that numerators are floats in the last example.
Hope this helps.
Regards,
Ala'a
Juergen Sauermann
2017-08-14 20:28:49 UTC
Permalink
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font face="Helvetica, Arial, sans-serif">Hi Ala'a,<br>
<br>
not sure what the problem is. What you see is probably a less-than-obvious<br>
combination of APL2 formatting rules:<br>
<br>
1. when the numerator and/or the denominator becomes larger than
64 bit, then<br>
   the quotient is automatically converted to a float. This
creates the <b>0.5</b> below.<br>
<br>
2. table column alignment: If a table column has only non-rational
floats then they are<br>
 aligned at either their <b>E</b> (if<b> </b> exponential format
is required) or at their dot (if not).<br>
 Columns of quotients are aligned at their <b>÷</b>. Mixed
columns are aligned at either the <b>÷</b><br>
 or at the E. That's why the <b>÷</b> and the <b>E</b> below are
in the same column.<br>
<br>
3. if one item in a column requires exponential form then all
items have to use it.<br>
  The <b>÷</b> in quotients is considered the alignment point and
it causes the <b>E0</b> in the<br>
  <b>0.5E0</b> below. The <b>.5</b> in  </font><font
face="Helvetica, Arial, sans-serif"><font face="Helvetica, Arial,
sans-serif"><b>0.5E0</b> then causes the<b> .0</b> in the
numerator of quotients.<b><br>
<br>
</b></font>All this is a consequence of applying the existing
alignment rules to quotient.<br>
<br>
/// Jürgen<br>
<br>
<br>
</font>
<div class="moz-cite-prefix">On 08/14/2017 09:12 PM, Ala'a Mohammad
wrote:<br>
</div>
<blockquote
cite="mid:CAJ--6maz+***@mail.gmail.com"
type="cite">
<pre wrap="">Hi,

I was playing with the sum of the series 1/3, 1/9, 1/27 ..etc
(1÷3⋆⍳x), and found that If I'm using the rationals experimental
feature (⎕ps ← 1 0), then it the following were found:

1)

1÷3⋆⍳5
1÷3 1÷9 1÷27 1÷81 1÷243

+/1÷3⋆⍳39
2026277576509488133÷4052555153018976267

+/1÷3⋆⍳40
0.5

Shouldn't the above be 1÷2?

2) creating a table for the sums of the above series until 39

n,⍪{+/1÷3⋆⍳⍵}¨n←⍳39
1 1÷3
2 4÷9
3 13÷27
4 40÷81
5 121÷243
6 364÷729
7 1093÷2187
8 3280÷6561
9 9841÷19683
10 29524÷59049
11 88573÷177147
12 265720÷531441
13 797161÷1594323
14 2391484÷4782969
15 7174453÷14348907
16 21523360÷43046721
17 64570081÷129140163
18 193710244÷387420489
19 581130733÷1162261467
20 1743392200÷3486784401
21 5230176601÷10460353203
22 15690529804÷31381059609
23 47071589413÷94143178827
24 141214768240÷282429536481
25 423644304721÷847288609443
26 1270932914164÷2541865828329
27 3812798742493÷7625597484987
28 11438396227480÷22876792454961
29 34315188682441÷68630377364883
30 102945566047324÷205891132094649
31 308836698141973÷617673396283947
32 926510094425920÷1853020188851841
33 2779530283277761÷5559060566555523
34 8338590849833284÷16677181699666569
35 25015772549499853÷50031545098999707
36 75047317648499560÷150094635296999121
37 225141952945498681÷450283905890997363
38 675425858836496044÷1350851717672992089
39 2026277576509488133÷4052555153018976267

Is fine, but after 39 (when we starting getting 0.5, the numerators of
the above cases in the table have 'float' numerators, and the last 0.5
at the end of the table is float and written using the E notation.

n,⍪{+/1÷3⋆⍳⍵}¨n←⍳40
1 1.0÷3
2 4.0÷9
3 13.0÷27
4 40.0÷81
5 121.0÷243
6 364.0÷729
7 1093.0÷2187
8 3280.0÷6561
9 9841.0÷19683
10 29524.0÷59049
11 88573.0÷177147
12 265720.0÷531441
13 797161.0÷1594323
14 2391484.0÷4782969
15 7174453.0÷14348907
16 21523360.0÷43046721
17 64570081.0÷129140163
18 193710244.0÷387420489
19 581130733.0÷1162261467
20 1743392200.0÷3486784401
21 5230176601.0÷10460353203
22 15690529804.0÷31381059609
23 47071589413.0÷94143178827
24 141214768240.0÷282429536481
25 423644304721.0÷847288609443
26 1270932914164.0÷2541865828329
27 3812798742493.0÷7625597484987
28 11438396227480.0÷22876792454961
29 34315188682441.0÷68630377364883
30 102945566047324.0÷205891132094649
31 308836698141973.0÷617673396283947
32 926510094425920.0÷1853020188851841
33 2779530283277761.0÷5559060566555523
34 8338590849833284.0÷16677181699666569
35 25015772549499853.0÷50031545098999707
36 75047317648499560.0÷150094635296999121
37 225141952945498681.0÷450283905890997363
38 675425858836496044.0÷1350851717672992089
39 2026277576509488133.0÷4052555153018976267
40 0.5E0

I tried to replicate it using another simpler example below:

⎕←x←0.5, 1÷1 2 3
0.5 1 1÷2 1÷3

x,x
0.5 1 1÷2 1÷3 0.5 1 1÷2 1÷3

x,[.5]x
0.5 1 1÷2 1÷3
0.5 1 1÷2 1÷3

x,⍪x
0.5E0 0.5E0
1.0E0 1.0E0
1.0÷2 1.0÷2
1.0÷3 1.0÷3

Notice that numerators are floats in the last example.

Hope this helps.

Regards,

Ala'a


</pre>
</blockquote>
<br>
</body>
</html>

Loading...