Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

**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.**

Permanent assumptions work best for the mathematical properties
that hold true throughout your computations. Suppose, you want to
calculate the time during which a free-falling object drops from the
height `h`

. The kinematic equation for the free fall
motion is *h* = *g* *t*^{2},
where `g`

is the free fall acceleration. Using this
equation, calculate the time during which the object falls from a
certain height. Without assumptions, you get the complete solution
for all possible values of parameters including complex values:

t = solve(h = g*t^2/2, t)

If you do not consider the special case where no gravitational forces exist, you can safely assume that the gravitational acceleration is positive. This assumption removes the special zero-gravity cases from the solution:

assume(g > 0); t = solve(h = g*t^2/2, t)

The variable `h`

in the equation represents
the height from which the object falls. If you do not consider that
someone initially throws the object upward and that the object reflects
from the ground, the height `h`

is always positive.
Therefore, you can assume that both gravitational acceleration `g`

and
height `h`

are positive:

assume(g > 0 and h > 0); t = solve(h = g*t^2/2, t)

Assuming that the time of the drop is a positive value, you get the expected result. When you set assumptions on variables, the solver compares the obtained solutions with the specified assumptions. This additional task can slow down the solver:

assume(g > 0 and h > 0 and t > 0); t := solve(h = g*t^2/2, t)

The solver returns the solutions as a set, even if the set contains
only one element. To access the elements of a solution set, use square
brackets or the `op`

command:

time = t[1]

Clear the variable `t`

for further computations:

delete t

If you set several assumptions for the same object, each new assumption overwrites the previous one:

assume(h in R_); assume(h <> 0); is(h in R_), is(h <> 0)

If you want to keep the previous assumption while adding a new one, see Adding Assumptions.

The `assume`

command
cannot solve assumptions in the form of equations and does not assign
values to the variables:

assume(g + 5 = 14.8 and 2*t = 14); h = g*t^2/2

When you set an assumption in the form of an inequality, both
sides of the inequality must represent real values. Inequalities with
complex numbers are invalid because the field of complex numbers is
not an ordered field. For example, if you try to use the following
assumption, MuPAD^{®} returns an error:

assume(t > 2*I)

Error: Inconsistent assumptions. [property::_assume]

You can use complex values in an assumption written in the form of an equation:

assume(t = 2*PI*I)

When you set an assumption on an object, MuPAD replaces the previous assumptions on that object with the new assumption:

assume(x in Z_); assume(x in R_); is(x in Z_), is(x in R_)

To add a new assumption without removing the previous assumptions,
use the `assumeAlso`

command:

assume(x in Z_); assumeAlso(x in R_); is(x in Z_), is(x in R_)

Also, you can set multiple assumptions in one function call
by using the logical operators. For example, set two assumptions on `x`

:

assume(x in Z_ and x in R_); is(x in Z_), is(x in R_)

When adding assumptions, always check that a new assumption
does not contradict the existing assumption. MuPAD does not guarantee
to detect conflicting assumptions. For example, assume that `y`

is
simultaneously nonzero, real and an imaginary value. `Type::Imaginary`

refers
to all complex numbers lying on the imaginary axis. When you set these
assumptions, MuPAD does not issue any warning and does not error:

assume(y <> 0); assumeAlso(y in R_); assumeAlso(y, Type::Imaginary)

Do not set conflicting assumptions because they can lead to unpredictable and inconsistent results.

To check if the assumption still holds true, use the `is`

command. For example, MuPAD drops
the assumption that the variable `y`

represents imaginary
numbers because this assumption conflicts with the combination of
the previous two assumptions:

is(y <> 0), is(y in R_), is(y, Type::Imaginary)

If you set conflicting assumptions, the order in which you set them does not always determine which assumption MuPAD accepts:

assume(y <> 0); assumeAlso(y, Type::Imaginary); assumeAlso(y in Z_); is(y <> 0), is(y, Type::Imaginary), is(y in Z_)

Permanent assumptions hold for all further calculations. Before
using a parameter in other calculations, check which properties MuPAD assumes
to be valid for this parameter. The `property::showprops`

command returns all
assumptions specified for the parameter:

assume(g in R_); assume(h in Z_); assume(t > 0); property::showprops(g), property::showprops(h), property::showprops(t)

The `unassume`

command
clears a particular object from all assumptions:

unassume(g); unassume(h); unassume(t); property::showprops(g), property::showprops(h), property::showprops(t)

To delete the value of a parameter and clear all assumptions
set for this parameter, use the `delete`

command:

delete g, h, t

For example, assign the value to
the variable `h`

and assume that ```
h >
0
```

:

h := g*t^2/2: assume(g > 0 and h > 0); property::showprops(h); h

The `unassume`

command
clears the assumption, but does not remove the value of the variable:

unassume(h > 0); property::showprops(h); h

The `delete`

command
clears the assumption and the value:

delete h; property::showprops(h); h