# Vector calculator

- Calculate the norm of a vector

- Calculate orthogonal vector of a given vector (2D plan)

- Normalize a vector

## Euclidean Norm of a vector

The Euclidean norm of a vector `\vecu` of coordinates (x, y) in the 2-dimensional Euclidean space, can be defined as its length (or magnitude) and is calculated as follows :

`norm(vecu) = sqrt(x^2+y^2)`

The norm (or length) of a vector `\vecu` of coordinates (x, y, z) in the 3-dimensional Euclidean space is defined by:

`norm(vecu) = sqrt(x^2+y^2+z^2)`

Example: Calculate the norm of vector `[[3],[2]]`

`norm(vecu) = sqrt(3^2+2^2) = sqrt(13)`

## Orthogonal Vector

**Definition**

Two vectors of the n-dimensional Euclidean space are orthogonal if and only if their dot product is zero.

The following propositions are equivalent :

- `\vecu _|_ \vecv`

- Vectors `\vecu` and `\vecv` are orthogonal

- Their dot product is zero: `\vecu . \vecv = 0`

**How to calculate the orthogonal vector ?**

Let `\vecu` be a vector of coordinates (a, b) in the Euclidean plane `\mathbb{R^2}`. Any `\vecv` vector of coordinates (x, y) satisfying this equation is orthogonal to `\vecu`:

`\vecu . \vecv = 0`

`a.x + b.y = 0`

If `b != 0` then `y = -a*x/b`

Therefore, all vectors of coordinates `(x, -a*x/b)` are orthogonal to vector `(a,b)` whatever x. We note that all these vectors are collinear (have the same direction).

For x = 1, we have `\vecv = (1,-a/b)` is an orthogonal vector to `\vecu`.

## Vector Normalization

**Definition** : Let `\vecu` be a non-zero vector. The normalized vector of `\vecu` is a vector that has the same direction than `\vecu` and has a norm which is equal to 1.

We note `\vecv` the normalized vector of `\vecu`, then we have,

`\vecv = \vecu/norm(vecu)`

**Example** : Normalization of the vector of coordinates (3, -4) in the Euclidean plane

We compute its norm,

`\norm(vecu) = sqrt(3^2 + (-4)^2) = sqrt(25) = 5`

The normalized vector of `\vecu` is therefore `\vecv = \vecu/norm(vecu) = (3/5 , -4/5)`