assume

Sets assumptions on symbolic variables.

Category: Mathematics > Assumptions

Syntax

assume(cond)

Declares that the condition holds, replacing earlier assumptions on the variables involved.

assume(x, set)

States that x belongs to a set such as 'real', 'integer' or 'positive'.

assume(x, 'clear')

Removes the assumptions on x.

Description

A symbolic variable is complex by default, so sqrt(x^2) cannot be simplified to x. Assumptions narrow the domain and let functions such as simplify, int and limit use facts like x real or x positive. assume replaces what was assumed before, whereas assumeAlso adds to it.

The assumptions belong to the variable and stay until they are cleared with assume(x, 'clear'), with assumptions('clear') or with clear x. assumptions lists them.

Input arguments

cond
Relation such as x > 0, or a logical combination of relations.
set
Name of a set, as text.

Example

Declare x real

syms x
assume(x, 'real')
assumptions(x)
Output
ans = in(x, 'real')

Notes

Only the 'real' set is recorded reliably in MatLivre, and the stored assumptions are not yet used by simplify. assume(x, 'clear') does not clear them; use assumptions('clear').

See also

assumeAlso assumptions syms sym simplify