Basic transformations on complex number


/ Published in: Python
Save to your folder(s)

Effect of rotating the phase of the complex number


Copy this code and paste it in your HTML
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Tue Aug 12 19:59:00 2014
  4.  
  5. @author: Anish
  6. """
  7.  
  8. # Importing libraries
  9. import os
  10. os.system('cls')
  11. import numpy as np
  12. import matplotlib.pyplot as plt
  13. #j = sqrt(-1)
  14. r0 = 2.0
  15. theta = pi/4.0
  16. x0 = r0*cos(theta)
  17. y0 = r0*sin(theta)
  18. zvec = [x0+1j*y0,x0-1j*y0, sqrt(x0**2 +y0**2), -x0-1j*y0,-x0+1j*y0]
  19.  
  20. for ix in range(0, 5):
  21. x = real(zvec[ix])
  22. y = imag(zvec[ix])
  23. plot(x,y,'o')
  24. text(x, y,'z%1.0f'%(ix),fontsize = 12)
  25.  
  26. plt.xlabel('real')
  27. plt.ylabel('imaginary')

URL: transformations of a complex number

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.