mathe
发表于 2020-5-31 12:06:32
推广到四个数可以要求
求在$x+y+z+w=0$时$(x/y)^2+(y/z)^2+(z/w)^2+(w/x)^2$的最小值
wayne
发表于 2020-6-2 23:39:36
偶数情况就不考虑了, 倒是可以作为数值非线性全局最优化算法的准确性的验证。{但应该还缺少一个证明,证明为啥是都取-1/1的时候全局最小},
随着个数的增加,对全局最优化的算法挑战也变大。要不要大家pk一下,打个擂台,看看谁的代码调的好,算的多算的准
mathe
发表于 2020-6-3 16:00:20
迭代计算
n=5:
s=5.5837424137607321737587108695119652893
n=7:
s=7.2429439431253376102344469504453164735
n=9:
[-398333547.03949660537981885453071446246, 379977187.57283816088904255835321159308, -337070142.84417324120690782864339925716, -318735337.39071680947089197467724429591, -322926341.87729084882997535115800870115, -354848570.12723339048904867130872738548, 434263641.68093597166620065496512291888, 467169763.00599415738949819361753890571, 450503347.01914260543190127338222068445]
s=9.1767206884756847786773243621684481839
n=11:
[-1599223178.0239534137959526258888563021, 1519907775.7671666196082558992988500912, -1367398926.6658597436679662209681453783, -1292083892.4155559784941624278150934174, -1285154243.5526473592264370293980533699, -1352992543.9243432653989697258551908615, 1524238153.9536080172465001574487855790, -1591983274.9528557257755615073043090670, 1800027151.3148877122764054286818845606, 1862261020.6565629748973990364723834962, 1782401957.8429901623304890153277446695]
s=11.130551383065715848548656261520702727
n=13:
[-604833506.59846018631949140076725692380, -590378945.61327031598924351410159325244, -596202620.75577996702960352931786148072, -624690994.26159621516634571440054165342, 682465978.49685379693466859018758256461, -712440186.18533759716089352657419623233, 779963167.24541426255761196402616090228, 810740373.37842436105272854166295634996, 802641827.95410368456176531367592583206, 760431126.32709248993376490436642401650, -693314345.46584989552146401626428009038, -654552648.06661362610786358572160931708, 640170773.54501920825436597322828928482]
s=13.081351595802460124520674307229984034
而n=13还可以有次优结果:
[-1412514727.2397332648302160068842839511, 1276644333.8115743477876127119279090617, -1211809366.0871994714831647695339190531, 1097851206.5663556169534950040446740704, 1037338577.7779693963357431831232185526, 1023519445.5673132444024804057218601072, 1058195114.0064073854796547109266918185, -1154048202.4798242078392812866154056375, 1187710215.4530476551387647049838205998, -1297623072.5259722223052252123729103648, 1328566131.5165358793528474598814179887, -1453920304.0713306379902791126902811766, -1479909352.2951437210024317925127920157]
s=13.109736927440767969109114269108661673
mathe
发表于 2020-6-3 16:04:26
算法很简单,先随机产生n个和为0的随机数$x_1,x_2,...,x_n$
然后依次挑选其中任意两个数$x_i, x_{i+1}$, 然后限定其它数都不变,求仅改变$x_i,x_{i+1}$情况下的最小值问题,这时要求限定条件两者之和为常数时的极值情况,对应取机制条件为一个7次方程,依次将方程7个解代入找到最小值情况。
仿佛迭代上面过程就可以收敛到一个不错的解。
wayne
发表于 2020-6-3 17:13:24
我的代码 有一部分的手工调参的过程。5和7的时候跟mathe的一样,之后的都比mathe的要好些,嘿嘿,先贴结果:
n=5的时候[等同于mathe在楼上贴出的5.5837424137607321737587108695119652893]::
{5.5837424137607321737587108695119652893919081384213,{f->1.0774915816252611015093454171487320315423587907721,f->-0.79707982464586797618833901245223296846916963478189,f->-0.69346823829996056491061216466765819739714481880392,f->-0.73893224788837763464989514401058586127422509002876,f->1.1519887292089450742395009039817449955981807528424}}
n=7的时候[等同于mathe在楼上贴出的7.2429439431253376102344469504453164735]::
{7.2429439431253376102344469504453164735238599972906,{f->1.0000000000000000000000000000000000000000000000000,f->-0.828849738224098355469939271886081951515338888037,f->-0.74673404415013914960661076172666833989974649116707,f->-0.73557118697707915982126609056357065994091604934711,f->-0.80635081158828060112893221736553912815519827988095,f->1.0285361064989210188156138252164780690963323208595,f->1.0889696744406762472111345163253820104148673875722}}
n=9的时候[优于mathe在楼上贴出的9.1767206884756847786773243621684481839]:
{9.1208835938805801963410199725647599711420989460098,{f->1.0000000000000000000000000000000000000000000000000,f->0.930740206278065169727878722614768732582068478621,f->-0.82130885143478080833013734600956493201676736245317,f->-0.75941909989461782471627497384130476496768405393861,f->-0.73633935236349721211808185563486105425924375810856,f->-0.75116066726416262783660468242271140263430250182076,f->-0.81183293532881364488491012222660861488130465873415,f->0.94193193905706388635947055866378568804168301792334,f->1.0073887609507430617986596988564963481355508385114}}
n=11的时候[优于mathe在楼上贴出的11.130551383065715848548656261520702727]:
{11.0681076691778873386044486618962711125899559599643068476885,{f->1.00000000000000000000000000000000000000000000000000000000000,f->1.0591079647066245571448582028357748512073505879395410639344,f->1.07655514133327716901095323093407555338507084854829059567090,f->1.05288850660187980210135568948437222267333817937289464469642,f->0.994280013163685428624838161017644721809755939953083019131955,f->-0.910290822148993589951480728067057691605423737742647491216290,f->-0.857308495551433440741403062929512690566358372155343282247626,f->-0.830494641418891092720346939039322268355117229693517788260689,f->-0.828119905995725776386219333675006922630104557827005576626012,f->-0.851408342076334153830990563899569534839248761361667935868589,f->-0.905209418614088903251564656661398241079262897033627249214475}}
n=13的时候[优于mathe在楼上贴出的13.081351595802460124520674307229984034]:
内点法给出的结果:
{13.041937521812376592163675384366442597497488571462,{f->1.0000000000000000000000000000000000000000000000000,f->0.998285819436214092906357513226775372465931212257,f->0.97415083639981177328608567343885794441296248062401,f->0.93061064699648867926715362115714003451626980517661,f->-0.87185599512201005221876890334105574262707876958601,f->-0.83184469110362413512234719903008557078503529566325,f->-0.80812069623983331068454037995713688192691376783600,f->-0.79947336058841925189129348801609782975079175394005,f->-0.80581260972087375624258254717035297637092550859083,f->-0.82822539959381550472982310521769437603471995829045,f->-0.86924714828958058285319710685492704141350078989848,f->0.93345820269872347033942567076775013009003935341953,f->0.97807439512691857794353025099682693742376299232772}}
n=15的时候:
内点法给出的结果:
{15.027579704577829300111481675284693984939461227768,{f->1.005055135433105614515747160447609006197748555743,f->0.96794553942599517311429387868409700111977101242392,f->0.94366007520733754613887327193557942016752832328608,f->0.93127634609807370476344594301335054862532636927128,f->0.93046546385997668503487260555259974554836614259297,f->0.94148062487649719552435996333869054560186558588658,f->0.96521017646890419866949116435038820891274500142133,f->1.0033096377380125779295465619784533881022059256324,f->-1.0584458213366884534887153623496661126780305719296,f->-1.0993458231520614894768999422508587994762910340487,f->-1.1240534881668975071698655862799799543494507807340,f->-1.1315862682443048646869792085963908718238985769344,f->-1.1220102098390985543233534351001296542215192794486,f->-1.0963821589817560536838880056631652422156449634511,f->-1.0565792293870957728609290090605772295107217097113}}
n=17的时候:
内点法给出的结果:
{17.021781121957166209092328829372393295839915421680,{f->1.000000000000000444089612867969937607300082461119,f->1.0222442218069296508185113412423675450457001562661,f->1.0323064821707284470006570136172189114331976817558,f->1.0300017438640309814118426503880446379339677291732,f->1.0157260719486122444557306759512380066493708617276,f->0.99039708979579957435258547365002932707617427117558,f->-0.95535102129949301877445004819828984836318198197895,f->0.93116880823997103888568125733505537031809575384725,f->-0.89845244071703528975609029365772464751310516561516,f->-0.87539582445591642203031233000419125857485861646712,f->-0.86124947542283315638385615012682323473016709301033,f->-0.85562189616645118447308581316506524261901185619277,f->-0.85845739887525336742555536359838392048703380520514,f->-0.87004234992781356398372511373462494930619105335011,f->-0.89104209220582358451101259974940452861961233629691,f->-0.92257582642735957749785000024788048504024280232517,f->0.96634390767190678382131643232849670949681579537714}}
With[{param=f/@Range},NMinimize[{(param/RotateLeft)^2//Total,Total==0},param,Method->{"SimulatedAnnealing","PerturbationScale"->2},WorkingPrecision->50]]
模拟退火算法有一个参数需要手工挨个的试。不过有mathe率先立出的靶子就是好, 可以不停的试,直到比mathe的结果要好为止,哈哈哈,^_^
。
。
wayne
发表于 2020-6-3 17:46:13
后来发现,内点法总能得到最优解。不仅给前面的模拟退火的结果树立了好的靶子,还把n=13的结果给刷新记录了。
With[{param=f/@Range},NMinimize[{(param/RotateLeft)^2//Total,Total==0,f>1},param,Method->{"RandomSearch",Method->"InteriorPoint"},WorkingPrecision->50]]
数学星空
发表于 2020-6-3 19:13:27
对于n=5,我们可以利用拉格朗日乘子法求解:
设\(s=(\frac{a_1}{a_2})^2+(\frac{a_2}{a_3})^2+(\frac{a_3}{a_4})^2+(\frac{a_4}{a_5})^2+(\frac{a_5}{a_1})^2-t(a_1+a_2+a_3+a_4+a_5)\)
然后分别对\(a_1,a_2,a_3,a_4,a_5\)求导得到
\(\frac{2a_1}{a_2^2}-\frac{2a_5^2}{a_1^3}-t=0\)
\(\frac{2a_2}{a_3^2}-\frac{2a_1^2}{a_2^3}-t=0\)
\(\frac{2a_3}{a_4^2}-\frac{2a_2^2}{a_3^3}-t=0\)
\(\frac{2a_4}{a_5^2}-\frac{2a_3^2}{a_4^3}-t=0\)
\(\frac{2a_5}{a_1^2}-\frac{2a_4^2}{a_5^3}-t=0\)
联立\(a_1+a_2+a_3+a_4+a_5=0\)
消元可以得到:\(\frac{a_1}{a_2},\frac{a_2}{a_3},\frac{a_3}{a_4},\frac{a_4}{a_5},\frac{a_5}{a_1}\)满足下列代数方程:
k^115 + 23*k^114 + 249*k^113 + 1670*k^112 + 7624*k^111 + 24079*k^110 + 48125*k^109 + 27390*k^108 - 194074*k^107 - 810670*k^106 - 1626373*k^105 - 1288826*k^104 + 2778641*k^103 + 11738550*k^102 + 19630036*k^101 + 10320797*k^100 - 31532695*k^99 - 92117225*k^98 - 107269999*k^97 + 3435081*k^96 + 231660459*k^95 + 391224442*k^94 + 206246680*k^93 - 378297093*k^92 - 928431589*k^91 - 736884523*k^90 + 405033990*k^89 + 1595544211*k^88 + 1381917117*k^87 - 528554951*k^86 - 2148374397*k^85 - 710178650*k^84 + 3672518516*k^83 + 6027459933*k^82 + 137885204*k^81 - 13545223892*k^80 - 23466841305*k^79 - 13912675691*k^78 + 18462662623*k^77 + 53044993824*k^76 + 55027810900*k^75 + 6320558079*k^74 - 67118078419*k^73 - 103540718624*k^72 - 55319946715*k^71 + 56880180634*k^70 + 141944986609*k^69 + 108696828905*k^68 - 41235950427*k^67 - 188588342979*k^66 - 186155745118*k^65 - 1259054738*k^64 + 224571806060*k^63 + 281302668790*k^62 + 87479376684*k^61 - 208102749488*k^60 - 341062379944*k^59 - 176131340106*k^58 + 150689937912*k^57 + 345084562767*k^56 + 228620637610*k^55 - 89015665102*k^54 - 313263865978*k^53 - 245719559865*k^52 + 34445141554*k^51 + 262495548942*k^50 + 247215658204*k^49 + 33994104985*k^48 - 169366259124*k^47 - 199853150078*k^46 - 69844640968*k^45 + 79492615023*k^44 + 124692614485*k^43 + 57219576822*k^42 - 39920485612*k^41 - 84412568575*k^40 - 58448475096*k^39 - 1216958390*k^38 + 38835152402*k^37 + 41339440748*k^36 + 18221060456*k^35 - 5938615689*k^34 - 15184534622*k^33 - 9191446682*k^32 + 3151208042*k^31 + 12084462612*k^30 + 11672680281*k^29 + 3469355163*k^28 - 4436900416*k^27 - 5903263890*k^26 - 2414034277*k^25 + 867389024*k^24 + 1439505390*k^23 + 269066013*k^22 - 957490933*k^21 - 1354685713*k^20 - 931619236*k^19 - 289563094*k^18 + 13550781*k^17 - 43634284*k^16 - 156177334*k^15 - 157059379*k^14 - 93266479*k^13 - 41846806*k^12 - 19221448*k^11 - 10894026*k^10 - 6314386*k^9 - 3101734*k^8 - 1225816*k^7 - 388930*k^6 - 99388*k^5 - 20305*k^4 - 3224*k^3 - 374*k^2 - 28*k - 1=0
可以求得代数方程的实根分别为:[-2.362410088312962034859919, -1.450440455762255802533788, -1.382687832725138383385208, -1.351798839098676672923711, -0.8593978432356048237104345, -0.6414405186028098699134122, -0.5381188972219660445212091, -0.1714218736650791520866084, 0.9384733719250471560187946, 0.9904799044884984442453844, 1.069139424246187015143149, 1.078210237863080636430359, 1.149410716487768093506190, 1.386959077295580867453245, 1.797501070895192625003567]
其中(如何筛选出下面的解,还没搞清楚)
\(\frac{a_1}{a_2}=-1.351798839098676672923711\)
\(\frac{a_2}{a_3}=1.149410716487768093506190\)
\(\frac{a_3}{a_4}=0.9384733719250471560187946\)
\(\frac{a_4}{a_5}=-0.6414405186028098699134122\)
\(\frac{a_5}{a_1}=1.069139424246187015143149\)
wayne
发表于 2020-6-4 09:48:17
数学星空 发表于 2020-6-3 19:13
对于n=5,我们可以利用拉格朗日乘子法求解:
设\(s=(\frac{a_1}{a_2})^2+(\frac{a_2}{a_3})^2+(\frac{a_3 ...
我在你算出来的这15个实根里每五个一组,计算一下平方和,跑了一遍,找到了5.5837424137607321737587108695119652893919081384213的组合:
func=-1-28 #1-374 #1^2-3224 #1^3-20305 #1^4-99388 #1^5-388930 #1^6-1225816 #1^7-3101734 #1^8-6314386 #1^9-10894026 #1^10-19221448 #1^11-41846806 #1^12-93266479 #1^13-157059379 #1^14-156177334 #1^15-43634284 #1^16+13550781 #1^17-289563094 #1^18-931619236 #1^19-1354685713 #1^20-957490933 #1^21+269066013 #1^22+1439505390 #1^23+867389024 #1^24-2414034277 #1^25-5903263890 #1^26-4436900416 #1^27+3469355163 #1^28+11672680281 #1^29+12084462612 #1^30+3151208042 #1^31-9191446682 #1^32-15184534622 #1^33-5938615689 #1^34+18221060456 #1^35+41339440748 #1^36+38835152402 #1^37-1216958390 #1^38-58448475096 #1^39-84412568575 #1^40-39920485612 #1^41+57219576822 #1^42+124692614485 #1^43+79492615023 #1^44-69844640968 #1^45-199853150078 #1^46-169366259124 #1^47+33994104985 #1^48+247215658204 #1^49+262495548942 #1^50+34445141554 #1^51-245719559865 #1^52-313263865978 #1^53-89015665102 #1^54+228620637610 #1^55+345084562767 #1^56+150689937912 #1^57-176131340106 #1^58-341062379944 #1^59-208102749488 #1^60+87479376684 #1^61+281302668790 #1^62+224571806060 #1^63-1259054738 #1^64-186155745118 #1^65-188588342979 #1^66-41235950427 #1^67+108696828905 #1^68+141944986609 #1^69+56880180634 #1^70-55319946715 #1^71-103540718624 #1^72-67118078419 #1^73+6320558079 #1^74+55027810900 #1^75+53044993824 #1^76+18462662623 #1^77-13912675691 #1^78-23466841305 #1^79-13545223892 #1^80+137885204 #1^81+6027459933 #1^82+3672518516 #1^83-710178650 #1^84-2148374397 #1^85-528554951 #1^86+1381917117 #1^87+1595544211 #1^88+405033990 #1^89-736884523 #1^90-928431589 #1^91-378297093 #1^92+206246680 #1^93+391224442 #1^94+231660459 #1^95+3435081 #1^96-107269999 #1^97-92117225 #1^98-31532695 #1^99+10320797 #1^100+19630036 #1^101+11738550 #1^102+2778641 #1^103-1288826 #1^104-1626373 #1^105-810670 #1^106-194074 #1^107+27390 #1^108+48125 #1^109+24079 #1^110+7624 #1^111+1670 #1^112+249 #1^113+23 #1^114+#1^115&;
realrootindex=Select,Element,Reals]&];
N&/@{4,6,9,11,13})^2],100]
5.583742413760732173758710869511965289391908138421222113567417214069488710462275126439321609823493105
。。
。
然后我稍微转化了一下,已知\(x y z s t =1,\frac{1}{x}+\frac{1}{x y} +\frac{1}{x y z}+\frac{1}{x y z s }+\frac{1}{x y z s t }=0\),求\(x^2+y^2+z^2+s^2+t^2\)的最小值。然后尝试将这五个变量都放进一个方程,还是没成功。
代数计算还是太难了,放弃。。
数学星空
发表于 2020-7-21 21:46:49
由于取极值条件为:
\(\frac{2a_k}{a_{k+1}^2}-\frac{2a_{k-1}^2}{a_k^3}=t\)...........................(1)
可以变形为:
\(\frac{a_k^2}{a_{k+1}^2}-\frac{a_{k-1}^2}{a_k^2}=\frac{ta_k}{2}\)
记\(b_k=\frac{a_{k-1}^2}{a_k^2}\)
则有\(b_{k+1}-b_k=\frac{ta_k}{2}\)
并且\(a_1+a_2+\dots+a_n=0\)
由于(1)是循环的方程,肯定与\(\sin(\frac{2\pi}{n})\)有关,
不知道如何设\(a_k=1+\frac{v_1}{n}+\frac{v_2}{n^2}+\frac{v_3}{n^3}+\dots\)
才能使得\(a_{n+k}=a_k\) ? 即使得(1)对所有1~n都成立
若能搞清楚a_k的渐近表达式结构,应该可以得到我们最终的结论?
数学星空
发表于 2020-7-22 19:44:35
对于\(n=7\),我们可以得到下面结果
利用\(\frac{a_k^2}{a_{k+1}^2}-\frac{a_{k-1}^2}{a_k^2}=ta_k\)
可以得到:
\(\frac{a_1^2}{a_2^2}=ta_1+\frac{a_7^2}{a_1^2}\)
\(\frac{a_2^2}{a_3^2}=t(a_1+a_2)+\frac{a_7^2}{a_1^2}\)
\(\frac{a_3^2}{a_4^2}=t(a_1+a_2+a_3)+\frac{a_7^2}{a_1^2}\)
\(\frac{a_4^2}{a_5^2}=t(a_1+a_2+a_3+a_4)+\frac{a_7^2}{a_1^2}\)
\(\frac{a_5^2}{a_6^2}=t(a_1+a_2+a_3+a_4+a_5)+\frac{a_7^2}{a_1^2}\)
\(\frac{a_6^2}{a_7^2}=t(a_1+a_2+a_3+a_4+a_5+a_6)+\frac{a_7^2}{a_1^2}\)
为了更简洁的计算:我们可以设\(a_1=1\),则可以得到
\(a_2+a_3+a_4+a_5+a_6+a_7=-1\)
\(\frac{1}{a_2^2}=t+a_7^2\)
\(\frac{1}{a_3^2}=(t+a_7^2)(t(1+a_2)+a_7^2)\)
\(\frac{1}{a_4^2}=(t+a_7^2)(t(1+a_2)+a_7^2)(t(1+a_2+a_3)+a_7^2)\)
\(\frac{1}{a_5^2}=(t+a_7^2)(t(1+a_2)+a_7^2)(t(1+a_2+a_3)+a_7^2)(t(1+a_2+a_3+a_4)+a_7^2)\)
\(\frac{1}{a_6^2}=(t+a_7^2)(t(1+a_2)+a_7^2)(t(1+a_2+a_3)+a_7^2)(t(1+a_2+a_3+a_4)+a_7^2)(t(1+a_2+a_3+a_4+a_5)+a_7^2)\)
\(\frac{1}{a_7^2}=(t+a_7^2)(t(1+a_2)+a_7^2)(t(1+a_2+a_3)+a_7^2)(t(1+a_2+a_3+a_4)+a_7^2)(t(1+a_2+a_3+a_4+a_5)+a_7^2)(-ta_7+a_7^2)\)