({{, (RefLink[ComplexExpand, paclet:ref/ComplexExpand])[expr]
expands expr assuming that all variables are real. }, {, (RefLink[ComplexExpand, paclet:ref/ComplexExpand])[expr,{(Subscript[x, 1]),(Subscript[x, 2]),…}]
expands expr assuming that variables matching any of the (Subscript[x, i]) are complex. }})

OpenersNotesSection(Spacer1)Details and Options

The variables given in the second argument of (RefLink[ComplexExpand, paclet:ref/ComplexExpand]) can be patterns.

The option (RefLink[TargetFunctions, paclet:ref/TargetFunctions]) can be given as a list of functions from the set {(RefLink[Re, paclet:ref/Re]),(RefLink[Im, paclet:ref/Im]),(RefLink[Abs, paclet:ref/Abs]),(RefLink[Arg, paclet:ref/Arg]),(RefLink[Conjugate, paclet:ref/Conjugate]),(RefLink[Sign, paclet:ref/Sign])}. (RefLink[ComplexExpand, paclet:ref/ComplexExpand]) will try to give results in terms of functions specified.

(RefLink[ComplexExpand, paclet:ref/ComplexExpand]) automatically threads over lists in expr, as well as equations, inequalities and logic functions.

OpenersPrimaryExamplesSection(Spacer1)Examples  (9)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Assume both x and y are real:

ComplexExpand[Sin[x + I y]]

Take x to be complex:

ComplexExpand[Sin[x],x]

OpenersExampleSection1(Spacer1)Scope  (5)

Polynomials:

ComplexExpand[Re[z^5-2z^3-z+1],z]

Trigonometric and hyperbolic functions:

ComplexExpand[Cos[x+I y]+Tanh[z],{z}]

Inverse trigonometric and inverse hyperbolic functions:

ComplexExpand[Re[ArcCot[x+I y]]+Im[ArcSinh[x-I y]]]

Exponential and logarithmic functions:

ComplexExpand[Abs[2^z Log[2z]],z]

Composition of functions:

ComplexExpand[Re[Log[Sin[Exp[x+I y]^2]]]]

OpenersExampleSection2(Spacer1)Options  (1)

OpenersExampleSubsection0(Spacer1)TargetFunctions  (1)

This gives an answer in terms of (RefLink[Re, paclet:ref/Re])[z] and (RefLink[Im, paclet:ref/Im])[z]:

ComplexExpand[Re[Tan[z]],z]

With (RefLink[TargetFunctions, paclet:ref/TargetFunctions])->{(RefLink[Abs, paclet:ref/Abs]), (RefLink[Arg, paclet:ref/Arg])}, the answer is given in terms of (RefLink[Abs, paclet:ref/Abs])[z] and (RefLink[Arg, paclet:ref/Arg])[z]:

ComplexExpand[Re[Tan[z]],z,TargetFunctions->{Abs,Arg}]

Use (RefLink[Conjugate, paclet:ref/Conjugate]) as the target function:

ComplexExpand[Re[Tan[z]],z,TargetFunctions->Conjugate]

OpenersExampleSection3(Spacer1)Properties & Relations  (1)

This computes (RefLink[Re, paclet:ref/Re])[(RefLink[Sin, paclet:ref/Sin])[x+(RefLink[I, paclet:ref/I]) y]] assuming that x and y are real:

ComplexExpand[Re[Sin[x+I y]]]

The same computation can be done using (RefLink[TrigExpand, paclet:ref/TrigExpand]) and (RefLink[Refine, paclet:ref/Refine]):

TrigExpand[Sin[x+I y]]

Refine[Re[%],Element[x|y,Reals]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[GaussianIntegers, paclet:ref/GaussianIntegers])  ▪  (RefLink[TrigToExp, paclet:ref/TrigToExp])  ▪  (RefLink[ExpToTrig, paclet:ref/ExpToTrig])  ▪  (RefLink[TrigExpand, paclet:ref/TrigExpand])  ▪  (RefLink[FunctionExpand, paclet:ref/FunctionExpand])  ▪  (RefLink[PowerExpand, paclet:ref/PowerExpand])  ▪  (RefLink[Abs, paclet:ref/Abs])  ▪  (RefLink[ReIm, paclet:ref/ReIm])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Putting Expressions into Different Forms, paclet:tutorial/PuttingExpressionsIntoDifferentForms])}, {▪(RefLinkPlain[Expressions Involving Complex Variables, paclet:tutorial/ExpressionsInvolvingComplexVariables])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Complex Numbers, paclet:guide/ComplexNumbers])}, {▪(RefLinkPlain[Functions of Complex Variables, paclet:guide/FunctionsOfComplexVariables])}, {▪(RefLinkPlain[Hyperbolic Functions, paclet:guide/HyperbolicFunctions])}, {▪(RefLinkPlain[Algebraic Transformations, paclet:guide/AlgebraicTransformations])}, {▪(RefLinkPlain[Trigonometric Functions, paclet:guide/TrigonometricFunctions])}, {▪(RefLinkPlain[Formula Manipulation, paclet:guide/FormulaManipulation])}})}})