# Solution to 8 non-linear equations.

7 views (last 30 days)
Amit Darekar on 2 May 2016
Answered: Alex Sha on 29 Nov 2019
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.
Amit Darekar on 5 May 2016
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?

Walter Roberson on 3 May 2016
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]);
Amit Darekar on 24 May 2016
okay walter.

Alex Sha on 29 Nov 2019
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