Use Temporary Assumptions

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.

Create Temporary Assumptions

Use temporary assumptions to specify that an object holds mathematical properties for a particular calculation. Temporary assumptions also help you narrow a general solution and get specific solutions. For example, the following equation describes linear motion with constant acceleration: . Here, r is the distance the object travels, r0 is the initial distance, v0 is the initial velocity, a is the constant acceleration, and t is the time of travel. If you know all other parameters and want to calculate the time that the object was moving, solve the equation for the variable t:

t = solve(r = r_0 + v_0*t + a*t^2/2, t)

Suppose, you want to keep the general solution for all possible cases of the linear motion with constant acceleration. You also want to derive several special cases of this motion and get particular solutions for these cases. For example, one of the objects you consider moves with constant velocity. Derive the solution for this object from the general solution for the time of the motion by assuming the acceleration a = 0:

t = solve(r = r_0 + v_0*t + a*t^2/2, t)
    assuming a = 0 and r > r_0 and v_0 > 0

The assumption a = 0 holds true only for this particular call to solve. The assumption does not affect other calculations:

is(a = 0)

If you set an assumption in the form of an inequality, both sides of an inequality should 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:

y + 1 assuming y > 2*I
Error: Inconsistent assumptions. [property::_assume]

You can use complex values in assumptions presented in forms of equations:

y + 1 assuming y = 2*I

Assign Temporary Values to Parameters

To solve the linear motion equation for particular values of the parameters, assign the values to the parameters:

r := 4:
r_0 := 0:
v_0 := 3:
a := 2:
t = solve(r = r_0 + v_0*t + a*t^2/2, t) assuming t > 0

If you use assignments, MuPAD evaluates variables to their values in all further computations:

r, r_0, v_0, a

To be able to reuse the variables in further computations, use the delete command:

delete r, r_0, v_0, a

Using assumptions, you can temporarily assign values to the parameters. For example, solve the equation for the following values:

t = solve(r = r_0 + v_0*t + a*t^2/2, t)
assuming r = 4 and r_0 = 0 and v_0 = 3 and a = 2 and t > 0

The variables remain free for further calculations because temporary assumptions do not hold true:

r, r_0, v_0, a, t

If assumptions contain linear equations with one variable, MuPAD solves these equations, inserts the solutions into the expression, and then evaluates the expression:

r = r_0 + v_0*t + a*t^2/2 assuming  a + 5 = 5
                          and 2*v_0 + 4 = 14
                          and t = 3 and r_0 = 0

Interactions Between Temporary and Permanent Assumptions

The assuming command temporarily overwrites all permanent assumptions set on an object:

assume(z in R_);
z assuming z = -2*I

After evaluating the statement with a temporary assumption, MuPAD reinstates the permanent assumption:

is(z in R_)

See how to use temporary assumptions in combination with permanent assumptions in Using Temporary Assumptions on Top of Permanent Assumptions.

Use Temporary Assumptions on Top of Permanent Assumptions

Suppose you set permanent assumptions on a MuPAD object. If you evaluate the object with a temporary assumption set by the assuming command, MuPAD ignores the permanent assumptions in this evaluation:

assume(x in R_);
solve(x^3 + x = 0, x) assuming (x <> 0)

To use permanent assumptions and a temporary assumption together, add the temporary assumption using the assumingAlso command:

assume(x in R_);
solve(x^3 + x = 0, x) assumingAlso (x <> 0)

When you use temporary assumptions on top of the permanent ones, always check that the assumptions do not contradict each other. Contradicting assumptions can lead to inconsistent and unpredictable results. In some cases, MuPAD detects conflicting assumptions and issues the following error:

assume(x < 0);
x assumingAlso (x > 0);
Error: Inconsistent assumptions. [property::_assume]

MuPAD does not guarantee to detect contradicting assumptions:

assume(x, Type::Even);
x assumingAlso (x + 1, Type::Even)