# Add method tangent_vector to differentiable manifolds

Reported by: Owned by: Eric Gourgoulhon major sage-9.4 manifolds tangent vector Samuel Lelièvre Eric Gourgoulhon Michael Jung N/A b5d7a8f b5d7a8f800fb496de28a5e89cabac2250b124c6f

Currently, constructing a tangent vector v at some point p of a manifold M requires two steps: first construct the tangent space at p, TpM, and then construct v as an element of TpM. For instance:

```sage: E.<x,y> = EuclideanSpace()
sage: p = E((1, 2), name='p')
sage: Tp = E.tangent_space(p)   # step 1
sage: v = Tp((-1, 3)); v        # step 2
Vector at Point p on the Euclidean plane E^2
```

This ticket endows the class `DifferentiableManifold` with a method `tangent_vector`, with `vector` as an alias, to make it a 1-step process. We can now write:

```sage: E.<x,y> = EuclideanSpace()
sage: p = E((1, 2), name='p')
sage: v = E.vector(p, -1, 3); v
Vector at Point p on the Euclidean plane E^2
```

This feature is motivated by this ask.sagemath question.

### comment:1 Changed 20 months ago by Eric Gourgoulhon

Branch: → public/manifolds/tangent_vector-31609 Samuel Lelièvre added → 5b225961f67c6a01b238e657549cf6a9e7e11d05 new → needs_review

New commits:

 ​5b22596 `Add method vector() to DifferentiableManifold`

### comment:2 Changed 20 months ago by Michael Jung

Sweet! I have just one comment. Since Python 3.6, we have f-strings which are way more convenient and easier to read than `format` (and also faster). I'd propose to use f-strings more often in the future. For this ticket:

```- raise ValueError("{} components must be provided".format(dim))
+ raise ValueError(f"{dim} components must be provided")
```
Last edited 20 months ago by Michael Jung (previous) (diff)

### comment:3 follow-up:  5 Changed 20 months ago by Michael Jung

Here is an explanation also elaborating on more advantages of f-strings over `format`: https://realpython.com/python-f-strings/.

Last edited 20 months ago by Michael Jung (previous) (diff)

### comment:4 Changed 20 months ago by git

Commit: 5b225961f67c6a01b238e657549cf6a9e7e11d05 → c4a76e92ff90733bf484265c1d0421152db252c8

Branch pushed to git repo; I updated commit sha1. New commits:

 ​c4a76e9 `Use f-string in DifferentialManifold.vector`

### comment:5 in reply to:  3 Changed 20 months ago by Eric Gourgoulhon

Here is an explanation also elaborating on more advantages of f-strings over `format`: https://realpython.com/python-f-strings/.

Thanks for the tip! The change to f-string is performed in the last commit.

### comment:6 follow-up:  7 Changed 20 months ago by Michael Jung

Is there a reason why you chose `vector` over `tangent_vector` for the method's name? The latter would sound more intuitive to me.

### comment:7 in reply to:  6 Changed 20 months ago by Eric Gourgoulhon

Is there a reason why you chose `vector` over `tangent_vector` for the method's name? The latter would sound more intuitive to me.

`vector` is more adapted to elementary use, like in vector calculus in the Euclidean space, when the user might not know what "tangent space" means. Of course, we can make an alias for `tangent_vector` if you feel it necessary.

### comment:8 follow-up:  11 Changed 20 months ago by Michael Jung

Mh, I don't know. Manifolds usually don't constitute of vectors. So a `vector` method wouldn't make much sense there as it sounds to me more like a method that should be reserved for vector spaces only. I'd advocate to rename `vector` to `tangent_vector` because mathematically precise.

This is a neat feature though, and I don't want to block it just because of my pedantry. An alias sounds like a good compromise.

Last edited 20 months ago by Michael Jung (previous) (diff)

### comment:9 follow-up:  12 Changed 20 months ago by Michael Jung

Alternatively the Euclidean space, as a special case, can be endowed with an alias `vector` whereas general (differentiable) manifolds only supposed to have `tangent_vector`. I think that is the best solution to maintain preciseness and having that alias in the elementary case at the same time.

Last edited 20 months ago by Michael Jung (previous) (diff)

### comment:10 Changed 20 months ago by git

Commit: c4a76e92ff90733bf484265c1d0421152db252c8 → b5d7a8f800fb496de28a5e89cabac2250b124c6f

Branch pushed to git repo; I updated commit sha1. New commits:

 ​b5d7a8f `Rename vector to tangent_vector and make vector an alias to it`

### comment:11 in reply to:  8 ; follow-up:  15 Changed 20 months ago by Eric Gourgoulhon

Description: modified (diff) Add method vector to differentiable manifolds → Add method tangent_vector to differentiable manifolds

Mh, I don't know. Manifolds usually don't constitute of vectors. So a `vector` method wouldn't make much sense there as it sounds to me more like a method that should be reserved for vector spaces only. I'd advocate to rename `vector` to `tangent_vector` because mathematically precise.

OK, this is done in the last commit. Note however that saying simply "vector at point p of manifold M" is quite unambiguous and is in line with the terminology "vector field": we do not say "tangent vector field", do we?

This is a neat feature though, and I don't want to block it just because of my pedantry. An alias sounds like a good compromise.

Done. `vector` is now an alias for `tangent_vector`.

### comment:12 in reply to:  9 Changed 20 months ago by Eric Gourgoulhon

Alternatively the Euclidean space, as a special case, can be endowed with an alias `vector` whereas general (differentiable) manifolds only supposed to have `tangent_vector`. I think that is the best solution to maintain preciseness and having that alias in the elementary case at the same time.

I oppose to this: we shall not introduce on Euclidean spaces method names that break for more general manifolds, while the functionality is exactly the same.

### comment:13 follow-up:  14 Changed 20 months ago by Samuel Lelièvre

```v = E.vector(p, (-1, 3))
```

```v = E.vector(p, -1, 3)
```

I don't mind either way but there's a choice to make.

### comment:14 in reply to:  13 Changed 20 months ago by Eric Gourgoulhon

```v = E.vector(p, (-1, 3))
```

```v = E.vector(p, -1, 3)
```

I don't mind either way but there's a choice to make.

There is no choice to make ;-) Both work in the current implementation (cf. the examples in the doctests).

Last edited 20 months ago by Eric Gourgoulhon (previous) (diff)

### comment:15 in reply to:  11 Changed 20 months ago by Michael Jung

OK, this is done in the last commit. Note however that saying simply "vector at point p of manifold M" is quite unambiguous and is in line with the terminology "vector field": we do not say "tangent vector field", do we?

No, we don't say "tangent vector field". But I haven't heard or read the use of "vector" over "tangent vector" either. Historical burden I suppose.

It should be unambiguous though and having both is fine with me. Someone who seeks for (tangent) vectors will find them now.

### comment:16 Changed 20 months ago by Michael Jung

Status: needs_review → positive_review

LGTM

### comment:17 Changed 20 months ago by Michael Jung

Reviewers: → Michael Jung

### comment:18 Changed 20 months ago by Eric Gourgoulhon

Thanks for the review and suggestions!

### comment:19 Changed 20 months ago by Matthias Köppe

Milestone: sage-9.3 → sage-9.4

Sage development has entered the release candidate phase for 9.3. Setting a new milestone for this ticket based on a cursory review.

### comment:20 Changed 18 months ago by Volker Braun

Branch: public/manifolds/tangent_vector-31609 → b5d7a8f800fb496de28a5e89cabac2250b124c6f → fixed positive_review → closed
Note: See TracTickets for help on using tickets.