Solving an equation system with lsqnonlin gives wrong/insufficient solution

3 views (last 30 days)
I want so solve a system of 6 equations with lsqnonlin. The solution is not satisfactory, as estimated values are too far from expected and sufficient values.
I have tried to improve the solving by changing the initial values, Algorithm and Step Tolerance - without any success.
Can anyone help?
A = 3.6855e03;
B = 7.6168e03;
C = 1.0747e08;
D = 0.0013;
E = 5.4871e-04;
F = 2.2370e-05;
p_sys = 3e05;
fun=@(y)[D - y(1) - y(4); % 1
E - y(2) - y(5); % 2
F - y(3) - y(6); % 3
1 - (A*(y(1)/(y(1)+y(2)+y(3))))/((y(4)/(y(4)+y(5)+y(6)))*p_sys); % 4
1 - (B*(y(2)/(y(1)+y(2)+y(3))))/((y(5)/(y(4)+y(5)+y(6)))*p_sys); % 5
1 - (C*(y(3)/(y(1)+y(2)+y(3))))/((y(6)/(y(4)+y(5)+y(6)))*p_sys)]; % 6
y0 = [D, E, F, D, E, F];
lb = [0 0 0 0 0 0];
ub = [D, E, F, D, E, F];
lsg = lsqnonlin(fun,y0,lb,ub);
check_1 = D - lsg(1,1) - lsg(1,4);
check_2 = E - lsg(1,2) - lsg(1,5);
check_3 = F - lsg(1,3) - lsg(1,6);
check_4 = 1-(A*lsg(1,1)/(lsg(1,1)+lsg(1,2)+lsg(1,3)))/((lsg(1,4)/(lsg(1,4)+lsg(1,5)+lsg(1,6)))*p_sys);
check_5 = 1-(B*(lsg(1,2)/(lsg(1,1)+lsg(1,2)+lsg(1,3))))/((lsg(1,5)/(lsg(1,4)+lsg(1,5)+lsg(1,6)))*p_sys);
check_6 = 1-(C*(lsg(1,3)/(lsg(1,1)+lsg(1,2)+lsg(1,3))))/((lsg(1,6)/(lsg(1,4)+lsg(1,5)+lsg(1,6)))*p_sys);
  3 Comments
Miriam Weiß
Miriam Weiß on 28 Sep 2020
Hello Mario,
please excuse my late reply and thank you for your answer.
A good solution was to change the first three equations:
fun=@(y)[(D - y(1) - y(4))*10000; % 1
(E - y(2) - y(5))*10000; % 2
(F - y(3) - y(6))*10000; % 3
1 - (A*(y(1)/(y(1)+y(2)+y(3))))/((y(4)/(y(4)+y(5)+y(6)))*p_sys); % 4
1 - (B*(y(2)/(y(1)+y(2)+y(3))))/((y(5)/(y(4)+y(5)+y(6)))*p_sys); % 5
1 - (C*(y(3)/(y(1)+y(2)+y(3))))/((y(6)/(y(4)+y(5)+y(6)))*p_sys)]; % 6

Sign in to comment.

Answers (1)

Matt J
Matt J on 29 Aug 2020
In addition to what Mario said, the first 3 equations can be used to eliminate y(4:6). With only 3 unknowns it would be computationally feasible to sample the objective function on say a 500x500x500 search grid of values for y(1:3). This would give you a decent idea of where to choose your initial guess.

Categories

Find more on Systems of Nonlinear Equations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!