Accelerating the pace of engineering and science

# Documentation

## Clear Assumptions and Reset the Symbolic Engine

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 some value, and so on. These assumptions can affect solutions to equations, simplifications, and transformations, as explained in Effects of Assumptions on Computations.

 Note:   These commands```syms x x = sym('x'); clear x```clear any existing value of x in the MATLAB workspace, but do not clear assumptions about x in the symbolic engine workspace.

If you make an assumption about the nature of a variable, for example, using the commands

```syms x
assume(x,'real')```

or

```syms x
assume(x > 0)```

then clearing the variable x from the MATLAB workspace does not clear the assumption from the symbolic engine workspace. To clear the assumption, enter the command

`syms x clear`

If you reset the symbolic engine by entering the command

`reset(symengine)`

MATLAB no longer recognizes any symbolic variables that exist in the MATLAB workspace. Clear the variables with the clear command, or renew them with the syms or sym command.

This example shows how the MATLAB workspace and the symbolic engine workspace respond to a sequence of commands.

1syms x positive
or
syms x;
assume(x > 0)
xx > 0
2clear xemptyx > 0
3syms xxx > 0
4syms x clearxempty

### Check Assumptions Set On Variables

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 Command Window:

`assumptions(x)`

If the function returns an empty symbolic object, there are no additional assumptions on the variable. (The default assumption is that x can be any complex number.) Otherwise, there are additional assumptions on the value of that variable.

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:

`syms x z clear`
`assumptions`
```ans =
Empty sym: 1-by-0```

### Effects of Assumptions on Computations

Assumptions can affect many computations, including results returned by the solve function. They also can affect the results of simplifications. For example, solve this equation without any additional assumptions on its variable:

```syms x
solve(x^4 == 1, x)```
```ans =
-1
1
-i
i```

Now solve the same equation assuming that x is real:

```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
syms x
assumptions(x)
solve(x^4 == 1, x)```
```ans =
[ 0 < x, in(x, 'real')]
ans =
1```

Clearing x with syms x clear clears the assumption:

```syms x clear
assumptions(x)```
```ans =
Empty sym: 1-by-0```
 Tip   syms x clear clears the assumptions and the value of x. To clear the assumptions only, use sym('x','clear').