Documentation

`assume`

Set permanent assumption

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

Syntax

```assume(`condition`)
assume(`expr`, `set`)
```

Description

`assume(condition)` sets the assumption that condition `condition` is true for all further calculations. This call removes all previous assumptions containing identifiers used in `condition`.

`assume(expr, set)` attaches the property `set` to the identifier or expression `expr`. This call overwrites all previous assumptions containing identifiers used in `expr`.

Assumptions are mathematical conditions that are assumed to hold true for all calculations. By default, all MuPAD® identifiers are independent of each other and can take any value in the complex plane. For example, `sign(1 + x^2)` cannot be simplified any more because MuPAD assumes that `x` is a complex number. If you set an assumption that `x` is a real number, then MuPAD can simplify `sign(1 + x^2)` to `1`.

For this reason, many MuPAD functions return very general or piecewise-defined results that depend on further conditions. For example, `solve` or `int` can return `piecewise` results.

Many mathematical theorems hold only under certain conditions. For example, `x^b*y^b = (x*y)^b` holds if `b` is an integer. But this equation is not true for all combinations of `x`, `y`, and `b`. For example, it is not true if ```x = y = -1, b = 1/2```. In such cases, you can use assumptions to get more specific results.

If you use `assume` inside a function or procedure, MuPAD uses the new assumption and ignores existing assumptions only inside the function or procedure. After the function or procedure call, MuPAD removes the new assumption and restores the assumptions that were set before the function or procedure call.

If `condition` is a relation (for example, ```x < y```), then MuPAD implicitly assumes that both sides of the relation are real. See Example 4.

To delete assumptions previously set on `x`, use `unassume(x)` or `delete x`.

When you assign a value to an identifier with assumptions, the assigned value can be inconsistent with existing assumptions. Assignments overwrite all assumptions previously set on an identifier. See Example 5.

`assume` accepts any `condition` and Boolean combinations of `condition`s. See Example 7.

If `expr` is a list, vector, or matrix, use the syntax `assume(expr, set)`. Here `set` must be specified as one of `C_`, `R_`, `Q_`, `Z_`, `N_`, or an expression constructed with the set operations, such as `union`, `intersect`, or `minus`. `set` also can be a function of the `Type` library, for example, `Type::Real`, `Type::Integer`, `Type::PosInt`, and so on.

Do not use the syntaxes `assume(expr in set)` and `assume(condition)` for nonscalar `expr`.

Examples

Example 1

Set an assumption that identifier `n` is an integer. Here, `assume(n, Type::Integer)` is equivalent to `assume(n in Z_)` because `n` is a scalar.

```assume(n, Type::Integer): assume(n in Z_): getprop(n);```

Check if `n^2` is a nonnegative integer. MuPAD uses the assumption that you set on `n`.

`is(n^2, Type::NonNegInt)`

Other system functions take this assumption into account:

```abs(n^2 + 1); simplify(sin(2*n*PI))```

For further computations, delete the identifier `n`:

`delete n`

Example 2

To keep the existing assumptions and combine them with the new ones, use `assumeAlso`:

```assume(n, Type::Integer): getprop(n);```

```assumeAlso(n, Type::Positive): getprop(n);```

For further computations, delete the identifier `n`:

`delete n`

Alternatively, set multiple assumptions in one function call:

```assume(n, Type::Integer and Type::Positive): getprop(n);```

For further computations, delete the identifier `n`:

`delete n`

Example 3

You can set separate assumptions on the real and imaginary parts of an identifier:

```assume(Re(z) > 0); assumeAlso(Im(z) < 0):```
```abs(Re(z)); sign(Im(z))```

`is(z, Type::Real), is(z > 0)`

For further computations, delete the identifier `z`:

`delete z`

Example 4

Using `assume`, set the assumption `x > y`. Assumptions set as relations affect the properties of both identifiers.

`assume(x > y)`

To see the assumptions set on identifiers, use `getprop`:

```getprop(x); getprop(y);```

To keep an existing assumption on `y` and add a new one, use `assumeAlso`. For example, add the new assumption that `y` is greater than `0` while keeping the assumption that `y` is less than `x`:

`assumeAlso(y > 0)`
`is(x^2 >= y^2)`

Relations, such as `x > y`, imply that the involved identifiers are real:

`is(x, Type::Real), is(y, Type::Real)`

You also can set a relational assumption where one side is not an identifier, but an expression:

`assume(x > 1/y)`
```getprop(x); getprop(y)```

For further computations, delete the identifiers `x` and `y`:

`delete x, y`

Example 5

`_assign` and `:=` do not check if an identifier has any assumptions. The assignment operation overwrites all assumptions:

```assume(a > 0): a := -2: a, getprop(a)```

For further computations, delete the identifier `a`:

`delete a`

Example 6

Set the assumption that x is positive and find the absolute value of `x`, the sign of `x`, and the real and imaginary parts of `x`. These system functions take assumptions set on identifiers into account:

```assume(x > 0): abs(x), sign(x), Re(x), Im(x)```

Try expanding the expression `ln(z1*z2)` without additional assumptions. It does not expand because ```ln(z1*z2) = ln(z1) + ln(z2)``` is not true for arbitrary `z1`, `z2` in the complex plane:

`expand(ln(z1*z2))`

Now, set the assumption that one number is real and positive. Expand the same expression:

`assume(z1 > 0): expand(ln(z1*z2))`

For further computations, remove the assumptions on `x` and `z1`:

`unassume(x); unassume(z1)`

Example 7

Set these two assumptions on the identifier `a`. To combine the assumptions, use the Boolean operator `and`:

```assume(a > 0 and a in Z_): is(a = 0); is(a = 1/2); is(a = 2);```

Parameters

 `expr` Identifier, mathematical expression, list, vector, or matrix containing identifiers. If `expr` is a list, vector, or matrix, then only the syntax `assume(expr, set)` is valid. `set` Property representing a set of numbers or a set returned by `solve`. For example, this set can be an element of `Dom::Interval`, `Dom::ImageSet`, `piecewise`, or one of `C_`, `R_`, `Q_`, `Z_`, `N_`. It also can be an expression constructed with the set operations, such as `union`,, `intersect` or `minus`. For more examples, see Properties. `condition` Equality, inequality, element of relation, or Boolean combination (with the operators `and` or `or`).

Return Values

Void object `null()` of type `DOM_NULL`.

Mathematical Modeling with Symbolic Math Toolbox

Get examples and videos