#this code block imports some basic libraries we will need
import numpy as np
import matplotlib.pyplot as plt
import cmath as cm
import math
#remember, to exicute this block you need to press SHIFT + ENTERng code here...

#this code block sets up a 1D array with two entries that we can use to
#represent the complext number 3-4i
C1 = np.array([3,-4])
print(C1)
#notice the brackets around the whole array

# this code block creates a method (CAdd) that adds two complex numbers that
# are stored in numpy arrays
def CAdd(num1,num2):
result = [num1[0]+num2[0],num1[1]+num2[1]] #notice result is in the form of an array
return result

# We will use this code block to check that our CAddd method produces the expected
# results. We define a second complex number C2, then use the method and print
# the output
C2=np.array([3,5])
answer = CAdd(C1,C2) #remember C1 was defined above
print('The sum is =',answer)

# Use this code block to define the rest of the arithmetic operations on
# complet numbers.
def CMult(num1, num2):
return result
def CConj(num):
return result
def CDiv(num1, num2):
return result

# Use this code block to check that new methods produce the expected results.

A=2+5j
B=-4+2j
print ('A+B={}'.format(A+B))
print('A*B={}'.format(A*B))
print('A/B={}'.format(A/B))
print('A/B = ' + str(A/B))

# use this code block to write a method that converts complex
# numbers from their rectangular form to their polar form.
# Check your methods against the built in method cm.polar()
#input to RecToPolar should be a 1 x 2 numpy array [A,B]
def RecToPolar(num):
return result
#result should be a 1 x 2 numpy array [R,Theta]

# Use this code block to check that new method RecToPolar produces the expected results.
# Check your method against the built in cm.polar()
print(RecToPolar([3,4]))
print(cm.polar(3+4j))

# This code block multiples complex numbers in polar form
# then plots the original numbers and their product on the
# complex plane. The method PlotComplex() has been provided
# input to PlotComplex is a 1 x 2 numpy arrary [R,Theta] and
# a string containing the color of the plot
def PlotComplex(N,Color):
x = N[0]*np.cos(N[1])
y = N[0]*np.sin(N[1])
origin = [0,0]
plt.arrow(*origin, x, y, color=Color)
plt.scatter(x,y,color=Color)
plt.axis('scaled')
# PlotComplex does not return a value
C1 = [2, 0]
C2 = [1, np.pi/2]
PlotComplex(C1, 'blue')
PlotComplex(C2, 'red')
PlotComplex(CMult(C1, C2), 'm')