Vector Operations

## Description

Sage is capable of executing most vector operations, including dot products, cross products, and Euclidean norms.
For example. we can compute the dot product of $\mathbf u = (1, 3/2, -1)$ and $\mathbf v = (1, 8, -2)$,

(1)
\begin{align} \mathbf u \cdot \mathbf v = 1 \cdot 1 + \frac{3}{2} \cdot 8 + (-1) \cdot (-2) = 15. \end{align}

## Sage Cell

#### Code

u=vector(QQ,[1, 3/2, -1])
v=vector(ZZ,[1, 8, -2])
u.dot_product(v)


## Options

#### Option

We can calculate the cross product $\mathbf u \times \mathbf v$ of $\mathbf u = (1, 3/2, -1)$ and $\mathbf v = (1, 8, -2)$.

#### Code

u=vector(QQ,[1, 3/2, -1])
v=vector(ZZ,[1, 8, -2])
u.cross_product(v)


#### Option

We can calculate the Euclidean norm of $\mathbf v$ of $\mathbf v = (1, 8, -2)$.

#### Code

v=vector(ZZ,[1, 8, -2])
v.norm()


## Tags

Primary Tags: Linear Algebra: Vector geometry; Multivariable Calculus: Vector geometry.

Secondary Tags: Vector geometry: Dot product, length, and unit vectors; Cross product.

## Attribute

Permalink:

Author: T. W. Judson

Date: 28 Jul 2018 20:50

Submitted by: Tom Judson

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License