Default number of terms in series expansions

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.


The environment variable ORDER controls the default number of terms that the system returns when you compute a series expansion.

Possible values: Positive integer less than 231. The default value is 6.

The functions taylor, series, and asympt have an optional third argument specifying the desired number of terms of the requested series expansion, counting from the dominant term on (relative order). If this optional argument is missing, then the value of ORDER is used instead.

ORDER may also affect the results returned by the function limit.

Deletion via the statement “delete ORDER” resets ORDER to its default value 6. Executing the function reset also restores the default value.

In some cases, the number of terms returned by taylor, series, or asympt may not agree with the value of ORDER. Cf. Example 2.


Example 1

In the following example, we compute the first 6 terms of the series expansion of the function exp(x)/x^2 around the origin:

series(exp(x)/x^2, x = 0)

To obtain the first 10 terms, we specify the third argument of series:

series(exp(x)/x^2, x = 0, 10)

Alternatively, we increase the value of ORDER. This affects all subsequent calls to series or any other function returning a series expansion:

ORDER := 10: series(exp(x)/x^2, x = 0)

taylor(x^2/(1 - x), x = 0)

Finally, we reset ORDER to its default value 6:

delete ORDER: taylor(x^2/(1 - x), x = 0)

Example 2

The number of terms returned by series may differ from the value of ORDER when cancellation or rational exponents occur:

ORDER := 3:
series(exp(x) - 1 - x - x^2/2 - x^3/6, x = 0)

series(1/(1 - sqrt(x)), x = 0)

delete ORDER:

See Also

MuPAD Functions