Find the solution of the coupled system of equations
2 views (last 30 days)
Show older comments
I have several equations with coefficients such as c_i, d_i, etc. I need to obtain the coefficients using the least squares method, subject to the following conditions:
- I would appreciate any help in determining these coefficients using the least squares method given the above constraints.
- Additionally, what would be a better or more efficient way to obtain these coefficients?
Thank you.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
F11 = c00 + d00 - (2*c2)/3 - (2*c5)/9 + ((4*c4)/7 + 4*(c1) + 3*(c3) - 6*c1*c3 + (16*c1*c4)/7 - (12*c3*c4)/7 + (c00 - d00)^2)^(1);
F12 = c00 + d00 - (2*c2)/3 - (2*c5)/9 - ((4*c4)/7 + 4*(c1) + 3*(c3) - 6*c1*c3 + (16*c1*c4)/7 - (12*c3*c4)/7 + (c00 - d00)^2)^(1);
F21 = c00 + d00 + 2*c2 + (2*c5)/3 + ((24*c4)/7 + 12*(c1) + 3*(c3) + 18*c1*c3 + (144*c1*c4)/7 + (36*c3*c4)/7 + (c00 - d00)^2)^(1);
F22 = c00 + d00 + 2*c2 + (2*c5)/3 - ((24*c4)/7 + 12*(c1) + 3*(c3) + 18*c1*c3 + (144*c1*c4)/7 + (36*c3*c4)/7 + (c00 - d00)^2)^(1);
F31 = c00 + d00 - c2 + (2*c5)/3 + (4*(c1^20282)^(1) - (c1*c3)/50706 + 4*(c3^2/8112)^(1) + (c00 - d00)^2)^(1);
F33 = c00 + d00 - c2 + (2*c5)/3 - (4*(c1^20282)^(1) - (c1*c3)/50706 + 4*(c3^2/8112)^(1) + (c00 - d00)^2)^(1);
F11 = 0.86;
F12 = -2.3;
F21 = 6.8;
F22 = -6.3;
F31 = 0.3;
F32 = -0.4;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 Comments
Sam Chak
on 15 Jan 2024
Hi @Torsten, they do look like 3 pairs of identical equations to me at first glance. However, when I displayed them in code format (horizontal single line), you will see the plus-minus signs in each pair.
Another issue is that the system is considered underdetermined because there are fewer equations (6: F11, F12, F21, F22, F31, F32) than unknown variables (7: c00, d00, c1, c2, c3, c4, c5).
Accepted Answer
Sam Chak
on 15 Jan 2024
Hi @Arad
If you set a specific value for the variable d00, the system of 6 nonlinear equations can be solved using the fsolve() command.
fun = @system;
c0 = ones(6, 1);
c = fsolve(fun, c0)
%% A system of nonlinear equations
function F = system(c)
% 6 unknown variables
c00 = c(1);
c1 = c(2);
c2 = c(3);
c3 = c(4);
c4 = c(5);
c5 = c(6);
% Constants
d00 = 0; % <-- assumed, find out this value
F1 = 0.86;
F2 = -2.3;
F3 = 6.8;
F4 = -6.3;
F5 = 0.3;
F6 = -0.4;
% 6 Nonlinear equations
F(1) = c00 + d00 - (2*c2)/3 - (2*c5)/9 + ((4*c4)/7 + 4*(c1) + 3*(c3) - 6*c1*c3 + (16*c1*c4)/7 - (12*c3*c4)/7 + (c00 - d00)^2)^(1) - F1;
F(2) = c00 + d00 - (2*c2)/3 - (2*c5)/9 - ((4*c4)/7 + 4*(c1) + 3*(c3) - 6*c1*c3 + (16*c1*c4)/7 - (12*c3*c4)/7 + (c00 - d00)^2)^(1) - F2;
F(3) = c00 + d00 + 2*c2 + (2*c5)/3 + ((24*c4)/7 + 12*(c1) + 3*(c3) + 18*c1*c3 + (144*c1*c4)/7 + (36*c3*c4)/7 + (c00 - d00)^2)^(1) - F3;
F(4) = c00 + d00 + 2*c2 + (2*c5)/3 - ((24*c4)/7 + 12*(c1) + 3*(c3) + 18*c1*c3 + (144*c1*c4)/7 + (36*c3*c4)/7 + (c00 - d00)^2)^(1) - F4;
F(5) = c00 + d00 - c2 + (2*c5)/3 + (4*(c1^20282)^(1) - (c1*c3)/50706 + 4*(c3^2/8112)^(1) + (c00 - d00)^2)^(1) - F5;
F(6) = c00 + d00 - c2 + (2*c5)/3 - (4*(c1^20282)^(1) - (c1*c3)/50706 + 4*(c3^2/8112)^(1) + (c00 - d00)^2)^(1) - F6;
end
0 Comments
More Answers (2)
Sulaymon Eshkabilov
on 14 Jan 2024
Applying the LS method for solving such systems is relatively straight forward, e.g.:
b1 = 3x + 2y-3z
b2 = 2x-y+5z
b3 = -3x+6y-2z
b1 = 1; b2 = 2; b3 = 5;
% Step 1. Define A matrix:
A = [3 2 -3; 2 -1 5; -3 6 -2];
b1 = 1; b2 = 2; b3 = 5;
% Step 2. Define b matrix:
b = [b1;b2;b3];
% Step 3. Determine solution tolerance
tol = 1e-15;
% Step 4. Solve the system of [A]*{X} = [b] where [A] is coefficients, [b]
% is the column matrix (also called a system response), {X} is unknowns
% How to apply LS method:
SOL1 = lsqr(A,b, tol); % Using the least squares method
fprintf('Solutions: x = %f; y = %f; z = %f \n', SOL1')
%% NB: \ operator or linsolve() can be also used for such systems:
SOL2 = A\b; % Using backslash (\)
fprintf('Solutions: x = %f; y = %f; z = %f \n', SOL2')
SOL3 = linsolve(A,b); % Using linsolve()
fprintf('Solutions: x = %f; y = %f; z = %f \n', SOL3')
0 Comments
Sulaymon Eshkabilov
on 15 Jan 2024
Edited: Sulaymon Eshkabilov
on 15 Jan 2024
The accepted answer is NOT the least squares method as mentioned in the question itself.
F11 = 0.86;
F12 = -2.3;
F21 = 6.8;
F22 = -6.3;
F31 = 0.3;
F32 = -0.4;
A = [1, 1, 0, 0, -2/3, -2/9;
1, 1, 0, 0, -2/3, -2/9;
1, 1, 2, 0, 0, 2/3;
1, 1, 2, 0, 0, 2/3;
1, 1, -1, 0, -1, 2/3;
1, 0, 0, 0, 0, 0;];
B = [F11; F12; F21; F22; F31; F32];
tol = 1e-7;
SOLUTION = lsqr(A,B, tol) % Using the least squares method
0 Comments
See Also
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!