(* Curvature Template *)

(* F[u_,v_]:=r*Cos[v]*Cos[u]; *)   (* Definition of Longitude/Latitude Coordinate Mapping *) 
(* G[u_,v_]:=r*Cos[v]*Sin[u]; *)   (* for Sphere *)
(* H[u_,v_]:=r*Sin[v]; *)

(* F[u_,v_]:=r*((2*u)/(u^2+v^2+1)); *)         (* Definition of Stereographic Coordinate *) 
(* G[u_,v_]:=r*((2*v)/(u^2+v^2+1)); *)         (* Mapping for Sphere *)
(* H[u_,v_]:=r*((u^2+v^2-1)/(u^2+v^2+1)); *)

(* F[u_,v_]:=a*Cos[v]*Cos[u]; *)    (* Definition of Coordinate Mapping for Ellipsoid *)
(* G[u_,v_]:=b*Cos[v]*Sin[u]; *) 
(* H[u_,v_]:=c*Sin[v]; *)       

(* F[u_,v_]:=(s+r*Cos[v])*Cos[u]; *)      (* Definition of Coordinate Mapping for Torus *)
(* G[u_,v_]:=(s+r*Cos[v])*Sin[u]; *)   
(* H[u_,v_]:=r*Sin[v]; *)  

(* f[u_]:=1/u; *)
(* g[u_]:=u; *)
F[u_,v_]:=f[u]*Cos[v];	    (* Definition of Coordinate Mapping for Cylindrical *)
G[u_,v_]:=f[u]*Sin[v];		(* Surface with Profile Functions f[u] and g[u] *) 
H[u_,v_]:=g[u];

(* F[u_,v_]:=Cosh[u]*Cos[v]; *)	    (* Definition of Coordinate Mapping for Particular *)
(* G[u_,v_]:=Cosh[u]*Sin[v]; *)		(* Cylindrical Surface with Profile Functions Cosh[u] *) 
(* H[u_,v_]:=Sinh[u]; *)            (* and Sinh[u] *)

(* F[u_,v_]:=; *)   (* General Coordinate Mapping *)
(* G[u_,v_]:=; *)
(* H[u_,v_]:=; *)

Fu[u_,v_]:=D[F[u,v],u];		(* Jacobian of Coordinate Mapping *)
Fv[u_,v_]:=D[F[u,v],v];
Gu[u_,v_]:=D[G[u,v],u];
Gv[u_,v_]:=D[G[u,v],v];
Hu[u_,v_]:=D[H[u,v],u];
Hv[u_,v_]:=D[H[u,v],v];

Fuu[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_,v_]:=Fuv[u,v]*LL[u,v]+Guv[u,v]*MM[u,v]+Huv[u,v]*NN[u,v];	(* Form *)
SFFvu[u_,v_]:=Fvu[u,v]*LL[u,v]+Gvu[u,v]*MM[u,v]+Hvu[u,v]*NN[u,v];
SFFvv[u_,v_]:=Fvv[u,v]*LL[u,v]+Gvv[u,v]*MM[u,v]+Hvv[u,v]*NN[u,v];

XX[u_,v_]:=FFFuu[u,v]*FFFvv[u,v]-FFFvu[u,v]*FFFuv[u,v];		(* Determinants *)
YY[u_,v_]:=SFFuu[u,v]*SFFvv[u,v]-SFFvu[u,v]*SFFuv[u,v];

KK[u_,v_]:=YY[u,v]/XX[u,v];		(* Ratio: the Curvature *)

TWW=KK[u,v]; FullSimplify[TWW]

(* f1[u_]:=D[f[u],u]; *)			(* Conditions on f, g:  f1*f1+g1*g1=1, f1*f2+g1*g2=0 *) 
(* f2[u_]:=D[f1[u],u]; *)
(* g1[u_]:=D[g[u],u]; *)
(* g2[u_]:=D[g1[u],u]; *)

(* Simplify[TWW,f1[u]*f1[u]+g1[u]*g1[u]==1 && f1[u]*f2[u]+g1[u]*g2[u]==0] *)
		(*  Simplify Subject to Conditions on f[u] and g[u]  *)