11 February 2013 04:41:48 PM BRENT_PRB C++ version Test the BRENT library. TEST_ZERO_ALL Test the Brent ZERO routine, which seeks a root of a function F(X) in an interval [A,B]. f_01(x) = sin ( x ) - x / 2 A Z B F(A) F(Z) F(B) 1 1.89549 2 0.341471 0 -0.0907026 f_02(x) = 2 * x - exp ( - x ) A Z B F(A) F(Z) F(B) 0 0.351734 1 -1 0 1.63212 f_03(x) = x * exp ( - x ) A Z B F(A) F(Z) F(B) -1 2.67518e-24 0.5 -2.71828 2.67518e-24 0.303265 f_04(x) = exp ( x ) - 1 / ( 100 * x * x ) A Z B F(A) F(Z) F(B) 0.0001 0.0953446 20 -999999 -2.22045e-16 4.85165e+08 f_05(x) = (x+3) * (x-1) * (x-1) A Z B F(A) F(Z) F(B) -5 -3 2 -72 0 5 TEST_ZERO_RC_ALL Test the ZERO_RC routine, which seeks a root of a function F(X) in an interval [A,B]. f_01(x) = sin ( x ) - x / 2 STATUS X F(X) 1 1 0.341471 2 2 -0.0907026 3 1.79012 0.0809815 4 1.88912 0.00520096 5 1.89555 -4.26626e-05 6 1.89549 1.58013e-07 7 1.89549 4.76186e-12 8 1.89549 0 0 1.89549 0 f_02(x) = 2 * x - exp ( - x ) STATUS X F(X) 1 0 -1 2 1 1.63212 3 0.379922 0.0759287 4 0.353111 0.00372163 5 0.351734 2.82665e-07 6 0.351734 1.02618e-12 7 0.351734 0 0 0.351734 0 f_03(x) = x * exp ( - x ) STATUS X F(X) 1 -1 -2.71828 2 0.5 0.303265 3 0.349449 0.246388 4 -0.248528 -0.318647 5 0.088696 0.0811678 6 -0.013398 -0.0135787 7 0.00123372 0.0012322 8 1.64292e-05 1.64289e-05 9 -4.03522e-10 -4.03522e-10 10 6.62958e-15 6.62958e-15 11 2.67518e-24 2.67518e-24 12 -2.22045e-16 -2.22045e-16 0 2.67518e-24 2.67518e-24 f_04(x) = exp ( x ) - 1 / ( 100 * x * x ) STATUS X F(X) 1 0.0001 -999999 2 20 4.85165e+08 3 0.041238 -4.83826 4 0.0412382 -4.83821 5 0.0581414 -1.89835 6 10.0291 22676.2 7 0.058976 -1.81432 8 0.0769971 -0.606711 9 5.05303 156.496 10 0.096214 0.0207459 11 0.0955786 0.00563656 12 0.0953437 -2.10642e-05 13 0.0953446 7.39127e-08 14 0.0953446 9.6545e-13 15 0.0953446 -2.22045e-16 16 0.0953446 6.43929e-15 0 0.0953446 -2.22045e-16 f_05(x) = (x+3) * (x-1) * (x-1) STATUS X F(X) 1 -5 -72 2 2 5 3 1.54545 1.35237 4 1.38004 0.632604 5 1.23631 0.236562 6 -1.88185 9.28631 7 -3.44092 -8.69579 8 -2.68698 4.2551 9 -2.9347 1.01104 10 -3.00386 -0.061806 11 -2.99987 0.00206145 12 -3 3.9686e-06 13 -3 -8.59757e-13 14 -3 0 0 -3 0 TEST_LOCAL_MIN_ALL Test the Brent LOCAL_MIN routine, which seeks a local minimizer of a function F(X) in an interval [A,B]. g_01(x) = ( x - 2 ) * ( x - 2 ) + 1 A X B F(A) F(X) F(B) 0 2 3.14159 5 1 2.30323 g_02(x) = x * x + exp ( - x ) A X B F(A) F(X) F(B) 0 0.351734 1 1 0.827184 1.36788 g_03(x) = x^4 + 2x^2 + x + 3 A X B F(A) F(X) F(B) -2 -0.236733 2 25 2.87849 29 g_04(x) = exp ( x ) + 1 / ( 100 x ) A X B F(A) F(X) F(B) 0.0001 0.0953446 1 101 1.20492 2.72828 g_05(x) = exp ( x ) - 2x + 1/(100x) - 1/(1000000x^2) A X B F(A) F(X) F(B) 0.0002 0.703205 2 25.9998 0.628026 3.39406 TEST_LOCAL_MIN_RC_ALL Test the reverse communication version of the Brent LOCAL_MIN routine, which seeks a local minimizer of a function F(X) in an interval [A,B]. g_01(x) = ( x - 2 ) * ( x - 2 ) + 1 Step X F(X) 0 0 5 0 3.141592653589793 2.303233786730186 1 1.199981614864327 1.640029416555091 2 1.941611038725466 1.003409270798719 3 2.399963229728653 1.159970585134975 4 2 1 5 2.000000029802322 1.000000000000001 6 1.999999970197678 1.000000000000001 7 1.999999970197678 1.000000000000001 g_02(x) = x * x + exp ( - x ) Step X F(X) 0 0 1 0 1 1.367879441171442 1 0.3819660112501051 0.8284162845035989 2 0.6180339887498948 0.9209690939741497 3 0.2360679774997897 0.8454550784427712 4 0.3528496811495104 0.8271857093986708 5 0.3518917166104074 0.8271840598740323 6 0.3517320418182495 0.8271840261312916 7 0.3517337036958197 0.8271840261275244 8 0.3517337112615478 0.8271840261275243 9 0.3517337165027886 0.8271840261275244 10 0.3517337165027886 0.8271840261275244 g_03(x) = x^4 + 2x^2 + x + 3 Step X F(X) 0 -2 25 0 2 29 1 -0.4721359549995796 3.02337868524942 2 0.4721359549995792 3.967650595248578 3 -1.055728090000841 5.415643516089551 4 -0.1498138939889126 2.895578253916099 5 -0.2226817817160358 2.878951458114974 6 -0.2318072413850192 2.878549359863836 7 -0.237056101926344 2.878493033943844 8 -0.2367455245027443 2.878492790245848 9 -0.2367325704732761 2.878492789873986 10 -0.2367329046684402 2.878492789873726 11 -0.2367329011408449 2.878492789873726 12 -0.2367328976132497 2.878492789873726 13 -0.2367327726568989 2.878492789873766 14 -0.2367328498841708 2.878492789873733 15 -0.2367328793823638 2.878492789873727 16 -0.236732890649671 2.878492789873726 17 -0.236732890649671 2.878492789873726 g_04(x) = exp ( x ) + 1 / ( 100 x ) Step X F(X) 0 0.0001 101.0001000050002 0 1 2.728281828459045 1 0.3820278146489801 1.491428944564399 2 0.6180721853510198 1.871527165190991 3 0.2361443707020397 1.308704097842649 4 0.1459834439469404 1.225677948134214 5 0.09026092675509928 1.205249730835979 6 0.06987608932080662 1.215485764492621 7 0.1020637327872526 1.205432046585031 8 0.09568202682193082 1.20492194401373 9 0.09551304332896546 1.204920914847202 10 0.09535723006160622 1.20492057445533 11 0.09534430133398021 1.204920572533846 12 0.09534460687029817 1.204920572532641 13 0.09534461723542657 1.20492057253264 14 0.09534461865617216 1.20492057253264 15 0.09534462007691777 1.20492057253264 16 0.09534462007691777 1.20492057253264 g_05(x) = exp ( x ) - 2x + 1/(100x) - 1/(1000000x^2) Step X F(X) 0 0.0002 25.99980002000133 0 2 3.39405584893065 1 0.7640556292979601 0.6319409659880333 2 1.23614437070204 0.9781158267720461 3 0.4722887414040793 0.680251882055913 4 0.6885274466075678 0.6282485878721349 5 0.7016460077946312 0.628028243845387 6 0.7030662791367996 0.6280257405372534 7 0.703208406706925 0.6280257206060759 8 0.7032048702467216 0.6280257205928642 9 0.7032048403471922 0.628025720592863 10 0.7032048298686234 0.628025720592863 11 0.7032048193900549 0.6280257205928637 12 0.7032048193900549 0.6280257205928637 TEST_GLOMIN_ALL Test the Brent GLOMIN routine, which seeks a global minimizer of a function F(X) in an interval [A,B], given some upper bound M for the second derivative of F. h_01(x) = 2 - x, M = 0 A X B F(A) F(X) F(B) 7 9 9 -5 -7 -7 h_01(x) = 2 - x, M = 100 A X B F(A) F(X) F(B) 7 9 9 -5 -7 -7 h_02(x) = x * x, M = 2 A X B F(A) F(X) F(B) -1 0 2 1 0 4 h_02(x) = x * x, M = 2.1 A X B F(A) F(X) F(B) -1 0 2 1 0 4 h_03(x) = x^3 + x^2, M = 14 A X B F(A) F(X) F(B) -0.5 3.05218e-09 2 0.125 9.31583e-18 12 h_03(x) = x^3 + x^2, M = 28 A X B F(A) F(X) F(B) -0.5 6.22262e-09 2 0.125 3.8721e-17 12 h_04(x) = ( x + sin(x) ) * exp(-x*x), M = 72 A X B F(A) F(X) F(B) -10 -0.679579 10 -3.5177e-43 -0.824239 3.5177e-43 h_05(x) = ( x - sin(x) ) * exp(-x*x), M = 72 A X B F(A) F(X) F(B) -10 -1.19514 10 -3.92246e-43 -0.0634905 3.92246e-43 BRENT_PRB Normal end of execution. 11 February 2013 04:41:48 PM