vpasolve does not handle inequalities correctly
이전 댓글 표시
Hello MATLAB community,
I am currently experiencing a problem with vpasolve's handling of inequalities, mainly them not working. I am running the following on Windows 7:
MATLAB R2015a
v8.5.0.197613
Windows 64-bit
consider the following simple quadratic example
x^2-12.5*x+37==0
this has two solutions: x = 4.8138593383654928350373471329453 or x = 7.6861406616345071649626528670547
if we run vpasolve without an interval we get the two solutions: syms x
xx=vpasolve(x^2-12.5*x+37==0,x);
xx =
4.8138593383654928350373471329453
7.6861406616345071649626528670547
now, let's say we want to find the first solution, we know that it is lest than 5 so we bound our search between 0 and 5:
syms x
xx=vpasolve(x^2-12.5*x+37==0,x,[0,5]);
this gives us the solution
xx =
4.8138593383654928350373471329453
which is great but let's say we don't know the solution, just that it's less than five; we would use the inequality option:
syms x
xx=vpasolve([x^2-12.5*x+37==0,x<5],x);
but this returns
xx =
Empty sym: 0-by-1
which of course is not true. My particular problem is a more sophisticated multivariate problem but this example shows all the problems that I currently face. Any help would be greatly appreciated.
Cheers,
Jesse V
답변 (2개)
Mischa Kim
2015년 6월 29일
Jesse, according to the documentation
" vpasolve ignores assumptions set on variables. You can restrict the returned results to particular ranges by specifying appropriate search ranges using the argument init_guess."
In other words, you could use
syms x
xsol = vpasolve(x^2 - 12.5*x + 37 == 0, x, [-inf,5]);
if you don't know the solution, just that it's less than five
카테고리
도움말 센터 및 File Exchange에서 Numeric Solvers에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!