/**	XLobachevskiy	**/

/*A:	Paul C Abbott	*/
/*S:	University of Western Australia	*/
/*D:	March 1986	*/

/*	Lobachevskiy and Clausen Integrals as given by GR 8.26 and	*/
/*	AS 27.8 and my notes of 18/3/86. Uses the Bernoulli numbers.	*/

<XBerV
Lob_:Cl_:Tier

/*	Special Values	*/

Lob[0]:0
Lob[Pi]:N[Pi Log[2]]
Lob[($a_=Intp[2$a])Pi]:$a N[Pi Log[2]]
Lob[Pi/4]:N[Pi/4 Log[2]-1/2 (0.915966)]  	/*  Cl(Pi/2) from AS  */

Cl[0]:Cl[Pi]:0
Cl[Pi/2]:0.915966

/*	Define summand for Lob and/or Clausen Integral	*/

Poc[$x,$n]:Prod[$x+%#i,{%#i,0,$n-1}]
exp[$x,$n]::(-1)^($n-1) Ber[2$n] (2$x)^(2$n+1)/Poc[1,2$n]/(2$n(2$n+1))/2

/*	Lob[x] for 0 < x < Pi/4	*/

Lob[$x_=(0<N[$x]<N[Pi/4]),$max,$test]::\
  Sum[exp[N[$x],%#i] (2^(2%#i)-1),{%#i,1,$max,,,N[$[2]/$[3]]<$test}]

/*	Lob[x] for Pi/4 < x < Pi/2	*/

Lob[$x_=(N[Pi/4]<N[$x]<N[Pi/2]),$max,$test]::\
  N[Lob[Pi/2] + (Pi/2-$x)(Log[Pi/2-$x]-1)] -\
  Sum[exp[N[P%#i/2-$x],%#i],{%#i,1,$max,,,N[$[2]/$[3]]<$test}]

/*	Lob[x] for Pi/2 < x < Pi	*/

Lob[$x_=(N[Pi/2]<N[$x]<N[Pi]),$max,$test]::Lob[Pi]-Lob[N[Pi-$x],$max,$test]

/*	Lob[x] for x > Pi or x < 0	*/

Lob[$x_=(N[$x]>N[Pi] | N[$x]<0),$max,$test]::N[($x-Mod[$x,N[Pi]]) Log[2]] +\
	Lob[Mod[$x,N[Pi]],$max,$test]

/*	Default limits for numerical evaluation	*/

Lob[$x]::Lob[$x]:N[Lob[$x,20,0.0001]]

/*	Cl[$x] for 0 < $x < Pi/2	*/

Cl[$x_=(0<N[$x]<N[Pi/2]),$max,$test]:: -$x(Log[$x]-1)+\
  Sum[exp[$x,%#i]/2^(2%#i),{%#i,1,$max,,,N[$[2]/$[3]]<$test}]

/*	Cl[$x] for Pi/2 < $x < Pi	*/

Cl[$x_=(N[Pi/2]<N[$x]<N[Pi]),$max,$test]:: (Pi-$x)Log[2]-\
  Sum[exp[Pi-$x,%#i](1-2^(-2%#i)),{%#i,1,$max,,,N[$[2]/$[3]]<$test}]

/*	Default limits for numerical evaluation	*/

Cl[$x]::N[Cl[$x,20,0.0001]]

