Documentation

linalg::angle

Angle between two vectors

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

linalg::angle(u, v)

Description

linalg::angle(u,v) computes the angle φ between the two vectors u and v, defined by

,

where denotes the scalar product of two vectors given by linalg::scalarProduct, and the 2-norm of a vector, i.e., .

linalg::angle does not check if the computation is defined in the corresponding component ring. This can lead to an error message, as shown in Example 2.

The following relationship between the angle between and and the angle between and holds: .

An error message is returned if the vectors are not defined over the same component ring.

Examples

Example 1

We compute the angle between the two vectors and :

phi := linalg::angle( 
  matrix([2, 5]), matrix([-3, 3]) 
)

We use the function float to get a floating-point approximation of this number:

float(phi)

We give two further examples:

linalg::angle(
  matrix([1, -1]), matrix([1, 1])
)

linalg::angle(
  matrix([1, 1]), matrix([-1, -1])
)

Example 2

linalg::angle does not check whether the term is defined in the corresponding component ring.

As an example, we try to compute the angle between two vectors with components in 7:

MatZ7 := Dom::Matrix(Dom::IntegerMod(7))

The following call leads to an error because the 2-norm cannot be computed:

linalg::angle(MatZ7([1, 1]), MatZ7([-1, -1]))
Error: An integer exponent is expected. [(Dom::IntegerMod(7))::_power]

Note that the domain Dom::IntegerMod(7) does not implement the square root of an element, therefore in MuPAD® you cannot compute the angle of any two vectors over 7.

Parameters

u, v

Vectors of the same dimension; a vector is a n×1 or 1 ×n matrix of a domain of category Cat::Matrix

Return Values

Arithmetical expression.

See Also

MuPAD Functions

Was this topic helpful?