Professional Documents
Culture Documents
ComplexAnalysis LAB 9
ComplexAnalysis LAB 9
ComplexAnalysis LAB 9
Name: Aayush
Class: 6CMS
Registration Number: 21215419
LAB 1 : Revision
AIM: To revise the basic concepts of Python
QUES 1: Write a program to enter two real number and convert them into complex number.
Also find the real and imaginary part of the complex number.
QUES 3: Write a python program which accepts the user's first and last name and print it with a
space between them.
QUES 4: Write a python program which accepts a number from the user and predicts whether it
is even or odd.
Enter a number: 19
The number is odd.
QUES 5: Write a python program which gives the reverse of a number given by the user and
tells whether the reverse is same as the orginal number.
number=int(input("Enter a number"))
reverse_number = int(str(number)[::-1])
if number == reverse_number:
print("The number is a palindrome.")
else:
print("The number is not a palindrome.")
Enter a number15
The number is not a palindrome.
if denominator != 0:
result = numerator / denominator
print("Result of division:", result)
else:
print("Cannot divide by zero.")
QUES 8: Plot a scatter plot, 2D, 3D, and subplot with four 2D plots.
'cmath' module:
The 'cmath' module defines functions that take a complex number as argument and return a
complex number as a result.
from cmath import *
from math import *
a= 4+7j
abs(a)
8.06225774829855
import math
abs_a= sqrt(a.real**2+a.imag**2)
abs_a
8.06225774829855
phase(a)
1.0516502125483738
import math
phase_a= atan(a.imag/a.real)
phase_a
1.0516502125483738
polar(a)
(8.06225774829855, 1.0516502125483738)
polar_a=(abs(a),phase(a))
polar_a
(8.06225774829855, 1.0516502125483738)
The form z=a+b i or z=( r c o s θ , r s i nθ ) is called the rectangular coordinate form of a complex
number.
The rect() method takes the modulus as the first argument and phase of the complex number as
the second argument and returns the corresponding complex number as follows.
rect(polar_a[0],polar_a[1])
(3.999999999999999+7j)
rect_a= (polar_a[0]*cos(polar_a[1]),polar_a[0]*sin(polar_a[1]))
rect_a
(3.999999999999999, 7.0)
All of the trigonometric functions take the complex number as input and also return a complex
number which represents the corresponding output for the trigonometric functions.
import cmath as cm
a= 4+7j
print("Complex number is:",a)
print("Sine of the complex number is:",cm.sin(a))
print("Cosine of the complex number is:",cm.cos(a))
print("Tangent of the complex number is:",cm.tan(a))
print("Inverse Sine of the complex number is:",cm.asin(a))
print("Inverse Cosine of the complex number is:",cm.acos(a))
print("Inverse Tangent of the complex number is:",cm.atan(a))
Lab2- Assignment
Q1. Write a Python program that accepts three complex numbers from the user and verifies the
following property. " Any three set complex numbers 𝑧 1 , 𝑧 2 , a n d 𝑧 3 satisfies the commutative,
associative and distributive laws. "
# Distributive law
distributive_law = z1 * (z2 + z3) == (z1 * z2) + (z1 * z3)
def main():
# Accept three complex numbers from the user
z1 = complex(input("Enter the first complex number (in the form
a+bj): "))
z2 = complex(input("Enter the second complex number (in the form
a+bj): "))
z3 = complex(input("Enter the third complex number (in the form
a+bj): "))
# Verify properties
results = verify_properties(z1, z2, z3)
# Display results
print("\nResults:")
print(f"(i) Commutative law for addition: {results[0]}")
print(f"(ii) Commutative law for multiplication: {results[1]}")
print(f"(iii) Associative law for addition: {results[2]}")
print(f"(iv) Associative law for multiplication: {results[3]}")
print(f"(v) Distributive law: {results[4]}")
if __name__ == "__main__":
main()
Enter the first complex number (in the form a+bj): 7+8j
Enter the second complex number (in the form a+bj): 8+9j
Enter the third complex number (in the form a+bj): 9+2j
Results:
(i) Commutative law for addition: True
(ii) Commutative law for multiplication: True
(iii) Associative law for addition: True
(iv) Associative law for multiplication: True
(v) Distributive law: True
Q2. Write a Python program to input a complex number from the user and prove the following. "
The sum of two conjugate complex numbers is real. "
def complex_number():
real = float(input("Enter the real part: "))
imag = float(input("Enter the imaginary part: "))
return complex(real, imag)
# Get three complex numbers
z1 = complex_number()
z2 = complex_number()
# Display the entered complex numbers
print("\nYou entered the following complex numbers:")
print("z1:", z1)
print("z2:", z2)
conjugate_z1 = z1.conjugate()
print("conj_z1:",conjugate_z1)
print()
conjugate_z2 = z2.conjugate()
print("conj_z2:",conjugate_z2)
print()
# The sum of two conjugate complex numbers is real.
Sum = conjugate_z1 + conjugate_z2
if Sum.imag == 0:
print("The sum is a real number.")
else:
print("The sum is not a real number.")
conj_z2: (3+6j)
Q3. Write a Python program to input a complex number from the user and prove the following. "
The product of two conjugate complex numbers is real. "
def is_product_of_conjugates_real(z):
# Conjugate of complex number
conjugate_z = z.conjugate()
# Product of conjugates
product_of_conjugates = z * conjugate_z
def main():
# Accept a complex number from the user
z = complex(input("Enter a complex number (in the form a+bj): "))
# Display results
print("\nResults:")
print(f"The conjugate of {z} is {z.conjugate()}")
print(f"The product of conjugates is: {result}")
print(f"The product of conjugates is real: {is_real}")
if __name__ == "__main__":
main()
Results:
The conjugate of (2+4j) is (2-4j)
The product of conjugates is: (20+0j)
The product of conjugates is real: True
Q4. Prove that for any two complex numbers |𝑧1+𝑧2|≤|𝑧1|+|𝑧2|, for two complex numbers 𝑧1
and 𝑧2.
# Display results
print("\nResults:")
print(f"|z1 + z2| = {result_lhs}")
print(f"|z1| + |z2| = {result_rhs}")
print(f"The triangle inequality is satisfied: {is_satisfied}")
if __name__ == "__main__":
main()
Enter the first complex number (in the form a+bj): 6+7j
Enter the second complex number (in the form a+bj): 5+9j
Results:
|z1 + z2| = 19.4164878389476
|z1| + |z2| = 19.515174598279888
The triangle inequality is satisfied: True
Q5. Write a Python program that shows that the following statement is true. " When the sum of
two complex numbers is real and the product of two complex numbers is also real then the
complex numbers are conjugate. "
return are_conjugate
def main():
# Accept two complex numbers from the user
z1 = complex(input("Enter the first complex number (in the form
a+bj): "))
z2 = complex(input("Enter the second complex number (in the form
a+bj): "))
# Display results
print("\nResults:")
print(f"The sum of the complex numbers is real: {(z1 + z2).imag ==
0}")
print(f"The product of the complex numbers is real: {(z1 *
z2).imag == 0}")
print(f"The complex numbers are conjugate: {are_conjugate}")
if __name__ == "__main__":
main()
Enter the first complex number (in the form a+bj): 8+7j
Enter the second complex number (in the form a+bj): 8-7j
Results:
The sum of the complex numbers is real: True
The product of the complex numbers is real: True
The complex numbers are conjugate: True
import cmath
z=complex(90,4)
print("The complex number is",z)
s=cmath.exp(z)
print("LHS= e^z=",s)
d=(cmath.exp(z.real))*(cmath.cos(z.imag)+1j*cmath.sin(z.imag))
print("RHS= ",d)
if(d==s):
print("Eulers law verified")
else:
print("Eulers law not verified")
z1= complex(2.5,1.9)
z2= complex(1.5,2.9)
z3= complex(-2,2.2)
w1= abs(z1)
w2= abs(z2)
w3=abs(z3)
c=max(w1,w2,w3)
if c==w1:
print("z1=",z1,"is the farthest from the origion")
elif c ==w2:
print("z2=",z2,"is the farthest from the origin")
elif c== w3:
print("z3=",z3,"is the farthest from the origion")
print("The distance from the origin is: ",c)
Practice Questions
Ques 1: Write a python program to plot the fourth roots of unity
import numpy as np
import matplotlib.pyplot as plt
from sympy import *
x= Symbol('x')
s= x**4-1
t=solve(s)
print(t)
for i in range(len(t)):
z=complex(t[i])
plt.scatter(z.real,z.imag)
plt.text(z.real,z.imag,z)
[-1, 1, -I, I]
Ques 2: Write a python program to plot the nth roots of unity
import numpy as np
import matplotlib.pyplot as plt
from sympy import *
n=int(input("Enter the value of n:"))
x= Symbol('x')
s= x**n-1
t=solve(s)
print(t)
for i in range(len(t)):
z=complex(t[i])
plt.scatter(z.real,z.imag)
plt.text(z.real,z.imag,z)
import cmath
#Addition
def add(num1,num2):
return num1 +num2
#subtraction
def subtract(num1,num2):
return num1-num2
#multiplication
def multiply(num1,num2):
return num1*num2
#user input
select = int(input("Select operations from 1,2,3,4,5,6,7,8,9:"))
c1= complex(input("Enter first complex number (a+jb): "))
c2= complex(input("Enter second complex number (c+jd):"))
if select == 1:
print(c1, "+",c2,"=", add(c1,c2))
elif select == 2:
print(c1, "-",c2,"=",subtract(c1,c2))
elif select == 3:
print(c1, "*",c2,"=",multiply(c1,c2))
elif select == 4:
print(c1, "/",c2,"=",divide(c1,c2))
elif select == 5:
print('Argument of c1 is', cmath.phase(c1))
print('Argument of c2 is', cmath.phase(c2))
else:
print("Invalid input")
Please select the operation -
1.Add
2.Subtract
3.Multiply
4.Divide
5.Argument
6.Absolute values
7.Polar conversion
8.Rectangular conversion
9.Plotting
Lab 3
AIM: To find the limit of the given complex sequence in Python.
limit_real_z=limit(real_z,z, inf)
limit_img_z=limit(img_z,z,inf)
x= []
y= []
l= int(input("Enter the lower limit of the range:"))
u= int(input("Enter the upper limit of the range:"))
b=1
figure(figsize=(6,5))
for i in range(0,u-1):
re= 1/b
im= (b-1)/b
x.append(re)
y.append(im)
b+=1
plt.scatter(x,y,color='r')
plt.scatter(a.real,a.imag,color='g')
show()
1j
Enter the lower limit of the range:50
Enter the upper limit of the range:100
Find the limit of the following complex sequences:
2
n
1) i (
n +1 )
2
z=Symbol('z')
a= complex(limit(0,z,inf),limit((z**2)/(z**2+1),z,inf)) #evaluating
the limit of the sequence
print(a)
x=[]
y=[]
x.append(re)
y.append(im)
b=b+1
plt.figure(figsize=(8,8))
plt.scatter(x,y,color='r')
plt.scatter(a.real,a.imag,color='g')
plt.show()
1j
Enter the lower limit of the range:50
Enter the upper limit of the range:100
n 7n
2) ( 1+4 n ) +i ( n+ 4 )
import matplotlib.pyplot as plt
z=Symbol('z')
a=complex(limit(((1+4/z)**z),z,np.inf),
limit((7*z/(z+4)),z,np.inf))#evaluating the limit of the sequence
print(a)
x=[]
y=[]
x.append(re)
y.append(im)
b=b+1
plt.figure(figsize=(8,8))
plt.scatter(x,y,color='r')
plt.scatter(a.real,a.imag,color='g') #plotting the limit of the
sequence
plt.show()
(54.598150033144236+7j)
Enter the lower limit of the range:150
Enter the upper limit of the range:350
3) √(¿ n+ 1)−i ¿ ¿
import matplotlib.pyplot as plt
z=Symbol('z')
a=complex(limit((sqrt(z+1)),z,np.inf),limit(sqrt(z)
+3,z,np.inf))#evaluating the limit of the sequence
print(a)
x=[]
y=[]
plt.figure(figsize=(8,8))
plt.scatter(x,y,color='r')
plt.scatter(a.real,a.imag,color='g') #plotting the limit of the
sequence
plt.show()
(inf+infj)
Enter the lower limit of the range:75
Enter the upper limit of the range:300
4) () ( )
1 n
2
+n
1 −i
2
import matplotlib.pyplot as plt
z=Symbol('z')
a=complex(limit((1/2)**z+z/2,z,inf),limit((-z/2),z,inf))#evaluating
the limit of the sequence
print(a)
x=[]
y=[]
plt.figure(figsize=(8,8))
plt.scatter(x,y,color='r')
plt.scatter(a.real,a.imag,color='g') #plotting the limit of the
sequence
plt.show()
(inf-infj)
Enter the lower limit of the range:100
Enter the upper limit of the range:150
(
( 3+ 4 i )2
5) n 5 )
import matplotlib.pyplot as plt
z=Symbol('z')
a=complex(limit(z*real_part,z,inf),limit(z*imag_part,z,inf))#evaluatin
g the limit of the sequence
print(a)
x=[]
y=[]
plt.figure(figsize=(8,8))
plt.scatter(x,y,color='r')
plt.scatter(a.real,a.imag,color='g') #plotting the limit of the
sequence
plt.show()
(-inf+infj)
Enter the lower limit of the range:50
Enter the upper limit of the range:100
( ) ( )
n
5 5+ n
6) 3+
n
+i
n
import matplotlib.pyplot as plt
z=Symbol('z')
a=complex(limit((3+ 5/z)**z,z,inf),limit(((5+z)/z),z,inf))#evaluating
the limit of the sequence
print(a)
x=[]
y=[]
plt.figure(figsize=(8,8))
plt.scatter(x,y,color='r')
plt.scatter(a.real,a.imag,color='g') #plotting the limit of the
sequence
plt.show()
(inf+1j)
Enter the lower limit of the range:50
Enter the upper limit of the range:100
from datetime import date
today= date.today()
print("Today's date:", today)
u=x**2-y**2
v=2*x*y
print("Given expression f(z):",u,"+i",v)
diff_ux=diff(u,x,1)
print("\n Derivative of u wrt x:",diff_ux)
diff_uy=diff(u,y,1)
print("\n Derivative of u wrt y:",diff_uy)
diff_vx=diff(v,x,1)
print("\n Derivative of v wrt x:",diff_vx)
diff_vy=diff(v,y,1)
print("\n Derivative of v wrt y:",diff_vy)
if (diff_ux==diff_vy and diff_uy==-diff_vx):
print("\n f(z) satisfies CR equations.")
else:
print("\n f(z) does not satisfy CR equations.")
Question : Write a python program to check whether f ( z )=2 x y+ 2 x i satisfies the CR equations
Derivative of v wrt x: 2
Derivative of v wrt y: 0
( x −i y )
Question : Write a python program to check whether f ( z )= satisfies the CR equations
( x2+ y2)
Question : Write a python program to check whether f ( z )=2 x +i x y 2 satisfies the CR equations
Derivative of u wrt x: 2
Derivative of u wrt y: 0
Question : Write a python program to check whether f ( z )=x y +i y satisfies the CR equations
Derivative of u wrt x: y
Derivative of u wrt y: x
Derivative of v wrt x: 0
Derivative of v wrt y: 1
Question : Write a python program to check whether $f(z)=x^3 -3ix^2y-3xy^2 +iy^3 $ satisfies
the CR equations
Question : Write a python program to accept any complex function from the user and check
whether it satisfies the CR equations.
Enter u :x**y+2*x*y
Enter v:x*y
Given expression f(z): x**y+2*x*y +i x*y
Derivative of v wrt x: y
Derivative of v wrt y: x
Question : Write a python program to check whether $f(z)=(x+iy)^3 $ satisfies the CR equations
f=(x+i*y)**3
u= re(f)
v= im(f)
diff_ux = diff(u, x, 1)
diff_uy = diff(u, y, 1)
diff_vx = diff(v, x, 1)
diff_vy = diff(v, y, 1)
harmonic(x**3-y**3+x+1)
harmonic(x**3-3*x*y**2+2*x)
Harmonic Conjugates
Let u ( x , y ) be a harmonic function, then a function v ( x , y ) is said to be harmonic conjugate of
u ( x , y ) if 1. v ( x , y ) is harmonic 2.u and v satisfies CR Equations
Write a general program to check whether v is harmonic conjugate of u
from sympy import *
x,y=symbols('x,y')
def verify(u,v):
dv_dx2=diff(v,x,2)
dv_dy2=diff(v,y,2)
du_dx=diff(u,x)
du_dy=diff(u,y)
dv_dx=diff(v,x)
dv_dy=diff(v,y)
if dv_dx2 +dv_dy2==0:
if du_dx==dv_dy and du_dy==-dv_dx:
print("v is a harmonic conjugate of u ")
else:
print("CR Equations are not satisfied")
else:
print("v itself is not a harmonic function")
v is a harmonic conjugate of u
2 2
−x y
Ques 1: Check if 2
+
2
is the harmonic conjugate of x 2 − y 2+ x +1
verify(x**2-y**2+x+1,-x**2/2 + y**2/2)
2 2
−x y
Ques 2: Check if 2
+
2
is the harmonic conjugate of x y
verify(x*y,-x**2/2+y**2/2)
v is a harmonic conjugate of u
verify(x**2-y**2,2*x*y)
v is a harmonic conjugate of u
def conjugate():
init_printing(use_latex=True)
x,y,c=symbols("x,y,c")
u=input("Enter the function u:")
print("")
dx2=diff(u,x,2)
dy2=diff(u,y,2)
if dx2+dy2==0:
print("The function",u,"is harmonic.")
dux=diff(u,x)
duy=diff(u,y)
iv=integrate(-duy,x)
vy=diff(iv,y)
gy= dux-vy
ig=integrate(gy,y)
v=iv+ig
print("The harmonic conjugate of u is:")
display(v)
else:
print("The function",u,"is not harmonic.")
Lab 6
ortho_family(2,4)
(-4.829809383269385, -22.720847417619233)
#Plotting u
from numpy import *
from sympy import *
x,y=symbols('x y')
p1=plot_implicit(Eq(exp(x)*cos(y),5),line_color='blue',line_width=2)
None
#Plotting v
from numpy import *
from sympy import *
x,y=symbols('x y')
p2=plot_implicit(Eq(exp(y)*sin(x),10))
None
#Plotting u and v together
from numpy import *
from sympy import *
import matplotlib.pyplot as plt
x,y=symbols('x y')
p1=plot_implicit(Eq(exp(x)*cos(y),10))
p2=plot_implicit(Eq(exp(y)*sin(x),10))
None
p1.extend(p2)
p1
p1.show()
Ques 2: x 3 y −i x y 3=C
import numpy as np
def ortho_family(x,y):
u=x**3*y
v=x*y**3
return u,v
ortho_family(2,4)
(32, 128)
#Question 3
conjugate()
LAB 7
∂v ∂v
$\textbf{Case II: When v is given}$ Step 1: Find and equate it to u x. Step 2: Find and
∂x ∂y
equate it to u y . Step 3: Find f ′ ( x , y ) by the formula f ′ ( x , y )=v y + i v x Step 4: Replace $ x$ by z
and y by 0 in f ′ ( x , y ) to get f ′ ( z , 0 ) . Step 5: Find f ( z ) by the formula f ( z )= ∫ f ′ ( z , 0 ) d z +c
import pprint
import sympy as sp
x,y,z=sp.symbols("x,y,z")
def u_giv(u):
ux=sp.diff(u,x)
print("ux=",ux)
uy=sp.diff(u,y)
print("uy=",uy)
fp=sp.simplify(ux-1j*uy)
print("f'(x,y)=",str(fp))
g=fp.subs({x:z,y:0})
print("f'(z,0)=",g)
f=sp.integrate(g,z)
return ("f="+str(f))
def v_giv(v):
vx=sp.diff(v,x)
print("vx=",vx)
vy=sp.diff(v,y)
print("vy=",vy)
fp=sp.simplify(vy+1j*vx)
print("f'(x,y)=",str(fp))
g=fp.subs({x:z,y:0})
print("f'(z,0)=",g)
f=sp.integrate(g,z)
return ("f="+str(f))
sp.pprint(u_giv(sp.exp(x)*(x*sp.cos(y)-y*sp.sin(y))))
print()
sp.pprint(v_giv(1j*sp.exp(x)*(x*sp.cos(y)-y*sp.sin(y))))
import sympy as sp
x,y,z=sp.symbols("x,y,z")
def u_giv(u):
ux=sp.diff(u,x)
print("ux=",ux)
uy=sp.diff(u,y)
print("uy=",uy)
fp=sp.simplify(ux-1j*uy)
print("f'(x,y)=",str(fp))
g=fp.subs({x:z,y:0})
print("f'(z,0)=",g)
f=sp.integrate(g,z)
return ("f="+str(f))
F=u_giv(x**2-y**2)
sp.pprint(F)
ux= 2*x
uy= -2*y
f'(x,y)= 2.0*x + 2.0*I*y
f'(z,0)= 2.0*z
f=1.0*z**2
import sympy as sp
x,y,z=sp.symbols("x,y,z")
def v_giv(v):
vx=sp.diff(v,x)
print("vx=",vx)
vy=sp.diff(v,y)
print("vy=",vy)
fp=sp.simplify(vy+1j*vx)
print("f'(x,y)=",str(fp))
g=fp.subs({x:z,y:0})
print("f'(z,0)=",g)
f=sp.integrate(g,z)
return ("f="+str(f))
F=v_giv(-2*sp.sin(x)*(e**x-e**-y))
z
ℯ
ⅈ⋅z
-1.0⋅ⅈ⋅ℯ
3
1.0⋅z + z⋅(2.0 - 2.0⋅ⅈ)
$\textbf{Conclusion:} $Analytics functions are found out easily in python using the Milne
Thomson Method
import math
import cmath
import sympy as sp
x,y,z=sp.symbols('x,y,z')
f=sp.exp(z)
r=sp.exp(x)*sp.cos(y)
i=sp.exp(x)*sp.sin(y)
du_dx=sp.diff(r,x)
dv_dy=sp.diff(i,y)
du_dy=sp.diff(r,y)
dv_dx=sp.diff(i,x)
if du_dx==sp.simplify(dv_dy) and du_dy==sp.simplify(-dv_dx):
a=1
else:
a=0
print('a=',a)
d=sp.diff(f)
print('derivative=',d)
s=sp.solve(d,z)
print('critical points=',s)
if len(s)==0:
b=1
else:
b=0
print('b=',b)
if a==1 and b==1:
print("This is a conformal transformation")
else:
print("This is not a conformal transformation")
a= 1
derivative= exp(z)
critical points= []
b= 1
This is a conformal transformation
2 2 2
2. z =x +2 x y i− y
x,y,z=sp.symbols('x,y,z')
f=z**2
r=x**2-y**2
i=2*x*y
du_dx=sp.diff(r,x)
dv_dy=sp.diff(i,y)
du_dy=sp.diff(r,y)
dv_dx=sp.diff(i,x)
if du_dx==sp.simplify(dv_dy) and du_dy==sp.simplify(-dv_dx):
a=1
else:
a=0
print('a=',a)
d=sp.diff(f)
print('derivative=',d)
s=sp.solve(d,z)
print('critical points=',s)
if len(s)==0:
b=1
else:
b=0
print('b=',b)
if a==1 and b==1:
print("This is a conformal transformation")
else:
print("This is not a conformal transformation")
a= 1
derivative= 2*z
critical points= [0]
b= 0
This is not a conformal transformation
3. s i n ( z )=c o s h (− y ) c o s ( x ) +i s i nh ( − y ) s i n ( x )
x,y,z=sp.symbols('x,y,z')
f=sp.sin(z)
r=sp.cosh(-y)*sp.cos(x)
i=sp.sinh(-y)*sp.sin(x)
du_dx=sp.diff(r,x)
dv_dy=sp.diff(i,y)
du_dy=sp.diff(r,y)
dv_dx=sp.diff(i,x)
if du_dx==sp.simplify(dv_dy) and du_dy==sp.simplify(-dv_dx):
a=1
else:
a=0
print('a=',a)
d=sp.diff(f)
print('derivative=',d)
s=sp.solve(d,z)
print('critical points=',s)
if len(s)==0:
b=1
else:
b=0
print('b=',b)
if a==1 and b==1:
print("This is a conformal transformation")
else:
print("This is not a conformal transformation")
a= 1
derivative= cos(z)
critical points= [pi/2, 3*pi/2]
b= 0
This is not a conformal transformation
if axis=="y":
xref=-x
yref=y
elif axis=="x":
xref=x
yref=-y
x=[x,xref]
y=[y,yref]
plt.scatter(x,y,color=["red","black"])
plt.axhline(0,color="black")
plt.axvline(0,color='blue')
<matplotlib.lines.Line2D at 0x24ef8d1eca0>
Question:Plot the reflection of the points (3,2) and (5,1) with respect to both the x-axis and y-axis
in the same place.
[<matplotlib.lines.Line2D at 0x24ef94226d0>]
The reflection of a complex number z about the real is its conjugate ź and the
reflection about the imaginary axis is − ź
Question: Plot the reflection of the points -2+j,1+4j,3+2j,-2+1j with respect to imaginary axis in
plane.
plt.polar([np.angle(v),np.angle(w)],
[np.abs(v),np.abs(w)],marker='o',label="Translation Point")
translation (3,2,2,3)
(5+5j)
Rotation: w=z∗ei θ is the rotation of the complex number z about an angle θ to obtain a
complex number w of the same magnitude.
import math
import cmath
from matplotlib.pylab import *
from numpy import *
a=complex(3,2)
b=complex(2,3)
alpha=angle(b)
w=a*exp(alpha*1j)
polar([0,angle(a)],[0,abs(a)],marker='o',color='red')
[<matplotlib.lines.Line2D at 0x24ef967fc40>]
Bilinear Transformation
Transformation of the form
a z +b
w=T ( z ) =
c z+ d
are called Bilinear Transformation, where a , b , c , d are complex or real constants. To find the
bilinear transformation that takes the ordered triple ( z 1 , z 2 , z 3 ) to the ordered triple ( w1 , w2 , w3 )
we use the formula
( w − w1 ) ( w 2 − w3 ) ( z − z 1 )( z 2 − z 3 )
=
( w1 − w2 ) ( w 3 − w ) ( z 1 − z2 ) ( z 3 − z )
BT(1,1j,-1,1,0,-1)
Question 2: Find the bilinear transformation that takes (2,1,i) onto (i,1,2).
BT(2,1,1j,1j,1,2)
Question 3: Find the bilinear transformation that takes (1,i,20) onto (2,9,-1).
BT(1,1j,20,2,9,-1)
Question 4: Find the bilinear transformation that takes (5,-1,-3) onto (1,i,-1).
BT(5,-1,-3,1,1j,-1)
Conclusion
In this class we learnt how to solve bilinear transformation using python.
Lab-9
MACLAURIN SERIES
Aim: To learn about the maclaurin series in python
from datetime import datetime
current_date = datetime.now()
print("Current Date:", current_date.date())
Current Date: 2024-04-09
import numpy as np
from sympy import *
import math
def factorial(n):
fact=1
for i in range(1,n+1):
fact=fact*i
return fact
x,z,z0=symbols('x,z,z0')
z0=0
fun=1/(1-x)
series=0
dif=fun
for i in range(8):#the upper range will be the highest number needed
to your expamsion
if(i!=0):
dif=diff(dif)
exp=dif.subs(x,0)*(z)**i/factorial(i)
series=series+exp
else:
exp=dif.subs(x,0)*(z)**i/factorial(i)
series=series+exp
pprint(series)
7 6 5 4 3 2
z + z + z + z + z + z + z + 1
import numpy as np
from sympy import *
import math
def factorial(n):
fact=1
for i in range(1,n+1):
fact=fact*i
return fact
x,z,z0=symbols('x,z,z0')
z0=2*I
fun=1/(1-x)
series=0
dif=fun
for i in range(4):#the upper range will be the highest number needed
to your expamsion
if(i!=0):
dif=diff(dif)
exp=dif.subs(x,z0)*(z-z0)**i/factorial(i)
series=series+exp
else:
exp=dif.subs(x,z0)*(z-z0)**i/factorial(i)
series=series+exp
print("The taylor series expansion of",fun,"is",)
pprint(series)
x=np.linspace(-np.pi,np.pi,200)
y=np.zeros(len(x))
plt.plot(x,np.sin(x),'k',label='Analytic')
plt.grid()
plt.title('Taylor eries approximation of various orders')
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
plt.show()
Conclusion
In this class we learnt how to solve maclaurin series and learnt how to plot the series.