0% found this document useful (0 votes)
11 views6 pages

Complex Number Operations in Mathematica

The document discusses complex numbers and their operations like addition, subtraction, multiplication and division. It also discusses finding the modulus, conjugate and phase angle of complex numbers. Several examples of integrals involving complex functions along contours are presented.

Uploaded by

ghoshmrin2003
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

Complex Number Operations in Mathematica

The document discusses complex numbers and their operations like addition, subtraction, multiplication and division. It also discusses finding the modulus, conjugate and phase angle of complex numbers. Several examples of integrals involving complex functions along contours are presented.

Uploaded by

ghoshmrin2003
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

In[2]:= (*Practical 1: Declaring a complex number in

Mathematica and its graphical representation in Mathematica *)

Complex - 5, 4

Out[2]= -5 + 4 ⅈ

In[4]:= (*Practical 1: Declaring a complex number in Mathematica *)

z = -6 + 4 I
Out[4]= -6 + 4 ⅈ

In[5]:= (* Extracting the real part from the complex number z *)

Re[z]
Out[5]= -6

In[6]:= (* Extracting the imaginary part from the complex number z *)

Im[z]
Out[6]= 4

In[7]:= (* Graphical representation of the complex number z *) ListPlot[{{Re[z], Im[z]}}]

Out[7]= 4

-12 -10 -8 -6 -4 -2

In[15]:= (* Practical 2: Program to discuss the algebra of complex numbers *)

z1 = - 66 + 4 I
z2 = 14 + 6 I
z1 + z2(* Additon of two complex numbers *)
Out[15]=

- 66 + 4 ⅈ

Out[16]=

14 + 6 ⅈ
Out[17]=

- 52 + 10 ⅈ

In[18]:= z1 - z2(* Subtraction of two complex numbers *)


Out[18]=

- 80 - 2 ⅈ
2

In[19]:= z1 * z2 (* Multiplication of two complex numbers *)


Out[19]=

- 948 - 340 ⅈ

In[20]:= z1  z2(* Verify manually the division of two complex numbers *)

Out[20]=

225 113 ⅈ
- +
58 58

In[21]:= z1 ^ 2
Out[21]=

4340 - 528 ⅈ

In[22]:= (* Practical 3: To find conjugate,


modulus and phase angle of an array of complex numbers *)

Abs[z1](* Modulus of complex number *)


Out[22]=

2 1093

In[23]:= Conjugate[z1](* Conjugate of complex number *)


Out[23]=

- 66 - 4 ⅈ

In[24]:= Arg[z1](* Phase Angle of complex number *)


Out[24]=
2
π - ArcTan 
33

In[26]:= theta = %
Out[26]=
2
π - ArcTan 
33

In[27]:= N[theta]
Out[27]=

3.08106

In[28]:= ComplexExpandz1 ^ 2, z1


Out[28]=

4340 - 528 ⅈ

In[29]:= Arg[z1 ^ 2]
Out[29]=
132
- ArcTan 
1085
3

In[30]:= theta = %
Out[30]=
132
- ArcTan 
1085

In[31]:= N[theta]
Out[31]=

- 0.121064

In[32]:= z3 = Abs[z1] * Exp[I * Arg[z1]]


Out[32]=
2
ⅈ π-ArcTan 
2 1093 ⅇ 33

In[33]:= ExpToTrig[z3]
Out[33]=

- 66 + 4 ⅈ

In[34]:= z1 + z3
Out[34]=
2
ⅈ π-ArcTan 
- 66 + 4 ⅈ + 2 1093 ⅇ 33

In[35]:= Clearz1, z2, z3

In[38]:= (* Array of complex numbers *)

z = 4 + I, 67 - 88 I, 7 + 33 I
Out[38]=
4 + ⅈ , 67 - 88 ⅈ , 7 + 33 ⅈ

In[39]:= Abs[z](* Modulus of array of complex numbers *)


Out[39]=

 17 , 12 233 , 1138 

In[40]:= Conjugate[z](* Conugate of array of complex numbers *)


Out[40]=

4 - ⅈ , 67 + 88 ⅈ , 7 - 33 ⅈ

In[41]:= Arg[z](* Argument of array of complex numbers *)


Out[41]=
1 88 33
ArcTan , - ArcTan , ArcTan 
4 67 7

In[42]:= theta = %
Out[42]=
1 88 33
ArcTan , - ArcTan , ArcTan 
4 67 7
4

In[43]:= N[theta]
Out[43]=

{0.244979, - 0.920062, 1.36177}

In[44]:= z1, z2, z3 = 4 + I, 67 - 88 I, 7 + 33 I


Out[44]=
4 + ⅈ , 67 - 88 ⅈ , 7 + 33 ⅈ

In[45]:= z1
Out[45]=

4+ⅈ

In[46]:= z2
Out[46]=
67 - 88 ⅈ

In[47]:= z3
Out[47]=
7 + 33 ⅈ

In[48]:= ListPlot[{{Re[z1], Im[z1]}, {Re[z2], Im[z2]}, {Re[z3], Im[z3]}}]


Out[48]=

20

10 20 30 40 50 60

-20

-40

-60

-80

In[2]:= (* practical 4: Program to compute the integral of sin(z) along a \


contour C which is a straight line path from -4+2i to 5-2i *)

IntegrateSin[z], z, - 4 + 2 I, 5 - 2 I

Out[2]= Cosh2 + 4 ⅈ - Cosh2 + 5 ⅈ

In[3]:= (* Practical 5: Program to compute the integral of z^2 - 5z + 1 along \


a contour C given by x = y^2 + 1, -2 ≤ y ≤ 2 *)

Integratez ^ 2 - 5*z + 1, z, 3 - 2 I, 5 + I


35
Out[3]= - - 12 ⅈ
6
5

In[4]:= Simplifyx + Iy + I 77

Out[4]= x + ⅈ (77 + y)

In[5]:= (* Program to compute the integral of z^3 + 2z^2 + 1 along a contour \


C given by x^2 + y^2 = 1, 0 ≤ y ≤ 2 Pi *)

Integratez ^ 3 + 2 * z^2 + 1, z, 1, 588 414.3191322385 I

Out[5]= 2.9969 × 1022 - 1.35818 × 1017 ⅈ

In[6]:= ComplexExpandCost + I Sint  ^ 3 + 2 * Cost + I Sint ^ 2 + 1

Out[6]= 1 + 2 Cos[t]2 + Cos[t]3 - 2 Sin[t]2 - 3 Cos[t] Sin[t]2 + ⅈ 4 Cos[t] × Sin[t] + 3 Cos[t]2 Sin[t] - Sin[t]3 

In[7]:= (* Practical 6: Program to compute the Taylor series expansion of e^z \


along z=0 and n=10 *)

SeriesExp[z], z, 6, 19


1 1 1 1
ⅇ + ⅇ (z - 6) + ⅇ (z - 6) + ⅇ (z - 6) + ⅇ (z - 6) + ⅇ (z - 6) +
6 6 6 2 6 3 6 4 6 5
Out[7]=
2 6 24 120
1 ⅇ6 (z - 6)7 ⅇ6 (z - 6)8 ⅇ6 (z - 6)9 ⅇ6 (z - 6)10 ⅇ6 (z - 6)11
ⅇ (z - 6) +
6 6
+ + + + +
720 5040 40 320 362 880 3 628 800 39 916 800
ⅇ6 (z - 6)12 ⅇ6 (z - 6)13 ⅇ6 (z - 6)14 ⅇ6 (z - 6)15 ⅇ6 (z - 6)16
+ + + + +
479 001 600 6 227 020 800 87 178 291 200 1 307 674 368 000 20 922 789 888 000
ⅇ6 (z - 6)17 ⅇ6 (z - 6)18 ⅇ6 (z - 6)19
20
+ + + O[z - 6]
355 687 428 096 000 6 402 373 705 728 000 121 645 100 408 832 000

In[25]:= (* Practical 7: To perform Laurent series expansion of the function \


f(z) = 1z^2 - 1z^2 - 4 *)

Withr = 3 / 2, n = 8,
TableFourierCoefficient Withz = r ExpI t, 1  z ^ 2 - 1 z ^ 2 - 4, t, k  r ^ k,
k, - n, n, 2
Out[25]=
1 1 1 1 1 1 1 1 1
- , - , - , - , - , - , - , - , - 
3 3 3 3 12 48 192 768 3072

In[10]:= Clear["Global`*"]
6

In[11]:= Polyx_ , n_ := SeriesExp[x], x, 0, n

errorTaylorx_ , n_ :=
Assumingn > - 1, 1  Factorial[n] *
Integratex - t ^ n * Exp[t], t, 0, x

TableerrorTaylor30 + 30 I, n, n, 1, 3 // N


Out[13]=

1.6484 × 10 ⅈ, 1.6484 × 1012 - 1.05586 × 1013 ⅈ , 1.6484 × 1012 - 1.05586 × 1013 ⅈ


12 13
- 1.05586 × 10

In[23]:= ol = Ceiling
n /. FindRootAbserrorTaylor22 + 25 I, n ⩵ 1 / 21, n, 46,
WorkingPrecision → 49
Out[23]=

90

You might also like