Hi, After demands from users (see e.g. https://ask.sagemath.org/question/40792/div-grad-and-curl-once-again/ and https://ask.sagemath.org/question/10104/gradient-divergence-curl-and-vector-products/) and a first attempt (see ticket #3021 <https://trac.sagemath.org/ticket/3021>), a proposal to fully implement elementary vector calculus (dot and cross products, gradient, divergence, curl, Laplace operator) is ready for review at #24623 <https://trac.sagemath.org/ticket/24623>.
In this implementation, Euclidean spaces are considered as Riemannian manifolds diffeomorphic to R^n endowed with a flat metric. This allows for an easy use of various coordinate systems, along with the related transformations. However, the user interface does not assume any knowledge of Riemannian geometry. In particular, no direct manipulation of the metric tensor is required. A minimal example is sage: E.<x,y,z> = EuclideanSpace(3) sage: v = E.vector_field(-y, x, 0) sage: v.display() -y e_x + x e_y sage: v[:] [-y, x, 0] sage: w = v.curl() sage: w.display() 2 e_z sage: w[:] [0, 0, 2] It is possible to use curl(v) instead of v.curl(), via sage: from sage.manifolds.operators import * sage: w = curl(v) This can be compared with the curl() already implemented (through #3021 <https://trac.sagemath.org/ticket/3021>) for vectors of symbolic expressions: sage: x, y, z = var('x y z') sage: v = vector([-y, x, 0]) sage: v (-y, x, 0) sage: w = v.curl([x, y, z]) sage: w (0, 0, 2) Note that [x, y, z] must be provided as the argument of curl to define the orientation. A limitation of this implementation is that it is valid only with Cartesian coordinates. With the #24623 <https://trac.sagemath.org/ticket/24623> implementation, we can do, in continuation with the first piece of code shown above: sage: spherical.<r,th,ph> = E.spherical_coordinates() sage: spherical_frame = E.spherical_frame() # orthonormal frame (e_r, e_th, e_ph) sage: v.display(spherical_frame, spherical) r*sin(th) e_ph sage: v[spherical_frame, :, spherical] [0, 0, r*sin(th)] sage: w.display(spherical_frame, spherical) 2*cos(th) e_r - 2*sin(th) e_th sage: w[spherical_frame, :, spherical] [2*cos(th), -2*sin(th), 0] More detailed examples are provided in the following Jupyter notebooks (click on the names to see them via nbviewer.jupyter.org): - vector calculus in Cartesian coordinates <http://nbviewer.jupyter.org/github/egourgoulhon/SageMathTest/blob/master/Worksheets/vector_calc_cartesian.ipynb> - vector calculus in spherical coordinates <http://nbviewer.jupyter.org/github/egourgoulhon/SageMathTest/blob/master/Worksheets/vector_calc_spherical.ipynb> - vector calculus in cylindrical coordinates <http://nbviewer.jupyter.org/github/egourgoulhon/SageMathTest/blob/master/Worksheets/vector_calc_cylindrical.ipynb> - changing coordinates in the Euclidean 3-space <http://nbviewer.jupyter.org/github/egourgoulhon/SageMathTest/blob/master/Worksheets/vector_calc_change.ipynb> - advanced aspects: Euclidean spaces as Riemannian manifolds <http://nbviewer.jupyter.org/github/egourgoulhon/SageMathTest/blob/master/Worksheets/vector_calc_advanced.ipynb> - the Euclidean plane <http://nbviewer.jupyter.org/github/egourgoulhon/SageMathTest/blob/master/Worksheets/Euclidean_plane.ipynb> Needless to say, any feedback / review is welcome. Eric. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.