フィルターのクリア

Facing problem in solving simultaneous nonlinear equation with 3 unknowns

1 回表示 (過去 30 日間)
Chu Yan
Chu Yan 2023 年 12 月 4 日
コメント済み: Chu Yan 2023 年 12 月 4 日
x = optimvar('x',3);
eq1 = 0.7133/(1-0.7133)== x(1).*(1-exp(-(1-x(1)).*127./x(2))).*exp(-127/x(3))/(1-x(1));
eq2 = 0.8058/(1-0.8058)== x(1).*(1-exp(-(1-x(1)).*229./x(2))).*exp(-229/x(3))/(1-x(1));
eq3 = 0.7133/(1-0.8708)== x(1).*(1-exp(-(1-x(1)).*421./x(2))).*exp(-421/x(3))/(1-x(1));
prob = eqnproblem;
prob.Equations.eq1 = eq1;
prob.Equations.eq2 = eq2;
prob.Equations.eq3 = eq3;
show(prob)
EquationProblem : Solve for: x eq1: 2.488 == arg_RHS where: arg5 = exp(((-127) ./ x(3))); arg_RHS = (((x(1) .* (1 - exp((((-(1 - x(1))) .* 127) ./ x(2))))) .* arg5) ./ (1 - x(1))); eq2: 4.1493 == arg_RHS where: arg5 = exp(((-229) ./ x(3))); arg_RHS = (((x(1) .* (1 - exp((((-(1 - x(1))) .* 229) ./ x(2))))) .* arg5) ./ (1 - x(1))); eq3: 5.5209 == arg_RHS where: arg5 = exp(((-421) ./ x(3))); arg_RHS = (((x(1) .* (1 - exp((((-(1 - x(1))) .* 421) ./ x(2))))) .* arg5) ./ (1 - x(1)));
x0.x = [0.9 410 8000];
[sol,fval,exitflag] = solve(prob,x0);
Solving problem using fsolve. Solver stopped prematurely. fsolve stopped because it exceeded the function evaluation limit, options.MaxFunctionEvaluations = 3.000000e+02.
disp(sol.x)
1.0e+03 * 0.0010 0.0525 1.1031
Here is my codes and error popout. I cant get the correct ans
Hope other can help me :) thanks in advance
  3 件のコメント
John D'Errico
John D'Errico 2023 年 12 月 4 日
Note that the presence of x1, x2, and x3 both inside and out of exponentials makes this almost certainly one where solve would never have succeeded anyway. With one unknown, the Lambert W and its close cousin, the Wright-Omega function will sometimes succeed. But not with 3 unknowns. So fsolve or lsqnonlin are the only real choices.
Chu Yan
Chu Yan 2023 年 12 月 4 日
yeaa but it seems cannot get the ans also, as shown by @Matt J

サインインしてコメントする。

回答 (1 件)

Matt J
Matt J 2023 年 12 月 4 日
編集済み: Matt J 2023 年 12 月 4 日
What @Dyuman Joshi says is true. However, your equations don't seem to make sense without upper and lower bounds on x. For example, since you are dividing by x(2) and x(3) in certain places, you are clearly assuming them to be bounded away from zero somehow... When I impose bounds, a solution (least squares only) is found without hitting the iteration limit.
x = optimvar('x',3,'Lower',[0,0,0],'Upper',[1,inf,inf]);
eq1 = 0.7133/(1-0.7133)== x(1).*(1-exp(-(1-x(1)).*127./x(2))).*exp(-127/x(3))/(1-x(1));
eq2 = 0.8058/(1-0.8058)== x(1).*(1-exp(-(1-x(1)).*229./x(2))).*exp(-229/x(3))/(1-x(1));
eq3 = 0.7133/(1-0.8708)== x(1).*(1-exp(-(1-x(1)).*421./x(2))).*exp(-421/x(3))/(1-x(1));
prob = eqnproblem;
prob.Equations.eq1 = eq1;
prob.Equations.eq2 = eq2;
prob.Equations.eq3 = eq3;
x0.x = [0.9 410 8000];
[sol,fval,exitflag,output] = solve(prob,x0);
Equation problem has bound constraints. Reformulating as a least squares problem. Solving problem using lsqnonlin. No solution found. lsqnonlin stopped because the last step was ineffective. However, the vector of function values is not near zero, as measured by the value of the function tolerance.
disp(sol.x)
0.9969 40.1046 681.4420
exitflag,output
exitflag =
NoFeasiblePointFound
output = struct with fields:
firstorderopt: 1.5721e-05 iterations: 163 funcCount: 164 cgiterations: 0 algorithm: 'trust-region-reflective' stepsize: 0.4884 bestfeasible: [] constrviolation: [] equationderivative: "forward-AD" solver: 'lsqnonlin' message: 'No solution found.↵↵lsqnonlin stopped because the last step was ineffective. However, the vector of function↵values is not near zero, as measured by the value of the function tolerance. ↵↵<stopping criteria details>↵↵lsqnonlin stopped because the sum of squared function values, r, is changing by less ↵ than options.FunctionTolerance = 1.000000e-06 relative to its initial value.↵However, r = 2.894672e-02, exceeds sqrt(options.FunctionTolerance) = 1.000000e-03.'
  1 件のコメント
Chu Yan
Chu Yan 2023 年 12 月 4 日
alritee, thank you very much, will check back my equations

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumbers and Precision についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by