Week 1:
Vectors: The Foundation of Everything — From Space to Qubits:
What is a vector?
A vector is like a “mathematical arrow”(or just an arrow in a space) with two properties:
Direction: Where it points
Magnitude: how long it is (also called longitude)
In math, a vector is just a list of numbers, like this:
v=(1,2,3)
Each number represents the coordinates in a space. But it depends on how many dimensions the space has, for example: If you are working with vectors in a cartesian plane(2D), your vectors will have 2 coordinates, the one in the x axis, and the other in the y axis. Instead, if you are working in 3D, your vector will have 3 coordinates, the one in the x axis, in the y axis, and in the z axis, and so on with each dimension you add to your space.
Where are vectors used?
Vectors are everywhere, even if we don’t see them!
Physics: Forces, velocity, electric fields
AI & Machine Learning: Data representation in multi-dimensional spaces.
Quantum Computing(my main goal :)): Qubits and superposition states.
How do we calculate its direction and magnitude?
You don’t need at the moment to calculate the direction with degrees, it is just to know that it can be in one direction or another, and it is a fundamental propertie of a vector
For the magnitude, there is a formula, which is:
$$\|v\|=\sqrt{x^2 + y^2}$$
The two lines in both sides of the v means that is the magnitude of v. This formula is just for 2D vectors, for 3D would be the same, but adding the squared z.Here is an example:
If we have the vector (3,4) its magnitude is:
$$\|v\| = \sqrt{3^2 + 4^2}=5$$
The magnitude is really important, we are going t see more about it the next week
How to operte with them?
At the moment, Iwill just explain you the 3 main operartions, and the more basic:
Vector addition: Vector addition is just picking the coordinates of the x axis, and calculate, and the same with the y axis, for example
v1=(1,2) v2=(2,3)
v1+v2=1+2(x coordinates), 2+3(y coordinates)
Really important, it is 1+2 , 2+3, we don’t put (1+2)+(2+3)
Final result= v1+v2=(3,5)
Vector substraction: The vector substraction it is the same as the addition, you just pick the coordinates of the same axis, and you calculate, here is an example:
v1=(3,5,6)(we can work with 3D vectors too) v2=(5,7,6)
The structure of a 3D vector is: (x,y,z), so, you do the substraction of x1-x2,y1-y2 etc:
The result of v1-v2=3-5,5-7,6-6=(-2,-2,0)Our goal when we operate with vectors in this way (when it gets more complicates it changes) is to create a new vector, operating with 2, so this two vectors, create a new, operating with them.
Vector multiplication: It is really important to do not mix vector multiplication (a vector multiplied by a vector) with scalar multiplication (a scalar number multiplied by a vector, I will explain that in the next week). The process, is the same as the others, example:
(2,3)·(1,2)=2·1,3·2
Result=2,6
As you can see, there is no complication at the moment with this operations!
How do we represent them grafically?
At the moment, we will just represent vectors in 2D, in the 3rd week I will explain how t represent n 3D. It is really simple, you just need how to indicate points in a cartesian plane. For example:
v=(3,5)
For representing these vectors you follow these steps:
You put a point in the place of first vector (3 steps to the right and 5 up, the place where they meet, you draw a point
The you draw a line, from the (0,0) to your point
Finally, the point that you just drawed for indicating the vector, at the end, you draw the top part of an arrow.
It would be so:
How to apply this concepts to Python?
As I sais, my main goal is Quantum Computing, so here, I will also explain how do we apply mathematical concets to Python. I hope you have a really basicPython knowledge, if you don’t, write it down in the commentaries, and I will try to help you.
We will use a library(module) called numpy, for importing it, you just need to write this:
import numpy as np
#Here we have imported Numpy
When we have done this, we can start!
I will only explain 2 things of Python this week:
How to define a vector
How to do the vector additon,substraction and multiplication
1: For defining a vector, you write this:
import numpy as np
#Now we define a vector with the function array()
v1=np.array([3,1])
Is really important to don’t forget the [], and the np before the function
2: For operating we just define variables, and write the operators:
import numpy as np
v1=np.array([1,2])
v2=np.array([2,4])
print(v1+v2)
print(v1-v2)
print(v1*v2)
I know this is too much basic,but we will gradually make it harder!
Which is the relation between this and Quantum computing?
As I already told you, all the things that I learn are for one main goal, so they must be related.
The vectors are a crucial part of Quantum Computing, I will explain it later, but, the qbits (Quantum Bits) are represented in a Hilbert Space with vectors! And not just vectors, unit vectors,(with magnitude 1, we will se this the next week :)) Don ´t worry if you don’t understand this, is just for remidn you that all the things that we do, are for achiving knowledge in Quantum Computing!!!
Excercices:
If you want, I put here some excerecises for practicing the concepts that we have just learned:
If you have the vector
v1=(3,4)
Calculate:
1: Vector’s magnitude
2: The result of a vector addition between v1 and (1,2)
If you do this excercises, write the solutions in the comments!
I hope anybody that readed this understood all! If you have any question I will read you comments!
The next week we will start with the scalar multiplication, and more vectors!