mathajax

Complex number on Polar coordinates

A complex number is represented on polar coordinates to simplify arithmetic operation like multiplication and division on the complex numbers. The complex number's real and imaginary number is converted into polar coordinates' parameter r (radius) and θ (angle/radiant).

complex number on polar

Complex number on polar coordinates

A complex number z = a + ib on polar graph representation is r(cos(θ)+isin(θ)).
Here r  - radius , θ  - angle/radiant derived from the complex number c.

r  =  |z|  = √ a2+ b2 

θ   =   atan2  ( b , a )


Complex number on polar form - Multiplication

 
      complex number
              z1  = a + ib 
              z2  = a + ib
      polar form
          z1= r1(cos(θ1)+isin(θ1))          
          z2= r2(cos(θ2)+isin(θ2)) 
     Multiplication
         z1 x z2  =  (r1 x r2)(cos(θ1+θ2)+isin(θ1+θ2))  
   

Complex number on polar form - Division

 
      complex number
              z1  = a + ib 
              z2  = a + ib
      polar form
          z1= r1(cos(θ1)+isin(θ1))          
          z2= r2(cos(θ2)+isin(θ2)) 
     Division
         z1 / z2  =  (r1 / r2)(cos(θ1-θ2)+isin(θ1-θ2))  
   

Complex number on Polar co-ordinates - Java programming code

The Java class Polar has two members radius and theta (r,θ) to represent a complex number on polar coordinates and two member functions product and divide to carry out multiplication and division operation on complex numbers in the polar form. In addition to, It converts complex number into polar form and vice versa.


package math.complex;

public class Polar {

 public double r,theta;
 
 public Polar() {
  this.r = 0;
  this.theta=0;
 }
 public Polar(double r,double theta) {
  this.r = r;
  this.theta = theta;
 }
 
 public Polar(Complex C1) 
 {  
  double tmp = Math.pow(C1.real,2.0)  + Math.pow(C1.imag,2.0);  
  this.r   = Math.sqrt( tmp);  
  this.theta =  Math.atan2( C1.imag,C1.real);     
 }
 
 public double abs() {  
  return this.r;
 }
 
 public Complex toComplex() 
 {
  Complex z = new Complex();
  z.real  = r*Math.cos(this.theta);
  z.imag  = r*Math.sin(this.theta);
  return z;
 }
 
 public Polar product(Polar P) 
 {  
  Polar temp =new Polar();
  temp.r=this.r*P.r;
  temp.theta = this.theta + P.theta;
  return temp;
 }
 
 public Polar divide(Polar P) 
 {  
  Polar temp =new Polar();
  temp.r=this.r/P.r;
  temp.theta = this.theta - P.theta;
  return temp;
 }
 
 public String toString() {  
  return this.r +"( cos(" +this.theta +") + " + 
                                 "isin(" +this.theta +")"  +" )" ;
 }
    
 
 
 public static void main(String str[]) {
      
  
    System.out.println("\nComplex number to Polar form");
  Complex C1 = new Complex(3,1);  
  System.out.println("Complex C1 :" + C1);
  Polar P1 = new Polar(C1);
  System.out.println("Polar P1 :" + P1);
  
  Complex C2 = new Complex(4,-2);  
  System.out.println("Complex C2 :" + C2);
  Polar P2 = new Polar(C2);
  System.out.println("Polar P2 :" + P2);
  
     System.out.println("\nComplex numbers product on Polar form");
  Polar P3= P1.product(P2);
  
  System.out.println( "Polar P3=P1xP2 : " + P3.toString());
  System.out.println( "Complex C1xC2 : " + P3.toComplex());
  
    System.out.println("\Complex numbers division on Polar form");
  Polar P4= P1.divide(P2);
  System.out.println( "Polar P4=P1/P2 : " + P4.toString());  
  System.out.println( "Complex C1/C2 : " + P4.toComplex());
  
 }
}

Complex number on Polar form - Arithmetic Operation output


Complex number to Polar form

Complex C1 :3.0+1.0i
Polar P1 :3.16228( cos(0.3218) + isin(0.3218) )
Complex C2 :4.0-2.0i
Polar P2 :4.47214( cos(-0.4636) + isin(-0.4636) )

Complex numbers product on Polar form
Polar P3=P1xP2 : 14.14214( cos(-0.14189) + isin(-0.14189) )
Complex C1xC2 : 14.00-2.004i

Complex numbers division on Polar form
Polar P4=P1/P2 : 0.70711( cos(0.7854) + isin(0.7854) )
Complex C1/C2 : 0.501+0.5i

Comments

Popular posts from this blog

Matrix Forward and Back Substitution

Chebyshev distance between two points

Solve System of Linear Equations by LU Decompose

Complex number Multiplication and Division

Matrix Determinant, Matrix Adjoint and Matrix Inverse