Christoffel symbols of unit sphere – second kind

Tangent vector \(e_i\) is a degree 1 partial derivative on the surface point. We have done it before, we let \(x^i\) be the surface parameters, \(\bar r\) be the surface point. Define

\[e_i=\frac{\partial \bar r}{\partial x^i}.\] We also have done the degree 2 partial derivative, \[\frac{\partial e_i}{\partial x^j}=\frac{\partial \bar r}{\partial x^i\partial x^j}.\] We still can define Christoffel symbols of the second kind as a dot product for degree 2 and degree 1 partial derivative vectors, \[\Gamma_{\text{ }\text{ }ij}^k=\frac{\partial e_i}{\partial x^j} . e^k\]

Above are all notations, but we still need to compute the \(e^k\) vector, the superscript \(k\) indicates it is a contravariant tangent vector, it is call the dual basis. We can define the usual metric tensor \[g_{ij}=e_ie_j\] The metric tensor inverse is \[g^{ij}=g^{-1}_{ij}\] And the dual basis is \[e^i=e_jg^{ji}\] We also can have \[\Gamma_{\text{ }\text{ }ij}^k=\frac{\partial e_i}{\partial x^j} . g^{km}e_m\]

Consider unit sphere surface, radius \(R=1\), surface point https://mathworld.wolfram.com/SphericalCoordinates.html \[\bar r=\{x=\cos\theta \sin\phi,y=\sin\theta \sin\phi,z=\cos\phi\}.\]

library(Deriv)
## Warning: package 'Deriv' was built under R version 4.0.5
dot_prod<-function(a,b){
 Simplify(paste(paste(a,b,sep="*"),collapse="+") )
}

x="cos(theta)*sin(phi)"
y="sin(theta)*sin(phi)"
z="cos(phi)"

r=c(x,y,z)

r.theta=sapply(r,function(m) Deriv(m,"theta"))
r.phi=sapply(r,function(m) Deriv(m,"phi"))

r.thetatheta=sapply(r.theta,function(m) Deriv(m,"theta"))
r.phitheta=sapply(r.phi,function(m) Deriv(m,"theta"))
r.thetaphi=sapply(r.theta,function(m) Deriv(m,"phi"))
r.phiphi=sapply(r.phi,function(m) Deriv(m,"phi"))
g11=dot_prod(r.theta,r.theta)
g12=dot_prod(r.theta,r.phi)
g21=dot_prod(r.phi,r.theta)
g22=dot_prod(r.phi,r.phi)
g=c(g11,g12,g21,g22)

g=gsub("cos(phi)^2 + sin(phi)^2", "1", g,fixed=TRUE)
g=gsub("cos(theta)^2 + sin(theta)^2", "1", g,fixed=TRUE)
g=gsub(" * (1)", "", g,fixed=TRUE)
g=gsub("(1) * ", "", g,fixed=TRUE)
g=gsub("cos(phi)^2 + sin(phi)^2", "1", g,fixed=TRUE)
g=gsub("*(1)", "", g,fixed=TRUE)
matrix(g,nrow = 2)
##      [,1]         [,2]
## [1,] "sin(phi)^2" "0" 
## [2,] "0"          "1"
inv_g=matrix(c("1/sin(phi)^2","0","0","1") ,nrow = 2)#g inverse
inv_g
##      [,1]           [,2]
## [1,] "1/sin(phi)^2" "0" 
## [2,] "0"            "1"

\(e^i=e_jg^{ji}\)

#dot product matrices strings, only accept conformed matrices.

dot_mat<- function(x,y){
 m=nrow(x)
 n=ncol(y)

 res=matrix(rep("0",m*n),nrow=m)
 for(i in 1:m){
  for(j in 1:n){
   res[i,j]=dot_prod(x[i,],y[,j])
  }
 }
 return(res)
}
basis=as.matrix(cbind(r.theta,r.phi))
dual_basis=dot_mat(basis,inv_g)
dual_basis
##      [,1]                     [,2]                   
## [1,] "-(sin(theta)/sin(phi))" "cos(phi) * cos(theta)"
## [2,] "cos(theta)/sin(phi)"    "cos(phi) * sin(theta)"
## [3,] "0"                      "-sin(phi)"
Chris11.1=dot_prod(r.thetatheta,dual_basis[,1])
Chris11.2=dot_prod(r.thetatheta,dual_basis[,2])
Chris12.1=dot_prod(r.thetaphi,dual_basis[,1])
Chris12.2=dot_prod(r.thetaphi,dual_basis[,2])
Chris22.1=dot_prod(r.phiphi,dual_basis[,1])
Chris22.2=dot_prod(r.phiphi,dual_basis[,2])
raw1=c(Chris11.1,Chris12.1,Chris12.1,Chris22.1)
raw2=c(Chris11.2,Chris12.2,Chris12.2,Chris22.2)

raw1=gsub("cos(phi)^2 + sin(phi)^2", "1", raw1,fixed=TRUE)
raw2=gsub("cos(phi)^2 + sin(phi)^2", "1", raw2,fixed=TRUE)
raw1=gsub("cos(theta)^2 + sin(theta)^2", "1", raw1,fixed=TRUE)
raw2=gsub("cos(theta)^2 + sin(theta)^2", "1", raw2,fixed=TRUE)

raw1=gsub("(1)", "1", raw1,fixed=TRUE)
raw2=gsub("(1)", "1", raw2,fixed=TRUE)

raw1=gsub("(1 - 1)", "0", raw1,fixed=TRUE)
raw2=gsub("(1 - 1)", "0", raw2,fixed=TRUE)

Christoffel symbols of 2nd kind for unit sphere, is a \(2\times2\times2\) tensor. Simplify by using \(\cot(x)=\cos(x)/\sin(x)\).

Gamma1ij=matrix(raw1,nrow=2)
Gamma2ij=matrix(raw2,nrow=2)

Gamma1ij
##      [,1]                    [,2]                   
## [1,] "0"                     "cos(phi) * 1/sin(phi)"
## [2,] "cos(phi) * 1/sin(phi)" "0"
Gamma2ij
##      [,1]                         [,2]                     
## [1,] "-(cos(phi) * 1 * sin(phi))" "0"                      
## [2,] "0"                          "0 * cos(phi) * sin(phi)"

There is another computation to output Christoffel symbols of second kind. We use the metric tensors of unit sphere for following formula. \[g_{ij}=\left| {\begin{array} *{\sin^2(\phi)}&{0}\\ {0}&{1} \end{array}} \right|, g^{ij}=\left| {\begin{array} *{1/\sin^2(\phi)}&{0}\\ {0}&{1} \end{array}} \right|\] Indices \(i,j,k\) tell us which row/column to retrieve, sum up some vectors, and then finish with a vector dot product. \[\Gamma^{k}_{\text{ }\text{ }ij} = \frac{1}{2}g^{k\alpha} \left(\frac{\partial g_{i\alpha}}{\partial x^{j}}+ \frac{\partial g_{\alpha j}}{\partial x^{i}} - \frac{\partial g_{ij}}{\partial x^{\alpha}}\right)\]

g=matrix(c("sin(phi)^2","0","0","1"),nrow=2)
inv_g=matrix(c("1/sin(phi)^2","0","0","1"),nrow=2)

Gamma2nd<-function(k,i,j){
 para=c("theta","phi")
 g1=inv_g[k,]
 g2=sapply(g[i,],function(m) Deriv(m,para[j]))
 g3=sapply(g[,j],function(m) Deriv(m,para[i]))
 g4=sapply(para,function(m) Deriv(g[i,j],m))
 g5=sapply(paste(paste(g2,g3,sep="+"),g4,sep="-"),Simplify)

 res=Simplify(paste0(dot_prod(g1,g5),"/2"))
 return(res)
}


Gamma2nd(1,1,1)
## [1] "0"
Gamma2nd(1,1,2)
## [1] "cos(phi)/sin(phi)"
Gamma2nd(1,2,1)
## [1] "cos(phi)/sin(phi)"
Gamma2nd(1,2,2)
## [1] "0"
Gamma2nd(2,1,1)
## [1] "-(cos(phi) * sin(phi))"
Gamma2nd(2,1,2)
## [1] "0"
Gamma2nd(2,2,1)
## [1] "0"
Gamma2nd(2,2,2)
## [1] "0"