(*:Title: Bryant Surfaces and integral Representation - Formulas *)
(* Copyright 2002 Hubert Gollek *)
(*:Keywords:
	CMC-1 Surfaces in H^3, Nullcurves in Sl(2,C), natural parametrization,
	algebraic representation formulas*)
(*:Requirements: none. *)
(*:Warnings: Some commands are thought for former and future developing. So it's
	meaning might not become clear to other users. Other commands deserve improvements
	(for instance nullcurveToBallmodel[nullcurve][u, v] and 
	nullcurveToUpperhalfSpace[nullcurve][u, v] are to slow even for simple nullcurves.*)


(***********************************************************
	Summary: According to R. Bryant, constant mean curvature (CMC-1) surfaces in 
	hyperbolic space H^3 are related to null curves in Sl(2,C), i.e., to holomorphic
	curves FF:z\in C---> FF[z_]={{a11[z],a12[z]},{a21[z],a22[z]}}\in Sl(2,C), so called
	Bryantframes, i.e., FF[z] has determinant=1 and solves the linear system 
	(x) 	FF'[z]=FF[z].{{g[z],-g[z]^2},{1,-g[z]}}*om[z], 
	where g[z] is a holomorphic function and omega[z] a  holomorphic 1-form. Similar to
	minimal curves in complex space, null curves in Sl(2,C) are characterised by the fact,
	that their tangent vector has length = 0 with respect to the invariant complex Riemannian
	metric g(X,Y) induced on Sl(2,C) by 1/8 of the Killing form of sl(2,C).
	
	
	The package provides among others 
	
	(i) A modification of Bryant's formula obtained by the reduction procedure for
	systems of linear differential equations (due to D'Alembert) that leads to 
	an integral representation formula {a[z],b[z]} --> Sl2CFrameModified[a, b][z]
	for null curves.
	
	(ia) A double sequence of invariant algebraic representation formulas
	{f[z],h[z]} --> Sl2CFrameMeromorphic[n,k][f, h][z] (n-1>k>1, n=3,4,5,6,...)
	for null curves defined on Riemann surfaces derived from  formula together with
	the (integral) formula for the inverse. 

	(ib) The invariant algebraic representation formula for null curves that was
	found by A. J. Small ('Surfaces of constant mean
        curvature 1 in H^3 and algebraic curves on a quadric',
        Proc. AMS, vol 122, No. 4, (1994), 1211- 1220).)
        Later on it turned out that the surface analogue was already known to L. Bianchi
        and his students.(see Levi L. de Lima; Pedro Roitman;
	Constant mean curvature one surfaces in hyperbolic 3-space using the 
	Bianchi - Cal\`{o} method, Anais de Academia Brasileira de Ci\^{e}ncias
	(2002) 74(1), 19-24 or R. Bryant's homepage)
               
	(ii) plotting facilities together with transformations between the various models
	(Lorentzian-, Hermitian-, ball-, upperhalfspace model) of hyperbolic 3-space
	for the parametrized surfaces for the  CMC-1 surfaces 
	obtained from Bryant's formula. Moreover, programs to
	
	(iii) compute the invariants of null curves,
	
	(iv) the Levi civita connection and covariant derivative of the invariant
	complex Riemannian metric g(X,Y) on Sl(2,C),
	
	(v) invariants such as 1-st and 2-nd fundamentalform, Gaussian and mean curvature 
	of surfaces in H^3,
	
	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	Remark (for personal use, in german) concerning the reduction procedure of d'Alembert
	
	Die Differentialgleichung für die Sl(2,C)-Bryantframes ist das lineare System
	(1)			F'[z]=F[z]*X[z],
	wobei X die von zwei Funktionen g[z] und omega[z] abhängende Matrix
	nilpotentsl2MatrixBasic[g,omega][z] ist. Wir betrachten nur die erste Zeile {a[z],b[z]},
	nehmen a[z],b[z] als Eingangsgröße und bestimmen aus diesen g[z] und omega[z].


	Dann erfüllen a[z] und b[z] das Differentialgleichungssystem (1),
	wenn g[z] und omega[z] so gesetzt werden,
	wie oben errechnet und mit basicFunctionG[a,b][z] und
	basicFunctionOmega[a,b][z] explizit angegeben.
	Wie erhält man alle Lösungen??


	Das geht mit dem Reduktionsverfahren von D'Alembert
	(siehe R. Walter, Gewöhnliche Differentialgleichungen (SK520), Seite 113)
	Ein Fundamentalsystem erhält man durch Integration.
	++++++++++++++++++++++++++++++++++++++++++++++++++
	***********************************************************)


BeginPackage["CMCSurfaces`"]


Unprotect[ballmodelPlot,ballmodelPlotPolar,upperHalfspacePlot,upperHalfspacePlotPolar,
	Sl2CFrameMeromorphicToSl2CModified,Sl2CFrameMeromorphicToSl2CModified1,
	Sl2CFrameMeromorphicToSl2CModified2,BianchiCaloSmallDouble,
	Sl2CFrameMeromorphic,Sl2CFrameMeromorphicInvers,Sl2CFrameMeromorphicInvers1,
	Sl2CFrameMeromorphicInvers2,Sl2CFrameMeromorphicInverswithConstants,
	Sl2CFrameMeromorphicInverswithConstants1,Sl2CFrameMeromorphicInverswithConstants2,
	hyperbolicadjointMatrix,hyperbolicComplexargumentrule,
	hyperbolicComplexExpand,hyperbolicCross,hyperbolicCrosswithCheck,
	hyperbolicCrossX,hyperbolicSurfaceNormalInhyperbolicPolarCoords,
	hyperbolicSurfaceNormalVector,hyperbolicSurfaceNormalVectorwithCheck,
	hyperbolicOrthogonalProjection,hyperbolicTangentVectorofH3,
	hyperbolicTangentVectorofH3Invers,
	hyperbolicunitNormal,hyperbolicE,hyperbolicF,hyperbolicG,hyperbolicfirstFF,
	hyperbolicL,hyperbolicM,hyperbolicN,hyperbolicsecondFF,hyperbolicsecondFFdirect,
	hyperbolicGaussiancurvature,hyperbolicMeancurvature,hyperbolicLeviCivita,
	hyperbolicWeingartenmap,lorentzToHermitean2by2,hermitean2by2ToLorentz,
	llEukl,llLoren,lorentzGruppe,lorentzLength,lorentzmetric,lorentzMetrik,
	lorentzmodelToBallmodel,ballmodelToLorentzmodel,
	upperhalfSpaceToBallmodel,ballmodelToUpperhalfSpace,
	upperhalfSpaceToLorentzmodel,lorentzmodelToUpperhalfSpace,lorentzianTypeSurface,
	nullcurveToBallmodel,nullcurveToBallmodelPolar,nullcurveToHermiteanmodel,
	nullcurveToHermiteanmodelPolar,
	nullcurveToUpperhalfSpace,nullcurveToUpperhalfSpacePolar,
	drahtrahmenderspaehreX,drahtrahmenderspaehreY,
	drahtrahmen,
	lorentzianTypeSurfaceModified,lorentzpart,normalofH3,

	Sl2KANparam,Sl2CToSO13,Sl2KANparamInvers1,Sl2KANparamInvers2,
	Sl2KANparamInvers3,Sl2KANparamInvers,invariantmetricKAN,gammaKAN,
	gammaKANcollection,covDerivativeKAN,highercovDerKANofCurve,
	covDerofVectorfieldKANalongCurve,
	basicFunctionG,basicFunctionOmega,basicFunctionGMeromorphic,basicFunctionOmegaMeromorphic,
	basicFunctionGModified,basicFunctionOmegaModified,
	Sl2Framerule,Sl2Framerule4,Sl2CAction,toBryantframeData,brCPP,brKappa,
	cmcKappaKAN,cmcCPPKAN,

	tangentVectorKAN1,tangentVectorKAN2,tangentVectorKAN3,Sl2MatrixEXPparam,
	Sl2MatrixEXPparamInvers,Sl2MatrixEXPparamInvers1,Sl2MatrixEXPparamInvers2,
	Sl2MatrixEXPparamInvers3,invariantmetricMatrixEXP,invariantmetricTensorMatrixEXP,
	gammaMatrixEXP,
	covDerivativeMatrixEXP,covDerofVectorfieldMatrixEXPalongCurve,highercovDerMatrixEXPofCurve,
	Sl2KANparamDifferentialInvers,Sl2KANparamDifferential,
	Sl2KANparamInversXX,Sl2KANparamInversXX1,Sl2KANparamInversXX2,Sl2KANparamDifferentialInversXX,
	Sl2KANparamDifferentialInversXX1,Sl2KANparamDifferentialInversXX2,
	matrixOfScalarproducts,schwarzDerCMC,
	bbcan,partielIntegrationbbcan,aFunForEqualG,aFunModifiedForEqualG,
	nullcurveToBryantdata,nullcurveToBryantdata1,nullcurveToBryantdata2,
	nullcurveToModifiedData1,nullcurveToModifiedData2,nullcurveToModifiedData,
	Sl2CFrameBR,Sl2CFrame,Sl2CFrameModified,Sl2CFrameBianchiCaloSmall,
	auxBianchiCaloSmall,BianchiCaloSmallFrame,
	covDerVectorKAN1,covDerVectorKAN2,
	covDerVectorKAN3,covDerVectorKAN4,covDerVectorKAN5,cppKAN2,
	varexplicitKANcan,varexplicitNullKANcan,canKANFunctionOmega,canKANFunctionG,
	commutatorKAN,commutatorKANoriginal,
	spur,commutator,adjointRepresentation,
	cmcKappaRulecan,cmcKappaRule,cmcCPPRule,
	tocmcKappacan,tocmcKappa,
	wurzelausdruck,determineOrder,determineOrderBasic]

Clear[ballmodelPlot,ballmodelPlotPolar,upperHalfspacePlot,upperHalfspacePlotPolar,
(* Befehle zur algebraischen Darstellungsformel von Nullkurven *)
Sl2CFrameMeromorphicToSl2CModified,Sl2CFrameMeromorphicToSl2CModified1,
Sl2CFrameMeromorphicToSl2CModified2,BianchiCaloSmallDouble,
Sl2CFrameMeromorphic,Sl2CFrameMeromorphicInvers,Sl2CFrameMeromorphicInvers1,
Sl2CFrameMeromorphicInvers2,Sl2CFrameMeromorphicInverswithConstants,
Sl2CFrameMeromorphicInverswithConstants1,Sl2CFrameMeromorphicInverswithConstants2,

(*tominkBR,fromminkBR,RuleforMinkUndNpvpBR,RuleforMinkUndNpvpInversBR,*)

(*technische Befehle für H^3*)
	hyperbolicadjointMatrix,hyperbolicComplexargumentrule,hyperbolicComplexExpand,
	hyperbolicCross,hyperbolicCrosswithCheck,hyperbolicCrossX,
	hyperbolicSurfaceNormalInhyperbolicPolarCoords,hyperbolicSurfaceNormalVector,
	hyperbolicSurfaceNormalVectorwithCheck,hyperbolicOrthogonalProjection,
	hyperbolicTangentVectorofH3,hyperbolicTangentVectorofH3Invers,hyperbolicunitNormal,
(*Befehle für Flächen in H^3*)
	hyperbolicE,hyperbolicF,hyperbolicG,hyperbolicfirstFF,hyperbolicL,hyperbolicM,hyperbolicN,
	hyperbolicsecondFF,hyperbolicsecondFFdirect,
	hyperbolicGaussiancurvature,hyperbolicMeancurvature,hyperbolicLeviCivita,
	hyperbolicWeingartenmap,

	lorentzToHermitean2by2,hermitean2by2ToLorentz,
	(*gehören zur Gruppe der Befehle, die zwischenSO(1,3) und Sl(2,C) vermittel*)

(*Befehle für Lorentzparametrisierung und im Kugel (Poincare)-Model, oberer Halbraum*)
	llEukl,llLoren,lorentzGruppe,lorentzLength,lorentzmetric,lorentzMetrik,
	lorentzmodelToBallmodel,ballmodelToLorentzmodel,
	upperhalfSpaceToBallmodel,ballmodelToUpperhalfSpace,
	upperhalfSpaceToLorentzmodel,lorentzmodelToUpperhalfSpace,lorentzianTypeSurface,
	nullcurveToBallmodel,nullcurveToBallmodelPolar,nullcurveToHermiteanmodel,
	nullcurveToHermiteanmodelPolar,
	nullcurveToUpperhalfSpace, nullcurveToUpperhalfSpacePolar,
	drahtrahmenderspaehreX,drahtrahmenderspaehreY,
	drahtrahmen,
	lorentzianTypeSurfaceModified,lorentzpart,normalofH3,

(*Befehle für KAN-Parametrisierung von Sl(2, und die lokalen Ausdrücke für die
invariante komplex-Riemannsche Metrik, kovariante Ableitung etc*)
	Sl2KANparam,Sl2CToSO13,Sl2KANparamInvers1,
	Sl2KANparamInvers2, Sl2KANparamInvers3, Sl2KANparamInvers,
	invariantmetricKAN,gammaKAN,gammaKANcollection,covDerivativeKAN,
	highercovDerKANofCurve,covDerofVectorfieldKANalongCurve,

(* weitere Befehle zu Sl2KANParametrisierung und Sl2MatrixEXPParametrisierung vom Aug. 2002*)
	basicFunctionG,basicFunctionOmega,basicFunctionGMeromorphic,basicFunctionOmegaMeromorphic,
	basicFunctionGModified,basicFunctionOmegaModified,
	Sl2Framerule, Sl2Framerule4,Sl2CAction,toBryantframeData,brCPP,brKappa,
	cmcKappaKAN,cmcCPPKAN,tangentVectorKAN1,tangentVectorKAN2,tangentVectorKAN3,
	Sl2MatrixEXPparam,Sl2MatrixEXPparamInvers,Sl2MatrixEXPparamInvers1,
	Sl2MatrixEXPparamInvers2,Sl2MatrixEXPparamInvers3,invariantmetricMatrixEXP,
	invariantmetricTensorMatrixEXP,gammaMatrixEXP,
	covDerivativeMatrixEXP,covDerofVectorfieldMatrixEXPalongCurve,highercovDerMatrixEXPofCurve,
	Sl2KANparamDifferentialInvers,Sl2KANparamDifferential,
	Sl2KANparamInversXX,Sl2KANparamInversXX1,Sl2KANparamInversXX2,
	Sl2KANparamDifferentialInversXX,Sl2KANparamDifferentialInversXX1,
	Sl2KANparamDifferentialInversXX2,
	matrixOfScalarproducts,schwarzDerCMC,
	bbcan,partielIntegrationbbcan,aFunForEqualG,aFunModifiedForEqualG,

	nullcurveToBryantdata,nullcurveToBryantdata1,nullcurveToBryantdata2,
	nullcurveToModifiedData1,nullcurveToModifiedData2,nullcurveToModifiedData,
	Sl2CFrameBR,Sl2CFrame,Sl2CFrameModified,Sl2CFrameBianchiCaloSmall,auxBianchiCaloSmall,BianchiCaloSmallFrame,
	covDerVectorKAN1,covDerVectorKAN2,
	covDerVectorKAN3,covDerVectorKAN4,covDerVectorKAN5,cppKAN2,

(*Befehle zur Variation von Nullkurven - sind jetzt wahrscheinlich überholt*)
	
	varexplicitKANcan,varexplicitNullKANcan,canKANFunctionOmega,canKANFunctionG,
	commutatorKAN,commutatorKANoriginal,
	
	spur,commutator,adjointRepresentation,
(*Befehle aus dem Paket tocmcKappa.m - stehen in Zusammenhang mit
	varexplicitKANcan,varexplicitNullKANcan,canKANFunctionOmega,canKANFunctionG*)

	cmcKappaRulecan,cmcKappaRule,cmcCPPRule,
	tocmcKappacan,tocmcKappa,
	wurzelausdruck,determineOrder,determineOrderBasic]


(**************** Begin of 'usages' **************)


BianchiCaloSmallDouble::usage="BianchiCaloSmallDouble[f, g][z] is the invariant algebraic
	representation formula {f[z],g[z]} ---> Sl2CFrameBianchiCaloSmall[f][z].
	Inverse[Sl2CFrameBianchiCaloSmall[g][z]]. The Bryant data of this curve are
	g[z] and the difference of the squares of the Schwarzian derivatives of f and g
	divided by 4 g'[z]. Type\nnullcurveToBryantdata[BianchiCaloSmallDouble[f,g]][z]-\n{g[z],
	(schwarzDerCMC[f][z]^2-schwarzDerCMC[g][z]^2)/(4*D[g[z],z])}//Simplify\n
	to convince yourself."

ballmodelPlot::usage="ballmodelPlot[nullcurve_][u0,u1,v0,v1,pu,pv,options] plots the 
	ball model version of the CMC-surface x[u,v] corresponding to the null curve
	nullcurve[z] in Sl(2,C) in conformal parametrization. The ranges of u and v
	are given by u0 < u1 resp v0 < v1, while pu, pv give the number of plot points.
	Options of Graphics3D can be used. The command avoids to determine an explicit
	parametrization of x[u,v] and uses the numerical values of nullcurve[ui+I*vj]
	at the corresponding grid points (ui,vj)."

ballmodelPlotPolar::usage="ballmodelPlotPolar[nullcurve_][u0,u1,v0,v1,pu,pv,options]
	plots the ball model version of the CMC-surface x[u,v] corresponding to the
	null curve nullcurve[z] in Sl(2,C) in polar coordinates. The ranges of u and v
	are given by u0 < u1 resp v0 < v1, while pu, pv give the number of plot points.
	Options of Graphics3D can be used. The command avoids to determine an explicit
	parametrization of x[u,v] and uses the numerical values of 
	nullcurve[ui*Exp[I*vj]] at the corresponding grid points (ui,vj)."

upperHalfspacePlot::usage="upperHalfspacePlot[nullcurve_][u0,u1,v0,v1,pu,pv,options]
	plots the upper half space version of the CMC-surface x[u,v] corresponding
	to the null curve nullcurve[z] in Sl(2,C) in conformal parametrization. The
	ranges of u and v are given by u0 < u1 resp v0 < v1, while pu, pv give the
	number of plot points. Options of Graphics3D can be used. The command avoids
	to determine an explicit parametrization of x[u,v] and uses the numerical
	values of nullcurve[ui+I*vj] at the corresponding grid points (ui,vj)."

upperHalfspacePlotPolar::usage="upperHalfspacePlotPolar[nc][u0,u1,v0,v1,pu,pv,options]
	plots the upper half space version of the CMC-surface x[u,v] corresponding to
	the null curve nc[z] in Sl(2,C) in polar coordinates. The ranges of u and v
	are given by u0 < u1 resp v0 < v1, while pu, pv give the numer of plot points.
	Options of Graphics3D can be used. The command avoids to determine an explicit
	parametrization of x[u,v] and uses the numerical values of nc[ui*Exp[I*vj]]
	at the corresponding grid points (ui,vj)."


Sl2CFrameMeromorphic::usage="Sl2CFrameMeromorphic[n,k][f,h][z] is a double sequence of 
algebraic representation formulas for null curves in Sl(2,C). The arguments n,k are integers
with n-1>k>0, while f[z] and h[z] are meromorphic functions. In the global setting,
f[z] is a meromorphic function and h[z] a meromorphic vector field on a Riemann surface.
The differential operator (f,h)-->Sl2CFrameMeromorphic[n,k][f,h][z] can be inverted.
Sl2CFrameMeromorphic[f,h][z] is Sl2CFrameMeromorphic[3,1][f,h][z] - the first, simplest,
and most important member of the whole sequence,"

Sl2CFrameMeromorphicInvers1::usage="matrix[z] --> Sl2CFrameMeromorphicInvers1[n,k][matrix][z]
is the first component f[z] of the inverse of the operator 
(f,h)-->Sl2CFrameMeromorphic[n,k][f,h][z]. The argument matrix[z] must be an Sl(2,C)-matrix 
of meromorphic functions. Sl2CFrameMeromorphicInvers1[matrix][z] is 
Sl2CFrameMeromorphicInvers1[3,1][matrix][z]. Integrations do not occur in this command."

Sl2CFrameMeromorphicInvers2::usage="matrix --> Sl2CFrameMeromorphicInvers2[n,k][matrix][z]
is the second component h[z] of the inverse of the operator 
(f,h)-->Sl2CFrameMeromorphic[n,k][f,h][z]. The argument matrix[z] must be an Sl(2,C)-matrix of 
meromorphic functions. Sl2CFrameMeromorphicInvers2[matrix][z] is 
Sl2CFrameMeromorphicInvers2[3,1][matrix][z]. Constants of integration are set to 0."

Sl2CFrameMeromorphicInverswithConstants1::usage="
Sl2CFrameMeromorphicInverswithConstants[n,k][matrix][z] does not exist."

Sl2CFrameMeromorphicInverswithConstants2::usage="
matrix --> Sl2CFrameMeromorphicInverswithConstants2[n,k][matrix][z] is almost the same as
matrix --> Sl2CFrameMeromorphicInvers2[n,k][matrix][z], but displaying the constants of
integration. Sl2CFrameMeromorphicInverswithConstants2[matrix][z] is the case n=3, k=1.";

Sl2CFrameMeromorphicInvers::usage="matrix --> Sl2CFrameMeromorphicInvers[n,k][matrix][z]
is the inverse of the operator 
(f,h)-->Sl2CFrameMeromorphic[n,k][f,h][z]. The argument matrix[z] must be an Sl(2,C)-matrix of 
meromorphic functions. Sl2CFrameMeromorphicInvers[f,h][z] is the case n=3, k=1.
Constants of integration are set to 0."

Sl2CFrameMeromorphicInverswithConstants::usage="
matrix --> Sl2CFrameMeromorphicInverswithConstants[n,k][matrix][z] is almost the same as
matrix --> Sl2CFrameMeromorphicInvers[n,k][matrix][z], but displaying the constants of
integration. Sl2CFrameMeromorphicInverswithConstants[matrix][z] is the case n=3, k=1.";

Sl2CFrameMeromorphicToSl2CModified1::usage="Sl2CFrameMeromorphicToSl2CModified1[m][z]
is the first component u[z] of Sl2CFrameMeromorphicToSl2CModified1[m][z]." ;

Sl2CFrameMeromorphicToSl2CModified2::usage="Sl2CFrameMeromorphicToSl2CModified2[n,k][m][z]
is the second component b[z] of Sl2CFrameMeromorphicToSl2CModified1[n,k][m][z]." ;

Sl2CFrameMeromorphicToSl2CModified::usage="m[z] --> Sl2CFrameMeromorphicToSl2CModified[m][z],
where m[z] is an Sl(2,C)-matrix, gives the pair {u[z],b[z]} of meromorphic functions such
that m[z]=dd.Sl2CFrameModified[u,b][z].dd, where dd={{1,0},{0,-1}}.
Actually, our aim was to get m[z]=Sl2CFrameModified[u,b][z]. Still, this must be achieved.
May be, something has to be changed in the term 
-{{1,bb},{-int,aa^2-bb*int}}/aa // Simplify of Sl2CFrameMeromorphic[n, k][f, h][z], Testexample:\n

n=5;k=3;mm[z_]=Sl2CFrameMeromorphic[n,k][f,h][z];\n
u[z_]=Sl2CFrameMeromorphicToSl2CModified1[n,k][mm][z]//Simplify\n
b[z_]=Sl2CFrameMeromorphicToSl2CModified2[n,k][mm][z]//Simplify\n
dd={{1,0},{0,-1}};
mm[z]-dd.Sl2CFrameModified[u,b][z].dd//Simplify";

basicFunctionG::usage="basicFunctionG[a,b][z] together with  basicFunctionOmega[a,b][z] is a
	transformation {a[z],b[z]}--->{g[z],omega[z]} such that a solution vector of
	the linear 2x2-system with matrix {{g[z],-g[z]^2},{1,-g[z]}}*omega[z]
	is just formed by the two given functions sol1={a[z],b[z]}. This can be
	checked by typing  qq=nilpotentsl2MatrixBasic[{basicFunctionG[a,b][#],
	basicFunctionOmega[a,b][#]}&][z]//Transpose;
	qq.{a[z],b[z]}//Simplify. A second solution vector sol2 of this system such
	that sol1 and sol2 are linearly independent is obtained by the reduction
	procedure of d'Alembert  (see for instance Walter, gewöhnliche
	Differentialgleichungen (SK520), page 113). The final fundamental system is
	then obtained with the function Sl2CFrame[a,b][z]."
	
basicFunctionOmega::usage="basicFunctionOmega[a,b][z] see: basicFunctionG[a,b][z]."

basicFunctionGModified::usage="basicFunctionGModified[u,b][z] together with 
	basicFunctionOmegaModified[u,b][z] is a transformation {u[z],b[z]}--->{g[z],omega[z]}
	such that a solution vector sol1={-1/u[z],b[z]} of the linear 2x2-system with matrix 
	{{g[z],-g[z]^2},{1,-g[z]}}*omega[z] is expressed directly by the two given functions 
	{u[z],b[z]}. This can be checked by typing\n
	qq = nilpotentsl2MatrixBasic[basicFunctionGModified[a, b],\n
	basicFunctionOmegaModified[a, b]][z]//Transpose//Simplify;\n
	vv = {-1/a[z], -b[z]/a[z]}; qq.vv - D[vv, z] // Together\n
	This simplifies the integral appearing in the solution formula FF[z]=Sl2CFrame[a, b][z]
	of the linear system FF'[z]=FF[z].basicFunctionG[a,b][z].";

basicFunctionOmegaModified::usage="see: basicFunctionGModified[a,b][z]."

basicFunctionGMeromorphic::usage="{f[z],h[z]} --> basicFunctionGMeromorphic[f,h][z] together with 
	{f[z],h[z]} --> basicFunctionOmegaMeromorphic[a,b][z] is the operation that gives the pair 
	{g[z],omega[z]} of functions such that the Maurer-Cartan derivative of Sl2CFrameMeromorphic[f,h][z]
	equals nilpotentsl2MatrixBasic[g,omega][z]. This is an explicit formula written as a quick
	tool for the case n=3, k=1 of Sl2CFrameMeromorphic[n,k][f,h][z]. For general n, k use for instance
	nullcurveToBryantdata[Sl2CFrameMeromorphic[n,k][f,h]][z] and concrete values of n and k. The
	complexity of the results is rapidly growing with n and k."

basicFunctionOmegaMeromorphic::usage="See under basicFunctionGMeromorphic[f,h][z]."

Sl2CFrame::usage="F=Sl2CFrame[a,b][z] is an Sl(2,C)-matrix that solves the
	linear system F'=F*X, where X is the null 
	matrix X=nilpotentsl2Matrix[a, b][z] of sl(2,C) (see the command
	nilpotentsl2Matrix[a,b][z]) and where a[z] and b[z] are two arbitrary
	meromorphic functions of one variable."

Bryantframe::usage="Bryantframe[a,b][z] is the same as Sl2CFrame[a,b][z]."

nullcurveToBryantdata::usage="nullcurveToBryantdata[nullMatrix][z] is the inverse
	operation to the Bryant representation formula {g[z],omega[z]} -->FF[z]=nullMatrix[z];
	where FF[z] is a solution of FF'[z]=FF[z].XX[z] with
	XX[z_]=nilpotentsl2MatrixBasic[g,omega][z]={{g[z],-g[z]^2},{1,-g[z]}}*om[z].
	It checks whether FF[z] is really null, i.e., whether Det[FF[z]^(-1).FF'[z]] is zero
	and returns a pair {g[z],omega[z]} of meromorphic functions."

nullcurveToBryantdata1::usage="nullcurveToBryantdata1[nullMatrix][z] is the first component
	g[z] of nullcurveToBryantdata[nullMatrix][z]. A check of nullMatrix[z] is omitted for
	simplicity." 

nullcurveToBryantdata2::usage="nullcurveToBryantdata2[nullMatrix][z] is the second component
	omega[z] of nullcurveToBryantdata[nullMatrix][z]. A check of nullMatrix[z] is omitted for
	simplicity." 

nullcurveToModifiedData::usage="nullcurveToModifiedData[nullMatrix][z] is the inverse operation
	to the representation formula {a[z],b[z]} --> FF[z]=Sl2CFrameModified[a,b][z].
	It checks whether FF[z] is really null, i.e., whether Det[FF[z]^(-1).FF'[z]] is zero and
	returns a pair {a[z],b[z]} of meromorphic functions."

nullcurveToModifiedData1::usage="nullcurveToModifiedData1[nullMatrix][z] is the first component
	a[z] of nullcurveToModifiedData[nullMatrix][z]. A check of nullMatrix[z] is omitted for
	the sake of simplicity."

nullcurveToModifiedData2::usage="nullcurveToModifiedData2[nullMatrix][z] is the second component
	b[z] of nullcurveToModifiedData[nullMatrix][z]. A check of nullMatrix[z] is omitted for
	the sake of simplicity."

BryantframeModified::usage="BryantframeModified[a,b][z] is the same as
	Sl2CFrameModified[a,b][z]."
	
Sl2CFrameModified::usage="Sl2CFrameModified[u,b][z] is
	Sl2CFrame[a,bb][z] with a[z_]=-1/u[z] and bb[z_]=b[z]*a[z]. 
	This yields a simpler form of this
	expression. The resulting expression contains  only one integral, namely 
	Integrate[Derivative[1][u][z]^2/Derivative[1][b][z],z]."

nilpotentsl2MatrixModified::usage="nilpotentsl2MatrixModified[u,b][z] is
	nilpotentsl2Matrix[a,bb][z] with  a[z_]=-1/u[z] and bb[z_]=b[z]*a[z]. 
	This yields a simple form for the explicit solution F=Sl2CFrameModified[u,b][z] of 
	the cporresponding 2x2-linear system. The resulting expression for F contains only one 
	integral, namely Integrate[Derivative[1][u][z]^2/Derivative[1][b][z],z]."

Sl2CFrameBianchiCaloSmall::usage="f[z] --> Sl2CFrameBianchiCaloSmall[f][z] is an implementation of
	the algebraic representation formula for null curves in Sl(2,C) found by 
	A. J. Small with methods of algebraic geometriy (see 'Surfaces of constant mean
	curvature 1 in H^3 and algebraic curves on a quadric', 
	Proc. AMS, vol 122, No. 4, (1994), 1211- 1220). It seems to be some kind of analogue
	of the Study formula used in minimal surface theory in R^3.\n
	The  operator {f[z],g[z]} --> Sl2CFrameBianchiCaloSmall[f, g][z] is the reparametrization 
	Sl2CFrameBianchiCaloSmall[f_, g_][z_]:=Sl2CFrameBianchiCaloSmall[f][g[z]] of the first one. 
	The Bryant data of Sl2CFrameBianchiCaloSmall[f][z] are g[z]=z and
	omega[z]=1/4 the square of the Schwarzian derivative of f[z] (implemented here
	as schwarzDerCMC[f][z]).
	Analogously, the same holds for Sl2CFrameBianchiCaloSmall[f,g][z].
	(Type for instance\n nullcurveToBryantdata[Sl2CFrameBianchiCaloSmall[f]][z].\n
	\tnilpotentsl2MatrixBasic[# &, schwarzDerCMC[f][#]^2/4 &][z] // Simplify)\n
	This shows, that Bryant's linear system FF'[z]==FF[z].nilpotentsl2MatrixBasic[g,omega][z]
	for null curves can be solved explicitely for omega[z_]=schwarzDerCMC[g][z]^2/4. Type\n 
	D[Sl2CFrameBianchiCaloSmall[f][z], z] - Sl2CFrameBianchiCaloSmall[f][z].\n
	nilpotentsl2MatrixBasic[# &, schwarzDerCMC[f][#]^2/4 &][z] // Simplify\n.
	Observe that Mathematica's NDSolve is not able to produce the solution Sl2CFrameBianchiCaloSmall[f][z]
	from Sl2CFrameBR[# &, schwarzDerCMC[f][#]^2/4 &][z].\n
	A note on the two basic differential invariants of the curve Sl2CFrameBianchiCaloSmall[f][z]:\n
	\t1) The natural parameter (Hopf differential) is schwarzDerCMC[f][z]^2/4
	(type cmcCPPKAN[nullcurveToModifiedData[BianchiCaloSmallFrame[f]]][z])\n
	\t2) The curvature is given by 
	kappa[z_]=-(s[z]^2*(s[z]^4 - 24*s'[z]^2 + 8*s[z]*s''[z]))/32,
	where s[z]=schwarzDerCMC[f][z]. Type\n
	
	Module[{schw0=schwarzDerCMC[f][z],schw1,schw2},schw1=D[schw0,z];schw2=D[schw1,z];\n
	-(schw0^2*(schw0^4-24*schw1^2+8*schw0*schw2))/32]-\n
		cmcKappaKAN[nullcurveToModifiedData[BianchiCaloSmallFrame[f]]][z]//Simplify\n
	to verify this assertion with Mathematica.\n
	The representation formula for CMC-1-surfaces in H^3 corresponding to the formula
	of A. J. Small was rederived by Levi L. de Lima and Pedro Roitman with methods
	of classical Euclidean differential geometry in the paper 'Constant mean curvature
	one surfaces in hyperbolic 3-space using the Bianchi-Cal\`{o} method, 
	An. Acad. Bras. Cien\^{e}c. 74, No.1, 19-24, (2002) by considering
	envelopes of 2-parameter families of spheres in R^3 and classical results of L. Bianchi
	(Lezione di Geometria Differenziale, Terza Editione, Bologna 1927, see also the
	german translation, Page 500 ff, Leipzig 1910) and B. Cal\`{o} (Risoluzione di
	alcuni problemi sull' applicabilitat\`{a} delle superficie, 
	Annali di Mathematica IV, (1899))"

BianchiCaloSmallFrame::usage="BianchiCaloSmallFrame[f][z] and BianchiCaloSmallFrame[f,g][z] are
	the same as Sl2CFrameBianchiCaloSmall[f][z] or Sl2CFrameBianchiCaloSmall[f,g][z] respectively."

auxBianchiCaloSmall::usage="{f[z],g[z]} --> auxBianchiCaloSmall[f,g][z] is an auxiliary command used 
	exclusively to produce the command Sl2CFrameBianchiCaloSmall[f][z] as auxBianchiCaloSmall[f,#&][z]."

hermitianTypeSurface::usage="(u,v)--->hermitianTypeSurface[a,b][u,v] is 
	for parametrized surfaces of constant mean curvature 1 in the space of all 
	2x2 Hermitian matrices that serves as a model for the 3-dimensional hyperbolic space.
	It depends on two meromorphic functions a[z] and b[z].
	It's definition: hermitianTypeSurface[a,b][u,v]=F.F^*, where
	F=Sl2CFrame[a,b][u+I*v] and F^* is the adjoint matrix of F.";

hermitianTypeSurfaceModified::usage="(x,y)--->hermitianTypeSurfaceModified[a,b][x,y] is an
	integral representation formula for parametrized surface of constant mean curvature 1
	in the space of all 2x2 Hermitian matrices that serves as a model for the
	3-dimensional hyperbolic space. It depends on two meromorphic functions a[z] and b[z].
	It's definition: [a,b][u,v]=F.F^*, where F=Sl2CFrameModified[a,b][x+I*y] and
	F^* is the adjoint matrix of F.";

lorentzianTypeSurface::usage="(u,v)--->lorentzianTypeSurface[a,b][u,v] is the Lorentzian version of 
	(u,v)--->hermitianTypeSurface[a,b][u,v], i.e., the parametrized surface in
	the Lorentzian model of the hyperbolic space H^3 obtained as
	hermitean2by2ToLorentz[hermitianTypeSurface[a,b][u,v]]";

lorentzianTypeSurfaceModified::usage="(u,v)--->lorentzianTypeSurfaceModified[a,b][u,v] is the
	Lorentzian version of (u,v)--->hermitianTypeSurfaceModified[a,b][u,v], i.e., the parametrized
	surface in the Lorentzian model of the hyperbolic space H^3 obtained as
	hermitean2by2ToLorentz[hermitianTypeSurfaceModified[a,b][u,v]]";

ballmodelTypeSurface::usage="(u,v)--->ballmodelTypeSurface[a,b][u,v] is the projection of 
	(u,v)--->lorentzianTypeSurface[a,b][u,v] by the map 
	x in R^4 ----> lorentzmodelToBallmodel[x] in the 3-dimensional ball D^3 -
	the usual transformation between the Lorentzian- and the ball-model of the hyperbolic space";

ballmodelTypeSurfaceModified::usage="(u,v)--->ballmodelTypeSurfaceModified[a,b][u,v] is the projection of 
	(u,v)--->lorentzianTypeSurfaceModified[a,b][u,v] by the map 
	x in R^4 ----> lorentzmodelToBallmodel[x] in the 3-dimensional ball D^3 -
	the usual transformation between the Lorentzian- and the ball-model of the hyperbolic space";

nullcurveToBallmodel::usage="nullCurve[z]-->nullcurveToBallmodel[nullCurve][u,v] gives
	the parametrization of the surface corresponding to a given null curve z --> nullCurve[z]
	in the ballmodel of hyperbolic 3-space, replacing the complex variable z by u+I*v."

nullcurveToBallmodelPolar::usage="nullCurve[z]-->nullcurveToBallmodelPolar[nullCurve][r,phi] gives
	the parametrization of the surface corresponding to a given null curve z --> nullCurve[z]
	in the ballmodel of hyperbolic 3-space, replacing the complex variable z by r*Exp[I*phi]."

nullcurveToUpperhalfSpace::usage="nullCurve[z]-->nullcurveToUpperhalfSpace[nullCurve][u,v]
	gives the parametrization of the surface corresponding to a given null curve 
	z -->nullCurve[z]in the upper half space model of hyperbolic 3-space, replacing 
	the complex variable z by u+I*v."

nullcurveToUpperhalfSpacePolar::usage="nullCurve[z]-->nullcurveToUpperhalfSpace[nullCurve][r,phi]
	gives the parametrization of the surface corresponding to a given null curve 
	z --> nullCurve[z] in the upper half space model of hyperbolic 3-space, replacing the
	complex variable z by r*Exp[I*phi]."

nullcurveToHermiteanmodelPolar::usage="nullCurve[z]-->
	nullcurveToHermiteanmodelPolar[nullCurve][r,phi] gives the parametrization of
	the surface in the model of hermitean 2x2-matrices of determinant 1 corresponding
	to the given null curve z --> nullCurve[z]. The operation sends ff[z] to the
	matrix product of ff[z] with the adjoint Matrix of ff[z], replacing the complex
	variable z by r*Exp[I*phi]. "

nullcurveToHermiteanmodel::usage="nullCurve[z]-->nullcurveToHermiteanmodel[nullCurve][u,v]
	gives the parametrization of the surface in the model of hermitean 2x2-matrices of
	determinant 1 corresponding to the given null curve z --> nullCurve[z].
	replacing the complex variable z by u+I+v. The operation sends ff[z] to the matrix
	product of ff[z] with the adjoint Matrix of ff[z], replacing the complex
	variable z by u+I+v."

drahtrahmenderspaehreX::usage="drahtrahmenderspaehreX[m,n] plots a wire frame of the
	2-sphere in R^3 using n longitudes and m latitudes, displaying straight line segments."

drahtrahmenderspaehreY::usage="drahtrahmenderspaehreY[m,n] plots a wire frame of the
	2-sphere in R^3 using n longitudes and m latitudes, displaying smooth curves."

drahtrahmen::usage="drahtrahmen=drahtrahmenderspaehreX[17,11]."


lorentzmodelToBallmodel::usage="lorentzmodelToBallmodel[x0,x1,x2,x3]:={x1,x2,x3}/(1+x0)//Simplify
	or lorentzmodelToBallmodel[vec] is the transformation of H^3 to the 
	3-dimensional open ball D^3 , i.e., the central projection of the Lorentzian 
	space R^4 to R^3 from the point (-1,0,0,0) mapping the hyperbolic space H^3 
	to the 3-dimensional open ball D^3.";

ballmodelToLorentzmodel::usage="ballmodelToLorentzmodel[y1,y2,y3]
	or ballmodelToLorentzmodel[n-dimvector] is the transformation of the 
	3-dimensional open ball D^3 to the hyperbolic space H^3, i.e., the 
	right-inverse of {x0,x1,x2,x3}--->lorentzmodelToBallmodel[x0,x1,x2,x3].
	The command
	lorentzmodelToBallmodel[ballmodelToLorentzmodel[y1,y2,y3]]//Simplify
	returns {y1,y2,y3}.";

upperhalfSpaceToBallmodel::usage="upperhalfSpaceToBallmodel[x1,x2,x3]
	or upperhalfSpaceToBallmodel[n-dimvector] is the isometric transformation of 
	the upper half space x3>0 to the 3-dimensional open ball D^3. The command 
	also works in higher dimensions."

ballmodelToUpperhalfSpace::usage="ballmodelToUpperhalfSpace[x1,x2,x3]
	or ballmodelToUpperhalfSpace[n-dimvector] is the isometric transformation of
	the 3-dimensional ball D^3 in R^3 to the upper half space x3>0. The command 
	also works in higher dimensions."

upperhalfSpaceToLorentzmodel::usage="upperhalfSpaceToLorentzmodel[x1,x2,x3] or
	upperhalfSpaceToLorentzmodel[n-dimvector] is the isometric transformation
	of the upper half space x3>0 to the hyperbolic space H^3. The command also
	works in higher dimensions."

lorentzmodelToUpperhalfSpace::usage="lorentzmodelToBallmodel[x1,x2,x3] or 
	upperhalfSpaceToLorentzmodel[n-dimvector] is the isometric transformation 
	of the hyperbolic space H^3 to the upper half space x3>0."

normalofH3::usage="normalofH3[x0,x1,x2,x3] or
	normalofH3[vec] is the normal vector of the 3-dimensional hyperbolic space H^3,
	realized as a hypersurface of R^4. Confirm this with the commands
	alpha[t_]=hyperbolicPolarCoords[a[t],b[t],c[t]];
	lorentzMetrik[normalofH3[alpha[t]],alpha'[t]]//Simplify";

hyperbolicE::usage="hyperbolicE[x][u,v] is the first coefficient of the
	induced metric tensor of a parametrized surface (u,v)-->x[u,v] in the 
	3-dimensional hyperbolic space H^3, realized as a hypersurface of R^4.";

hyperbolicF::usage="hyperbolicF[x][u,v] is the second coefficient of the induced metric tensor of a
	parametrized surface (u,v)-->x[u,v] in the 3-dimensional hyperbolic space H^3,
	realized as a hypersurface of R^4.";

hyperbolicG::usage="hyperbolicG[x][u,v] is the third coefficient of the induced metric tensor of a
	parametrized surface (u,v)-->x[u,v] in the 3-dimensional hyperbolic space H^3,
	realized as a hypersurface of R^4.";


hyperbolicL::usage="hyperbolicL[x][u,v] is the first coefficient of the second fundamental
	form of a parametrized surface (u,v)-->x[u,v] in the 3-dimensional hyperbolic space H^3,
	realized as a hypersurface of R^4.";

hyperbolicM::usage="hyperbolicM[x][u,v] is the second coefficient of the second fundamental
	form of a parametrized surface (u,v)-->x[u,v] in the 3-dimensional hyperbolic space H^3,
	realized as a hypersurface of R^4.";

hyperbolicN::usage="hyperbolicN[x][u,v] is the third coefficient of the second fundamental
	form of a parametrized surface (u,v)-->x[u,v] in the 3-dimensional hyperbolic space H^3,
	realized as a hypersurface of R^4.";

hyperbolicfirstFF::usage="hyperbolicfirstFF[x][u,v] is the induced metric tensor of a
	parametrized surface (u,v)-->x[u,v] in the 3-dimensional hyperbolic space H^3,
	realized as a hypersurface of R^4.";

hyperbolicsecondFF::usage="hyperbolicsecondFF[x][u,v] is the second fundamental form of a
	parametrized surface (u,v)-->x[u,v] in the 3-dimensional hyperbolic space H^3,
	realized as a hypersurface of R^4.";

hyperbolicWeingartenmap::usage="hyperbolicWeingartenmap[x][u,v] is the Weingarten map of a
	parametrized surface (u,v)-->x[u,v] in the 3-dimensional hyperbolic space H^3,
	realized as a hypersurface of R^4.";

hyperbolicGaussiancurvature::usage="hyperbolicGaussiancurvature[x][u,v] is the Gaussian curvature of a
	parametrized surface (u,v)-->x[u,v] in the 3-dimensional hyperbolic space H^3,
	realized as a hypersurface of R^4.";

hyperbolicMeancurvature::usage="hyperbolicMeancurvature[x][u,v] is the mean curvature of a
	parametrized surface (u,v)-->x[u,v] in the 3-dimensional hyperbolic space H^3,
	realized as a hypersurface of R^4.";

hyperbolicSurfaceNormalVector::usage="n=hyperbolicNormal[x][u,v] is the normal vector of a
	parametrized surface (u,v)-->x[u,v] in the 3-dimensional hyperbolic space
	H^3, where H^3 is realized as a hypersurface of R^4. This means that n is a vector of R^4
	tangent to H^3 and normal to the surface x[u,v].";

hyperbolicSurfaceNormalVectorwithCheck::usage="hyperbolicNormalwithCheck[x][u,v] is the same as
	hyperbolicSurfaceNormalVector[x][u,v], but
	a checks whether the derivatives of x[u,v] are tangent to H^3 at the point x[u,v] of H^3 is
	included."

spur::usage="spur[m] is the trace of a the square matrix m."
	
commutator::usage="commutator[x,y] is the ordinary commutator of two square matrices x and y.
	commutator[{x,y}] or pair//commutator applies two pairs of matrices."

adjointRepresentation::usage="adjointRepresentation[n][x][y] is the n-th power of the operator
	ad[x]:y-->x.y-y.x acting on the Lie algebra of all square matrices of some fixed order. 
	This command is used for instance for the invesigation of power series of ad[x] for instance."

hyperbolicunitNormal::usage="n=hyperbolicunitNormal[x][u,v] is the unit normal vector of a
	parametrized surface (u,v)-->x[u,v] in the 3-dimensional hyperbolic space H^3,realized as a hypersurface
	of R^4. This means that n is a vector of R^4 of unit length with respect to the Lorentzian scalar product.
	It is tangent to H^3 and normal to the surface x[u,v].";

hyperbolicCross::usage="hyperbolicCross[v,w][point] is the cross product of
	two tangent vectors v and w
	of the tangent space T_point(H^3) of the hyperbolic space H^3 at a point
	'point' of H^3 with respect to the metric induced from the lorentzian metric
	of the ambient space R^4. H^3 is considered as a 3-dimensional hyperspace of R^4."

hyperbolicCrosswithCheck::usage="hyperbolicCrosswithCheck[v,w][point] is
	the same as hyperbolicCross[v,w][point] but
	checks whether v and w are tangent to H^3 at the point 'point' of H^3."

hyperbolicTangentVectorofH3::usage=
	"{x1,x2,x3}-->hyperbolicTangentVectorofH3[a,b,c][x1,x2,x3] is a bijective
	linear map of R^3 to the tangent space of H^3 at the point
	p=hyperbolicPolarCoords[a,b,c]."

hyperbolicTangentVectorofH3Invers::usage=
	"{xx0,xx1,xx2,xx3}-->hyperbolicTangentVectorofH3Invers[a,b,c][xx0,xx1,xx2,xx3]
	is the left-inverse linear map of
	hyperbolicTangentVectorofH3[a,b,c][x1,x2,x3]. To see it's relation to this
	command type for instance
	hyperbolicTangentVectorofH3Invers[a,b,c][xx0,xx1,xx2,xx3]//hyperbolicTangentVectorofH3[a,b,c]
	or
	hyperbolicTangentVectorofH3[a,b,c][x1,x2,x3]//hyperbolicTangentVectorofH3Invers[a,b,c]";


(******************** second fundamental form *******************)

hyperbolicL::usage="hyperbolicL[x][u,v] is the first coefficient of the second fundamental
	form of a parametrized surface x[u,v] in the hyperbolic space H^3.";

hyperbolicM::usage="hyperbolicM[x][u,v] is the second coefficient of the second fundamental
	form of a parametrized surface x[u,v] in the hyperbolic space H^3.";

hyperbolicN::usage="hyperbolicN[x][u,v] is the third coefficient of the second fundamental
	form of a  parametrized surface x[u,v] in the hyperbolic space H^3.";

hyperbolicsecondFF::usage="hyperbolicsecondFF[x][u,v] is the matrix of the second fundamental form
	of a parametrized surface x[u,v] in the hyperbolic space H^3.";


hyperbolicLeviCivita::usage="hyperbolicLeviCivita[x,v][{r,s}][u,v] is the covariant derivative of a
	vector field v[u,v] defined on a parametrized surface x[u,v] in the
	hyperbolic space H^3.";

hyperbolicOrthogonalProjection::usage="hyperbolicOrthogonalProjection[x][a] is the
	orthogonal projection of Lorentzian space R^4 of a vector x of R^4 in the
	direction of a nonisotropic vector a giving the direction of orthogonal projection.
	This command is used in defining the Levi-Civita connection of the hyperbolic
	space H^3.";

hyperbolicMeancurvature::usage="hyperbolicMeancurvature[x][u,v] is the mean 
	curvature of a parametrized surface x[u,v] in the hyperbolic space H^3.";

hyperbolicGaussiancurvature::usage="hyperbolicGaussiancurvature[x][u,v] is the 
	Gaussian curvature of a parametrized surface x[u,v] in the hyperbolic space H^3.";

hyperbolicWeingartenmap::usage="hyperbolicWeingartenmap[x][u,v] is the shape operator of a parametrized 
	surface x[u,v] in the hyperbolic space H^3.";


(*******************************************************************************
	Quaternionen, Sl(2,C), Spur, Lorentzmetrik,
	Transformation H^3<--->HermitescheMatrizen etc. 
*******************************************************************************)



adjointMatrix::usage="M=matrix-->adjointMatrix[M] is the matrix of all determinants
	of square submatrices of order n-1 of M, where n is the minimum of the two dimensions of M."

nilpotentsl2MatrixBasic::usage="nilpotentsl2MatrixBasic[g,omega][z] is a matrix valued
	function depending on a meromorphic function g[z] and a meromorphic
	differential 1-form omega[z] with values in the Lie-algebra of Sl(2,C)
	that presents R. Bryants analogue of the Weierstrass-formula for
	CMC-surfaces in the hyperbolic space H^3. Namely, solving the linear
	matrix-system F'=F*X of differential equations yields an Sl(2,C)-Matrix
	F[z] such that the map z->Transpose[Conjugate[F[z]]].F[z] yields a
	CMC-surface parametrized by z\in C. Here, the hyperbolic space
	H^3 is identified with the subset of Hermitian matrices of the Lie
	algebra of Gl(2,C) by the map lorentzToHermitean2by2[x0,x1,x2,x3].";

nilpotentsl2Matrix::usage="X=nilpotentsl2Matrix[a,b][z] is a version
	of nilpotentsl2MatrixBasic[g,omega][z] with
	g[z_]=basicFunctionG[a,b][z] and omega[z_]=basicFunctionOmega[a,b][z]. 
	The advantage is that a fundamental solution of the linear system F'=F.X
	can be expressed by quadratures in terms of a[z] and b[z]. The exact form of
	this F is provided by the operator Sl2CFrame[a,b][z],z]. This can be conformed by typing
	D[Sl2CFrame[a,b][z],z]-Sl2CFrame[a,b][z].nilpotentsl2Matrix[a,b][z]//Simplify.
	The result will be the 2x2-0-matrix.";

lorentzToHermitean2by2::usage="lorentzToHermitean2by2[x0,x1,x2,x3] or
	lorentzToHermitean2by2[vec] transforms a point vec={x0,x1,x2,x3} of the Lorentzian space
	R^4 into a Hermitean matrix of gl(2,C). The mapping {x0,x1,x2,x3}--->
	lorentzToHermitean2by2[x0,x1,x2,x3] is a bijection onto the space of Hermitean matrices
	and it's inverse is given by the command hermitean2by2ToLorentz.
	Moreover, the determinant of I*lorentzToHermitean2by2[x0,x1,x2,x3] is the negative
	square of the length of vec with respect the Lorentzian scalarproduct in R^3.";

hermitean2by2ToLorentz::usage="hermitean2by2ToLorentz[m] or
	hermitean2by2ToLorentz[m11,m12,m21,m22], where m={{m11,m12},{m21,m22}}
	is a complex 2x2-matrix, is the inverse transformation of lorentzToHermitean2by2."


lorentzMetrik::usage="lorentzMetrik[{x0,x1,x2,x3},{y0,y1,y2,y3}]=-x0*y0+x1*y1+x2*y2+x3*y3 is
	the Lorentzian indefinite scalar product of R^4 of signature (1,3).";
	
lorentzLength::usage="lorentzLength[{x0,x1,x2,x3}] is the lenght of the vector
	{x0,x1,x2,x3} with respect to the indefinite Lorentzian scalar product (seelorentzMetrik).";

lorentzGruppe::usage="lorentzGruppe[a,b,c,d,e,f] is a parametrization of
	the 6-dimensional group of Lorentzian transformations of R^4, i.e., the group of all 
	matices preserving the indefinite Lorentzian scalar product lorentzMetrik[v ,w]. 
	Try the commands
	mm=lorentzGruppe[a,b,c,d,e,f];
	Transpose[mm].lorentzmetric.mm//Simplify"

QuaternionicMatrix::usage="QuaternionicMatrix[a,b,c,d] is a general quaternionic matrix.
	hermitean2by2ToLorentz[QuaternionicMatrix[a,b,c,d]] yields {a,I*d,-I*c,I*b}.";

Quaternions::usage="Quaternions is a list of 8 complex 2x2-matrices
	representing the group
	{e,i,j,k,-e,-i,-j,-k} of quaternions. The following term produces the
	muliplication table of the group
	of quaternions:
	quaternionicmultiplicationtable=(qq=Thread[Quaternions->{e,i,j,k,e1,i1,j1,k1}];
	qq1=Thread[{e1,i1,j1,k1}->{-e,-i,-j,-k}];
	ruleReverse[rule_]:=Table[rule[[i,2]]->rule[[i,1]],{i,Length[rule]}];
	qqi=ruleReverse[qq];qq1i=ruleReverse[qq1];
	quaternions/.qq/.qq1;
	multiplikationstabelle=Table[Quaternions[[i]].Quaternions[[j]],{i,8},{j,8}]
	/.qq/.qq1;TableForm[multiplikationstabelle,TableSpacing->{1,1,1,1,1,1,1,1}])"

	
hyperbolicSurfaceNormalInhyperbolicPolarCoords::usage=
	"hyperbolicSurfaceNormalInhyperbolicPolarCoords[a,b,c][u,v] is the explicit
	expression of the
	surface normal of a surface in the hyperbolic space H^3 defined by three
	functions a[u,v], b[u,v], c[u,v] and
	the assignment (u,v)--->surfaceInhyperbolicPolarCoords[a,b,c][u,v]. It is the
	same operation as
	hyperbolicSurfaceNormalVector[surfaceInhyperbolicPolarCoords[a,b,c]][u,v].";


surfaceInhyperbolicPolarCoords::usage=
	"surfaceInhyperbolicPolarCoords[a,b,c][u,v] is a parametrized
	surface in the hyperbolic space H^3 defined by three functions a[u,v],
	b[u,v], c[u,v] and
	the parametrization of H^3 by hyperbolic polar coordinates, i.e.,
	surfaceInhyperbolicPolarCoords[a_,b_,c_][u_,v_]:=
	hyperbolicPolarCoords[a[u,v],b[u,v],c[u,v]]."

	
hyperbolicPolarCoords::usage="hyperbolicPolarCoords[a,b,c]:={Cosh[a]
	Cosh[b] Cosh[c],Cosh[b] Cosh[c] Sinh[a],Cosh[c] Sinh[b],Sinh[c]} is a
	parametrization of the 3-dimensional hyperbolic space, realized as
	the hyperquadric -x0^2+x1^2+x2^2+x3^3=-1 of R^4. hyperbolicPolarCoords[a,b,c]
	is the first line of the 4x4-matrix lorentzGruppe[a,b,c,d,e,f]."
	
llLoren::usage="llLoren[1,2][a], llLoren[1,3][b], llLoren[1,4][c] are the
	elementary Lorentzian matrizes of SO(1,3)."
	llEukl::usage="llEukl[2,3][a], llEukl[2,4][b], llEukl[3,4][c] are the elementary
	matrizes of SO(1,3)." 

(************* KAN-parametrization, conformal metriv, covariant derivative*******************)

covDerVectorKAN1::usage="covDerVectorKAN1[a,b][z] is the tangent vector of the curve\n
	sl2KAN[z_]=Sl2KANparamInvers[Sl2CFrameModified[a,b][z]][[1]]";

covDerVectorKAN2::usage="covDerVectorKAN2[a,b][z] is the second order tangent vector of the curve\n
	sl2KAN[z_]=Sl2KANparamInvers[Sl2CFrameModified[a,b][z]][[1]]\n
	obtained as covariant derivative of covDerVectorKAN1[a,b][z] along sl2KAN[z].";

covDerVectorKAN3::usage="covDerVectorKAN3[a,b][z] is the 3-rd order tangent vector of the curve\n
	sl2KAN[z_]=Sl2KANparamInvers[Sl2CFrameModified[a,b][z]][[1]]\n
	obtained as covariant derivative of covDerVectorKAN2[a,b][z] along sl2KAN[z].";

covDerVectorKAN4::usage="covDerVectorKAN3[a,b][z] is the 4-th order tangent vector of the curve\n
	sl2KAN[z_]=Sl2KANparamInvers[Sl2CFrameModified[a,b][z]][[1]]\n
	obtained as covariant derivative of covDerVectorKAN3[a,b][z] along sl2KAN[z].";

covDerVectorKAN5::usage="covDerVectorKAN5[a,b][z] is the 5-th order tangent vector of the curve\n
	sl2KAN[z_]=Sl2KANparamInvers[Sl2CFrameModified[a,b][z]][[1]]\n
	obtained as covariant derivative of covDerVectorKAN4[a,b][z] along sl2KAN[z].";

Sl2CAction::usage="Sl2CAction[matrix][pairs] is an action of Sl(2,C) on pairs {g,om}
	that is induced from the invariance of the space of nilpotent sl(2,C)-matrices of the
	form X=nilpotentsl2MatrixBasic[g,om][z] under the adjoint representation of Sl(2,C).
	It is designed so that {g,om} ---> nilmatrix[g_,om_]:=om*{{g,-g^2},{1,-g}} is equivariant.
	The equivariance can be seen by typing\n\n
	nilmatrix[g_,om_]:=om*{{g,-g^2},{1,-g}};\n
	nilmatrix[x_List]:=nilmatrix[x[[1]],x[[2]]]\n
	pp={g[z],om[z]};mm={{a,b},{c,d}};mmInvers={{d,-b},{-c,a}};\n
	nilmatrix[Sl2CAction[mm][pp]]-mm.nilmatrix[{g[z],om[z]}].mmInvers//Expand\n\n
	Another check of the action property is given with\n
	matrix1={{a1,b1},{c1,d1}};matrix2={{a2,b2},{c2,d2}};pair={f[z],om[z]};\n
	Sl2CAction[matrix2][Sl2CAction[matrix1][pair]]-Sl2CAction[matrix2.matrix1][pair]//Simplify.\n\n
	Sl2CAction[matrix][function,form], Sl2CAction[a,b,c,d][function,form] and 
	Sl2CAction[a,b,c,d][pair] are similar commands that accept other forms of inputs."

Sl2Framerule::usage="Sl2Framerule[n][a11,a12,a21,a22][g,om][z]is a rule that substitutes
	all derivatives of the functions a11[z], a12[z], a21[z],a22[z]  up to order n by the
	expressions that they are subject to if the matrix FF[z_]={{a11[z],a12[z]},{a21[z],a22[z]}}
	is a Bryantframe, i.e., has determinant=1 and solves the linear system
	FF'[z]=FF[z].nilpotentsl2MatrixBasic[g,om][z]=FF[z].{{g[z],-g[z]^2},{1,-g[z]}}*om[z].
	This rule is used to investigate higher order derivatives of Bryantframes, i.e., of null-curves
	in Sl(2,C).";

toBryantframeData::usage="toBryantframeData[n][a11, a12, a21, a22][g, om][z][term]=
	(term//.Sl2Framerule[n][a11,a12,a21,a22][g,om][z])//Simplify reduces
	an expression 'term' containing the four functions a11[z],a12[z],a21[z],a22[z],
	together with their derivatives up to order n to an expression containing only the
	functions g[z] and om[z] and their derivatives. The correspondence is made so that the
	aij[z] are to be regarded as entries of a solution FF[z_]={{a11[z],a12[z]},{a21[z],a22[z]}}
	of the linear system FF'[z]=FF[z].{{g[z],-g[z]^2},{1,-g[z]}}*om[z].
	Examples: The first command shows that null curves have vanishing arc length:\n
	sl2[z_] = {{a11[z], a12[z]}, {a21[z], a22[z]}}\n
	tt = Sl2KANparamInvers[sl2[z]][[1]]\n
	invariantmetricKAN[tt][D[tt, z]][D[tt, z]] // toBryantframeData\n
	
	The following commands compute the metric invariants of a null curve\n
	sl2KAN[z_] = Sl2KANparamInvers[sl2[z]][[1]]\n
	t1 = highercovDerKANofCurve[1][sl2KAN][z] // toBryantframeData;\n
	t2 = highercovDerKANofCurve[2][sl2KAN][z] // toBryantframeData;\n
	t3 = highercovDerKANofCurve[3][sl2KAN][z] // toBryantframeData;\n
	{invariantmetricKAN[sl2KAN[z]][t1][t1],invariantmetricKAN[sl2KAN[z]][t1][t2],
	invariantmetricKAN[sl2KAN[z]][t2][t2],invariantmetricKAN[sl2KAN[z]][t2][t3],
	invariantmetricKAN[sl2KAN[z]][t3][t3]} // Simplify";

cppKAN2::usage="cppKAN2[a,b][z] is the expression in KAN-parametrization for the square
	of the derivative of the natural parameter of the Sl2CFrameModified[a,b][z].
	The command can be designed in the following way: Transfer
	Sl2CFrameModified[a,b][z] into KAN-parametrization by\n
	sl2KAN[z_]=SSl2KANparamInvers[Sl2CFrameModified[a,b][z]][[1]].
	Next put t2=highercovDerKANofCurve[2][sl2KAN][z]//Simplify;
	Finally cppKAN2[a,b][z] is given by invariantmetricKAN[sl2KAN[z]][t2][t2]//Simplify.\n
	Note that this natural parameter is defined as the root of the length
	invariantmetricKAN[sl2KAN[z]][t2][t2] of second tangent vector t2 of
	Sl2CFrameModified[a,b][z] and that it is given in terms Bryant representation formula
	Sl2CFrameBR[g,om][z] simply by (g'[z]*om[z])^2.";


matrixOfScalarproducts::usage="matrixDerSkalarprodukte[a][z] is a 5x5-matrix whose
	entries are the scalar products invariantmetricKAN[sl2KAN[z]][tttx[[i]]][tttx[[j]]]
	of the tangent vectors tttx[[i]] of order i and j respectively of the null curve
	Sl2CFrameModified[a,b][z] in natural parametrization, 1<=i,j<=5. More detailed explanation:
	We transfer Sl2CFrameModified[a,b][z] into KAN-parametrization putting\n
	sl2[z_]=Sl2CFrameModified[a,b][z];\n
	sl2KAN[z_]=Sl2KANparamInvers[sl2[z]][[1]]//Simplify;\n
	Next we compute a list of higher order tangent vectors by\n
	tttx={ttt1[a_,b_][z_]=FullSimplify[D[sl2KAN[z],z]],\n
	ttt2[a_,b_][z_]=FullSimplify[covDerofVectorfieldKANalongCurve[sl2KAN,ttt1[a,b]][z]],\n
	ttt3[a_,b_][z_]=FullSimplify[covDerofVectorfieldKANalongCurve[sl2KAN,ttt2[a,b]][z]],\n
	ttt4[a_,b_][z_]=FullSimplify[covDerofVectorfieldKANalongCurve[sl2KAN,ttt3[a,b]][z]],\n
	ttt5[a_,b_][z_]=FullSimplify[covDerofVectorfieldKANalongCurve[sl2KAN,ttt4[a,b]][z]]};\n
	Finally, the entries cij of matrixDerSkalarprodukte[a][z] are obtained by\n
	cij=(mm[a_,b_][z_]=invariantmetricKAN[sl2KAN[z]][tttx[[i]]][tttx[[j]]]//Simplify;
	 mm[a,bbcan[a]][z]//Simplify).";


schwarzDerCMC::usage="schwarzDerCMC[f][z]=Sqrt[3*D[f[z],z,z]^2-2*D[f[z],z]*D[f[z],{z,3}]]/D[f[z],z]
	 is the Schwarzian derivative of a function f[z]."


aFunModifiedForEqualG::usage="aFunModifiedForEqualG[qq,b][z] is an operator designed 
	so that the matrix xc=nilpotentsl2MatrixModified[aFunModifiedForEqualG[q,b],b][z]
	satisfies xc[[1,1]]/xc[[2,1]]=q[z], i.e., the g[z]-term of the Bryantdata of all
	matrices nilpotentsl2MatrixModified[aFunModifiedForEqualG[q,b],b][z]
	is the same function.";

aFunForEqualG::usage="aFunForEqualG[qq,b][z] is is an operator designed so that 
	xc=nilpotentsl2Matrix[aFunForEqualG[q,b],b][z] satisfies xc[[1,1]]/xc[[2,1]]=q[z],
	i.e., the g[z]-term of the Bryantdata of all matrices 
	nilpotentsl2Matrix[aFunForEqualG[q,b],b][z] is the same function.";

bbcan::usage="bbcan[c1,c2][a][z]:=c1+c2*Integrate[D[a[z],z]*E^(-Integrate[a[z]/D[a[z],z],z]),z]
	is a function that solves the differential equation
	cmcKappa[a,bbcan][z]=1, where cmcKappaKAN[a,b][z]
	is the length of the second covariant derivative of the curve Sl2CFrameModified[a,b][z]
	with respect to the invariant complex Riemannian metric 'invariantmetricKAN'.
	bbcan[a][z] is bbcan[0,1][a][z]."

partielIntegrationbbcan::usage="partielIntegrationbbcan[a,z][term] transforms any expression
	'term' containing the integral bbcan[a][z] into an equivalent expression by transforming
	bbcan[a][z] according to the rule of partielle integration."


Sl2CFrameBR::usage="{g[z],om[z]} --> Sl2CFrameBR[g,om][z] is an implementation of
	the Bryant representation formula for nullcurves in Sl(2,C). It uses 'DSolve' for the
	corresponding system of linear differential equations.
	Therefore, it will not be very efficient."

cmcCPPKAN::usage="cmcds2[z]=cmcCPPKAN[a,b][z] is the derivative of the natural
	parameter of the null curve in Sl(2,C) given by the integral representation formula
	Sl2CFrameModified[a,b][z]. The expression is obtained as the length of the
	2-nd covariant derivative of Sl2CFrameModified[a,b][z]. Explicit computation:
	cmcds2[z_]=invariantmetricKAN[sl2KAN[z]][covDerVectorKAN2[a,b][z]][covDerVectorKAN2[a,b][z]]//Sqrt
	where sl2KAN[z] serves temporarily as short expression for
	Sl2KANparamInvers[Sl2CFrameModified[a,b][z]][[1]]//Simplify;\n
	cmcCPPKAN[pair][z] is cmcCPPKAN[a,b][z] where pair[z_]={a[z],b[z]}."

cmcKappaKAN::usage="cmcCurvature[z_]=cmcKappaKAN[a,b][z] is the square of the length of the
	3-rd covariant derivative of the null curve in Sl(2,C) given by the integral representation formula
	Sl2CFrameModified[a,b][z]. As such, it is an analogue of the Study parameter that
	occurs in minimal surface theory. The expression is obtained using the commands
	covDerVectorKA3[a,b][z] and invariantmetricKAN[point][vec1][vec2]:
	cmcKappaKAN[z_]=
		invariantmetricKAN[sl2KAN[z]][covDerVectorKAN3[a,b][z]][covDerVectorKAN3[a,b][z]]//Sqrt
	where sl2KAN[z] serves temporarily as short expression for
	Sl2KANparamInvers[Sl2CFrameModified[a,b][z]][[1]]//Simplify;\n
	cmcKappaKAN[pair][z] is cmcKappaKAN[a,b][z] where pair[z_]={a[z],b[z]}."


nilpotent::usage="nilpotent[a_]:={{1,a},{0,1}}//Simplify"

abelian::usage="abelian[a_]:=DiagonalMatrix[{a,1/a}]//Simplify"

compact::usage="compact[c_]:={{Cos[c],-Sin[c]},{Sin[c],Cos[c]}}//Simplify"

Sl2KANparam::usage="Sl2KANparam[a_,b_,c_]:=
	compact[I*Log[a]].abelian[b].nilpotent[c] is an algebraic parametrization
	of the special linear group Sl(2,C) related to the canonical decomposition
	of its Lie-algebra into a compact, abelien and nilpotent part. 
	Sl2KANparam[vec_] is the same but expects a list of variables as input.";

Sl2CToSO13::usage="matrix --> Sl2CToSO13[matrix] is a 'quasi-group homomorphism' of
	the full linear group Gl(2,C) to SO(1,3), where 'quasi' means, that it is not
	uniquely defined. It is not a accurate homomorphism, since we were forced to
	include the root of the square of the complex norm of the determinant of 'matrix',
	which not a unique-valued function, except in Mathematica 
	in combination with 'PowerExpand' where a unique result comes out - sometimes false.
	This gives a formula, simpler than other ones that came out for instance by
	confining to Sl(2,C) and using the KAN-Parametrization of Sl(2,C).
	Restricted to the subgroup Sl(2,C) an accurate 
	group homomorphism is obtained from Sl2CToSO13. Possible tests:\n
	test1:=(ma=Sl2KANparam[a,b,c];mb=Sl2KANparam[ax,bx,cx];\n
	\tSl2CToSO13[ma].Sl2CToSO13[mb]-Sl2CToSO13[ma.mb]//Simplify)\n
	test2:=(ma={{ar,br},{cr,dr}}+I*{{af,bf},{cf,df}};\n
	\tmb={{arr,brr},{crr,drr}}+I*{{aff,bff},{cff,dff}};\n
	\ttx//complextreatment)\n\n
	Sl2CToSO13[a11,a12,a21,a22,b11,b12,b21,b22] is the same, accepting 8 real numers, namely
	the real and imaginary parts of the entris of 'matrix' as input."

Sl2KANparamInversX::usage="w-->Sl2KANparamInversX[w] is a
	version of Sl2KANparamInvers[w] whose construction uses the fact that 
	the matrix multiplikation w-->Transpose[w].w factors out the compact part immediately 
	together with the unsubtle command 'PowerExpand' to give a unique result {a,b,c}, 
	that has to be completed by a second {-a,-b,c} however."
	
Sl2KANparamInvers1::usage="w -->Sl2KANparamInvers1[w] is the
	first component of the inverse map to the parametrization 
	{a,b,c}--->Sl2KANparam[a,b,c], i.e., a pair {a,-a}, where a and -a are 
	complex numbers such that w=compact[I*Log[a]].abelian[b].nilpotent[c]=
	compact[I*Log[-a]].abelian[b].nilpotent[c].";

Sl2KANparamInvers2::usage="w -->Sl2KANparamInvers1[w] is the
	second component of the inverse map to the parametrization 
	{a,b,c}--->Sl2KANparam[a,b,c], i.e., a  pair {b,-b}, where b and -b are 
	complex numbers such that w=compact[I*Log[a]].abelian[b].nilpotent[c]=
	compact[I*Log[a]].abelian[-b].nilpotent[c].";

Sl2KANparamInvers3::usage="w --> Sl2KANparamInvers1[w] is the
	third component of the inverse map to the parametrization 
	{a,b,c}--->Sl2KANparam[a,b,c], i.e., a complex number c 
	(better to say the pair {c,c}), such that w=compact[I*Log[a]].abelian[b].nilpotent[c].";

Sl2KANparamInvers::usage="w-->Sl2KANparamInvers[w] is the
	inverse map to the parametrization {a,b,c}--->Sl2KANparam[a,b,c]. 
	More precisely, Sl2KANparamInvers[w] gives two triples {a,b,c} and {-a,-b,c}
	such that w=Sl2KANparam[a,b,c]=Sl2KANparam[-a,-b,c].
	The three components of Sl2KANparamInvers[w] can be obtained separately with 
	Sl2KANparamInversi[w] (i=1,2,3).
	Note  that c is unique in contrast to a and b. 
	A convincing check is given by the following term:
	(ii=2;(*or ii=1;*)
	  zz:=Random[Real,{-99,99}];z:=zz+I*zz
	  test:=Module[{w=Sl2KANparam[z,z,z],aa,bb,cc,e},
	  aa=Sl2KANparamInvers1[w][[ii]];
	  bb=Sl2KANparamInvers2[w][[ii]];
	  cc=Sl2KANparamInvers3[w][[ii]];
	  e=Chop[w-Sl2KANparam[aa,bb,cc],10^-7]//Flatten//Union;e[[1]]];
		Table[test,{1000}])"

Sl2KANparamDifferential::usage="
	{point,vector}={{a,b,c},{x,y,z}}--> Sl2KANparamDifferential[a,b,c][x,y z]
	is the differential (i.e., the tangent map) of {a,b,c} -> Sl2KANparam[a,b,c].
	Inverse operation to Sl2KANparamDifferentialInvers. In other words and in formulas:
	Sl2KANparamDifferential[a,b,c][x,y,z] is the same as\n
	(Inverse[Sl2KANparam[a,b,c]].(D[Sl2KANparam[a+t*x,b+t*y,c+t*z],t]//.t->0))//Simplify.\n
	The return is a matrix X of sl(2,C) (i.e., a tracefree 2x2-matrix), that has to
	be considered has as tangent vector at the point P=Sl2KANparam[{a,b,c}] of C^3 defined
	as transform of X by left translation with P.\n
	Sl2KANparamDifferential[point][vector],\n
	Sl2KANparamDifferential[a,b,c][vector],\n
	Sl2KANparamDifferential[point][x,y,z]\n
	are the same but expecting lists as input."
	
Sl2KANparamDifferentialInvers::usage="
	{matrix,tangentmatrix}={{{a11,a12},{a21,a22}},{{x11,x12},{x21,x22}}} -->
	Sl2KANparamDifferentialInvers[a11,a12,a21,a22][x11,x12,x21,x22] is the
	differential (i.e., the tangent map) of matrix -> Sl2KANparamInvers[matrix].
	Inverse operation to Sl2KANparamDifferential. In other words and in formulas:
	For mu={{a,b},{c,d}} and xu={{x11,x12},{x21,x22}} holds
	Sl2KANparamDifferentialInvers[mu][xu]-(D[Sl2KANparamInvers[mu+t*mu.xu],t][[1]]/.t->0)//Simplify\n
	The return is a vector of C^3, that has to be considered as tangent vector
	at the point Sl2KANparamInvers[{{a11,a12},{a21,a22}}] of C^3.\n
	Sl2KANparamDifferential[matrix][tangentmatrix],\n
	Sl2KANparamDifferential[a11,a12,a21,a22][tangentmatrix],\n
	Sl2KANparamDifferential[matrix][x11,x12,x21,x22]\n
	are the same but expecting as input four variables in place
	of the corresponding matrices."

Sl2KANparamInversXX::usage="m={{a,b},{c,d}} --> Sl2KANparamInversXX[signum][m] or
	Sl2KANparamInversXX[signum][a,b,c,d] is another version of Sl2KANparamInvers[{{a,b},{c,d}}]
	based on Mathematica's response to\n
	pp={a,b,c};mm=Sl2KANparam[pp];mmx={{ax,bx},{cx,dx}};\n
	gl=Join[FullSimplify[Thread[Flatten[mmx-mm]=={0,0,0,0}]],{Det[mmx]==1}];\n
	sol=Solve[gl,pp];\n
	The cariable 'sign' should be +1 or -1 and determines, which of the two solutions 
	of this equation is used."

Sl2KANparamInversXX1::usage="m={{a,b},{c,d}} --> Sl2KANparamInversXX1[m] or Sl2KANparamInversXX1[a,b,c,d]
	is Sl2KANparamInversXX[-1][m] resp. Sl2KANparamInversXX[-1][a,b,c,d]."

Sl2KANparamInversXX2::usage="m={{a,b},{c,d}} --> Sl2KANparamInversXX2[m] or Sl2KANparamInversXX2[a,b,c,d]
	is Sl2KANparamInversXX[1][m] resp. Sl2KANparamInversXX[1][a,b,c,d]."

Sl2KANparamDifferentialInversXX::usage="(m={{a,b},{c,d}},n={{x,y},{u,v}}) --> 
	Sl2KANparamDifferentialInversXX[sign][m][n] or 
	Sl2KANparamDifferentialInversXX[sign][{{a,b},{c,d}}][{{x,y},{u,v}}] is the differential
	of the map m --> Sl2KANparamInversXX[signum][m]. This expression was defined as the 
	Mathematica-output of the command\n
	Sl2KANparamDifferentialInversXXoriginal[sign_][m_][x_]:=
	\t(D[Sl2KANparamInversXX[sign][m+t*m.x],t]//.t->0)//Simplify"

Sl2KANparamDifferentialInversXX1::usage="(m={{a,b},{c,d}},n={{x,y},{u,v}} --> 
	Sl2KANparamDifferentialInversXX1[m][n] or
	Sl2KANparamDifferentialInversXX1[{{a,b},{c,d}}][{{x,y},{u,v}}] is 
	Sl2KANparamDifferentialInversXX[-1][m][n] resp. 
	Sl2KANparamDifferentialInversXX[-1][{{a,b},{c,d}}][{{x,y},{u,v}}].
	Mixed versions available are Sl2KANparamDifferentialInversXX1[{{a,b},{c,d}}][][n] and 
	Sl2KANparamDifferentialInversXX1[m][{{x,y},{u,v}]."

Sl2KANparamDifferentialInversXX2::usage="(m={{a,b},{c,d}},n={{x,y},{u,v}} --> 
	Sl2KANparamDifferentialInversXX2[m][n] or
	Sl2KANparamDifferentialInversXX2[{{a,b},{c,d}}][{{x,y},{u,v}}] is 
	Sl2KANparamDifferentialInversXX[1][m][n] resp. 
	Sl2KANparamDifferentialInversXX[1][{{a,b},{c,d}}][{{x,y},{u,v}}].
	Mixed versions available are Sl2KANparamDifferentialInversXX2[{{a,b},{c,d}}][][n] and 
	Sl2KANparamDifferentialInversXX2[m][{{x,y},{u,v}]."

commutatorKAN::usage="{{p={a,b,c},v1={x1,y1,z1},v2={x2,y2,z2}} --> commutatorKAN[p][v1,v2]
	is the coordinate expression for the comutator of two tangent vectors v1,v2 at a point
	p of Sl(2,C) in KAN-parametrisation {a,b,c} --> Sl2KANparam[a,b,c]. The arguments
	p,v1,v2 must be given as the corresponding tripels of complex numbers. 
	The notion of commutator has to be understood as follows: The tangent vectors v1, v2
	define unique left invariant vector fields X1, X2 on the Lie-group Sl(2,C) such that
	X1[p]=v1 and X2[p]=v2. The commutator X=[X1,X2] of these is a new left 
	invariant vector field on Sl(2,C), defined in the sense of the 
	basic notion the commutator of two vector fileds in differential geometry.
	The value X[p] of X at p commutatorKAN[p][v1,v2]. The command\n\n
	commutatorKANoriginal[point_][vector1_,vector2_]:=Module[{\n
	\tcorrespondingMatrix=Sl2KANparam[point],inversematrix,\n
	\tcorrespondingsltwoCmatrix1,correspondingsltwoCmatrix2,comm},\n
	\tinversematrix=correspondingMatrix//Inverse;\n
	\tcorrespondingsltwoCmatrix1=inversematrix.Sl2KANparamDifferential[point][vector1];\n
	\tcorrespondingsltwoCmatrix2=inversematrix.Sl2KANparamDifferential[point][vector2];\n
	\tcomm=commutator[correspondingsltwoCmatrix1,correspondingsltwoCmatrix2];\n
	\tSl2KANparamDifferentialInvers[correspondingMatrix][correspondingMatrix.comm]//Simplify]\n\n
	transfers this idea into a Mathematica expression and returns the explicit formula by
	commutatorKANoriginal[{a,b,c}][{x1,y1,z1},{x2,y2,z2}].\n
	commutatorKAN[a,b,c][x1,y1,z1][x2,y2,z2] and commutatorKAN[a,b,c][v1,v2] are 
	the same but accepting different type of input.
	Numerical check:"
	
(*is written in conformity with this idea*)

commutatorKANoriginal::usage="An other version of commutatorKAN[p][v1,v2]."

varexplicitKANcan::usage="varexplicitKANcan[u1,u2,u3][a][z] is the linear combination\n
	u1[z]*vv1[a,b][z]+u2[z]*vv2[a,b][z]+u3[z]*vv3[a,b][z]\n
	of the three sl(2,C)-matrices vvi[a,b][z] (i=1,2,3) that represent the covariant
	derivatives of orders i=1,2,3 of the curve Sl2CFrameModified[a,b][z],
	for b[z]=bbcan[a][z] (see under ?bbcan), i.e., for the case of natural parametrization.
	and where u1[z],u2[z],u3[z] are arbitrary
	coefficient functions.\n
	We obtain the derivatives vvi with the help of the KAN-parametrization
	{x,y,z}-->Sl2KANparam[x,y,z] and retain the results under covDerVectorKAN1[a,b][z], 
	covDerVectorKAN2[a,b][z], covDerVectorKAN3[a,b][z] in this package.  We transform these 3-vectors
	into sl(2,C)-matrices by putting for i=1,2,3\n
	vvi[a_,b_][z_]=Sl2KANparamDifferential[sl2KAN[z]][covDerVectorKANi[a,b][z]],\n
	where sl2KAN[z_]=Sl2KANparamInvers[Sl2CFrameModified[a,b][z]][[1]] and
	replace finally b[z] by the function bbcan[a][z] that makes the parameter of the curve
	Sl2CFrameModified[a,b][z] the natural one.";

varexplicitNullKANcan::usage="varexplicitNullKANcan[u2,u3][a][z] is
	varexplicitKAN[(u2[#]^2+cmcStudy[#]*u3[#]^2)/(2*u3[#])&,u2,u3][a][z], 
	where cmcStudy[z] is a symbolic function that stands for cmcKappaKAN[a, bbcan[a]][z]. 
	It is the special case z-->varexplicitKANcan[uNull1,u2,u3][a][z], where 
	uNull1[z_]= (u2[z]^2+cmcStudy[z]*u3[z]^2)/(2*u3[z]) is obtained by solving
	Det[varexplicitKANcan[u1,u2,u3][a][z]]==0 for u1[z], i.e., i.e., the case of
	u1,u2,u3 in which varexplicitKAN[u1,u2,u3][a][z] becomes a null matrix 
	(nilpotent, determinant=0) of sl(2,C). 
	Observe that  L=varexplicitKANcan[u1,u2,u3][a][z]//Det equals L=-u2[z]^2+2*u1[z]*u3[z]-
	cmcKappaKAN[a,bbcan[a]][z]*u3[z]^2. Therefore, solving L=0 for u1[z] and inserting
	the resulting expression for u1[z] in varexplicitKANcan[u1,u2,u3][a][z]gives a 
	null matrix of sl(2,C)."


canKANFunctionG::usage="g[z_]=canKANFunctionG[u2,u3][a][z] and 
	om[z_]=canKANFunctionOmega[u2,u3][a][z] are the two functions such that\n
	varexplicitNullKANcan[u2,u3][a][z]==nilpotentsl2MatrixBasic[g,om][z]"
	
(*A simpler expression of canKANFunctionG[u2,u3][a][z] is obtained by applying 
	the additional command 'FullSimplify'.*)

canKANFunctionOmega::usage="See canKANFunctionG[u2,u3][a][z]."

cmcKappaRulecan::usage="cmcKappaRulecan[n][a,cmcCur][z] is a list of rules that
	replaces all derivatives of orders 3 to n of a[z] occuring in the expression
	'term' by the derivatives of orders up to n of the function obtained by solving\n
	cmcCur[z]^2==cmcKappaKAN[a,bbcan[a]][z] for a'''[z]."

cmcKappaRule::usage="cmcKappaRule[n][a,b,cmcCur][z] is a list of rules that replaces
	all derivatives of orders 3 to n of a[z] occuring in an expression 'term' by
	the derivatives of orders up to n of the function obtained by solving\n
	cmcCur[z]^2==cmcKappaKAN[a,b][z] for a'''[z]."

cmcCPPRule::usage="cmcCPPRule[a,b,CPP][z] is a list of rules that replaces all
	derivatives of orders 2 to 8 of a[z] occuring in an expression'term' by
	the derivatives of orders up to 6 of the function CPP[z] obtained by solving\n
	Solve[cmcCPPKANa,b][z]==CPP[z],D[a[z],z,z]][[1]] for a''[z]."

tocmcKappacan::usage="tocmcKappacan[a,curv][term][z] replaces all derivatives D[a[z],{z,i}]
	of a[z] of orders i>2 occuring in the expression 'term' by the derivatives of
	orders up to n of the expression obtained by solving\n
	cmcCur[z]==cmcKappaKAN[a,bbcan[a]][z] for a'''[z]. The result will contain only
	a[z], a'[z], a''[z] and derivatives of the function curv[z], that symbolizes
	the differential invariant cmcKappaKAN[a,bbcan[a]][z] (CMC Study parameter ) of a
	null curve in natural parametrization. If a[z], a'[z], a''[z] do not occur, 'term'
	is a differential invariant of the given curve and the return 
	tocmcKappacan[a,curv][term] shows it's expression in terms of the CMC Study parameter."

tocmcKappa::usage="tocmcKappa[a,b,curv][term][z] replaces all derivatives D[a[z],{z,i}]
	of a[z] of orders i>2 occuring in the expression 'term' by the corresponding
	derivatives of the function obtained by solving cmcCur[z]^2==cmcKappaKAN[a,b][z]
	for a'''[z]. tocmcKappa[a,b,curv,CPP][term][z] is similar, but tries also to substitute
	the derivatives by the natural parameter using cmcCPPRule[a,b,CPP][z]."

	
wurzelausdruck::usage="wurzelausdruck[a,b][z] is a complicated expression occuring as
	solution of the equation\n
	Solve[cmcKappaKAN[a,b][z]==cmcCur[z]^2,D[a[z],{z,3}]][[2]]\n
	for a'''[z]."

determineOrder::usage="determineOrder[term] looks in term for all derivatives with
	respect to the first variable x of any function f[x,y,...] of arbitrary number
	of variables occurring in 'term' and returns the maximum of the orders of these
	derivatives. (Still this command needs a refinement that permits to consider only
	derivatives of a fixed given function f.)"

determineOrderBasic::usage="determineOrderBasic[term] looks in 'term' for all
	partial derivatives of all functions f[x,y,...] of arbitrary number of variables
	occurring in 'term' and returns the maximum of the orders of the derivatives
	with respect to the first variable x."

onBasisofsl2C::usage="onBasisofsl2C is a tripel {f1,f2,f3} of matrices
	of sl(2,C) that are orthonormal with respect to the nondegenerate
	bilinear Form  killingFormSl2C[.,.]. The appropriate command that 
	verifies this assertion is:
	Table[killingFormSl2C[onBasisofsl2C[[i]],onBasisofsl2C[[j]]]/8,{i,3},{j,3}]";
	
	
killingFormSl2C::usage="killingFormSl2C[x,y]=4*(2*x11*y11+x21*y12+x12*y21)//Simplify
	is the Killing form of two tracefree matrices x={{x11,x12},{x21,-x11}} and 
	y={{y11,y12},{y21,-y11}}.";

killingFormofGln::usage="{matrixA,matrixB} --> killingFormofGln[matrixA,matrixB]
	gives the killing form of the lie algebra gl(n,K of the full linear group
	Gl(n,K), where K can be the field of real or of complex numbers.";

allgemeinematrix::usage="allgemeinematrix[a_,n_]:=Table[ToExpression[
	StringJoin[ToString[a],ToString[i],ToString[j]]],{i,n},{j,n}]
	is the matrix {{a11,...,a1n},{a21,...,a2n},...,{an1,...,ann}}."

orthonormierungGln::usage="orthonormierungGln[k][listOfquadraticMatrices] returnes a
	list of length k of quadratic matrices that are orthonormal with respect to
	the Killing form of gl(n,R) (resp. gl(n,C)) and that are produced by a version
	of the orthonormalization procedure that applies to the first k square matrices
	of 'listOfquadraticMatrices' using the symmetric bilinear form
	{a,b} --> killingFormofGln[a,b], a,b matrices of gl(n,R), (resp. gl(n,C)), as
	'scalar product'. If the matrices of 'listOfquadraticMatrices' are not linearly
	independent, the resulting list will contain a certain number of matrices with
	Killing-length 0. The matrix of all 'scalar products' of all pairs from the
	resulting list of matrices will be a diagonal matrix whose entries on the diagonal
	are -1, 0, +1. orthonormierungGln[listOfquadraticMatrices] is the same, but processes
	the whole list.";

normierungGln::usage="normierungGln[matrix]:=Module[{nn=killingFormofGln[matrix,matrix]},
	If[nn==0,1,vv/Sqrt[nn]]] produces a square matrix 'm' of length 
	killingFormofGln[m,m]=-1, 0, or +1, according to the sign of killingFormofGln[matrix,matrix]."

onBasisofGln::usage="onBasisofGln[n]is  the result of orthonormierungGln[standardBasis],
	where 'standardBasis' is the basis of gl(n,R) (resp. gl(n,C)), constructed
	for instance by the Mathematica - command\n
	standardBasis[n_]=(null=Table[0,{n},{n}];\ntemp=Table[null,{n},{n}];
	Do[temp[[i,j,i,j]]=1,{i,n},{j,n}];temp);\n
	It is a sequence of n^2  square matrices that are orthonormal with respect to
	'killingFormofGln'."

matrixofkillingFormofGln::usage="matrixofkillingFormofGln gives the matrix of the killing
	form of the lie algebra gl(n,K of the full linear group Gl(n,K), where K can be the
	field of real or of complex numbers, with respect to the ordinary basis 
	eij = the matrix with all entries null except that of index i,j.";

(*xx::usage="xx:={{x11,x12},{x21,-x11}} is a general matrix of the Lie-algebra sl(2,C)"
yy::usage="yy:={{y11,y12},{y21,-y11}} is a general matrix of the Lie-algebra sl(2,C)"
ad::usage="ad[m][n] is the adjoint representation of the Lie-algebra sl(2,C) on itself."*)

adXadYvonMatrix::usage="adXadYvonMatrix[basis][x,y,matrix] is the list {a,b,c}
	of the three coefficients a,b,c of ad[x][ad[y][matrix]] with respect to a given 
	basis 'basis'. Type for instance 
		check=adXadYvonMatrix[onBasisofsl2C][xx,yy,e1];
	Inner[Times,check,onBasisofsl2C,Plus]-ad[xx][ad[yy][e1]]//Simplify"

invariantmetricKAN::usage="invariantmetricKAN[aa][tt][ss] is the local expression of
	the invariant complex Riemannian metrik of Sl(2,C) defined by its Killing form in terms of 
	the coordinate system 
	aa={a,b,c}\in C^3 -->Sl2KANparam[a,b,c]. 
	tt and ss must be lists of complex numbers or functions of length 3 
	that represent their coordinates with respect to this coordinate system. 
	The final short form of the command was computed with 

invariantmetricKAN[aa_][tt_][ss_]:=Module[{
	tvec=(D[Sl2KANparam[aa+t*tt],t]/.t->0)//Simplify,
	svec=(D[Sl2KANparam[aa+t*ss],t]/.t->0)//Simplify,
	point=Sl2KANparam[aa],tx,sx},
	tx=Simplify[Inverse[point].tvec];sx=Simplify[Inverse[point].svec];
	killingFormSl2C[tx,sx]/8//Simplify]"	
	
invariantmetricTensorKAN::usage="invariantmetricTensorKAN[a,b,c] is the complex symmetric
	3x3-matrix that represents the complex Riemannian metric 
	invariantmetricKAN[{a,b,c}][vec1][vec2] on Sl(2,C). invariantmetricTensorKAN[p] is the
	same but expects a point p={a,b,c} as input."

gammaKANcollection::usage="gammaKANcollection[i][a,b,c]:={
	{gammaKAN[i,1,1][a,b,c],gammaKAN[i,2,1][a,b,c],gammaKAN[i,3,1][a,b,c]},\n
	{gammaKAN[i,1,2][a,b,c],gammaKAN[i,2,2][a,b,c],gammaKAN[i,3,2][a,b,c]},\n
	{gammaKAN[i,1,3][a,b,c],gammaKAN[i,2,3][a,b,c],gammaKAN[i,3,3][a,b,c]}},\
	is a collection of Christoffel symbols of the metric metrischerTensorKAN[a,b,c].\n
	gammaKANcollection[a,b,c] is the collection\n
	{gammaKANcollection[1],gammaKANcollection[2],gammaKANcollection[3]}\n
	of all Christoffel symbols."



gammaKAN::usage="gammaKAN[k,j,i][a,b,c] (1<= i,j,k <=3 and a,b,c \in C) are the
	Christoffel sympbols for the invariant complex Riemannian metrik on Sl(2,C) 
	defined by 1/8-th of the killing form of sl(2,C). The command works also for 
	numeric arguments as for instance in gammaKAN[1,2,3][3,I,Pi].
	To get the whole set of gamma's at a time type 'gammaKANcollection'."


covDerivativeKAN::usage="covDerivativeKAN[xx,yy][point] is the covariant derivative
	of two vector fields xx and yy on Sl(2,C) with respect to the Levi-Civita connection
	of the complex Riemannian metric invariantmetricKAN[point]. It is assumed that 
	point={a,b,c} is a triple of complex numbers representing the coordinate system 
	{a,b,c}\in C^3 --> Sl2KANparam[a,b,c] \in Sl(2,C)
	and that xx={x1[a,b,c],x2[a,b,c],x3[a,b,c]} and yy={y1[a,b,c],y2[a,b,c],y3[a,b,c]} 
	are given as triples of functions whose elements represent the coefficients of xx 
	(resp. yy) with respect to the basis formed by the tangent vectors to the 
	coordinate lines of {a,b,c}-->Sl2KANparam[a,b,c]."

christoffelSymbols::usage="christoffelSymbols[i,j,k][metrictensor][point]
	computes the Christoffel symbols of a metric tensor 'metrictensor' given as a 
	symmetric n x n-matrix of functions of n-variables point={x1,...,xn}. 
	No checks of symmetry, positivity, nondegeneracy, or matching of dimensions are provided.
	2 Examples:\n
	mmm[a_,b_]:={{a,b^2},{b^2,-a}}
	mmm[vvv_]:=mmm[vvv[[1]],vvv[[2]]]
	Table[christoffelSymbols[1,j,k][mmm][{a,b}],{i,2},{j,2},{k,2}]\n

	n=3;\n
	mm[x_]:=Table[x[[i]]*x[[j]],{i,n},{j,n}]-IdentityMatrix[3]*(Plus@@x)
	mm[{a,b,c}]-Transpose[mm[{a,b,c}]]
	Table[christoffelSymbols[1,j,k][n][mm][{a,b,c}],{i,n},{j,n},{k,n}]//Simplify"

covDerofVectorfieldKANalongCurve::usage="covDerofVectorfieldKANalongCurve[gamma,vec][z]
	gives the coordinate expression with respect to of the covariant derivative of a
	vector field vec[z] defined along a curve gamma[z]  with respect to the parametrization
	{a,b,c} --> Sl2KANparam[a, b, c] of Sl(2,C) and the conformal structure 
	invariantmetricKAN[a,b,c]. The curve gamma[z] and the vectorfield vec[z] must be given 
	in terms of these these coordinates as well, i.e., must be triples
	gamma[z_]={x1[z],x2[z],x3[z]} (resp. vec[z]={v1[z],v2[z],v3[z]} of functions 
	of a complex parameter z."

highercovDerKANofCurve::usage="highercovDerKANofCurve[n][gamma][t] gives
	the vector field of the n-th covariant derivative of the tangent vector field
	of a curve gamma[t] in Sl(2,C) with respect to the invariant metric invariantmetricKAN[a,b,c]."

(************** Sl2MatrixEXP parametrization and related stuff *******************)


brCPP::usage="brCPP[g,om][z] is the derivative of the length of the second order
	tangent vector of the null curve Sl2CFrameBR[g,om][z]. An analogue of the natural
	parameter of a minimal curve in C^2."

brKappa::usage="brKappa[g,om][z] is the derivative of the length of the third
	tangent vector of the null curve Sl2CFrameBR[g,om][z]. An analogue of the
	Study parameter (also called minimal curvature) of a minimal curve in C^2."

tangentVectorKAN1::usage="tangentVectorKAN1[a11,a12,a21,a22][g,om][z] is the tangent
	vector of the null curve FF[z_]=Sl2CFrameBR[g,om][z]. Since FF[z] can not be expressed
	explicitely by g[z] and om[z] the unknown entries aij[z] of FF[z] enter into the expression. 
	When forming derivatives or scalarproducts one can use the command toBryantframeData to
	eliminate the aij[z] and their derivatives as far as possible.";

tangentVectorKAN2::usage="tangentVectorKAN2[a11,a12,a21,a22][g,om][z] is the second
	tangent vector of the null curve FF[z_]=Sl2CFrameBR[g,om][z]. Since FF[z] can not
	be expressed explicitely by g[z] and om[z] the unknown entries aij[z] of FF[z] enter
	into the expression. When forming derivatives or scalarproducts one can use the command
	toBryantframeData to eliminate the aij[z] and their derivatives as far as possible.";

tangentVectorKAN3::usage="tangentVectorKAN3[a11,a12,a21,a22][g,om][z] is the third
	tangent vector of the null curve FF[z_]=Sl2CFrameBR[g,om][z]. Since FF[z] can not
	be expressed explicitely by g[z] and om[z] the unknown entries aij[z] of FF[z] enter
	into the expression. When forming derivatives or scalarproducts one can use the command
	toBryantframeData to eliminate the aij[z] and their derivatives as far as possible.";

Sl2MatrixEXPparam::usage="Sl2MatrixEXPparam[r,u,v] is a parametrization of
	Sl(2,C) obtained by introducing (with respect the orthogonal frame `onBasisofsl2C')
	3-dimensional polar coordinates {r Cos[u] Cos[v], r Cos[v] Sin[u], r Sin[v]} in the
	Lie-algebra sl(2,C) and then applying the matrix exponential. All together,
	Sl2MatrixEXPparam is
	{r,u,v} -> X=r*Cos[u]*Cos[v]*e1+r*Cos[v]*Sin[u]*e2+r*Sin[v]*e3-->MatrixExp[X].
	A special feature of this command: The metric tensor has diagonal form
	- type invariantmetricTensorMatrixEXP[{r,u,v}]//MatrixForm"

Sl2MatrixEXPparamInvers::usage="w\in Sl(2.C)-->Sl2MatrixEXPparamInvers[w]
	is the inverse map to {r,u,v}->Sl2MatrixEXPparam[r,u,v]."

Sl2MatrixEXPparamInvers1::usage="w\in Sl(2.C)-->Sl2MatrixEXPparamInvers1[w]
	is the first coordinate (radius) of Sl2MatrixEXPparamInvers[w]."

Sl2MatrixEXPparamInvers2::usage="w\in Sl(2.C)-->Sl2MatrixEXPparamInvers2[w]
	is the second coordinate  (azimute??) of Sl2MatrixEXPparamInvers[w]."

Sl2MatrixEXPparamInvers3::usage="w\in Sl(2.C)-->Sl2MatrixEXPparamInvers3[w]
	is the third coordinate of Sl2MatrixEXPparamInvers[w]."

invariantmetricMatrixEXP::usage="invariantmetricMatrixEXP[aa][tt][ss]is the local expression of
	the invariant complex Riemannian metrik of Sl(2,C) defined by its Killing form in terms
	of the coordinate system  aa={a,b,c}\\in C^3 -->Sl2MatrixEXPparam[a,b,c].
	tt and ss must be lists of complex numbers or functions of length 3  that
	represent their coordinates with respect to this coordinate system. The final short form
	of the command was computed with
	tvec=(D[Sl2MatrixEXPparam[aa+t*tt],t]/.t->0)//Simplify
	svec=(D[Sl2MatrixEXPparam[aa+t*ss],t]/.t->0)//Simplify
	point=Sl2MatrixEXPparam[aa]
	tx=Simplify[Inverse[point].tvec]
	sx=Simplify[Inverse[point].svec]
	invariantmetricMatrixEXPxxx=killingFormSl2C[tx,sx]/8//Simplify"


invariantmetricTensorMatrixEXP::usage="invariantmetricTensorMatrixEXP[{r,u,v}] is the complex
	symmetric 3x3-matrix that represents the complex Riemannian metric
	invariantmetricMatrixEXP[{a,b,c}][vec1][vec2] on Sl(2,C).
	invariantmetricTensorMatrixEXP[r,u,v] is the same but expects a point p={r,u,v} as
	input. Note that this matrix has diagonal form and that it's Christoffelsymbols can
	be computed with christoffelSymbols[i, j, k][invariantmetricTensorMatrixEXP][{r, u, v}].
	To get a survey on them type
	Table[christoffelSymbols[1,j,k][invariantmetricTensorMatrixEXP][{r,u,v}],{j,3},{k,3}]//TableForm
	Table[christoffelSymbols[2,j,k][invariantmetricTensorMatrixEXP][{r,u,v}],{j,3},{k,3}]//TableForm
	Table[christoffelSymbols[3,j,k][invariantmetricTensorMatrixEXP][{r,u,v}],{j,3},{k,3}]//TableForm"

gammaMatrixEXP::usage="gammaMatrixEXP[i_,j_,k_][point_]:=
	christoffelSymbols[i,j,k][invariantmetricTensorMatrixEXP][{r,u,v}] are the Christoffel
	symbols of the invariant complex metric of Sl(2,C) in the coordinate system
	point={r,u,v}-->Sl2MatrixEXPparam[point]. gammaMatrixEXP[i,j,k][r,u,v] is the same,
	expecting the coordinates r,u,v as separate variables."


covDerofVectorfieldMatrixEXPalongCurve::usage="covDerofVectorfieldKANalongCurve[gamma,vec][t]
	gives the covariant derivative of a vector field yy defined along a curve gamma[t] in
	Sl(2,C)with respect to the invariant metric invariantmetricMatrixEXP[a,b,c]. The curve gamma[z]
	and the vectorfield vec[z] must be defined as triples gamma[z_]={x1[z],x2[z],x3[z]}
	(resp. vec[z]={v1[z],v2[z],v3[z]} of functions of a complex parameter z.";

invariantmetricMatrixEXP::usage="covDerivativeMatrixEXP[xx,yy][point] is the covariant derivative of
	two vector fields xx and yy on Sl(2,C) with respect to the Levi-Civita connection of
	the complex Riemannian metric invariantmetricMatrixEXP[point]. It is assumed that
	point={a,b,c} is a triple of complex numbers representing the coordinate system
	{a,b,c}\in C^3 --> Sl2MatrixEXPParametrisierung[a,b,c] \in Sl(2,C) and that
	xx={x1[a,b,c],x2[a,b,c],x3[a,b,c]} and yy={y1[a,b,c],y2[a,b,c],y3[a,b,c]}
	are given as triples of functions whose elements represent the coefficients of xx
	(resp. yy) with respect to the basis formed by the tangent vectors to the
	coordinate lines of {a,b,c} --> Sl2MatrixEXPParametrisierung[a,b,c].";

highercovDerMatrixEXPofCurve::usage="highercovDerMatrixEXPofCurve[n][gamma][t] gives the vector field
	of the n-th covariant derivative of the tangent vector field of a curve gamma[t]
	in Sl(2,C) with respect to the invariant metric invariantmetricMatrixEXP[a,b,c]."



(************** Gebrauchsanweisungen - Ende *******************)



Begin["`Private`"]

BianchiCaloSmallDouble[f_,g_][z_]:=
	Sl2CFrameBianchiCaloSmall[f][z].Inverse[Sl2CFrameBianchiCaloSmall[g][z]]//Simplify

ballmodelPlot[nullcurve_][u0_,u1_,v0_,v1_,pu_,pv_,options___]:=Module[{
	du=(u1-u0)/pu,dv=(v1-v0)/pv,p,h,g},
	p=Table[(h=Chop[N[nullcurve[u0+i*du+I*(v0+j*dv)]]];
		g=Chop[hermitean2by2ToLorentz[h.Conjugate[Transpose[h]]]];
		lorentzmodelToBallmodel[g]),{i,0,pu},{j,0,pv}];
	h=Table[Graphics3D[
		Polygon[{p[[i,j]],p[[i+1,j]],p[[i+1,j+1]],p[[i,j+1]]}]],
		{i,1,pu},{j,1,pv}]//Flatten;
	Show[h,options]];

ballmodelPlotPolar[nullcurve_][u0_,u1_,v0_,v1_,pu_,pv_,options___]:=Module[{
	du=(u1-u0)/pu,dv=(v1-v0)/pv,p,h,g},
	p=Table[(h=Chop[N[nullcurve[(u0+i*du)*Exp[I*(v0+j*dv)]]]];
		g=Chop[hermitean2by2ToLorentz[h.Conjugate[Transpose[h]]]];
		lorentzmodelToBallmodel[g]),{i,0,pu},{j,0,pv}];
	h=Table[Graphics3D[
		Polygon[{p[[i,j]],p[[i+1,j]],p[[i+1,j+1]],p[[i,j+1]]}]],
		{i,1,pu},{j,1,pv}]//Flatten;
	Show[h,options]];

upperHalfspacePlot[nullcurve_][u0_,u1_,v0_,v1_,pu_,pv_,options___]:=Module[{
	du=(u1-u0)/pu,dv=(v1-v0)/pv,p,h,g},
	p=Table[(h=Chop[N[nullcurve[u0+i*du+I*(v0+j*dv)]]];
		g=Chop[hermitean2by2ToLorentz[h.Conjugate[Transpose[h]]]];
		lorentzmodelToUpperhalfSpace[g]),{i,0,pu},{j,0,pv}];
	h=Table[Graphics3D[
		Polygon[{p[[i,j]],p[[i+1,j]],p[[i+1,j+1]],p[[i,j+1]]}]],
	{i,1,pu},{j,1,pv}]//Flatten;
	Show[h,options]];

upperHalfspacePlotPolar[nullcurve_][u0_,u1_,v0_,v1_,pu_,pv_,options___]:=Module[{
	du=(u1-u0)/pu,dv=(v1-v0)/pv,p,h,g},
	p=Table[(h=Chop[N[nullcurve[(u0+i*du)*Exp[I*(v0+j*dv)]]]];
		g=Chop[hermitean2by2ToLorentz[h.Conjugate[Transpose[h]]]];
		lorentzmodelToUpperhalfSpace[g]),{i,0,pu},{j,0,pv}];
	h=Table[Graphics3D[
		Polygon[{p[[i,j]],p[[i+1,j]],p[[i+1,j+1]],p[[i,j+1]]}]],
	{i,1,pu},{j,1,pv}]//Flatten;
	Show[h,options]];
	
meromorphicBRToExactForms[0][f_,h_][z_]:=D[f[z],z]^2*h[z]

meromorphicBRToExactForms[n_Integer][f_,h_][z_]:=Simplify[
	D[meromorphicBRToExactForms[n-1][f,h][z]/D[f[z],z],z]]/;n>0

meromorphicBRIntegralDirect[n_,k_][f_,h_][z_]:=
	Sum[meromorphicBRToExactForms[j+n-k-1][f,h][z]*
	Factorial[k]/Factorial[j]*
	f[z]^j*(-1)^(k-j)/D[f[z],z],{j,0,k}]/;n>k

meromorphicBRIntegral[n_Integer,0][f_,h_][z_]:=
	meromorphicBRToExactForms[n-1][f,h][z]/D[f[z],z]

meromorphicBRIntegral[n_Integer,k_Integer][f_,h_][z_]:=Simplify[
	f[z]^k*meromorphicBRToExactForms[n-1][f,h][z]/D[f[z],z]-
	k*meromorphicBRIntegral[n-1,k-1][f,h][z]]/;n>k

meroBRInversDirect[0][f_,form_][z_]:=form[z]/D[f[z],z]^2;

meroBRInversDirect[n_Integer][f_,form_][z_]:=Expand[(Plus@@Table[f[z]^(n-1-i)*
	Integrate[form[z]*(-f[z])^(i)*Binomial[n-1,i],z],{i,0,n-1}])/(D[f[z],z]*
	Factorial[n-1])]/;n>0;

meroBRInversDirectwithConstants[n_Integer][f_,form_][z_]:=
	meroBRInversDirect[n][f,form][z]+(f[z]^(Range[n]-1)/D[f[z],z]).Table[C[i-1],{i,n}]

meroBRInverswithConstants[n_Integer][f_,form_][z_]:=
	meroBRInvers[n][f,form][z]+(f[z]^(Range[n]-1)/D[f[z],z]).Table[C[i-1],{i,n}]

(* the commands 'int', 'partintBR' and 'miBR' are needed for the definition of
MeroInvers.*)

intBR/:intBR[f_/(n_?IntegerQ),z]:=intBR[f,z]/n
intBR[a_+b_,z]:=intBR[a,z]+intBR[b,z]
intBR[-a_,z]:=-intBR[a,z]

partintBR[f_,term_][z_]:={intBR[xxx_./2,z]->intBR[xxx,z]/2,
	intBR[f[z]^k_*(a_+b_),z]->intBR[f[z]^k*a,z]+intBR[f[z]^k*b,z],
	intBR[intBR[term[z],z]*D[f[z],z],z]->
	f[z]*intBR[term[z],z]-intBR[term[z]*f[z],z],
	intBR[f[z]*intBR[term[z],z]*D[f[z],z],z]->
		f[z]^2*intBR[term[z],z]/2-intBR[term[z]*f[z]^2/2,z],
	intBR[Power[f[z],k_Integer]*intBR[term[z],z]*D[f[z],z],z]->
		(f[z]^(k+1)*intBR[term[z],z]-intBR[term[z]*f[z]^(k+1),z])/(k+1)}

miBR[0][f_,form_][z_]:=form[z]/D[f[z],z]^2

miBR[n_Integr][f_,form_][z_]:=Module[{fo=D[f[#],#]*intBR[form[#],#]&,temp},
	temp=miBR[n-1][f,fo][z]//Expand;
	fo=(temp//.partintBR[f,form][z])//Expand]

meroBRInvers[n_Integer][f_,form_][z_]:=If[n>49||n<0,
	Print[Bad order n. Choose n so that 0 <= n < 50.],
		miBR[n][f,form][z]//.intBR->Integrate]
(*Test:
nn=19;miBR[nn][f,r][z]
hh[z_]=MeroInvers[nn][f,r][z]
MeromorphicToExactForms[nn][f,hh][z]*)

Sl2CFrameMeromorphic[n_Integer,k_Integer][f_,h_][z_]:=Module[{int,aa,bb},
	If[n>k+1&&k>0,
		(int=meromorphicBRIntegral[n,k-1][f,h][z];
		aa=meromorphicBRIntegral[n,k][f,h][z];
		bb=meromorphicBRIntegral[n,k+1][f,h][z];
		{{-1,-bb},{int,bb*int-aa^2}}/aa//Simplify),
	Print["The integers n and k do not satisfy n>k+1 and k>0."]]]

Sl2CFrameMeromorphic[f_,h_][z_]:=Sl2CFrameMeromorphic[3,1][f,h][z]//Simplify;

Sl2CFrameMeromorphicInvers1[n_,k_][MATRIX_][z_]:=Module[{d=Det[MATRIX[z]]//Simplify,aa,bb},
	If[d==1&&n>k+1&&k>0,(aa=-1/MATRIX[z][[1,1]]//Simplify;
		bb=-MATRIX[z][[1,2]]*aa//Simplify;D[bb,z]/D[aa,z]//Simplify),
		Print["Matrix is not an Sl(2,C)-matrix or the condition\n
			n>k+1 and k>0 is not satisfied."],
			Print["Can not decide whether the matrix has determinant 1."]]]

Sl2CFrameMeromorphicInvers1[MATRIX_][z_]:=Sl2CFrameMeromorphicInvers1[3,1][MATRIX][z]//Simplify;

Sl2CFrameMeromorphicInvers2[n_,k_][MATRIX_][z_]:=Module[{
	ffun=Sl2CFrameMeromorphicInvers1[n,k][MATRIX][#]&,d=Det[MATRIX[z]]//Simplify,aa,ppn},
	If[d==1&&n>k+1&&k>0,
		(aa=-1/Part[MATRIX[#],1,1]&//Simplify;
		ppn=D[aa[#],#]/ffun[#]^k&//Simplify;
		meroBRInversDirect[n][ffun,ppn][z]),
			Print["Matrix[z] is not an Sl(2,C)-matrix or the condition\n
			n>k+1 and k>0 is not satisfied."],
     				Print["Can not decide whether the matrix has determinant 1." ]]]

Sl2CFrameMeromorphicInvers2[MATRIX_][z_]:=Sl2CFrameMeromorphicInvers2[3,1][MATRIX][z]//Simplify;

Sl2CFrameMeromorphicInverswithConstants1[n_,k_][MATRIX_][z_]:=Print["This command does not exist."]


Sl2CFrameMeromorphicInverswithConstants2[n_,k_][MATRIX_][z_]:=Module[{
	ffun=Sl2CFrameMeromorphicInvers1[n,k][MATRIX][#]&,d=Det[MATRIX[z]]//Simplify,aa,ppn},
	If[d==1&&n>k+1&&k>0,
		(aa=-1/Part[MATRIX[#],1,1]&//Simplify;
		ppn=D[aa[#],#]/ffun[#]^k&//Simplify;
		meroBRInversDirectwithConstants[n][ffun,ppn][z]),
			Print["Matrix[z] is not an Sl(2,C)-matrix or the condition\n
			n>k+1 and k>0 is not satisfied."],
     				Print["Can not decide whether the matrix has determinant 1." ]]]

Sl2CFrameMeromorphicInverswithConstants2[MATRIX_][z_]:=
	Sl2CFrameMeromorphicInverswithConstants2[3,1][MATRIX][z]//Simplify;

Sl2CFrameMeromorphicInverswithConstants[n_,k_][MATRIX_][z_]:=Module[{
	ffun=Sl2CFrameMeromorphicInvers1[n,k][MATRIX][#]&,d=Det[MATRIX[z]]//Simplify,aa,bb},
	If[d==1&&n>k+1&&k>0,
	(aa=-1/Part[MATRIX[#],1,1]&//Simplify;bb=-MATRIX[z][[1,2]]*aa[z]//Simplify;
	ppn=D[aa[#],#]/ffun[#]^k&//Simplify;
	{D[bb,z]/D[aa[z],z]//Simplify,meroBRInversDirectwithConstants[n][ffun,ppn][z]}),
		Print["Matrix[z] is not an Sl(2,C)-matrix or the condition\n
		n>k+1 and k>0 is not satisfied."],
			Print["Can not decide whether the matrix has determinant 1."]]]

Sl2CFrameMeromorphicInverswithConstants[MATRIX_][z_]:=
	Sl2CFrameMeromorphicInverswithConstants[3,1][MATRIX][z]//Simplify;

Sl2CFrameMeromorphicInvers[n_,k_][MATRIX_][z_]:=Module[{
	ffun=Sl2CFrameMeromorphicInvers1[n,k][MATRIX][#]&,d=Det[MATRIX[z]]//Simplify,aa,bb},
	If[d==1&&n>k+1&&k>0,
	(aa=-1/Part[MATRIX[#],1,1]&//Simplify;bb=-MATRIX[z][[1,2]]*aa[z]//Simplify;
	ppn=D[aa[#],#]/ffun[#]^k&//Simplify;
	{D[bb,z]/D[aa[z],z]//Simplify,meroBRInversDirect[n][ffun,ppn][z]}),
		Print["Matrix[z] is not an Sl(2,C)-matrix or the condition\n
		n>k+1 and k>0 is not satisfied."],
			Print["Can not decide whether the matrix has determinant 1."]]]

Sl2CFrameMeromorphicInvers[MATRIX_][z_]:=Sl2CFrameMeromorphicInvers[3,1][MATRIX][z]//Simplify;

Sl2CFrameMeromorphicToSl2CModified1[MATRIX_][z_]:=-1/Part[MATRIX[z],1,1]//Simplify

Sl2CFrameMeromorphicToSl2CModified2[MATRIX_][z_]:=
	-Part[MATRIX[z],1,2]/Part[MATRIX[z],1,1]//Simplify;

Sl2CFrameMeromorphicToSl2CModified[MATRIX_][z_]:=
	-{1,Part[MATRIX[z],1,2]}/Part[MATRIX[z],1,1]//Simplify

lorentzToHermitean2by2[x0_,x1_,x2_,x3_]:={{x0+x3,x1+I*x2},{x1-I*x2,x0-x3}};

lorentzToHermitean2by2[v_List]:=(lorentzToHermitean2by2@@v)//Simplify

hermitean2by2ToLorentz[a11_,a12_,a21_,a22_]:={a11+a22,a12+a21,I(a21-a12),a11-a22}/2//Simplify

hermitean2by2ToLorentz[m_]:=hermitean2by2ToLorentz[m[[1,1]],m[[1,2]],m[[2,1]],m[[2,2]]]

(*testhermitean2by2ToLorentz:=
	{hermitean2by2ToLorentz[lorentzToHermitean2by2[x0,x1,x2,x3]],
	lorentzToHermitean2by2[hermitean2by2ToLorentz[a11,a12,a21,a22]]}*)

adjointMatrix[m_]:=Module[{dim=Dimensions[m],z,x},n=Min[dim];z=Minors[m,n-1];
	x=Table[z[[i,j]]*(-1)^(i+j),{i,n},{j,n}];
	x//Reverse//Transpose//Reverse//Simplify]

QuaternionicMatrix[a_,b_,c_,d_]:={{a+I*b,c+I*d},{-c+I*d,a-I*b}}
	
commutator[x_List,y_List]:=x.y-y.x//Simplify
	
commutator[pair_]:=commutator[pair[[1]],pair[[2]]]

adjointRepresentation[0][x_][y_]:=y
	
adjointRepresentation[1][x_][y_]:=commutator[x,y]//Simplify

adjointRepresentation[n_Integer][x_][y_]:=commutator[x,adjointRepresentation[n-1][x][y]]
	
spur[m_List]:=Sum[m[[i,i]],{i,Length[m]}]//Simplify
	
QuaternionicMatrix[a_,b_,c_,d_]:={{a+I*b,c+I*d},{-c+I*d,a-I*b}}
	
Quaternions:={{{1,0},{0,1}},{{I,0},{0,-I}},{{0,1},{-1,0}},{{0,I},{I,0}},
	{{-1,0},{0,-1}},{{-I,0},{0,I}},{{0,-1},{1,0}},{{0,-I},{-I,0}}}

basicFunctionG[a_,b_][z_]:=-D[b[z],z]/D[a[z],z]
	
basicFunctionOmega[a_,b_][z_]:=Module[{p=D[a[z],z],q=D[b[z],z]},p^2/(b[z]*p-a[z]*q)]

basicFunctionGModified[u_,b_][z_]:=basicFunctionG[modifiedU[u],modifiedB[u,b]][z]//Simplify
	
basicFunctionOmegaModified[u_,b_][z_]:=basicFunctionOmega[modifiedU[u],modifiedB[u,b]][z]//Simplify


basicFunctionGMeromorphic[f_,h_][z_]:=Module[{f1,f2,zz,h1},
	f1=D[f[zz],zz];h1=D[h[zz],zz];f2=D[f1,zz];
	(f[z]*h1+h[z]*((f[z]*f2)/f1-2*f1)/.zz->z)//Simplify]

basicFunctionOmegaMeromorphic[f_,h_][z_]:=Module[{f1,f2,f3,f4,zz,h1,h2,h3,qqd,qqn,qq},
	f1=D[f[zz],zz];h1=D[h[zz],zz];f2=D[f1,zz];h2=D[h1,zz];f3=D[f2,zz];h3=D[h2,zz];f4=D[f3,zz];
	qqn=f1*f2*(3*f2*h1+4*f3*h[z])-f1^3*h3-f1^2*(2*f3*h1+h[z]*f4)-3*f2^3*h[z];
	qqd=f1^2*(f1*h1+f2*h[z])-f[z]*(f1*(f2*h1+f1*h2)+(-f2^2+f1*f3)*h[z]);
	qq=qqn*f1^2/qqd^2;
	(qq/.zz->z)//Simplify]
nilpotentsl2MatrixBasic[g_,omega_][z_]:=omega[z]*Transpose[{{g[z],1}}].{{1,-g[z]}}

nilpotentsl2MatrixBasic[vv_][z_]:=nilpotentsl2MatrixBasic[vv[#][[1]]&,vv[#][[2]]&][z]

nilpotentsl2Matrix[a_,b_][z_]:=nilpotentsl2MatrixBasic[basicFunctionG[a,b],
	basicFunctionOmega[a,b]][z]

nilpotentsl2MatrixModified[u_,b_][z_]:=nilpotentsl2Matrix[modifiedU[u],modifiedB[u,b]][z]//Simplify

modifiedU[u_][z_]:=-1/u[z];

modifiedB[u_,b_][z_]:=1*b[z]*modifiedU[u][z];

Sl2CFrame[a_,b_][z_]:=Module[{zeile1={a[z],b[z]},wronski,phiz,zz,temp},
	wronski=Det[{temp={a[zz],b[zz]},D[temp,zz]}];
	phiz=Integrate[-(D[a[zz],zz]/a[zz])^2/wronski,zz]/.zz->z;
	temp={zeile1,phiz*zeile1+{0,1/a[z]}}//Simplify];

Bryantframe[a_,b_][z_]:=Sl2CFrame[a,b][z]

BryantframeModified[a_,b_][z_]:=Sl2CFrameModified[a,b][z]

Sl2CFrameModified[u_,b_][z_]:=Sl2CFrame[modifiedU[u],modifiedB[u,b]][z]//Simplify

auxBianchiCaloSmall[f_,g_][z_]:=Module[{f1=D[f[zz],zz]/D[g[zz],zz],
	f2=D[f[zz],zz,zz]/D[g[zz],zz]^2,a11,a12,a21,a22},
	a22=(f1^(-1/2)+g[z]*f1^(-3/2)*f2/2);
	a11=Sqrt[f1]-f[z]*f1^(-3/2)*f2/2;
	a12=f[z]*a22-g[z]*Sqrt[f1];a21=-f1^(-3/2)*f2/2;
	({{a11,a12},{a21,a22}}//.zz->z)//Simplify]

Sl2CFrameBianchiCaloSmall[f_][z_]:=auxBianchiCaloSmall[f,#&][z]//Simplify

Sl2CFrameBianchiCaloSmall[f_,g_][z_]:=Sl2CFrameBianchiCaloSmall[f][g[z]]//Simplify

BianchiCaloSmallFrame[f_][z_]:=Sl2CFrameBianchiCaloSmall[f][z]

BianchiCaloSmallFrame[f_,g_][z_]:=Sl2CFrameBianchiCaloSmall[f,g][z]

Sl2CAction[m_][fun_,form_]:={(m[[1,1]]*fun+m[[1,2]])/(m[[2,1]]*fun+m[[2,2]]),
	(m[[2,1]]*fun+m[[2,2]])^2*form}

Sl2CAction[matrix_List][pair_List]:=Sl2CAction[matrix][pair[[1]],pair[[2]]]

Sl2CAction[a_,b_,c_,d_][pair_List]:=Sl2CAction[{{a,b},{c,d}}][pair[[1]],pair[[2]]]

Sl2CAction[a_,b_,c_,d_][x_,y_]:=Sl2CAction[{{a,b},{c,d}}][x,y]

Sl2Framerule[order_][a11_,a12_,a21_,a22_][g_,om_][z_]:=Module[{
		k,y,np=nilpotentsl2MatrixBasic[g,om][z],sl2={{a11[z],a12[z]},{a21[z],a22[z]}},
			ableitungen,bryantframebedingung},
		ableitungen=Union[Flatten[D[sl2,z]]];
		bryantframebedingung=Thread[Flatten[D[sl2,z]-sl2.np]=={0,0,0,0}];
		k=ableitungen//.Flatten[Solve[bryantframebedingung,ableitungen]];
		y=Table[Thread[D[ableitungen,{z,i}]->Simplify[D[k,{z,i}]]],{i,0,order}];
		Flatten[{y,Solve[Det[sl2]==1,a22[z]],
			Table[D[a22[z],{z,i}]->-D[a11[z],{z,i}],{i,0,order+1}]}]];

Sl2Framerule4:=Sl2Framerule[4][a11,a12,a21,a22][g,om][z];

toBryantframeData[n_][a11_,a12_,a21_,a22_][g_,om_][z_][x_]:=
		(x//.Sl2Framerule[n][a11,a12,a21,a22][g,om][z])//Simplify

nullcurveToBryantdata1[nullMatrix_][z_]:=
	-D[nullMatrix[z][[1,2]],z]/D[nullMatrix[z][[1,1]],z]//Simplify

nullcurveToBryantdata2[nullMatrix_][z_]:=D[nullMatrix[z][[1,1]],z]/
	(nullMatrix[z][[1,1]]*nullcurveToBryantdata1[nullMatrix][z]+nullMatrix[z][[1,2]])//Simplify

nullcurveToBryantdata[nullMatrix_][z_]:=Module[{
	xi=Inverse[nullMatrix[z]],xp=D[nullMatrix[z],z],om,g,determinante,qq},
	determinante=Det[Simplify[xi.xp]]//FullSimplify;
	qq:=(g=-xp[[1,2]]/xp[[1,1]]//Simplify;om=xp[[1,1]]/
		(g*nullMatrix[z][[1,1]]+nullMatrix[z][[1,2]])//Simplify;{g,om});
	If[TrueQ[determinante==0],qq,Print["The given matrix is not null."],
		(Print["Check whether the matrix is a null matrix."];qq)]]

nullcurveToModifiedData1[nullMatrix_][z_]:=-1/nullMatrix[z][[1,1]]//Simplify

nullcurveToModifiedData2[nullMatrix_][z_]:=nullMatrix[z][[1,2]]/nullMatrix[z][[1,1]]//Simplify

nullcurveToModifiedData[nullMatrix_][z_]:=Module[{
	xi=Inverse[nullMatrix[z]],xp=D[nullMatrix[z],z],om,g,determinante,qq},
	determinante=Det[Simplify[xi.xp]]//FullSimplify;
	qq:={-1,nullMatrix[z][[1,2]]}/nullMatrix[z][[1,1]]//Simplify;
	If[TrueQ[determinante==0],qq,Print["The given matrix is not null."],
		(Print["Check whether the matrix is a null matrix."];qq)]]

(************* konkrete Formeln für die graphischen Darstellungen in
				den verschiedenen Modellen. *******************)

hermitianTypeSurface[a_,b_][u_,v_]:=Module[{sl2frame=Sl2CFrame[a,b][u+I*v],imt},
	imt=sl2frame.Transpose[Conjugate[sl2frame]]//ComplexExpand//Simplify;
	imt//hyperbolicComplexExpand//Simplify]
	
hermitianTypeSurfaceModified[u_,b_][x_,y_]:=Module[{
	sl2frame=Sl2CFrameModified[u,b][x+I*y],imt},
	imt=sl2frame.Transpose[Conjugate[sl2frame]]//ComplexExpand//Simplify;
	imt//hyperbolicComplexExpand//Simplify]

lorentzmodelToBallmodel[x0_,x1_,x2_,x3_]:={x1,x2,x3}/(1+x0)//Simplify

lorentzmodelToBallmodel[v_]:=Drop[v,1]/(1+v[[1]])

ballmodelToLorentzmodel[y1_,y2_,y3_]:=Module[{x0=Simplify[y1^2+y2^2+y3^2-1]},
	{-(2+x0),-2y1,-2y2,-2y3}/x0//Simplify//Simplify]
	
ballmodelToLorentzmodel[v_]:=Module[{x0=Simplify[v.v-1]},
	Prepend[-2v,-(2+x0)]/x0//Simplify//Simplify]

upperhalfSpaceToBallmodel[vec_]:=ballmodelToUpperhalfSpace[vec]
(*ballmodelToUpperhalfSpace is self-inverse*)

upperhalfSpaceToLorentzmodel[v_]:=v//upperhalfSpaceToBallmodel//ballmodelToLorentzmodel//Simplify
lorentzmodelToUpperhalfSpace[v_]:=v//lorentzmodelToBallmodel//ballmodelToUpperhalfSpace//Simplify


ballmodelToUpperhalfSpace[v_]:=Module[{l=Length[v],en,y},en=Last[IdentityMatrix[l]];
	y=v+en;2y/(y.y)-en//Simplify]

ballmodelToUpperhalfSpace[x1_,x2_,x3_]:=ballmodelToUpperhalfSpace[{x1,x2,x3}]

lorentzianTypeSurface[a_,b_][u_,v_]:=
	Simplify[hermitean2by2ToLorentz[hermitianTypeSurface[a,b][u,v]]]

lorentzianTypeSurfaceModified[a_,b_][u_,v_]:=
	Simplify[hermitean2by2ToLorentz[hermitianTypeSurfaceModified[a,b][u,v]]]

ballmodelTypeSurface[a_,b_][u_,v_]:=
	Simplify[lorentzmodelToBallmodel[lorentzianTypeSurface[a,b][u,v]]]

ballmodelTypeSurfaceModified[a_,b_][u_,v_]:=Simplify[lorentzmodelToBallmodel[
	lorentzianTypeSurfaceModified[a,b][u,v]]]


hyperbolicOrthogonalProjection[x_List][a_List]:=Module[{
	ll=lorentzMetrik[a,a]//Simplify},If[ll==0,
	Print["The 2-nd vector a that gives the direction of the projection is isotropic."],
	x-lorentzMetrik[x,a]*a/ll//Simplify,
	x-lorentzMetrik[x,a]*a/ll//Simplify]]/;Length[x]==Length[a]==4

hyperbolicL[x_][u_,v_]:=Module[{normal=hyperbolicunitNormal[x][uu,vv],
	xuu=hyperbolicOrthogonalProjection[D[x[uu,vv],uu,uu]][x[uu,vv]]},
	(-lorentzMetrik[xuu,normal]/.{uu->u,vv->v})//Simplify]

hyperbolicM[x_][u_,v_]:=Module[{normal=hyperbolicunitNormal[x][uu,vv],
	xuv=hyperbolicOrthogonalProjection[D[x[uu,vv],uu,vv]][x[uu,vv]]},
	(-lorentzMetrik[xuv,normal]/.{uu->u,vv->v})//Simplify]

hyperbolicN[x_][u_,v_]:=Module[{normal=hyperbolicunitNormal[x][uu,vv],
	xvv=hyperbolicOrthogonalProjection[D[x[uu,vv],vv,vv]][x[uu,vv]]},
	(-lorentzMetrik[xvv,normal]/.{uu->u,vv->v})//Simplify]

hyperbolicsecondFFdirect[x_][u_,v_]:=Module[{
	normal=hyperbolicunitNormal[x][uu,vv],l,m,n,
	xuu=hyperbolicOrthogonalProjection[D[x[uu,vv],uu,uu]][x[uu,vv]],
	xuv=hyperbolicOrthogonalProjection[D[x[uu,vv],uu,vv]][x[uu,vv]],
	xvv=hyperbolicOrthogonalProjection[D[x[uu,vv],vv,vv]][x[uu,vv]]},
	l=lorentzMetrik[xuu,normal];m=lorentzMetrik[xuv,normal];
	n=lorentzMetrik[xvv,normal];({{l,m},{m,n}}/.{uu->u,vv->v})//Simplify]

hyperbolicsecondFF[x_][u_,v_]:=Module[{l=hyperbolicL[x][u,v],
	m=hyperbolicM[x][u,v],n=hyperbolicN[x][u,v]},{{l,m},{m,n}}//Simplify]

hyperbolicWeingartenmap[x_][u_,v_]:=
	-hyperbolicsecondFF[x][u,v].Inverse[hyperbolicfirstFF[x][u,v]]//Simplify

hyperbolicOrthogonalProjection[x0_,x1_,x2_,x3_][a0_,a1_,a2_,a3_]:=
	hyperbolicOrthogonalProjection[{x0,x1,x2,x3}][{a0,a1,a2,a3}]

hyperbolicLeviCivita[surface_,vectorfield_][vec_List][u_,v_]:=Module[{
	vu=D[vectorfield[uu,vv],uu]//Simplify,
	vv=D[vectorfield[uu,vv],vv]//Simplify,a=vec[[1]],b=vec[[2]]},
	(hyperbolicOrthogonalProjection[a*vu+b*vv][x[u,v]]/.{uu->u,vv->v})//Simplify]

hyperbolicMeancurvature[x_][u_,v_]:=spur[hyperbolicWeingartenmap[x][u,v]]/2//Simplify

hyperbolicGaussiancurvature[x_][u_,v_]:=hyperbolicWeingartenmap[x][u,v]//Det//Simplify

hyperbolicTangentVectorofH3[a_,b_,c_][x1_,x2_,x3_]:=
	{x1*Cosh[b]*Cosh[c]*Sinh[a]+x2*Cosh[c]*Sinh[b]+x3*Sinh[c],
	x1*Cosh[a]*Cosh[b]*Cosh[c],x2*Cosh[a]*Cosh[b]*Cosh[c],
	x3*Cosh[a]*Cosh[b]*Cosh[c]}

hyperbolicTangentVectorofH3[a_,b_,c_][vv_List]:=
	hyperbolicTangentVectorofH3[a,b,c][vv[[1]],vv[[2]],vv[[3]]]//Simplify

hyperbolicTangentVectorofH3Invers[a_,b_,c_][xx0_,xx1_,xx2_,xx3_]:=
	{xx1*Sech[a]*Sech[b]*Sech[c],xx2*Sech[a]*Sech[b]*Sech[c],xx3*Sech[a]*Sech[b]*Sech[c]}

hyperbolicTangentVectorofH3Invers[a_,b_,c_][vv_List]:=
	hyperbolicTangentVectorofH3Invers[a,b,c][vv[[1]],vv[[2]],vv[[3]],vv[[4]]]//Simplify

lorentzmetric=DiagonalMatrix[{-1,1,1,1}]

hyperbolicCross[v_List,w_List][point_List]:=
	Simplify[Reverse[Flatten[Minors[{v,w,point}.lorentzmetric,3]]]*{1,-1,1,-1}]

hyperbolicCrossX[v_List,w_List][point_List]:=Cross[v,w,point]*{1,-1,-1,-1}

hyperbolicCrosswithCheck[v_List,w_List][point_List]:=If[
	TrueQ[lorentzMetrik[v,point]==0&&lorentzMetrik[w,point]==0&&
	lorentzMetrik[point,point]==-1],
	hyperbolicCross[v,w][point],
	Print[
	"hyperbolicCross warning: One of the arguments v, w is not tangent
	to H^3 at 'point' or 'point' is not an element of H^3."]]


normalofH3[x0_,x1_,x2_,x3_]:={x0,x1,x2,x3}

normalofH3[vec_]:=normalofH3@@vec

hyperbolicE[x_][u_,v_]:=(lorentzMetrik[D[x[uu,vv],uu],D[x[uu,vv],uu]]/.{uu->u,vv->v})//Simplify;

hyperbolicF[x_][u_,v_]:=(lorentzMetrik[D[x[uu,vv],uu],D[x[uu,vv],vv]]/.{uu->u,vv->v})//Simplify;

hyperbolicG[x_][u_,v_]:=(lorentzMetrik[D[x[uu,vv],vv],D[x[uu,vv],vv]]/.{uu->u,vv->v})//Simplify;

hyperbolicfirstFF[x_][u_,v_]:=Module[{e=hyperbolicE[x][u,v],f=hyperbolicF[x][u,v],
	g=hyperbolicG[x][u,v]},{{e,f},{f,g}}]

hyperbolicL[x_][u_,v_]:=-(lorentzMetrik[D[x[uu,vv],uu,uu],
	hyperbolicunitNormal[x][uu,vv]]/.{uu->u,vv->v})//Simplify;

hyperbolicM[x_][u_,v_]:=-(lorentzMetrik[D[x[uu,vv],uu,vv],
	hyperbolicunitNormal[x][uu,vv]]/.{uu->u,vv->v})//Simplify;

hyperbolicN[x_][u_,v_]:=(-lorentzMetrik[D[x[uu,vv],vv,vv],
	hyperbolicunitNormal[x][uu,vv]]/.{uu->u,vv->v})//Simplify;

hyperbolicsecondFF[x_][u_,v_]:=Module[{nn=hyperbolicunitNormal[x][uu,vv],l,m,n},
	l=lorentzMetrik[D[x[uu,vv],uu,uu],nn];m=lorentzMetrik[D[x[uu,vv],uu,vv],nn];
	n=lorentzMetrik[D[x[uu,vv],vv,vv],nn];(-{{l,m},{m,n}}/.{uu->u,vv->v})//Simplify]

hyperbolicWeingartenmap[x_][u_,v_]:=
	-hyperbolicsecondFF[x][u,v].Inverse[hyperbolicfirstFF[x][u,v]]//Simplify

hyperbolicMeancurvature[x_][u_,v_]:=spur[hyperbolicWeingartenmap[x][u,v]]/2//Simplify

hyperbolicGaussiancurvature[x_][u_,v_]:=hyperbolicWeingartenmap[x][u,v]//Det//Simplify

hyperbolicSurfaceNormalVector[x_][u_,v_]:=Module[{xxu=D[x[u,v],u]//Simplify,
	xxv=D[x[u,v],v]//Simplify},
	Reverse[Flatten[Minors[{xxu,xxv,x[u,v]}.lorentzmetric,3]]]*{1,-1,1,-1}//Simplify]

hyperbolicSurfaceNormalVectorwithCheck[x_][u_,v_]:=(hyperbolicCrosswithCheck[
	D[x[uu,vv],uu],xv=D[x[uu,vv],vv]][x[uu,vv]]//.{uu->u,vv->v})//Simplify;

hyperbolicunitNormal[x_][u_,v_]:=Module[{
	n=hyperbolicSurfaceNormalVector[x][u,v]},n/lorentzLength[n]//Simplify];

lorentzMetrik[v_List,w_List]:=Simplify[w.(lorentzmetric.v)]/;Length[v]==Length[w]==4

lorentzLength[v_List]:=lorentzMetrik[v,v]//Simplify//Sqrt

llEukl[i_Integer?Positive,j_Integer?Positive][z_]:=Module[{y=IdentityMatrix[4]},
	y[[i,i]]=Cos[z];y[[j,j]]=y[[i,i]];y[[i,j]]=-Sin[z];y[[j,i]]=-y[[i,j]];y]/;j>i

llLoren[i_Integer?Positive,j_Integer?Positive][z_]:=Module[{y=IdentityMatrix[4]},
	y[[i,i]]=Cosh[z];y[[j,j]]=y[[i,i]];y[[i,j]]=Sinh[z];y[[j,i]]=y[[i,j]];y]/;j>i

lorentzGruppe[a_,b_,c_,d_,e_,f_]:=Module[{
	lorentzpart=llLoren[1,2][a].llLoren[1,3][b].llLoren[1,4][c],
	euclideanpart=llEukl[2,3][d].llEukl[2,4][e].llEukl[3,4][f]},lorentzpart.euclideanpart]

lorentzGruppe[vec_]:=lorentzGruppe@@vec

hyperbolicPolarCoords[a_,b_,c_]=lorentzGruppe[a,b,c,0,0,0].{1,0,0,0}//Simplify

hyperbolicPolarCoords[a,b,c]//lorentzToHermitean2by2//Det//Simplify

surfaceInhyperbolicPolarCoords[a_,b_,c_][u_,v_]:=hyperbolicPolarCoords[a[u,v],b[u,v],c[u,v]]

hyperbolicSurfaceNormalInhyperbolicPolarCoords[a_,b_,c_][u_,v_]:=Module[{
	au=Derivative[1,0][a][u,v],bu=Derivative[1,0][b][u,v],cu=Derivative[1,0][c][u,v],
	av=Derivative[0,1][a][u,v],bv=Derivative[0,1][b][u,v],cv=Derivative[0,1][c][u,v]},
	
	{(Cosh[c[u,v]]*(cv*(-(Cosh[a[u,v]]*Sinh[2*b[u,v]]*au)+2*Sinh[a[u,v]]*bu)+
	bv*(Cosh[a[u,v]]*Cosh[b[u,v]]^2*Sinh[2*c[u,v]]*au-2*Sinh[a[u,v]]*cu)+
	Cosh[a[u,v]]*av*(-(Cosh[b[u,v]]^2*Sinh[2*c[u,v]]*bu)+Sinh[2*b[u,v]]*cu)))/2,
	(Cosh[c[u,v]]*(cv*(-(Sinh[a[u,v]]*Sinh[2*b[u,v]]*au)+2*Cosh[a[u,v]]*bu)+
	bv*(Cosh[b[u,v]]^2*Sinh[a[u,v]]*Sinh[2*c[u,v]]*au-2*Cosh[a[u,v]]*cu)+
	Sinh[a[u,v]]*av*(-(Cosh[b[u,v]]^2*Sinh[2*c[u,v]]*bu)+Sinh[2*b[u,v]]*cu)))/2,
	Cosh[b[u,v]]*Cosh[c[u,v]]*(Cosh[c[u,v]]*Sinh[b[u,v]]*Sinh[c[u,v]]*bv*
	au-Cosh[b[u,v]]*cv*au+av*(-(Cosh[c[u,v]]*Sinh[b[u,v]]*Sinh[c[u,v]]*bu)+
	Cosh[b[u,v]]*cu)),
	Cosh[b[u,v]]*Cosh[c[u,v]]^3*(bv*au-av*bu)}]

(*************************** Technisches **************************)

hyperbolicComplexargumentrule:={
	Arg[z_]:>ArcTan[Simplify[ComplexExpand[Im[z]]/ComplexExpand[Re[z]]]],
	Abs[z_]:>Sqrt[Simplify[PowerExpand[ComplexExpand[Im[z]]^2+ComplexExpand[Re[z]]^2]]],
	Log[`x_^n_]:>n*Log[`x],ArcTan[Tan[y_]]:>y,ArcTan[Cot[y_]]:>Pi/2-y}

hyperbolicComplexExpand[term_]:=(term//.hyperbolicComplexargumentrule)//Simplify

hyperbolicadjointMatrix[m_List]:=Simplify[ComplexExpand[Transpose[Conjugate[m]]]]


(*************  Programme: KAN-Parametrisierung, inv. Metrik, kovariante Ableitung *******************)

cmcKappaKAN[a_,b_][z_]:=Module[{a1=D[a[zz],zz]//Simplify,b1=D[b[zz],zz]//Simplify,
	a2,a3,b2,b3},a2=D[a1,zz]//Simplify;b2=D[b1,zz]//Simplify;
	a3=D[a2,zz]//Simplify;b3=D[b2,zz]//Simplify;
	((-3*a1^4*b1*b2^2+6*a1^3*b2*(b1^2*a2+a[z]*b2^2-a[z]*b1*b3)+
	a[z]*b1^2*(b1*(6*a2^3+a[z]*a3^2)-2*a[z]*a2^2*b3)-2*a[z]*a1*
	b1*(3*b1^2*a2*a3-2*a[z]*a2*b2*b3+b1*(3*a2^2*b2+a[z]*a3*b3))+
	a1^2*(-3*b1^3*a2^2-2*a[z]^2*b2^2*b3+6*a[z]*b1^2*(b2*a3+a2*b3)+
	a[z]*b1*(-6*a2*b2^2+a[z]*b3^2)))/(a[z]^4*b1^3)/.zz->z)//Simplify]

cmcKappaKAN[p_][z_]:=cmcKappaKAN[p[#][[1]]&,p[#][[2]]&][z]

cmcCPPKAN[a_,b_][z_]:=((D[b[zz],zz]*D[a[zz],zz,zz]-
	D[a[zz],zz]*D[b[zz],zz,zz])/(a[z]*D[b[zz],zz])/.zz->z)//Simplify

cmcCPPKAN[p_][z_]:=cmcCPPKAN[p[#][[1]]&,p[#][[2]]&][z]

Sl2CFrameBR[g_,om_][z_]:=Module[{xx=nilpotentsl2MatrixBasic[g,om][z],
	a11,a12,a21,a22,ff,gl},
	ff={{a11[z],a12[z]},{a21[z],a22[z]}};
	gl=Thread[Flatten[D[ff,z]-ff.xx]==Table[0,{4}]]//FullSimplify;
	(ff/.Flatten[DSolve[gl,{a11,a12,a21,a22},z]])//Simplify]


bbcan[c1_,c2_][a_][z_]:=(c1+c2*Integrate[D[a[zz],zz]*
	E^(-Integrate[a[zz]/D[a[zz],zz],zz]),zz]/.zz->z)//Simplify

aFunForEqualG[qq_,b_][z_]:=-Integrate[D[b[z],z]/qq[z],z]

aFunModifiedForEqualG[qq_,b_][z_]:=Exp[Integrate[D[b[z],z]/(qq[z]+b[z]),z]]


bbcan[a_][z_]:=bbcan[0,1][a][z]

partielIntegrationbbcan[a_,z_][term_]:=(term//.
	{Integrate[Exp[-Integrate[a[z]/a'[z],z]]*a'[z],z]s->
		Exp[-Integrate[a[z]/a'[z],z]]*a[z]-
			Integrate[D[Exp[-Integrate[a[z]/a'[z],z]],z]*a[z],z],
	Integrate[Exp[Integrate[a[z]/a'[z],z]]*a'[z],z]->
		Exp[Integrate[a[z]/a'[z],z]]*a[z]-
		Integrate[D[Exp[Integrate[a[z]/a'[z],z]],z]*a[z],z]})//Simplify
	
covDerVectorKAN1[a_,b_][z_]:=Module[{a1=D[a[z],z],b1=D[b[z],z],x},
	x=Integrate[a1^2/b1,z];
	{-(a1^2/(Sqrt[x-I]*(I+x)^(3/2)*b1)),(a1*(-(a[z]*x*a1)+(1+x^2)*b1))/
	(a[z]^2*Sqrt[x-I]*Sqrt[I+x]*b1),(-2*a[z]*x*a1)/(1+x^2)+
	(a[z]^2*(x^2-1)*a1^2)/((1+x^2)^2*b1)+b1}//Simplify]

covDerVectorKAN2[a_,b_][z_]:=Module[{a1=D[a[z],z],b1=D[b[z],z],x,a2,b2},
	x=Integrate[a1^2/b1,z];a2=D[a1,z]//Simplify;b2=D[b1,z]//Simplify;
	{(a1*(2*b1*(a1^2-a[z]*a2)+a[z]*a1*b2))/(a[z]*Sqrt[x-I]*(I+x)^(3/2)*b1^2),
	(-2*(1+x^2)*a1^2*b1^2+a[z]*b1*(2*x*a1^3+(1+x^2)*b1*a2)+a[z]^2*x*a1*
	(-2*b1*a2+a1*b2))/(a[z]^3*Sqrt[x-I]*Sqrt[I+x]*b1^2),
	(-2*(1+x^2)^2*a1*b1^3-2*a[z]^2*b1*((x^2-1)*a1^3+(x+x^3)*b1*a2)+
	a[z]*(1+x^2)*b1^2*(4*x*a1^2+(1+x^2)*b2)+
	a[z]^3*(x^2-1)*a1*(2*b1*a2-a1*b2))/(a[z]*(1+x^2)^2*b1^2)}//Simplify]


covDerVectorKAN3[a_,b_][z_]:=Module[{a1=D[a[z],z],b1=D[b[z],z],x,a2,b2,a3,b3},
	x=Integrate[a1^2/b1,z];a2=D[a1,z]//Simplify;b2=D[b1,z]//Simplify;
	a3=D[a2,z]//Simplify;b3=D[b2,z]//Simplify;
	{(-6*a1^4*b1^2-2*a[z]^2*b1^2*a2^2-3*a[z]*a1^3*b1*b2-2*a[z]^2*a1*b1*(-2*a2*b2+b1*a3)+
	a[z]*a1^2*(9*b1^2*a2-2*a[z]*b2^2+a[z]*b1*b3))/(a[z]^2*Sqrt[x-I]*(I+x)^(3/2)*b1^3),
	(6*(1+x^2)*a1^3*b1^3+6*a[z]*a1*b1^2*(-(x*a1^3)-(1+x^2)*b1*a2)+
	a[z]^2*b1*(-3*x*a1^2*(-3*b1*a2+a1*b2)+(1+x^2)*b1^2*a3)+a[z]^3*x*(-2*(b1*a2-a1*b2)^2-
	2*a1*b1^2*a3+a1^2*b1*b3))/(a[z]^4*Sqrt[x-I]*Sqrt[I+x]*b1^3),
	(6*(1+x^2)^2*a1^2*b1^4+3*a[z]*(1+x^2)*b1^3*(-4*x*a1^3-b1*a2-a1*b2-
	x^2*(b1*a2+a1*b2))+a[z]^3*b1*(3*(x^2-1)*a1^2*(-3*b1*a2+a1*b2)-
	2*(x+x^3)*b1^2*a3)+a[z]^2*b1^2*(6*(x^2-1)*a1^4+12*(x+x^3)*a1*b1*a2+
	(1+x^2)^2*b1*b3)+a[z]^4*(x^2-1)*(2*a1^2*b2^2+2*b1^2*(a2^2+a1*a3)-a1*b1*
	(4*a2*b2+a1*b3)))/(a[z]^2*(1+x^2)^2*b1^3)}//Simplify]

covDerVectorKAN4[a_,b_][z_]:=Module[{a1=D[a[z],z],b1=D[b[z],z],x,a2,b2,a3,b3},
	x=Integrate[a1^2/b1,z];a2=D[a1,z]//Simplify;b2=D[b1,z]//Simplify;
	a3=D[a2,z]//Simplify;b3=D[b2,z]//Simplify;
	a4=D[a3,z]//Simplify;b4=D[b3,z]//Simplify;
	{(24*a1^5*b1^3+12*a[z]*a1^4*b1^2*b2+6*a[z]^3*b1^2*a2*(a2*b2-b1*a3)-
	4*a[z]*a1^3*b1*(12*b1^2*a2-2*a[z]*b2^2+a[z]*b1*b3)+2*a[z]^2*a1*b1*
	(-6*a[z]*a2*b2^2+3*a[z]*b1*(b2*a3+a2*b3)+b1^2*(10*a2^2-a[z]*a4))+
	a[z]^2*a1^2*(6*a[z]*b2^3+12*b1^3*a3-6*a[z]*b1*b2*b3+
	b1^2*(-22*a2*b2+a[z]*b4)))/(a[z]^3*Sqrt[x-I]*(I+x)^(3/2)*b1^4),
	(-24*(1+x^2)*a1^4*b1^4+12*a[z]*a1^2*b1^3*(2*x*a1^3+3*(1+x^2)*b1*a2)+
	a[z]^2*b1^2*(2*a1*b1*a2*b2-a1^2*b2^2+12*x*a1^3*(-4*b1*a2+a1*b2)-
	b1^2*(7*a2^2+8*a1*a3)-x^2*(-2*a1*b1*a2*b2+a1^2*b2^2+b1^2*(7*a2^2+8*a1*a3)))+
	a[z]^3*b1*(-2*x*a1*(-4*a1^2*b2^2-2*b1^2*(5*a2^2+3*a1*a3)+a1*b1*
	(11*a2*b2+2*a1*b3))+(1+x^2)*b1^3*a4)+a[z]^4*x*(6*a1^2*b2^3-6*a1*b1*b2*(2*a2*b2+
	a1*b3)-2*b1^3*(3*a2*a3+a1*a4)+b1^2*(6*a2^2*b2+6*a1*a2*b3+a1*
	(6*b2*a3+a1*b4))))/(a[z]^5*Sqrt[x-I]*Sqrt[I+x]*b1^4),
	(-24*(1+x^2)^2*a1^3*b1^5+12*a[z]*(1+x^2)*a1*b1^4*(4*x*a1^3+
	2*b1*a2+a1*b2+x^2*(2*b1*a2+a1*b2))-2*a[z]^2*b1^3*(12*(x^2-1)*a1^5+
	36*(x+x^3)*a1^2*b1*a2+(1+x^2)^2*b1*(3*a2*b2+2*b1*a3)+2*(1+x^2)^2*a1*b1*b3)+
	2*a[z]^4*b1*((x^2-1)*a1*(-4*a1^2*b2^2-2*b1^2*(5*a2^2+3*a1*a3)+a1*b1*
	(11*a2*b2+2*a1*b3))-(x+x^3)*b1^3*a4)+a[z]^3*b1^2*(48*(x^2-1)*a1^3*b1*
	a2-12*(x^2-1)*a1^4*b2+2*(x+x^3)*a1^2*b2^2+4*(x+x^3)*a1*b1*(-(a2*b2)+
	4*b1*a3)+b1^2*(14*(x+x^3)*a2^2+(1+x^2)^2*b4))+a[z]^5*(x^2-1)*
	(-6*a1^2*b2^3+6*a1*b1*b2*(2*a2*b2+a1*b3)+2*b1^3*(3*a2*a3+a1*a4)-
	b1^2*(6*a2^2*b2+6*a1*a2*b3+a1*(6*b2*a3+a1*b4))))/(a[z]^3*(1+x^2)^2*b1^4)}//Simplify]

covDerVectorKAN5[a_,b_][z_]:=Module[{a1=D[a[z],z],b1=D[b[z],z],x,a2,b2,a3,b3},
	x=Integrate[a1^2/b1,z];a2=D[a1,z]//Simplify;b2=D[b1,z]//Simplify;
	a3=D[a2,z]//Simplify;b3=D[b2,z]//Simplify;
	a4=D[a3,z]//Simplify;b4=D[b3,z]//Simplify;
	a5=D[a4,z]//Simplify;b5=D[b4,z]//Simplify;
	{(-120*a1^6*b1^4-60*a[z]*a1^5*b1^3*b2+a[z]*a1^4*b1^2*(-41*a[z]*b2^2+
	20*b1*(15*b1*a2+a[z]*b3))+2*a[z]^3*b1^2*(-12*a[z]*a2^2*b2^2+6*a[z]*b1*a2*(2*b2*a3+
	a2*b3)+b1^2*(10*a2^3-3*a[z]*a3^2-4*a[z]*a2*a4))-a[z]^2*a1^3*b1*(30*a[z]*b2^3+
	80*b1^3*a3-30*a[z]*b1*b2*b3+b1^2*(-142*a2*b2+5*a[z]*b4))+2*a[z]^3*a1*b1*
	(24*a[z]*a2*b2^3-12*a[z]*b1*b2*(b2*a3+2*a2*b3)+b1^2*(-35*a2^2*b2+6*a[z]*a3*
	b3+4*a[z]*b2*a4+4*a[z]*a2*b4)+b1^3*(35*a2*a3-a[z]*a5))+
	a[z]^2*a1^2*(-24*a[z]^2*b2^4+36*a[z]^2*b1*b2^2*b3+b1^4*(-191*a2^2+15*a[z]*a4)-
	2*a[z]*b1^2*(-40*a2*b2^2+3*a[z]*b3^2+4*a[z]*b2*b4)+a[z]*b1^3*(-40*(b2*a3+a2*b3)+
	a[z]*b5)))/(a[z]^4*Sqrt[x-I]*(I+x)^(3/2)*b1^5),
	(120*(1+x^2)*a1^5*b1^5+120*a[z]*a1^3*b1^4*(-(x*a1^3)-2*(1+x^2)*b1*a2)+
	6*a[z]^2*a1*b1^3*(-2*a1*b1*a2*b2+a1^2*b2^2-10*x*a1^3*(-5*b1*a2+a1*b2)+
	2*b1^2*(8*a2^2+5*a1*a3)+x^2*(-2*a1*b1*a2*b2+a1^2*b2^2+2*b1^2*(8*a2^2+5*a1*a3)))+
	a[z]^3*b1^2*(x*a1^2*(-41*a1^2*b2^2-b1^2*(191*a2^2+80*a1*a3)+2*a1*b1*
	(71*a2*b2+10*a1*b3))-5*(-(a1^2*b2^3)+a1*b1*b2*(2*a2*b2+a1*b3)-b1^2*(b2*(a2^2+a1*a3)+
	a1*a2*b3)+b1^3*(5*a2*a3+2*a1*a4))-5*x^2*(-(a1^2*b2^3)+a1*b1*b2*(2*a2*b2+
	a1*b3)-b1^2*(b2*(a2^2+a1*a3)+a1*a2*b3)+b1^3*(5*a2*a3+2*a1*a4)))+
	a[z]^4*b1*(5*x*(-6*a1^3*b2^3+2*a1^2*b1*b2*(8*a2*b2+3*a1*b3)+b1^3*(4*a2^3+14*a1*a2*
	a3+3*a1^2*a4)-a1*b1^2*(14*a2^2*b2+8*a1*a2*b3+a1*(8*b2*a3+a1*b4)))+
	(1+x^2)*b1^4*a5)+a[z]^5*x*(-24*a1^2*b2^4+12*a1*b1*b2^2*(4*a2*b2+
	3*a1*b3)-2*b1^2*(3*(4*b2^2*(a2^2+a1*a3)+8*a1*a2*b2*b3+a1^2*b3^2)+4*a1^2*b2*b4)-
	2*b1^4*(3*a3^2+4*a2*a4+a1*a5)+b1^3*(12*a2^2*b3+8*a2*(3*b2*a3+a1*b4)+
	a1*(12*a3*b3+8*b2*a4+a1*b5))))/(a[z]^6*Sqrt[x-I]*Sqrt[I+x]*b1^5),
	(120*(1+x^2)^2*a1^4*b1^6-60*a[z]*(1+x^2)*a1^2*b1^5*(4*x*a1^3+3*b1*a2+
	a1*b2+x^2*(3*b1*a2+a1*b2))+a[z]^2*b1^4*(120*(x^2-1)*a1^6+480*(x+x^3)*a1^3*b1*a2+
	31*(1+x^2)^2*b1^2*a2^2+2*(1+x^2)^2*a1*b1*(29*a2*b2+20*b1*a3)+(1+x^2)^2*a1^2*
	(b2^2+20*b1*b3))-a[z]^3*b1^3*(300*(x^2-1)*a1^4*b1*a2-60*(x^2-1)*a1^5*b2+
	12*(x+x^3)*a1^3*b2^2+24*(x+x^3)*a1^2*b1*(-(a2*b2)+5*b1*a3)+5*(1+x^2)^2*
	b1^2*(2*b2*a3+2*a2*b3+b1*a4)+a1*b1^2*(192*(x+x^3)*a2^2+5*(1+x^2)^2*b4))+
	a[z]^5*b1*(-5*(x^2-1)*(-6*a1^3*b2^3+2*a1^2*b1*b2*(8*a2*b2+3*a1*b3)+
	b1^3*(4*a2^3+14*a1*a2*a3+3*a1^2*a4)-a1*b1^2*(14*a2^2*b2+8*a1*a2*b3+a1*
	(8*b2*a3+a1*b4)))-2*x*(1+x^2)*b1^4*a5)+a[z]^4*b1^2*(2*(x^2-1)*a1^3*b1*(-71*a2*b2+
	40*b1*a3)+(x^2-1)*a1^4*(41*b2^2-20*b1*b3)+a1^2*(191*(x^2-1)*b1^2*a2^2-10*x*(1+x^2)*b2^3+
	10*(x+x^3)*b1*b2*b3)+10*x*(1+x^2)*a1*b1*(a2*(2*b2^2-b1*b3)+b1*(-(b2*a3)+2*b1*a4))+
	(1+x^2)*b1^2*(-10*x*a2*(a2*b2-5*b1*a3)+(1+x^2)*b1*b5))+a[z]^6*(x^2-1)*
	(24*a1^2*b2^4-12*a1*b1*b2^2*(4*a2*b2+3*a1*b3)+b1^2*(6*(4*b2^2*(a2^2+a1*a3)+
	8*a1*a2*b2*b3+a1^2*b3^2)+8*a1^2*b2*b4)+2*b1^4*(3*a3^2+4*a2*a4+a1*a5)-
	b1^3*(12*a2^2*b3+8*a2*(3*b2*a3+a1*b4)+a1*(12*a3*b3+8*b2*a4+a1*b5))))/
	(a[z]^4*(1+x^2)^2*b1^5)}//Simplify]

matrixOfScalarproducts[a_][z_]=Module[{a1=D[a[z],z],a2,a3,a4,a5},
	a2=D[a1,z]//Simplify;a3=D[a2,z]//Simplify;
	a4=D[a3,z]//Simplify;a5=D[a4,z]//Simplify;
	{{0,0,-1,0,(-a[z]^4-8*a1^4+8*a[z]*a1^2*a2+a[z]^2*(a2^2-2*a1*a3))/(a[z]^2*a1^2)},
	{0,1,0,(a[z]^4+8*a1^4-8*a[z]*a1^2*a2-a[z]^2*(a2^2-2*a1*a3))/(a[z]^2*a1^2),
	(-3*(-(a[z]^4*a1^2)+8*a1^6+a[z]^5*a2-12*a[z]*a1^4*a2+4*a[z]^2*a1^3*a3-
	a[z]^3*(a2^3-2*a1*a2*a3+a1^2*a4)))/(a[z]^3*a1^3)},
	{-1,0,(-a[z]^4-8*a1^4+8*a[z]*a1^2*a2+a[z]^2*(a2^2-2*a1*a3))/(a[z]^2*a1^2),
	(-(a[z]^4*a1^2)+8*a1^6+a[z]^5*a2-12*a[z]*a1^4*a2+4*a[z]^2*a1^3*a3-
	a[z]^3*(a2^3-2*a1*a2*a3+a1^2*a4))/(a[z]^3*a1^3),
	-((a[z]^8+88*a1^8-19*a[z]^5*a1^2*a2-176*a[z]*a1^6*a2+a[z]^6*(a2^2+3*a1*a3)+
	12*a[z]^2*a1^4*(5*a2^2+4*a1*a3)-4*a[z]^3*a1^2*(-4*a2^3+8*a1*a2*a3+a1^2*a4)+
	a[z]^4*(17*a1^4-2*a2^4+3*a1*a2^2*a3+a1^2*(2*a3^2-3*a2*a4)+a1^3*a5))/
	(a[z]^4*a1^4))},
	{0,(a[z]^4+8*a1^4-8*a[z]*a1^2*a2-a[z]^2*(a2^2-2*a1*a3))/(a[z]^2*a1^2),
	(-(a[z]^4*a1^2)+8*a1^6+a[z]^5*a2-12*a[z]*a1^4*a2+
	4*a[z]^2*a1^3*a3-a[z]^3*(a2^3-2*a1*a2*a3+a1^2*a4))/(a[z]^3*a1^3),
	(a[z]^4+8*a1^4-8*a[z]*a1^2*a2-a[z]^2*(a2^2-2*a1*a3))^2/(a[z]^4*a1^4),
	(-2*(a[z]^4+8*a1^4-8*a[z]*a1^2*a2-a[z]^2*(a2^2-2*a1*a3))*(-(a[z]^4*a1^2)+8*a1^6+
	a[z]^5*a2-12*a[z]*a1^4*a2+4*a[z]^2*a1^3*a3-a[z]^3*(a2^3-2*a1*a2*a3+a1^2*a4)))/
	(a[z]^5*a1^5)},{(-a[z]^4-8*a1^4+8*a[z]*a1^2*a2+a[z]^2*(a2^2-2*a1*a3))/(a[z]^2*a1^2),
	(-3*(-(a[z]^4*a1^2)+8*a1^6+a[z]^5*a2-12*a[z]*a1^4*a2+4*a[z]^2*a1^3*a3-
	a[z]^3*(a2^3-2*a1*a2*a3+a1^2*a4)))/(a[z]^3*a1^3),
	-((a[z]^8+88*a1^8-19*a[z]^5*a1^2*a2-176*a[z]*a1^6*a2+
	a[z]^6*(a2^2+3*a1*a3)+12*a[z]^2*a1^4*(5*a2^2+4*a1*a3)-4*a[z]^3*a1^2*
	(-4*a2^3+8*a1*a2*a3+a1^2*a4)+a[z]^4*(17*a1^4-2*a2^4+3*a1*a2^2*a3+
	a1^2*(2*a3^2-3*a2*a4)+a1^3*a5))/(a[z]^4*a1^4)),
	(-2*(a[z]^4+8*a1^4-8*a[z]*a1^2*a2-a[z]^2*(a2^2-2*a1*a3))*
	(-(a[z]^4*a1^2)+8*a1^6+a[z]^5*a2-12*a[z]*a1^4*a2+4*a[z]^2*a1^3*a3-
	a[z]^3*(a2^3-2*a1*a2*a3+a1^2*a4)))/(a[z]^5*a1^5),
	(-a[z]^12-320*a1^12+12*a[z]^9*a1^2*a2+960*a[z]*a1^10*a2+a[z]^10*(6*a2^2-4*a1*a3)-
	160*a[z]^2*a1^8*(6*a2^2+a1*a3)-80*a[z]^3*a1^6*(-a2^3-8*a1*a2*a3+
	a1^2*a4)+2*a[z]^7*a1^2*(6*a2^3+64*a1*a2*a3+13*a1^2*a4)-a[z]^8*(17*a1^4+9*a2^4-
	20*a1*a2^2*a3+4*a1^2*(a3^2+3*a2*a4)+2*a1^3*a5)-
	8*a[z]^4*a1^4*(50*a1^4-57*a2^4+106*a1*a2^2*a3-a1^2*(2*a3^2+25*a2*a4)+2*a1^3*a5)+
	8*a[z]^5*a1^2*(113*a1^4*a2-3*a2^5-7*a1*a2^3*a3+a1^2*a2*(26*a3^2-7*a2*a4)+
	a1^3*(-7*a3*a4+2*a2*a5))+a[z]^6*(4*a2^6-188*a1^5*a3-16*a1*a2^4*a3+
	4*a1^2*a2^2*(4*a3^2+3*a2*a4)+2*a1^3*a2*(-12*a3*a4+a2*a5)+
	a1^4*(-478*a2^2+9*a4^2-4*a3*a5)))/(a[z]^6*a1^6)}}]

schwarzDerCMC[f_][z_]:=Sqrt[3*D[f[z],z,z]^2-2*D[f[z],z]*D[f[z],{z,3}]]/D[f[z],z]

covDerVectorKAN[a_,b_][z_]:={covDerVectorKAN1[a,b][z],covDerVectorKAN2[a,b][z],
	covDerVectorKAN3[a,b][z],covDerVectorKAN4[a,b][z],covDerVectorKAN5[a,b][z]}

nilpotent[a_]:={{1,a},{0,1}}//Simplify

abelian[a_]:=DiagonalMatrix[{a,1/a}]//Simplify

compact[c_]:={{Cos[c],-Sin[c]},{Sin[c],Cos[c]}}//Simplify

Sl2CToSO13[ar_,br_,cr_,dr_,af_,bf_,cf_,df_]:=Module[{
	d=Simplify[Det[{{ar,br},{cr,dr}}+I*{{af,bf},{cf,df}}]],mm},
	mm=Transpose[{{(af^2+ar^2+bf^2+br^2+cf^2+cr^2+df^2+dr^2)/2,
		af*cf+ar*cr+bf*df+br*dr,-(ar*cf)+af*cr-br*df+bf*dr,
		(af^2+ar^2+bf^2+br^2-cf^2-cr^2-df^2-dr^2)/2},
		{af*bf+ar*br+cf*df+cr*dr,bf*cf+br*cr+af*df+ar*dr,
		-(br*cf)+bf*cr-ar*df+af*dr,af*bf+ar*br-cf*df-cr*dr},
		{ar*bf-af*br+cr*df-cf*dr,-(br*cf)+bf*cr+ar*df-af*dr,
		-(bf*cf)-br*cr+af*df+ar*dr,ar*bf-af*br-cr*df+cf*dr},
		{(af^2+ar^2-bf^2-br^2+cf^2+cr^2-df^2-dr^2)/2,
		af*cf+ar*cr-bf*df-br*dr,-(ar*cf)+af*cr+br*df-bf*dr,
		(af^2+ar^2-bf^2-br^2-cf^2-cr^2+df^2+dr^2)/2}}];
	If[d==1,Simplify[mm],Simplify[mm/Abs[d]],Simplify[mm/Abs[d]]]]

Sl2CToSO13[m_]:=Module[{r=ComplexExpand[Re[m]],i=ComplexExpand[Im[m]]},
	Sl2CToSO13[r[[1,1]],r[[1,2]],r[[2,1]],r[[2,2]],i[[1,1]],i[[1,2]],i[[2,1]],i[[2,2]]]]


Sl2KANparam[a_,b_,c_]:=compact[I*Log[a]].abelian[b].nilpotent[c]

Sl2KANparam[v_List]:=Sl2KANparam[v[[1]],v[[2]],v[[3]]]

Sl2KANparamInversvereinfachen[term_]:=
	(term/.Sqrt[x_]:>PowerExpand[Sqrt[Factor[x]]])//Simplify

Sl2KANparamInvers[w_]:=Module[{a=Sl2KANparamInvers1[w],b,c},
	b=(w[[1,1]]+I*w[[2,1]])*a//Simplify;
		(*kann man hier einfach b=+-Sqrt[w11^2+w12^2] setzen?*)
	c=(w[[1,2]]-I*w[[2,2]]+I/(w[[1,1]]+I*w[[2,1]]))/(a*b)//Simplify;
	Transpose[{a,b,ExpandDenominator[Together[c]]//Simplify}]]

Sl2KANparamInversX[w_]:=Module[{ww=Transpose[w].w//Simplify,cc,bb,aa,v},
	cc=(abelian[1/ww[[1,1]]].ww)[[1,2]];bb=Sqrt[ww[[1,1]]];
	v=(w.nilpotent[-cc].abelian[1/bb])[[1,1]];aa=v-Sqrt[Simplify[v^2-1]];
	{1/aa,bb,cc}]//PowerExpand//Simplify

Sl2KANparamInvers1[w_]:=Module[{kl=Sqrt[(w[[1,1]]-I*w[[2,1]])/(w[[1,1]]+
	I*w[[2,1]])]},{kl,-kl}//Sl2KANparamInversvereinfachen]

Sl2KANparamInvers2[w_]:=(w[[1,1]]+I*w[[2,1]])*Sl2KANparamInvers1[w]//Simplify

Sl2KANparamInvers3[w_]:=(w[[1,2]]-I*w[[2,2]]+I/(w[[1,1]]+I*w[[2,1]]))/
	(Sl2KANparamInvers1[w]*Sl2KANparamInvers2[w])//Simplify

Sl2KANparamDifferentialoriginal[a_,b_,c_][x_,y_,z_]:=(Inverse[Sl2KANparam[a,b,c]].
	(D[Sl2KANparam[a+t*x,b+t*y,c+t*z],t]//.t->0))//Simplify
	
Sl2KANparamDifferential[a_,b_,c_][x_,y_,z_]:={{((-I)*b^2*c*x)/a+y/b,
	((-I)*(1+b^4*c^2)*x+a*b*(2*c*y+b*z))/(a*b^2)},{(I*b^2*x)/a,(I*b^2*c*x)/a-y/b}}

Sl2KANparamDifferential[p__][v_]:=
	Sl2KANparamDifferential[p[[1]],p[[2]],p[[3]]][v[[1]],v[[2]],v[[3]]]

Sl2KANparamDifferential[p__][x_,y_,z_]:=
	Sl2KANparamDifferential[p[[1]],p[[2]],p[[3]]][x,y,z]

Sl2KANparamDifferential[a_,b_,c_][v_]:=
	Sl2KANparamDifferential[a,b,c][v[[1]],v[[2]],v[[3]]]

Sl2KANparamDifferentialInversoriginal[m_][x_]:=
	(D[Sl2KANparamInvers[m+t*m.x],t][[1]]//.t->0)//Simplify

Sl2KANparamDifferentialInvers[a11_,a12_,a21_,a22_][x11_,x12_,x21_,x22_]:=
	{(I*(a12*a21-a11*a22)*x21)/(Sqrt[a11-I*a21]*(a11+I*a21)^(3/2)),
	(a11^2*x11+a11*a12*x21+a21*(a21*x11+a22*x21))/(Sqrt[a11-I*a21]*Sqrt[a11+I*a21]),
	(-2*(I+(a11+I*a21)*(a12-I*a22))*(a11^2*x11+a11*a12*x21+a21*(a21*x11+a22*x21))+
	(a11^2+a21^2)*(a21*a22*x11+a11^2*x12+a21^2*x12+a12^2*x21+a22^2*x21+a21*a22*x22+
	I*a12*a21*(x11+x22)+a11*(a12-I*a22)*(x11+x22)))/(a11^2+a21^2)^2}

Sl2KANparamDifferentialInvers[m_][x_]:=
	Sl2KANparamDifferentialInvers[m[[1,1]],
	m[[1,2]],m[[2,1]],m[[2,2]]][x[[1,1]],x[[1,2]],x[[2,1]],x[[2,2]]];

Sl2KANparamDifferentialInvers[a11_,a12_,a21_,a22_][x_]:=
	Sl2KANparamDifferentialInvers[a11,a12,a21,a22][
	x[[1,1]],x[[1,2]],x[[2,1]],x[[2,2]]];

Sl2KANparamDifferentialInvers[m_][x11_,x12_,x21_,x22_]:=
	Sl2KANparamDifferentialInvers[m[[1,1]],
	m[[1,2]],m[[2,1]],m[[2,2]]][x11,x12,x21,x22]

Sl2KANparamInversXX[signum_][a_,b_,c_,d_]:=Module[
	{plus=1+b*c+I*c*d,minus=1+b*c-I*c*d,x,y},
	x=signum*Sqrt[minus]/Sqrt[plus];
	y=(a+I*c)*x;
	{x,y,I*((b-I*d)^2/(4*x^2)-x^2*(1*(b+I*d))^2/4)}//Simplify];
	
Sl2KANparamInversXX[sign_][m_]:=Sl2KANparamInversXX[sign][m[[1,1]],m[[1,2]],m[[2,1]],m[[2,2]]]

Sl2KANparamInversXX1[ax_,bx_,cx_,dx_]:=Sl2KANparamInversXX[-1][ax,bx,cx,dx]

Sl2KANparamInversXX1[m_]:=Sl2KANparamInversXX[-1][m]

Sl2KANparamInversXX2[ax_,bx_,cx_,dx_]:=Sl2KANparamInversXX[1][ax,bx,cx,dx]

Sl2KANparamInversXX2[m_]:=Sl2KANparamInversXX[1][m]

Sl2KANparamDifferentialInversXXoriginal[sign_][m_][x_]:=
	(D[Sl2KANparamInversXX[sign][m+t*m.x],t]//.t->0)//Simplify

Sl2KANparamDifferentialInversXX[s_][a_,b_,c_,d_][x_,y_,u_,v_]:=
	{((-I)*s*(d^2*u+c^2*(1+b*c)*y+c*d*(v+x-a*c*y)))/
	(Sqrt[1+b*c-I*c*d]*(1+b*c+I*c*d)^(3/2)),
	(s*(b^3*c^2*u+I*c^2*d^3*u+b^2*c*((2+I*c*d)*u+(a+I*c)*c*x)+
	((-I)*a+c)*d^2*(u+I*c^2*x)+(a+I*c)*(x-I*c^2*y)+
	I*d*(u+(a+I*c)*c*(-v-x+a*c*y))+b*((1+(2*I)*c*d+c^2*d^2)*u+
	c*((-I)*a+c)*((2*I)*x+c^2*y))))/(Sqrt[1+b*c-I*c*d]*(1+b*c+I*c*d)^(3/2)),
	((I/4)*((2*(b-I*d)*(1+b*c+I*c*d)*(b*v+a*y-I*(d*v+c*y)))/(1+b*c-I*c*d)-
	(2*(b+I*d)*(1+b*c-I*c*d)*s^4*(b*v+a*y+I*(d*v+c*y)))/(1+b*c+I*c*d)+
	((b-I*d)^2*(b*(d*u+c*(v+x))+I*(d^2*u+c*d*(v+x)+c*((-I)*a+c)*y)))/
	(1+b*c-I*c*d)+((b+I*d)^2*(1+b*c-I*c*d)*s^4*(b*(d*u+c*(v+x))+
	I*(d^2*u+c*d*(v+x)+c*((-I)*a+c)*y)))/(1+b*c+I*c*d)^2-
	((b-I*d)^2*(1+b*c+I*c*d)*(b*(d*u+c*(v+x))-I*(d^2*u+c*d*(v+x)+c*(I*a+c)*y)))/
	(1+b*c-I*c*d)^2-((b+I*d)^2*s^4*(b*(d*u+c*(v+x))-
	I*(d^2*u+c*d*(v+x)+c*(I*a+c)*y)))/(1+b*c+I*c*d)))/s^2}//Simplify

Sl2KANparamDifferentialInversXX[sign_][m_][x_]:=Sl2KANparamDifferentialInversXX[sign][m[[1,1]],
	m[[1,2]],m[[2,1]],m[[2,2]]][x[[1,1]],x[[1,2]],x[[2,1]],x[[2,2]]];

Sl2KANparamDifferentialInversXX[sign_][a_,b_,c_,d_][x_]:=
	Sl2KANparamDifferentialInversXX[sign][a,b,c,d][x[[1,1]],x[[1,2]],x[[2,1]],x[[2,2]]];

Sl2KANparamDifferentialInversXX[sign_][m_][x_,y_,u_,v_]:=
	Sl2KANparamDifferentialInversXX[sign][m[[1,1]],m[[1,2]],m[[2,1]],m[[2,2]]][x,y,u,v]

Sl2KANparamDifferentialInversXX1[a_,b_,c_,d_][x_,y_,u_,v_]:=
	Sl2KANparamDifferentialInversXX[-1][a,b,c,d][x,y,u,v]
	
Sl2KANparamDifferentialInversXX1[m_][x_]:=Sl2KANparamDifferentialInversXX1[m[[1,1]],
	m[[1,2]],m[[2,1]],m[[2,2]]][x[[1,1]],x[[1,2]],x[[2,1]],x[[2,2]]];

Sl2KANparamDifferentialInversXX1[a_,b_,c_,d_][x_]:=
	Sl2KANparamDifferentialInversXX1[a,b,c,d][x[[1,1]],x[[1,2]],x[[2,1]],x[[2,2]]];

Sl2KANparamDifferentialInversXX1[m_][x_,y_,u_,v_]:=
	Sl2KANparamDifferentialInversXX1[m[[1,1]],m[[1,2]],m[[2,1]],m[[2,2]]][x,y,u,v]

Sl2KANparamDifferentialInversXX2[a_,b_,c_,d_][x_,y_,u_,v_]:=
	Sl2KANparamDifferentialInversXX[1][a,b,c,d][x,y,u,v]
	
Sl2KANparamDifferentialInversXX2[m_][x_]:=Sl2KANparamDifferentialInversXX2[m[[1,1]],
	m[[1,2]],m[[2,1]],m[[2,2]]][x[[1,1]],x[[1,2]],x[[2,1]],x[[2,2]]];

Sl2KANparamDifferentialInversXX2[a_,b_,c_,d_][x_]:=
	Sl2KANparamDifferentialInversXX2[a,b,c,d][x[[1,1]],x[[1,2]],x[[2,1]],x[[2,2]]];

Sl2KANparamDifferentialInversXX2[m_][x_,y_,u_,v_]:=
	Sl2KANparamDifferentialInversXX2[m[[1,1]],m[[1,2]],m[[2,1]],m[[2,2]]][x,y,u,v]

commutatorKAN[a_,b_,c_][x1_,y1_,z1_][x2_,y2_,z2_]:=
	{((-I/2)*((-I)*(1+a^2)*(1+b^2)+(-1+a^2)*b^2*c)*(x2*y1-x1*y2))/(Sqrt[b/a]*(a*b)^(3/2)),
	
	((-((-1+a^2)*(-1+b^2))-I*(1+a^2)*b^2*c)*x2*y1+((-1+a^2)*(-1+b^2)+I*(1+a^2)*b^2*c)*x1*y2-
	b^5*(-I-c+a^2*(-I+c))*x2*z1+b^5*((-I)*(1+a^2)+(-1+a^2)*c)*x1*z2-
	I*(-a+a^3)*b^2*(y2*z1-y1*z2))/(2*a^2*Sqrt[b/a]*Sqrt[a*b]),
	
	(a^2*((-4*I)*x2*y1+(4*I)*x1*y2+b^3*(-1+b^2*(1+I*c))*x2*z1+b^3*(1+b^2*(-1-I*c))*x1*z2)+
	b^2*(-4*(I+c)*x2*y1+4*(I+c)*x1*y2+b*(-1+b^2-I*b^2*c)*x2*z1+b*(1+I*b^2*(I+c))*x1*z2)-
	I*a^3*b^2*(-3*I+b^2*(-I+c))*(y2*z1-y1*z2)+a*b^2*(1+I*b^2*(I+c))*(y2*z1-y1*z2))/(2*a^2*b^4)}

commutatorKAN[p_][x_,y_]:=commutatorKAN[p[[1]],p[[2]],p[[3]]][
	x[[1]],x[[2]],x[[3]]][y[[1]],y[[2]],y[[3]]]

commutatorKAN[a_,b_,c_][x_,y_]:=commutatorKAN[a,b,c][x[[1]],x[[2]],x[[3]]][y[[1]],y[[2]],y[[3]]]
	
commutatorKANoriginal[point_][vector1_,vector2_]:=Module[{inversematrix,comm,
	correspondingsltwoCmatrix1,correspondingsltwoCmatrix2,
	correspondingMatrix=Sl2KANparam[point]},
	inversematrix=correspondingMatrix//Inverse;
	correspondingsltwoCmatrix1=inversematrix.Sl2KANparamDifferential[point][vector1];
	correspondingsltwoCmatrix2=inversematrix.Sl2KANparamDifferential[point][vector2];
	comm=commutator[correspondingsltwoCmatrix1,correspondingsltwoCmatrix2];
	Sl2KANparamDifferentialInvers[correspondingMatrix][correspondingMatrix.comm]//Simplify]
	
cmcKappaRule[n_][a_,b_,cmcCur_][z_]:=Module[{a1=D[a[z],z],b1=D[b[z],z],a2,b2,b3,Da3temp},
	a2=D[a1,z];b2=D[b1,z];b3=D[b2,z];
	Da3temp=(3*a[z]*a1*b1^3*a2-3*a[z]*a1^2*b1^2*b2+a[z]^2*a1*b1^2*b3+a[z]*b1^(3/2)*
	Sqrt[a[z]^4*cmcCur[z]^2*b1^3+12*a1^2*b1^3*a2^2-6*a[z]*b1^3*a2^3-24*a1^3*b1^2*a2*b2+
	6*a[z]*a1*b1^2*a2^2*b2+12*a1^4*b1*b2^2+6*a[z]*a1^2*b1*a2*b2^2-6*a[z]*a1^3*b2^3+
	2*a[z]^2*b1^2*a2^2*b3-4*a[z]^2*a1*b1*a2*b2*b3+2*a[z]^2*a1^2*b2^2*b3])/(a[z]^2*b1^3);
	Table[D[a[z],{z,3+i}]->D[Da3temp,{z,i}],{i,0,n}]]

cmcKappaRulecanFalsch[n_][a_,cmcCur_][z_]:=Module[{Da3temp=D[a[z],{z,3}]/.Solve[
	Simplify[cmcKappaKAN[a,bbcan[a]][z]]==cmcCur[z]^2,D[a[z],{z,3}]][[1]]},
	Table[D[a[z],{z,3+i}]->D[Da3temp,{z,i}]//Simplify,{i,0,n}]]

cmcKappaRulecan[n_][a_,cmcCur_][z_]:=Module[{Da3temp=D[a[z],{z,3}]/.
		Solve[cmcKappaKAN[a,bbcan[a]][z]==cmcCur[z]^2,D[a[z],{z,3}]][[1]]},
	Table[D[a[z],{z,3+i}]->D[Da3temp,{z,i}]//Simplify,{i,0,n}]]


cmcCPPRule[a_,b_,CPP_][z_]:=Module[{
	Da2temp=D[a[z],z,z]/.Solve[cmcCPPKAN[a,b][z]==CPP[z],D[a[z],z,z]][[1]],xx,l},
	xx={Da2temp};
	Do[AppendTo[xx,Simplify[D[Last[xx],z]]],{5}];
	l=Length[xx];Table[D[a[z],{z,i+1}]->xx[[i]],{i,l}]];


cmcKappaRule[n_][a_,cmcCur_][z_]:=Module[{Da3temp=D[a[z],{z,3}]/.
		Solve[cmcKappaKAN[a,bbcan[a]][z]==cmcCur[z]^2,D[a[z],{z,3}]][[1]]},
	Table[D[a[z],{z,3+i}]->D[Da3temp,{z,i}]//Simplify,{i,0,n}]]


tocmcKappa[a_,b_,curv_][term_][z_]:=Module[{n=determineOrderBasic[term]},
	(term//.cmcKappaRule[n][a,b,curv][z])//Simplify]

tocmcKappa[a_,b_,curv_,CPP_][term_][z_]:=Module[{n=determineOrderBasic[term],ru,ccc,l,rr},
	ccc=cmcKappaRule[n][a,b,curv][z];l=Length[ccc];
	rr=cmcCPPRule[a,b,CPP][z];
	ru=Table[ccc[[i,1]]->(ccc[[i,2]]//.rr),{i,l}];
	(term//.Join[ru,rr])//Simplify]

tocmcKappacan[a_,curv_][term_][z_]:=Module[{n=determineOrderBasic[term]},
	(term//.cmcKappaRulecan[n][a,curv][z])//Simplify]
	

determineOrderBasic[term_]:=Module[{pp=Position[term,Derivative],l},l=Length[pp];
	Table[Extract[term,Drop[pp[[i]],-1]][[1]],{i,l}]//Max]
	
determineOrder[term_]:=Module[{pp=Position[term,Derivative],l},l=Length[pp];
	Table[Table[Extract[term,Append[Drop[pp[[j]],-1],i]],
		{i,Length[Extract[term,Drop[pp[[j]],-1]]]}],{j,l}]//Max]

wurzelausdruck[a_,b_][z_]:=Module[{a1=D[a[z],z],b1=D[b[z],z],a2,b2,b3},a2=D[a1,z];
	b2=D[b1,z];b3=D[b2,z];
	Sqrt[b1^3(a[z]^4*cmcCur[z]^2*b1^3+12*a1^2*b1^3*a2^2-6*a[z]*b1^3*a2^3-
	24*a1^3*b1^2*a2*b2+6*a[z]*a1*b1^2*a2^2*b2+12*a1^4*b1*b2^2+6*a[z]*a1^2*b1*a2*b2^2-
	6*a[z]*a1^3*b2^3+2*a[z]^2*b1^2*a2^2*b3-4*a[z]^2*a1*b1*a2*b2*b3+
	2*a[z]^2*a1^2*b2^2*b3)]//Simplify]


(********************* Befehle zur Killingform ***********************)

onBasisofsl2C={DiagonalMatrix[{1,-1}],{{0,1},{1,0}},{{0,I},{-I,0}}}

(*xx={{x11,x12},{x21,-x11}};
yy={{y11,y12},{y21,-y11}}*)

killingFormSl2C[x_,y_]:=Module[{
	x11=x[[1,1]],x12=x[[1,2]],x21=x[[2,1]],
	y11=y[[1,1]],y12=y[[1,2]],y21=y[[2,1]]},
		4(2*x11*y11+x21*y12+x12*y21)//Simplify]

killingFormofGln[n_][aMatrix_,bMatrix_]:=Module[{null=Table[0,{n},{n}],
	basis,kommutatormitA,kommutatormitB,diagonalelemente,ix,jx},
	basis=Table[null,{n},{n}];
	Do[basis[[i,j,i,j]]=1,{i,n},{j,n}];
	diagonalelemente=Table[
		(kommutatormitB=bMatrix.basis[[ix,jx]]-basis[[ix,jx]].bMatrix;
		kommutatormitA=aMatrix.kommutatormitB-kommutatormitB.aMatrix;
		kommutatormitA[[ix,jx]]//Simplify),{ix,n},{jx,n}];
	Simplify[Plus@@Flatten[diagonalelemente]]]

killingFormofGln[aMatrix_,bMatrix_]:=Module[{
	dim={Dimensions[aMatrix],Dimensions[bMatrix]}//Flatten//Union},
	If[Length[dim]==1,killingFormofGln[dim[[1]]][aMatrix,bMatrix],
		Print["The matrices given are not quadratic or not of the same size."]]]

allgemeinematrix[symbol_,ord_]:=Table[ToExpression[
	StringJoin[ToString[symbol],ToString[i],ToString[j]]],{i,ord},{j,ord}]

matrixofkillingFormofGln[n_]:=Module[{null=Table[0,{n},{n}],basis,ix,jx},
	basis=Table[null,{n},{n}];
	Do[basis[[ix,jx,ix,jx]]=1,{ix,n},{jx,n}];
	gestrecktebasis=Flatten[basis,1];
	Table[killingFormofGln[gestrecktebasis[[ix]],gestrecktebasis[[jx]]],{ix,n*n},{jx,n*n}]];

onBasisofGln[n_]:=Module[{null=Table[0,{n},{n}],basis,ix,jx,vv,mm=matrixofkillingFormofGln[n]},
	basis=Table[null,{n},{n}];
	Do[basis[[ix,jx,ix,jx]]=1,{ix,n},{jx,n}];
	eve=Eigenvectors[mm];
	vv=Table[Table[Take[eve[[j]],{n(i-1)+1,n*i}],{i,n}],{j,n^2}];
	orthonormierungGlnOBS[vv]]

normierungGlnSimple[vv_]:=Module[{nn=killingFormofGln[vv,vv]//Simplify},
	If[nn==0,vv,If[nn>0,vv/Sqrt[nn]//simplGln,vv/Sqrt[-nn]//simplGln]]]

(* Die obige falsche Variante von normierungGln[vv] berücksichtigt nicht komplexe Matrizen,
und nicht Matrizen mit formalen Einträgen. Wir verwenden sie aber wegen ihrer Einfachheit
unten bei onBasisofGln[n]**)


normierungGln[vv_]:=Module[{nn=killingFormofGln[vv,vv]//Simplify,endres},
	endres:=If[nn==0,vv,
		If[TrueQ[Head[nn]==Complex],vv/Sqrt[nn]//simplGln,
		If[nn>0,vv/Sqrt[nn]//simplGln,vv/Sqrt[-nn]//simplGln],vv/Sqrt[nn]//simplGln]];
	If[NumericQ[nn],endres,vv/Sqrt[nn]//simplGln,vv/Sqrt[nn]//simplGln]]
orthonormierungGln[1][v1_List]:={normierungGln[v1[[1]]]}

orthonormierungGln[k_][vv_List]:=Module[{vvkaminus1=Drop[vv,-1],orthokaminus1,
	letztematrix=Last[vv],temp},orthokaminus1=orthonormierungGln[k-1][vvkaminus1];
	
	temp=letztematrix-Sum[killingFormofGln[letztematrix,orthokaminus1[[i]]]*
		killingFormofGln[orthokaminus1[[i]],orthokaminus1[[i]]]*
		orthokaminus1[[i]],{i,1,k-1}];
	Append[orthokaminus1,normierungGln[temp]]]

orthonormierungGln[vv_List]:=orthonormierungGln[Length[vv]][vv]

ad[m_][n_]:=m.n-n.m//Simplify;


adXadYvonMatrix[bas_][x_,y_,matr_]:=Module[{a,b,c,gl},
	gl=Flatten[Inner[Times,{a,b,c},bas,Plus]-ad[x][ad[y][matr]]];
	Flatten[{a,b,c}/.Solve[Thread[gl==Simplify[gl-gl]],{a,b,c}]]//Expand]


invariantmetricKAN[a_,b_,c_][t1_,t2_,t3_][s1_,s2_,s3_]:=
(8*b^2*s1*t1+8*a^2*s2*t2+(4*I)*a*b^4*(s3*t1+s1*t3))/8/(a^2*b^2)

invariantmetricKAN[a_][t_][s_]:=invariantmetricKAN[a[[1]],a[[2]],a[[3]]][
	t[[1]],t[[2]],t[[3]]][s[[1]],s[[2]],s[[3]]]

invariantmetricTensorKAN[a_,b_,c_]:=Module[{id=IdentityMatrix[3]},
	Table[invariantmetricKAN[{a,b,c}][id[[i]]][id[[j]]],{i,3},{j,3}]]

invariantmetricTensorKAN[p_]:=invariantmetricTensorKAN[p[[1]],p[[2]],p[[3]]]



gammaKAN[i_,j_,k_][point_]:=Module[{gij,gijInvers,aa,bb,cc,generalpoint,gammas},
	generalpoint={aa,bb,cc};
	gij=invariantmetricTensorKAN[generalpoint];
	gijInvers=Inverse[gij];
	gammas=Sum[gijInvers[[i,h]]*
		(D[gij[[h,j]],generalpoint[[k]]]+
		D[gij[[h,k]],generalpoint[[j]]]-
		D[gij[[j,k]],generalpoint[[h]]])/2,{h,3}];
	(gammas/.Thread[generalpoint:>point])//Simplify]

gammaKAN[i_,j_,k_][a_,b_,c_]:=gammaKAN[i,j,k][{a,b,c}]

covDerivativeKAN[xx_,yy_][point_]:=Module[{
	x=xx[point[[1]],point[[2]],point[[3]]],
	y=yy[point[[1]],point[[2]],point[[3]]]},
	(*Richtungsableitung der Koeffizienten von yy nach xx +
	Überschiebung (ohne Ableitung) der gammaKAN[k,i,j][point] mit x[[i]]*y[[j]]*)
	Table[Sum[x[[i]]*D[y[[k]],point[[i]]]//Simplify,{i,3}]+
        	Sum[x[[i]]*y[[j]]*gammaKAN[k,i,j][point]//Simplify,{i,3},{j,3}],
      			{k,3}]//Simplify]

covDerivativeKAN[xx_,yy_][a_,b_,c_]:=covDerivativeKAN[xx,yy][{a,b,c}]



gammaKANcollection[i_][a_,b_,c_]:={
	{gammaKAN[i,1,1][a,b,c],gammaKAN[i,2,1][a,b,c],gammaKAN[i,3,1][a,b,c]},
	{gammaKAN[i,1,2][a,b,c],gammaKAN[i,2,2][a,b,c],gammaKAN[i,3,2][a,b,c]},
	{gammaKAN[i,1,3][a,b,c],gammaKAN[i,2,3][a,b,c],gammaKAN[i,3,3][a,b,c]}}

gammaKANcollection[a_,b_,c_]:={
	gammaKANcollection[1][a,b,c],gammaKANcollection[2][a,b,c],gammaKANcollection[3][a,b,c]}

christoffelSymbols[i_,j_,k_][n_][metrictensor_][point_List]:=Module[{
	gij,gijInvers,p,generalpoint,gammas},
	generalpoint=
		Table[ToExpression[StringJoin[ToString[p],ToString[h]]],{h,n}];
	gij=metrictensor[generalpoint];
	gijInvers=Inverse[gij];
	gammas=Sum[gijInvers[[i,h]]*
		(D[gij[[h,j]],generalpoint[[k]]]+
		D[gij[[h,k]],generalpoint[[j]]]-
		D[gij[[j,k]],generalpoint[[h]]])/2,{h,n}];
	(gammas/.Thread[generalpoint:>point])//Simplify]

christoffelSymbols[i_,j_,k_][metrictensor_][point_List]:=
	christoffelSymbols[i,j,k][Length[point]][metrictensor][point]

covDerofVectorfieldKANalongCurve[gamma_,vec_][z_]:=Module[{
	tangent=D[gamma[z],z]//Simplify},
	Table[Sum[gammaKAN[i,j,k][gamma[z]]*tangent[[j]]*vec[z][[k]],
	{j,3},{k,3}],{i,3}]+D[vec[z],z]]


highercovDerKANofCurve[1][gamma_][t_]:=D[gamma[t],t]//Simplify

highercovDerKANofCurve[n_Integer][gamma_][t_]:=
	covDerofVectorfieldKANalongCurve[gamma,
		highercovDerKANofCurve[n-1][gamma][#]&][t]//Together


tangentVectorKAN1[a11_,a12_,a21_,a22_][g_,om_][z_]:=
	{((-I)*om[z])/(Sqrt[a11[z]-I*a21[z]]*(a11[z]+I*a21[z])^(3/2)),
	((a11[z]*(a12[z]+a11[z]*g[z])+(a21[z]*(1+a12[z]*a21[z]+
	a11[z]*a21[z]*g[z]))/
	a11[z])*om[z])/(Sqrt[a11[z]-I*a21[z]]*Sqrt[a11[z]+I*a21[z]]),
	-(((a21[z]^2*(1+a12[z]*a21[z])^2+2*a11[z]^5*a12[z]*g[z]+
	2*a11[z]*a21[z]^3*(1+a12[z]*a21[z])*g[z]+2*a11[z]^3*a21[z]*
	(1+2*a12[z]*a21[z])*g[z]+a11[z]^6*g[z]^2+
	a11[z]^4*(a12[z]^2+2*a21[z]^2*g[z]^2)+a11[z]^2*(-1+2*a12[z]*a21[z]+
	2*a12[z]^2*a21[z]^2+a21[z]^4*g[z]^2))*om[z])/
	(a11[z]^2*(a11[z]^2+a21[z]^2)^2))}

tangentVectorKAN2[a11_,a12_,a21_,a22_][g_,om_][z_]:=
	{((-I)*Derivative[1][om][z])/(Sqrt[a11[z]-I*a21[z]]*
	(a11[z]+I*a21[z])^(3/2)),
	(a11[z]^2*a12[z]*Derivative[1][om][z]+a21[z]*(1+a12[z]*a21[z])*
	Derivative[1][om][z]+a11[z]^3*(om[z]*Derivative[1][g][z]+
	g[z]*Derivative[1][om][z])+a11[z]*a21[z]^2*(om[z]*Derivative[1][g][z]+
	g[z]*Derivative[1][om][z]))/(a11[z]*Sqrt[a11[z]-I*a21[z]]*Sqrt[a11[z]+I*a21[z]]),
	-((a21[z]^2*(1+a12[z]*a21[z])^2*Derivative[1][om][z]+
	2*a11[z]^5*a12[z]*(om[z]*Derivative[1][g][z]+g[z]*Derivative[1][om][z])+
	2*a11[z]*a21[z]^3*(1+a12[z]*a21[z])*(om[z]*Derivative[1][g][z]+
	g[z]*Derivative[1][om][z])+2*a11[z]^3*a21[z]*(1+2*a12[z]*a21[z])*
	(om[z]*Derivative[1][g][z]+g[z]*Derivative[1][om][z])+
	a11[z]^6*g[z]*(2*om[z]*Derivative[1][g][z]+g[z]*Derivative[1][om][z])+
	a11[z]^4*(a12[z]^2*Derivative[1][om][z]+
	2*a21[z]^2*g[z]*(2*om[z]*Derivative[1][g][z]+g[z]*Derivative[1][om][z]))+
	a11[z]^2*(-Derivative[1][om][z]+2*a12[z]*a21[z]*Derivative[1][om][z]+
	2*a12[z]^2*a21[z]^2*Derivative[1][om][z]+
	a21[z]^4*g[z]*(2*om[z]*Derivative[1][g][z]+
	g[z]*Derivative[1][om][z])))/(a11[z]^2*(a11[z]^2+a21[z]^2)^2))}

tangentVectorKAN3[a11_,a12_,a21_,a22_][g_,om_][z_]:=
	{((-I)*(om[z]^2*Derivative[1][g][z]+Derivative[2][om][z]))/
	(Sqrt[a11[z]-I*a21[z]]*(a11[z]+I*a21[z])^(3/2)),
	(a11[z]^2*a12[z]*(om[z]^2*Derivative[1][g][z]+Derivative[2][om][z])+
	a21[z]*(1+a12[z]*a21[z])*(om[z]^2*Derivative[1][g][z]+Derivative[2][om][z])+
	a11[z]^3*(2*Derivative[1][g][z]*Derivative[1][om][z]+om[z]*Derivative[2][g][z]+
	g[z]*(om[z]^2*Derivative[1][g][z]+Derivative[2][om][z]))+
	a11[z]*a21[z]^2*(2*Derivative[1][g][z]*Derivative[1][om][z]+om[z]*Derivative[2][g][z]+
	g[z]*(om[z]^2*Derivative[1][g][z]+Derivative[2][om][z])))/
	(a11[z]*Sqrt[a11[z]-I*a21[z]]*Sqrt[a11[z]+I*a21[z]]),
	-((a21[z]^2*(1+a12[z]*a21[z])^2*(om[z]^2*Derivative[1][g][z]+Derivative[2][om][z])+
	2*a11[z]^5*a12[z]*(2*Derivative[1][g][z]*Derivative[1][om][z]+
	om[z]*Derivative[2][g][z]+g[z]*(om[z]^2*Derivative[1][g][z]+Derivative[2][om][z]))+
	2*a11[z]*a21[z]^3*(1+a12[z]*a21[z])*(2*Derivative[1][g][z]*Derivative[1][om][z]+
	om[z]*Derivative[2][g][z]+g[z]*(om[z]^2*Derivative[1][g][z]+Derivative[2][om][z]))+
	2*a11[z]^3*a21[z]*(1+2*a12[z]*a21[z])*(2*Derivative[1][g][z]*Derivative[1][om][z]+
	om[z]*Derivative[2][g][z]+g[z]*(om[z]^2*Derivative[1][g][z]+Derivative[2][om][z]))+
	a11[z]^6*(2*om[z]*Derivative[1][g][z]^2+2*g[z]*(2*Derivative[1][g][z]*Derivative[1][om][z]+
	om[z]*Derivative[2][g][z])+g[z]^2*(om[z]^2*Derivative[1][g][z]+Derivative[2][om][z]))+
	a11[z]^2*((-1+2*a12[z]*a21[z]+2*a12[z]^2*a21[z]^2+a21[z]^4*g[z]^2)*om[z]^2*
	Derivative[1][g][z]+2*a21[z]^4*om[z]*(Derivative[1][g][z]^2+
	g[z]*Derivative[2][g][z])-Derivative[2][om][z]+2*a12[z]*a21[z]*
	Derivative[2][om][z]+2*a12[z]^2*a21[z]^2*Derivative[2][om][z]+a21[z]^4*g[z]*
	(4*Derivative[1][g][z]*Derivative[1][om][z]+g[z]*Derivative[2][om][z]))+
	a11[z]^4*(a12[z]^2*(om[z]^2*Derivative[1][g][z]+Derivative[2][om][z])+
	2*a21[z]^2*(2*om[z]*Derivative[1][g][z]^2+
	2*g[z]*(2*Derivative[1][g][z]*Derivative[1][om][z]+om[z]*Derivative[2][g][z])+
	g[z]^2*(om[z]^2*Derivative[1][g][z]+Derivative[2][om][z]))))/
	(a11[z]^2*(a11[z]^2+a21[z]^2)^2))}

(*************************** Examples


beispiel2:=(gamma[t_]:={a[t],b[t],c[t]};
	gamma1[t_]={Exp[a*t],Exp[b*t],Exp[c*t]};
	vec[t_]:={x[t],y[t],z[t]};vec1[z_]=D[gamma[z],z];
	covDerofVectorfieldKANalongCurve[gamma,vec][t];
	{covDerofVectorfieldKANalongCurve[gamma,vec1][t]-
		covDerofVectorfieldKANalongCurve[gamma,D[gamma[#],#]&][t],
	highercovDerKANofCurve[1][gamma][t],highercovDerKANofCurve[2][gamma][t],
		highercovDerKANofCurve[3][gamma][t]})


	Clear[herm];herm[z_]=Sl2CFrame[Sinh[#]&,Cosh[#]&][z]
	hh=herm[u+I*v];Conjugate[Transpose[hh]];
	surf = Simplify[ComplexExpand[Conjugate[Transpose[hh]]]].hh // Simplify //
	ComplexExpand // Simplify
	xx[u_, v_] = hermitean2by2ToLorentz[surf] // Simplify
	lorentzMetrik[xx[u, v], xx[u, v]]


	Auch

	herm[z_]=Sl2CFrame[Sin[#]&,Cos[#]&][z]
	Sl2CFrame[Sin[#]&,Tan[#]&][z]

	vv = normalofH3[xx][u, v]
	lorentzMetrik[hh, vv] // Simplify


	***************)
	
(********** Befehle zur Sl2MatrixEXP - Parametrisierung u. ä. von August 2002 ************)
(************** Sl2MatrixEXPParametrisierung and related stuff *******************)

Sl2Framerule[order_][a11_,a12_,a21_,a22_][g_,om_][z_]:=Module[{
	k,y,np=nilpotentsl2MatrixBasic[g,om][z],
	sl2={{a11[z],a12[z]},{a21[z],a22[z]}},ableitungen,
	bryantframebedingung},
	ableitungen=Union[Flatten[D[sl2,z]]];
	bryantframebedingung=Thread[Flatten[D[sl2,z]-sl2.np]=={0,0,0,0}];
	k=ableitungen//.Flatten[Solve[bryantframebedingung,ableitungen]];
	y=Table[Thread[D[ableitungen,{z,i}]->Simplify[D[k,{z,i}]]],{i,0,order}];
	Flatten[{y,Solve[Det[sl2]==1,a22[z]],
		Table[D[a22[z],{z,i}]->-D[a11[z],{z,i}],{i,0,order+1}]}]];


brCPP[g_,om_][z_]:=Sqrt[om[z]^2*Derivative[1][g][z]^2]

brKappa[g_,om_][z_]:=Sqrt[4*Derivative[1][g][z]^2*Derivative[1][om][z]^2-
	2*om[z]^3*Derivative[1][g][z]^3+om[z]^2*Derivative[2][g][z]^2-2*om[z]*Derivative[1][g][z]*
	(Derivative[1][g][z]*Derivative[2][om][z]-2*Derivative[1][om][z]*Derivative[2][g][z])]


Sl2MatrixEXPparam[r_,u_,v_]:=Module[{
	liealgebra=Inner[Times,{r*Cos[u]Cos[v],r*Cos[v]Sin[u],r*Sin[v]},
	onBasisofsl2C,Plus]},MatrixExp[liealgebra]//Simplify]

Sl2MatrixEXPparam[v_List]:=Sl2MatrixEXPparam[v[[1]],v[[2]],v[[3]]]

Sl2MatrixEXPparamInvers1[matrix_]:=Eigenvalues[matrix][[2]]//Log//Simplify

Sl2MatrixEXPparamInvers2[matrix_]:=(matrix[[1,2]]-matrix[[2,1]])/(2I*
	Sinh[Sl2MatrixEXPparamInvers1[matrix]])//ArcSin//Simplify

Sl2MatrixEXPparamInvers3[matrix_]:=Module[{
	fak=2I*Sinh[Sl2MatrixEXPparamInvers1[matrix]]//FullSimplify,xx,yy},
	xx=(matrix[[1,2]]+matrix[[2,1]])/fak//Simplify;
	yy=(matrix[[1,2]]-matrix[[2,1]])/fak//Simplify;
	I*xx/Sqrt[1-yy^2]//FullSimplify//PowerExpand//ArcSin]

Sl2MatrixEXPparamInvers[matrix_]:=Module[{
	fak=2I*Sinh[Sl2MatrixEXPparamInvers1[matrix]]//FullSimplify,xx,yy},
	xx=(matrix[[1,2]]+matrix[[2,1]])/fak//Simplify;
	yy=(matrix[[1,2]]-matrix[[2,1]])/fak//Simplify;
	{Sl2MatrixEXPparamInvers1[matrix],
		I*xx/Sqrt[1-yy^2]//FullSimplify//PowerExpand//ArcSin,
		yy//ArcSin}]

invariantmetricMatrixEXP[ax_][tx_][sx_]:=
	(sx[[2]]*tx[[2]]+(-1+E^(2*ax[[1]]))^2*Cos[2*ax[[3]]]*sx[[2]]*tx[[2]]+
	2*sx[[3]]*tx[[3]]+E^(2*ax[[1]])*(8*sx[[1]]*tx[[1]]-2*sx[[2]]*tx[[2]]-
	4*sx[[3]]*tx[[3]])+E^(4*ax[[1]])*(sx[[2]]*tx[[2]]+2*sx[[3]]*tx[[3]]))/
	(8*E^(2*ax[[1]]))//Simplify

invariantmetricMatrixEXP[a1_,a2_,a3_][t1_,t2_,t3_][s1_,s2_,s3_]:=
	invariantmetricMatrixEXP[{a1,a2,a3}][{t1,t2,t3}][{s1,s2,s3}]


invariantmetricTensorMatrixEXP[ax_]:={{1,0,0},
	{0,((-1+E^(2*ax[[1]]))^2*Cos[ax[[3]]]^2)/(4*E^(2*ax[[1]])),0},
	{0,0,(-1+E^(2*ax[[1]]))^2/(4*E^(2*ax[[1]]))}}//Simplify

invariantmetricTensorMatrixEXP[r_,u_,v_]:=invariantmetricTensorMatrixEXP[{r,u,v}]

gammaMatrixEXP[i_,j_,k_][point_]:=
	christoffelSymbols[i,j,k][invariantmetricTensorMatrixEXP][point]//Simplify

gammaMatrixEXP[i_,j_,k_][a_,b_,c_]:=gammaMatrixEXP[i,j,k][{a,b,c}]

covDerivativeMatrixEXP[xx_,yy_][point_]:=Module[{
	x=xx[point[[1]],point[[2]],point[[3]]],
	y=yy[point[[1]],point[[2]],point[[3]]]},
(*Richtungsableitung der Koeffizienten von yy nach xx + Überschiebung
(ohne Ableitung) der gammaMatrixEXP[k, i, j][point] mit x[[i]]*y[[j]]*)
	Table[Sum[x[[i]]*D[y[[k]],point[[i]]]//Simplify,
	{i,3}]+Sum[x[[i]]*y[[j]]*gammaMatrixEXP[k,i,j][point]//Simplify,
	{i,3},{j,3}],{k,3}]//Simplify]

covDerofVectorfieldMatrixEXPalongCurve[gamma_,vec_][z_]:=Module[{
	tangent=D[gamma[z],z]//Simplify},
	Table[
		Sum[gammaMatrixEXP[i,j,k][gamma[z]]*tangent[[j]]*vec[z][[k]],{j,3},{k,3}],
		{i,3}]+D[vec[z],z]]

highercovDerMatrixEXPofCurve[1][gamma_][t_]:=D[gamma[t],t]//Simplify

highercovDerMatrixEXPofCurve[n_Integer][gamma_][t_]:=
	covDerofVectorfieldMatrixEXPalongCurve[gamma,
		highercovDerMatrixEXPofCurve[n-1][gamma][#]&][t]//Together


nullcurveToHermiteanmodel[mm_][u_,v_]:=
	hyperbolicComplexExpand[ComplexExpand[mm[u+I*v].Conjugate[Transpose[mm[u+I*v]]]]]

nullcurveToHermiteanmodelPolar[mm_][u_,v_]:=
	hyperbolicComplexExpand[ComplexExpand[mm[u*Exp[I*v]].Conjugate[Transpose[mm[u*Exp[I*v]]]]]]

(****************************
nullcurveToHermiteanmodelX[mm_][u_,v_]:=Simplify[ComplexExpand[mm[u+I*v].
	Conjugate[Transpose[mm[u+I*v]]]]//.hyperbolicComplexargumentrule]//TrigToExp//Simplify;

nullcurveToHermiteanmodelPolarX[mm_][u_,v_]:=Simplify[ComplexExpand[mm[u*Exp[I*v]].
	Conjugate[Transpose[mm[u*Exp[I*v]]]]]//.hyperbolicComplexargumentrule]
********************************)

nullcurveToBallmodel[mm_][u_,v_]:=nullcurveToHermiteanmodel[mm][u,v]//hermitean2by2ToLorentz//
	lorentzmodelToBallmodel//Simplify

nullcurveToBallmodelPolar[mm_][u_,v_]:=nullcurveToHermiteanmodelPolar[mm][u,v]//
	hermitean2by2ToLorentz//lorentzmodelToBallmodel//Simplify
	
nullcurveToUpperhalfSpace[mm_][u_,v_]:=nullcurveToHermiteanmodel[mm][u,v]//
	hermitean2by2ToLorentz//lorentzmodelToUpperhalfSpace//Simplify

nullcurveToUpperhalfSpacePolar[mm_][u_,v_]:=nullcurveToHermiteanmodelPolar[mm][u,v]//
	hermitean2by2ToLorentz//lorentzmodelToUpperhalfSpace//Simplify

drahtrahmenderspaehreX[m_,n_]:=Module[{p=ParametricPlot3D[{Cos[v]Cos[u],Cos[v]Sin[u],Sin[v]}//Evaluate,
	{u,0,2Pi},{v,-Pi/2,Pi/2},DisplayFunction->Identity,PlotPoints->{2m,2n}],q,x,y={}},
	q=p[[1]];l=Length[q];
	Do[(x=q[[i,1]];y=Join[y,
		{Table[Line[{x[[i]],x[[i+1]]}]//Graphics3D,{i,Length[x]-1}],
			{Line[{Last[x],First[x]}]//Graphics3D}}//Flatten]),{i,l}];
	Show[Union[y],Axes->None,Boxed->False,DisplayFunction->Identity]]
	
drahtrahmenderspaehreY[n_,m_]:=Module[{s={Cos[#2]Cos[#1],Cos[#2]Sin[#1],Sin[#2]}&,breiten},
	breiten=Table[s[u,i]//Evaluate,{i,-Pi/2,Pi/2,Pi/n}];
	laengen=Table[s[i,u]//Evaluate,{i,0,2Pi,Pi/m}];
	ParametricPlot3D[Join[breiten,laengen]//Evaluate,{u,0,2Pi},
	Axes->None,Boxed->False,DisplayFunction->Identity]]


drahtrahmen:=drahtrahmenderspaehreY[5,5];

           End[]   (* Geometry`CMCSurfaces`Private` *)

commandsavailableCMCsurfs:=Module[{tt=Names["CMCSurfaces`*"],l,l1,teil1,teil2},
l=Length[tt];If[Mod[l,2]==0,l1=Floor[l/2],l1=Floor[l/2]+1];
teil1=Take[tt,l1];teil2=Complement[tt,teil1];
If[Mod[l,2]==1,AppendTo[teil2,""],{}];
Transpose[{teil1,teil2}]//TableForm]

Protect[ballmodelPlot,ballmodelPlotPolar,upperHalfspacePlot,upperHalfspacePlotPolar,
	Sl2CFrameMeromorphicToSl2CModified,Sl2CFrameMeromorphicToSl2CModified1,
	Sl2CFrameMeromorphicToSl2CModified2,BianchiCaloSmallDouble,
	Sl2CFrameMeromorphic,Sl2CFrameMeromorphicInvers,Sl2CFrameMeromorphicInvers1,
	Sl2CFrameMeromorphicInvers2,Sl2CFrameMeromorphicInverswithConstants,
	Sl2CFrameMeromorphicInverswithConstants1,Sl2CFrameMeromorphicInverswithConstants2,
	hyperbolicadjointMatrix,hyperbolicComplexargumentrule,
	hyperbolicComplexExpand,hyperbolicCross,hyperbolicCrosswithCheck,
	hyperbolicCrossX,hyperbolicSurfaceNormalInhyperbolicPolarCoords,
	hyperbolicSurfaceNormalVector,hyperbolicSurfaceNormalVectorwithCheck,
	hyperbolicOrthogonalProjection,
	hyperbolicTangentVectorofH3,hyperbolicTangentVectorofH3Invers,hyperbolicunitNormal,
	hyperbolicE,hyperbolicF,hyperbolicG,hyperbolicfirstFF,hyperbolicL,
	hyperbolicM,hyperbolicN,hyperbolicsecondFF,hyperbolicsecondFFdirect,
	hyperbolicGaussiancurvature,hyperbolicMeancurvature,hyperbolicLeviCivita,
	hyperbolicWeingartenmap,
	lorentzToHermitean2by2,hermitean2by2ToLorentz,
	llEukl,llLoren,lorentzGruppe,lorentzLength,lorentzmetric,lorentzMetrik,
	lorentzmodelToBallmodel,ballmodelToLorentzmodel,
	upperhalfSpaceToBallmodel,ballmodelToUpperhalfSpace,upperhalfSpaceToLorentzmodel,
	lorentzmodelToUpperhalfSpace,lorentzianTypeSurface,
	nullcurveToBallmodel,nullcurveToBallmodelPolar,nullcurveToHermiteanmodel,
	nullcurveToHermiteanmodelPolar,nullcurveToUpperhalfSpace, nullcurveToUpperhalfSpacePolar,
	drahtrahmenderspaehreX,drahtrahmenderspaehreY,drahtrahmen,
	lorentzianTypeSurfaceModified,lorentzpart,normalofH3,
	Sl2KANparam,Sl2CToSO13,Sl2KANparamInvers1,
	Sl2KANparamInvers2,Sl2KANparamInvers3,Sl2KANparamInvers,
	invariantmetricKAN,gammaKAN,gammaKANcollection,covDerivativeKAN,
	highercovDerKANofCurve,covDerofVectorfieldKANalongCurve,
	basicFunctionG,basicFunctionOmega,basicFunctionGMeromorphic,basicFunctionOmegaMeromorphic,
	basicFunctionGModified,basicFunctionOmegaModified,
	Sl2Framerule,Sl2Framerule4,Sl2CAction,toBryantframeData,cmcCPPKAN,brKappa,
	tangentVectorKAN1,tangentVectorKAN2,tangentVectorKAN3,
	Sl2MatrixEXPparam,paramSl2MatrixEXPparamInvers,
	Sl2MatrixEXPparamInvers1,Sl2MatrixEXPparamInvers2,
	Sl2MatrixEXPparamInvers3,invariantmetricMatrixEXP,
	invariantmetricTensorMatrixEXP,gammaMatrixEXP,covDerivativeMatrixEXP,
	covDerofVectorfieldMatrixEXPalongCurve,highercovDerMatrixEXPofCurve,
	Sl2KANparamDifferentialInvers,Sl2KANparamDifferential,Sl2KANparamInversXX,
	Sl2KANparamInversXX1,Sl2KANparamInversXX2,Sl2KANparamDifferentialInversXX,
	Sl2KANparamDifferentialInversXX1,Sl2KANparamDifferentialInversXX2,
	matrixOfScalarproducts,schwarzDerCMC,bbcan,partielIntegrationbbcan,
	aFunForEqualG,aFunModifiedForEqualG,
	nullcurveToBryantdata,nullcurveToBryantdata1,nullcurveToBryantdata2,
	nullcurveToModifiedData1,nullcurveToModifiedData2,nullcurveToModifiedData,
	Sl2CFrameBR,Sl2CFrame,Sl2CFrameModified,Sl2CFrameBianchiCaloSmall,
	auxBianchiCaloSmall,BianchiCaloSmallFrame,
	covDerVectorKAN1,covDerVectorKAN2,covDerVectorKAN3,covDerVectorKAN4,covDerVectorKAN5,
	cppKAN2,varexplicitKANcan,varexplicitNullKANcan,canKANFunctionOmega,canKANFunctionG,
	commutatorKAN,commutatorKANoriginal,
	spur,commutator,adjointRepresentation,
	cmcKappaRulecan,cmcKappaRule,cmcCPPRule,
	tocmcKappacan,tocmcKappa,
	wurzelausdruck,determineOrder,determineOrderBasic]


EndPackage[] (*CMCSurfaces` *)


Print["For a list of available commands type\n 'commandsavailableCMCsurfs'."]

Print["Type findString[s] to find commands whose names contain the string s."]

findString[string_String] := Module[{pp = StringJoin["*", string, "*"]},
    Select[Flatten[commandsavailableCMCsurfs[[1]]],
      StringMatchQ[#, pp] == True &]]
findString[s_Symbol]:=findString[ToString[s]]

