Question: Flaw in my understanding of for loops

I am pretty certain that the problem here is simple, but only in the sense that what is counter intuitive to me is intuitive to most.
The final line as i have indicated ought to be a sequence of 1's, which should be evident upon inspection  of the code within the "for loop". But as you can see, it always has an additional count which is going to be an issue if I elaborate on this basis to further investigate. 

Can someone please explain to me why this occurs? I intented for a boolean as can be seen, only two outcomes, either the tally represented by the variable TRUE is incremented by 1, or the tally represented by the variable FALSE is incremented by 1.

I'm hoping it is sleep deprivation and it is simply because  I am not paying attention, but it's hard to tell if I am or am not, i know it's very funny yes i am a strange breed of crazy

Help appreciated in advance.

 


 

restart

``

 

delta := proc (x, y) options operator, arrow; piecewise(x = y, 1, x <> y, 0) end proc

``

``

Identity1 := proc (alpha, beta, eta, lambda, n, N) options operator, arrow; sum((delta(n, k)-(eta+I*lambda)*delta(n, k+1))*floor((alpha+I*beta)*(eta+I*lambda)^(k-N)), k = 1 .. N) = floor((alpha+I*beta)*(eta+I*lambda)^(n-N))-(eta+I*lambda)*floor((alpha+I*beta)*(eta+I*lambda)^(n-N-1))-delta(n, N+1)*(alpha+I*beta)*(eta+I*lambda) end proc:

``

``

R := {}:

Card := 0:

while Card < 10 do TOTAL := 1000; TRUE := 0; FALSE := 0; for w from 0 to TOTAL do A := (rand(-100 .. 100))()/(rand(1 .. 100))(); B := (rand(-100 .. 100))()/(rand(1 .. 100))(); C := (rand(-100 .. 100))()/(rand(1 .. 100))(); F := (rand(-100 .. 100))()/(rand(1 .. 100))(); N := 100; if is(Identity1(A, B, C, F, w, N)) = true then TRUE := TRUE+1 else FALSE := FALSE+1 end if end do; result := [TRUE/TOTAL, FALSE/TOTAL]; R := `union`(R, {result}); Card := Card+1 end do:

{[71/500, 859/1000]}

(1)

R

{[3/20, 851/1000], [7/50, 861/1000], [29/200, 107/125], [69/500, 863/1000], [141/1000, 43/50], [147/1000, 427/500], [149/1000, 213/250]}

(2)

seq(R[k][1]+R[k][2], k = 1 .. nops(R))

1001/1000, 1001/1000, 1001/1000, 1001/1000, 1001/1000, 1001/1000, 1001/1000

(3)

NULL


 

Download MAPLE_Q_29_09_2019.mw

Please Wait...