def cycle_brent_test05 ( ) : #*****************************************************************************80 # ## CYCLE_BRENT_TEST05 tests CYCLE_BRENT for F5. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 13 May 2013 # # Author: # # John Burkardt # from f5 import f5 from cycle_brent import cycle_brent print print 'CYCLE_BRENT_TEST05' print ' Test CYCLE_BRENT for F5().' print ' f5(i) = mod ( 16383 * i + 1, 65536 ).' x0 = 1 print print ' Starting argument X0 = %d' % ( x0 ) [ lam, mu ] = cycle_brent ( f5, x0 ) print print ' Reported cycle length is %d' % ( lam ) print ' Expected value is 8' print print ' Reported distance to first cycle element is %d' % ( mu ) print ' Expected value is 0' i = 0 x0 = 1 print print ' %d %d' % ( i, x0 ) for i in range ( 1, 11 ): x0 = f5 ( x0 ) print ' %d %d' % ( i, x0 ) return
def cycle_brent_test01(): #*****************************************************************************80 # ## CYCLE_BRENT_TEST01 tests CYCLE_BRENT for a tiny example. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 13 May 2013 # # Author: # # John Burkardt # from cycle_brent import cycle_brent from f1 import f1 print print 'CYCLE_BRENT_TEST01' print ' Test CYCLE_BRENT on F1().' print ' f1(0) = 6.' print ' f1(1) = 6.' print ' f1(2) = 0.' print ' f1(3) = 1.' print ' f1(4) = 4.' print ' f1(5) = 3.' print ' f1(6) = 3.' print ' f1(7) = 4.' print ' f1(8) = 0.' x0 = 2 print print ' Starting argument X0 = %d' % (x0) [lam, mu] = cycle_brent(f1, x0) print print ' Reported cycle length is %d' % (lam) print ' Expected value is 3' print print ' Reported distance to first cycle element is %d' % (mu) print ' Expected value is 2' return
def cycle_brent_test01(): # *****************************************************************************80 # ## CYCLE_BRENT_TEST01 tests CYCLE_BRENT for a tiny example. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 13 May 2013 # # Author: # # John Burkardt # from cycle_brent import cycle_brent from f1 import f1 print print "CYCLE_BRENT_TEST01" print " Test CYCLE_BRENT on F1()." print " f1(0) = 6." print " f1(1) = 6." print " f1(2) = 0." print " f1(3) = 1." print " f1(4) = 4." print " f1(5) = 3." print " f1(6) = 3." print " f1(7) = 4." print " f1(8) = 0." x0 = 2 print print " Starting argument X0 = %d" % (x0) [lam, mu] = cycle_brent(f1, x0) print print " Reported cycle length is %d" % (lam) print " Expected value is 3" print print " Reported distance to first cycle element is %d" % (mu) print " Expected value is 2" return
def cycle_brent_test04 ( ) : #*****************************************************************************80 # ## CYCLE_BRENT_TEST04 tests CYCLE_BRENT for F4. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 13 May 2013 # # Author: # # John Burkardt # from f4 import f4 from cycle_brent import cycle_brent print print 'CYCLE_BRENT_TEST04' print ' Test CYCLE_BRENT for F4().' print ' f4(i) = mod ( 31421 * i + 6927, 65536 ).' x0 = 1 print print ' Starting argument X0 = %d' % ( x0 ) [ lam, mu ] = cycle_brent ( f4, x0 ) print print ' Reported cycle length is %d' % ( lam ) print ' Expected value is 65536' print print ' Reported distance to first cycle element is %d' % ( mu ) print ' Expected value is 0' return
def cycle_brent_test02 ( ) : #*****************************************************************************80 # ## CYCLE_BRENT_TEST02 tests CYCLE_BRENT for F2. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 13 May 2013 # # Author: # # John Burkardt # from f2 import f2 from cycle_brent import cycle_brent print print 'CYCLE_BRENT_TEST02' print ' Test CYCLE_BRENT for F2().' print ' f2(i) = mod ( 22 * i + 1, 72 ).' x0 = 0 print print ' Starting argument X0 = %d' % ( x0 ) [ lam, mu ] = cycle_brent ( f2, x0 ) print print ' Reported cycle length is %d' % ( lam ) print ' Expected value is 9' print print ' Reported distance to first cycle element is %d' % ( mu ) print ' Expected value is 3' return
def cycle_brent_test03 ( ) : #*****************************************************************************80 # ## CYCLE_BRENT_TEST03 tests CYCLE_BRENT for F3. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 13 May 2013 # # Author: # # John Burkardt # from cycle_brent import cycle_brent from f3 import f3 print print 'CYCLE_BRENT_TEST03' print ' Test CYCLE_BRENT for F3().' print ' f3(i) = mod ( 123 * i + 456, 100000 ).' x0 = 789 print print ' Starting argument X0 = %d' % ( x0 ) [ lam, mu ] = cycle_brent ( f3, x0 ) print print ' Reported cycle length is %d' % ( lam ) print ' Expected value is 50000' print print ' Reported distance to first cycle element is %d' % ( mu ) print ' Expected value is 0' return
def cycle_brent_test03(): #*****************************************************************************80 # ## CYCLE_BRENT_TEST03 tests CYCLE_BRENT for F3. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 13 May 2013 # # Author: # # John Burkardt # from cycle_brent import cycle_brent from f3 import f3 print print 'CYCLE_BRENT_TEST03' print ' Test CYCLE_BRENT for F3().' print ' f3(i) = mod ( 123 * i + 456, 100000 ).' x0 = 789 print print ' Starting argument X0 = %d' % (x0) [lam, mu] = cycle_brent(f3, x0) print print ' Reported cycle length is %d' % (lam) print ' Expected value is 50000' print print ' Reported distance to first cycle element is %d' % (mu) print ' Expected value is 0' return
def cycle_brent_test04(): #*****************************************************************************80 # ## CYCLE_BRENT_TEST04 tests CYCLE_BRENT for F4. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 13 May 2013 # # Author: # # John Burkardt # from f4 import f4 from cycle_brent import cycle_brent print print 'CYCLE_BRENT_TEST04' print ' Test CYCLE_BRENT for F4().' print ' f4(i) = mod ( 31421 * i + 6927, 65536 ).' x0 = 1 print print ' Starting argument X0 = %d' % (x0) [lam, mu] = cycle_brent(f4, x0) print print ' Reported cycle length is %d' % (lam) print ' Expected value is 65536' print print ' Reported distance to first cycle element is %d' % (mu) print ' Expected value is 0' return