isAlways

Tests whether a symbolic relation holds for all values of its variables.

Category: Symbolic Computations in MATLAB > Operators and Elementary Operations

Syntax

tf = isAlways(cond)

Returns true if the relation cond is always true, and false if it is false or cannot be decided.

Description

An equation or inequality between symbolic expressions is not a plain true or false, so it cannot be put directly in an if. isAlways decides whether the relation holds as an identity: isAlways(x^2 - 1 == (x - 1)*(x + 1)) is true, while isAlways(x > 1) is false, because some values of x fail it.

Use it to verify that two expressions are equal after simplification, or that an inequality is always satisfied.

Input arguments

cond
Symbolic equation or inequality, or a logical value.

Output arguments

tf
Logical scalar.

Example

Identities and a failing inequality

syms x
isAlways(x^2 - 1 == (x - 1)*(x + 1))
isAlways(sin(x)^2 + cos(x)^2 == 1)
isAlways(x > 1)
isAlways(x < x + 1)
Output
ans = logical
   1
ans = logical
   1
ans = logical
   0
ans = logical
   1

Notes

The 'Unknown' option is not supported, and inequalities that depend on assumptions about the variables (such as x^2 >= 0 for real x) are not resolved and return false.

See also

simplify isequal assume in