Solve a System of five non linear equation
3 ビュー (過去 30 日間)
古いコメントを表示
I want to solve numerically a system of five non linear equations. I use the solve equation but instead of numerical expressions for the parameters, matlab returns a symbol for each parameter. For the parameters a1, mu1, a2, mu2, and w1 I need them to be positive and real, also 0<=w1<=1. My question is, can the following system return numerical expressions for the parameters of interest? If so, is there an option in the solve() function that I need to include?
C1=2.083333333333334;
C2=5.514861889710719;
C3=15.477300064209032;
C4=44.665706966377420;
C5=1.313098986326810e+02;
syms a1 mu1 a2 mu2 w1
E_i=[( w1*gamma(mu1+1/a1)/( ( mu1^(1/a1) )*gamma(mu1) ) )...
+( (1-w1)*gamma(mu2+1/a2)/( ( mu2^(1/a2) )*gamma(mu2) ) )==C1,...
( w1*gamma(mu1+2/a1)/( ( mu1^(2/a1) )*gamma(mu1) ) )...
+( (1-w1)*gamma(mu2+2/a2)/( ( mu2^(2/a2) )*gamma(mu2) ) )==C2,...
( w1*gamma(mu1+3/a1)/( ( mu1^(3/a1) )*gamma(mu1) ) )...
+( (1-w1)*gamma(mu2+3/a2)/( ( mu2^(3/a2) )*gamma(mu2) ) )==C3,...
( w1*gamma(mu1+4/a1)/( ( mu1^(4/a1) )*gamma(mu1) ) )...
+( (1-w1)*gamma(mu2+4/a2)/( ( mu2^(4/a2) )*gamma(mu2) ) )==C4,...
( w1*gamma(mu1+5/a1)/( ( mu1^(5/a1) )*gamma(mu1) ) )...
+( (1-w1)*gamma(mu2+5/a2)/( ( mu2^(5/a2) )*gamma(mu2) ) )==C5
];
assume(a1>0 & mu1>0 & a2>0 & mu2>0 & 0<=w1 & w1<=1) % assumptions to narrow results
S=solve(E_i,'Real',true,'ReturnConditions', true);
5 件のコメント
採用された回答
John D'Errico
2022 年 1 月 27 日
編集済み: John D'Errico
2022 年 1 月 27 日
E_i=[( w1*gamma(mu1+1/a1)/( ( mu1^(1/a1) )*gamma(mu1) ) )+( (1-w1)*gamma(mu2+1/a2)/( ( mu2^(1/a2) )*gamma(mu2) ) )==C1,...
( w1*gamma(mu1+2/a1)/( ( mu1^(2/a1) )*gamma(mu1) ) )+( (1-w1)*gamma(mu2+2/a2)/( ( mu2^(2/a2) )*gamma(mu2) ) )==C2,...
( w1*gamma(mu1+3/a1)/( ( mu1^(3/a1) )*gamma(mu1) ) )+( (1-w1)*gamma(mu2+3/a2)/( ( mu2^(3/a2) )*gamma(mu2) ) )==C3,...
( w1*gamma(mu1+4/a1)/( ( mu1^(4/a1) )*gamma(mu1) ) )+( (1-w1)*gamma(mu2+4/a2)/( ( mu2^(4/a2) )*gamma(mu2) ) )==C4,...
( w1*gamma(mu1+5/a1)/( ( mu1^(5/a1) )*gamma(mu1) ) )+( (1-w1)*gamma(mu2+5/a2)/( ( mu2^(5/a2) )*gamma(mu2) ) )==C5
];
numel(E_i)
ans =
5
So 5 equations, in the 5 unknowns a1,a2,mu1,mu2,w1.
S=vpasolve(E_i)
S =
struct with fields:
a1: [0×1 sym]
a2: [0×1 sym]
mu1: [0×1 sym]
mu2: [0×1 sym]
w1: [0×1 sym]
But nothing insures that a solution always exists for any set of equations you may choose to pose. vpasolve did not find one. Nor did solve. Solve just returned a result that effectively said the solution is the solution to the system of equations listed in the conditions. vpasolve tried, but gave up.
In fact, I would postulate that certainly there will be no explicit (algebraic) solution that solve could find. you cannot plead with a solver. You cannot demand that it do better.
That does not mean no solution exists, only that a numerical solver was unable to find it based on the default starting values. It might have been successful, it you give it better guesses (than the default) for those starting values.
0 件のコメント
その他の回答 (1 件)
William Rose
2022 年 1 月 27 日
You can get numeric values for the unknown quatities by using fsolve() and by not using "syms". Rewrite your equations, and instead of uing a1, mu1, a2, mu2, w1, use x(1:5). Use fsolve to estimate the vector of unknowns, x. See the help for fsolve().
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Assumptions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!