# Differentiate vector field w.r.t a variable not defining the chart

I define a 3+1-dimensional manifold M:

n = 3
M = Manifold(1+n, 'M', structure='Lorentzian')


and a chart X with spherical coordinates t, r, th and ph.

X.<t,r,th,ph> = M.chart('t r:(0,+oo) th:(0,pi) ph:(0,2*pi)')


I define the following symbolic function Ne, which depends on r and a new variable, eps:

eps = var('eps')
Ne = function('Ne')(r,eps)


Now, I define a vector field, u, as:

u = M.vector_field('u')
u[0] = 2*Ne;  u[1] = Ne;  u[2] = 0;  u[3] = 0


At this point, I want to differentiate each term of u with respect to eps. However, when I write:

diff(u[0],eps)


I get:

ValueError: tuple.index(x): x not in tuple

However, I would expect to obtain:

2*diff(Ne(r, eps), eps)

I guess this is because I am differentiating a vector field from the manifold with respect to a variable (eps) which is not on the chart. In fact, if I differentiate with respect to $r$, then everything goes right. Is there a way I can fix this?

edit retag close merge delete

Sort by » oldest newest most voted

When you write u[0] you are getting a chart function object. The global diff function calls the derivative method on the object, and this one is only defined for coordinates of the chart.

What you can do is call the expr method on the chart function to get the underlying symbolic expression:

sage: diff(u[0].expr(), eps)
2*diff(Ne(r, eps), eps)

more