bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-apl] rational experimental feature: 'float' issue


From: Ala'a Mohammad
Subject: [Bug-apl] rational experimental feature: 'float' issue
Date: Mon, 14 Aug 2017 23:12:12 +0400

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]