defderiv={alpha->alpha[R[r[x,y,z]]],beta1->beta1[x,r[x,y,z],R[r[x,y,z]]],beta2->beta2[y,r[x,y,z],R[r[x,y,z]]],beta3->beta3[z,r[x,y,z],R[r[x,y,z]]],R->R[r[x,y,z]],r->r[x,y,z]};

undefderiv={alpha[R_]->alpha,beta1[x,r_,R_]->beta1,beta2[y,r_,R_]->beta2,beta3[z,r_,R_]->beta3,R[r_]->R,r[x,y,z]->r};
expderiv={R'[r_]->R*alpha/r,D[r[x,y,z],x]->x/r,D[r[x,y,z],y]->y/r,D[r[x,y,z],z]->z/r,alpha'[R_]->(2*M/R^2 - 4C^2/R^5)/(2*alpha),D[beta1[x,r_,R_],x]->beta1/x,D[beta1[x,r_,R_],r_]->-2*beta1/r,D[beta1[x,r_,R_],R_]->-beta1/R,D[beta2[y,r_,R_],y]->beta2/y,D[beta2[y,r_,R_],r_]->-2*beta2/r,D[beta2[y,r_,R_],R_]->-beta2/R,D[beta3[z,r_,R_],z]->beta3/z,D[beta3[z,r_,R_],r_]->-2*beta3/r,D[beta3[z,r_,R_],R_]->-beta3/R};
expbeta={beta1->C*x/(r^2*R),beta2->C*y/(r^2*R),beta3->C*z/(r^2*R)};

psi=Sqrt[R/r];

beta1=psi^4* x*C/R^3;

beta2=psi^4* y*C/R^3;

beta3=psi^4 *z*C/R^3;

alpha:=Sqrt[1-2*M/R[r]+C^2/R[r]^4]

gamma=1/Sqrt[1-beta^2];

gorig={{-alpha^2+psi^(-4)*(beta1^2+beta2^2+beta3^2), beta1, beta2, beta3},{beta1,psi^4,0,0},{beta2,0,psi^4,0},{beta3,0,0,psi^4}};

Lambda={{gamma,-gamma*beta,0,0},{-gamma*beta,gamma,0,0},{0,0,1,0},{0,0,0,1}};

g=FullSimplify[Lambda.gorig.Lambda];

g3d=g[[2;;4,2;;4]];

g3u=FullSimplify[Inverse[g3d]];

g3dy=FullSimplify[D[g3d/.defderiv,y]]/.undefderiv;

g3dz=FullSimplify[D[g3d/.defderiv,z]]/.undefderiv;

g3dx=FullSimplify[gamma*D[g3d/.defderiv,x]]/.undefderiv;

g3diff={g3dx,g3dy,g3dz};

bbeta=g[[1,2;;4]];

aalpha=FullSimplify[Sqrt[-1/Inverse[g][[1,1]]]];

G = Table[Sum[1/2*g3u[[k,l]]*(g3diff[[i]][[j,l]]+g3diff[[j]][[i,l]]-g3diff[[l]][[i,j]])*bbeta[[k]],{k,3},{l,3}],{i,3},{j,3}];

Dbeta = FullSimplify[Table[D[bbeta[[i]]/.defderiv,j],{i,3},{j,{x,y,z}}]]/.undefderiv;

Dbeta[[All,1]]=Dbeta[[All,1]]*gamma;

K=FullSimplify[Table[1/(2*aalpha)*(beta*g3dx[[i,j]]+Dbeta[[i,j]]-G[[i,j]]+Dbeta[[j,i]]-G[[j,i]]),{i,3},{j,3}]/.expderiv/.expbeta];

FullSimplify[K[[1,3]],Assumptions->{r>0,R>0,alpha>0,beta<1,beta>0}]

FullSimplify[%/.{z^2->r^2-x^2-y^2}]

FullSimplify[%/.{x^2+y^2+z^2->r^2}]

FullSimplify[%/.{y^2->r^2-x^2-z^2}]

CForm[%]

trK=Simplify[Sum[(K.g3u)[[i,i]],{i,1,3}]/.expbeta];

KijKij=Simplify[Sum[K[[i,j]]*g3u[[i,k]]*K[[k,l]]*g3u[[l,j]],{i,1,3},{j,1,3},{k,1,3},{l,1,3}]/.expbeta];

chrx =FullSimplify[Table[Sum[1/2*g3u[[1,l]]*(g3diff[[i]][[j,l]]+g3diff[[j]][[i,l]]-g3diff[[l]][[i,j]]),{l,3}],{i,3},{j,3}]/.expderiv];

chry=FullSimplify[Table[Sum[1/2*g3u[[2,l]]*(g3diff[[i]][[j,l]]+g3diff[[j]][[i,l]]-g3diff[[l]][[i,j]]),{l,3}],{i,3},{j,3}]/.expderiv];

chrz=FullSimplify[Table[Sum[1/2*g3u[[3,l]]*(g3diff[[i]][[j,l]]+g3diff[[j]][[i,l]]-g3diff[[l]][[i,j]]),{l,3}],{i,3},{j,3}]/.expderiv];

chr={chrx,chry,chrz};

chrdx=D[gamma*chr/.defderiv,x]/.undefderiv;

chrdy=D[chr/.defderiv,y]/.undefderiv;

chrdz=D[chr/.defderiv,z]/.undefderiv;

chrd={chrdx,chrdy,chrdz};

Ric=Simplify[Sum[g3u[[a,b]]*(chrd[[c]][[c]][[a,b]]-chrd[[b]][[c]][[a,c]]),{a,3},{b,3},{c,3}]+Sum[g3u[[a,b]]*(chr[[d]][[a,b]]*chr[[c]][[c,d]]-chr[[d]][[a,c]]*chr[[c]][[b,d]]),{a,3},{b,3},{c,3},{d,3}]/.expderiv/.expbeta];

Simplify[Ric/.{alpha^2->1 - 2M/R+C^2/R^4,y^2->r^2-z^2-x^2}]

FullSimplify[%]

CForm[%]