필터 지우기
필터 지우기

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.'

카테고리

Help CenterFile Exchange에서 Numbers and Precision에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by