Problems with Solving inequalities in matlab

조회 수: 11 (최근 30일)
Erik Börjesson
Erik Börjesson 2021년 1월 1일
댓글: Torsten 2022년 12월 8일
Hello, I have a question on how to solve in matlab.
I have tried the following code:
syms x;
f = (sqrt(x+1)-1)/x;
sol = solve(f<(sqrt(2)-1)/2,x);
but I only get the following error:
sol =
Empty sym: 0-by-1
Warning: Unable to find explicit solution. For options, see help.
Is there someone out there who could help?

답변 (2개)

John D'Errico
John D'Errico 2021년 1월 1일
편집: John D'Errico 2021년 1월 1일
That is not an error. It is a warning message, telling you there is a problem with what you have posed to solve.
There is no explicit solution found, because there are infinitely many solutions.
syms x;
f = (sqrt(x+1)-1)/x;
fplot(f,[-5,100])
yline((sqrt(2)-1)/2);
A solution exists for ALL x, such that the curve is less than the horizontal line drawn. That is to say, whenever x strictly exceeds
xmin = solve(f == (sqrt(2)-1)/2)
xmin = 
vpa(xmin)
ans = 
13.65685424949237156668015607393
  댓글 수: 3
Matthew Cassini
Matthew Cassini 2022년 12월 8일
I don't get why it doesn't give the minimum or maximum value that is a solution, as that is normally how you would solve an inequality. If given 2x > 1 and asked to find x you would say x > 1/2, not theres infinitely many solutions.
Torsten
Torsten 2022년 12월 8일
You get the "cut points" of your inequality if you solve it as an equation as John D'Errico did.
syms x
f = 2*x==1;
solve(f)
ans = 

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


Walter Roberson
Walter Roberson 2021년 1월 2일
solve() is pretty inconsistent as to whether it can handle inequalities. When it succeeds and you do not use returnconditions then it picks a representative solution instead of showing the inequality boundaries. For example if the range of solution was 3 to 15 it might say 9, but if it were -1 to 15 it might say 0

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by