import numpy as np 
# import numpy

# this is a comment 

pi_number = np.pi
print(pi_number)

e_number = np.e
print(e_number)

# float with specific number of decimals 
print("pie is {0:.5f}, {1}".format(pi_number, " test"))
print(f"pi is {pi_number}")
print("The Euler number is {0:.2f}".format(e_number))

# scientific format with a given number of decimals 
x = 3074.1e4
print("x is {0:.2e}".format(x)) 

# define an array manually 
A = np.array([0, 3, 7, -2])
# print(A)
print("A is " + str(A))

# define an array with linearly spaced components 
B = np.linspace(0, 1, num=11, endpoint=True)
print("B is " + str(B))

# print the size of the array
print(np.size(A))
print(np.size(B))

# square 
x = 2.0 
y = np.square(x) 
print("y is " + str(y)) 

# square root
a = 36
b = np.sqrt(a)
print("b is " + str(b))

theta = np.pi/4
f = np.cos(theta)
print(f)
print(np.sqrt(2)/2)

# custom functions 
def my_function(x):
    return x**3

print(my_function(2))
print(my_function(3))
print(my_function(A))

B = np.array([[1, -2, 3, -4], [0, -1.5, 3, 7 + 1j]])
print(B*2)



print(type(B))

C = [1, 2, "test", my_function]
print(C)


M = np.ones((4, 7))
N = np.ones((7, 3))
print(np.matmul(M, N))


def another_function(x):
    return x**3 -3*x**2 + 2

x = np.linspace(-2, 2, num=101)
y = another_function(x)


print(np.size(x))
print(np.size(y))

import matplotlib.pyplot as plt

# make figure
fig = plt.figure()

# get the axes
ax = plt.axes()

# plot y array versus x array
# ax.plot(x, y)
ax.scatter(x, y, s=1)

# labels 
ax.set_xlabel('the x axis')
ax.set_ylabel('y = f(x)')

# show the plot 
plt.show()

