vpasolve does not handle inequalities correctly
Mostrar comentarios más antiguos
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
Respuestas (2)
Jesse
el 7 de Jul. de 2015
Mischa Kim
el 29 de Jun. de 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 comentario
Categorías
Más información sobre Numeric Solvers en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!