If Results Look Too Complicated

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.

Use Options to Narrow Results

By default, the MuPAD® solvers return all possible solutions regardless of their length. Also, by default the solvers assume the solutions are complex numbers. To limit the number of the solutions to some specific ones, the solvers provide a number of options. For information about the options accepted by a particular solver, see the page for that solver. For example, for the list of options provided by the general solver, see the solve help page.

The following equation has five solutions:

solve(x^5 - 1, x)

If you need a solution in real numbers, use the Real option. The only real solution of this equation is 1:

solve(x^5 - 1, x, Real)

For the following standard quadratic equation, the solver returns the solutions for all possible values of symbolic parameters a, b, and c:

solve(a*x^2 + b*x + c, x)

To disregard special cases, use the IgnoreSpecialCases option:

solve(a*x^2 + b*x + c, x, IgnoreSpecialCases)

For the following equation, the solver returns a complete, but rather long and complicated solution:

solve(x^(5/2) + 1/x^(5/2) = 1, x)

If you want a simpler and more practical solution, try the IgnoreAnalyticConstraints option. With this option, the solver uses a set of simplified mathematical rules that are not generally correct. The returned solutions tend to be most useful for many problems in engineering and physics. Note that with this option the solver does not guarantee the correctness and completeness of the result:

solve(x^(5/2) + 1/x^(5/2) = 1, x, IgnoreAnalyticConstraints)

See the list of the options accepted by the general solver solve.

Use Assumptions to Narrow Results

If you want to limit the number of solutions, but the list of options available for solve does not have an appropriate option, try using assumptions. Suppose, for the following polynomial expression you need only positive solutions. Use the assuming command to temporarily assume that x is a positive number. Under this assumption, the solver returns four positive solutions:

solve(x^7 + 2*x^6 - 59*x^5 - 106*x^4 + 478*x^3 + 284*x^2
      - 1400*x + 800, x) assuming x > 0

Without the assumption, the solver returns all seven solutions:

solve(x^7 + 2*x^6 - 59*x^5 - 106*x^4 + 478*x^3 + 284*x^2
      - 1400*x + 800, x)

To make several assumptions, combine them with and:

solve([a*x + b*y = c, h*x - g*y = f], [x, y])
      assuming f = c and a = h and a <> 0
{ { --     f + g z        -- }
{ { |  x = -------, y = z  | }  if  b + g = 0
{ { --        h           -- }
{    { --     f        -- }
{    { |  x = -, y = 0  | }     if  b + g <> 0
{    { --     h        -- }

For more information, see Properties and Assumptions.

Simplify Solutions

While solving equations, MuPAD automatically simplifies many objects such as some function calls and arithmetical expressions with numbers. Automatic simplifications reduce the complexity of expressions used in intermediate steps, which improves performance of the solvers.

MuPAD solvers do not call the simplification functions for final results. When you call the solve command, you can get a long and complicated solution:

S := solve((sin(x/2) - cos(x/2))/(sin(x/2) + cos(x/2)) = I/2, x)

To simplify such results, use simplify or Simplify. The simplify function is faster:


Simplify is slower, but more powerful:


For more information, see Simplification.