This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Symbolic expansion of polynomials and elementary functions




expand(S) expands the symbolic expression S. expand is often used with polynomials. It also expands trigonometric, exponential, and logarithmic functions.

expand(S,Name,Value) expands S using additional options specified by one or more Name,Value pair arguments.

Input Arguments


Symbolic expression or symbolic matrix.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.


If the value is true, expand the arithmetic part of an expression without expanding trigonometric, hyperbolic, logarithmic, and special functions. This option does not prevent expansion of powers and roots.

Default: false


If the value is true, apply purely algebraic simplifications to an expression. With IgnoreAnalyticConstraints, expand can return simpler results for the expressions for which it would return more complicated results otherwise. Using IgnoreAnalyticConstraints also can lead to results that are not equivalent to the initial expression.

Default: false


Expand the expression:

syms x
expand((x - 2)*(x - 4))
ans =
x^2 - 6*x + 8

Expand the trigonometric expression:

syms x y
expand(cos(x + y))
ans =
cos(x)*cos(y) - sin(x)*sin(y)

Expand the exponent:

syms a b
expand(exp((a + b)^2))
ans =

Expand the expressions that form a vector:

syms t
expand([sin(2*t), cos(2*t)])
ans =
[ 2*cos(t)*sin(t), 2*cos(t)^2 - 1]

Expand this expression. By default, expand works on all subexpressions including trigonometric subexpressions:

syms x
expand((sin(3*x) - 1)^2)
ans =
2*sin(x) + sin(x)^2 - 8*cos(x)^2*sin(x) - 8*cos(x)^2*sin(x)^2...
 + 16*cos(x)^4*sin(x)^2 + 1

To prevent expansion of trigonometric, hyperbolic, and logarithmic subexpressions and subexpressions involving special functions, use ArithmeticOnly:

expand((sin(3*x) - 1)^2, 'ArithmeticOnly', true)
ans =
sin(3*x)^2 - 2*sin(3*x) + 1

Expand this logarithm. By default, the expand function does not expand logarithms because expanding logarithms is not valid for generic complex values:

syms a b c
ans =

To apply the simplification rules that let the expand function expand logarithms, use IgnoreAnalyticConstraints:

expand(log((a*b/c)^2), 'IgnoreAnalyticConstraints', true)
ans =
 2*log(a) + 2*log(b) - 2*log(c)


When you use IgnoreAnalyticConstraints, expand applies these rules:

  • log(a) + log(b) = log(a·b) for all values of a and b. In particular, the following equality is valid for all values of a, b, and c:

      (a·b)c = ac·bc.

  • log(ab) = b·log(a) for all values of a and b. In particular, the following equality is valid for all values of a, b, and c:

      (ab)c = ab·c.

  • If f and g are standard mathematical functions and f(g(x)) = x for all small positive numbers, f(g(x)) = x is assumed to be valid for all complex x. In particular:

    • log(ex) = x

    • asin(sin(x)) = x, acos(cos(x)) = x, atan(tan(x)) = x

    • asinh(sinh(x)) = x, acosh(cosh(x)) = x, atanh(tanh(x)) = x

    • Wk(x·ex) = x for all values of k

Introduced before R2006a

Was this topic helpful?