Google
 
Web unafbapune.blogspot.com

Saturday, September 08, 2012

 

PS1 P9: I == P^k in Octave

(This problem is an investigation on a computer.)






== Solution ==

I am sure there exists better solutions.  Anyhow, here is one solved via Python and Octave:

First I generated the 120 permutations via Python, and save the result to a file, permute_5.txt
import itertools for i in itertools.permutations([1,2,3,4,5]): print ' '.join(map(str, i))
Next is the Octave code to find the answers based on the permutation file. I know the max value of k is 6 via experimentation.
[a b c d e] = textread('permute_5.txt','%d %d %d %d %d'); I = eye(5); distinct_ks=[0 0 0 0 0 0]; for i = 1:size(a)(1) p=[a(i) b(i) c(i) d(i) e(i)]; P=I(:,p); k=1; while (!all(all(I == P^k))) k = k + 1; endwhile if distinct_ks(k) k p endif distinct_ks(k) = distinct_ks(k) + 1; endfor distinct_ks
Here is a summary of the interesting results:
P^1 == I when p = [1 2 3 4 5] P^2 == I when p = [1 2 3 5 4] P^3 == I when p = [1 2 4 5 3] P^4 == I when p = [1 3 4 5 2] P^5 == I when p = [2 3 4 5 1] P^6 == I when p = [2 1 4 5 3]
Distributions:
k : 1 2 3 4 5 6 P^k == I: 1 25 20 30 24 20

Comments:
What course is this? Looks interesting...
 
http://web.mit.edu/18.06/www
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?