Unable to solve nonlinear equation using fsolve as the message shows No solution found

7 ビュー (過去 30 日間)
function F = FeMnC660newuipffc(x)
F(1) =-9.135789053E+00-log(x(1))+166.2509975*x(1)+5.84074229*x(2)+(-166.2509975*x(1)^2)/2-5.84074229*x(1)*x(2)+(-19.52527074*x(2)^2)/2;
F(2) =-3.51500942E+00-log(x(2)) +5.84074229*x(1)+19.52527074*x(2)+(-166.2509975*x(1)^2)/2-5.84074229*x(1)*x(2)+(-19.52527074*x(2)^2)/2;
end
unable to solve this equation using fsolve as the message shows
No solution found.
fsolve 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.
Kindly help me out

採用された回答

John D'Errico
John D'Errico 2023 年 2 月 6 日
編集済み: John D'Errico 2023 年 2 月 6 日
I would not be at all surprised if it was poor starting values that might cause the problem.
syms x y
F1 = -9.135789053E+00-log(x)+166.2509975*x+5.84074229*y+(-166.2509975*x^2)/2-5.84074229*x*y+(-19.52527074*y^2)/2;
F2 =-3.51500942E+00-log(y) +5.84074229*x+19.52527074*y+(-166.2509975*x^2)/2-5.84074229*x*y+(-19.52527074*y^2)/2;
fimplicit(F1,[0,5])
hold on
fimplicit(F2,[0,5])
xlabel x
ylabel y
It is the intersection of the red and blue curves where you will find a solution. There appear to be three such intersections, and a third non-solution happens at x=y=0. but that point is a singularity, not a true solution. The other solutions at x==0 and y==0 are also problematic.
But fsolve should have no real problem in finding the solution as found by @Matt J, as long as you give it reasonable starting values. A problem may be that if you are not careful, is if fsolve ever tries to go outside of the legal search space where x>0 and y>0, then fsolve will fail.
See that even vpasolve fails to find a happy solution, if you allow it to choose its own starting values.
[X,Y] = vpasolve(F1,F2,[x,y])
X = 
Y = 
However, other starting values seem to get to a happy place.
[X,Y] = vpasolve(F1,F2,[x,y],[1 1])
X = 
0.15522119616222286695786155139462
Y = 
1.5782427803358099006829260487597
So it was very likely a poor choice of starting values that caused the fsolve failure for @Vikash Sahu.
Can the problem be modified to avoid the issue completely? Well, yes. Replace each of x and y with the squares of two variables.
syms xx yy
G1 = subs(F1,[x,y],[xx^2, yy^2]);
G2 = subs(F2,[x,y],[xx^2, yy^2]);
[XX,YY] = vpasolve(G1,G2,[xx,yy])
XX = 
YY = 
1.256281330091237923863200963915
X = XX^2
X = 
0.15522119616222286695786155139462
V = YY^2
V = 
1.5782427803358099006829260487597
Now fsolve should be more robust too, even with random starting values, though it still might get trapped in one of the "solutions" at x==0 or y==0.

その他の回答 (2 件)

Alan Stevens
Alan Stevens 2023 年 2 月 6 日
編集済み: Alan Stevens 2023 年 2 月 6 日
fminsearch makes a reasonable attempt:
F1 = @(a,b) -9.135789053E+00-log(a)+166.2509975*a+5.84074229*b+...
-166.2509975*a^2/2-5.84074229*a*b-19.52527074*b^2/2;
F2 = @(a,b) -3.51500942E+00-log(b)+5.84074229*a+19.52527074*b+...
-166.2509975*a^2/2-5.84074229*a*b-19.52527074*b^2/2;
F = @(x) norm(F1(x(1),x(2))) + norm(F2(x(1),x(2)));
opt = optimset('TolFun', 1E-15);
x0 = [1, 1];
[x, fval] = fminsearch(F, x0, opt);
disp(x)
0.1552 1.5782
disp(fval)
7.1054e-15

Matt J
Matt J 2023 年 2 月 6 日
編集済み: Matt J 2023 年 2 月 6 日
You haven't shown how the optimization was executed. fsolve appears to work fine below:
opt = optimoptions('fsolve', 'FunctionTol',1E-15,'OptimalityTol',1e-15,'StepTol',1e-15);
x0 = 100*rand(1,2);
[x, fval] = fsolve(@FeMnC660newuipffc, x0, opt)
Equation solved, solver stalled. fsolve stopped because the relative size of the current step is less than the value of the step size tolerance squared and the vector of function values is near zero as measured by the value of the function tolerance.
x = 1×2
0.1552 1.5782
fval = 1×2
1.0e-14 * 0.3553 0
function F = FeMnC660newuipffc(x)
F(1) =-9.135789053E+00-log(x(1))+166.2509975*x(1)+5.84074229*x(2)+(-166.2509975*x(1)^2)/2-5.84074229*x(1)*x(2)+(-19.52527074*x(2)^2)/2;
F(2) =-3.51500942E+00-log(x(2)) +5.84074229*x(1)+19.52527074*x(2)+(-166.2509975*x(1)^2)/2-5.84074229*x(1)*x(2)+(-19.52527074*x(2)^2)/2;
end

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by