This is not what you are proposing but somehow related to it: provided you consider (x,y) as coordinates on a manifold, you may define g as a named function as follows:
sage: M = Manifold(2, 'M') sage: X.<x,y> = M.chart() # declares the chart X on M, with coordinates (x,y) sage: g = M.scalar_field(x+sin(y), name='g') sage: g.display() g: M --> R (x, y) |--> x + sin(y) Then you may use the function set_name to change the name of g: sage: g.set_name('G') sage: g.display() G: M --> R (x, y) |--> x + sin(y) You can also set the LaTeX display of g: sage: g.set_name('G', latex_name=r'\mathcal{G}') A difference with callable symbolic expressions is that you cannot call directly g on a pair of coordinates, i.e. write g(1,2), but have to go through the manifold point corresponding to these coordinates, i.e. M((1,2)) (in the present case, there is no need to specify the chart to which the coordinates belong, since only one chart has been declared; otherwise, one should declare the point as M((1,2), chart=X)). Hence sage: g(M((1,2))) sin(2) + 1 Another difference regards derivatives: the scalar function g has no diff() method, but it has a differential: sage: g.differential().display() dG = dx + cos(y) dy and you can get the two partial derivatives via sage: g.differential()[:] [1, cos(y)] Best wishes, Eric. PS: a big +1 to Paul's suggestion of turning the very nice answer of Nils into a proper documentation. Le dimanche 19 mars 2017 08:54:34 UTC+1, Aidan a écrit : > > > I wrote some code > <https://gist.github.com/aijony/8675b9b348a7c510d634f768d5ad7e8e> I would > like to contribute, but I don't know the most appropriate place to put it. > > > -- 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.