Confused about function solve

조회 수: 1 (최근 30일)
yuquan xiao
yuquan xiao 2020년 12월 24일
댓글: yuquan xiao 2020년 12월 29일
I am trying to use the function "solve" to find out the solution of inequality specified in cond1. Cond1 is shown in the following picture:
However, the solution is not obtained. I also plot the function given by the left of "cond1". Corresponding result shows there exactly exists the feasible solution.
Help!
Thank you in advance!
syms x;
cond1 = (x - 7) * x^2 / 2 - (4 + x)*2 >= 0;
sol = solve(cond1, x, 'ReturnConditions', true);
sol.conditions
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 12월 24일
Convert it to an equality and solve(), and throw away any complex-valued roots. Then for each root, check to see which side of the root the inequality holds on.
Rik
Rik 2020년 12월 24일
Comment posted as flag by yuquan xiao:
Thank you! But I still do not know why such an inequality can not be directly solved with solve().

댓글을 달려면 로그인하십시오.

채택된 답변

Milan Padhiyar
Milan Padhiyar 2020년 12월 28일
Hello Yuquan,
When you are trying to find the root of an inequality equation using the ‘solve’ function, sometimes it is required to give assumptions for the variable to get an explicit solution.
For example, in your query, if we assume that ‘x’ is greater than zero then we can get an explicit solution.
Please find here the modified code:
syms x;
assume(x > 0);
cond1 = (x - 7) * x^2 / 2 - (4 + x)*2 >= 0;
sol = solve(cond1, x, 'ReturnConditions', true);
sol.conditions
Please refer to the below link for example on finding roots of an inequality equation.
Thank You!
  댓글 수: 1
yuquan xiao
yuquan xiao 2020년 12월 29일
Thank you very much! It works!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Equation Solving에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by