(*Covariant form of the (Subscript[g, ij]) in FLRW metric *)
g4cov[i_,j_,r_,θ_,ϕ_,t_]:= Module[{f=0},
If[i==0 &&j==0,  f =  1];

If[i==1 &&j==1,  f =  -(((a[t])^2)/(1-k (r^2)))];
If[i==2&&j==2,  f =  -((a[t])^2)(r^2)];
If[i==3&&j==3,  f =  -((a[t])^2)(r^2)(((Sin[θ]))^2)];
f];

(*Contravariant form of the (g^ij) in FLRW metric *)
g4cont[i_,j_,r_,θ_,ϕ_,t_]:= Module[{f=0},
If[i==0 &&j==0,  f =  1];

If[i==1 &&j==1,  f =  -((((((a[t])^2)/(1-k (r^2)))))^(-1))];
If[i==2&&j==2,  f =  -(((((a[t])^2)(r^2)))^(-1))];
If[i==3&&j==3,  f =  -(((((a[t])^2)(r^2)(((Sin[θ]))^2)))^(-1))];
f];

(* dvar[μ_]:= Module[{f=0},
If[μ==0,f=t];
If[μ==1,f=r];
If[μ==2,f=θ];
If[μ==3,f=ϕ];
f]; *)

(*dvar[3]
D[g4cov[1,1,r,θ,ϕ,t],dvar[0]] *)

(* (Subscript[g, ij,l]) *)
dg4cov[i_,j_,l_,r_,θ_,ϕ_,t_]:=Module[{f=0},
If[l==0, f = (1/c)D[g4cov[i,j,r,θ,ϕ,t],t]];
If[l==1, f = D[g4cov[i,j,r,θ,ϕ,t],r]];
If[l==2, f = D[g4cov[i,j,r,θ,ϕ,t],θ]];
If[l==3, f = D[g4cov[i,j,r,θ,ϕ,t],ϕ]];
f];

dg4cov[1,1,0,r,θ,ϕ,t]

(* (Subscript[Γ, μν]^λ) *)
Γ4[μ_,ν_,λ_,r_,θ_,ϕ_,t_]:= Module[{f=0,k=0},
f= (∑_(k=0)^3)g4cont[λ,k,r,θ,ϕ,t]
(dg4cov[k,ν,μ,r,θ,ϕ,t]+ dg4cov[k,μ,ν,r,θ,ϕ,t]- dg4cov[μ,ν,k,r,θ,ϕ,t]); 
(*(D[g4cov[k,ν,r,θ,ϕ,t],dvar[μ]] + D[g4cov[k,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