How to check an inequality of a variable is true or not in MatLab? isAlways -- MatLab

 How to check an inequality of a variable is true or not in MatLab? isAlways -- MatLab


How to check an inequality of a variable is true or not in MatLab? 
e.g. 
check abs(x)>=0 where x is any number.
or 
check (2*x+1>=0) where x>=0;


[Ans]

isAlways command


[Description]

isAlways(<expre>) 
it will return true if the expression <expre> is Alaways true.
it will return false if the expression <expre> is Alaways false.
If the expression <expre> is Unknown (i.e. it is not certain ) (i.e.it maybe true or false), it will throw warning (by default ,without other argument) and return false.

you can change the default behavoiur by setting its <Name>

[Syntax]

isAlways(<expre>);
isAlways(<expre>,<Name>,<Value>);

Set <Name> as <Value>.
e.g. is on at buttom.


more details on:

e.g.
clear
clc
%true
syms x;
assume(x<0);
isAlways(x<0)
fprintf("1\n");
%Unknown
syms y
isAlways(y)
fprintf("2\n");
%Unknown to false
syms z
isAlways(y,'Unknown','false')
fprintf("3\n");
%true
syms a
isAlways(abs(a)>=0,'Unknown','false')
fprintf("4\n");
%true
syms b
isAlways((sin(b)*sin(b)+cos(b)*cos(b))==1,'Unknown','false')
fprintf("5\n");
%false
syms c
isAlways(c>1,'Unknown','true')
fprintf("6\n");
%false
syms d
isAlways(abs(d)<-1,'Unknown','true')
fprintf("7\n");
%{
all output:
ans =
logical
1
1
Warning: Unable to prove 'y'.
> In symengine
In sym/isAlways (line 41)
In assume_example (line 11)
ans =
logical
0
2
ans =
logical
0
3
ans =
logical
1
4
ans =
logical
1
5
ans =
logical
1
6
ans =
logical
0
s7
%}

Comments