MATLAB Answers

Confused about function solve

44 views (last 30 days)
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 Comments
Rik
Rik on 24 Dec 2020
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().

Sign in to comment.

Accepted Answer

Milan Padhiyar
Milan Padhiyar on 28 Dec 2020
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 Comment
yuquan xiao
yuquan xiao on 29 Dec 2020
Thank you very much! It works!

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by