Facing problem in solving simultaneous nonlinear equation with 3 unknowns

3 views (last 30 days)
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 Comments
John D'Errico
John D'Errico on 4 Dec 2023
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.

Sign in to comment.

Answers (1)

Matt J
Matt J on 4 Dec 2023
Edited: Matt J on 4 Dec 2023
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.'

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!