Main Content


Show assumptions affecting symbolic variable, expression, or function



assumptions(var) returns all assumptions that affect variable var. If var is an expression or function, assumptions returns all assumptions that affect all variables in var.


assumptions returns all assumptions that affect all variables in MATLAB® Workspace.


collapse all

In Symbolic Math Toolbox™, you can set mathematical assumptions or conditions when creating symbolic variables. For example, create a symbolic variable n and assume that the variable is an integer. Return the assumption using assumptions.

syms n integer
ans = nZ

You can also use the assume function to set assumptions. For example, assume that n is less than x and that x < 42. The assume function replaces old assumptions on input with the new assumptions. Return all assumptions that affect n.

syms x
assume(n < x & x < 42)
ans = (n<xx<42)

assumptions returns the assumption x < 42 because it affects n through the assumption n < x. Thus, assumptions returns the transitive closure of assumptions, which is all assumptions that mathematically affect the input.

Set the assumption on variable m that 1 < m < 3. Return all assumptions on m and x using assumptions.

syms m
assume(1 < m < 3)
assumptions([m x])
ans = (n<x1<mm<3x<42)

To see the assumptions that affect all variables, use assumptions without any arguments.

ans = (n<x1<mm<3x<42)

For further computations, clear the assumptions.

assume([m n x],"clear")

You cannot set an additional assumption on a variable using assume because assume clears all previous assumptions on that variable. To set an additional assumption on a variable, using assumeAlso.

Set an assumption on x using assume. Set an additional assumption on x use assumeAlso. Use assumptions to return the multiple assumptions on x.

syms x
assumeAlso(x < 0)
ans = (xRx<0)

For further computations, clear the assumptions.


assumptions accepts symbolic expressions and functions as input and returns all assumptions that affect all variables in the symbolic expressions or functions.

Set assumptions on variables in a symbolic expression and function. Find all assumptions that affect all variables in the symbolic expression using assumptions.

syms a b c f(a,b,c)
expr = a*exp(b)*sin(c);
assume(a+b > 3 & in(a,"integer") & in(c,"real"))
ans = (aZcR3<a+b)

Find all assumptions that affect all variables that are inputs to a symbolic function.

ans = (aZcR3<a+b)

Note that if you use syms to create another symbolic function after setting assumptions on the function input arguments, syms clears all previously set assumptions on the symbolic variables. Instead, create the symbolic function first, and then set the assumptions on the symbolic variables.

syms g(a,b,c)
ans =
Empty sym: 1-by-0
assume(a+b > 3 & in(a,"integer") & in(c,"real"))
ans = (aZcR3<a+b)

Clear the assumptions for further computations.

assume([a b c],"clear")

To restore old assumptions, first store the assumptions returned by assumptions. Then you can restore these assumptions at any point by calling assume or assumeAlso.

Solve the equation for a spring system using dsolve under the assumptions that the mass and spring constant are positive.

syms m k positive
syms x(t)
xsol = dsolve(m*diff(x,t,t) == -k*x, x(0) == 0)
xsol = 


Suppose you want to explore solutions unconstrained by assumptions, but want to restore the assumptions afterwards. First store the assumptions using assumptions, then clear the assumptions and solve the equation. dsolve returns unconstrained solutions.

tmp = assumptions;
assume([m k],"clear")
xsol = dsolve(m*diff(x,t,t) == -k*x, x(0) == 0)
xsol = 


Restore the original assumptions using assume.


After computations are complete, clear assumptions using assume.

assume([m k],"clear")

Input Arguments

collapse all

Symbolic input for which to show assumptions, specified as a symbolic variable, expression, or function, or a vector, matrix, or multidimensional array of symbolic variables, expressions, or functions.


  • When you delete a symbolic object from the MATLAB workspace by using clear, all assumptions that you set on that object remain in the symbolic engine. If you declare a new symbolic variable with the same name, it inherits these assumptions.

  • To clear all assumptions set on a symbolic variable var use this command.

  • To clear all objects in the MATLAB workspace and close the Symbolic Math Toolbox™ engine associated with the MATLAB workspace resetting all its assumptions, use this command.

    clear all

Version History

Introduced in R2012a