SOURCE CODE
//DATE: 21.08.25
//AIM: To perform the basic opera ons on complex numbers.
clc
clear
x=3
y=4
a=4
b=-5
z1=complex(x,y)
z2=complex(a,b)
disp("the addi on of two complex numbers is:",string(z1+z2))
disp("the substrac on of two complex numbers is:",string(z1-z2))
disp("the mul plica on of two complex numbers is:",string(z1*z2))
disp("the division of two complex numbers is:",string(z1/z2))
disp("the conjugate of ",string(z1),"is:",string(x-%i*y))
disp("the conjugate of ",string(z2),"is:",string(a-%i*b))
CONSOLE OUTPUT
"the addi on of two complex numbers is:"
"7-%i"
"the substrac on of two complex numbers is:"
"-1+%i*9"
"the mul plica on of two complex numbers is:"
"32+%i"
"the division of two complex numbers is:"
"-0.195122+%i*0.7560976"
"the conjugate of "
"3+%i*4"
"is:"
"3-%i*4"
"the conjugate of "
"4-%i*5"
"is:" "4+%i*5"
SOURCE CODE
//DATE: 21.08.25
//AIM: To find the modulus and argument of a complex number.
clc
clear
x=input("enter the real part of the complex number:")
y=input("enter the imaginary part of the complex number:")
z=complex(x,y)
r=sqrt(x^2 + y^2)
arg=atand(y/x)
disp("the modulus of the complex number is:",r)
disp("the argument of the complex number (in degrees) is:",arg)
CONSOLE OUTPUT
enter the real part of the complex number:3
enter the imaginary part of the complex number:4
"the modulus of the complex number is:"
5.
"the argument of the complex number (in degrees) is:"
53.130102
SOURCE CODE
//DATE: 21.08.25
//AIM: To represent a complex number in polar form.
func on [r, arg]=polar(x, y)
x=input("enter the real part of the complex number:")
y=input("enter the imaginary part of the complex number:")
r=sqrt(x^2 + y^2)
arg=atand(y/x)
endfunc on
[a,b]=polar()
disp("the polar form of the given complex number
is:",string(a)+"(cos"+string(b)+string ("+i")+"sin"+string(b)+")")
c=cosd(b);s=sind(b)
disp("the final polar form is:",string(a)+"("+string(c)+string ("+i")+string(s)+")")
CONSOLE OUTPUT
enter the real part of the complex number:3
enter the imaginary part of the complex number:4
"the polar form of the given complex number is:"
"5(cos53.130102+isin53.130102)"
"the final polar form is:"
"5(0.6+i0.8)"
SOURCE CODE
//DATE: 21.08.25
//AIM: Plo ng complex numbers.
clc
clear
clf
figure(1)
hf=gcf()
hf .background=[-2]
ha= gca()
ha .data_bounds=[-5,5,-6,6]
//Define two complex numbers
z1=complex(3,4)
z2=complex(4,-5)
//plot complex numbers
x=real(z1)
y=imag(z1)
plot([0,x],[0,y],'r')
x1=real(z2)
y1=imag(z2)
plot([0,x1],[0,y1],'b')
tle("plo ng complex numbers")
xlabel("real axis",'fontsize', 4)
ylabel("imaginary axis",'fontsize', 4)
legend('$\Large{z_{1}=3+4i}$','$\Large{z_{2}=4+-5i}$')
CONSOLE OUTPUT
SOURCE CODE
//DATE: 28.08.25
//AIM: To find the roots of a complex number
clc
clear
func on w=root(z, n)
x=real(z)
y=imag(z)
r=sqrt(x^2 + y^2)
arg=atand(y/x)
for k=0:n-1
w(k+1)=r^(1/n)*(cos((arg+2*%pi*k)/n)+ %i*sin((arg+2*%pi*k)/n))
end
endfunc on
z=complex(3,4)
a=root (z,3)
disp("the roots are:",a)
CONSOLE OUTPUT
"the roots are:"
0.7148195 - 1.5533998i
0.9878739 + 1.3957517i
-1.7026934 + 0.1576481i
SOURCE CODE
//DATE: 04.09.25
//AIM: Transforma ons of complex numbers.
clc
clear
clf
z=complex(3,4)
//transla on
w=complex(5,6)
z1=w+z
disp("the transla on of "+string(z)+"is "+string(z1))
figure(1)
ha=gca()
ha.data_bounds=[-10,10,-10,10]
xgrid()
x=real(z1)
y=imag(z1)
plot([0,real(z)],[0,imag(z)],"r")
plot([0,x],[0,y],"b")
legend("original","translated")
tle("transla on")
//rota on
z2=z*%e^(%i*2)
disp("the rota on of "+string(z)+"is "+string(z2))
figure(2)
ha=gca()
ha.data_bounds=[-10,10,-10,10]
xgrid()
x=real(z1)
y=imag(z1)
plot([0,real(z)],[0,imag(z)],"r")
x1=real(z2)
y1=imag(z2)
plot([0,x1],[0,y1],"b")
legend("original","rotated")
tle("rota on")
//stretching
z3=0.5*z
disp("the stretched version of "+string(z)+"is "+string(z3))
figure(3)
ha=gca()
ha.data_bounds=[-10,10,-10,10]
xgrid()
x=real(z1)
y=imag(z1)
plot([0,real(z)],[0,imag(z)],"r")
x2=real(z3)
y2=imag(z3)
plot([0,x2],[0,y2],"b")
legend("original","stretched")
tle("stretching")
//inversion
z4=1/z
disp("the inversion of "+string(z)+"is "+string(z4))
figure(4)
ha=gca()
ha.data_bounds=[-10,10,-10,10]
xgrid()
x=real(z1)
y=imag(z1)
plot([0,real(z)],[0,imag(z)],"r")
x3=real(z4)
y3=imag(z4)
plot([0,x3],[0,y3],"b")
legend("original","inverted")
tle("inversion")
CONSOLE OUTPUT
"the transla on of 3+%i*4is 8+%i*10"
"the rota on of 3+%i*4is -4.8856302+%i*1.0633049"
"the stretched version of 3+%i*4is 1.5+%i*2"
"the inversion of 3+%i*4is 0.12-%i*0.16"