assume(t>0);

depends([t],[x]);

r : transpose([t, x]);

e_t : diff(r,t);

e_x : diff(r,x);

e : addcol(e_t, e_x);

eta : diag_matrix(-1,1);

gLL : transpose(e) . eta . e;

/* still not sure about this one ...
gLL[1][2] : 0;
gLL[2][1] : 0;*/"";

gLL;

gUU : invert(gLL);

nU_var : matrix([nUt], [nUx]);

n_dot_e_x : transpose(nU_var) . gLL . e_x = 0;

nUt_from_nUx : solve(n_dot_e_x, nUt)[1];

n_norm : transpose(nU_var) . gLL . nU_var = -1;

n_norm_nUx : subst(nUt_from_nUx, n_norm);

nUx_soln : solve(n_norm_nUx, nUx)[2] /* using positive answer */;

nUt_soln : subst(nUx_soln, nUt_from_nUx) /* negative this for negative solution */;

nU : matrix([rhs(nUt_soln)], [rhs(nUx_soln)]);

transpose(nU) . gLL . e_x$ ratsimp(%) /* verify orthogonal with e_x */;

transpose(nU) . gLL . nU$ ratsimp(%) /* verify normalized */;

g_tt : gLL[1][1];
g_tx : gLL[1][2];
g_xt : gLL[2][1];
g_xx : gLL[2][2];

conn_ttt : 1/2 * (diff(g_tt,t) + diff(g_tt,t) - diff(g_tt,t));
conn_ttx : 1/2 * (diff(g_tt,x) + diff(g_tx,t) - diff(g_tx,t));
conn_txt : 1/2 * (diff(g_tx,t) + diff(g_tt,x) - diff(g_xt,t));
conn_xtt : 1/2 * (diff(g_xt,t) + diff(g_xt,t) - diff(g_tt,x));
conn_txx : 1/2 * (diff(g_tx,x) + diff(g_tx,x) - diff(g_xx,t));
conn_xtx : 1/2 * (diff(g_xt,x) + diff(g_xx,t) - diff(g_tx,x));
conn_xxt : 1/2 * (diff(g_xx,t) + diff(g_xt,x) - diff(g_xt,x));
conn_xxx : 1/2 * (diff(g_xx,x) + diff(g_xx,x) - diff(g_xx,x));

connUx_xx : conn_xxx / g_xx /* only true for symmetric G ... */;

transpose(gLL . nU)$ ratsimp(%)$ nL : %;

addrow(diff(nL,t),diff(nL,x))$ ratsimp(%)$ partialL_nL : %;

partialL_nL - matrix([0,0],[0,connUx_xx]*nL[1][2])$ ratsimp(%)$ diffL_nL : %;

ident(2) + nU . nL$ ratsimp(%)$ projUL : %;

transpose(projUL) . diffL_nL . projUL$ ratsimp(%)$ proj_diffL_nL : %;

-(proj_diffL_nL + transpose(proj_diffL_nL))/2$ ratsimp(%)$ KLL : %;

gUU[1][1] * KLL[1][1] + gUU[1][2] * KLL[1][2] + gUU[2][1] * KLL[2][1] + gUU[2][2] * KLL[2][2]$ ratsimp(%)$ K:%;