Deadstar

192 Reputation

6 Badges

11 years, 40 days

MaplePrimes Activity


These are answers submitted by Deadstar

Ok despite my realization I'm still unsure as to how to plot it, would I have to make a sequence of points and plot it like that or is there a command within plot() I can use..?

 

I.e. plot(F(x, 10), x=-0.5..0.5) doesn't work...

Oh lord I was right, my proc should have ended in T[lim] not T[n].

 

 

...

 

Cool thanks guys. I finally got it to work by just putting the text file in the Maple folder in program files (as in the folder it creates when you first install it).
Thanks for the answers guys. Joes method is something I just started doing yesterday although I didn't think it was a very efficient way... Perhaps it's fine enough though. Another way would be to perhaps sort them, convert them to a decimal number than see if they equal zero when one is subtracted from another..?

Some further things I've though of...

 

Using the binary method I mentioned at the bottom of my first post... We can narrow this down to the fact that any point must have an equal number of 0s and 1s.

 

Now if we consider i from out loop...

 

These are the same binary expression except they are missing the first n/4 0s. As in, the i value for n=16 is 2049 with binary expression 100000000001. But 2049/65535 = 0000100000000001...(repeating).

 

So we can perhaps narrow this down further to check the binary expression of S[1] and see if it has n/2 1s and n/4 0s. I don't know if this will speed things up though perhaps convert will slow things down too much...

Ok I'll post what I've done so far. I've made the mods you suggested however it has now slowed up my code so clearly I'm using extra steps somewhere (or perhaps it's the ceil function that does it..?)

 

A := proc(n)
local K,S,Q,i,j,m,q,count;
K := NULL:
S := Array(1..n):
for i from (2^n)/(2*n) + 1 to (2^n)/n - 1 by 2 do
Q := Array(1..n):
S[1] := i/(2^n - 1);
  Q[1] := 1:
  for j to n-1 do
    if S[j]<=1/2 then
      S[j+1]:=2*S[j];
    else
      S[j+1] := 2*S[j]-1:
    end if;


      m := ceil((n*S[j+1])):
        if Q[m]=0 then
          Q[m] := 1:
        else
          break:
        end if:
      end do:
    count := 0:
    for q to n do
      if Q[q]=0 then
        count := 1:
        break:
      end if:
    end do:
  if count=0 then
    K := K, S[1]
  end if:
end do:


K := [K]:        
end proc:
d1:d2:d3:gc():

 

I think perhaps it's not breaking fully out of the loop I want it to and just keeps running. I'm not entirely sure...

 

m := ceil(n*S[k+1]) is the only way I can think of 'classifying' the point into an interval, perhaps there is a more obvious way...

Great thanks very much for that!

 

I'll use your code for now and try to modify it so it doesn't need sort or the checking loop.

 

As for your questions, 3/15 (=1/5 which is the result given), is only supposed to appear for n=4. In general, the 'initial' (by initial, I mean point in the first interval) will be of the form k/(2^n - 1) where I'm almost certain k will be odd.

 

"But I'm curious, why were the two inequalities in the "check" on S[k] both strict"

 

By strict so you mean <= instead of just <?

 

I suppose it won't actually matter since no point tested will be at one of the interval endpoints but yes < and > could be used instead.

I have two additional questions though.

What do the d1,d2 and d3 stand for here... 

d1:d2:d3:gc():

I know g() is garbage collection but I'm unsure as to what the other terms do.

Finally, is this a situation where compile might be useful? I've never really used it before except when another
member here gave me a code with compile in it but it seems to speed things up massively.

No it would miss 555777 I think or anything like that...

It was the best I could do and I figured the possibility of two 3-digit sequences back to back would be so small it wouldn't matter within a 10000 digit limit.

 

Just used Robert Israels code, works very fast and comes out with an answer of 89.

My code gives an answer of 79. Which one (if any) is right? I would assume Roberts however I don't fully understand his code so I don't even know if it's the answer to the question! Although it seems to be...

 

 

Ok I had a play around with that and could not get it to work. I would have to copy and paste all 10000 digits of pi into the code and even then it finds every string possible.

Thank you that worked great!

Thanks very much!

Also gives me a basis to create my own ones.

Nevermind its fixed now.

Hmm that eats through memory and wont allow combining more than a few 1 million value arrays as it says object too large. I think that my loop thing, while looking long and odd, actually does the job quite well. Doesnt chew through much memory really and fills the whole array.

Saying that I'm still confused about why my second point about the 75%  point isnt working...

Ah grim its done that <p> thing... Hopefully this will work

Is there a way to combine Arrays, like 5 Arrays called a,b,c,d,e into a single Array? a,b,c,d and e are all the same size.
Ive been using.

z is the size of the arrays.


A := Array(...) (whatever size I need)

for k to z do

A[k] := a[k]

end do:
 

for k to z do

A[k+z] := b[k]

end do:

 

for k to z do

A[k+(2*z)] := c[k]

end do:

 

for k to z do

A[k+(3*z)] := d[k]

end do:

 

for k to z do

A[k+(4*z)] := e[k]

end do:



But this seems to do some weird things that maybe someone could also help me with.
I'm combining 50 Arrays of size 1 million into one Array of size 50 million.
Each individual Array has been sorted and the upper 25% point (a[750000]) is (for example in one case), 0.0679. Which differs by a max of maybe 0.001 or so for all 50 Arrays.
However when they have been combined into the one larger Array using the code above, the upper 25% point of the (sorted) large Array is something like 0.19. Which seems odd since I should be expecting a value similar to 0.0679.
If you cant figure out what I'm rambling about then consider the numbers 1-10. The upper 30% (7th) number is 7. If you repeat this list 10 times, combine them then arrange them in ascending order the upper 30% number will still be 7.

Cheers guys.
I found the with(RandomTools[MersenneTwister]) thing from the randomize part and now its working great.

1 2 Page 1 of 2