Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Re: symbolic calculations with complex numbers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg32079] Re: symbolic calculations with complex numbers
  • From: Sotirios Bonanos <sbonano at mail.ariadne-t.gr>
  • Date: Sat, 22 Dec 2001 04:22:54 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

    I understand you want to carry out general manipulations with complex 
symbols and not just calculate 
the Abs of an expression.

    In that case it is best to define your own Re, Im, Abs functions 
using a function, Bar[], which converts an 
expression to its complex conjugate. Depending on the symbols / 
expressions you use, you can make modifications to the definition of Bar 
to force it to behave the way you want.

    Copy and paste the text following  (*************) in a new 
Mathematica notebook to see 2 examples 
of what I mean.

    Regards,
    Sotirios Bonanos
http://www.demokritos.gr/people/sbonanos.html

(*************)

Notebook[{
Cell[BoxData[
    \( (**\ Define\ complex\ conjugate\ operation\ \*"\""Bar \*"\"\<\>  
"**)
      \)], "Input",
  FontColor->RGBColor[0, 0, 1]],

Cell[BoxData[
    \(SetAttributes[Bar, {Listable}]; \nBar[Bar[x_]] = x; \n
    Bar[Complex[u_, v_]] := Complex[u, \(-v\)]; \n
    Bar[x_Plus | x_Times | x_Power | x_Rule | x_Equal] := Bar/@x; \)],
  "Input"],

Cell[BoxData[
    \(\( (**\ Case\ I : \ All\ symbols\ used\ are\ real\ **) \n
    \(Bar[x_] := x; \)\)\)], "Input"],

Cell[BoxData[
    \(\n\)], "Input"],

Cell[BoxData[
    \( (*\(*\ Use\ Bar\ to\ define\ Re\), \ Im, \ Abs\ **) \)], "Input",
  FontColor->RGBColor[0, 0, 1]],

Cell[BoxData[
    \(\(myRe[x_] := Simplify[\((x + Bar[x])\)/2]; \)\)], "Input"],

Cell[BoxData[
    \(\(myIm[x_] := Simplify[\((x - Bar[x])\)/\((2  I)\)]; \)\)], 
"Input"],

Cell[BoxData[
    \(\(myAbs[x_] := Sqrt[Simplify[myRe[x]^2 + myIm[x]^2]]; \)\)], 
"Input"],

Cell[BoxData[
    \(\n\)], "Input"],

Cell[BoxData[
    \( (**\ EXAMPLES\ **) \)], "Input",
  FontColor->RGBColor[0, 0, 1]],

Cell[CellGroupData[{

Cell[BoxData[
    \(myRe[\((x + I\ y)\)^3]\)], "Input"],

Cell[BoxData[
    \(x\^3 - 3\ x\ y\^2\)], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
    \(myIm[\((x + I\ y)\) + a^2/\((x + I\ y)\)]\)], "Input"],

Cell[BoxData[
    \(\(y\ \((\(-a\^2\) + x\^2 + y\^2)\)\)\/\(x\^2 + y\^2\)\)], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
    \(myAbs[a \((x - a + I\ y)\) + I\ b \((y - b + I\ x)\)]\)], "Input"],

Cell[BoxData[
    \(\@\(\((a\^2 - a\ x + b\ x)\)\^2 + \((\(-b\^2\) + a\ y + b\ 
y)\)\^2\)\)],
   "Output"]
}, Open  ]],

Cell[BoxData[
    \(\(\n\n\)\)], "Input"],

Cell[BoxData[
    \( (**\ Case\ II : \ Complex\ symbols\ have\ the\ form\ z[i_]\ **) 
\)],
  "Input",
  FontColor->RGBColor[0, 0, 1]],

Cell[BoxData[
    \(\(Clear[Bar]; \)\)], "Input"],

Cell[BoxData[
    \(SetAttributes[Bar, {Listable}]; \nBar[Bar[x_]] = x; \n
    Bar[Complex[u_, v_]] := Complex[u, \(-v\)]; \n
    Bar[x_Plus | x_Times | x_Power | x_Rule | x_Equal] := Bar/@x; \)],
  "Input"],

Cell[BoxData[
    \(\(Bar[x_] := x /; Head[x] =!= z; \)\)], "Input"],

Cell[BoxData[
    \(\n\)], "Input"],

Cell[BoxData[
    \( (**\ THEN\ **) \)], "Input",
  FontColor->RGBColor[0, 0, 1]],

Cell[CellGroupData[{

Cell[BoxData[
    \(myRe[z[1] + I\ z[2]]\)], "Input"],

Cell[BoxData[
    \(1\/2\ \((Bar[z[1]] - I\ Bar[z[2]] + z[1] + I\ z[2])\)\)], "Output"]
}, Open  ]],

Cell[BoxData[
    \(\(zTOxy = {z[1] -> x1 + I\ y1, z[2] -> x2 + I\ y2}; \)\)], "Input"],

Cell[CellGroupData[{

Cell[BoxData[
    \(Together[%% /. %]\)], "Input"],

Cell[BoxData[
    \(x1 - y2\)], "Output"]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[
    \(myIm[z[1]^2 + I\ z[2]^2 /. zTOxy]\)], "Input"],

Cell[BoxData[
    \(x2\^2 + 2\ x1\ y1 - y2\^2\)], "Output"]
}, Open  ]]
},
FrontEndVersion->"Macintosh 3.0",
ScreenRectangle->{{0, 1024}, {0, 748}},
WindowSize->{956, 721},
WindowMargins->{{4, Automatic}, {Automatic, 2}},
MacintoshSystemPageSetup->"\<\
00000000000000000NHh00000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000\>"
]



  • Prev by Date: RE: Replacement Rule
  • Next by Date: Re: Displaying Mathematica's Global rules
  • Previous by thread: Re: symbolic calculations with complex numbers
  • Next by thread: problem with mathematica 4.0 and office XP