Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Evaluating Inequalities in Symbolic Toolbox

Subject: Evaluating Inequalities in Symbolic Toolbox

From: Eduardo Montoya

Date: 28 Feb, 2011 03:50:14

Message: 1 of 6

Hello,

I'd like to be able to make assumptions about the signs of symbolic expressions and then test what those assumptions imply about the sign of related symbolic expressions. Is there a way to do this reliably with the symbolic toolbox?

For example, I'd like to tell Matlab to assume that the expression x/y is greater than zero, and also that y is less than zero, which should allow Matlab to conclude that x < 0. Instead, in 2010b I get 'UNKNOWN'.

evalin(symengine, 'assume(x/y > 0 and y < 0 )');
[ evalin(symengine, 'is(y > 0)') ; evalin(symengine, 'is(x/y > 0)') ; evalin(symengine, 'is(x > 0)') ]

Thanks for any help.

Subject: Evaluating Inequalities in Symbolic Toolbox

From: Think blue, count two.

Date: 28 Feb, 2011 04:36:14

Message: 2 of 6

On 27/02/11 9:50 PM, Eduardo Montoya wrote:

> I'd like to be able to make assumptions about the signs of symbolic
> expressions and then test what those assumptions imply about the sign of
> related symbolic expressions. Is there a way to do this reliably with
> the symbolic toolbox?
>
> For example, I'd like to tell Matlab to assume that the expression x/y
> is greater than zero, and also that y is less than zero, which should
> allow Matlab to conclude that x < 0. Instead, in 2010b I get 'UNKNOWN'.
>
> evalin(symengine, 'assume(x/y > 0 and y < 0 )');
> [ evalin(symengine, 'is(y > 0)') ; evalin(symengine, 'is(x/y > 0)') ;
> evalin(symengine, 'is(x > 0)') ]

I agree that such computations should be possible, but I don't have
MuPad to try them out with.

Those computations work as expected in Maple.

Subject: Evaluating Inequalities in Symbolic Toolbox

From: Eduardo Montoya

Date: 28 Feb, 2011 05:43:05

Message: 3 of 6

"Think blue, count two." <roberson@hushmail.com> wrote in message
>
> I agree that such computations should be possible, but I don't have
> MuPad to try them out with.
>
> Those computations work as expected in Maple.

Thanks for the response. It would be disappointing to hear Matlab can no longer do computations it used to; hopefully I just need to modify the commands I'm using in some way....

As a follow-up, if anyone knows or can point me to some documentation on how MuPAD in particular (or even Maple or some other symbolic math program) would try to set up and solve a problem like this internally, that would be good to know. I assume the program goes off somewhere, scribbles down a system of inequalities and tries to solve or hopefully just simplify it into something it can sign -- is this a hard problem or an easy one for a symbolic math program?

Thanks.

Subject: Evaluating Inequalities in Symbolic Toolbox

From: Eduardo Montoya

Date: 28 Feb, 2011 06:07:05

Message: 4 of 6

"Eduardo Montoya" wrote in message <ikf61m$4ec$1@fred.mathworks.com>...
> Hello,
>
> I'd like to be able to make assumptions about the signs of symbolic expressions and then test what those assumptions imply about the sign of related symbolic expressions. Is there a way to do this reliably with the symbolic toolbox?
>
> For example, I'd like to tell Matlab to assume that the expression x/y is greater than zero, and also that y is less than zero, which should allow Matlab to conclude that x < 0. Instead, in 2010b I get 'UNKNOWN'.
>
> evalin(symengine, 'assume(x/y > 0 and y < 0 )');
> [ evalin(symengine, 'is(y > 0)') ; evalin(symengine, 'is(x/y > 0)') ; evalin(symengine, 'is(x > 0)') ]
>
> Thanks for any help.

To clarify, the results were:
FALSE, TRUE, UNKNOWN

However, I just noticed that the result of the command:
>> evalin(symengine,'getprop(x)')
ans =
Dom::Interval(-Inf, 0)

This is identical to the properties on y. But the sign command on x won't confirm that x is negative. Why?

Subject: Evaluating Inequalities in Symbolic Toolbox

From: Nasser M. Abbasi

Date: 28 Feb, 2011 06:09:17

Message: 5 of 6

On 2/27/2011 9:43 PM, Eduardo Montoya wrote:

>
> As a follow-up, if anyone knows or can point me to some documentation on how MuPAD in
> particular (or even Maple or some other symbolic math program) would try to set up and
> solve a problem like this internally, that would be good to know. I assume the
> program goes off somewhere, scribbles down a system of inequalities and tries to
> solve or hopefully just simplify it into something it can sign -- is this a hard problem
> or an easy one for a symbolic math program?
>
> Thanks.

This is a question on computer algebra, may be it can be asled on sci.math.symbolic

If you want to see internals of CAS, try SAGE, as the code in open source,
and you can read the code and learn how these things are implemented.

It is a hard problem.

--Nasser

Subject: Evaluating Inequalities in Symbolic Toolbox

From: Eduardo Montoya

Date: 28 Feb, 2011 16:19:19

Message: 6 of 6

"Eduardo Montoya" wrote in message <ikfe29$9mm$1@fred.mathworks.com>...
> "Eduardo Montoya" wrote in message <ikf61m$4ec$1@fred.mathworks.com>...
> > Hello,
> >
> > I'd like to be able to make assumptions about the signs of symbolic expressions and then test what those assumptions imply about the sign of related symbolic expressions. Is there a way to do this reliably with the symbolic toolbox?
> >
> > For example, I'd like to tell Matlab to assume that the expression x/y is greater than zero, and also that y is less than zero, which should allow Matlab to conclude that x < 0. Instead, in 2010b I get 'UNKNOWN'.
> >
> > evalin(symengine, 'assume(x/y > 0 and y < 0 )');
> > [ evalin(symengine, 'is(y > 0)') ; evalin(symengine, 'is(x/y > 0)') ; evalin(symengine, 'is(x > 0)') ]
> >
> > Thanks for any help.
>
> To clarify, the results were:
> FALSE, TRUE, UNKNOWN
>
> However, I just noticed that the result of the command:
> >> evalin(symengine,'getprop(x)')
> ans =
> Dom::Interval(-Inf, 0)
>
> This is identical to the properties on y. But the sign command on x won't confirm that x is negative. Why?

Any other tips? Thanks to Nasser, I appreciate that signing symbolic expressions is hard in general, but in this case it looks like Matlab is making the right inference somewhere internally. But Boolean checks like the is() function fail.

As far as I can tell, I'm calling these functions correctly. Are they useful for anything more than the most trivial calculations? Is there some other approach I should think about?

As I noted, internally Matlab seems to realize that 'x' is in the open real interval from -infty to 0, but for some reason it won't confirm that x is less than zero. If I define a new variable equal to 'x', Matlab still agrees that the new variable must be in the same interval. But this doesn't seem reliable at all.

Is this something Matlab is trying to fix? I'd appreciate any further comments from people.

Thank you.

>> evalin(symengine, 'assume(x/y > 0 and y < 0 )');
>> [ evalin(symengine, 'is(y > 0)') ; evalin(symengine, 'is(x/y > 0)') ; evalin(symengine, 'is(x > 0)') ]
FALSE, TRUE, UNKNOWN

>> evalin(symengine,'z := x');
>> evalin(symengine,'getprop(y)')
ans =
Dom::Interval(-Inf, 0)
>> evalin(symengine,'getprop(x)')
ans =
Dom::Interval(-Inf, 0)
>> evalin(symengine,'getprop(z)')
ans =
Dom::Interval(-Inf, 0)
>> [evalin(symengine,'is(x>0)') evalin(symengine,'is(z>0)') ]
UNKNOWN, UNKNOWN

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us