The symbolic engine workspace associated with the MATLAB^{®} workspace is usually empty. The MATLAB workspace tracks the values of symbolic variables, and passes them to the
symbolic engine for evaluation as necessary. However, the symbolic engine workspace contains
all assumptions you make about symbolic variables, such as whether a variable is real,
positive, integer, greater or less than a certain value, and so on. These assumptions can
affect solutions to equations, simplifications, and transformations, as explained in Effects of Assumptions on Computations.

For example, create a symbolic variable `x`

and assume that it is
positive.

syms x assume(x > 0)

If you clear the variable `x`

using the command ```
clear
x
```

, the MATLAB workspace does not clear the assumption from the symbolic engine
workspace.

clear x assumptions

ans = 0 < x

To clear the assumption for the variable `x`

, use the command
`assume(x,'clear')`

.

syms x assume(x > 0) assume(x,'clear') assumptions

ans = Empty sym: 1-by-0

Alternatively, you can create a fresh symbolic variable without assumptions using
`syms`

.

syms x

If you want to clear a symbolic variable and also reset the symbolic engine, use the
command `clear all`

.

syms x positive clear all whos assumptions

ans = Empty sym: 1-by-0

The following shows how the MATLAB workspace and symbolic engine workspace differ in their responses to a sequence of commands.

Step | Command | MATLAB Workspace | Symbolic Engine Workspace |
---|---|---|---|

1 | ```
syms x
positive
``` or ```
syms
x;
``` ```
assume(x >
0)
``` | `x` | `x > 0` |

2 | `clear x` | empty | `x > 0` |

3 | `syms x` | `x` | empty |

4 | `clear all` | empty | empty |

To check whether a variable, say `x`

, has any assumptions in the
symbolic engine workspace associated with the MATLAB workspace, use the `assumptions`

function in the MATLAB Live Editor:

assumptions(x)

If the function returns an empty symbolic object, there are no additional assumptions
on the variable. The default assumption is that `x`

represents any
complex number. Otherwise, there are additional assumptions on the value that the
variable represents.

For example, while declaring the symbolic variable `x`

, make an
assumption that the value of this variable is a real number.

syms x real assumptions(x)

ans = in(x, 'real')

Another way to set an assumption is to use the `assume`

function.

syms z assume(z ~= 0); assumptions(z)

ans = z ~= 0

To see assumptions set on all variables in the MATLAB workspace, use `assumptions`

without input
arguments.

assumptions

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

Clear assumptions set on `x`

and `z`

.

assume([x z],'clear')

assumptions

ans = Empty sym: 1-by-0

Equivalently, the following command also clears assumptions from `x`

and `z`

.

syms x z

Assumptions can affect many computations, including results returned by the
`solve`

and `simplify`

functions. For example,
solve this equation without any additional assumptions on its variable.

syms x solve(x^4 == 1, x)

ans = -1 1 -1i 1i

Now assume that `x`

is real and solve the same equation.

syms x real solve(x^4 == 1, x)

ans = -1 1

Use the `assumeAlso`

function to add the
assumption that `x`

is also positive.

assumeAlso(x > 0) solve(x^4 == 1, x)

ans = 1

Clearing `x`

does not change the underlying assumptions that
`x`

is real and positive.

clear x x = sym('x'); assumptions(x) solve(x^4 == 1, x)

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

Clearing `x`

with `assume(x,'clear')`

or
`syms x`

clears the assumptions.

syms x assumptions(x)

ans = Empty sym: 1-by-0