Multiple equations solving in MATLAB
2 次查看(过去 30 天)
显示 更早的评论
I have 10 equations and 10 variables. 6 of them are non-linear and 4 of then are linear . I have 2 constraints. I have tried several programming .nothing is working out for me.
i was wondering if anyone can tell me how to solve it in MATLAB
4 个评论
Walter Roberson
2020-1-24
Do you need a numeric solution or a symbolic solution? Do you need the complete set of solutions?
Golam Ismot Ara taposhe
2020-1-31
Hi walter
thank you for responding
Yes, i need numerical solutions
approximate answers are ok too even it is not exact solution.
thanks
Golam Ismot Ara taposhe
2020-1-31
Hi walter
Is there any way I can solve it in MATLAB?
I was wondering if you can give any suggestion here?
Thank you for your time
Golam Ismot Ara taposhe
2020-2-14
Hi walter
I have solved it, thank you so much for your constant support
best
Taposhe
回答(2 个)
Alex Sha
2020-1-28
Hi, Golam, post out your problem, we may try.
28 个评论
Golam Ismot Ara taposhe
2020-1-31
Hi Alex, thank you for responding
these are the equations
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*438317.8267;
F (2) = x(13)^2- x(11)* x(33)*1504.404097;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*6.893675349;
F (5) = x(24)^2- x(22)* x(44)*367575692.3;
F (6) = x(34)^2- x(33)* x(44)*59.56559281;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.617423671;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-0.903918712;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.389080754;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.089576863;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
Alex Sha
2020-1-31
If the range is limited to positive, there is only one solution, otherwise, multi-solutions:
x12: 0.568805871997955
x11: 1.75161505466035E-5
x22: 0.0421405635331669
x13: 0.0485825906464157
x33: 0.0895690725368929
x14: 1.76044033444841E-7
x44: 5.1740864465406E-10
x23: 0.161307522651606
x24: 0.0895241902858586
x34: 5.24956300155729E-5
Fevl:
f1=-5.4373172631017E-13
f2=4.64219091118878E-10
f3=-5.26052914397006E-15
f4=-2.02602171150978E-11
f5=8.91699908356358E-14
f6=-4.70548939307902E-12
f7=-1.05025987906515E-11
f8=1.75337522279051E-12
f9=1.8231527398882E-12
f10=-5.27509980141616E-12
f11=-6.1007865426177E-12
Golam Ismot Ara taposhe
2020-1-31
编辑:Golam Ismot Ara taposhe
2020-1-31
range is positive. 1st batch looks right answer. I have to solve like these 25 sets of equations
i was wondering if it is ok can you please tell me the progammimg you used here? that would be great for me
thanks for your kind help
Walter Roberson
2020-1-31
Alex uses a commercial global optimization package named "1stOpt". I do not know what algorithms it uses, but Alex has been getting some very good results using it.
Alex Sha
2020-1-31
Hi, Golam, if you post your 25 sets of equations here, I may try to solve it for you.
Golam Ismot Ara taposhe
2020-1-31
Hi Alex, problem is i have to show my supervisor how i did the calculations. thank you for your understanding
Golam Ismot Ara taposhe
2020-1-31
编辑:Golam Ismot Ara taposhe
2020-1-31
Hi Walter
thank you for your kind response. I really approciate it
is there anything you can say more?
thanks
Walter Roberson
2020-2-1
You have 11 equations in 10 variables. There are not generally solutions in such cases. Maple says that there are no solutions if you include all 11 equations. If you drop the last equation then there is a set of (generally complex) solutions involving the roots of a polynomial of degree 56. If you instead drop the 7th equation then there is different set of (generally) complex solutions involving the roots of a (different) polynomial of degree 56.
Golam Ismot Ara taposhe
2020-2-3
Hi Alex
I was wondering if you would kindly solve these sets of equations. Thank you so much for your time and really appreciate it. your guys are genious. thanks
set 1:
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*2784469.63;
F (2) = x(13)^2- x(11)* x(33)*39929.22798;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*2.355514402;
F (5) = x(24)^2- x(22)* x(44)*19184500080;
F (6) = x(34)^2- x(33)* x(44)*99.1384437;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.314795373;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-1.175613938;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.354205406;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.155385282;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
Set 2:
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*3085568.526;
F (2) = x(13)^2- x(11)* x(33)*9285.647504;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*4.387181426;
F (5) = x(24)^2- x(22)* x(44)*8737892458;
F (6) = x(34)^2- x(33)* x(44)*115.8860114;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.451771862;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-1.012018299;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.372707799;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.16350204;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
Set 3:
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*3189501.651;
F (2) = x(13)^2- x(11)* x(33)*6104.314997;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*5.623324964;
F (5) = x(24)^2- x(22)* x(44)*7052901939;
F (6) = x(34)^2- x(33)* x(44)*123.3959763;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.506873032;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-0.946209114;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.380150707;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.166767146;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
set4:
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*3343727.706;
F (2) = x(13)^2- x(11)* x(33)*3996.510971;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*7.690798865;
F (5) = x(24)^2- x(22)* x(44)*5758396848;
F (6) = x(34)^2- x(33)* x(44)*133.7210361;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.577387291;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-0.861991559;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.389675571;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.17094558;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
set 5:
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*3509338.916;
F (2) = x(13)^2- x(11)* x(33)*3048.918666;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*9.93055936;
F (5) = x(24)^2- x(22)* x(44)*5115837010;
F (6) = x(34)^2- x(33)* x(44)*142.9904076;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.636198118;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-0.791751805;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.397619569;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.174430508;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
Golam Ismot Ara taposhe
2020-2-3
set6
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*3884377.728;
F (2) = x(13)^2- x(11)* x(33)*2243.954041;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*14.73634537;
F (5) = x(24)^2- x(22)* x(44)*4551124262;
F (6) = x(34)^2- x(33)* x(44)*159.141244;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.730099331;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-0.679602421;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.410303476;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.179994772;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
Set 7:
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*566903404.7;
F (2) = x(13)^2- x(11)* x(33)*2101.614568;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*10.16222778;
F (5) = x(24)^2- x(22)* x(44)*4604040421;
F (6) = x(34)^2- x(33)* x(44)*911.4372747;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.507521905;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-0.694648638;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.614150761;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.183678696;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
Set 8
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*22240900.45;
F (2) = x(13)^2- x(11)* x(33)*3622.177029;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*6.791814204;
F (5) = x(24)^2- x(22)* x(44)*5591056023;
F (6) = x(34)^2- x(33)* x(44)*340.1051497;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.480828459;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-0.846607084;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.498546462;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.174017995;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
Set 9
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*5611034.749;
F (2) = x(13)^2- x(11)* x(33)*6185.794156;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*5.165229053;
F (5) = x(24)^2- x(22)* x(44)*7131200880;
F (6) = x(34)^2- x(33)* x(44)*173.5998693;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.462659176;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-0.950039815;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.41985871;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.167442298;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
set10
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*1829802.608;
F (2) = x(13)^2- x(11)* x(33)*16206.56782;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*3.648114361;
F (5) = x(24)^2- x(22)* x(44)*11708864434;
F (6) = x(34)^2- x(33)* x(44)*72.99900738;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.43936488;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-1.082647836;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.31897549;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.159011794;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
Golam Ismot Ara taposhe
2020-2-3
set 11
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*1174114.134;
F (2) = x(13)^2- x(11)* x(33)*35786.2956;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*2.955018606;
F (5) = x(24)^2- x(22)* x(44)*17973714249;
F (6) = x(34)^2- x(33)* x(44)*42.56941011;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.424970716;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-1.164589853;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.25663707;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.153802361;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
set 12
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*1050220.42;
F (2) = x(13)^2- x(11)* x(33)*8229.81313;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*6.880624655;
F (5) = x(24)^2- x(22)* x(44)*8158762318;
F (6) = x(34)^2- x(33)* x(44)*60.28207736;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.723669993;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-0.992662401;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.283667606;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
set 13
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*999979.3411;
F (2) = x(13)^2- x(11)* x(33)*6550.074333;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*7.255477172;
F (5) = x(24)^2- x(22)* x(44)*7257704706;
F (6) = x(34)^2- x(33)* x(44)*50.50852829;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.695643443;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-0.956022864;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.271105993;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.077227699;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
set 14
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*983501.996;
F (2) = x(13)^2- x(11)* x(33)*5738.37751;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*7.528993805;
F (5) = x(24)^2- x(22)* x(44)*6793296848;
F (6) = x(34)^2- x(33)* x(44)*47.13907859;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.680946748;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-0.93273616;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.266295968;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.120021124;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
set15
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*943859.5978;
F (2) = x(13)^2- x(11)* x(33)*5199.033377;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*7.693424176;
F (5) = x(24)^2- x(22)* x(44)*6471061434;
F (6) = x(34)^2- x(33)* x(44)*42.36532691;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.663564308;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-0.91408532;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.256727996;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.165622377;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
set 16
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*925080.9547;
F (2) = x(13)^2- x(11)* x(33)*4558.651692;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*8.012584917;
F (5) = x(24)^2- x(22)* x(44)*6075426366;
F (6) = x(34)^2- x(33)* x(44)*39.48156833;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.646519493;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-0.887422951;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.250999;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.215058556;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
Walter Roberson
2020-2-3
11 equations in 10 variables almost never has a solution (unless there are an infinite number of solutions.)
Are you looking for a set of values that minimizes the fitting error, or are you looking for the exact solution?
Walter Roberson
2020-2-3
The first 10 equations of Set 1 together are solvable in terms of roots of a polynomial. My system is busy computing so I do not know the exact degree a the moment, but degree 56 seems likely based on the previous work.
Now one thing about that set of solutions is that it turns out that 16 decimal digits will get you nonsense answers, and the default 32 decimal digits of the Symbolic Toolbox will get you wrong answers; you need to go for at least 40 digits in order to get reasonable solutions. And when you do, evaluating the set of solutions numerically takes a long time.
Once I have the set of numeric solutions, I will substitute each one into the 11th equation to see how badly the constraint is violated.
Walter Roberson
2020-2-3
Could you remind us of any constraints you have? All real and non-negative for example?
Alex Sha
2020-2-3
Hi, Golam, I suppose you want to real and positive solution:
Set 1:
x12: 0.296790391356669
x11: 1.21453599136089E-7
x22: 0.260463455760424
x13: 0.0180046230081065
x33: 0.0668446557770811
x14: 1.15851527897666E-7
x44: 4.83194321121088E-12
x23: 0.202511470273299
x24: 0.155385164974354
x34: 1.28955025530814E-9
Fevl:
-1.87835857978769E-13
5.29232785525212E-11
1.34192290886484E-14
-9.14164577370258E-13
1.47104550762833E-15
-3.20206826977637E-11
1.23501653348512E-10
1.25170318554524E-10
1.25117971538913E-10
1.25096016878601E-10
-2.50557241621152E-10
Set 2:
x12: 0.431797958826541
x11: 5.46046151711537E-7
x22: 0.110661518014259
x13: 0.0199702357941947
x33: 0.0786547013480454
x14: 2.57528248319112E-6
x44: 2.76406853737176E-11
x23: 0.195412999996965
x24: 0.16348430414904
x34: 1.51605140706519E-5
Fevl:
-9.63173985013555E-13
1.42456797714522E-10
6.63201949587151E-12
-1.04953545854158E-12
-3.74086178700495E-13
-2.2103096897211E-11
-4.47769599176695E-12
1.06381570219583E-12
1.32110988815271E-12
8.75244321463242E-13
-6.08735284401973E-13
Set 3:
x12: 0.481404596355386
x11: 1.18653732985892E-6
x22: 0.0612373272826296
x13: 0.02546559794606
x33: 0.0895342940942687
x14: 4.64748920736514E-7
x44: 6.43717894730441E-11
x23: 0.175589851473741
x24: 0.166740011730629
x34: 2.66695166682591E-5
Fevl:
2.04558592287185E-14
-2.83491763050647E-14
2.15686041200956E-13
1.73056013963446E-14
-5.89805981832114E-17
7.25409553619925E-14
1.25026433650532E-10
1.25015331420286E-10
1.25006671680694E-10
1.24961568870319E-10
-2.49995024681482E-10
Set 4:
x12: 0.531780682148586
x11: 4.71432286386688E-6
x22: 0.0179396880799777
x13: 0.0455961312781964
x33: 0.110345755469119
x14: 1.04879194770259E-6
x44: 2.82873005623025E-10
x23: 0.123387449356439
x24: 0.17094405121275
x34: 4.79304275186946E-7
Fevl:
-2.1049828546893E-13
1.27921642462808E-10
1.09463033085387E-12
-7.21288480332039E-12
8.68853600177744E-14
-4.17371669210198E-9
-1.35542133072875E-10
-1.22269638858086E-10
-1.22851395722989E-10
-1.25281118812381E-10
2.47027953648171E-10
Set 5:
x12: 0.544262794724716
x11: 2.31125908857653E-5
x22: 0.00365210580011895
x13: 0.0918890980793043
x33: 0.119821155523983
x14: 3.02975505910474E-12
x44: 1.6253734921726E-9
x23: 0.0659212269037869
x24: 0.174263571773913
x34: 0.000166932972045344
Fevl:
-6.10456130090142E-13
5.91015378997861E-11
-1.50266370235432E-13
-2.22427978813222E-11
1.44530221124484E-13
1.86447268134526E-11
-1.11783915457409E-11
2.65376609576151E-12
3.102518242315E-12
-2.64926969251178E-13
-2.84350321066995E-12
Set 6:
x12: 0.485961809895246
x11: 0.000347128913271497
x22: 0.000175142698859543
x13: 0.243432092384426
x33: 0.076076568886829
x14: 1.11708930174907E-5
x44: 4.03220215334567E-8
x23: 0.0140125255498316
x24: 0.179277800160654
x34: 0.000705720293559415
Fevl:
9.28282450907147E-12
2.83468179484991E-11
6.88010927449476E-11
4.00413617464724E-11
5.06125835686433E-11
9.86565138225466E-9
-7.67497176923371E-13
3.45068418283745E-12
1.47504231051698E-12
-8.72601990664634E-12
-2.28395080625887E-12
Set 7:
x12: 0.481288756177787
x11: 1.16670139276446E-6
x22: 0.00035022137607592
x13: 0.0260707583249654
x33: 0.277200778073954
x14: 0.000160057087454156
x44: 2.03738578545971E-8
x23: 0.0314096437167506
x24: 0.181249795354142
x34: 0.00226880281157537
Fevl:
-5.1680881796301E-13
1.50245953157123E-10
2.5618176163474E-8
3.46647190119231E-13
-1.61086421979206E-13
-1.18427615431523E-11
-7.00794977603891E-12
8.3144602314178E-13
1.19937393350256E-12
8.87262485704809E-13
-2.04491978905708E-12
Set 8:
x12: 0.46526834683578
x11: 4.14083223504362E-7
x22: 0.0235053657577015
x13: 0.015550513420014
x33: 0.161224849016526
x14: 8.77057419568636E-6
x44: 2.3009955436095E-10
x23: 0.160432516113573
x24: 0.173895489533099
x34: 0.000113734434399332
Fevl:
9.27952159557321E-13
9.92832256295137E-11
7.69225906005787E-11
1.2056022846707E-11
1.82377724033955E-12
3.18380339570992E-10
-3.56326079753444E-12
-2.1449508835758E-12
1.03833608378068E-12
1.89309679043959E-12
-1.38844491459622E-12
Set 9:
x12: 0.444864216836446
x11: 4.94790953809723E-7
x22: 0.0712837008853971
x13: 0.0177939659450528
x33: 0.10344942083704
x14: 3.75627828745266E-9
x44: 5.51540516910762E-11
x23: 0.19516590238288
x24: 0.167442294135323
x34: 1.23883700222921E-10
Fevl:
-1.95343741182796E-13
1.68914214267266E-10
-9.50492767980051E-17
-8.04342703553118E-13
9.04137875679112E-15
-9.90500910914772E-10
1.19684706589851E-10
1.25443100351674E-10
1.2589645992378E-10
1.25793098160187E-10
-2.51591303346288E-10
Set 10:
x12: 0.416249134739258
x11: 5.83560253175685E-7
x22: 0.162261968810759
x13: 0.0231145678230364
x33: 0.0564930099892952
x14: 1.03128724993784E-8
x44: 1.33074406117712E-11
x23: 0.182868941088728
x24: 0.159005822550797
x34: 5.96111028628954E-6
Fevl:
-2.53352894219461E-13
1.05395274972719E-10
7.52925655383329E-17
-1.16267412364479E-12
1.79023462720806E-14
-1.93441663305649E-11
-4.32676117156916E-12
3.00870439673417E-13
6.41098285569797E-13
5.7065463465733E-13
-1.40709666140992E-12
Set 11:
x12: 0.397334924533982
x11: 5.88483202067972E-7
x22: 0.228490997179711
x13: 0.0276346144930659
x33: 0.0362623513414042
x14: 2.61619888270877E-12
x44: 5.75968596369031E-12
x23: 0.156474162972961
x24: 0.153798771134184
x34: 3.58985202406238E-6
Fevl:
-1.49574796992624E-13
7.73027370197174E-11
-1.35579069107771E-17
-1.59408597433242E-12
8.03038191499184E-14
3.99600094468563E-12
-3.93179933055876E-12
5.48894263374677E-13
8.59368132211102E-13
3.43641781697102E-13
-1.08968389866959E-12
Set 12:
x12: 0.6795141330995
x11: 5.51075396520542E-6
x22: 0.0797821081561921
x13: 0.0441448383899904
x33: 0.0429693580313435
x14: 7.40568348127855E-12
x44: 2.14114924634587E-20
x23: 0.153584051555701
x24: 3.30886968482179E-11
x34: 1.04639187644802E-20
Fevl:
1.90131244082181E-12
6.02717702136157E-12
5.43721739569061E-23
-1.387124790031E-11
-1.39372384249107E-11
-5.54618070531652E-20
4.82647255495294E-12
6.7390537594747E-13
8.37840907763621E-12
4.04943803827834E-11
2.71864752932061E-11
Set 13:
x12: 0.646197551955075
x11: 8.16104962596517E-6
x22: 0.0511674260049779
x13: 0.0494295529970784
x33: 0.0457068315130717
x14: 1.60377683875958E-8
x44: 1.60602811659785E-11
x23: 0.130262777120675
x24: 0.0772276830553979
x34: 3.27638353215301E-12
Fevl:
3.46616624291585E-11
1.46475162728088E-11
-2.6706499155585E-16
-2.94126736855027E-11
3.65759133050259E-11
-3.70765208634308E-11
8.91736684494049E-11
1.41103684292432E-10
1.47173218056906E-10
1.28563229506717E-10
-2.469932036675E-10
Set 14:
x12: 0.625735315226235
x11: 1.10038685508278E-5
x22: 0.036179344439831
x13: 0.0551894250038921
x33: 0.0482366574430207
x14: 1.45453672000967E-11
x44: 5.86043643963759E-11
x23: 0.114627130072603
x24: 0.120015025826032
x34: 6.09804212485561E-6
Fevl:
-2.53130849614536E-14
1.64295283974769E-10
-2.57949867772243E-15
-2.05987449319878E-11
7.47110706633691E-14
-9.60703370927724E-11
-1.8225754239154E-11
4.53204140882235E-12
4.66138239119118E-12
-8.90537643627454E-14
-4.56079618516014E-12
Set 15:
x12: 0.601318293628764
x11: 1.52719115628394E-5
x22: 0.0250846494299134
x13: 0.0622147815080364
x33: 0.048749609397943
x14: 6.88898643597429E-7
x44: 1.68947324581724E-10
x23: 0.0969950176642763
x24: 0.165602709726423
x34: 1.89779113971348E-5
Fevl:
-1.71307412699662E-13
1.26717468115767E-10
4.64260746751216E-13
-2.53125714833047E-11
1.149011441548E-13
1.12353707069578E-11
-1.41430311906277E-10
-1.2070988653079E-10
-1.20404131109808E-10
-1.25641608228477E-10
2.45906850437905E-10
Set 16:
x12: 0.570250079149119
x11: 2.54277243018483E-5
x22: 0.0138243103362261
x13: 0.0762185582625593
x33: 0.0501161239896505
x14: 4.48185769366361E-11
x44: 5.50461053439252E-10
x23: 0.0745069451004263
x24: 0.215017306187701
x34: 4.12486220431992E-5
Fevl:
1.17703069513198E-11
1.05854931244098E-9
-5.59878856143283E-14
-1.0317599908119E-9
7.11438546963095E-12
6.12271805448652E-10
-9.48994216543042E-11
1.09698472527953E-10
-3.56702445358792E-11
-4.45151138173117E-11
-3.26930704730444E-11
If there is plenty of time to carry out calculation, a slight more better results may be achieved.
Walter Roberson
2020-2-3
I have confirmed that there are no exact solutions for Set 1 (and probably not for any of the others.)
The range of constraint violations for the 11th equation is not a lot, but there are differences. I am still working on calculating the minimum violation -- it is pretty slow going due to the number of digits needed to avoid arithmetic blunders.
Walter Roberson
2020-2-3
编辑:Walter Roberson
2020-2-3
The only solution for the first 10 equations with strictly non-negative values is
x11 = 1.214524277289861712800601589733287518317*10^(-7)
x12 = 0.2967908473070547727205424545780513067751
x13 = 0.01800428125601524100873800651915724835393
x14 = 1.532060687546415368317427436105442109056*10^(-9)
x22 = 0.2604667772215134096398882259351167094862
x23 = 0.2025099141564405156435831652865925296165
x24 = 0.1553796220934540219183459278238648763805
x33 = 0.06684277611136843983267220526673385479902
x34 = 5.658364714053207937908180617464529886491*10^(-6)
x44 = 4.835812026405734456246080987725605334118*10^(-12)
This violates the 11th equation by -5.001153174692997235760335196370*10^(-10)
Golam Ismot Ara taposhe
2020-2-4
Hi Alex,
thank you so much for your time.
I really appriciate it
thanks again
Golam Ismot Ara taposhe
2020-2-4
编辑:Golam Ismot Ara taposhe
2020-2-5
Hi Walter
Your result is also pretty great too
I need all possitive answers i.e. No negative values.
I am trying to minimize error% here.
If there is no exact solution , is it possible to have multiple answer from same set?
I was wondering if you can help me to understand how you did it so that I can solve other sets.
Thanks a lot for your help
Walter Roberson
2020-2-7
What I did for the first pass was the equivalent of solve() on the first 10 equations, and then finding all the numeric equivalents of the root() structures, and weeding out all the entries that had negative or complex numbers in the solutions.
I say "equivalent" because although I did actually use a function named solve(), it was in Maplesoft's "maple" software.
You can then construct a residue function from sum() of the squares of all 11 equations, and use the numeric result from solve() of the first 10 functions as the starting point to minimize the residue.
Unfortunately, on this system of equations, solve() and vpasolve() of the first 10 equations is pretty slow in MATLAB. You can do a numeric solution using fsolve() but it returns some negative values, because you cannot put any bounds on fsolve(). You can put bounds on vpasolve() but it is still quite slow.
I wrote up some code that went through a couple of numeric approximations and then minimized the residue of all 11 functions using fmincon(), but the final results from fmincon() had some variables fairly far away from the initial conditions, and the residue was about 3.5 when it is known the residue can be about 1e-9 with points closer to the numeric approximation locations.
Alex Sha
2020-2-8
Hi, Walter and Golam, if posible you may have a try of 1stOpt package, for Golam's 16 problems, it is quite easy for getting stable and unique results in a few second, also very simple code like below, without guessing initial start values.
Parameter x1(4),x2(2:4), x3(3:4), x44;
ParameterDomain = [0,];
Function
x12^2- x11* x22*2784469.63;
x13^2- x11* x33*39929.22798;
x14^2- x11* x44*4;
x23^2- x22* x33*2.355514402;
x24^2- x22* x44*19184500080;
x34^2- x33* x44*99.1384437;
2*x11+x12+x13+x14-0.314795373;
2*x22+x12+x23+x24-1.175613938;
2*x33+x13+x23+x34-0.354205406;
2*x44+x14+x24+x34-0.155385282;
x11+x22+x33+x44+x12+x13+x14+x24+x23+x34-1;
Golam Ismot Ara taposhe
2020-2-10
Hi ALex,
thank you for the reply
Is there any trial version for this software? I found this software pretty expensive
Golam Ismot Ara taposhe
2020-2-10
编辑:Golam Ismot Ara taposhe
2020-2-10
Hi walter
I am trying to use vpasolve(). it is taking a lot of time. still running
I was wondering if you can provide me how did you use fmincom()/ progamming code you used?
I have another question, if you are using Maple software what codes did you used? Is that going to give me better results?
Walter Roberson
2020-2-10
The flow was something like this.
X = sym('x', [1 44]);
F = root2d(X);
vars = symvar(F);
nvars = length(vars);
F10fun = matlabFunction(F(1:10), 'vars', {vars});
x0 = 0.01 * ones(1, nvars);
%unfortunately some entries from fsolve are negative
F10sol = fsolve(F10fun, x0);
%so we pop that into vpasolve with a bounds restriction
%we did not just go directly to vpasolve because it is too slow without a decent guess
F10_restricted_struct = vpasolve(F10fun, abs(F10sol), vars, repmat([0 1], nvars, 1));
%vpasolve returns a struct, we need a vector
F10_restricted = double(cell2mat(struct2cell(F10_restricted_struct)));
%now we have a vector of initial values
%proceed to minimize residue for the full set of equations
residue11 = matlabFunction( sum(F.^2), 'vars', {vars});
F11min = fmincon(residue11, F10sol, [], [], [], [], zeros(1,nvar)); %zeros is lb
%F11min should in theory now be a list of values that give a good fit for the entire
%set of 11 equations. Unfortunately in practice some of the values went towards .9
%when they should have been about 1e-2 -- perhaps an ub parameter is called for
Golam Ismot Ara taposhe
2020-2-11
Hi Walter
From vapsolve it took almost 5 hours to get some values.
I got several warning values like below and multiple values of each vaiables (I have given one of them to show you).
{Warning: Solution '[x11 = -0.38750367826943393346203707487446, x22 =
-0.00000060583325942090259608703097820327, x33 =
-0.000038650066836096378956219616167947, x44 = -0.0000048908827834088449488126789731625,
x12 = 0.85110289647020175449525875148945, x13 =
0.37292297133288576681275288927368, x14 = 0.0027533507357803688041407060780671, x24 =
0.16090647871265852412483387878892, x23 =
0.000010135483658517192456190547613278, x34 = -0.00014800768287208782214890388479803]'
seems to be affected by some numeric instability.
Inserting this solution into equation 'x12^2 - (6626207954368463*x11*x22)/2147483648 = 0'
produces the residue
'0.00000000000030833038535512130740942027139926'.}..............................................................
X11=
3.8738121895266076426113797703788e+74
3.6665527467324870120747140518347e+69 + 4.3567273814115433908181896380624e+70i
3.6665527467324870120747140518347e+69 - 4.3567273814115433908181896380624e+70i
1.2093861453901211537782805512659e+101
0.000053882931343728240927855813790698
0.000053882706767122569158490778389023
0.000053807955312050678830801654097808
0.0000538077304413047952097862083875
-7.3854207307736464976581835531054e+74
0.000033176145565362070576015087524794
0.000033176338952970457036913395663678
0.000033109103226504987910799623088257
0.000033109296589075267193735647291267
2.8254024107173870504811031811197e+70 - 5.9311882667731407548267433191443e+70i
2.8254024107173870504811031811197e+70 + 5.9311882667731407548267433191443e+70i
1.7685725013650819705301561897085e+70 + 1.8063164266990928662426900108303e+70i
Golam Ismot Ara taposhe
2020-2-11
Hi Walter
like you said fsolve() gave me a good result but one variable is negative. I tried to use your flow this restricted_structure i am unfamilier and giving me error.
I was wondering if you can help me to figure this out
thank you so much for your time
>>F10_restricted_struct = vpasolve(F10fun, abs(F10sol), vars, repmat([0 1], nvars, 1));
Error using sym.getEqnsVars (line 32)
Arguments must be symbolic objects.
Error in sym/vpasolve (line 132)
[eqns,vars] = sym.getEqnsVars(varargin{1:N});
>> F10_restricted = double(cell2mat(struct2cell(F10_restricted_struct)));
Unrecognized function or variable 'F10_restricted_struct'.
>> F11min = fmincon(residue11, F10sol, zeros(1,nvar));
Unrecognized function or variable 'residue11'.
Did you mean:
>> F11min = fmincon(residue, F10sol, zeros(1,nvar));
Not enough input arguments.
Error in residue (line 81)
u = u(:).'; v = v(:).'; k =[];
Samatha Aleti
2020-1-28
Hi,
You may use “fsolve” and “solve” functions to solve system of non-linear equations and linear equations respectively. Refer the following documentation links on detailed explanation on using “fsolve” and “solve”:
6 个评论
Walter Roberson
2020-1-28
fsolve() is for numeric solutions.
solve() is for closed-form indefinitely precise solutions when those can be found. It is able to deal with quadratic equations in practice, and usually cubic as well, and sometimes quartic, but beyond that it is hit and miss as to whether it can solve higher order polynomials. In theory it can at least get down to a placeholder saying "roots of a polynomial with these coefficients" but in practice it can miss out on higher degree if the coefficients are not already collected.
solve() typically cannot find closed form solutions to trig problems.
There is also vpasolve() which is for finding numeric solutions to equations. If your equations are well-scaled and well behaved then typically fsolve() is better (more efficient), but sometimes you need higher precision. For example, root finding of a higher order polynomial can be pretty unstable numerically.
Golam Ismot Ara taposhe
2020-1-31
this are the euations
function F = root2d(x)
F (1) = x(12)^2- x(11)* x(22)*438317.8267;
F (2) = x(13)^2- x(11)* x(33)*1504.404097;
F (3) = x(14)^2- x(11)* x(44)*4;
F (4) = x(23)^2- x(22)* x(33)*6.893675349;
F (5) = x(24)^2- x(22)* x(44)*367575692.3;
F (6) = x(34)^2- x(33)* x(44)*59.56559281;
F (7) = 2*x(11)+x(12)+x(13)+x(14)-0.617423671;
F (8) = 2*x(22)+x(12)+x(23)+x(24)-0.903918712;
F (9) = 2*x(33)+x(13)+x(23)+x(34)-0.389080754;
F (10) = 2*x(44)+x(14)+x(24)+x(34)-0.089576863;
F (11) = x(11)+x(22)+x(33)+x(44)+x(12)+x(13)+x(14)+x(24)+x(23)+x(34)-1;
My command window is showing these errors
fun = @root2d;
x0 = [0,0,0,0,0,0,0,0,0,0];
x = fsolve(fun,x0)
Index exceeds the number of array elements (10).
Error in root2d (line 2)
F (1) = x(12)^2- x(11)* x(22)*438317.8267;
Error in fsolve (line 248)
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
>> fun = @root2d;
x0 = [0,0];
x = fsolve(fun,x0,options)
Unrecognized function or variable 'options'.
Did you mean:
>> x = fsolve(fun,x0,foptions)
Index exceeds the number of array elements (2).
Error in root2d (line 2)
F (1) = x(12)^2- x(11)* x(22)*438317.8267;
Error in fsolve (line 248)
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
Walter Roberson
2020-2-12
Hmmm, my original code was not acting the same way. Unfortunate that I didn't save it... the second step I had was a lot faster than the vpasolve() is now, but it was solving for positive solutions of the first 10 equations and the extending it to optimize all 11 equations was changing the values.
In the code below, the vpasolve() takes a fair while; it wasn't as much as 5 hours on my system, but it was easily more than an hour (I did not record the time.)
In this version, the location I get back from solving the first 10 equations is kept intact through the fmincon -- to the point where there is no benefit from doing the fmincon.
Now I don't know if I can reconstruct what I did before...
The current modification of the code is below.
X = sym('x', [1 44], 'positive');
assumeAlso(X<1);
F = root2d_set1(X);
vars = symvar(F);
nvars = length(vars);
F10fun = matlabFunction(F(1:10), 'vars', {vars});
x0 = 0.01 * ones(1, nvars);
%unfortunately some entries from fsolve are negative
F10sol = fsolve(F10fun, x0);
%so we pop that into vpasolve with a bounds restriction
%we did not just go directly to vpasolve because it is too slow without a decent guess
%this step takes quite a while
tic
F10_restricted_struct = vpasolve(F(1:10), vars, abs(F10sol));
toc
%vpasolve returns a struct, we need a vector
F10_restricted_cell = struct2cell(F10_restricted_struct);
F10_restricted = double(vertcat(F10_restricted_cell{:})) .';
%how good was the solution?
F10_restricted_fval10 = sum(F10fun(F10_restricted).^2);
display(F10_restricted_fval10);
%now we have a vector of initial values
%proceed to minimize residue for the full set of equations
residue11 = matlabFunction( sum(F.^2), 'vars', {vars});
F10_restricted_fval11 = residue11(F10_restricted);
display(F10_restricted_fval11);
options = optimoptions('fmincon', 'OptimalityTolerance', 1e-25, 'StepTolerance', 1e-20, 'display', 'iter', 'Algorithm','sqp');
[F11min, F11fval] = fmincon(residue11, F10_restricted, [], [], [], [], zeros(1,nvars), [], [], options); %zeros is lb
%F11min should in theory now be a list of values that give a good fit for the entire
%set of 11 equations. Unfortunately in practice some of the values went towards .9
%when they should have been about 1e-2 -- perhaps an ub parameter is called for
display(F11min);
display(F11fval);
Golam Ismot Ara taposhe
2020-2-13
Hi Walter,
Thank you for your time
fmincon() has some [ ], [ ] . what should i input inside this [ ] . sorry for asking lame question. I am not familier with this optimity tolerance/ fmincon
thanks again
Walter Roberson
2020-2-13
Change
[F11min, F11fval] = fmincon(residue11, F10_restricted, [], [], [], [], zeros(1,nvars), [], [], options); %zeros is lb
to
empty = zeros(0,0);
A = empty;
b = empty;
Aeq = empty;
beq = empty;
lb = zeros(1,nvars);
ub = empty;
nlcon = empty;
[F11min, F11fval] = fmincon(residue11, F10_restricted, A, b, Aeq, beq, lb, ub, nlcon, options);
That is exactly equivalent for calling purposes, but it documents more clearly what the various parameters are standing for.
To clarify: the [] in the function call were not placeholders indicating values that you had to fill in: instead [] is the empty array, 0 x 0, and using it signals to MATLAB that you do not want to supply a value for the parameter. For example, [] in the A and b locations indicates that you have no linear constraints to work with.
In some contexts, [] in a MATLAB call indicates that you want the default to be supplied, instead of indicating that you want to skip the parameter. For example, if you had
x = rand(6,5);
reshape(x, 2, [], 5)
would signal to MATLAB that MATLAB should calculate how many elements are in x, and divide by 2 and 5, and fill in what is left in place of the [] -- so 30 / 2 / 5 giving 3, making the call equivalent to reshape(x, 2, 3, 5)
Whether [] signals to a routine to de-activate functionality (like fmincon) or to provide default functionality or values (like reshape) is up to the routine. If you mentally translate it as, "I don't want to bother putting this in" and expecting the routine to do something "sensible" then that will be pretty close.
Golam Ismot Ara taposhe
2020-2-14
hi walter
thank you so much for your help. will be greatful for this
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Signal Reception and Recovery 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)