Solution to 8 non-linear equations.

20 ビュー (過去 30 日間)
Amit Darekar
Amit Darekar 2016 年 5 月 2 日
回答済み: Alex Sha 2019 年 11 月 29 日
I want to solve system of non-linear equations. I have total 8 equations with 8 unknowns. I only know we can sole non-linear equations in matlab by command called fsolve but i am not able to solve in matlab. I am attahching one document which gives these all equations. I have already asked solution for these equations last week but i guess due to complexity of equations no one has tried to solve it so I have simplified equations by replacing some terms with constants. I am providing two attahcments one of which is pdf where there are total 8 equations which are to be solved for the unknown variables as x(1) x(2) upto x(8) which are marked as red and all other variables are known whereas in second attahcment i have written all these equations in matlab. So i request you people to go through these attahcments and please give some idea on syntax to solve these equations.
  19 件のコメント
Walter Roberson
Walter Roberson 2016 年 5 月 5 日
Each equation has a left hand side and a right hand side. If you take (lhs)-(rhs) then you get the amount of mismatch between the two sides: if the two sides were equal then the difference would be 0. Now take the sum of squares of these partial resides, to get an expression for the total residue. Again, if you had perfect match on all of the equations then the total residue would be 0.
Now take this sum-of-squares residue formula and mininimize its output over the input parameter space. A perfect match would give 0, and it is not possible for negative totals to occur if all of the terms are real-valued. Your best match, the location of a root, is the place where the sum-of-squares residue is as small as you can get.
This is a standard formulation for solving such problems, non-linear least squares.
Finding the global minimum is not easy. There are various strategies you can use, which are implemented by the Global Optimization Toolbox. I wrote my own global minimizer instead, that combines brute force with fminsearch. I am continuing to improve the code, and I am not ready to release it.
Amit Darekar
Amit Darekar 2016 年 5 月 5 日
okay. So if we dont find global minimum, will it be accurate soluations, or we always have to calculate global minimum because i dont know how to do that. and can you provide syntax in answer for the method of non-linear least squares which can give mi output?

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2016 年 5 月 3 日
Getting you further: if you have the symbolic toolbox then:
syms a1 a2 a3 a4 a5 a6 a7 a8 g1 g2 g3 g4 g5 g6 g7 g8 k1 k11 k12 k13 k14 k2 k3 k4 k5 x1 x2 x3 x4 x5 x6 x7 x8
Q = @(v) sym(v); %converts to rational
eqn1 = a1*(g1-x1) == k1*x1*x2/((k11*x1+k12*x2+1)^2*(k13*x1^2*x5^2+1)*(k14*x8+1))+k4*x1*x8;
eqn2 = a2*(g2-x2) == Q(.5)*k1*x1*x2/((k11*x1+k12*x2+1)^2*(k13*x1^2*x5^2+1)*(k14*x8+1))+Q(4.5)*k2*x2*x5/((k11*x1+k12*x2+1)^2*(k13*x1^2*x5^2+1)*(k14*x8+1))+5*k3*x2*x6/((k11*x1+k12*x2+1)^2*(k13*x1^2*x5^2+1)*(k14*x8+1));
eqn3 = a3*(g3-x3) == k1*x1*x2/((k11*x1+k12*x2+1)^2*(k13*x1^2*x5^2+1)*(k14*x8+1))+3*k2*x2*x5/((k11*x1+k12*x2+1)^2*(k13*x1^2*x5^2+1)*(k14*x8+1))+3*k3*x2*x6/((k11*x1+k12*x2+1)^2*(k13*x1^2*x5^2+1)*(k14*x8+1))+k4*x1*x8+3*k5*x6*x8;
eqn4 = a4*(g4-x4) == 3*k2*x2*x5/((k11*x1+k12*x2+1)^2*(k13*x1^2*x5^2+1)*(k14*x8+1))+4*k3*x2*x6/((k11*x1+k12*x2+1)^2*(k13*x1^2*x5^2+1)*(k14*x8+1))+3*k5*x6*x8;
eqn5 = a5*(g5-x5) == k2*x2*x5/((k11*x1+k12*x2+1)^2*(k13*x1^2*x5^2+1)*(k14*x8+1))+3*k5*x6*x8;
eqn6 = a6*(g6-x6) == k3*x2*x6/((k11*x1+k12*x2+1)^2*(k13*x1^2*x5^2+1)*(k14*x8+1));
eqn7 = a7*(g7-x7) == Q(.5)*k4*x1*x8+Q(4.5)*k5*x6*x8;
eqn8 = a8*(g8-x8) == k4*x1*x8+k5*x6*x8
eqns = [eqn1, eqn2, eqn3, eqn4, eqn5, eqn6, eqn7, eqn8];
va1 = Q(4.8994),
va2 = Q(5.143),
va3 = Q(4.09248);
va4 = Q(6.264);
va5 = Q(3.7584);
va6 = Q(2.81184);
va7 = Q(5.568);
va8 = Q(4.176);
vg1 = Q(0.00001);
vg2 = Q(0.001);
vg3 = Q(0);
vg4 = Q(0);
vg5 = Q(0.01);
vg6 = Q(0.008);
vg7 = Q(0.89);
vg8 = Q(0.01899);
vk1 = Q(6.4721*10^33);
vk2 = Q(6.86457*10^37);
vk3 = Q(3.66776*10^44);
vk4 = Q(3.76152*10^18);
vk5 = Q(2.61193*10^25);
vk11 = Q(1612.404956);
vk12 = Q(6925.140687);
vk13 = Q(2.56699*10^17);
vk14 = Q(1.21445*10^11);
neweqns = subs(eqns, [a1 a2 a3 a4 a5 a6 a7 a8 g1 g2 g3 g4 g5 g6 g7 g8 k1 k11 k12 k13 k14 k2 k3 k4 k5], [va1 va2 va3 va4 va5 va6 va7 va8 vg1 vg2 vg3 vg4 vg5 vg6 vg7 vg8 vk1 vk11 vk12 vk13 vk14 vk2 vk3 vk4 vk5]);
  60 件のコメント
Walter Roberson
Walter Roberson 2016 年 5 月 24 日
編集済み: Walter Roberson 2016 年 5 月 24 日
Working further with the 4-variable reduced version (by solving for the 4 variables that are easy to get rid of), I did more work with simulannealbnd() with a hybrid function specified. It turns out that the hybrid function result is not used to inform the code about the direction to move, in current versions. I created a support case and asked for an enhancement; perhaps it will show up some day.
I continued on to make a private copy of the simulannealbnd routines and added the enhancement of having the hybrid call inform the code about the direction to move. With that in place, I had a fair success in starting from random points and getting dececently fast convergence to a solution when the variables is in the right quadrant. It is not an all-in-one solution but it might be possible to connect it with a MultiStart process. I have a better understanding of how simulannealbnd works now, but I have no idea yet what parameters to use to allow it to converge reasonably without the hack I put in.
So far I have identified at least 9 different sets of roots, including two that are very close together but not identical. I might have identified a 10th as well, close to one of the other ones, but it is possible that it is the same "basin" and just not as optimized as much. One of the solutions that I discovered has x8 in a very different place than all of the other solutions.
So far only one of the solutions for x2, x3, x5, x8 has all of the quantities positive; I have not back-substituted to figure out whether the other values would also come out positive.
Is it still the case that you want all of the quantities to be constrained to be non-negative? That might prove to be difficult to find -- that combination I perhaps found is the only one I have seen so far and it has only shown up once; x8 in particular really wants to be negative.
My next step would be to investigate patternsearch() to see if it can do something for this situation.
Amit Darekar
Amit Darekar 2016 年 5 月 24 日
okay walter.

サインインしてコメントする。


Alex Sha
Alex Sha 2019 年 11 月 29 日
for the case:
a1= 4.8994;
a2=5.143;
a3= 4.09248;
a4= 6.264;
a5= 3.7584;
a6= 2.81184;
a7= 5.568;
a8=4.176;
g1=0.00001;
g2=0.001;
g3=0;
g4=0;
g5=0.01;
g6=0.008;
g7=0.89;
g8= 0.01899;
k1=6.4721*10^33;
k2=6.86457*10^37;
k3=3.66776*10^44;
k4=3.76152*10^18;
k5=2.61193*10^25;
k11=1612.404956;
k12=6925.140687;
k13=2.56699*10^17;
k14=1.21445*10^11;
results:
x1: 1.00000104645732E-5
x2: 2.7660633694392E-41
x3: -0.058886670079626
x4: -0.0386368328164341
x5: -0.0532999996306495
x6: 0.00763418928185147
x7: 0.825908750010556
x8: 3.97704950889303E-25
for the case:
a1 = 4.8994;
a2 = 5.143;
a3 = 4.09248;
a4 = 6.264;
a5 = 3.7584;
a6 = 2.81184;
a7 = 5.568;
a8 = 4.176;
k1 = 6.4721*10^33;
k2 = 6.86457*10^37;
k3 = 3.66776*10^44;
k4 = 3.76152*10^18;
k5 = 2.61193*10^25;
k11 =1612.404956;
k12 =6925.140687;
k13 =2.56699*10^17;
k14 =1.21445*10^11;
g1 = 1;
g2 = 10;
g3 = 0;
g4 = 0;
g5 = 100;
g6 = 20;
g7 = 890;
g8 = 1.81;
The results:
x1: 1.00000025803197
x2: 1.01251539939794E-17
x3: 13.0809883376179
x4: 10.1883258496752
x5: 93.9666637847973
x6: 16.341900663404
x7: 896.108749942814
x8: 1.77082221063051E-26

カテゴリ

Help Center および File ExchangeLinear Least Squares についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by