Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: ComplexExpand and subscrips

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109586] Re: ComplexExpand and subscrips
  • From: Nico Scherf <nscherf at googlemail.com>
  • Date: Thu, 6 May 2010 04:53:00 -0400 (EDT)

hi,

ComplexExpand doesnt treat the expressions Subscript[p,1][x] and Subscript[p,2][x] as elements of the real numbers (which ComplexExpand usually assumes for all variables, and works in the case of the first equation with p1[x] and p2[x]). As is written in the help page you can achieve the same Result as

In[2]:== ComplexExpand[Re[eq]]
Out[2]== p1[x] + Cosh[p2[x]] Sin[p1[x]]

by using


In[3]:== tmp == TrigExpand[eq]
Out[3]== p1[x] + I p2[x] + Cosh[p2[x]] Sin[p1[x]] - I Cos[p1[x]] Sinh[p2[x]]

and the explicitly specifying assumptions for the solution by:


In[4]:== Refine[Re[tmp], Element[ p1[x] | p2[x], Reals]]
Out[4]== p1[x] + Cosh[p2[x]] Sin[p1[x]]


this also works for

In[10]:== tmp2 == TrigExpand[eq /. {p1 -> Subscript[p, 1], p2 -> Subscript[p, 2]}]
Out[10]== Cosh[Subscript[p, 2][x]] Sin[Subscript[p, 1][x]] -
 I Cos[Subscript[p, 1][x]] Sinh[Subscript[p, 2][x]] + Subscript[p, 1][x] +
 I Subscript[p, 2][x]
I
n[11]:== Refine[Re[tmp2], Element[Subscript[p, 2][x] | Subscript[p, 1][x], Reals]]
Out[11]== Cosh[Subscript[p, 2][x]] Sin[Subscript[p, 1][x]] + Subscript[p, 1][x]

hope this helps a bit...=09

best

nico


On May 5, 2010, at 12:06 PM, slawek wrote:

> Why the Out[4] and Out[2] are quite different? The eq is a sample and has
> got no deep meaning.
>
> In[1]:== eq == p1[x] + I p2[x] + Sin[p1[x] - I p2[x]]
> Out[1]== p1[x] + I p2[x] + Sin[p1[x] - I p2[x]]
> In[2]:== Re[eq] // ComplexExpand
> Out[2]== p1[x] + Cosh[p2[x]] Sin[p1[x]]
> In[3]:== eq /. {p1 -> Subscript[p, 1], p2 -> Subscript[p, 2]}
> Out[3]== Sin[Subscript[p, 1][x] - I Subscript[p, 2][x]] + Subscript[p, 1][x]
> + I Subscript[p, 2][x]
> In[4]:== Re[  eq /. {p1 -> Subscript[p, 1],   p2 -> Subscript[p, 2]}] //
> ComplexExpand
> Out[4]== -Im[Subscript[p, 2][x]] + Re[Subscript[p, 1][x]] +
> Cosh[Im[Subscript[p, 1][x]] - Re[Subscript[p, 2][x]]] Sin[Im[Subscript[p,
> 2][x]] + Re[Subscript[p, 1][x]]]
>
> TIA
> slawek
>
>
>



  • Prev by Date: Re: mathlink error handling inside :Begin: - :End:
  • Next by Date: Re: Plot modular function on unit disk
  • Previous by thread: Re: ComplexExpand and subscrips
  • Next by thread: DistributeDefinitions statement appears to create memory leak