sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.37k stars 465 forks source link

Dot and cross products along a differentiable map #30318

Closed egourgoulhon closed 4 years ago

egourgoulhon commented 4 years ago

This ticket makes the methods dot_product(), cross_product() and norm() of class VectorField work for vector fields defined along a differentiable map, the codomain of which is a Riemannian manifold. Previously, these methods worked only for vector fields on a Riemannian manifold, i.e. along the identity map. An important subcase is of course that of a curve in a Riemannian manifold.

For instance, considering a helix parametrized by its arc length:

sage: E.<x,y,z> = EuclideanSpace()
sage: R.<s> = RealLine()
sage: C = E.curve((2*cos(s/3), 2*sin(s/3), sqrt(5)*s/3), (s, 0, 6*pi),
....:             name='C')

we have now

sage: T = C.tangent_vector_field()
sage: T.display()
C' = -2/3*sin(1/3*s) e_x + 2/3*cos(1/3*s) e_y + 1/3*sqrt(5) e_z
sage: norm(T)
Scalar field |C'| on the Real interval (0, 6*pi)
sage: norm(T).expr()
1

Introducing the unit normal vector N via the derivative of T:

sage: I = C.domain()
sage: Tp = I.vector_field([diff(T[i], s) for i in E.irange()], dest_map=C,
....:                     name="T'")
sage: N = Tp / norm(Tp)   

we get the binormal vector as the cross product of T and N:

sage: B = T.cross_product(N)
sage: B
Vector field along the Real interval (0, 6*pi) with values on the
 Euclidean space E^3
sage: B.display()
1/3*sqrt(5)*sin(1/3*s) e_x - 1/3*sqrt(5)*cos(1/3*s) e_y + 2/3 e_z

We can then form the Frenet-Serret frame:

sage: FS = I.vector_frame(('T', 'N', 'B'), (T, N, B),
....:                     symbol_dual=('t', 'n', 'b'))
sage: FS
Vector frame ((0, 6*pi), (T,N,B)) with values on the Euclidean space E^3

and check that it is orthonormal:

sage: [[u.dot(v).expr() for v in FS] for u in FS]
[[1, 0, 0], [0, 1, 0], [0, 0, 1]]

The Frenet-Serret formulas are obtained as:

sage: Np = I.vector_field([diff(N[i], s) for i in E.irange()],
....:                     dest_map=C, name="N'")
sage: Bp = I.vector_field([diff(B[i], s) for i in E.irange()],
....:                     dest_map=C, name="B'")
sage: for v in (Tp, Np, Bp):
....:     v.display(FS)
....:
T' = 2/9 N
N' = -2/9 T + 1/9*sqrt(5) B
B' = -1/9*sqrt(5) N

CC: @tscrim @mjungmath @mkoeppe

Component: manifolds

Keywords: dot product, cross product, curve

Author: Eric Gourgoulhon

Branch/Commit: b793247

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/30318

egourgoulhon commented 4 years ago

Commit: 2f3ac09

egourgoulhon commented 4 years ago

New commits:

2f3ac0930318: Dot and cross products along a differentiable map
egourgoulhon commented 4 years ago

Branch: public/manifolds/30318-dot_cross_product_along_diff_map

tscrim commented 4 years ago
comment:3

Thank you for this. The code looks good. One minor doctest tweak:

-sage: [[u.dot(v).expr() for v in FS] for u in FS]
+sage: matrix([[u.dot(v).expr() for v in FS] for u in FS])

as I think the output is a little easier to read and to reflect that it is the Gram matrix of dot product as a bilinear form.

Once changed (or you say my idea is stupid) and a green patchbot, then positive review.

tscrim commented 4 years ago

Reviewer: Travis Scrimshaw

egourgoulhon commented 4 years ago
comment:4

There are doctest errors in pseudo_riemannian_submanifold.py.

egourgoulhon commented 4 years ago
comment:5

Replying to @tscrim:

Thank you for this. The code looks good. One minor doctest tweak:

-sage: [[u.dot(v).expr() for v in FS] for u in FS]
+sage: matrix([[u.dot(v).expr() for v in FS] for u in FS])

as I think the output is a little easier to read and to reflect that it is the Gram matrix of dot product as a bilinear form.

Thanks for the suggestion; I'll perform the change.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 2f3ac09 to b793247

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

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

b793247#30318: Improve dot and cross product
egourgoulhon commented 4 years ago
comment:7

The latest version corrects the doctest errors, takes into account comment:5 and extends the capabilities to the dot/cross product between a vector field along a diff map and a vector field defined on the codomain of the diff map.

tscrim commented 4 years ago
comment:8

Thank you. LGTM.

egourgoulhon commented 4 years ago
comment:9

Thank you for the review!

vbraun commented 4 years ago

Changed branch from public/manifolds/30318-dot_cross_product_along_diff_map to b793247