フィルターのクリア

What's the best way to check if a system of one equation and one inequality has any solution?

1 回表示 (過去 30 日間)
Hello
I've tried the solve function, but it gave me empty result:
syms x y
>> cond1 = x^2/25 + y^2/25 == 1;
>> cond2 = y <= x-4;
>> conds = [cond1 cond2];
>> sol = solve(conds, [x y], 'ReturnConditions', true);
Tried it on wolframalpha which shows that there is solution : https://www.wolframalpha.com/input/?i=x%5E2%2F25+%2B+y%5E2%2F25+%3D+1+and+y+%3C%3D+x-4
So what do you recommend if I'm not interested in the solutions only want to know if there is any solution or not?

採用された回答

Torsten
Torsten 2019 年 8 月 9 日
Use "fmincon" with an arbitrary objective function (e.g. 0).
  2 件のコメント
Richárd Tóth
Richárd Tóth 2019 年 8 月 9 日
nice, if exitflag=-2 that means that there is no solution, otherwise there is at least one solution, right?
Torsten
Torsten 2019 年 8 月 9 日
Usually yes.
To be sure, just evaluate "nonlcon" for the solution fmincon returns.
ceq should be 0 and c should be <=0.

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

その他の回答 (1 件)

Bruno Luong
Bruno Luong 2019 年 8 月 9 日
編集済み: Bruno Luong 2019 年 8 月 9 日
In your case use first Euler-Lagrange condition gives one solution if it exists
meaning find lambda, x, y, st
[2*x/25, 2*y/25] = lambda * [-1,1]
x^2/25 + y^2/25 = 1
That gives 2 solutuions
(x,y) = sqrt(1/2)*5*[1,-1];
and
(x,y) = sqrt(1/2)*5*[-1,1];
Then check for the inequalities. The first solution meets the inequalities
y <= x-4
This solution does not require any toolbox or numerical calculation. Just pencil and paper. If you take some care with Kuhn Turker condition with the sign of lambda, you can even discard one of the two solutions before the last step.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by