필터 지우기
필터 지우기

Find the solution of the coupled system of equations

조회 수: 2 (최근 30일)
Arad
Arad 2024년 1월 14일
편집: Sulaymon Eshkabilov 2024년 1월 15일
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
Torsten
Torsten 2024년 1월 14일
편집: Torsten 2024년 1월 14일
Thus with identical expressions for F11 and F12, you want to approximate at the same time 0.86 and -2.3 (similar for F21,F22 and F31,F33) ? That doesn't make sense.
Sam Chak
Sam Chak 2024년 1월 15일
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).

댓글을 달려면 로그인하십시오.

채택된 답변

Sam Chak
Sam Chak 2024년 1월 15일
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)
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
c = 6×1
-0.4775 0.9998 0.1000 0.4791 -0.5947 0.7912
%% 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

추가 답변 (2개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2024년 1월 14일
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
lsqr converged at iteration 3 to a solution with relative residual 4.4e-16.
fprintf('Solutions: x = %f; y = %f; z = %f \n', SOL1')
Solutions: x = 0.157895; y = 1.097744; z = 0.556391
%% 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')
Solutions: x = 0.157895; y = 1.097744; z = 0.556391
SOL3 = linsolve(A,b); % Using linsolve()
fprintf('Solutions: x = %f; y = %f; z = %f \n', SOL3')
Solutions: x = 0.157895; y = 1.097744; z = 0.556391

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2024년 1월 15일
편집: Sulaymon Eshkabilov 2024년 1월 15일
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

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by