F solve error, how can I fix it?
4 ビュー (過去 30 日間)
古いコメントを表示
Fares Sahli F2HYGC
2020 年 6 月 27 日
コメント済み: Fares Sahli F2HYGC
2020 年 6 月 27 日
I receive the following error: fsolve stopped because the problem appears regular as measured by the gradient,
but the vector of function values is not near zero as measured by the
value of the function tolerance.
My code is as follows:
function F = root2d(x)
F(1) = -(118/121)*x(1)^2-(333/242)*x(2)^2-(196/121)*x(1)*x(2)+(63/121)*x(1)-(361/242)*x(2)-(724/121);
F(2) = (21/121)*x(1)^2+(299/484)*x(2)^2+(80/121)*x(1)*x(2)-(35/242)*x(1)+(391/484)*x(2)-256/121;
end
and the command I use is
fun = @root2d;
x0 = [1,1];
x = fsolve(fun,x0)
I've tried various combinations of x0 but had no effect, can someone please help?
0 件のコメント
採用された回答
Walter Roberson
2020 年 6 月 27 日
The four roots are all complex values. You will not be able to find them using fsolve unless you split the x into two variables each, one for real part and one for imaginary part, OR you use a complex initial value.
その他の回答 (2 件)
John D'Errico
2020 年 6 月 27 日
編集済み: John D'Errico
2020 年 6 月 27 日
There are no real solutions. First, I converted them to a problem that fimplicit can use.
F1 = @(x,y) -(118/121)*x.^2-(333/242)*y.^2-(196/121)*x.*y+(63/121)*x-(361/242)*y-(724/121);
F2 = @(x,y) (21/121)*x.^2+(299/484)*y.^2+(80/121)*x.*y-(35/242)*x+(391/484)*y-256/121;
So the same equations, changed using find and replace in the editor to insure no mistakes were made.
H2 = fimplicit(F2,[-500,500,-500,500]);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/322660/image.jpeg)
Your expression F(2) has a locus of solutions that form a hyperbola. Two hyperbolic arcs, extending to infinity in either direction.
The first however, has no real solutions at all. We can prove that using solve. For example, converting F1 to a symbolic form, if I use solve to find the two roots of the quadratic for X as a function of Y, we will find it involves a square root, of an expression that looks like this:
sqrt(-2.7438*Y^2 - 7.5058*Y - 23.069)
The sub-expression inside the sqrt is negative for ALL values of Y. Therefore all solutions for F1 are complex. It has no real solutions that will make it zero, for any inputs.
syms Y
fplot(-2.7438*Y^2 - 7.5058*Y - 23.069)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/322669/image.jpeg)
As I said, the solution involves the squre root of that value, which is always negative, as a parabolic arc.
As far as having received an error, the message was a correct assessment, although that was actually a warning message, not a true error. There simply are no real solutions to this set of equations.
0 件のコメント
RAVIKIRAN YALAMARTHI
2020 年 6 月 27 日
編集済み: RAVIKIRAN YALAMARTHI
2020 年 6 月 27 日
g = @(x,y) -(118/121)*x.^2 -(333/242)*y.^2 -(196/121)*x.*y +(63/121)*x -(361/242)*y -(724/121);
h = @(x,y) (21/121)*x.^2 +(299/484)*y.^2 +(80/121)*x.*y -(35/242)*x +(391/484)*y -(256/121);
f = @(w) [g(w(1),w(2));h(w(1),w(2))];
w0 = [.1+.1*1i, .1 +.1*1i];
wRoot = fsolve(f,w0)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!