• API
• FAQ
• Tools
• Trends
• Archive
daily pastebin goal
5%
SHARE
TWEET

# how to determine the period of a function

a guest Feb 27th, 2012 23 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. def functionA(origin_matrix,N_times):
2.    #apply rule on the origin_matrix to generate another matrix which is the next sate of it.
3.    #apply rule on origin_matrix for N_times
4.    return the_final_matrix
5.
6. def functionB(origin_matrix):
7.    #determine the period of the the origin_matrix.
8.    return period
9.
10. iterations = 0;
11. tmp = origin_matrix;
12.
13. do
14.     tmp = operation(tmp);
15.     iterations += 1;
16. while tmp != origin_matrix;
17.
18. return iterations;
19.
20. while True:
21.     tmp = operation(tmp)
22.     iterations += 1
23.
24.     if tmp == origin_matrix:
25.         break  # Or you could return here.
26.
27. matrix = origin_matrix
28.
29. for i in range(N_times):
30.     matrix = operation(matrix)
31.
32. return matrix
RAW Paste Data
Top