vpasolve does not handle inequalities correctly
Show older comments
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
Answers (2)
Jesse
on 7 Jul 2015
Mischa Kim
on 29 Jun 2015
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
1 Comment
Categories
Find more on Numeric Solvers in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!