# Wrong example of Covariant Vector

I have a question about covariant and contravariant vectors. I tried making concrete examples and in one example I succeed, in another I fail.

It is said that displacement vectors transform contravariantly, and gradients of a scalar transform covariantly.

I can get the whole story working in 1D:
Contravariant: Let's suppose I have a displacement of 1km, and I want it expressed in meters. So we have to make our "basis vector" (i.e. unit) 1000 times smaller. Since we're contravariant, I multiply by 1000 => 1km = 1000m.
Covariant: Let's suppose now I have a temperature field that changes 1K per kilometer. The gradient is 1K/km. Let's transform that in meters, i.e. make basis 1000 times smaller. Since we're covariant, I have to divide by 1000 => 1K/km = 0.001K/m.
So once I multiply by 1000, once I divide by 1000. That seems to make sense so far. I hope the example is valid.

But here's the example that seems to be wrong:
Let's take a 2D scalar function and take its gradient at a point. As is well known, the gradient of a scalar function will point in the direction of steepest slope. Let's suppose in an example that it points upwards (y direction points upwards) in a coordinate system. Now let's take a coordinate system that is rotated clockwise (y' now points to the right).
Of course, the direction of steepest slope is a physical entity and doesn't change, but from the point of view of the rotated coordinate system, it has been rotated anticlockwise (i.e. if I look in the direction of y', the steepest slope appears to the left). So, I rotated the system clockwards and the vector rotated the other way around; that is contravariant, not covariant. Where's the mistake?

I suppose the direction of steepest slope is somehow like a displacement so it behaves contravariantly. But why is it said that the gradient transform covariantly? How do I have to alter the example to be correct?

Thanks for helping me understand.

Hi, dyb,

I'm currently having my own difficulties with tensor calculus, so take my answer with a grain of salt:

Covariant and Contravariant tensors both transform the same way under pure euclidian rotation.
The reason why this is so is because the inverse of the rotation matrix is equal to the transpose of the rotation matrix: dx^i/dy^j = dy^j/dx^i

Where the differences come in is when you have skewing or scaling of your coordinate system. In your example, both a contravariant (length-like) tensor and a covariant (rate or gradient-like) tensor would rotate 90 degrees to the left.

If, however, you scaled your axes, then the (covariant, contravariant) tensors would (expand, contract) or vice versa depending on how you are scaling.

I hope this helps.

Does that mean that contravariant vs. covariant is not inverse behavior but something like inverse + transposed in linear algebra? Because if rotation doesn't matter it can't be inverse.

I think that's right. The general tensor transformation rules for a contravariant index for a tensor is as follows:

T^i (frame y) = T^j (frame x) * dy^i/dx^j

For covariant tensors, it is:

T_i (frame y) = T_j (frame x) * dx^j/dy^i

for rotation matrices, you are transforming one orthonormal set of basis vectors to another: These conditions yield the relationship

dy^i/dx^j = dx^j/dy^i, or [R] = ([R]^-1)^t

For contravariant tensors, you are dealing with something length-like (or area-like, volume-like, ect). To scale these, you multiply by how much each component x varies the given y axis. T^i = T^1 * dy^i/dx^1 + T^2 * dy^i/dx^2 + ...

For covariant tensors, you are dealing wiht something rate-like (or density-like). The density along the given y axis is the amount T changes over each of the x axes divided by the change in y along these axes: T_i = T_1 * dx^1/dy^i + T_2 * dx^2/dy^i ...

------
If you will imagine one of those altitude-contour maps of a mountain range:

Suppose you have two waypoints - the distance between these waypoints constitutes a contravariant vector. Suppose also you have the gradient of altitude per inch on the map, and plot the gradient field - these would be a covariant vector.

As you rotate the map, the waypoint vector rotates, and the terrain also rotates with it, so the gradient field would also be rotating with that, and you wouldn't percieve any differences in how they transform.

If you start squashing the map though, scaling it down - the gradient over the map dimensions increases (the map-mountain is becoming steeper as its base shrinks). The vector between the two waypoints is shrinking, though (that vector is becoming smaller, as the waypoints come closer together).

If you were to integrate between the two waypoints to get the difference in height - that would be an invariant. The height difference between the two waypoints is a scalar, no matter what you are doing to the x and y axes of the map.

So multiplying the contravariant vector of the distance between two close together waypoints with the covariant vector of the steepness of the hill yields your height difference - and this doesn't change between mappings:

Coordinates x:
dh = dv^i (x) * grad^i (x), where dv is some differential vector, and grad^i = dh/dx^i

Coordinates y:
dh = dv^i (x) * dy^j/dx^i * grad^i (x) * dx^i/dy^j = dv^j (y) * grad^j (y)

These are the same, because dy^j/dx^i * dx^i/dy^j = 1

Excellent answer! Thanks a lot. One of the most intuitive examples on the net. I'm actually getting a feeling for it now and have examples I can relate to.

I think that's right. The general tensor transformation rules for a contravariant index for a tensor is as follows:

T^i (frame y) = T^j (frame x) * dy^i/dx^j

For covariant tensors, it is:

T_i (frame y) = T_j (frame x) * dx^j/dy^i

for rotation matrices, you are transforming one orthonormal set of basis vectors to another: These conditions yield the relationship

dy^i/dx^j = dx^j/dy^i, or [R] = ([R]^-1)^t

For contravariant tensors, you are dealing with something length-like (or area-like, volume-like, ect). To scale these, you multiply by how much each component x varies the given y axis. T^i = T^1 * dy^i/dx^1 + T^2 * dy^i/dx^2 + ...

For covariant tensors, you are dealing wiht something rate-like (or density-like). The density along the given y axis is the amount T changes over each of the x axes divided by the change in y along these axes: T_i = T_1 * dx^1/dy^i + T_2 * dx^2/dy^i ...

------
If you will imagine one of those altitude-contour maps of a mountain range:

Suppose you have two waypoints - the distance between these waypoints constitutes a contravariant vector. Suppose also you have the gradient of altitude per inch on the map, and plot the gradient field - these would be a covariant vector.

As you rotate the map, the waypoint vector rotates, and the terrain also rotates with it, so the gradient field would also be rotating with that, and you wouldn't percieve any differences in how they transform.

If you start squashing the map though, scaling it down - the gradient over the map dimensions increases (the map-mountain is becoming steeper as its base shrinks). The vector between the two waypoints is shrinking, though (that vector is becoming smaller, as the waypoints come closer together).

If you were to integrate between the two waypoints to get the difference in height - that would be an invariant. The height difference between the two waypoints is a scalar, no matter what you are doing to the x and y axes of the map.

So multiplying the contravariant vector of the distance between two close together waypoints with the covariant vector of the steepness of the hill yields your height difference - and this doesn't change between mappings:

Coordinates x:
dh = dv^i (x) * grad^i (x), where dv is some differential vector, and grad^i = dh/dx^i

Coordinates y:
dh = dv^i (x) * dy^j/dx^i * grad^i (x) * dx^i/dy^j = dv^j (y) * grad^j (y)

These are the same, because dy^j/dx^i * dx^i/dy^j = 1