a = 2 + 3j
b = 5 - 2j
print("a + b=", a+b)
print("a * b=", a*b)

a = 2 + 3j
a_bar = 2 - 3j
print("a + a_bar = ", a + a_bar)
print("a * a_bar = ", a * a_bar)

import matplotlib.pyplot as plt
import numpy as np
import math

z1 = 3 + 4j

x_min = 0
x_max = 5.0

y_min = 0
y_max = 5.0

def plot_complex_number_geometric_representation(z,x_min,x_max,y_min,y_max):

    fig = plt.figure()

    ax = plt.gca()

    a = [0.0,0.0]
    b = [z.real,z.imag]

    head_length = 0.2

    dx = b[0] - a[0]
    dy = b[1] - a[1]

    vec_ab = [dx,dy]

    vec_ab_magnitude = math.sqrt(dx**2+dy**2)

    dx = dx / vec_ab_magnitude
    dy = dy / vec_ab_magnitude

    vec_ab_magnitude = vec_ab_magnitude - head_length

    ax.arrow(a[0], a[1], vec_ab_magnitude*dx, vec_ab_magnitude*dy, head_width=head_length, head_length=head_length, fc='black', ec='black')

    plt.xlim(x_min,x_max)
    plt.ylim(y_min,y_max)

    plt.grid(True,linestyle='-')

    plt.show()


plot_complex_number_geometric_representation(z1,x_min,x_max,y_min,y_max)

import numpy as np
A = np.array([[1,2,3]])
B = np.array([[7], [10], [9]])
A+B

A = np.array([[7], [10], [9]])
B = np.array([[1,2,3]])
C = np.array([[1, 2, 3], [5, 6, 7], [8,9,10]])

print("AB = ", np.matmul(A,B))
print("BA = ", np.matmul(B,A))
print("CA = ", np.matmul(C, A))
print("AC = ", np.matmul(A, C))

A = np.array([[1, 2], [3,4]])
B = np.array([[5, 6], [7,8]])
print("AB = \n", np.matmul(A,B))
print("BA = \n", np.matmul(B,A))

from scipy.linalg import orth
from numpy import linalg as LA

A = np.array([[1 + 3j, 2 - 1j], [3, 4 - 2j]]) 

data =orth(A)
x, y = data[:, 0], data[:, 1]
print("norm of x = %f" % LA.norm(x))
print("norm of y = %f" % LA.norm(y))
print("x dot y = ", np.vdot(x,y))



