# Tensors - Part 4: Behavior Under Change of Coordinates

# Tensors - Part 4: Behavior Under Change of Coordinates

### The fourth installment of the Tensors series covers the flavors and mixer of tensors.

Join the DZone community and get the full member experience.

Join For Free**Hortonworks Sandbox for HDP and HDF is your chance to get started on learning, developing, testing and trying out new features. Each download comes preconfigured with interactive tutorials, sample data and developments from the Apache community.**

In the first post in this series, I mentioned several apparently unrelated things that are all called tensors, one of these being objects that behave a certain way under changes of coordinates. That’s what we’ll look at this time.

In the second post, we said that a tensor is a multilinear functional. A *k*-tensor takes *k* vectors and returns a number, and it is linear in each argument if you hold the rest constant. We mentioned that this relates to the “box of numbers” idea of a tensor. You can describe how a *k*-tensor acts by writing out *k* nested sums. The terms in these sums are called the **components** of the tensor.

Tensors are usually defined in a way that has more structure. They vary from point to point in a space, and they do so in a way that in some sense is independent of the coordinates used to label these points. At each point, you have a tensor in the sense of a multilinear functional, but the emphasis is usually on the changes of coordinates.

## Components, Indexes, and Coordinates

Tensors in the sense that we’re talking about here come in two flavors: covariant and contravariant. They also come in mixtures; more on that later.

We consider two coordinate systems, one denoted by *x*‘s and another by *x*‘s with bars on top. The components of a tensor in the *x*-bar coordinate system will also have bars on top. For a covariant tensor of order one, the components satisfy

First of all, coordinates are written with superscripts. So *x ^{r}* is the

*r*coordinate, not

*x*to the power

*r*. Also, this uses Einstein summation notation: there is an implicit sum over repeated indexes, in this case of

*r*.

The components of a contravariant tensor of order one satisfy similar but different equation:

The components of a covariant tensor are written with subscripts and the components of a contravariant tensor with superscripts. In the equation for covariant components, the partial derivatives are with respect to the new coordinates, the *x* bars. In the equation for contravariant components, the partial derivatives are with respect to the original coordinates, the *x*‘s. Mnemonic: when the indexes go down (covariant tensors) the new coordinates go down (in the partial derivatives). When the indexes go up, the new coordinates go up.

For covariant tensors of order two, the change of coordinate formula is:

Here there the summation convention says that there are two implicit sums, one over *r* and one over *s*.

The contravariant counterpart says:

In general, you could have tensors that are a mixture of covariant and contravariant. A tensor with covariant order *p* and contravariant order *q* has *p* subscripts and *q* superscripts. The partial derivatives have *x*-bars on bottom corresponding to the covariant components and *x*-bars on top corresponding to contravariant components.

## Relation to Multilinear Functionals

We initially said a tensor was a multilinear functional. A tensor of order *k* takes *k* vectors and returns a number. Now we’d like to refine that definition to take two kinds of vectors. A tensor with covariant order *p* and contravariant order *q* takes *p* contravariant vectors and *q* covariant vectors. In linear algebra terms, instead of simply taking *k* elements of a vector space *V*, we say our tensor takes *p* vectors from the dual space *V** and *q* vectors from *V*.

## Relation to Category Theory

You may be familiar with the terms *covariant* and *contravariant* from category theory, or its application to object oriented programming. The terms are related. As Michael Spivak explains, “It’s very easy to remember which kind of vector field is covariant, and which is contravariant — it’s just the opposite of what it logically ought to be [from category theory].”

**Hortonworks Community Connection (HCC) is an online collaboration destination for developers, DevOps, customers and partners to get answers to questions, collaborate on technical articles and share code examples from GitHub. Join the discussion.**

Published at DZone with permission of John Cook . See the original article here.

Opinions expressed by DZone contributors are their own.

## {{ parent.title || parent.header.title}}

## {{ parent.tldr }}

## {{ parent.linkDescription }}

{{ parent.urlSource.name }}