Matlab continues to run and wont stop. Is my solution to complicated?

2 ビュー (過去 30 日間)
Meslech Bellay
Meslech Bellay 2018 年 8 月 3 日
コメント済み: Walter Roberson 2018 年 8 月 4 日
Here is my code
syms x y
a= 13;
b= 5;
c=2;
d=5;
p = 4*(a+b+c+d);
f(x,y)= (p./((3*x+a).^2+(3*y+c).^2+(a+c)))...
-(2*p./((3*x-b).^2+(3*y+d).^2+(b+d)))...
-(3*p./((3*x+a).^2+(3*y-d).^2+(a+d)))...
+(4*p./((3*x-b).^2+(3*y-c).^2+(b+c)));
ezsurf(f,[-10,10])
title('My land');
xlabel('X- Axis');
ylabel('Y-Axis');
colormap(jet)
hold off
fx= diff(f,x);
fy=diff(f,y);
[a,b]= solve(fx,fy);
double([a,b])

回答 (2 件)

Aquatris
Aquatris 2018 年 8 月 4 日
編集済み: Aquatris 2018 年 8 月 4 日
Try doing this in your code;
fx = simplify(expand(diff(f,x)));
fy = simplify(expand(diff(f,x)));
I think in your code, the expression for fx is too complicated without the simplify(expand()) command. When I replaced that part, it was able to solve in a second or so.
  3 件のコメント
Meslech Bellay
Meslech Bellay 2018 年 8 月 4 日
hey aquartis, did this actually work for you? because my matlab is still timing out when trying.
Aquatris
Aquatris 2018 年 8 月 4 日
It worked. I used Matlab online. However as Walter commented, this might not be what you want.

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


Walter Roberson
Walter Roberson 2018 年 8 月 4 日
If you try stepwise elimination of either fx or fy with respect to either x or y, you will get a solution involving the roots of a polynomial of order 12. With each of them being order 12, MATLAB has to work through 144 different roots -- but it cannot express them in full because there is not typically any closed form expression for any order above order 4. So this is not an easy equation to solve.
Unfortunately proceeding numerically does not work well in this case: the loss of precision that goes along with working with floating point numbers can result in somewhat negative values being calculated from fx^2+fy^2 even though algebraically that should not be possible.
You appear to be trying to calculate all of the extrema and inflections of f(x,y), including the complex ones.
If you are just looking for the global minima, then it is at about -4.34915949152492498, 1.72539721154691694
  2 件のコメント
Meslech Bellay
Meslech Bellay 2018 年 8 月 4 日
so this mean it is essentially not possible to find the solution via matlab bc its too complex?
Walter Roberson
Walter Roberson 2018 年 8 月 4 日
Probably.

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

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by