Sage: christoffel symbol calculation issue, help...
I got this trying to compute the example christoffel symbols sage:
sage: var('r t theta phi')
(r, t, theta, phi)
sage: (r, t, theta, phi)
(r, t, theta, phi)
sage: sage: m = matrix(SR, [[(1-1/r),0,0,0],[0,-(1-1/r)^(-1),0,0],[0,0,-r^2,0],[0,0,0,-r^2*(sin(theta))^2]])
sage: sage: print m
[ -1/r + 1 0 0 0]
[ 0 1/(1/r - 1) 0 0]
[ 0 0 -r^2 0]
[ 0 0 0 -r^2*sin(theta)^2]
sage: [ -1/r + 1 0 0 0]
Moreover, I get...
sage: var('r t theta phi')
(r, t, theta, phi)
sage: m = matrix(SR, [[(1-1/r),0,0,0],[0,-(1-1/r)^(-1),0,0],[0,0,-r^2,0],[0,0,0,-r^2*(sin(theta))^2]])
sage: def christoffel(i,j,k,vars,g):
....: s = 0
....: ginv = g^(-1)
....: for l in range(g.nrows()):
....: s = s + (1/2)*ginv[k,l]*(g[j,l].diff(vars[i])+g[i,l].diff(vars[j])-g[i,j].diff(vars[l]))
....: return s
....:
File "<ipython-input-3-70e0eaa76f50>", line 6
return s
^
IndentationError: unindent does not match any outer indentation level
What am I doing BAD?
In Python, which is the underlying base language of sage code block is determined by indentation. In your case the return statement should be at the same level (same column) as the for statement.