Show assumptions affecting symbolic variable, expression, or function

Assume that the variable `n`

is
an integer using `assume`

. Return the assumption
using `assumptions`

.

syms n assume(n,'integer') assumptions

ans = in(n, 'integer')

The syntax `in(n, 'integer')`

indicates `n`

is
an integer.

Assume that `n`

is less than `x`

and
that `x < 42`

using `assume`

.
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) assumptions(n)

ans = [ n < x, x < 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 = [ 1 < m, m < 3, n < x, x < 42]

To see the assumptions that affect all variables, use `assumptions`

without
any arguments.

assumptions

ans = [ n < x, x < 42, 1 < m, m < 3]

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 assume(x,'real') assumeAlso(x<0) assumptions(x)

ans = [ x < 0, in(x, 'real')]

The syntax `in(x, 'real')`

indicates `x`

is `real`

.

For further computations, clear the assumptions.

assume(x,'clear')

`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. Find
all assumptions that affect all variables in the symbolic expression
using `assumptions`

.

syms a b c expr = a*exp(b)*sin(c); assume(a+b > 3 & in(a,'integer') & in(c,'real')) assumptions(expr)

ans = [ 3 < a + b, in(a, 'integer'), in(c, 'real')

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

```
syms f(a,b,c)
assumptions(f)
```

ans = [ 3 < a + b, in(a, 'integer'), in(c, 'real')]

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 using `dsolve`

under
the assumptions that the mass and spring constant are `positive`

.

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

ans = C8*sin((k^(1/2)*t)/m^(1/2))

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')
dsolve(m*diff(x,t,t) == -k*x, x(0)==0)
```

ans = C10*exp((t*(-k*m)^(1/2))/m) + C10*exp(-(t*(-k*m)^(1/2))/m)

Restore the original assumptions using `assume`

.

assume(tmp)

After computations are complete, clear assumptions using `assume`

.

`assume([m k],'clear')`

Was this topic helpful?