Solve: Solution not satisfying the equation

1 回表示 (過去 30 日間)
Ankush
Ankush 2014 年 5 月 25 日
コメント済み: A Jenkins 2014 年 5 月 28 日
I am trying to solve 2 equations in the code
a = [-0.0008333 -0.025 -0.6667 -20];
length_OnePart = 7.3248;
xi = -6.4446;
yi = -16.5187;
syms x y
[sol_x,sol_y] = solve(y == poly2sym(a), ((x-xi)^2+(y-yi)^2) == length_OnePart^2,x,y,'Real',true);
sol_x = sym2poly(sol_x);
sol_y = sym2poly(sol_y);
The sets of solution it is giving are (-23.9067,-8.7301) and (11.0333,-24.2209) which are not even satisfying the equation of circle. Please help me to rectify the problem.

採用された回答

A Jenkins
A Jenkins 2014 年 5 月 27 日
Sometimes you can reshape the problem to make things easier for the solver. In this case, center the circle at zero by redefining your variables such that: xa=x-xi; ya=y-yi;
a = [-0.0008333 -0.025 -0.6667 -20];
length_OnePart = 7.3248;
xi = -6.4446;
yi = -16.5187;
syms xa ya
[sol_xa,sol_ya] = solve(ya+yi==subs(poly2sym(a),'x',xa+xi), ((xa)^2+(ya)^2) == length_OnePart^2,xa,ya,'Real',true);
sol_x=sol_xa+xi
sol_y=sol_ya+yi
______________________
sol_x =
-13.182825373861454619370838716408
0.00002145831413371390464567553686047
sol_y =
-13.646590348358951818881695033728
-20.000014306269544436430325843024
  2 件のコメント
Ankush
Ankush 2014 年 5 月 27 日
編集済み: Ankush 2014 年 5 月 27 日
@Jenkins: Thanks alot. But it seems we are solving same set of equations in both the cases. So why is it not giving answer with the method I above mentioned and it is giving correct result here?
A Jenkins
A Jenkins 2014 年 5 月 28 日
Circles are ugly things to numeric solvers, since they have multiple solutions of y for each value of x, and they have points where the derivative goes to infinity, etc. If you have ever tried to use Newton's Method by hand on something without continuous second derivatives, you will get the idea of how much a headache it can be.
I always check the solutions from solve(), and if it had problems, I try to reshape the equations somehow to give it a better chance.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by