cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c     Program to solve eigenvalue problem for Schrodinger equation 
c     with Woods-Saxon potential using LPM[4,2] and step adjusting
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
        implicit double precision (a-h,o-z)
	include 'params.dat'
        parameter(kmax=30)
	parameter (ngrad=4,ngrad1=6)
        common /part/ xin(nind),v(0:ngrad,nind)
	dimension p(0:ngrad1),xad(nind)
	common /fener/ f0,f1,en
	common /actdim/ nin
        parameter (maf=2,mbf=5,mcf=4,mef=5,mff=3,mgf=4)
	common /fcorr/ af(0:maf,nind),bf(0:mbf,nind),cf(0:mcf,nind),
     +  ef(0:mef,nind),ff(0:mff,nind),gf(0:mgf,nind)
	parameter (msa=10)
	double precision is,js,ks,ls,ms,ns
	common /scorr/ as(0:msa,nind),bs(0:msa,nind),cs(0:msa,nind),
     #  ds(0:msa,nind),es(0:msa,nind),fs(0:msa,nind),gs(0:msa,nind),
     #  hs(0:msa,nind),is(0:msa,nind),js(0:msa,nind),ks(0:msa,nind),
     #  ls(0:msa,nind),ms(0:msa,nind),ns(0:msa,nind),os(0:msa,nind),
     #  ps(0:msa,nind)
	common /valpi/ pi
	common /matpoint/ xmatch,match
        common /sercf/ dk(kmax),ck(kmax)
	common /valcorr0/ u0,v0,du0,dv0
	common /valcorr1/ u1,v1,du1,dv1
	dimension eref(14)
	common /legend/ x,h,k
	external fct
	data xl/0.d0/,xu/1.d0/
c    Reference eigenvalues (see L.Gr.Ixaru: Numerical Methods for 
c    differential equation and applications, Reidel 1984)
        data eref/
     !-49.45778872808258d0,-48.14843042000636d0,-46.29075395446608d0,
     !-43.96831843181423d0,-41.23260777218022d0,-38.12278509672792d0,
     !-34.67231320569966d0,-30.91224748790885d0,-26.87344891605987d0,
     !-22.58860225769321d0,-18.09468828212442d0,-13.43686904025008d0,
     !-8.67608167073655d0,-3.90823248120623d0/

	external fix
	external pot
        pi=4.d0*datan(1.d0)
        pi2=pi**2

c    Choosing the step sizes in terms of a given tolerance

        emax=-49.5d0
        emin=-3.d0

	i=1
	xad(i)=x0
4002	x=xad(i)
	h=step
	xnext=x+h
	if(xnext.ge.xmax) h=xmax-x 
	ind=0
4001    continue
	h7=h**7
	h8=h*h7
	h9=h*h8
	h10=h*h9
	h11=h*h10
	h12=h*h11
	h13=h*h12
	h14=h*h13
	do k=0,ngrad1
        call quadg16(xl,xu,fct,cofk)
	p(k)=(2*k+1)*cofk/h**k
	enddo

        z1=abs(p(0)-emin)
        z2=abs(p(0)-emax)
        zmax=z1
        if(z2.gt.zmax) zmax=z2
        pit=pi2/h**2
        if(zmax.lt.pit) then
        z=zmax
        else
        z=pit
        endif
        z2=z*z
	z3=z*z2

	delu=(-h13*p(5)/540540.d0)*z3+(-h11*p(5)/20790.d0
     #  +h14*p(5)*p(1)/1081080.d0)*z2+(41.d0*h14*p(3)*p(5)/
     #  1081080.d0-h13*p(1)*p(6)/54054.d0-h13*p(5)*p(2)/135135.d0
     #  +h14*p(2)*p(6)/180180.d0+h12*p(5)*p(1)/41580.d0+23.d0*h14
     #  *p(2)**3/75675600.d0)*z+(-h11*p(5)*p(2)/3465.d0+
     #  19.d0*h13*p(5)*
     #  p(1)**2/1081080.d0+h12*p(2)**3/138600.d0+h12*p(5)*p(3)/
     #  2772.d0+h14*p(6)*p(4)/5148.d0-17.d0*h14*p(2)*p(5)*p(1)/
     #  540540.d0-h13*p(3)*p(2)**2/1081080.d0
     #  +5.d0*h13*p(5)*p(4)/36036.d0-
     #  h14*p(5)**2/5148.d0-h14*p(2)*p(3)**2/103950.d0-5.d0*h13*
     #  p(3)*p(6)/36036.d0+h14*p(6)*p(1)**2/154440.d0+29.d0*h14*
     #  p(4)*p(2)**2/1801800.d0)

	delup=(h13*p(6)/270270.d0)*z3+(h13*p(5)*p(1)/360360.d0)
     #  *z2+(h11*p(5)*p(1)/5940.d0+3.d0*h13*p(3)*p(5)/20020.d0+
     #  h13*p(2)*p(6)/16380.d0-h13*p(2)**3/150150.d0)*z+(-h13*
     #  p(5)**2/2574.d0-h11*p(2)**3/6930.d0+h11*p(5)*p(3)/1386.d0+
     #  23.d0*h13*p(4)*p(2)**2/270270.d0-h13*p(2)*p(3)**2/13860.d0+
     #  h13*p(6)*p(4)/2574.d0+h13*p(6)*p(1)**2/77220.d0-43.d0*h13*
     #  p(2)*p(5)*p(1)/270270.d0)

	delv=(-h13*p(6)/270270.d0)*z2+(-h13*p(5)*p(1)/1081080.d0)
     #  *z+(-h11*p(5)*p(1)/8316.d0+h13*p(2)**3/1351350.d0+h13*p(3)*
     #  p(5)/6006.d0-h13*p(2)*p(6)/20020.d0)            

	delvp=(h13*p(5)/540540.d0)*z3+(h11*p(5)/20790.d0+h14*p(5)*
     #  p(1)/1081080.d0)*z2+(h13*p(5)*p(2)/135135.d0+41.d0*h14*p(3)*
     #  p(5)/1081080.d0+h14*p(2)*p(6)/180180.d0+h13*p(1)*p(6)/54054.d0
     #  +23.d0*h14*p(2)**3/75675600.d0+h12*p(5)*p(1)/41580.d0)*z+(
     #  h11*p(5)*p(2)/3465.d0-h14*p(2)*p(3)**2/103950.d0+h12*p(2)**3/
     #  138600.d0+h12*p(5)*p(3)/2772.d0+h14*p(6)*p(4)/5148.d0-17.d0*h14
     #  *p(2)*p(5)*p(1)/540540.d0-5.d0*h13*p(5)*p(4)/36036.d0+5.d0*h13*
     #  p(3)*p(6)/36036.d0-19.d0*h13*p(5)*p(1)**2/1081080.d0-h14*p(5)
     #  **2/5148.d0+h13*p(3)*p(2)**2/1081080.d0+h14*p(6)*p(1)**2/
     #  154440.d0+29.d0*h14*p(4)*p(2)**2/1801800.d0)

	adelu=abs(delu)
	adelup=h*abs(delup)
	adelv=abs(delv)/h
	adelvp=abs(delvp)
	devm=adelu
	if(adelup.gt.devm) devm=adelup
	if(adelv.gt.devm) devm=adelv
	if(adelvp.gt.devm) devm=adelvp
	hnew=h*(tol/devm)**(1.d0/10.d0)
	test=abs(hnew/h-1.d0)
	if(test.gt.0.1d0)then
	h=hnew
	go to 4001
	else
	i=i+1
	if(i.gt.nind) pause
	xnext=x+h
	if(xnext.ge.xmax) then 
	xad(i)=xmax
	h=xmax-x
	go to 4003
	endif
	xad(i)=x+h
	go to 4002	
	endif

4003	continue
	nin=i



	do i=1,nin
	xin(i)=xad(i)
	write(16,1500) i,xin(i),pot(xin(i))
1500    format(1x,i4,2x,f8.4,2x,d14.6)
	enddo

c       Potential approximation
        call pin(xin,v,nin)

	open(3,file='pot.out')

c       Coefficients of perturbation corrections

	do i=1,nin-1
	h=xin(i+1)-xin(i)
	s=h/10.d0
        h2=h*h
        h3=h*h2
        h4=h*h3
        h5=h*h4
        h6=h*h5
        h7=h*h6
        h8=h*h7
        h9=h*h8
        h10=h*h9
        h11=h*h10
        h12=h*h11
        h13=h*h12
        h14=h*h13
        h15=h*h14
        h16=h*h15
        h17=h*h16
        h18=h*h17
        h19=h*h18
        h20=h*h19
        h21=h*h20
        h22=h*h21
        h23=h*h22
        h24=h*h23
	f0=v(0,i)-v(1,i)*h
	f1=2.d0*v(1,i)
	finv=1.d0/f1

c       analytic form of first order correction
      
      af(0,i)=-2.d0/315.d0*h*(189*v(2,i)+560*v(4,i)*h2-
     #270*v(3,i)*h)*finv
      af(1,i)=-8.d0/21.d0*h*(-9*v(3,i)+28*v(4,i)*h)*finv
      af(2,i)=-32.d0/3.d0*finv*v(4,i)*h

      bf(0,i)=(6.d0/5.d0*v(2,i)-6*v(3,i)*h+18*v(4,i)*h2)*finv
      bf(1,i)=-v(4,i)*h4+v(3,i)*h3-v(2,i)*h2+
     #(-12*v(3,i)+84*v(4,i)*h)*finv
      bf(2,i)=-40.d0/3.d0*v(4,i)*h3-4*v(2,i)*h+8*v(3,i)*h2+
     #896.d0/9.d0*v(4,i)*finv
      bf(3,i)=-16.d0/5.d0*v(2,i)-48*v(4,i)*h2+16*v(3,i)*h
      bf(4,i)=64.d0/7.d0*v(3,i)-64*v(4,i)*h
      bf(5,i)=-256.d0/9.d0*v(4,i)
    
      cf(0,i)=(v(2,i)*h2/5+v(4,i)*h4/9-v(3,i)*h3/7)*finv+
     #(-260.d0/9.d0*v(4,i)*h+60.d0/7.d0*v(3,i))/f1**2
      cf(1,i)=(40.d0/9.d0*v(4,i)*h3-24.d0/7.d0*v(3,i)*h2+12.d0/5.d0*
     #v(2,i)*h)*finv-800.d0/9.d0*v(4,i)/f1**2
      cf(2,i)=(16.d0/5.d0*v(2,i)+80.d0/3.d0*v(4,i)*h2-
     #80.d0/7.d0*v(3,i)*h)*finv
      cf(3,i)=(448.d0/9.d0*v(4,i)*h-64.d0/7.d0*v(3,i))*finv
      cf(4,i)=256.d0/9.d0*v(4,i)*finv

      ef(0,i)=-h4*v(3,i)/7+v(4,i)*h5/9+h3*v(2,i)/5+(6*v(3,i)*h-
     #6.d0/5.d0*v(2,i)-302.d0/9.d0*v(4,i)*h2)*finv
      ef(1,i)=13.d0/5.d0*v(2,i)*h2-25.d0/7.d0*v(3,i)*h3+41.d0/
     #9.d0*v(4,i)*h4+(-1036.d0/9.d0*v(4,i)*h+12*v(3,i))*finv
      ef(2,i)=280.d0/9.d0*v(4,i)*h3-104.d0/7.d0*v(3,i)*h2+28.d0/
     #5.d0*v(2,i)*h-896.d0/9.d0*v(4,i)*finv
      ef(3,i)=688.d0/9.d0*v(4,i)*h2-144.d0/7.d0*v(3,i)*h+
     #16.d0/5.d0*v(2,i)
      ef(4,i)=704.d0/9.d0*v(4,i)*h-64.d0/7.d0*v(3,i)
      ef(5,i)=256.d0/9.d0*v(4,i)

      ff(0,i)=(-28.d0/9.d0*v(4,i)*h3-4.d0/5.d0*v(2,i)*h+16.d0/7.d0*
     #v(3,i)*h2)*finv+280.d0/9.d0*v(4,i)/f1**2
      ff(1,i)=(32.d0/7.d0*v(3,i)*h-8.d0/5.d0*v(2,i)-40.d0/3.d0*
     #v(4,i)*h2)*finv
      ff(2,i)=(32.d0/7.d0*v(3,i)-64.d0/3.d0*v(4,i)*h)*finv
      ff(3,i)=-128.d0/9.d0*v(4,i)*finv

      gf(0,i)=(-v(2,i)*h2+v(3,i)*h3-v(4,i)*h4)*finv+(60*v(4,i)*h-
     #60.d0/7.d0*v(3,i))/f1**2
      gf(1,i)=(-40.d0/3.d0*v(4,i)*h3-4*v(2,i)*h+8*v(3,i)*h2)*finv+
     #800.d0/9.d0*v(4,i)/f1**2
      gf(2,i)=(-16.d0/5.d0*v(2,i)-48*v(4,i)*h2+16*v(3,i)*h)*finv
      gf(3,i)=(64.d0/7.d0*v(3,i)-64*v(4,i)*h)*finv
      gf(4,i)=-256.d0/9.d0*v(4,i)*finv

c       analytic form of second order correction

        finv=1.d0/f1
	finv2=finv**2
	finv3=finv**3
	finv4=finv**4

	v22=v(2,i)**2
	v33=v(3,i)**2
	v44=v(4,i)**2
	v23 =v(2,i)*v(3,i)
	v24 =v(2,i)*v(4,i)
	v34 =v(4,i)*v(3,i)
	v4 = v(4,i)
	v3 = v(3,i)

c  u2=sum(a[k]*q^k*u0(h)+b[k]*q^k*v0(h)+c[k]*q^k*du0(h)+d[k]*q^k*dv0(h))
c  du2=sum(e[k]*q^k*u0(h)+f[k]*q^k*v0(h)+g[k]*q^k*du0(h)+h[k]*q^k*dv0(h))
c  v2=sum(i[k]*q^k*u0(h)+j[k]*q^k*v0(h)+k[k]*q^k*du0(h)+l[k]*q^k*dv0(h))
c  dv2=sum(m[k]*q^k*u0(h)+n[k]*q^k*v0(h)+o[k]*q^k*du0(h)+p[k]*q^k*dv0(h))


	do k=0,msa
	as(k,i)=0.d0
	bs(k,i)=0.d0
	cs(k,i)=0.d0
	ds(k,i)=0.d0
	es(k,i)=0.d0
	fs(k,i)=0.d0
	gs(k,i)=0.d0
	hs(k,i)=0.d0
	is(k,i)=0.d0
	js(k,i)=0.d0
	ks(k,i)=0.d0
	ls(k,i)=0.d0
	ms(k,i)=0.d0
	ns(k,i)=0.d0
	os(k,i)=0.d0
	ps(k,i)=0.d0
	enddo
	

        vv2 = v(2,i)    

      as(0,i)=(v44*h9/162+h7*vv2*v4/45-h6*vv2*v3/35-v4*h8*v3/63+h5*v22
     #/50+h
     #7*v33/98)*Finv+(344.D0/15.D0*vv2*v3*h3-180388.D0/3465.D0*vv2*v4*h4
     #-4870.D0/231.D0*v33*h4+100312.D0/1287.D0*v3*h5*v4-1605074.D0/27027
     #.D0*v44*h6-132.D0/35.D0*v22*h2)*Finv2+(-72.D0/7.D0*v23+66595840.D0
     #/11583.D0*v44*h3+18720.D0/77.D0*v33*h+4824.D0/11.D0*vv2*v4*h-80230
     #40.D0/3003.D0*v3*h2*v4)*Finv3
      as(1,i)=(-128.D0/63.D0*v3*h7*v4-72.D0/35.D0*vv2*h5*v3+v33*h6+v44*h
     #8+v
     #22*h4+98.D0/45.D0*vv2*h6*v4)*Finv+(-1518128.D0/3465.D0*vv2*v4*h3-4
     #0424.D0/231.D0*v33*h3+856.D0/7.D0*vv2*v3*h2-8252264.D0/9009.D0*v44
     #*h5+8067680.D0/9009.D0*v3*v4*h4-1992.D0/175.D0*v22*h)*Finv2+(87613
     #360.D0/3861.D0*v44*h2+320.D0/3.D0*v24+720.D0/7.D0*v33-899200.D0/14
     #3.D0*v3*v4*h)*Finv3
      as(2,i)=(-24*vv2*h4*v3-128.D0/3.D0*v3*h6*v4+80.D0/3.D0*v44*h7+8*v2
     #2*h
     #3+1568.D0/45.D0*vv2*h5*v4+16*v33*h5)*Finv+(-96.D0/25.D0*v22-643936
     #.D0/495.D0*vv2*v4*h2+6752.D0/35.D0*vv2*v3*h-265344.D0/539.D0*v33*h
     #2+34933984.D0/9009.D0*v3*v4*h3-776896.D0/143.D0*v44*h4)*Finv2+(113
     #868160.D0/3861.D0*v44*h-1920*v3*v4)*Finv3
      as(3,i)=(3136.D0/15.D0*vv2*v4*h4-512.D0/5.D0*vv2*v3*h3-1024.D0/3.D
     #0*v
     #3*h5*v4+96*v33*h4+112.D0/5.D0*v22*h2+2464.D0/9.D0*v44*h6)*Finv+(-7
     #82464.D0/495.D0*vv2*v4*h-292352.D0/539.D0*v33*h+69547264.D0/9009.D
     #0*v3*h2*v4+384.D0/5.D0*v23-184616192.D0/11583.D0*v44*h3)*Finv2+716
     #800.D0/81.D0*v44*Finv3
      as(4,i)=(-28160.D0/21.D0*v3*v4*h4-6912.D0/35.D0*vv2*v3*h2+1408*v44
     #*h5
     #+1792.D0/3.D0*vv2*v4*h3+1920.D0/7.D0*v33*h3+128.D0/5.D0*v22*h)*Fin
     #v+(63272960.D0/9009.D0*v3*v4*h-94111232.D0/3861.D0*v44*h2-9216.D0/
     #49.D0*v33-28672.D0/45.D0*v24)*Finv2
      as(5,i)=(39424.D0/45.D0*vv2*v4*h2-180224.D0/63.D0*v3*v4*h3-6144.D0
     #/35
     #.D0*vv2*v3*h+256.D0/25.D0*v22+2816.D0/7.D0*v33*h2+36608.D0/9.D0*v4
     #4*h4)*Finv+(-71118848.D0/3861.D0*v44*h+145408.D0/63.D0*v3*v4)*Finv
     #2
      as(6,i)=(-2048.D0/35.D0*v23+186368.D0/27.D0*v44*h3+2048.D0/7.D0*v3
     #3*h
     #+28672.D0/45.D0*vv2*v4*h-212992.D0/63.D0*v3*h2*v4)*Finv-434176.D0/
     #81.D0*Finv2*v44
      as(7,i)=(8192.D0/45.D0*v24+4096.D0/49.D0*v33+20480.D0/3.D0*v44*h2
     #-131
     #072.D0/63.D0*v3*v4*h)*Finv
      as(8,i)=-32768.D0/63.D0*v4*Finv*(v3-7*v4*h)
      as(9,i)=65536.D0/81.D0*Finv*v44
     

      bs(0,i)=(vv2*h5*v3+v3*h7*v4-v44*h8/2-vv2*h6*v4-v22*h4/2-v33*h6/2)
     #*Fin
     #v+(684.D0/7.D0*v33*h3+500*v44*h5-2448.D0/35.D0*vv2*v3*h2-10328.D0/
     #21.D0*v3*v4*h4+204.D0/25.D0*v22*h+3512.D0/15.D0*vv2*v4*h3)*Finv2+(
     #-14760.D0/77.D0*v33+155200.D0/33.D0*v3*v4*h-169960.D0/11.D0*v44*h2
     #-13328.D0/33.D0*v24)*Finv3
      bs(1,i)=(738.D0/35.D0*vv2*h4*v3+2356.D0/63.D0*v3*h6*v4-208.D0/9.
     #D0*v4
     #4*h7-34.D0/5.D0*v22*h3-1346.D0/45.D0*vv2*h5*v4-100.D0/7.D0*v33*h5)
     #*Finv+(444.D0/25.D0*v22+80744.D0/45.D0*vv2*v4*h2-11448.D0/35.D0*vv
     #2*v3*h+5172.D0/7.D0*v33*h2-344152.D0/63.D0*v3*v4*h3+68620.D0/9.D0*
     #v44*h4)*Finv2+(-2172800.D0/33.D0*v44*h+310400.D0/33.D0*v3*v4)*Finv
     #3
      bs(2,i)=(-13472.D0/45.D0*vv2*v4*h4+1048.D0/7.D0*vv2*v3*h3+31496.D0
     #/63
     #.D0*v3*h5*v4-1000.D0/7.D0*v33*h4-164.D0/5.D0*v22*h2-10720.D0/27.D0
     #*v44*h6)*Finv+(202976.D0/45.D0*vv2*v4*h+38912.D0/21.D0*v33*h-14031
     #68.D0/63.D0*v3*h2*v4-39776.D0/105.D0*v23+3642656.D0/81.D0*v44*h3)*
     #Finv2-64702400.D0/891.D0*v44*Finv3
      bs(3,i)=(-4352.D0/7.D0*v33*h3-58816.D0/45.D0*vv2*v4*h3+188896.D0
     #/63.D
     #0*v3*v4*h4+15616.D0/35.D0*vv2*v3*h2-28192.D0/9.D0*v44*h5-1504.D0/2
     #5.D0*v22*h)*Finv+(35254336.D0/297.D0*v44*h2+1710848.D0/495.D0*v24+
     #324416.D0/231.D0*v33-3610880.D0/99.D0*v3*v4*h)*Finv2
      bs(4,i)=(-805696.D0/63.D0*v44*h4-855808.D0/315.D0*vv2*v4*h2+1996
     #8.D0/
     #35.D0*vv2*v3*h-63296.D0/49.D0*v33*h2-6208.D0/175.D0*v22+189440.D0/
     #21.D0*v3*v4*h3)*Finv+(546875392.D0/3861.D0*v44*h-26236928.D0/1287.
     #D0*v3*v4)*Finv2
      bs(5,i)=(894976.D0/63.D0*v3*h2*v4-2338816.D0/81.D0*v44*h3-185344
     #.D0/1
     #47.D0*v33*h-119296.D0/45.D0*vv2*v4*h+27136.D0/105.D0*v23)*Finv+721
     #021952.D0/11583.D0*Finv2*v44
      bs(6,i)=(7751680.D0/693.D0*v3*v4*h-10812416.D0/297.D0*v44*h2-4833
     #28.D
     #0/495.D0*v24-750592.D0/1617.D0*v33)*Finv
      bs(7,i)=8192.D0/27027.D0*v4*Finv*(-79177*v4*h+11454*v3)
      bs(8,i)=-74596352.D0/11583.D0*Finv*v44
      

      cs(0,i)=(-40396.D0/9009.D0*v3*h6*v4+13798.D0/3465.D0*vv2*h5*v4+6
     #6184.
     #D0/27027.D0*v44*h7+452.D0/231.D0*v33*h5-358.D0/105.D0*vv2*h4*v3+46
     #.D0/35.D0*v22*h3)*Finv2+(-324.D0/35.D0*v22-39220.D0/231.D0*v33*h2-
     #100763420.D0/81081.D0*v44*h4-296168.D0/693.D0*vv2*v4*h2+1334680.D0
     #/1287.D0*v3*v4*h3+280.D0/3.D0*vv2*v3*h)*Finv3+(21526400.D0/1053.D0
     #*v44*h-184000.D0/39.D0*v3*v4)*Finv4
      cs(1,i)=(2132.D0/175.D0*v22*h2+2204080.D0/27027.D0*v44*h6+92128.
     #D0/11
     #55.D0*vv2*v4*h4-4936.D0/105.D0*vv2*v3*h3-349736.D0/3003.D0*v3*h5*v
     #4+424.D0/11.D0*v33*h4)*Finv2+(-72640.D0/77.D0*v33*h-75232.D0/33.D0
     #*vv2*v4*h+9158560.D0/1001.D0*v3*h2*v4+5920.D0/21.D0*v23-179902880.
     #D0/11583.D0*v44*h3)*Finv3+56302400.D0/1053.D0*v44*Finv4
      cs(2,i)=(-1536.D0/7.D0*vv2*v3*h2+3015392.D0/3003.D0*v44*h5-98298
     #56.D0
     #/9009.D0*v3*v4*h4+6304.D0/175.D0*v22*h+422272.D0/1617.D0*v33*h3+37
     #7792.D0/693.D0*vv2*v4*h3)*Finv2+(-286208.D0/99.D0*v24-1926080.D0/1
     #617.D0*v33-242770240.D0/3861.D0*v44*h2+209795840.D0/9009.D0*v3*v4*
     #h)*Finv3
      cs(3,i)=(-4520192.D0/1001.D0*v3*v4*h3+457622848.D0/81081.D0*v44*
     #h4+10
     #83904.D0/693.D0*vv2*v4*h2+1207232.D0/1617.D0*v33*h2-8192.D0/21.D0*
     #vv2*v3*h+5312.D0/175.D0*v22)*Finv2+(-1180165120.D0/11583.D0*v44*h+
     #164608000.D0/9009.D0*v3*v4)*Finv3
      cs(4,i)=(-24064.D0/105.D0*v23+188505088.D0/11583.D0*v44*h3+503
     #808.D0/
     #539.D0*v33*h-9095168.D0/1001.D0*v3*h2*v4+323072.D0/165.D0*vv2*
     #v4*h
     #)*Finv2-668154880.D0/11583.D0*v44*Finv3
      cs(5,i)=(683008.D0/1617.D0*v33+96527360.D0/3861.D0*v44*h2-10219
     #52.D0/
     #117.D0*v3*v4*h+438272.D0/495.D0*v24)*Finv2
      cs(6,i)=-8192.D0/81081.D0*v4*Finv2*(-192647*v4*h+31788*v3)
      cs(7,i)=69910528.D0/11583.D0*Finv2*v44

      ds(0,i)=(56.D0/15.D0*vv2*v4*h4+6.D0/25.D0*v22*h2+6.D0/7.D0*v33*h4
     #+2*v
     #44*h6-48.D0/35.D0*vv2*v3*h3-68.D0/21.D0*v3*h5*v4)*Finv2+(6880.D0/2
     #1.D0*v3*h2*v4-104.D0/3.D0*vv2*v4*h+72.D0/7.D0*v23-360.D0/7.D0*v33*
     #h-520*v44*h3)*Finv3
      ds(1,i)=(-v33*h6/7+12.D0/35.D0*vv2*h5*v3-14.D0/45.D0*vv2*h6*v4+16
     #.D0/
     #63.D0*v3*h7*v4-v44*h8/9-v22*h4/5)*Finv+(-8768.D0/63.D0*v3*v4*h4+72
     #.D0/25.D0*v22*h-1032.D0/35.D0*vv2*v3*h2+216.D0/7.D0*v33*h3+1064.D0
     #/9.D0*v44*h5+848.D0/9.D0*vv2*v4*h3)*Finv2+(-720.D0/7.D0*v33-320.D0
     #/3.D0*v24+1600*v3*v4*h-12080.D0/3.D0*v44*h2)*Finv3
      ds(2,i)=(8*vv2*h4*v3-160.D0/27.D0*v44*h7-448.D0/45.D0*vv2*h5*v4-1
     #6.D0
     #/5.D0*v22*h3-32.D0/7.D0*v33*h5+32.D0/3.D0*v3*h6*v4)*Finv+(4640.D0/
     #9.D0*vv2*v4*h2-96*vv2*v3*h+96.D0/25.D0*v22+1248.D0/7.D0*v33*h2-104
     #00.D0/9.D0*v3*v4*h3+108416.D0/81.D0*v44*h4)*Finv2+(-837760.D0/81.D
     #0*v44*h+1920*v3*v4)*Finv3
      ds(3,i)=(-288.D0/7.D0*v33*h4-448.D0/5.D0*vv2*v4*h4-2464.D0/27.D0*
     #v44*
     #h6+128*v3*h5*v4+256.D0/5.D0*vv2*v3*h3-336.D0/25.D0*v22*h2)*Finv+(-
     #384.D0/5.D0*v23+15232.D0/15.D0*vv2*v4*h+2304.D0/7.D0*v33*h+498176.
     #D0/81.D0*v44*h3-11008.D0/3.D0*v3*h2*v4)*Finv2-716800.D0/81.D0*v44*
     #Finv3
      ds(4,i)=(-1024.D0/3.D0*vv2*v4*h3+4608.D0/35.D0*vv2*v3*h2+14080.D0
     #/21.
     #D0*v3*v4*h4-512.D0/25.D0*v22*h-7680.D0/49.D0*v33*h3-5632.D0/9.D0*v
     #44*h5)*Finv+(363520.D0/27.D0*v44*h2+9216.D0/49.D0*v33+28672.D0/45.
     #D0*v24-309248.D0/63.D0*v3*v4*h)*Finv2
      ds(5,i)=(-5632.D0/9.D0*vv2*v4*h2+112640.D0/63.D0*v3*v4*h3+1024.D0
     #/7.D
     #0*vv2*v3*h-256.D0/25.D0*v22-14080.D0/49.D0*v33*h2-183040.D0/81.D0*
     #v44*h4)*Finv+(-145408.D0/63.D0*v3*v4+1122304.D0/81.D0*v44*h)*Finv2
      ds(6,i)=(2048.D0/35.D0*v23-372736.D0/81.D0*v44*h3-12288.D0/49.D0*
     #v33*
     #h-8192.D0/15.D0*vv2*v4*h+53248.D0/21.D0*v3*h2*v4)*Finv+434176.D0/8
     #1.D0*Finv2*v44
      ds(7,i)=(-8192.D0/45.D0*v24-4096.D0/49.D0*v33-143360.D0/27.D0*v44
     #*h2+
     #16384.D0/9.D0*v3*v4*h)*Finv
      ds(8,i)=32768.D0/567.D0*v4*Finv*(9*v3-56*v4*h)
      ds(9,i)=-65536.D0/81.D0*Finv*v44
 
 

      es(0,i)=(1593.D0/385.D0*vv2*h6*v4-13513.D0/3003.D0*v3*h7*v4+871.
     #D0/46
     #2.D0*v33*h6+99.D0/70.D0*v22*h4-71.D0/21.D0*vv2*h5*v3+135371.D0/540
     #54.D0*v44*h8)*Finv+(-14306312.D0/11583.D0*v44*h5-38944.D0/231.D0*v
     #33*h3-36.D0/5.D0*v22*h+9328808.D0/9009.D0*v3*h4*v4-42028.D0/99.D0*
     #vv2*h3*v4+11012.D0/105.D0*vv2*h2*v3)*Finv2+(14760.D0/77.D0*v33+188
     #73400.D0/891.D0*v44*h2+4032.D0/11.D0*v24-49680.D0/11.D0*v4*v3*h)*F
     #inv3
      es(1,i)=(-764.D0/15.D0*vv2*h4*v3+2572.D0/175.D0*v22*h3+2330324.D
     #0/270
     #27.D0*v44*h7+6712.D0/77.D0*vv2*h5*v4+1280.D0/33.D0*v33*h5-51668.D0
     #/429.D0*v3*h6*v4)*Finv+(91370480.D0/9009.D0*v3*v4*h3-1360424.D0/49
     #5.D0*vv2*v4*h2+40672.D0/105.D0*vv2*v3*h-265684.D0/231.D0*v33*h2-19
     #4017996.D0/11583.D0*v44*h4-396.D0/25.D0*v22)*Finv2+(67548320.D0/89
     #1.D0*v44*h-99360.D0/11.D0*v3*v4)*Finv3
      es(2,i)=(2217088.D0/3465.D0*vv2*h4*v4+29702968.D0/27027.D0*v44*h
     #6+871
     #6.D0/175.D0*v22*h2-10810424.D0/9009.D0*v3*h5*v4-28408.D0/105.D0*vv
     #2*h3*v3+475360.D0/1617.D0*v33*h4)*Finv+(5312.D0/15.D0*v23+42154208
     #.D0/1287.D0*v3*v4*h2-906983552.D0/11583.D0*v44*h3-2604832.D0/495.D
     #0*v4*h*vv2-516704.D0/231.D0*v33*h)*Finv2+61942720.D0/891.D0*v44*Fi
     #nv3
      es(3,i)=(1478944.D0/693.D0*vv2*h3*v4+540704.D0/539.D0*v33*h3-1289
     #6.D0
     #/21.D0*vv2*h2*v3+541056448.D0/81081.D0*v44*h5-7189792.D0/1287.D0*v
     #3*h4*v4+11616.D0/175.D0*v22*h)*Finv+(-311744.D0/231.D0*v33-1574272
     #.D0/495.D0*v24+18292096.D0/429.D0*v4*v3*h-1919216320.D0/11583.D0*v
     #44*h2)*Finv2
      es(4,i)=(12253312.D0/3465.D0*vv2*v4*h2-65024.D0/105.D0*vv2*v3*h+2
     #7186
     #56.D0/1617.D0*v33*h2+5312.D0/175.D0*v22+1778311616.D0/81081.D0*v44
     #*h4-11128192.D0/819.D0*v3*v4*h3)*Finv+(-1880431616.D0/11583.D0*v44
     #*h+25065472.D0/1287.D0*v3*v4)*Finv2
      es(5,i)=(1407488.D0/495.D0*v4*h*vv2+2194432.D0/1617.D0*v33*h-1605
     #4681
     #6.D0/9009.D0*v3*v4*h2-24064.D0/105.D0*v23+36775936.D0/891.D0*v44*h
     #3)*Finv-694371328.D0/11583.D0*Finv2*v44
      es(6,i)=(515034112.D0/11583.D0*v44*h2+438272.D0/495.D0*v24+68300
     #8.D0/
     #1617.D0*v33-11958272.D0/1001.D0*v4*v3*h)*Finv
      es(7,i)=-8192.D0/81081.D0*v4*(31788*v3-252385*v4*h)*Finv
      es(8,i)=69910528.D0/11583.D0*Finv*v44
      

      fs(0,i)=(56.D0/15.D0*vv2*h5*v4-68.D0/21.D0*v3*h6*v4+6.D0/25.D0*v2
     #2*h3
     #-48.D0/35.D0*vv2*h4*v3+2*v44*h7+6.D0/7.D0*v33*h5)*Finv+(72.D0/5.D0
     #*vv2*v3*h+928.D0/3.D0*v3*v4*h3-36*v33*h2-36.D0/25.D0*v22-928.D0/15
     #.D0*vv2*v4*h2-604*v44*h4)*Finv2
      fs(1,i)=16.D0/63.D0*v4*h8*v3-14.D0/45.D0*h7*vv2*v4-v44*h9/9-h5*v2
     #2/5+
     #12.D0/35.D0*h6*vv2*v3-h7*v33/7+(-9104.D0/63.D0*v3*h5*v4-1032.D0/35
     #.D0*vv2*h3*v3+1124.D0/9.D0*v44*h6+204.D0/7.D0*v33*h4+4672.D0/45.D0
     #*vv2*h4*v4+108.D0/25.D0*v22*h2)*Finv+(-14672.D0/3.D0*v44*h3-144*v3
     #3*h+5440.D0/3.D0*v3*v4*h2+144.D0/5.D0*v3*vv2-3584.D0/15.D0*v4*h*vv
     #2)*Finv2
      fs(2,i)=292.D0/35.D0*vv2*h5*v3-163.D0/27.D0*v44*h8-33.D0/7.D0*v33
     #*h6-
     #154.D0/15.D0*vv2*h6*v4+688.D0/63.D0*v3*h7*v4-17.D0/5.D0*v22*h4+(-4
     #488.D0/35.D0*vv2*h2*v3+122816.D0/81.D0*v44*h5+288.D0/25.D0*v22*h-8
     #1808.D0/63.D0*v3*h4*v4+192*v33*h3+5776.D0/9.D0*vv2*h3*v4)*Finv+(35
     #84*v4*v3*h-1198960.D0/81.D0*v44*h2-3584.D0/15.D0*v4*vv2-144*v33)*F
     #inv2
      fs(3,i)=-896.D0/9.D0*vv2*h5*v4-320.D0/7.D0*v33*h5-416.D0/25.D0*v
     #22*h3
     #+416.D0/3.D0*v3*h6*v4-2624.D0/27.D0*v44*h7+296.D0/5.D0*vv2*h4*v3+(
     #14432.D0/9.D0*vv2*v4*h2-6912.D0/35.D0*vv2*v3*h+622720.D0/81.D0*v44
     #*h4+192.D0/25.D0*v22+3456.D0/7.D0*v33*h2-303104.D0/63.D0*v3*v4*h3)
     #*Finv+(7168.D0/3.D0*v3*v4-1605632.D0/81.D0*v44*h)*Finv2
      fs(4,i)=-19360.D0/27.D0*v44*h6-9696.D0/49.D0*v33*h4-6464.D0/15.
     #D0*vv2
     #*h4*v4+16768.D0/21.D0*v3*h5*v4-848.D0/25.D0*v22*h2+1280.D0/7.D0*vv
     #2*h3*v3+(3840.D0/7.D0*v33*h+1614080.D0/81.D0*v44*h3+15872.D0/9.D0*
     #v4*h*vv2-3456.D0/35.D0*v3*vv2-545792.D0/63.D0*v3*v4*h2)*Finv-80281
     #6.D0/81.D0*Finv2*v44
      fs(5,i)=-233728.D0/81.D0*v44*h5+9728.D0/35.D0*vv2*h2*v3-21760.D
     #0/49.D
     #0*v33*h3+154880.D0/63.D0*v3*h4*v4-8704.D0/9.D0*vv2*h3*v4-768.D0/25
     #.D0*v22*h+(31744.D0/45.D0*v4*vv2+2251264.D0/81.D0*v44*h2-22528.D0/
     #3.D0*v4*v3*h+1536.D0/7.D0*v33)*Finv
      fs(6,i)=-256.D0/25.D0*v22+1024.D0/5.D0*vv2*v3*h-555776.D0/81.D0
     #*v44*h
     #4-52736.D0/45.D0*vv2*v4*h2+38912.D0/9.D0*v3*v4*h3-26368.D0/49.D0*v
     #33*h2+(-22528.D0/9.D0*v3*v4+1605632.D0/81.D0*v44*h)*Finv
      fs(7,i)=458752.D0/81.D0*Finv*v44-16384.D0/49.D0*v33*h+2048.D0/35
     #.D0*v
     #3*vv2-32768.D0/45.D0*v4*h*vv2+274432.D0/63.D0*v3*v4*h2-802816.D0/8
     #1.D0*v44*h3
      fs(8,i)=-4096.D0/49.D0*v33+16384.D0/7.D0*v4*v3*h-692224.D0/81.D0
     #*v44*
     #h2-8192.D0/45.D0*v4*vv2
      fs(9,i)=-327680.D0/81.D0*v44*h+32768.D0/63.D0*v3*v4
      fs(10,i)=-65536.D0/81.D0*v44


      gs(0,i)=(v44*h9/162-v4*h8*v3/63-h6*vv2*v3/35+h7*vv2*v4/45+h7*v33/
     #98+h
     #5*v22/50)*Finv+(102176.D0/1287.D0*v3*h5*v4-4832.D0/231.D0*v33*h4-1
     #704232.D0/27027.D0*v44*h6+364.D0/15.D0*vv2*h3*v3-40060.D0/693.D0*v
     #v2*h4*v4-38.D0/7.D0*v22*h2)*Finv2+(60512.D0/99.D0*v4*h*vv2-2906968
     #0.D0/9009.D0*v3*v4*h2+73755800.D0/11583.D0*v44*h3+65720.D0/231.D0*
     #v33*h-2000.D0/21.D0*v3*vv2)*Finv3-1019200.D0/81.D0*v44*Finv4
      gs(1,i)=(v33*h6+v44*h8-128.D0/63.D0*v3*h7*v4-72.D0/35.D0*vv2*h5*
     #v3+v2
     #2*h4+98.D0/45.D0*vv2*h6*v4)*Finv+(8584384.D0/9009.D0*v3*h4*v4-3328
     #.D0/175.D0*v22*h+5048.D0/35.D0*vv2*h2*v3-1715872.D0/3465.D0*vv2*h3
     #*v4-42208.D0/231.D0*v33*h3-8828800.D0/9009.D0*v44*h5)*Finv2+(12102
     #4.D0/99.D0*v4*vv2-12565760.D0/1287.D0*v4*v3*h+131440.D0/231.D0*v33
     #+116472080.D0/3861.D0*v44*h2)*Finv3
      gs(2,i)=(-24*vv2*h4*v3+1568.D0/45.D0*vv2*h5*v4+16*v33*h5+8*v22*h3
     #-128
     #.D0/3.D0*v3*h6*v4+80.D0/3.D0*v44*h7)*Finv+(-5457568.D0/3465.D0*vv2
     #*v4*h2+10048.D0/35.D0*vv2*v3*h+4343552.D0/1001.D0*v3*v4*h3-3328.D0
     #/175.D0*v22-54116224.D0/9009.D0*v44*h4-313696.D0/539.D0*v33*h2)*Fi
     #nv2+(-12565760.D0/1287.D0*v3*v4+201904640.D0/3861.D0*v44*h)*Finv3
      gs(3,i)=(3136.D0/15.D0*vv2*h4*v4-512.D0/5.D0*vv2*h3*v3-1024.D0/
     #3.D0*v
     #3*h5*v4+112.D0/5.D0*v22*h2+96*v33*h4+2464.D0/9.D0*v44*h6)*Finv+(-1
     #18784.D0/55.D0*v4*h*vv2+9425408.D0/1001.D0*v3*v4*h2-1291264.D0/161
     #7.D0*v33*h+20096.D0/105.D0*v3*vv2-213495808.D0/11583.D0*v44*h3)*Fi
     #nv2+403809280.D0/11583.D0*v44*Finv3
      gs(4,i)=(-28160.D0/21.D0*v3*h4*v4+1408*v44*h5+1792.D0/3.D0*vv2*
     #h3*v4+
     #1920.D0/7.D0*v33*h3+128.D0/5.D0*v22*h-6912.D0/35.D0*vv2*h2*v3)*Fin
     #v+(-116451328.D0/3861.D0*v44*h2-645632.D0/1617.D0*v33+9794560.D0/1
     #001.D0*v4*v3*h-59392.D0/55.D0*v4*vv2)*Finv2
      gs(5,i)=(-180224.D0/63.D0*v3*v4*h3+2816.D0/7.D0*v33*h2+256.D0/25
     #.D0*v
     #22+36608.D0/9.D0*v44*h4+39424.D0/45.D0*vv2*v4*h2-6144.D0/35.D0*vv2
     #*v3*h)*Finv+(3917824.D0/1001.D0*v3*v4-97042432.D0/3861.D0*v44*h)*F
     #inv2
      gs(6,i)=(-212992.D0/63.D0*v3*v4*h2+186368.D0/27.D0*v44*h3-2048.D
     #0/35.
     #D0*v3*vv2+2048.D0/7.D0*v33*h+28672.D0/45.D0*v4*h*vv2)*Finv-9704243
     #2.D0/11583.D0*Finv2*v44
      gs(7,i)=(-131072.D0/63.D0*v4*v3*h+8192.D0/45.D0*v4*vv2+20480.D0/
     #3.D0*
     #v44*h2+4096.D0/49.D0*v33)*Finv
      gs(8,i)=-32768.D0/63.D0*v4*Finv*(-7*v4*h+v3)
      gs(9,i)=65536.D0/81.D0*Finv*v44
  

      hs(0,i)=(-v22*h4/2-v33*h6/2-v44*h8/2+vv2*h5*v3-vv2*h6*v4+v3*h7*v4
     #)*Fi
     #nv+(508*v44*h5+660.D0/7.D0*v33*h3+216.D0/25.D0*v22*h-10168.D0/21.D
     #0*v3*h4*v4+3628.D0/15.D0*vv2*h3*v4-2508.D0/35.D0*vv2*h2*v3)*Finv2+
     #(-14760.D0/77.D0*v33-163800.D0/11.D0*v44*h2-4032.D0/11.D0*v4*vv2+4
     #9680.D0/11.D0*v4*v3*h)*Finv3
      hs(1,i)=(732.D0/35.D0*vv2*h4*v3-36.D0/5.D0*v22*h3-212.D0/9.D0*v44
     #*h7-
     #1384.D0/45.D0*vv2*h5*v4-96.D0/7.D0*v33*h5+2348.D0/63.D0*v3*h6*v4)*
     #Finv+(-112400.D0/21.D0*v3*v4*h3+8824.D0/5.D0*vv2*v4*h2-11232.D0/35
     #.D0*vv2*v3*h+5076.D0/7.D0*v33*h2+22748.D0/3.D0*v44*h4+396.D0/25.D0
     #*v22)*Finv2+(-695520.D0/11.D0*v44*h+99360.D0/11.D0*v3*v4)*Finv3
      hs(2,i)=(-2720.D0/9.D0*vv2*h4*v4-10808.D0/27.D0*v44*h6-164.D0/5
     #.D0*v2
     #2*h2+31000.D0/63.D0*v3*h5*v4+5176.D0/35.D0*vv2*h3*v3-960.D0/7.D0*v
     #33*h4)*Finv+(-5312.D0/15.D0*v3*vv2-195232.D0/9.D0*v3*v4*h2+3578944
     #.D0/81.D0*v44*h3+192544.D0/45.D0*v4*h*vv2+38048.D0/21.D0*v33*h)*Fi
     #nv2-61942720.D0/891.D0*v44*Finv3
      hs(3,i)=(-57824.D0/45.D0*vv2*h3*v4-4192.D0/7.D0*v33*h3+2144.D0/
     #5.D0*v
     #v2*h2*v3-27968.D0/9.D0*v44*h5+26336.D0/9.D0*v3*h4*v4-1376.D0/25.D0
     #*v22*h)*Finv+(311744.D0/231.D0*v33+1574272.D0/495.D0*v4*vv2-349120
     #0.D0/99.D0*v4*v3*h+34389824.D0/297.D0*v44*h2)*Finv2
      hs(4,i)=(-91008.D0/35.D0*vv2*v4*h2+18432.D0/35.D0*vv2*v3*h-60352
     #.D0/4
     #9.D0*v33*h2-5312.D0/175.D0*v22-789568.D0/63.D0*v44*h4+550016.D0/63
     #.D0*v3*v4*h3)*Finv+(530475008.D0/3861.D0*v44*h-25065472.D0/1287.D0
     #*v3*v4)*Finv2
      hs(5,i)=(-111104.D0/45.D0*v4*h*vv2-173056.D0/147.D0*v33*h+856064.
     #D0/6
     #3.D0*v3*v4*h2+24064.D0/105.D0*v3*vv2-2269184.D0/81.D0*v44*h3)*Finv
     #+694371328.D0/11583.D0*Finv2*v44
      hs(6,i)=(-10384384.D0/297.D0*v44*h2-438272.D0/495.D0*v4*vv2-68300
     #8.D0
     #/1617.D0*v33+7301120.D0/693.D0*v4*v3*h)*Finv
      hs(7,i)=8192.D0/27027.D0*v4*(10596*v3-75173*v4*h)*Finv
      hs(8,i)=-69910528.D0/11583.D0*Finv*v44


      is(0,i)=(-956.D0/45.D0*vv2*h5*v4-148.D0/9.D0*v44*h7-72.D0/7.D0*
     #v33*h5
     #+1684.D0/63.D0*v3*h6*v4-24.D0/5.D0*v22*h3+528.D0/35.D0*vv2*h4*v3)*
     #Finv2+(-1296.D0/7.D0*vv2*v3*h+92180.D0/21.D0*v44*h4-66320.D0/21.D0
     #*v3*v4*h3+7320.D0/7.D0*vv2*v4*h2+20700.D0/49.D0*v33*h2+324.D0/35.D
     #0*v22)*Finv3+(64800.D0/13.D0*v3*v4-453600.D0/13.D0*v44*h)*Finv4
      is(1,i)=(-2464.D0/9.D0*vv2*v4*h4+29480.D0/63.D0*v3*h5*v4+4904.
     #D0/35.D
     #0*vv2*v3*h3-944.D0/7.D0*v33*h4-156.D0/5.D0*v22*h2-10072.D0/27.D0*v
     #44*h6)*Finv2+(-1120160.D0/63.D0*v3*h2*v4+212960.D0/147.D0*v33*h+33
     #184.D0/9.D0*vv2*v4*h-6208.D0/21.D0*vv2*v3+2902400.D0/81.D0*v44*h3)
     #*Finv3-59214400.D0/1053.D0*v44*Finv4
      is(2,i)=(2208.D0/5.D0*vv2*v3*h2-27904.D0/9.D0*v44*h5+26656.D0/9
     #.D0*v3
     #*v4*h4-1504.D0/25.D0*v22*h-57376.D0/45.D0*vv2*v4*h3-4320.D0/7.D0*v
     #33*h3)*Finv2+(31389760.D0/297.D0*v44*h2+310144.D0/99.D0*vv2*v4+198
     #9440.D0/1617.D0*v33-22517120.D0/693.D0*v3*v4*h)*Finv3
      is(3,i)=(-63296.D0/49.D0*v33*h2+19968.D0/35.D0*vv2*v3*h+567424.
     #D0/63.
     #D0*v3*v4*h3-804800.D0/63.D0*v44*h4-94592.D0/35.D0*vv2*v4*h2-6208.D
     #0/175.D0*v22)*Finv2+(-171929600.D0/9009.D0*v3*v4+512128000.D0/3861
     #.D0*v44*h)*Finv3
      is(4,i)=(-185344.D0/147.D0*v33*h-2338816.D0/81.D0*v44*h3-119296.
     #D0/45
     #.D0*vv2*v4*h+27136.D0/105.D0*vv2*v3+894976.D0/63.D0*v3*h2*v4)*Finv
     #2+693048320.D0/11583.D0*v44*Finv3
      is(5,i)=(-10812416.D0/297.D0*v44*h2+7751680.D0/693.D0*v3*v4*h-48
     #3328.
     #D0/495.D0*vv2*v4-750592.D0/1617.D0*v33)*Finv2
      is(6,i)=-8192.D0/27027.D0*v4*(79177*v4*h-11454*v3)*Finv2
      is(7,i)=-74596352.D0/11583.D0*v44*Finv2


      js(0,i)=(h7*v33/98-h6*vv2*v3/35+h5*v22/50+v44*h9/162-v4*h8*v3/63
     #+h7*v
     #v2*v4/45)*Finv+(-1852.D0/105.D0*vv2*v3*h3-532192.D0/9009.D0*v3*h5*
     #v4+1291820.D0/27027.D0*v44*h6+596.D0/33.D0*v33*h4+162.D0/35.D0*v22
     #*h2+107284.D0/3465.D0*vv2*v4*h4)*Finv2+(3080720.D0/1287.D0*v3*h2*v
     #4-54880.D0/99.D0*vv2*v4*h+224.D0/3.D0*vv2*v3-41960.D0/231.D0*v33*h
     #-52260040.D0/11583.D0*v44*h3)*Finv3+1097600.D0/81.D0*v44*Finv4
      js(1,i)=(v44*h8+98.D0/45.D0*vv2*h6*v4+v22*h4+v33*h6-128.D0/63.D0*
     #v3*h
     #7*v4-72.D0/35.D0*vv2*h5*v3)*Finv+(2432.D0/175.D0*v22*h-2152.D0/35.
     #D0*vv2*v3*h2+3383360.D0/9009.D0*v44*h5+321248.D0/3465.D0*vv2*v4*h3
     #-3056576.D0/9009.D0*v3*v4*h4+18976.D0/231.D0*v33*h3)*Finv2+(-83920
     #.D0/231.D0*v33-109760.D0/99.D0*vv2*v4-69682480.D0/3861.D0*v44*h2+7
     #989760.D0/1287.D0*v3*v4*h)*Finv3
      js(2,i)=(80.D0/3.D0*v44*h7-128.D0/3.D0*v3*h6*v4+8*v22*h3-24*vv2*
     #h4*v3
     #+1568.D0/45.D0*vv2*h5*v4+16*v33*h5)*Finv+(2432.D0/175.D0*v22-2752.
     #D0/35.D0*vv2*v3*h+68000.D0/539.D0*v33*h2+5619776.D0/9009.D0*v44*h4
     #-194848.D0/3465.D0*vv2*v4*h2-1133056.D0/3003.D0*v3*v4*h3)*Finv2+(7
     #989760.D0/1287.D0*v3*v4-104527360.D0/3861.D0*v44*h)*Finv3
      js(3,i)=(2464.D0/9.D0*v44*h6+112.D0/5.D0*v22*h2+96*v33*h4-1024.D
     #0/3.D
     #0*v3*h5*v4-512.D0/5.D0*vv2*v3*h3+3136.D0/15.D0*vv2*v4*h4)*Finv+(-1
     #9038208.D0/11583.D0*v44*h3-16384.D0/55.D0*vv2*v4*h+142336.D0/1617.
     #D0*v33*h-5504.D0/105.D0*vv2*v3+2108416.D0/3003.D0*v3*h2*v4)*Finv2-
     #209054720.D0/11583.D0*v44*Finv3
      js(4,i)=(1408*v44*h5-28160.D0/21.D0*v3*v4*h4-6912.D0/35.D0*vv2*v3
     #*h2+
     #1920.D0/7.D0*v33*h3+1792.D0/3.D0*vv2*v4*h3+128.D0/5.D0*v22*h)*Finv
     #+(-23830528.D0/3861.D0*v44*h2-8192.D0/55.D0*vv2*v4+71168.D0/1617.D
     #0*v33+4295680.D0/3003.D0*v3*v4*h)*Finv2
      js(5,i)=(-180224.D0/63.D0*v3*v4*h3-6144.D0/35.D0*vv2*v3*h+2816.D
     #0/7.D
     #0*v33*h2+39424.D0/45.D0*vv2*v4*h2+256.D0/25.D0*v22+36608.D0/9.D0*v
     #44*h4)*Finv+(1718272.D0/3003.D0*v3*v4-24788992.D0/3861.D0*v44*h)*F
     #inv2
      js(6,i)=(186368.D0/27.D0*v44*h3+2048.D0/7.D0*v33*h-2048.D0/35.D0*
     #vv2*
     #v3+28672.D0/45.D0*vv2*v4*h-212992.D0/63.D0*v3*h2*v4)*Finv-24788992
     #.D0/11583.D0*v44*Finv2
      js(7,i)=(4096.D0/49.D0*v33-131072.D0/63.D0*v3*v4*h+8192.D0/45.D0
     #*vv2*
     #v4+20480.D0/3.D0*v44*h2)*Finv
      js(8,i)=32768.D0/63.D0*v4*Finv*(-v3+7*v4*h)
      js(9,i)=65536.D0/81.D0*v44*Finv
  

      ks(0,i)=(12.D0/35.D0*vv2*h5*v3+16.D0/63.D0*v3*h7*v4-v22*h4/5-14
     #.D0/45
     #.D0*vv2*h6*v4-v33*h6/7-v44*h8/9)*Finv2+(320.D0/9.D0*v44*h5+368.D0/
     #9.D0*vv2*v4*h3+480.D0/49.D0*v33*h3-2960.D0/63.D0*v3*v4*h4-72.D0/7.
     #D0*vv2*v3*h2)*Finv3+(-3600.D0/49.D0*v33+16000.D0/21.D0*v3*v4*h-520
     #0.D0/3.D0*v44*h2)*Finv4
      ks(1,i)=(-160.D0/27.D0*v44*h7-16.D0/5.D0*v22*h3-32.D0/7.D0*v33*h5
     #+32.
     #D0/3.D0*v3*h6*v4-448.D0/45.D0*vv2*h5*v4+8*vv2*h4*v3)*Finv2+(-384.D
     #0/7.D0*vv2*v3*h+60800.D0/81.D0*v44*h4+4800.D0/49.D0*v33*h2-43520.D
     #0/63.D0*v3*v4*h3+3296.D0/9.D0*vv2*v4*h2)*Finv3+(32000.D0/21.D0*v3*
     #v4-640000.D0/81.D0*v44*h)*Finv4
      ks(2,i)=(-2464.D0/27.D0*v44*h6+256.D0/5.D0*vv2*v3*h3-336.D0/25.D0
     #*v22
     #*h2+128*v3*h5*v4-288.D0/7.D0*v33*h4-448.D0/5.D0*vv2*v4*h4)*Finv2+(
     #11520.D0/49.D0*v33*h-58880.D0/21.D0*v3*h2*v4-384.D0/7.D0*vv2*v3+25
     #60.D0/3.D0*vv2*v4*h+369920.D0/81.D0*v44*h3)*Finv3-640000.D0/81.D0*
     #v44*Finv4
      ks(3,i)=(4608.D0/35.D0*vv2*v3*h2-5632.D0/9.D0*v44*h5+14080.D0/21
     #.D0*v
     #3*v4*h4-7680.D0/49.D0*v33*h3-512.D0/25.D0*v22*h-1024.D0/3.D0*vv2*v
     #4*h3)*Finv2+(7680.D0/49.D0*v33+309760.D0/27.D0*v44*h2+5120.D0/9.D0
     #*vv2*v4-266240.D0/63.D0*v3*v4*h)*Finv3
      ks(4,i)=(112640.D0/63.D0*v3*v4*h3+1024.D0/7.D0*vv2*v3*h-14080.D0
     #/49.D
     #0*v33*h2-5632.D0/9.D0*vv2*v4*h2-256.D0/25.D0*v22-183040.D0/81.D0*v
     #44*h4)*Finv2+(-133120.D0/63.D0*v3*v4+1024000.D0/81.D0*v44*h)*Finv3
      ks(5,i)=(-12288.D0/49.D0*v33*h+2048.D0/35.D0*vv2*v3-372736.D0/81.
     #D0*v
     #44*h3-8192.D0/15.D0*vv2*v4*h+53248.D0/21.D0*v3*h2*v4)*Finv2+409600
     #.D0/81.D0*v44*Finv3
      ks(6,i)=(-143360.D0/27.D0*v44*h2-4096.D0/49.D0*v33-8192.D0/45.D0*
     #vv2*
     #v4+16384.D0/9.D0*v3*v4*h)*Finv2
      ks(7,i)=-32768.D0/567.D0*v4*(-9*v3+56*v4*h)*Finv2
      ks(8,i)=-65536.D0/81.D0*v44*Finv2
  
      ls(0,i)=(2132.D0/385.D0*vv2*h5*v4+86204.D0/27027.D0*v44*h7+584.D0
     #/231
     #.D0*v33*h5-17660.D0/3003.D0*v3*h6*v4+12.D0/7.D0*v22*h3-472.D0/105.
     #D0*vv2*h4*v3)*Finv2+(2320.D0/21.D0*vv2*v3*h-116659300.D0/81081.D0*
     #v44*h4+10938640.D0/9009.D0*v3*v4*h3-340520.D0/693.D0*vv2*v4*h2-471
     #40.D0/231.D0*v33*h2-324.D0/35.D0*v22)*Finv3+(-64800.D0/13.D0*v3*v4
     #+22472800.D0/1053.D0*v44*h)*Finv4
      ls(1,i)=(42208.D0/385.D0*vv2*v4*h4-161576.D0/1001.D0*v3*h5*v4-685
     #6.D0
     #/105.D0*vv2*v3*h3+4112.D0/77.D0*v33*h4+3028.D0/175.D0*v22*h2+30769
     #52.D0/27027.D0*v44*h6)*Finv2+(30175520.D0/3003.D0*v3*h2*v4-77920.D
     #0/77.D0*v33*h-85088.D0/33.D0*vv2*v4*h+6208.D0/21.D0*vv2*v3-1963993
     #60.D0/11583.D0*v44*h3)*Finv3+59214400.D0/1053.D0*v44*Finv4
      ls(2,i)=(-9824.D0/35.D0*vv2*v3*h2+3880256.D0/3003.D0*v44*h5-12584
     #608.
     #D0/9009.D0*v3*v4*h4+8096.D0/175.D0*v22*h+478816.D0/693.D0*vv2*v4*h
     #3+541600.D0/1617.D0*v33*h3)*Finv2+(-257779520.D0/3861.D0*v44*h2-31
     #0144.D0/99.D0*vv2*v4-1989440.D0/1617.D0*v33+223066240.D0/9009.D0*v
     #3*v4*h)*Finv3
      ls(3,i)=(1439552.D0/1617.D0*v33*h2-9728.D0/21.D0*vv2*v3*h-4860736
     #0.D0
     #/9009.D0*v3*v4*h3+548081216.D0/81081.D0*v44*h4+1290880.D0/693.D0*v
     #v2*v4*h2+6208.D0/175.D0*v22)*Finv2+(171929600.D0/9009.D0*v3*v4-123
     #5809280.D0/11583.D0*v44*h)*Finv3
      ls(4,i)=(571392.D0/539.D0*v33*h+215155712.D0/11583.D0*v44*h3+3681
     #28.D
     #0/165.D0*vv2*v4*h-27136.D0/105.D0*vv2*v3-31092736.D0/3003.D0*v3*h2
     #*v4)*Finv2-693048320.D0/11583.D0*v44*Finv3
      ls(5,i)=(106777600.D0/3861.D0*v44*h2-1128448.D0/117.D0*v3*v4*h+483
     #328
     #.D0/495.D0*vv2*v4+750592.D0/1617.D0*v33)*Finv2
      ls(6,i)=8192.D0/81081.D0*v4*(208663*v4*h-34362*v3)*Finv2
      ls(7,i)=74596352.D0/11583.D0*v44*Finv2
      

      ms(0,i)=(-14.D0/45.D0*h7*vv2*v4-h5*v22/5-v44*h9/9-h7*v33/7+12.D0/
     #35.D
     #0*h6*vv2*v3+16.D0/63.D0*v4*h8*v3)*Finv+(2104.D0/45.D0*h4*v4*vv2+35
     #4.D0/49.D0*h4*v33-312.D0/35.D0*h3*v3*vv2+362.D0/9.D0*h6*v44-3092.D
     #0/63.D0*v4*h5*v3+6.D0/5.D0*h2*v22)*Finv2+(13600.D0/21.D0*v3*v4*h2+
     #72.D0/7.D0*v3*vv2-72*v4*h*vv2-360.D0/7.D0*v33*h-6040.D0/3.D0*v44*h
     #3)*Finv3
      ms(1,i)=(-17.D0/5.D0*v22*h4-163.D0/27.D0*v44*h8-154.D0/15.D0*vv2*
     #h6*v
     #4-33.D0/7.D0*v33*h6+292.D0/35.D0*vv2*h5*v3+688.D0/63.D0*v3*h7*v4)*
     #Finv+(-46720.D0/63.D0*v3*h4*v4+4440.D0/49.D0*v33*h3+3952.D0/9.D0*v
     #v2*h3*v4+24.D0/5.D0*v22*h+68504.D0/81.D0*v44*h5-2376.D0/35.D0*vv2*
     #h2*v3)*Finv2+(-320.D0/3.D0*v4*vv2-720.D0/7.D0*v33-801040.D0/81.D0*
     #v44*h2+2240*v4*v3*h)*Finv3
      ms(2,i)=(-896.D0/9.D0*vv2*h5*v4-416.D0/25.D0*v22*h3+416.D0/3.D0*v3
     #*h6
     #*v4-2624.D0/27.D0*v44*h7-320.D0/7.D0*v33*h5+296.D0/5.D0*vv2*h4*v3)
     #*Finv+(15648.D0/49.D0*v33*h2+96.D0/25.D0*v22-672.D0/5.D0*vv2*v3*h+
     #58144.D0/45.D0*vv2*v4*h2-31328.D0/9.D0*v3*v4*h3+446848.D0/81.D0*v4
     #4*h4)*Finv2+(-1312640.D0/81.D0*v44*h+1920*v3*v4)*Finv3
      ms(3,i)=(-6464.D0/15.D0*h4*v4*vv2+16768.D0/21.D0*v4*h5*v3+1280.D0
     #/7.D
     #0*h3*v3*vv2-9696.D0/49.D0*h4*v33-848.D0/25.D0*h2*v22-19360.D0/27.D
     #0*h6*v44)*Finv+(1324544.D0/81.D0*v44*h3+68992.D0/45.D0*v4*h*vv2+20
     #736.D0/49.D0*v33*h-448256.D0/63.D0*v3*v4*h2-384.D0/5.D0*v3*vv2)*Fi
     #nv2-716800.D0/81.D0*v44*Finv3
      ms(4,i)=(-233728.D0/81.D0*v44*h5+9728.D0/35.D0*vv2*h2*v3-21760.D0
     #/49.
     #D0*v33*h3+154880.D0/63.D0*v3*h4*v4-8704.D0/9.D0*vv2*h3*v4-768.D0/2
     #5.D0*v22*h)*Finv+(1991680.D0/81.D0*v44*h2+28672.D0/45.D0*v4*vv2+92
     #16.D0/49.D0*v33-139264.D0/21.D0*v4*v3*h)*Finv2
      ms(5,i)=(-52736.D0/45.D0*vv2*v4*h2-26368.D0/49.D0*v33*h2-555776.D0
     #/81
     #.D0*v44*h4+1024.D0/5.D0*vv2*v3*h-256.D0/25.D0*v22+38912.D0/9.D0*v3
     #*v4*h3)*Finv+(-145408.D0/63.D0*v3*v4+1482752.D0/81.D0*v44*h)*Finv2
      ms(6,i)=(-802816.D0/81.D0*v44*h3-16384.D0/49.D0*v33*h+274432.D0/63
     #.D0
     #*v3*v4*h2+2048.D0/35.D0*v3*vv2-32768.D0/45.D0*v4*h*vv2)*Finv+43417
     #6.D0/81.D0*v44*Finv2
      ms(7,i)=(-692224.D0/81.D0*v44*h2+16384.D0/7.D0*v4*v3*h-8192.D0/45
     #.D0*
     #v4*vv2-4096.D0/49.D0*v33)*Finv
      ms(8,i)=32768.D0/567.D0*v4*(9*v3-70*v4*h)*Finv
      ms(9,i)=-65536.D0/81.D0*v44*Finv
      

      ns(0,i)=(19727.D0/3465.D0*vv2*h6*v4-67.D0/15.D0*vv2*h5*v3-7589.D0
     #/128
     #7.D0*v3*h7*v4+1135.D0/462.D0*v33*h6+175411.D0/54054.D0*v44*h8+127.
     #D0/70.D0*v22*h4)*Finv+(-48.D0/5.D0*v22*h-50080.D0/99.D0*vv2*h3*v4-
     #44488.D0/231.D0*v33*h3-16937512.D0/11583.D0*v44*h5+10938416.D0/900
     #9.D0*v3*h4*v4+12776.D0/105.D0*vv2*h2*v3)*Finv2+(13328.D0/33.D0*v4*
     #vv2-155200.D0/33.D0*v4*v3*h+19803560.D0/891.D0*v44*h2+14760.D0/77.
     #D0*v33)*Finv3
      ns(1,i)=(3223216.D0/27027.D0*v44*h7+12524.D0/231.D0*v33*h5-150258
     #8.D0
     #/9009.D0*v3*h6*v4-7382.D0/105.D0*vv2*h4*v3+410918.D0/3465.D0*vv2*h
     #5*v4+3538.D0/175.D0*v22*h3)*Finv+(100956056.D0/9009.D0*v3*v4*h3-21
     #3876692.D0/11583.D0*v44*h4-287860.D0/231.D0*v33*h2+45208.D0/105.D0
     #*vv2*v3*h-1555256.D0/495.D0*vv2*v4*h2-444.D0/25.D0*v22)*Finv2+(-31
     #0400.D0/33.D0*v3*v4+70739200.D0/891.D0*v44*h)*Finv3
      ns(2,i)=(-1995736.D0/1287.D0*v4*h5*v3+11404.D0/175.D0*h2*v22+618
     #712.D
     #0/1617.D0*h4*v33+2825696.D0/3465.D0*h4*v4*vv2+38359616.D0/27027.D0
     #*h6*v44-7352.D0/21.D0*h3*v3*vv2)*Finv+(-77888.D0/33.D0*v33*h-28998
     #08.D0/495.D0*v4*h*vv2-970319968.D0/11583.D0*v44*h3+39776.D0/105.D0
     #*v3*vv2+316833760.D0/9009.D0*v3*v4*h2)*Finv2+64702400.D0/891.D0*v4
     #4*Finv3
      ns(3,i)=(654866144.D0/81081.D0*v44*h5+657920.D0/539.D0*v33*h3-610
     #0892
     #8.D0/9009.D0*v3*h4*v4+595648.D0/231.D0*vv2*h3*v4-78592.D0/105.D0*v
     #v2*h2*v3+14304.D0/175.D0*v22*h)*Finv+(-324416.D0/231.D0*v33-202263
     #3920.D0/11583.D0*v44*h2-1710848.D0/495.D0*v4*vv2+19335424.D0/429.D
     #0*v4*v3*h)*Finv2
      ns(4,i)=(14234368.D0/3465.D0*vv2*v4*h2-75776.D0/105.D0*vv2*v3*h-42
     #956
     #80.D0/273.D0*v3*v4*h3+6208.D0/175.D0*v22+2055324352.D0/81081.D0*v4
     #4*h4+3153728.D0/1617.D0*v33*h2)*Finv+(-1964483584.D0/11583.D0*v44*
     #h+26236928.D0/1287.D0*v3*v4)*Finv2
      ns(5,i)=(1587712.D0/495.D0*v4*h*vv2+2464768.D0/1617.D0*v33*h-2713
     #6.D0
     #/105.D0*v3*vv2-180168704.D0/9009.D0*v3*v4*h2+41191424.D0/891.D0*v4
     #4*h3)*Finv-721021952.D0/11583.D0*v44*Finv2
      ns(6,i)=(483328.D0/495.D0*v4*vv2+564528128.D0/11583.D0*v44*h2+750
     #592.
     #D0/1617.D0*v33-13129728.D0/1001.D0*v4*v3*h)*Finv
      ns(7,i)=-8192.D0/81081.D0*v4*(34362*v3-272405*v4*h)*Finv
      ns(8,i)=74596352.D0/11583.D0*v44*Finv
      
      os(0,i)=(1676.D0/63.D0*v3*h6*v4-994.D0/45.D0*vv2*h5*v4-26.D0/5.D
     #0*v22
     #*h3-152.D0/9.D0*v44*h7-68.D0/7.D0*v33*h5+522.D0/35.D0*vv2*h4*v3)*F
     #inv2+(-1320.D0/7.D0*vv2*v3*h+324.D0/35.D0*v22+65432.D0/63.D0*vv2*v
     #4*h2+20460.D0/49.D0*v33*h2-195080.D0/63.D0*v3*v4*h3+276260.D0/63.D
     #0*v44*h4)*Finv3+(-1288000.D0/39.D0*v44*h+184000.D0/39.D0*v3*v4)*Fi
     #nv4
      os(1,i)=(-12448.D0/45.D0*h4*v4*vv2-10160.D0/27.D0*h6*v44+968.D0/
     #7.D0*
     #h3*v3*vv2-904.D0/7.D0*h4*v33-156.D0/5.D0*h2*v22+28984.D0/63.D0*v4*
     #h5*v3)*Finv2+(-5920.D0/21.D0*v3*vv2+211520.D0/147.D0*v33*h+31520.D
     #0/9.D0*v4*h*vv2-1095520.D0/63.D0*v3*v4*h2+2859040.D0/81.D0*v44*h3)
     #*Finv3-56302400.D0/1053.D0*v44*Finv4
      os(2,i)=(-56384.D0/45.D0*vv2*h3*v4-4160.D0/7.D0*v33*h3+14848.D0/
     #35.D0
     #*vv2*h2*v3+182048.D0/63.D0*v3*h4*v4-1376.D0/25.D0*v22*h-27680.D0/9
     #.D0*v44*h5)*Finv2+(1926080.D0/1617.D0*v33+30685760.D0/297.D0*v44*h
     #2+286208.D0/99.D0*v4*vv2-21848320.D0/693.D0*v4*v3*h)*Finv3
      os(3,i)=(-5312.D0/175.D0*v22-60352.D0/49.D0*v33*h2+18432.D0/35.D
     #0*vv2
     #*v3*h-814592.D0/315.D0*vv2*v4*h2-788672.D0/63.D0*v44*h4+183040.D0/
     #21.D0*v3*v4*h3)*Finv2+(-164608000.D0/9009.D0*v3*v4+497484800.D0/38
     #61.D0*v44*h)*Finv3
      os(4,i)=(-173056.D0/147.D0*v33*h+24064.D0/105.D0*v3*vv2-111104.D
     #0/45.
     #D0*v4*h*vv2-2269184.D0/81.D0*v44*h3+856064.D0/63.D0*v3*v4*h2)*Finv
     #2+668154880.D0/11583.D0*v44*Finv3
      os(5,i)=(-683008.D0/1617.D0*v33-10384384.D0/297.D0*v44*h2-438272.
     #D0/4
     #95.D0*v4*vv2+7301120.D0/693.D0*v4*v3*h)*Finv2
      os(6,i)=8192.D0/27027.D0*v4*(10596*v3-75173*v4*h)*Finv2
      os(7,i)=-69910528.D0/11583.D0*v44*Finv2

      ps(0,i)=(h7*vv2*v4/45-h6*vv2*v3/35+v44*h9/162-v4*h8*v3/63+h5*v22
     #/50+h
     #7*v33/98)*Finv+(99692.D0/3465.D0*h4*v4*vv2+526.D0/33.D0*h4*v33-352
     #.D0/21.D0*h3*v3*vv2+1272742.D0/27027.D0*h6*v44-500840.D0/9009.D0*v
     #4*h5*v3+132.D0/35.D0*h2*v22)*Finv2+(5094400.D0/3003.D0*v3*v4*h2-72
     #.D0/7.D0*v3*vv2-10952.D0/33.D0*v4*h*vv2-10800.D0/77.D0*v33*h-42857
     #840.D0/11583.D0*v44*h3)*Finv3
      ps(1,i)=(v44*h8-72.D0/35.D0*vv2*h5*v3-128.D0/63.D0*v3*h7*v4+98.D
     #0/45.
     #D0*vv2*h6*v4+v22*h4+v33*h6)*Finv+(-2283616.D0/9009.D0*v3*h4*v4+150
     #80.D0/231.D0*v33*h3+103792.D0/3465.D0*vv2*h3*v4+648.D0/175.D0*v22*
     #h+2742760.D0/9009.D0*v44*h5-232.D0/7.D0*vv2*h2*v3)*Finv2+(320.D0/3
     #.D0*v4*vv2+720.D0/7.D0*v33-37620560.D0/3861.D0*v44*h2+350080.D0/14
     #3.D0*v4*v3*h)*Finv3
      ps(2,i)=(16*v33*h5+80.D0/3.D0*v44*h7+8*v22*h3+1568.D0/45.D0*vv2*
     #h5*v4
     #-128.D0/3.D0*v3*h6*v4-24*vv2*h4*v3)*Finv+(3456.D0/539.D0*v33*h2-96
     #.D0/25.D0*v22+1312.D0/35.D0*vv2*v3*h-188896.D0/495.D0*vv2*v4*h2+20
     #03488.D0/9009.D0*v3*v4*h3-10176.D0/143.D0*v44*h4)*Finv2+(-11365760
     #.D0/3861.D0*v44*h-1920*v3*v4)*Finv3
      ps(3,i)=(-1024.D0/3.D0*v4*h5*v3+3136.D0/15.D0*h4*v4*vv2-512.D0/
     #5.D0*h
     #3*v3*vv2+96*h4*v33+2464.D0/9.D0*h6*v44+112.D0/5.D0*h2*v22)*Finv+(-
     #52896512.D0/11583.D0*v44*h3-479104.D0/495.D0*v4*h*vv2-113152.D0/53
     #9.D0*v33*h+24388864.D0/9009.D0*v3*v4*h2+384.D0/5.D0*v3*vv2)*Finv2+
     #716800.D0/81.D0*v44*Finv3
      ps(4,i)=(1792.D0/3.D0*vv2*h3*v4-28160.D0/21.D0*v3*h4*v4-6912.D0
     #/35.D0
     #*vv2*h2*v3+1408*v44*h5+128.D0/5.D0*v22*h+1920.D0/7.D0*v33*h3)*Finv
     #+(-48952832.D0/3861.D0*v44*h2-28672.D0/45.D0*v4*vv2-9216.D0/49.D0*
     #v33+40693760.D0/9009.D0*v4*v3*h)*Finv2
      ps(5,i)=(39424.D0/45.D0*vv2*v4*h2-6144.D0/35.D0*vv2*v3*h+256.D0
     #/25.D0
     #*v22+2816.D0/7.D0*v33*h2+36608.D0/9.D0*v44*h4-180224.D0/63.D0*v3*v
     #4*h3)*Finv+(145408.D0/63.D0*v3*v4-53055488.D0/3861.D0*v44*h)*Finv2
      ps(6,i)=(186368.D0/27.D0*v44*h3+2048.D0/7.D0*v33*h-212992.D0/63
     #.D0*v3
     #*v4*h2-2048.D0/35.D0*v3*vv2+28672.D0/45.D0*v4*h*vv2)*Finv-434176.D
     #0/81.D0*v44*Finv2
      ps(7,i)=(4096.D0/49.D0*v33+20480.D0/3.D0*v44*h2-131072.D0/63.D0*
     #v4*v3
     #*h+8192.D0/45.D0*v4*vv2)*Finv
      ps(8,i)=-32768.D0/63.D0*v4*Finv*(-7*v4*h+v3)
      ps(9,i)=65536.D0/81.D0*v44*Finv
   
c     Probing the potential approximation
  
	do j=1,11
	t=xin(i)+(j-1)*s
	d=t-xin(i)
	dh=d/h
	four=0.d0
	do k=0,ngrad
	four=four+v(k,i)*h**k*poleg(k,dh)
	enddo
	dev=0.d0
	do k=2,ngrad
	dev=dev+v(k,i)*h**k*poleg(k,dh)
	enddo
	one=f0+f1*d
	write(3,100) t,pot(t),pot(t)-four,pot(t)-one
100	format(f12.6,2x,3d20.10)
	enddo
	enddo

c     Coefficients for some Airy series
 
        s=1.d0
        do  k=1,kmax
        s=s*(6.d0*k-5.d0)*(6.d0*k-1.d0)/(72.d0*k)
        ck(k)=s
        dk(k)=-(6.0d0*k+1.0d0)/(6.0d0*k-1.0d0)*ck(k)
        enddo


c       Adjustment of the matching point

	do i=1,nin
	if(xin(i).gt.xmat) then
	match=i
	xmatch=xin(match)
	go to 4455
	endif
	enddo
4455	continue

c       Eigenvalue finding (by bisection)

	open(10,file='res.out')
	eps=3.d-16
	iter=100
        write(10,1020) xin(1),xmatch,xin(nin),step,tol
        write(*,1020) xin(1),xmatch,xin(nin),step,tol
1020    format(3f12.3,2x,f15.10,2x,1pd12.4)
        write(10,*)

        elow=-50.d0
        eup=-3.d0
        he=0.1d0
        neig=(eup-elow)/he
        enold=elow
        fenold=fix(enold)
        k=0
        t1=second()
        niter=0
        do ie=1,neig
        enew=elow+ie*he
        fenew=fix(enew)
        if(fenew*fenold.lt.0.d0) then
        el=enold
        er=enew
        call bisec(el,er,enex,fix,eps,iter,ier)
        k=k+1
	if(k.gt.14) stop
        niter=niter+ier
        exact=eref(k)
        err=exact-enex
        fenex=fix(enex)
        write(10,1010) k,enex,err,fenex,ier
        write(*,1010) k,enex,err,fenex,ier
1010    format(i3,f23.14,2x,1pd10.2,3x,0pd16.6,i5)
        endif
        enold=enew
        fenold=fenew
        enddo
        stop
	end

        subroutine prop(x,h,int,if,sol,dsol,sole,dsole)
c       Calculates the solution and its derivative on each subinterval
        implicit double precision (a-h,o-z)
	include 'params.dat'
	parameter (ngrad=4)
        common /part/ xin(nind),v(0:ngrad,nind)
	common /fener/ f0,f1,en
	common /actdim/ nin
	common /valpi/ pi
        parameter (maf=2,mbf=5,mcf=4,mef=5,mff=3,mgf=4)
	common /fcorr/ af(0:maf,nind),bf(0:mbf,nind),cf(0:mcf,nind),
     +  ef(0:mef,nind),ff(0:mff,nind),gf(0:mgf,nind)
	parameter (msa=10)
	common /scorr/ sa(0:msa,nind),sb(0:msa,nind),sc(0:msa,nind),
     #  sd(0:msa,nind),se(0:msa,nind),sf(0:msa,nind),sg(0:msa,nind),
     #  sh(0:msa,nind),si(0:msa,nind),sj(0:msa,nind),sk(0:msa,nind),
     #  sl(0:msa,nind),sm(0:msa,nind),sn(0:msa,nind),so(0:msa,nind),
     #  sp(0:msa,nind)
        parameter (mse=3)
        dimension sec(0:mse),sew(0:mse),ses(0:mse),sez(0:mse)
	dimension pow(0:msa),qow(0:mse)
	common /valcorr0/ u0,v0,du0,dv0
	common /valcorr1/ u1,v1,du1,dv1
	f3=dabs(f1)**(1.d0/3.d0)
	if(f1.lt.0.d0) f3=-f3
	f0e=f0-en
	t0=(f0-en)/f3**2
	t=f3*h+t0
        h2=h*h
        h3=h*h2
        h4=h*h3
        h5=h*h4
        h6=h*h5
        h7=h*h6
        h8=h*h7
        h9=h*h8
        h10=h*h9
        h11=h*h10
        h12=h*h11
        h13=h*h12
	h14=h*h13
	h15=h*h14
	h16=h*h15
	h17=h*h16
	h18=h*h17
	h19=h*h18
	h20=h*h19
	h21=h*h20
	h22=h*h21
	h23=h*h22
	h24=h*h23
        f0e2=f0e*f0e
        f0e3=f0e*f0e2
        f0e4=f0e*f0e3
        f0e5=f0e*f0e4
        f0e6=f0e*f0e5
        f0e7=f0e*f0e6
        f0e8=f0e*f0e7
        f0e9=f0e*f0e8
        f12=f1*f1
        f13=f1*f12
        f14=f1*f13
        f15=f1*f14
        f16=f1*f15
	qf0f1=f0e/f1
	do k=0,10
	pow(k)=qf0f1**k
	enddo

        iasym=0

	if(f1.eq.0.d0) then
	if(f0e.lt.0.d0) then 
	iasym=-1
        cf0=cos(sqrt(-f0e)*h)
        sf0=-sqrt(-f0e)*sin(sqrt(-f0e)*h)
	else
        iasym=1
        cf0=cosh(sqrt(f0e)*h)
        sf0=sqrt(f0e)*sinh(sqrt(f0e)*h)
        endif
	go to 9988
	endif
        if(t0.lt.-2.d0.and.t.lt.-2.d0) then
        iasym=-1
        cf0=cos(sqrt(-f0e)*h)
        sf0=-sqrt(-f0e)*sin(sqrt(-f0e)*h)
        endif
        if(t0.gt.2.d0.and.t.gt.2.d0) then
        iasym=1
        cf0=cosh(sqrt(f0e)*h)
        sf0=sqrt(f0e)*sinh(sqrt(f0e)*h)
        endif
9988	continue
        if(iasym.ne.0) then
c  zeroth order correction asymptotic

      u0a= cf0+(-f0e*cf0*h+sf0+f0e*h2*sf0)*f1/f0e2/4+(3*f0e2*h4*cf0-10*f
     #0e*h3*sf0+21*f0e*h2*cf0-21*h*sf0)*f12/f0e3/96+(105*sf0-70*f0e2*h3*
     #cf0+105*f0e*h2*sf0+28*f0e2*h4*sf0-7*f0e3*h5*cf0+f0e3*h6*sf0-105*f0
     #e*cf0*h)*f13/f0e5/384+(238*f0e3*h6*cf0-12285*h*sf0+3*f0e4*h8*cf0+3
     #255*f0e2*h4*cf0-1050*f0e2*h5*sf0-36*f0e3*h7*sf0-7350*f0e*h3*sf0+12
     #285*f0e*h2*cf0)*f14/f0e6/18432

      v0a= sf0/f0e+(f0e*h2*cf0-h*sf0)*f1/f0e2/4+(15*sf0-10*f0e2*h3*cf0+1
     #5*f0e*h2*sf0+3*f0e2*h4*sf0-15*f0e*cf0*h)*f12/f0e4/96+(f0e3*h6*cf0-
     #7*f0e2*h5*sf0+25*f0e2*h4*cf0-60*f0e*h3*sf0+105*f0e*h2*cf0-105*h*sf
     #0)*f13/f0e5/384+(-6930*f0e2*h3*cf0-10395*f0e*cf0*h-966*f0e3*h5*cf0
     #+226*f0e3*h6*sf0-36*f0e4*h7*cf0+3045*f0e2*h4*sf0+10395*f0e*h2*sf0+
     #10395*sf0+3*f0e4*h8*sf0)*f14/f0e**7/18432

      du0a=sf0+(f0e*h2*cf0+h*sf0)*f1/f0e/4+(-21*sf0+3*f0e2*h4*sf0+21*f0e
     #*cf0*h-9*f0e*h2*sf0+2*f0e2*h3*cf0)*f12/f0e3/96+(f0e3*h6*cf0-f0e2*h
     #5*sf0-7*f0e2*h4*cf0+42*f0e*h3*sf0-105*f0e*h2*cf0+105*h*sf0)*f13/f0
     #e4/384+(-12285*sf0-14*f0e3*h6*sf0+3*f0e4*h8*sf0-1995*f0e2*h4*sf0+5
     #670*f0e2*h3*cf0-9765*f0e*h2*sf0+12285*f0e*cf0*h-12*f0e4*h7*cf0+378
     #*f0e3*h5*cf0)*f14/f0e6/18432

      dv0a=cf0+(-sf0+f0e*cf0*h+f0e*h2*sf0)*f1/f0e2/4+(3*f0e2*h4*cf0+2*f0
     #e*h3*sf0-15*f0e*h2*cf0+15*h*sf0)*f12/f0e3/96+(105*f0e*cf0*h-f0e3*h
     #5*cf0+f0e3*h6*sf0-105*sf0-75*f0e*h2*sf0+40*f0e2*h3*cf0-10*f0e2*h4*
     #sf0)*f13/f0e5/384+(5250*f0e*h3*sf0-10395*f0e*h2*cf0+3*f0e4*h8*cf0-
     #12*f0e3*h7*sf0-26*f0e3*h6*cf0+10395*h*sf0-1785*f0e2*h4*cf0+390*f0e
     #2*h5*sf0)*f14/f0e6/18432


        u0=u0a
        v0=v0a
        du0=du0a
        dv0=dv0a


c   first correction asymptotic

	f0inv=1/f0e
	f0inv2=f0inv**2
	f0inv3=f0inv**3
	f0inv4=f0inv**4
	f0inv5=f0inv**5
	f0inv6=f0inv**6
	f0inv7=f0inv**7
        f0inv8=f0inv**8

	qinv=f1/f0e
	qinv2=qinv**2
	qinv3=qinv**3
	qinv4=qinv**4
	do k=0,mse
	qow(k)=qinv**k
	enddo

c  cf0 and sf0 :

c  for both positive
c  cf0 = cosh(sqrt(f0)*h)=cf0
c  sf0 = sqrt(f0)*sinh(sqrt(f0)*h)

c  for both negative
c  cf0 = cos(sqrt(-f0)*h)
c  sf0 = -sqrt(-f0)*sin(sqrt(-f0)*h)




      s1 = 15.d0/2.d0*f0inv3*v(3,int)*sf0+(3*h2*sf0-15.d0/2.d0*h*cf0)*
     #v(3,int)*f
     #0inv2-f0inv*v(3,int)*h3*cf0/2
      s2 = s1+(-2205.d0/8.d0*f0inv4*v(4,int)*sf0+(-15.d0/4.d0*v(2,int)*
     #sf0-45.d0
     #/4.d0*v(3,int)*h*sf0+(-975.d0/8.d0*h2*sf0+2205.d0/8.d0*h*cf0)*
     #v(4,int))*f0
     #inv3+((-3.d0/2.d0*h2*sf0+15.d0/4.d0*h*cf0)*v(2,int)+
     #(-39.d0/8.d0*h3*sf
     #0+45.d0/4.d0*h2*cf0)*v(3,int)+(-33.d0/8.d0*h4*sf0+30*h3*cf0)*
     #v(4,int))*f0i
     #nv2+(v(2,int)*h3*cf0/4+(-h5*sf0/8+9.d0/8.d0*h4*cf0)*v(3,int)+
     #v(4,int)*h5*cf0/4
     #)*f0inv)*qinv
      s3 = s2+((7245.d0/64.d0*v(3,int)*sf0+21735.d0/32.d0*v(4,int)*
     #h*sf0)*f0inv4
     #+(231.d0/32.d0*v(2,int)*h*sf0+(1995.d0/32.d0*h2*sf0-
     #7245.d0/64.d0*h*cf
     #0)*v(3,int)+(4935.d0/16.d0*h3*sf0-21735.d0/32.d0*h2*cf0)*
     #v(4,int))*f0inv3+
     #((-231.d0/32.d0*h2*cf0+99.d0/32.d0*h3*sf0)*v(2,int)+
     #(115.d0/16.d0*h4*s
     #f0-1575.d0/64.d0*h3*cf0)*v(3,int)+(435.d0/32.d0*h5*sf0-
     #2625.d0/32.d0*h
     #4*cf0)*v(4,int))*f0inv2+((-11.d0/16.d0*h4*cf0+11.d0/160.d0*
     #h5*sf0)*v(2,int
     #)+(5.d0/24.d0*h6*sf0-3.d0/2.d0*h5*cf0)*v(3,int)+
     #(h7*sf0/16-43.d0/32.d0
     #*h6*cf0)*v(4,int))*f0inv-v(3,int)*h7*cf0/64)*qinv2
      s4 = s3
      s6 = (-2027025.d0/256.d0*f0inv5*v(4,int)*sf0+(-693.d0/16.d0*
     #v(2,int)*sf0-4
     #3065.d0/128.d0*v(3,int)*h*sf0+(2027025.d0/256.d0*h*cf0-
     #1202355.d0/256.
     #d0*h2*sf0)*v(4,int))*f0inv4+((-1827.d0/64.d0*h2*sf0+
     #693.d0/16.d0*h*cf0
     #)*v(2,int)+(-41985.d0/256.d0*h3*sf0+43065.d0/128.d0*h2*cf0)*
     #v(3,int)+(6583
     #5.d0/32.d0*h3*cf0-170415.d0/256.d0*h4*sf0)*v(4,int))*f0inv3+
     #((903.d0/6
     #4.d0*h3*cf0-77.d0/16.d0*h4*sf0)*v(2,int)+(-3035.d0/256.d0*
     #h5*sf0+13275
     #.d0/256.d0*h4*cf0)*v(3,int)+(9975.d0/64.d0*h5*cf0-
     #3325.d0/128.d0*h6*sf
     #0)*v(4,int))*f0inv2+((343.d0/320.d0*h5*cf0-139.d0/960.d0*
     #h6*sf0)*v(2,int)+
     #(131.d0/64.d0*h6*cf0-239.d0/896.d0*h7*sf0)*v(3,int)+
     #(191.d0/64.d0*h7*c
     #f0-167.d0/768.d0*h8*sf0)*v(4,int))*f0inv+3.d0/320.d0*h7*
     #v(2,int)*cf0+(-h9*
     #sf0/768+19.d0/768.d0*h8*cf0)*v(3,int)+v(4,int)*h9*cf0/128)*
     #qinv3
      s9 = (32207175.d0/1024.d0*v(4,int)*h*sf0+11550825.d0/4096.d0*
     #v(3,int)*sf0)
     #*f0inv5+(153153.d0/1024.d0*v(2,int)*h*sf0+(-11550825.d0/
     #4096.d0*h*cf0+
     #3906045.d0/2048.d0*h2*sf0)*v(3,int)+(-32207175.d0/1024.d0*
     #h2*cf0+25525
     #5.d0/16.d0*h3*sf0)*v(4,int))*f0inv4+((79695.d0/1024.d0*
     #h3*sf0-153153.d
     #0/1024.d0*h2*cf0)*v(2,int)+(-3961815.d0/4096.d0*h3*cf0+
     #45375.d0/128.d0
     #*h4*sf0)*v(3,int)+(1435665.d0/1024.d0*h5*sf0-
     #5600595.d0/1024.d0*h4*cf0
     #)*v(4,int))*f0inv3+((7665.d0/1024.d0*h5*sf0-7161.d0/
     #256.d0*h4*cf0)*v(2,int
     #)+(-24255.d0/256.d0*h5*cf0+4855.d0/256.d0*h6*sf0)*v(3,int)+
     #(-284515.d0
     #/1024.d0*h6*cf0+21805.d0/512.d0*h7*sf0)*v(4,int))*f0inv2
      s8 = s9+((-3801.d0/2560.d0*h6*cf0+1603.d0/7680.d0*h7*sf0)*
     #v(2,int)+(29
     #767.d0/86016.d0*h8*sf0-83399.d0/28672.d0*h7*cf0)*v(3,int)+
     #(-2533.d0/51
     #2.d0*h8*cf0+3839.d0/9216.d0*h9*sf0)*v(4,int))*f0inv+
     #(13.d0/15360.d0*h9
     #*sf0-29.d0/1536.d0*h8*cf0)*v(2,int)+(-8185.d0/258048.d0*
     #h9*cf0+13.d0/6
     #144.d0*h10*sf0)*v(3,int)+(-71.d0/3072.d0*h10*cf0+h11*sf0/1536)*
     #v(4,int)-1/
     #f0inv*v(3,int)*h11*cf0/12288
      s9 = qinv4
      s7 = s8*s9
      s5 = s6+s7
      u1 = s4+s5


      s1 = 105.d0/2.d0*f0inv3*v(4,int)*sf0+(3.d0/2.d0*v(2,int)*sf0+
     #(45.d0/2.d0*h
     #2*sf0-105.d0/2.d0*h*cf0)*v(4,int))*f0inv2+(-5*v(4,int)*h3*cf0-
     #3.d0/2.d0*v(
     #2,int)*h*cf0)*f0inv+f0inv*v(2,int)*sf0*h2/2
      s2 = s1+f0inv*v(4,int)*h4*sf0/2+((-525.d0/8.d0*v(4,int)*h*sf0-
     #30*v(3,int)*sf0)
     #*f0inv3+(-9.d0/8.d0*v(2,int)*h*sf0+(30*h*cf0-51.d0/4.d0*h2*sf0)* 
     #v(3,int)+(
     #-30*h3*sf0+525.d0/8.d0*h2*cf0)*v(4,int))*f0inv2+((-h3*sf0/2+
     #9.d0/8.d0*
     #h2*cf0)*v(2,int)+(-h4*sf0/4+11.d0/4.d0*h3*cf0)*v(3,int)+
     #(-11.d0/8.d0*h5*sf
     #0+65.d0/8.d0*h4*cf0)*v(4,int))*f0inv+h4*v(2,int)*cf0/8+
     #h6*v(4,int)*cf0/8)*qinv
      s3 = s2+(94185.d0/64.d0*f0inv4*v(4,int)*sf0+(777.d0/64.d0*
     #v(2,int)*sf0+105
     #.d0/2.d0*v(3,int)*h*sf0+(-94185.d0/64.d0*h*cf0+46305.d0/
     #64.d0*h2*sf0)*
     #v(4,int))*f0inv3+((377.d0/64.d0*h2*sf0-777.d0/64.d0*h*cf0)*
     #v(2,int)+(375.d
     #0/16.d0*h3*sf0-105.d0/2.d0*h2*cf0)*v(3,int)+(-7455.d0/
     #32.d0*h3*cf0+355
     #5.d0/64.d0*h4*sf0)*v(4,int))*f0inv2+((-59.d0/32.d0*h3*cf0+
     #7.d0/16.d0*h
     #4*sf0)*v(2,int)+(-95.d0/16.d0*h4*cf0+7.d0/8.d0*h5*sf0)*v(3,int)
     #+(-339.d0/3
     #2.d0*h5*cf0+161.d0/96.d0*h6*sf0)*v(4,int))*f0inv+(h6*sf0/64-
     #89.d0/960.
     #d0*h5*cf0)*v(2,int)-h6*v(3,int)*cf0/16+(-5.d0/24.d0*h7*cf0+
     #h8*sf0/64)*v(4,int)
     #)*qinv2
      s4 = s3
      s6 = ((-70785.d0/128.d0*v(3,int)*sf0-1036035.d0/256.d0*
     #v(4,int)*h*sf0)*f0i
     #nv4+(-6993.d0/256.d0*v(2,int)*h*sf0+(70785.d0/128.d0*h*cf0
     #-39915.d0/12
     #8.d0*h2*sf0)*v(3,int)+(1036035.d0/256.d0*h2*cf0-30555.d0/
     #16.d0*h3*sf0)
     #*v(4,int))*f0inv3+((-1603.d0/128.d0*h3*sf0+6993.d0/256.d0*
     #h2*cf0)*v(2,int)
     #+(-4975.d0/128.d0*h4*sf0+255.d0/2.d0*h3*cf0)*v(3,int)+
     #(-29295.d0/256.d
     #0*h5*sf0+143535.d0/256.d0*h4*cf0)*v(4,int))*f0inv2+
     #((875.d0/256.d0*h4*
     #cf0-79.d0/128.d0*h5*sf0)*v(2,int)+(-131.d0/96.d0*h6*sf0+
     #277.d0/32.d0*h
     #5*cf0)*v(3,int)+(-13.d0/6.d0*h7*sf0+4473.d0/256.d0*h6*cf0)*
     #v(4,int))*f0inv
     #+(-11.d0/960.d0*h7*sf0+163.d0/1920.d0*h6*cf0)*v(2,int)+
     #(-h8*sf0/128+19
     #1.d0/1344.d0*h7*cf0)*v(3,int)+(91.d0/384.d0*h8*cf0-
     #17.d0/768.d0*h9*sf0
     #)*v(4,int)+(h8*v(2,int)*cf0/768+v(4,int)*h10*cf0/768)/
     #f0inv)*qinv3
      s9 = 209684475.d0/4096.d0*f0inv5*v(4,int)*sf0+
     #(837837.d0/4096.d0*v(2,int)*
     #sf0+920205.d0/512.d0*v(3,int)*h*sf0+(-209684475.d0/4096.d0*
     #h*cf0+12518
     #0055.d0/4096.d0*h2*sf0)*v(4,int))*f0inv4+((538923.d0/4096.d0*
     #h2*sf0-83
     #7837.d0/4096.d0*h*cf0)*v(2,int)+(227205.d0/256.d0*h3*sf0-
     #920205.d0/512
     #.d0*h2*cf0)*v(3,int)+(18264015.d0/4096.d0*h4*sf0-27642615.d0/
     #2048.d0*h
     #3*cf0)*v(4,int))*f0inv3+((-64911.d0/1024.d0*h3*cf0+11193.d0/
     #512.d0*h4*
     #sf0)*v(2,int)+(35265.d0/512.d0*h5*sf0-147675.d0/512.d0*h4*cf0)*
     #v(3,int)+(2
     #07725.d0/1024.d0*h6*sf0-1123815.d0/1024.d0*h5*cf0)*v(4,int))*
     #f0inv2
      s8 = s9+((54719.d0/61440.d0*h6*sf0-108073.d0/20480.d0*h5*cf0)*
     #v(2,int)
     #+(349.d0/192.d0*h7*sf0-6489.d0/512.d0*h6*cf0)*v(3,int)+
     #(6517.d0/2048.d
     #0*h8*sf0-7329.d0/256.d0*h7*cf0)*v(4,int))*f0inv+
     #(1919.d0/184320.d0*h8*
     #sf0-1649.d0/15360.d0*h7*cf0)*v(2,int)+(-1069.d0/5376.d0*h8*
     #cf0+55.d0/3
     #584.d0*h9*sf0)*v(3,int)+(-10913.d0/36864.d0*h9*cf0+
     #913.d0/36864.d0*h10
     #*sf0)*v(4,int)+((h10*sf0/12288-21.d0/20480.d0*h9*cf0)*
     #v(2,int)-v(3,int)*h10*cf
     #0/1536+(-11.d0/6144.d0*h11*cf0+h12*sf0/12288)*v(4,int))/f0inv
      s9 = qinv4
      s7 = s8*s9
      s5 = s6+s7
      du1 = s4+s5


      s1 = -105.d0/2.d0*f0inv4*v(4,int)*sf0+(-3.d0/2.d0*v(2,int)*sf0+
     #(-45.d0/2.d
     #0*h2*sf0+105.d0/2.d0*h*cf0)*v(4,int))*f0inv3+((-h2*sf0/2+
     #3.d0/2.d0*h*c
     #f0)*v(2,int)+(-h4*sf0/2+5*h3*cf0)*v(4,int))*f0inv2
      s2 = s1+((105.d0/4.d0*v(3,int)*sf0+735.d0/8.d0*v(4,int)*h*sf0)*
     #f0inv4+(15.
     #d0/8.d0*v(2,int)*h*sf0+(45.d0/4.d0*h2*sf0-105.d0/4.d0*h*cf0)*
     #v(3,int)+(-73
     #5.d0/8.d0*h2*cf0+165.d0/4.d0*h3*sf0)*v(4,int))*f0inv3+
     #((-15.d0/8.d0*h2
     #*cf0+3.d0/4.d0*h3*sf0)*v(2,int)+(h4*sf0/4-5.d0/2.d0*h3*cf0)*
     #v(3,int)+(-85.
     #d0/8.d0*h4*cf0+13.d0/8.d0*h5*sf0)*v(4,int))*f0inv2+
     #(-h6*v(4,int)*cf0/8-h4*
     #v(2,int)*cf0/8)*f0inv)*qinv
      s3 = s2+(-86625.d0/64.d0*f0inv5*v(4,int)*sf0+
     #(-693.d0/64.d0*v(2,int)*sf0-9
     #45.d0/16.d0*v(3,int)*h*sf0+(-46305.d0/64.d0*h2*sf0+
     #86625.d0/64.d0*h*cf
     #0)*v(4,int))*f0inv4+((-413.d0/64.d0*h2*sf0+693.d0/
     #64.d0*h*cf0)*v(2,int)+(-
     #105.d0/4.d0*h3*sf0+945.d0/16.d0*h2*cf0)*v(3,int)+
     #(-4935.d0/64.d0*h4*sf
     #0+8715.d0/32.d0*h3*cf0)*v(4,int))*f0inv3+
     #((91.d0/32.d0*h3*cf0-7.d0/8.d
     #0*h4*sf0)*v(2,int)+(-15.d0/16.d0*h5*sf0+105.d0/16.d0*
     #h4*cf0)*v(3,int)+(525
     #.d0/32.d0*h5*cf0-245.d0/96.d0*h6*sf0)*v(4,int))*f0inv2+
     #((-h6*sf0/64+16
     #1.d0/960.d0*h5*cf0)*v(2,int)+h6*v(3,int)*cf0/16+
     #(-h8*sf0/64+13.d0/48.d0*h7
     #*cf0)*v(4,int))*f0inv)*qinv2
      s4 = s3
      s6 = ((32175.d0/64.d0*v(3,int)*sf0+1126125.d0/256.d0*
     #v(4,int)*h*sf0)*f0inv
     #5+(7623.d0/256.d0*v(2,int)*h*sf0+(-32175.d0/64.d0*h*cf0+
     #40095.d0/128.d
     #0*h2*sf0)*v(3,int)+(273735.d0/128.d0*h3*sf0-1126125.d0/
     #256.d0*h2*cf0)*
     #v(4,int))*f0inv4+((945.d0/64.d0*h3*sf0-7623.d0/256.d0*
     #h2*cf0)*v(2,int)+(62
     #25.d0/128.d0*h4*sf0-18645.d0/128.d0*h3*cf0)*v(3,int)+
     #(39165.d0/256.d0*
     #h5*sf0-172095.d0/256.d0*h4*cf0)*v(4,int))*f0inv3+
     #((147.d0/128.d0*h5*sf
     #0-1239.d0/256.d0*h4*cf0)*v(2,int)+(335.d0/192.d0*h6*sf0-
     #45.d0/4.d0*h5*
     #cf0)*v(3,int)+(-6825.d0/256.d0*h6*cf0+175.d0/48.d0*h7*
     #sf0)*v(4,int))*f0inv
     #2+((43.d0/1920.d0*h7*sf0-63.d0/320.d0*h6*cf0)*v(2,int)+
     #(-451.d0/2688.d
     #0*h7*cf0+h8*sf0/128)*v(3,int)+(-149.d0/384.d0*h8*cf0+
     #23.d0/768.d0*h9*s
     #f0)*v(4,int))*f0inv-h8*v(2,int)*cf0/768-v(4,int)*h10*
     #cf0/768)*qinv3
      s9 = -195270075.d0/4096.d0*f0inv6*v(4,int)*sf0+
     #(-765765.d0/4096.d0*v(2,int
     #)*sf0-482625.d0/256.d0*v(3,int)*h*sf0+(-125900775.d0/
     #4096.d0*h2*sf0+19
     #5270075.d0/4096.d0*h*cf0)*v(4,int))*f0inv5+((765765.d0/
     #4096.d0*h*cf0-5
     #55555.d0/4096.d0*h2*sf0)*v(2,int)+(-495495.d0/
     #512.d0*h3*sf0+482625.d0/
     #256.d0*h2*cf0)*v(3,int)+(30405375.d0/2048.d0*h3*cf0-
     #21636615.d0/4096.d
     #0*h4*sf0)*v(4,int))*f0inv4+((75075.d0/1024.d0*h3*cf0-
     #7161.d0/256.d0*h4
     #*sf0)*v(2,int)+(-11385.d0/128.d0*h5*sf0+173745.d0/
     #512.d0*h4*cf0)*v(3,int)+
     #(1426425.d0/1024.d0*h5*cf0-285285.d0/1024.d0*h6*sf0)*
     #v(4,int))*f0inv3
      s8 = s9+((-6433.d0/4096.d0*h6*sf0+31493.d0/4096.d0*h5*cf0)*
     #v(2,int)+(9
     #075.d0/512.d0*h6*cf0-675.d0/256.d0*h7*sf0)*v(3,int)+
     #(22165.d0/512.d0*h
     #7*cf0-10925.d0/2048.d0*h8*sf0)*v(4,int))*f0inv2+
     #((247.d0/1024.d0*h7*cf
     #0-1003.d0/36864.d0*h8*sf0)*v(2,int)+(-103.d0/5376.d0*
     #h9*sf0+501.d0/179
     #2.d0*h8*cf0)*v(3,int)+(-1537.d0/36864.d0*h10*sf0+6491.d0/
     #12288.d0*h9*c
     #f0)*v(4,int))*f0inv+(-h10*sf0/12288+127.d0/61440.d0*h9*cf0)*
     #v(2,int)+v(3,int)*
     #h10*cf0/1536+(5.d0/2048.d0*h11*cf0-h12*sf0/12288)*v(4,int)
      s9 = qinv4
      s7 = s8*s9
      s5 = s6+s7
      v1 = s4+s5

      s1 = -15.d0/2.d0*f0inv3*v(3,int)*sf0+(-3*h2*sf0+15.d0/
     #2.d0*h*cf0)*v(3,int)
     #*f0inv2+f0inv*v(3,int)*h3*cf0/2
      s2 = s1+((2205.d0/8.d0*f0inv4*sf0+(975.d0/8.d0*h2*sf0-
     #2205.d0/8.d0
     #*h*cf0)*f0inv3+(33.d0/8.d0*h4*sf0-30*h3*cf0)*f0inv2-
     #f0inv*h5*cf0/4
     #)*v(4,int)+(15.d0/4.d0*f0inv3*sf0+(3.d0/2.d0*h2*sf0-
     #15.d0/4.d0*h*cf0)*
     #f0inv2-f0inv*h3*cf0/4)*v(2,int)+15.d0/2.d0*f0inv3*v(3,int)*
     #h*sf0+(27.d0/8.
     #d0*h3*sf0-15.d0/2.d0*h2*cf0)*v(3,int)*f0inv2+(h5*sf0/8-
     #7.d0/8.d0*h4*cf
     #0)*v(3,int)*f0inv)*qinv
      s3 = s2+((-17955.d0/32.d0*f0inv4*h*sf0+(17955.d0/
     #32.d0*h2*cf0-4095
     #.d0/16.d0*h3*sf0)*f0inv3+(2205.d0/32.d0*h4*cf0-375.d0/
     #32.d0*h5*sf0
     #)*f0inv2+(-h7*sf0/16+39.d0/32.d0*h6*cf0)*f0inv)*v(4,int)+
     #(-189.d0/32.d
     #0*f0inv3*h*sf0+(-81.d0/32.d0*h3*sf0+189.d0/32.d0*h2*cf0)*
     #f0inv2+(-
     #9.d0/160.d0*h5*sf0+9.d0/16.d0*h4*cf0)*f0inv)*v(2,int)-
     #7245.d0/64.d0*f0
     #inv4*v(3,int)*sf0+(-1785.d0/32.d0*h2*sf0+7245.d0/64.d0*h*cf0)*
     #v(3,int)*f0i
     #nv3+(-35.d0/8.d0*h4*sf0+1155.d0/64.d0*h3*cf0)*v(3,int)*
     #f0inv2+(7.d0/8.
     #d0*h5*cf0-7.d0/48.d0*h6*sf0)*v(3,int)*f0inv+h7*
     #v(3,int)*cf0/64)*qinv2
      s4 = s3
      s6 = ((2027025.d0/256.d0*f0inv5*sf0+(-2027025.d0/
     #256.d0*h*cf0+1119
     #195.d0/256.d0*h2*sf0)*f0inv4+(-3465.d0/2.d0*h3*cf0+
     #132615.d0/256.d
     #0*h4*sf0)*f0inv3+(2485.d0/128.d0*h6*sf0-7455.d0/
     #64.d0*h5*cf0)*f0in
     #v2+(143.d0/768.d0*h8*sf0-149.d0/64.d0*h7*cf0)*f0inv-
     #h9*cf0/128)*v(
     #4,int)+(693.d0/16.d0*f0inv4*sf0+(819.d0/32.d0*h2*sf0-
     #693.d0/16.d0*h*cf
     #0)*f0inv3+(7.d0/2.d0*h4*sf0-357.d0/32.d0*h3*cf0)*f0inv2+
     #(47.d0/480
     #.d0*h6*sf0-119.d0/160.d0*h5*cf0)*f0inv-h7*cf0/160)*
     #v(2,int)+18315.d0/6
     #4.d0*f0inv4*v(3,int)*h*sf0+(-18315.d0/64.d0*h2*cf0+
     #34245.d0/256.d0*h3*
     #sf0)*v(3,int)*f0inv3+(-9825.d0/256.d0*h4*cf0+1935.d0/
     #256.d0*h5*sf0)*v(
     #3,int)*f0inv2+(389.d0/2688.d0*h7*sf0-9.d0/8.d0*h6*cf0)*
     #v(3,int)*f0inv+(h9*
     #sf0/768-13.d0/768.d0*h8*cf0)*v(3,int))*qinv3
      s9 = (-28603575.d0/1024.d0*f0inv5*h*sf0+(28603575.d0/
     #1024.d0*h2*cf
     #0-3528525.d0/256.d0*h3*sf0)*f0inv4+(4579575.d0/1024.d0*
     #h4*cf0-1093
     #785.d0/1024.d0*h5*sf0)*f0inv3+(-14945.d0/512.d0*h7*sf0+
     #202895.d0/1
     #024.d0*h6*cf0)*f0inv2+(-2815.d0/9216.d0*h9*sf0+1745.d0/
     #512.d0*h8*c
     #f0)*f0inv-h11*sf0/1536+59.d0/3072.d0*h10*cf0)*v(4,int)+
     #(-135135.d0/102
     #4.d0*f0inv4*h*sf0+(-67221.d0/1024.d0*h3*sf0+135135.d0/
     #1024.d0*h2*c
     #f0)*f0inv3+(693.d0/32.d0*h4*cf0-5355.d0/1024.d0*h5*sf0)*
     #f0inv2+(-6
     #3.d0/512.d0*h7*sf0+483.d0/512.d0*h6*cf0)*f0inv+27.d0/
     #2560.d0*h8*cf
     #0-7.d0/15360.d0*h9*sf0)*v(2,int)-11550825.d0/4096.d0*f0inv5*
     #v(3,int)*sf0+(
     #11550825.d0/4096.d0*h*cf0-3571425.d0/2048.d0*h2*sf0)*
     #v(3,int)*f0inv4
      s8 = s9+(-139425.d0/512.d0*h4*sf0+3292575.d0/4096.d0*h3*cf0)*
     #v(3,int)*
     #f0inv3+(2145.d0/32.d0*h5*cf0-6185.d0/512.d0*h6*sf0)*v(3,int)*
     #f0inv2+(-
     #15095.d0/86016.d0*h8*sf0+46775.d0/28672.d0*h7*cf0)*v(3,int)*
     #f0inv+(-3.
     #d0/2048.d0*h10*sf0+4345.d0/258048.d0*h9*cf0)*v(3,int)+
     #1/f0inv*h11*v(3,int)
     #*cf0/12288
      s9 = qinv4
      s7 = s8*s9
      s5 = s6+s7
      dv1 = s4+s5


        v44 = v(4,int)**2
        v22 = v(2,int)**2
        v33 = v(3,int)**2
        v23 = v(2,int)*v(3,int)
        v24 = v(2,int)*v(4,int)
        v34 = v(4,int)*v(3,int)
        v3 = v(3,int)
        v4 = v(4,int)
        vv2 = v(2,int)

c   second correction asymptotic

c  u2=sum(c[k]*qinv^k)
c  du2=sum(w[k]*qinv^k)
c  v2=sum(s[k]*qinv^k)
c  dv2=sum(z[k]*qinv^k)





c u2=sum(c[k]*Qinv^k)
c du2=sum(w[k]*Qinv^k)
c v2=sum(s[k]*Qinv^k)
c dv2=sum(z[k]*Qinv^k)



      s1=(-99225.D0/2.D0*v34*sf0+11025.D0/8.D0*h*sf0*v44)*F0inv6+(-1
     #575.D0/4.D0*v23*sf0+(-11025.D0/8.D0*h2*cf0+5775.D0/8.D0*h3*sf0)
     #*v44+99225.D0/2.D0*v34*cf0*h-22995*v34*h2*sf0-225.D0/8.D0*h*sf
     #0*v33+315.D0/4.D0*v24*h*sf0)*F0inv5
      sec(0)=s1+(12915.D0/2.D0*v34*h3*cf0+135.D0/4.D0*h3*v24*sf0
     #-705.
     #D0/4.D0*h2*v23*sf0+(-525.D0/2.D0*h4*cf0+555.D0/8.D0*h5*sf0)*v44
     #-315.D0/4.D0*v24*h2*cf0+9.D0/8.D0*h*sf0*v22+1575.D0/4.D0*v23
     #*cf0*h-1200*h4*v34*sf0+(225.D0/8.D0*h2*cf0-105.D0/8.D0*h3*sf0)*v
     #33)*F0inv4+((-25.D0/2.D0*h6*cf0+5.D0/4.D0*h7*sf0)*v44+(-9.D0/8.D0*
     #h2*cf0+3.D0/8.D0*h3*sf0)*v22-12*v34*h6*sf0+150*v34*h5*cf0+(15.
     #D0/4.D0*h4*cf0-3.D0/4.D0*h5*sf0)*v33+3.D0/4.D0*v24*h5*sf0-15.D0
     #/2.D0*v24*h4*cf0+45*v23*h3*cf0-27.D0/4.D0*v23*h4*sf0)*F0i
     #nv3+(-v44*h9*sf0/72+v34*h7*cf0/2-v22*h5*sf0/40+(h6*cf0/8-h7*sf0/
     #56)*v33+v23*h5*cf0/2)*F0inv2

      s1 = 206531325.D0/32.D0*F0inv7*v44*sf0+(904365.D0/16.D0*v24*sf0
     #+809325.D0/32.D0*sf0*v33+1195425.D0/8.D0*h*v34*sf0+(-206531325.D
     #0/32.D0*cf0*h+24306975.D0/8.D0*h2*sf0)*v44)*F0inv6+(-1195425.D0/8.
     #D0*v34*h2*cf0+(188595.D0/16.D0*h2*sf0-809325.D0/32.D0*cf0*h)*v33
     #+51975.D0/2.D0*v24*h2*sf0+(-28384125.D0/32.D0*h3*cf0+709905.D0/
     #4.D0*h4*sf0)*v44-904365.D0/16.D0*v24*cf0*h+5859.D0/32.D0*sf0*v2
     #2+561375.D0/8.D0*v34*h3*sf0+15525.D0/16.D0*v23*h*sf0)*F0inv5
      s2 = s1+((-107415.D0/32.D0*h3*cf0+20565.D0/32.D0*h4*sf0)*v33+(-585
     #9.D0/32.D0*cf0*h+1281.D0/16.D0*h2*sf0)*v22-40725.D0/2.D0*v34*h4*
     #cf0+32265.D0/8.D0*v34*h5*sf0+(-403725.D0/16.D0*h5*cf0+40355.D0/1
     #6.D0*h6*sf0)*v44-15525.D0/16.D0*v23*h2*cf0+10185.D0/8.D0*v24
     #*h4*sf0+7137.D0/16.D0*v23*h3*sf0-114345.D0/16.D0*v24*h3*cf0)
     #*F0inv4
      sec(1)=s2+(225.D0/4.D0*h7*v34*sf0+(-2745.D0/32.D0*h5*cf0+
     #65.D0/8.D
     #0*h6*sf0)*v33+81.D0/8.D0*h6*v24*sf0+(-5215.D0/32.D0*h7*cf0+155.
     #D0/32.D0*h8*sf0)*v44+87.D0/4.D0*h5*v23*sf0+(39.D0/16.D0*h4*sf0-
     #609.D0/32.D0*h3*cf0)*v22-147*v24*h5*cf0-981.D0/8.D0*v23*h4*c
     #f0-2265.D0/4.D0*v34*h6*cf0)*F0inv3+(23.D0/168.D0*v34*h9*sf0-39
     #.D0/16.D0*v23*h6*cf0-5.D0/16.D0*v24*h7*cf0-15.D0/4.D0*v34*
     #h8*cf0+(17.D0/288.D0*h9*cf0+h10*sf0/72)*v44+79.D0/560.D0*v23*h7
     #*sf0+(-67.D0/112.D0*h7*cf0+11.D0/224.D0*h8*sf0)*v33+(-13.D0/80.D0*
     #h5*cf0+h6*sf0/40)*v22)*F0inv2+(-v33*h9*cf0/224-v22*h7*cf0/160-v44*
     #h11*cf0/288)*F0inv

      s1 = (-583107525.D0/64.D0*v34*sf0-6583060575.D0/256.D0*h*sf0*v44
     #)*F0inv7+((-3124368975.D0/256.D0*h3*sf0+6583060575.D0/256.D0*h2*cf
     #0)*v44-4420845.D0/128.D0*v23*sf0+583107525.D0/64.D0*v34*cf0*h
     #-22683375.D0/256.D0*h*sf0*v33-24999975.D0/128.D0*v24*h*sf0-7306
     #9425.D0/16.D0*v34*h2*sf0)*F0inv6+(24999975.D0/128.D0*v24*h2*c
     #f0+97908525.D0/64.D0*v34*h3*cf0-11679525.D0/128.D0*h3*v24*sf0
     #-2242449.D0/128.D0*h2*v23*sf0-6117705.D0/16.D0*h4*v34*sf0+(-1
     #92985965.D0/256.D0*h5*sf0+465007725.D0/128.D0*h4*cf0)*v44-136917.D
     #0/256.D0*h*sf0*v22+(-10660815.D0/256.D0*h3*sf0+22683375.D0/256.D0*
     #h2*cf0)*v33+4420845.D0/128.D0*v23*cf0*h)*F0inv5
      s2 = s1+(418275.D0/16.D0*v24*h4*cf0+2396295.D0/32.D0*v34*h5*c
     #f0-197271.D0/128.D0*v23*h4*sf0+(-51455.D0/4.D0*h7*sf0+14635525.
     #D0/128.D0*h6*cf0)*v44+384417.D0/64.D0*v23*h3*cf0-646875.D0/128.
     #D0*v24*h5*sf0+(-77085.D0/32.D0*h5*sf0+1549845.D0/128.D0*h4*cf0)
     #*v33-374865.D0/32.D0*v34*h6*sf0+(136917.D0/256.D0*h2*cf0-62109.D
     #0/256.D0*h3*sf0)*v22)*F0inv4
      s3 = s2+((-2875.D0/48.D0*h9*sf0+135355.D0/128.D0*h8*cf0)*v44+(8752
     #5.D0/256.D0*h6*cf0-8965.D0/256.D0*h7*sf0)*v33+93855.D0/64.D0*v34
     #*h7*cf0+19617.D0/64.D0*v23*h5*cf0-9295.D0/64.D0*v34*h8*sf0+43
     #515.D0/64.D0*v24*h6*cf0+(-2731.D0/256.D0*h5*sf0+8235.D0/128.D0*
     #h4*cf0)*v22-3027.D0/64.D0*v23*h6*sf0-4015.D0/64.D0*v24*h7*sf
     #0)*F0inv3
      sec(2)=s3+(-95.D0/896.D0*v24*h9*sf0+(-353.D0/4480.D0*h7*sf0+
     #709.D
     #0/640.D0*h6*cf0)*v22+14851.D0/1344.D0*v34*h9*cf0+(-269.D0/1792.D
     #0*h9*sf0+2327.D0/896.D0*h8*cf0)*v33-6001.D0/13440.D0*v23*h8*sf0
     #+235.D0/64.D0*v24*h8*cf0+(4663.D0/2304.D0*h10*cf0-6899.D0/17740
     #8.D0*h11*sf0)*v44-101.D0/168.D0*v34*h10*sf0+771.D0/140.D0*v23
     #*h7*cf0)*F0inv2+(25.D0/1344.D0*v34*h11*cf0+(7.D0/1728.D0*h12*cf0
     #-h13*sf0/2304)*v44+(7.D0/960.D0*h8*cf0-h9*sf0/1280)*v22+11.D0/560.
     #D0*v23*h9*cf0+(-h11*sf0/1792+7.D0/768.D0*h10*cf0)*v33)*F0inv

      s2 = (2522101725.D0/1024.D0*sf0*v33+10468355625.D0/256.D0*h*v34*
     #sf0+2804997195.D0/512.D0*v24*sf0+(-1126100941875.D0/1024.D0*cf0
     #*h+298602056025.D0/512.D0*h2*sf0)*v44)*F0inv7+((-2522101725.D0/102
     #4.D0*cf0*h+688512825.D0/512.D0*h2*sf0)*v33+(-221837131425.D0/1024.
     #D0*h3*cf0+31483874175.D0/512.D0*h4*sf0)*v44-2804997195.D0/512.D0*v
     #v2*v4*cf0*h-10468355625.D0/256.D0*v34*h2*cf0+763416225.D0/256.D0
     #*v24*h2*sf0+5067998325.D0/256.D0*v34*h3*sf0+70212285.D0/512.D
     #0*v23*h*sf0+9401535.D0/1024.D0*sf0*v22)*F0inv6
      s3 = s2+(87272757.D0/256.D0*v24*h4*sf0+354526965.D0/256.D0*v4*v
     #3*h5*sf0+33859683.D0/512.D0*v23*h3*sf0-591833385.D0/512.D0*vv2*
     #v4*h3*cf0-70212285.D0/512.D0*v23*h2*cf0+(621375495.D0/256.D0*h6
     #*sf0-7023251625.D0/512.D0*h5*cf0)*v44-789273225.D0/128.D0*v34*h4
     #*cf0+(-9401535.D0/1024.D0*cf0*h+1334619.D0/256.D0*h2*sf0)*v22+(159
     #234075.D0/1024.D0*h4*sf0-536325075.D0/1024.D0*h3*cf0)*v33)*F0inv5
      s1 = s3+(862983.D0/64.D0*h6*v24*sf0+1157409.D0/256.D0*h5*v23
     #*sf0-19800495.D0/256.D0*v24*h5*cf0+1040355.D0/32.D0*h7*v34*sf
     #0-15243735.D0/64.D0*v34*h6*cf0+(3238125.D0/512.D0*h6*sf0-3650575
     #5.D0/1024.D0*h5*cf0)*v33+(-349765845.D0/1024.D0*h7*cf0+9755925.D0/
     #256.D0*h8*sf0)*v44-2613897.D0/128.D0*v23*h4*cf0+(170181.D0/256.
     #D0*h4*sf0-2204631.D0/1024.D0*h3*cf0)*v22)*F0inv4+(41845.D0/128.D0*
     #v34*h9*sf0+91797.D0/512.D0*v24*h8*sf0-230355.D0/64.D0*v34*h
     #8*cf0+51687.D0/512.D0*v23*h7*sf0-389895.D0/512.D0*v23*h6*cf0
     #+(-7675355.D0/2304.D0*h9*cf0+31985.D0/144.D0*h10*sf0)*v44+(-77385.
     #D0/512.D0*h5*cf0+12735.D0/512.D0*h6*sf0)*v22+(327735.D0/3584.D0*h8
     #*sf0-3108765.D0/3584.D0*h7*cf0)*v33-918885.D0/512.D0*v24*h7*cf0
     #)*F0inv3
      sec(3)=s1+(47807.D0/53760.D0*v23*h9*sf0+16487.D0/26880.D0*
     #v24*
     #h10*sf0-231587.D0/17920.D0*v24*h9*cf0+86117.D0/59136.D0*v34*h
     #11*sf0+(-11255.D0/1536.D0*h9*cf0+1593.D0/3584.D0*h10*sf0)*v33+(-10
     #4103.D0/35840.D0*h7*cf0+25589.D0/107520.D0*h8*sf0)*v22-47871.D0/44
     #80.D0*v23*h8*cf0-130927.D0/5376.D0*v34*h10*cf0+(-1902643.D0/1
     #77408.D0*h11*cf0+185153.D0/532224.D0*h12*sf0)*v44)*F0inv2+11261009
     #41875.D0/1024.D0*sf0*v44*F0inv8+((-4847.D0/532224.D0*h13*cf0+h14*s
     #f0/1728)*v44-53.D0/3584.D0*v24*h11*cf0-523.D0/8064.D0*v34*h12
     #*cf0+3.D0/1792.D0*v34*h13*sf0-2887.D0/53760.D0*v23*h10*cf0+97
     #.D0/53760.D0*v23*h11*sf0+(-67.D0/3072.D0*h11*cf0+23.D0/21504.D0
     #*h12*sf0)*v33+(h10*sf0/960-1621.D0/107520.D0*h9*cf0)*v22)*F0inv-h1
     #5*cf0*v44/27648-v22*h11*cf0/15360-h13*v33*cf0/21504


      sew(0)=-2767275.D0/8.D0*F0inv6*v44*sf0+(-15975.D0/8.D0*sf0*v33+
     #(-322
     #875.D0/2.D0*h2*sf0+2767275.D0/8.D0*cf0*h)*v44-17325.D0/4.D0*v24
     #*sf0)*F0inv5+(-171.D0/8.D0*sf0*v22-7815.D0/4.D0*v24*h2*sf0+(369
     #075.D0/8.D0*h3*cf0-71025.D0/8.D0*h4*sf0)*v44+(-1845.D0/2.D0*h2*sf0
     #+15975.D0/8.D0*cf0*h)*v33+17325.D0/4.D0*v24*cf0*h)*F0inv4+((949
     #5.D0/8.D0*h5*cf0-435.D0/4.D0*h6*sf0)*v44+(-93.D0/2.D0*h4*sf0+2055.
     #D0/8.D0*h3*cf0)*v33+(171.D0/8.D0*cf0*h-9*h2*sf0)*v22+510*v24*h3
     #*cf0-81*v24*h4*sf0)*F0inv3+((-h8*sf0/8+25.D0/4.D0*h7*cf0)*v44+(
     #-h6*sf0/4+21.D0/4.D0*h5*cf0)*v33+(-h4*sf0/8+15.D0/8.D0*h3*cf0)*v22
     #-h6*v24*sf0/4+29.D0/4.D0*v24*h5*cf0)*F0inv2+(-v44*h9*cf0/72-
     #v33*h7*cf0/56-v22*h5*cf0/40)*F0inv

      s1 = (30440025.D0/32.D0*h*sf0*v44+6288975.D0/8.D0*v34*sf0)*F0inv
     #6+(2943405.D0/8.D0*v34*h2*sf0+(14390775.D0/32.D0*h3*sf0-30440025
     #.D0/32.D0*h2*cf0)*v44+66555.D0/16.D0*v23*sf0+143775.D0/32.D0*h*
     #sf0*v33+155925.D0/16.D0*v24*h*sf0-6288975.D0/8.D0*v34*cf0*h)*
     #F0inv5+(7593.D0/4.D0*h2*v23*sf0+165105.D0/8.D0*h4*v34*sf0+119
     #7.D0/32.D0*h*sf0*v22-105885*v34*h3*cf0+(-143775.D0/32.D0*h2*cf0+
     #67635.D0/32.D0*h3*sf0)*v33+(-1061025.D0/8.D0*h4*cf0+433125.D0/16.D
     #0*h5*sf0)*v44+36015.D0/8.D0*h3*v24*sf0-155925.D0/16.D0*v24*h
     #2*cf0-66555.D0/16.D0*v23*cf0*h)*F0inv4
      s2 = s1+(87*v23*h4*sf0+(531.D0/32.D0*h3*sf0-1197.D0/32.D0*h2*cf
     #0)*v22+(-9855.D0/16.D0*h4*cf0+3915.D0/32.D0*h5*sf0)*v33+915.D0/4.D
     #0*v24*h5*sf0+(13845.D0/32.D0*h7*sf0-127995.D0/32.D0*h6*cf0)*v44
     #-8187.D0/16.D0*v23*h3*cf0-20055.D0/16.D0*v24*h4*cf0-5625.D0/
     #2.D0*v34*h5*cf0+1055.D0/4.D0*v34*h6*sf0)*F0inv3
      sew(1)=s2+(3.D0/8.D0*v23*h6*sf0-55.D0/2.D0*v24*h6*cf0+(9.D0/16
     #.D0*h5*sf0-33.D0/8.D0*h4*cf0)*v22+3.D0/8.D0*v34*h8*sf0+(53.D0/32
     #.D0*h9*sf0-535.D0/16.D0*h8*cf0)*v44+2*v24*h7*sf0-31.D0/2.D0*v4*
     #v3*h7*cf0+(-135.D0/8.D0*h6*cf0+3.D0/2.D0*h7*sf0)*v33-71.D0/8.D0*vv
     #2*v3*h5*cf0)*F0inv2+((-h9*sf0/224-3.D0/56.D0*h8*cf0)*v33+(-3.D0/16
     #0.D0*h6*cf0-h7*sf0/160)*v22-v24*h8*cf0/16+(-h11*sf0/288-7.D0/28
     #8.D0*h10*cf0)*v44+9.D0/560.D0*v23*h7*cf0+v34*h9*cf0/84)*F0inv

      s2= -22910071275.D0/256.D0*F0inv7*v44*sf0+((22910071275.D0/256.D0
     #*cf0*h-5630154075.D0/128.D0*h2*sf0)*v44-81756675.D0/32.D0*h*v34*
     #sf0-66891825.D0/256.D0*sf0*v33-74189115.D0/128.D0*v24*sf0)*F0in
     #v6
      s3 = s2+(-336501.D0/256.D0*sf0*v22-19333215.D0/16.D0*v34*h3*sf0-
     #36384975.D0/128.D0*v24*h2*sf0+81756675.D0/32.D0*v34*h2*cf0+(3
     #623617725.D0/256.D0*h3*cf0-856622295.D0/256.D0*h4*sf0)*v44-732105.
     #D0/64.D0*v23*h*sf0+(66891825.D0/256.D0*cf0*h-2059695.D0/16.D0*h
     #2*sf0)*v33+74189115.D0/128.D0*v24*cf0*h)*F0inv5
      s1 = s3+((-82161.D0/128.D0*h2*sf0+336501.D0/256.D0*cf0*h)*v22-3399
     #03.D0/64.D0*v23*h3*sf0+(10657845.D0/256.D0*h3*cf0-1269765.D0/12
     #8.D0*h4*sf0)*v33-682137.D0/32.D0*v24*h4*sf0+(-11712465.D0/128.D
     #0*h6*sf0+157862415.D0/256.D0*h5*cf0)*v44+5827635.D0/64.D0*v24*h
     #3*cf0-2333025.D0/32.D0*v34*h5*sf0+11414205.D0/32.D0*v34*h4*cf0
     #+732105.D0/64.D0*v23*h2*cf0)*F0inv4+(-18635.D0/16.D0*h7*v34*s
     #f0+(355255.D0/32.D0*h7*cf0-141095.D0/128.D0*h8*sf0)*v44+(59175.D0/
     #32.D0*h5*cf0-17805.D0/64.D0*h6*sf0)*v33+(52155.D0/256.D0*h3*cf0-11
     #969.D0/256.D0*h4*sf0)*v22+23967.D0/16.D0*v23*h4*cf0-69775.D0/12
     #8.D0*h6*v24*sf0-17931.D0/64.D0*h5*v23*sf0+492105.D0/128.D0*v
     #v2*v4*h5*cf0+345105.D0/32.D0*v34*h6*cf0)*F0inv3
      sew(2)=s1+(-43.D0/16.D0*v23*h7*sf0+(8691.D0/256.D0*h7*cf0-
     #831.D0/
     #256.D0*h8*sf0)*v33-139.D0/32.D0*v34*h9*sf0-1931.D0/384.D0*v24
     #*h8*sf0+1933.D0/32.D0*v24*h7*cf0+561.D0/16.D0*v23*h6*cf0+142
     #7.D0/16.D0*v34*h8*cf0+(-163.D0/160.D0*h6*sf0+10309.D0/1280.D0*h5
     #*cf0)*v22+(-6221.D0/1152.D0*h10*sf0+101507.D0/1152.D0*h9*cf0)*v44)
     #*F0inv2+(3797.D0/13440.D0*v24*h9*cf0+v34*h11*sf0/336+(12895.D
     #0/59136.D0*h11*cf0-11.D0/6912.D0*h12*sf0)*v44+9.D0/2240.D0*v23*
     #h9*sf0-v24*h10*sf0/128+(1069.D0/13440.D0*h7*cf0+h8*sf0/3840)*v2
     #2+87.D0/1120.D0*v23*h8*cf0+55.D0/672.D0*v34*h10*cf0+(383.D0/1
     #792.D0*h9*cf0-13.D0/2688.D0*h10*sf0)*v33)*F0inv-h11*v33*cf0/1792-h
     #13*v44*cf0/2304-h9*v22*cf0/1280

      s2=(389471211675.D0/1024.D0*h*sf0*v44+13154102325.D0/128.D0*v4*v
     #3*sf0)*F0inv7+(1003377375.D0/1024.D0*h*sf0*v33+(187857490275.D0/10
     #24.D0*h3*sf0-389471211675.D0/1024.D0*h2*cf0)*v44+13728004875.D0/25
     #6.D0*v34*h2*sf0+1112836725.D0/512.D0*v24*h*sf0+151872435.D0/5
     #12.D0*v23*sf0-13154102325.D0/128.D0*v34*cf0*h)*F0inv6+(-15187
     #2435.D0/512.D0*v23*cf0*h+40402791.D0/256.D0*h2*v23*sf0+(-100
     #3377375.D0/1024.D0*h2*cf0+481601835.D0/1024.D0*h3*sf0)*v33+1330822
     #35.D0/128.D0*h3*v24*sf0+(6430079955.D0/512.D0*h5*sf0-2901687652
     #5.D0/512.D0*h4*cf0)*v44+4374513.D0/1024.D0*h*sf0*v22-4958603325.D0
     #/256.D0*v34*h3*cf0+1363379355.D0/256.D0*h4*v34*sf0-1112836725.
     #D0/512.D0*v24*h2*cf0)*F0inv5
      s3 = s2+(17314209.D0/256.D0*v24*h5*sf0+(-4374513.D0/1024.D0*h2*
     #cf0+2065041.D0/1024.D0*h3*sf0)*v22+(-73571355.D0/512.D0*h4*cf0+320
     #20065.D0/1024.D0*h5*sf0)*v33+2138895.D0/128.D0*v23*h4*sf0+(2893
     #52895.D0/1024.D0*h7*sf0-2170491375.D0/1024.D0*h6*cf0)*v44+12710325
     #.D0/64.D0*v34*h6*sf0-30181437.D0/512.D0*v23*h3*cf0-161383365.
     #D0/512.D0*v24*h4*cf0-147569175.D0/128.D0*v34*h5*cf0)*F0inv4
      s1 = s3+((-2634885.D0/512.D0*h6*cf0+85185.D0/128.D0*h7*sf0)*v33+39
     #213.D0/64.D0*v23*h6*sf0-6974295.D0/256.D0*v34*h7*cf0+756075.D
     #0/256.D0*v34*h8*sf0-1390917.D0/128.D0*v24*h6*cf0-467511.D0/12
     #8.D0*v23*h5*cf0+(1386075.D0/512.D0*h9*sf0-15608515.D0/512.D0*h8
     #*cf0)*v44+(61605.D0/512.D0*h5*sf0-303435.D0/512.D0*h4*cf0)*v22+345
     #525.D0/256.D0*v24*h7*sf0)*F0inv3+((3049.D0/512.D0*h9*sf0-35589.
     #D0/512.D0*h8*cf0)*v33+15713.D0/1536.D0*v24*h9*sf0+(-90657.D0/51
     #20.D0*h6*cf0+9847.D0/5120.D0*h7*sf0)*v22-1387101.D0/17920.D0*vv2*v
     #3*h7*cf0-67581.D0/512.D0*v24*h8*cf0+(1757.D0/144.D0*h11*sf0-920
     #821.D0/4608.D0*h10*cf0)*v44+377033.D0/53760.D0*v23*h8*sf0-11097
     #7.D0/448.D0*v34*h9*cf0+27387.D0/1792.D0*v34*h10*sf0)*F0inv2
      sew(3)=s1+(9.D0/1280.D0*v23*h10*sf0-4265.D0/10752.D0*v23*h9*cf
     #0+121.D0/4480.D0*vv2*h11*v4*sf0+(-2939.D0/7168.D0*h10*cf0+421.D0/2
     #1504.D0*h11*sf0)*v33+(-671.D0/4480.D0*h8*cf0+45.D0/7168.D0*h9*sf0)
     #*v22+19.D0/2304.D0*h12*v34*sf0-33247.D0/53760.D0*h10*v24*cf0+
     #(2465.D0/133056.D0*h13*sf0-23213.D0/39424.D0*h12*cf0)*v44-35851.D0
     #/59136.D0*v34*h11*cf0)*F0inv+(-h12*cf0/5376-h13*sf0/21504)*v33+9
     #.D0/17920.D0*h11*v23*cf0+h13*v34*cf0/2688+(-h15*sf0/27648+h14
     #*cf0/27648)*v44+(-h11*sf0/15360+h10*cf0/3072)*v22-h12*v24*cf0/1
     #536

      ses(0)=2789325.D0/8.D0*F0inv7*v44*sf0+(15525.D0/8.D0*sf0*v33+
     #(163800
     #*h2*sf0-2789325.D0/8.D0*cf0*h)*v44+17955.D0/4.D0*v24*sf0)*F0inv
     #6+((-15525.D0/8.D0*cf0*h+1755.D0/2.D0*h2*sf0)*v33-17955.D0/4.D0*vv
     #2*v4*cf0*h+(-380625.D0/8.D0*h3*cf0+75495.D0/8.D0*h4*sf0)*v44+8295.
     #D0/4.D0*v24*h2*sf0+189.D0/8.D0*sf0*v22)*F0inv5+((75.D0/2.D0*h4*
     #sf0-1845.D0/8.D0*h3*cf0)*v33+(-10605.D0/8.D0*h5*cf0+525.D0/4.D0*h6
     #*sf0)*v44-1155.D0/2.D0*v24*h3*cf0+105*v24*h4*sf0+(21.D0/2.D0
     #*h2*sf0-189.D0/8.D0*cf0*h)*v22)*F0inv4+(3.D0/4.D0*h6*v24*sf0+(h
     #6*sf0/4-15.D0/4.D0*h5*cf0)*v33+(-35.D0/4.D0*h7*cf0+3.D0/8.D0*h8*sf
     #0)*v44+(-21.D0/8.D0*h3*cf0+3.D0/8.D0*h4*sf0)*v22-49.D0/4.D0*v24
     #*h5*cf0)*F0inv3+(-v44*h9*cf0/72-v33*h7*cf0/56-v22*h5*cf0/40)*F0inv
     #2

      s1 = (-36261225.D0/32.D0*h*sf0*v44-6081075.D0/8.D0*v34*sf0)*F0in
     #v7+(6081075.D0/8.D0*v34*cf0*h-63855.D0/16.D0*v23*sf0-2843775.
     #D0/8.D0*v34*h2*sf0-197505.D0/16.D0*v24*h*sf0-170775.D0/32.D0*
     #h*sf0*v33+(-17203725.D0/32.D0*h3*sf0+36261225.D0/32.D0*h2*cf0)*v44
     #)*F0inv6+(-7317.D0/4.D0*h2*v23*sf0-46305.D0/8.D0*h3*v24*sf0-
     #158715.D0/8.D0*h4*v34*sf0+(170775.D0/32.D0*h2*cf0-78705.D0/32.D0
     #*h3*sf0)*v33+197505.D0/16.D0*v24*h2*cf0+63855.D0/16.D0*v23*c
     #f0*h-1701.D0/32.D0*h*sf0*v22+408375.D0/4.D0*v34*h3*cf0+(2558325.
     #D0/16.D0*h4*cf0-66255.D0/2.D0*h5*sf0)*v44)*F0inv5
      s2 = s1+(-1025.D0/4.D0*v34*h6*sf0-2625.D0/8.D0*v24*h5*sf0+(17
     #01.D0/32.D0*h2*cf0-777.D0/32.D0*h3*sf0)*v22+7983.D0/16.D0*v23*h
     #3*cf0+2700*v34*h5*cf0+(-17955.D0/32.D0*h7*sf0+160335.D0/32.D0*h6
     #*cf0)*v44+(5445.D0/8.D0*h4*cf0-3945.D0/32.D0*h5*sf0)*v33+26775.D0/
     #16.D0*v24*h4*cf0-699.D0/8.D0*v23*h4*sf0)*F0inv4
      ses(1)=s2+(-4*v24*h7*sf0+39.D0/4.D0*v23*h5*cf0+65.D0/4.D0*v4*v
     #3*h7*cf0+357.D0/8.D0*v24*h6*cf0-5.D0/8.D0*v34*h8*sf0+(105.D0/
     #16.D0*h4*cf0-9.D0/8.D0*h5*sf0)*v22+(15*h6*cf0-5.D0/4.D0*h7*sf0)*v3
     #3+(735.D0/16.D0*h8*cf0-85.D0/32.D0*h9*sf0)*v44-5.D0/8.D0*v23*h6
     #*sf0)*F0inv3+(v34*h9*cf0/84+9.D0/560.D0*v23*h7*cf0+3.D0/16.D0
     #*v24*h8*cf0+(-h9*sf0/224+9.D0/112.D0*h8*cf0)*v33+(31.D0/288.D0*
     #h10*cf0-h11*sf0/288)*v44+(19.D0/160.D0*h6*cf0-h7*sf0/160)*v22)*F0i
     #nv2

      s2=(91216125.D0/32.D0*h*v34*sf0+(-22135829625.D0/256.D0*cf0*h+
     #5531096025.D0/128.D0*h2*sf0)*v44+63609975.D0/256.D0*sf0*v33+712161
     #45.D0/128.D0*v24*sf0)*F0inv7+(36068175.D0/128.D0*v24*h2*sf0-
     #91216125.D0/32.D0*v34*h2*cf0+(8011575.D0/64.D0*h2*sf0-63609975.D
     #0/256.D0*cf0*h)*v33+21525075.D0/16.D0*v34*h3*sf0-71216145.D0/128
     #.D0*v24*cf0*h+320463.D0/256.D0*sf0*v22+(915059925.D0/256.D0*h4*
     #sf0-3683582175.D0/256.D0*h3*cf0)*v44+830115.D0/64.D0*v23*h*sf0)
     #*F0inv6
      s1 = s2+((1366695.D0/128.D0*h4*sf0-10842975.D0/256.D0*h3*cf0)*v33-
     #3082365.D0/32.D0*v24*h3*cf0+(83655.D0/128.D0*h2*sf0-320463.D0/2
     #56.D0*cf0*h)*v22+791307.D0/32.D0*v24*h4*sf0+(-179106525.D0/256.
     #D0*h5*cf0+14180955.D0/128.D0*h6*sf0)*v44-830115.D0/64.D0*v23*h2
     #*cf0-12644775.D0/32.D0*v34*h4*cf0+385803.D0/64.D0*v23*h3*sf0+
     #2562615.D0/32.D0*v34*h5*sf0)*F0inv5+((-133155.D0/64.D0*h5*cf0+20
     #145.D0/64.D0*h6*sf0)*v33-637989.D0/128.D0*v24*h5*cf0+(-57325.D0
     #/4.D0*h7*cf0+193295.D0/128.D0*h8*sf0)*v44+20025.D0/16.D0*h7*v34*
     #sf0+102369.D0/128.D0*h6*v24*sf0+(-60489.D0/256.D0*h3*cf0+16479.
     #D0/256.D0*h4*sf0)*v22-374715.D0/32.D0*v34*h6*cf0-54549.D0/32.D0*
     #v23*h4*cf0+20565.D0/64.D0*h5*v23*sf0)*F0inv4
      ses(2)=s1+(-1323.D0/32.D0*v23*h6*cf0-1545.D0/16.D0*v34*h8*cf0+1
     #65.D0/32.D0*v34*h9*sf0+3757.D0/384.D0*v24*h8*sf0-3243.D0/32.D
     #0*v24*h7*cf0+(339.D0/160.D0*h6*sf0-17187.D0/1280.D0*h5*cf0)*v22
     #+(5815.D0/1792.D0*h8*sf0-65595.D0/1792.D0*h7*cf0)*v33+(9715.D0/115
     #2.D0*h10*sf0-147115.D0/1152.D0*h9*cf0)*v44+113.D0/32.D0*v23*h7*
     #sf0)*F0inv3+((-74659.D0/177408.D0*h11*cf0+109.D0/6912.D0*h12*sf0)*
     #v44-39.D0/224.D0*v34*h10*cf0+(5.D0/384.D0*h10*sf0-1207.D0/5376.D
     #0*h9*cf0)*v33+3.D0/128.D0*v24*h10*sf0+v34*h11*sf0/336-2939.D0
     #/4480.D0*v24*h9*cf0-101.D0/560.D0*v23*h8*cf0+(73.D0/3840.D0*
     #h8*sf0-219.D0/896.D0*h7*cf0)*v22+9.D0/2240.D0*v23*h9*sf0)*F0inv
     #2+(-h11*v33*cf0/1792-h9*v22*cf0/1280-h13*v44*cf0/2304)*F0inv+22135
     #829625.D0/256.D0*sf0*v44*F0inv8

      s2 = (-13544940825.D0/256.D0*v34*h2*sf0+(420580762875.D0/1024.D0
     #*h2*cf0-204028686225.D0/1024.D0*h3*sf0)*v44-144073215.D0/512.D0*vv
     #2*v3*sf0-1081369575.D0/1024.D0*h*sf0*v33-1210674465.D0/512.D0*vv2*
     #v4*h*sf0+12598574625.D0/128.D0*v34*cf0*h)*F0inv7+(-36660195.D0/3
     #2.D0*h3*v24*sf0+144073215.D0/512.D0*v23*cf0*h-40212315.D0/25
     #6.D0*h2*v23*sf0+5145891075.D0/256.D0*v34*h3*cf0+1210674465.D0
     #/512.D0*v24*h2*cf0+(-522103725.D0/1024.D0*h3*sf0+1081369575.D0/
     #1024.D0*h2*cf0)*v33-4806945.D0/1024.D0*h*sf0*v22-1492782525.D0/256
     #.D0*h4*v34*sf0+(7979387325.D0/128.D0*h4*cf0-3611943075.D0/256.D0
     #*h5*sf0)*v44)*F0inv6
      s1 = s2+((2515645275.D0/1024.D0*h6*cf0-350003745.D0/1024.D0*h7*sf0
     #)*v44+(4806945.D0/1024.D0*h2*cf0-2333331.D0/1024.D0*h3*sf0)*v22+18
     #3004965.D0/512.D0*v24*h4*cf0+32400225.D0/512.D0*v23*h3*cf0+1
     #68711075.D0/128.D0*v34*h5*cf0+(5051475.D0/32.D0*h4*cf0-35913735.
     #D0/1024.D0*h5*sf0)*v33-7467135.D0/32.D0*v34*h6*sf0-4940793.D0/25
     #6.D0*v23*h4*sf0-1288287.D0/16.D0*v24*h5*sf0)*F0inv5+((-20691
     #.D0/128.D0*h5*sf0+91377.D0/128.D0*h4*cf0)*v22+(-100155.D0/128.D0*h
     #7*sf0+3030885.D0/512.D0*h6*cf0)*v33+(19947525.D0/512.D0*h8*cf0-189
     #2425.D0/512.D0*h9*sf0)*v44+1141569.D0/256.D0*v23*h5*cf0+3563703
     #.D0/256.D0*v24*h6*cf0+8288865.D0/256.D0*v34*h7*cf0-490479.D0/
     #256.D0*v24*h7*sf0-897705.D0/256.D0*v34*h8*sf0-99429.D0/128.D0
     #*v23*h6*sf0)*F0inv4
      s2 = s1+(109659.D0/512.D0*v24*h8*cf0+362307.D0/3584.D0*v23*h
     #7*cf0+(147345.D0/1792.D0*h8*cf0-3105.D0/448.D0*h9*sf0)*v33+(28677.
     #D0/1024.D0*h6*cf0-3909.D0/1024.D0*h7*sf0)*v22+98405.D0/336.D0*v4*v
     #3*h9*cf0+(1353565.D0/4608.D0*h10*cf0-44825.D0/2304.D0*h11*sf0)*v44
     #-9963.D0/512.D0*v24*h9*sf0-98915.D0/5376.D0*v34*h10*sf0-34455
     #.D0/3584.D0*v23*h8*sf0)*F0inv3
      ses(3)=s2+(74771.D0/53760.D0*h10*v24*cf0-47.D0/1792.D0*v23*h10
     #*sf0+49069.D0/59136.D0*v34*h11*cf0-953.D0/13440.D0*vv2*h11*v4*sf
     #0+(10253.D0/21504.D0*h10*cf0-599.D0/21504.D0*h11*sf0)*v33+(-3679.D
     #0/107520.D0*h9*sf0+3687.D0/8960.D0*h8*cf0)*v22+34189.D0/53760.D0*v
     #v2*v3*h9*cf0-395.D0/16128.D0*h12*v34*sf0+(93601.D0/88704.D0*h12*
     #cf0-48733.D0/1064448.D0*h13*sf0)*v44)*F0inv2+(-12598574625.D0/128.
     #D0*v34*sf0-420580762875.D0/1024.D0*h*sf0*v44)*F0inv8+(h13*v34*
     #cf0/2688+h12*v24*cf0/512+(5.D0/3584.D0*h12*cf0-h13*sf0/21504)*v
     #33+(-h15*sf0/27648+43.D0/27648.D0*h14*cf0)*v44+9.D0/17920.D0*h11*v
     #v2*v3*cf0+(-h11*sf0/15360+31.D0/15360.D0*h10*cf0)*v22)*F0inv


      s1 = (99225.D0/2.D0*v34*sf0+11025.D0/8.D0*h*sf0*v44)*F0inv6+(-22
     #5.D0/8.D0*h*sf0*v33-99225.D0/2.D0*v34*cf0*h+(-11025.D0/8.D0*h2*c
     #f0+5775.D0/8.D0*h3*sf0)*v44+1575.D0/4.D0*v23*sf0+22995*v34*h2
     #*sf0+315.D0/4.D0*v24*h*sf0)*F0inv5
      sez(0)=s1+(-12915.D0/2.D0*v34*h3*cf0+9.D0/8.D0*h*sf0*v22+
     #(-525.D0/
     #2.D0*h4*cf0+555.D0/8.D0*h5*sf0)*v44-315.D0/4.D0*v24*h2*cf0+705.
     #D0/4.D0*h2*v23*sf0+135.D0/4.D0*h3*v24*sf0+(225.D0/8.D0*h2*cf
     #0-105.D0/8.D0*h3*sf0)*v33+1200*h4*v34*sf0-1575.D0/4.D0*v23*cf
     #0*h)*F0inv4+(3.D0/4.D0*v24*h5*sf0+(15.D0/4.D0*h4*cf0-3.D0/4.D0*
     #h5*sf0)*v33-150*v34*h5*cf0-15.D0/2.D0*v24*h4*cf0+(-25.D0/2.D0
     #*h6*cf0+5.D0/4.D0*h7*sf0)*v44+(-9.D0/8.D0*h2*cf0+3.D0/8.D0*h3*sf0)
     #*v22-45*v23*h3*cf0+12*v34*h6*sf0+27.D0/4.D0*v23*h4*sf0)*F0
     #inv3+(-v44*h9*sf0/72+(h6*cf0/8-h7*sf0/56)*v33-v34*h7*cf0/2-vv2*v
     #3*h5*cf0/2-v22*h5*sf0/40)*F0inv2

      s1 = -206531325.D0/32.D0*F0inv7*v44*sf0+(-904365.D0/16.D0*v24*s
     #f0-809325.D0/32.D0*sf0*v33-987525.D0/8.D0*h*v34*sf0+(206531325.D
     #0/32.D0*cf0*h-48735225.D0/16.D0*h2*sf0)*v44)*F0inv6+(987525.D0/8.D
     #0*v34*h2*cf0+904365.D0/16.D0*v24*cf0*h-12825.D0/16.D0*v23*
     #h*sf0-464895.D0/8.D0*v34*h3*sf0+(809325.D0/32.D0*cf0*h-93285.D0/
     #8.D0*h2*sf0)*v33-5859.D0/32.D0*sf0*v22-210735.D0/8.D0*v24*h2*sf
     #0+(28626675.D0/32.D0*h3*cf0-725655.D0/4.D0*h4*sf0)*v44)*F0inv5
      s2 = s1+((106575.D0/4.D0*h5*cf0-11585.D0/4.D0*h6*sf0)*v44+16965*v4
     #*v3*h4*cf0+120015.D0/16.D0*v24*h3*cf0+12825.D0/16.D0*v23*h2*
     #cf0-5883.D0/16.D0*v23*h3*sf0-27165.D0/8.D0*v34*h5*sf0-11445.D
     #0/8.D0*v24*h4*sf0+(-18645.D0/32.D0*h4*sf0+103365.D0/32.D0*h3*cf
     #0)*v33+(-84*h2*sf0+5859.D0/32.D0*cf0*h)*v22)*F0inv4
      
      sez(1)=s2+((7525.D0/32.D0*h7*cf0-455.D0/32.D0*h8*sf0)*v44-
     #195.D0/4.D
     #0*h7*v34*sf0+(2175.D0/32.D0*h5*cf0-35.D0/8.D0*h6*sf0)*v33+1491.D
     #0/8.D0*v24*h5*cf0+(-63.D0/16.D0*h4*sf0+735.D0/32.D0*h3*cf0)*v22
     #+1935.D0/4.D0*v34*h6*cf0+201.D0/2.D0*v23*h4*cf0-63.D0/4.D0*h6
     #*v24*sf0-141.D0/8.D0*h5*v23*sf0)*F0inv3+(31.D0/16.D0*v23*
     #h6*cf0+11.D0/16.D0*v24*h7*cf0+(163.D0/288.D0*h9*cf0+h10*sf0/144
     #)*v44+(-3.D0/112.D0*h7*cf0+9.D0/224.D0*h8*sf0)*v33-61.D0/560.D0*vv
     #2*v3*h7*sf0-19.D0/168.D0*v34*h9*sf0+(7.D0/20.D0*h5*cf0+h6*sf0/80
     #)*v22+13.D0/4.D0*v34*h8*cf0)*F0inv2+(-v33*h9*cf0/224-v22*h7*cf0/
     #160-v44*h11*cf0/288)*F0inv

      s1 = (5808818925.D0/256.D0*h*sf0*v44+583107525.D0/64.D0*v34*sf0)
     #*F0inv7+(22027005.D0/128.D0*v24*h*sf0-583107525.D0/64.D0*v34*
     #cf0*h+71718075.D0/16.D0*v34*h2*sf0+19401525.D0/256.D0*h*sf0*v33+
     #4420845.D0/128.D0*v23*sf0+(-5808818925.D0/256.D0*h2*cf0+2763913
     #425.D0/256.D0*h3*sf0)*v44)*F0inv6+(10357875.D0/128.D0*h3*v24*sf
     #0-22027005.D0/128.D0*v24*h2*cf0+2183049.D0/128.D0*h2*v23*sf0
     #-92503125.D0/64.D0*v34*h3*cf0+(9083745.D0/256.D0*h3*sf0-19401525
     #.D0/256.D0*h2*cf0)*v33-4420845.D0/128.D0*v23*cf0*h+(173694195.D
     #0/256.D0*h5*sf0-413820225.D0/128.D0*h4*cf0)*v44+5483115.D0/16.D0*h
     #4*v34*sf0+120879.D0/256.D0*h*sf0*v22)*F0inv5
      s2 = s1+(169299.D0/128.D0*v23*h4*sf0-354717.D0/64.D0*v23*h3*
     #cf0+600525.D0/128.D0*v24*h5*sf0+(-120879.D0/256.D0*h2*cf0+55827
     #.D0/256.D0*h3*sf0)*v22+(127665.D0/64.D0*h5*sf0-1308285.D0/128.D0*h
     #4*cf0)*v33-2028015.D0/32.D0*v34*h5*cf0-753885.D0/32.D0*v24*h4
     #*cf0+301785.D0/32.D0*v34*h6*sf0+(98375.D0/8.D0*h7*sf0-13449455.D
     #0/128.D0*h6*cf0)*v44)*F0inv4
      s3 = s2+(-42417.D0/64.D0*v24*h6*cf0+(2813.D0/256.D0*h5*sf0-7767
     #.D0/128.D0*h4*cf0)*v22+4217.D0/64.D0*v24*h7*sf0-73095.D0/64.D0*
     #v34*h7*cf0+2211.D0/64.D0*v23*h6*sf0-15531.D0/64.D0*v23*h5*
     #cf0+(14015.D0/192.D0*h9*sf0-139955.D0/128.D0*h8*cf0)*v44+(6475.D0/
     #256.D0*h7*sf0-69615.D0/256.D0*h6*cf0)*v33+7135.D0/64.D0*v34*h8*s
     #f0)*F0inv3
      sez(2)=s3+(-11323.D0/1344.D0*v34*h9*cf0+(h9*sf0/256-1241.D0/
     #896.D0
     #*h8*cf0)*v33-275.D0/64.D0*v24*h8*cf0-4173.D0/1120.D0*v23*h7*
     #cf0+3781.D0/13440.D0*v23*h8*sf0+(-8069.D0/2304.D0*h10*cf0+17125
     #.D0/177408.D0*h11*sf0)*v44+129.D0/896.D0*v24*h9*sf0+(-803.D0/64
     #0.D0*h6*cf0+291.D0/4480.D0*h7*sf0)*v22+25.D0/56.D0*v34*h10*sf0)*
     #F0inv2+(-17.D0/1344.D0*v34*h11*cf0+(-h11*sf0/1792+37.D0/5376.D0*
     #h10*cf0)*v33+(-h9*sf0/1280+h8*cf0/240)*v22-13.D0/1120.D0*v23*h9
     #*cf0+(h12*cf0/432-h13*sf0/2304)*v44)*F0inv

      s2 = (-2522101725.D0/1024.D0*sf0*v33-9357300225.D0/256.D0*h*v34*
     #sf0+(1126100941875.D0/1024.D0*cf0*h-18251312625.D0/32.D0*h2*sf0)*v
     #44-2804997195.D0/512.D0*v24*sf0)*F0inv7+(-62413065.D0/512.D0*vv
     #2*v3*h*sf0-9401535.D0/1024.D0*sf0*v22+9357300225.D0/256.D0*v34*h
     #2*cf0-4501683225.D0/256.D0*v34*h3*sf0-370559475.D0/128.D0*v24
     #*h2*sf0+(2522101725.D0/1024.D0*cf0*h-331949475.D0/256.D0*h2*sf0)*v
     #33+2804997195.D0/512.D0*v24*cf0*h+(-28377570975.D0/512.D0*h4*sf
     #0+208675023375.D0/1024.D0*h3*cf0)*v44)*F0inv6
      s3 = s2+((-2564991.D0/512.D0*h2*sf0+9401535.D0/1024.D0*cf0*h)*v22+
     #(-1058058885.D0/512.D0*h6*sf0+1527658275.D0/128.D0*h5*cf0)*v44+691
     #291575.D0/128.D0*v34*h4*cf0+(487097325.D0/1024.D0*h3*cf0-1358364
     #15.D0/1024.D0*h4*sf0)*v33+62413065.D0/512.D0*v23*h2*cf0-3034517
     #85.D0/256.D0*v34*h5*sf0-76925277.D0/256.D0*v24*h4*sf0+5472388
     #35.D0/512.D0*v24*h3*cf0-29810781.D0/512.D0*v23*h3*sf0)*F0inv
     #5
      s1 = s3+((29517345.D0/1024.D0*h5*cf0-2506515.D0/512.D0*h6*sf0)*v33
     #+(-146817.D0/256.D0*h4*sf0+1996137.D0/1024.D0*h3*cf0)*v22-828105.D
     #0/32.D0*h7*v34*sf0-240075.D0/64.D0*h5*v23*sf0+4503213.D0/256.
     #D0*v23*h4*cf0+12632685.D0/64.D0*v34*h6*cf0+263835.D0/4.D0*vv2
     #*v4*h5*cf0-2906937.D0/256.D0*h6*v24*sf0+(-524205.D0/16.D0*h8*sf
     #0+296302695.D0/1024.D0*h7*cf0)*v44)*F0inv4+(-80637.D0/512.D0*vv2*v
     #4*h8*sf0+(2311815.D0/3584.D0*h7*cf0-231345.D0/3584.D0*h8*sf0)*v33+
     #43845.D0/16.D0*v34*h8*cf0+(32703.D0/256.D0*h5*cf0-1359.D0/64.D0*
     #h6*sf0)*v22-30515.D0/128.D0*v34*h9*sf0+305415.D0/512.D0*v23*h
     #6*cf0-37293.D0/512.D0*v23*h7*sf0+(6869765.D0/2304.D0*h9*cf0-495
     #155.D0/2304.D0*h10*sf0)*v44+781275.D0/512.D0*v24*h7*cf0)*F0inv3
      sez(3)=s1+((24943.D0/5376.D0*h9*cf0-355.D0/1792.D0*h10*sf0)*v33+
     #(910
     #41.D0/35840.D0*h7*cf0-21053.D0/107520.D0*h8*sf0)*v22+215207.D0/179
     #20.D0*v24*h9*cf0-57961.D0/59136.D0*v34*h11*sf0-1037.D0/1680.D
     #0*v24*h10*sf0+7743.D0/1120.D0*v23*h8*cf0+(2110697.D0/177408.
     #D0*h11*cf0-249581.D0/532224.D0*h12*sf0)*v44-9053.D0/17920.D0*vv2*v
     #3*h9*sf0+30621.D0/1792.D0*v34*h10*cf0)*F0inv2-1126100941875.D0/1
     #024.D0*sf0*v44*F0inv8+(47.D0/1152.D0*v34*h12*cf0-43.D0/53760.D0*
     #v23*h11*sf0+(h10*sf0/1536+577.D0/107520.D0*h9*cf0)*v22-5.D0/537
     #6.D0*v34*h13*sf0+(5.D0/13824.D0*h14*sf0+9787.D0/1064448.D0*h13*c
     #f0)*v44+59.D0/3584.D0*v24*h11*cf0+(17.D0/21504.D0*h12*sf0-17.D0
     #/21504.D0*h11*cf0)*v33+41.D0/1536.D0*v23*h10*cf0)*F0inv-h15*cf0
     #*v44/27648-v22*h11*cf0/15360-h13*v33*cf0/21504

	sigc=0.d0
	sigw=0.d0
	sigs=0.d0
	sigz=0.d0
	do k=0,mse
	sigc=sigc+sec(k)*qow(k)
	sigw=sigw+sew(k)*qow(k)
	sigs=sigs+ses(k)*qow(k)
	sigz=sigz+sez(k)*qow(k)
	enddo
	u2=sigc
	du2=sigw
	v2=sigs
	dv2=sigz

        go to 8888
        endif

c    zeroth order correction analytical
   
        call airys(t0,ai0,bi0,dai0,dbi0,iscal,ierr)
        if(iscal.eq.0) then
        zet0=0.d0
        else
        zet0=2.d0*t0**(1.5d0)/3.d0
        endif
        call airys(t,ai,bi,dai,dbi,iscal,ierr)
        if(iscal.eq.0) then
        zet=0.d0
        else
        zet=2.d0*t**(1.5d0)/3.d0
        endif

        expz=dexp(zet-zet0)
        u0=pi*(dbi0*ai/expz-dai0*bi*expz)
        du0=pi*f3*(dbi0*dai/expz-dai0*dbi*expz)
        v0=pi*(-bi0*ai/expz+ai0*bi*expz)/f3
        dv0=pi*(-bi0*dai/expz+ai0*dbi*expz)

c    first order correction analytical

	suma=0.d0
	do k=0,maf
	suma=suma+af(k,int)*pow(k)
	enddo
	sumb=0.d0
	do k=0,mbf
	sumb=sumb+bf(k,int)*pow(k)
	enddo
	sumc=0.d0
	do k=0,mcf
	sumc=sumc+cf(k,int)*pow(k)
	enddo
	sume=0.d0
	do k=0,mef
	sume=sume+ef(k,int)*pow(k)
	enddo
	sumf=0.d0
	do k=0,mff
	sumf=sumf+ff(k,int)*pow(k)
	enddo
	sumg=0.d0
	do k=0,mgf
	sumg=sumg+gf(k,int)*pow(k)
	enddo
	u1=suma*u0+sumb*v0+sumc*du0
        du1=sume*u0+sumf*du0+sumb*dv0
	v1=sumg*u0-sumf*v0+sumc*dv0
	dv1=sume*v0+sumg*du0-suma*dv0

c    second order correction analytical

	siga=0.d0
	sigb=0.d0
	sigc=0.d0
	sigd=0.d0
	do k=0,msa
	siga=siga+sa(k,int)*pow(k)
	sigb=sigb+sb(k,int)*pow(k)
	sigc=sigc+sc(k,int)*pow(k)
	sigd=sigd+sd(k,int)*pow(k)
	enddo
	u2=siga*u0+sigb*v0+sigc*du0+sigd*dv0

	sige=0.d0
	sigf=0.d0
	sigg=0.d0
	sigh=0.d0
	do k=0,msa
	sige=sige+se(k,int)*pow(k)
	sigf=sigf+sf(k,int)*pow(k)
	sigg=sigg+sg(k,int)*pow(k)
	sigh=sigh+sh(k,int)*pow(k)
	enddo
	du2=sige*u0+sigf*v0+sigg*du0+sigh*dv0

	sigi=0.d0
	sigj=0.d0
	sigk=0.d0
	sigl=0.d0
	do k=0,msa
	sigi=sigi+si(k,int)*pow(k)
	sigj=sigj+sj(k,int)*pow(k)
	sigk=sigk+sk(k,int)*pow(k)
	sigl=sigl+sl(k,int)*pow(k)
	enddo
	v2=sigi*u0+sigj*v0+sigk*du0+sigl*dv0

	sigm=0.d0
	sign=0.d0
	sigo=0.d0
	sigp=0.d0
	do k=0,msa
	sigm=sigm+sm(k,int)*pow(k)
	sign=sign+sn(k,int)*pow(k)
	sigo=sigo+so(k,int)*pow(k)
	sigp=sigp+sp(k,int)*pow(k)
	enddo
	dv2=sigm*u0+sign*v0+sigo*du0+sigp*dv0

8888	continue
	u=u0+u1+u2
	du=du0+du1+du2
	w=v0+v1+v2
	dv=dv0+dv1+dv2	
c        ue0=-(pi/f3**2)*
c     +  ((t0*bi0*ai+dbi0*dai)/expz-(t0*ai0*bi+dai0*dbi)*expz)
c	due0=-(pi/f3)*
c     +  ((t0*bi0*dai+t*dbi0*ai)/expz-(t0*ai0*dbi+t*dai0*bi)*expz)
c	ve0=(pi/f1)*((dbi0*ai+bi0*dai)/expz-(dai0*bi+ai0*dbi)*expz)
c	dve0=(pi/f3**2)*
c     +  ((dbi0*dai+t*bi0*ai)/expz-(dai0*dbi+t*ai0*bi)*expz)
c	ue=ue0
c	due=due0
c	ve=ve0
c	dve=dve0
	if(if.eq.1) then
	y=u*sol+w*dsol
	dy=du*sol+dv*dsol
c	ye=ue*sol+u*sole+ve*dsol+w*dsole
c	dye=due*sol+du*sole+dve*dsol+dv*dsole
	endif
	if(if.eq.2) then
	y=dv*sol-w*dsol
	dy=-du*sol+u*dsol
c	ye=dve*sol+dv*sole-ve*dsol-w*dsole
c	dye=-due*sol-du*sole+ue*dsol+u*dsole
	endif
	sol=y
	dsol=dy
c	sole=ye
c	dsole=dye
	return
	end

	function pot(x)
c     Potential definition
        implicit double precision (a-h,o-z)
	data v0/-50.d0/,a/0.6d0/,b/7.d0/
	w=1.d0/(1.d0+dexp((x-b)/a))
	pot=v0*w*(1.d0-(1.d0-w)/a)
	return
	end
		

	function fix(ene)
c     Gives the connecting condition at matching point  
c     (continuity of the logarithmic derivative) 
c     from which the eigenvalue is obtained
        implicit double precision (a-h,o-z)
	include 'params.dat'
	parameter (ngrad=4)
        common /part/ xin(nind),vpol(0:ngrad,nind)
	common /fener/ f0,f1,en
	common /actdim/ nin
	common /matpoint/ xmatch,match
	en=ene
	if(pot(xin(1)).gt.en) then
	sol=1.d0
	dsol=dsqrt(pot(xin(1))-en)
	sole=0.d0
	dsole=-1.d0/(2.d0*dsqrt(pot(xin(1))-en))
	else
	sol=0.d0
	dsol=1.d0
	sole=0.d0
	dsole=0.d0
	endif
       
        hw=0.0625d0
        km=(xmatch-xin(1))/hw
        kmat=km+1
        wkb=0.d0
        ywkb=0.d0
        do k=1,kmat
        xw=xin(1)+(k-1)*hw
        dif=pot(xw)-en
        if(dif.ge.0.d0) wkb=wkb+hw*dsqrt(dif)
        enddo
        ywkb=dexp(wkb)
        ewkbl=ywkb

	if=1
	do i=1,match-1
	x=xin(i)
	h=xin(i+1)-xin(i)
	f0=vpol(0,i)-vpol(1,i)*h
	f1=2.d0*vpol(1,i)
	call prop(x,h,i,if,sol,dsol,sole,dsole)
	bin=dsol*sole-sol*dsole
	enddo
	soleft=sol
	dsoleft=dsol

	if(pot(xin(nin)).gt.en) then
	sol=1.d0
	dsol=-dsqrt(pot(xin(nin))-en)
	sole=0.d0
	dsole=1.d0/(2.d0*dsqrt(pot(xin(nin))-en))
	else
	sol=0.d0
	dsol=1.d0
	sole=0.d0
	dsole=0.d0
	endif
	
        ywkb=0.d0
        hw=0.0625d0
        km=(xin(nin)-xmatch)/hw
        kmat=km+1
        wkb=0.d0
        ywkb=0.d0
        do k=1,kmat
        xw=xmatch+(k-1)*hw
        dif=pot(xw)-en
        if(dif.ge.0.d0) wkb=wkb+hw*dsqrt(dif)
        enddo
        ywkb=dexp(wkb)
        ewkbr=ywkb

	if=2
	do i=nin-1,match,-1
	x=xin(i+1)
	h=xin(i+1)-xin(i)
	f0=vpol(0,i)-vpol(1,i)*h
	f1=2.d0*vpol(1,i)
	call prop(x,h,i,if,sol,dsol,sole,dsole)
	enddo
	sorig=sol
	dsorig=dsol
  
        fix=(sorig*dsoleft-soleft*dsorig)/(ewkbl*ewkbr)

	return
	end

c***************************************************************
      subroutine bisec(a,b,x,f,eps,iter,ier)
c
c  finding zero of the nonlinear equation f(x)=0 using bisection method
c
c         (from Numerical Recipes by W.H. Press, B.P. Flannery,
c                S.A. Teukolsky, W.T. Vetterling, 
c          with a small modification: relative instead of absolute error) 

      implicit double precision (a-h,o-z)
      external f
      xa=a
      xb=b
      it=0
*
      fa=f(xa)
      fb=f(xb)
*
      abfa=abs(fa)
      x=a
*
      if (abfa.lt.eps) go to 10
*
      abfb=abs(fb)
      x=b
*
      if (abfb.lt.eps) go to 10
      if (fa*fb.gt.0.d0) go to 11
*
   1  continue
*
      it=it+1
      x=0.5d0*(xa+xb)
      fx=f(x)
      abff=abs(fx)
*
      diff=xb-xa
c      if (abff.lt.eps) go to 10
	if(dabs(diff).lt.eps*dabs(xb)) go to 10 
      if (it.gt.iter) go to 20
      if (fa*fx) 2,10,4
*
   2  continue
*
*         function changes sign in the left subinterval
*
      xb=x
*
      go to 1
*
   4  continue
*
*         function changes sign in the right subinterval
*
      xa=x
*
      go to 1
*
   10 continue
*
      ier=it
*
      return
*
   11 continue
*
c      print 30
      write(6,30)
   30 format(///,1x,18hbisec out of range ,///)
*
      stop 'bisec'
*
   20 continue
*
      ier=it
*
      return
      end
c******************************************************************	     
c   Potential approximation by shifted Legendre polynomials
c******************************************************************	     
	subroutine pin(xin,vpol,n)
	implicit double precision (a-h,o-z)
	parameter (ngrad=4)
	dimension xin(n),vpol(0:ngrad,n)
	dimension c(0:ngrad)
	common /legend/ x,h,k
	external fct
	data xl/0.d0/,xu/1.d0/
	do i=1,n-1
	x=xin(i)
	h=xin(i+1)-x
	do k=0,ngrad
        call quadg16(xl,xu,fct,c(k))
	vpol(k,i)=(2*k+1)*c(k)/h**k
	enddo
	enddo
	return
	end
	function fct(t)
	implicit double precision (a-h,o-z)
	common /legend/ x,h,k
	if(k.eq.0) then
	poleg=1.d0
	endif
	if(k.eq.1) then
	poleg=2.d0*t-1.d0
	endif
	if(k.eq.2) then
	poleg=1.d0+t*(-6.d0+6.d0*t)
	endif
	if(k.eq.3) then
	poleg=-1.d0+t*(12.d0+t*(-30.d0+t*20.d0))
	endif
	if(k.eq.4) then
	poleg=1.d0+t*(-20.d0+t*(90.d0+t*(-140.d0+t*70.d0)))
	endif
	if(k.eq.5) then
	poleg=-1.d0+t*(30.d0+t*(-210.d0+t*(560.d0+t*(-630.d0+
     #  t*252.d0))))
	endif
	if(k.eq.6) then
	z=2.d0*t-1.d0
	poleg=(231.d0*z**6-315.d0*z**4+105.d0*z**2-5.d0)/16.d0
	endif
	fct=poleg*pot(x+t*h)
	return
	end

c******************************************************************	     
        subroutine quadg16(xl,xu,fct,y) 
c   this subroutine performs the gaussian 
c   quadrature by a 16-point rule.
c     input parameters:
c     xl = the lower limit of the integration. 
c     xu = the upper limit of the integration. 
c     fct= the function (must be declared external in calling program)
c     output parameter: 
c     y = the integral
c
	implicit double precision (a-h,o-z)
	parameter (n=8)
	dimension x(n),w(n)
	data x/
     +  0.095012509837637440185d0,0.281603550779258913230d0,
     +  0.458016777657227386342d0,0.617876244402643748447d0,
     +  0.755404408355003033895d0,0.865631202387831743880d0,
     +  0.944575023073232576078d0,0.989400934991649932596d0/
        data w/
     +  0.189450610455068496285d0,0.182603415044923588867d0,
     +  0.169156519395002538189d0,0.149595988816576732081d0,
     +  0.124628971255533872052d0,0.095158511682492784810d0,
     +  0.062253523938647892863d0,0.027152459411754094852d0/
c
c executable statements
c
 	a=0.5d0*(xu-xl)
        b=0.5d0*(xu+xl)    
	s=0.d0
	do i=1,n
	s=s+w(i)*(fct(-a*x(i)+b)+fct(a*x(i)+b))
	enddo
	y=a*s
     	return
        end
c************************************************************************
	function poleg(k,t)
	implicit double precision(a-h,o-z)
	if(k.eq.0) then
	poleg=1.d0
	endif
	if(k.eq.1) then
	poleg=2.d0*t-1.d0
	endif
	if(k.eq.2) then
	poleg=1.d0+t*(-6.d0+6.d0*t)
	endif
	if(k.eq.3) then
	poleg=-1.d0+t*(12.d0+t*(-30.d0+t*20.d0))
	endif
	if(k.eq.4) then
	poleg=1.d0+t*(-20.d0+t*(90.d0+t*(-140.d0+t*70.d0)))
	endif
	return
	end
c******************************************************************	     
c      Airy functions by NAG routines and some asymptotic series
c******************************************************************	     
        subroutine airys(x,ai,bi,ad,bd,iscal,ierr)
	implicit double precision(a-h,o-z)
	common /nterm/ kter1,kter2,kterm
	parameter(kmax=30)
	common /sercf/ dk(kmax),ck(kmax)
	data pi/3.141592653589793238462643d0/
	data sqpi/1.772453850905516027298167d0/
	data pi4/0.7853981633974483096156608d0/
        data c1/0.35502805388781723926d0/
        data c2/0.25881940379280679840d0/
        data sr3/1.7320508075688772935d0/
	data eps/1.d-18/
	data xmin/-8.d4/
	data xmax/1.d2/
        if (x.eq.0.0d0) then
           ai=c1
           bi=sr3*c1
           ad=-c2
           bd=sr3*c2
	   ierr=0
           return
        endif
	iscal=0
	if(int(x/4.5d0).gt.1) iscal=1  
	if(x.ge.xmin.and.x.le.xmax) then  
	ierr=0
	ai=s17agf(x,ifail)
	ierr=ierr+ifail
        bi=s17ahf(x,ifail)
	ierr=ierr+ifail
        ad=s17ajf(x,ifail)
	ierr=ierr+ifail
        bd=s17akf(x,ifail)
	ierr=ierr+ifail
	return
	endif
	if(x.lt.xmin.or.x.gt.xmax) then
	xa=dabs(x)
	srxa=dsqrt(xa)
	z=xa*srxa/1.5d0
	x4=dsqrt(srxa)
	if(x.gt.0.d0) then
c	write(*,*) 'positive asymptotic'
	ierr=0
	sa=1.d0
	sad=1.d0
	sb=1.d0
	sbd=1.d0
	pz=1.d0
	sig=1.d0
	kterm=0
	do k=1,kmax
	sig=-sig
	pz=pz/z
	tb=ck(k)*pz
	ta=sig*tb
	tbd=dk(k)*pz
	tad=sig*tbd
	sa=sa+ta
	sad=sad+tad
	sb=sb+tb
	sbd=sbd+tbd
	kterm=k
	if(dabs(ta).lt.eps.and.dabs(tad).lt.eps) go to 20
	if(k.eq.1) then
	taold=ta
	tadold=tad
	else
	if(dabs(ta).gt.dabs(taold).or.dabs(tad).gt.dabs(tadold)) then
	ierr=5
	go to 20
	else 
	taold=ta
	tadold=tad
	endif
	endif
	enddo
20	ai=sa/(2.d0*sqpi*x4)
	ad=-x4*sad/(2.d0*sqpi)
	bi=sb/(sqpi*x4)
	bd=x4*sbd/sqpi
	return
	else
c	write(*,*) 'negative asymptotic'
	ierr=0
        xcs=dcos(z+pi4)
        xss=dsin(z+pi4)
        ssa=1.0d0
        sda=1.0d0
        s=1.0d0
        xr2=1.0d0/(z*z)
	km=kmax/2
        do k=1,km
        s=-s*xr2
	tc=ck(2*k)*s
        ssa=ssa+tc
	td=dk(2*k)*s
        sda=sda+td
	kter1=k
	if(dabs(tc).lt.eps.and.dabs(td).lt.eps) go to 65
	enddo
	ierr=6
65      xr1=1.0d0/z
	ssb=ck(1)*xr1
        sdb=dk(1)*xr1
        s=xr1
	km=kmax/2-1
        do  k=1,km
        s=-s*xr2
	tc=ck(2*k+1)*s
        ssb=ssb+tc
	td=dk(2*k+1)*s
        sdb=sdb+td
	kter2=k
	if(dabs(tc).lt.eps.and.dabs(td).lt.eps) go to 70
	enddo 
	ierr=7
70      ai=(xss*ssa-xcs*ssb)/sqpi/x4
	bi=(xcs*ssa+xss*ssb)/sqpi/x4
	ad=-x4*(xcs*sda+xss*sdb)/sqpi
	bd=x4*(xss*sda-xcs*sdb)/sqpi
	return
	endif
	endif
	return
	end

      double precision function s17agf(x,ifail)
c     mark 8 release. nag copyright 1979.
c     mark 8a revised. ier-263 (aug 1980)
c     mark 11.5(f77) revised. (sept 1985.)
c     mark 13 revised. use of mark 12 x02 functions (apr 1988).
c
c     airy function ai(x)
c
c     **************************************************************
c
c     to extract the correct code for a particular machine-range,
c     activate the statements contained in comments beginning  cdd ,
c     where  dd  is the approximate number of significant decimal
c     digits represented by the machine
c     delete the illegal dummy statements of the form
c     * expansion (nnnn) *
c
c     also insert appropriate data statements to define constants
c     which depend on the range of numbers represented by the
c     machine, rather than the precision (suitable statements for
c     some machines are contained in comments beginning crd where
c     d is a digit which simply distinguishes a group of machines).
c     delete the illegal dummy data statements with values written
c     *value*
c
c     **************************************************************
c
c     .. parameters ..
      character*6                      srname
      parameter                        (srname='s17agf')
c     .. scalar arguments ..
      double precision                 x
      integer                          ifail
c     .. local scalars ..
      double precision                 a, b, c, c1, f, g, pib4, t, t2,
     *                                 xmax, xmin, xrelpr, y, z
c     .. local arrays ..
      character*1                      p01rec(1)
c     .. external functions ..
      integer                          p01abf
      external                         p01abf
c     .. intrinsic functions ..
      intrinsic                        abs, cos, exp, sin, sqrt, int
c     .. data statements ..
c     precision dependent constants
c08   data xmin,xrelpr,c1,pib4
c08  */-1.3d4,9.5d-7,3.55028054d-1,7.85398163d-1/
c09   data xmin,xrelpr,c1,pib4
c09  */-2.1d+5,1.8d-8,3.550280539d-1,7.853981634d-1/
c12   data xmin,xrelpr,c1,pib4
c12  */-3.4d+7,7.3d-12,3.550280538878d-1,7.853981633974d-1/
c15   data xmin,xrelpr,c1,pib4
c15  */-3.9d+9,7.1d-15,3.550280538878172d-1,7.853981633974483d-1/
      data xmin,xrelpr,c1,pib4
     */-8.5d+4,2.2d-16,3.55028053887817239d-1,7.85398163397448310d-1/
c19   data xmin,xrelpr,c1,pib4
c19  */-9.1d+11,1.7d-18,3.550280538878172393d-1,7.853981633974483096d-1/
c
c     c1=ai(0.0)
c     xrelpr=x02ajf()
c     xmin=-(1.5*xlim)**(2/3)
c     where xlim=amin1(1.0/xrelpr,xscmax-pib4)
c     and xscmax is the maximum value of x for which sin(x) and cos(x)
c     can be computed without execution error.
c
c     **** warning - values of xmin given above may need adjusting ****
c
c     range dependent constants
      data xmax/1.038d+2/
c     for icl 1900
cr3   data xmax/41.14d0/
c     for ibm 360/370 and similar machines
cr1   data xmax/41.46d0/
c     for cdc 7600/cyber
cr4   data xmax/100.6d0/
c     for dec10, honeywell, univac 1100 (s.p.)
cr2   data xmax/25.79d0/
c     for burroughs
cr6   data xmax/28.71d0/
c     for univac 1100 (d.p.)
cr5   data xmax/104.0d0/
c
c     xmax.lt.((-ln(xunflo)-0.25*ln(xmax)-1.26)*1.5)**(2/3)
c
c     .. executable statements ..
      if (abs(x).gt.xrelpr) go to 20
      s17agf = c1
      ifail = 0
      go to 180
   20 if (x.le.0.0d0) go to 100
c
c     positive arguments
      if (x.gt.xmax) go to 140
      ifail = 0
      if (int(x/4.5d0)-1) 40, 60, 80
c
c     0.0 .lt. x .lt. 4.5
   40 t = 4.0d0*x/9.0d0 - 1.0d0
c
c      * expansion (0064) *
c
c     expansion (0064) evaluated as y(t)  --precision 08e.09
c08   y = (((((((((((((+7.99289990d-6*t-1.73116622d-5)*t-8.74469398d-5)
c08  *    *t+3.14292508d-4)*t+4.04674645d-4)*t-3.12578338d-3)
c08  *    *t+6.29727109d-4)*t+1.99056681d-2)*t-2.27431670d-2)
c08  *    *t-7.94868509d-2)*t+1.54262056d-1)*t+1.75618452d-1)
c08  *    *t-5.05223673d-1)*t-1.49695902d-1)*t + 6.91290454d-1
c
c     expansion (0064) evaluated as y(t)  --precision 09e.10
c09   y = (((((((((((((+7.992899897d-6*t-1.731166223d-5)
c09  *    *t-8.744693976d-5)*t+3.142925075d-4)*t+4.046746450d-4)
c09  *    *t-3.125783385d-3)*t+6.297271090d-4)*t+1.990566806d-2)
c09  *    *t-2.274316696d-2)*t-7.948685092d-2)*t+1.542620564d-1)
c09  *    *t+1.756184518d-1)*t-5.052236734d-1)*t-1.496959021d-1)*t +
c09  *    6.912904545d-1
c
c     expansion (0064) evaluated as y(t)  --precision 12e.13
c12   y = (((((((((((((((+3.836240596035d-8*t+6.611873540335d-8)
c12  *    *t-8.552648000773d-7)*t+7.428802725086d-8)
c12  *    *t+1.104711859030d-5)*t-1.815225158772d-5)
c12  *    *t-9.221133986120d-5)*t+3.158343961983d-4)
c12  *    *t+4.086219928757d-4)*t-3.127068544450d-3)
c12  *    *t+6.279004336939d-4)*t+1.990622015469d-2)
c12  *    *t-2.274270600458d-2)*t-7.948697054665d-2)
c12  *    *t+1.542619991726d-1)*t+1.756184631701d-1)
c12  *    *t-5.052236706546d-1
c12   y = (y*t-1.496959024167d-1)*t + 6.912904544398d-1
c
c     expansion (0064) evaluated as y(t)  --precision 15e.16
c15   y = (((((((((((((((+6.799139857525155d-10*t-
c15  *    1.149126157245687d-9)*t-1.285959117644895d-8)
c15  *    *t+4.410803674658092d-8)*t+1.182779224284816d-7)
c15  *    *t-8.674742654980418d-7)*t-2.408109942406664d-8)
c15  *    *t+1.106148266726252d-5)*t-1.804791385007481d-5)
c15  *    *t-9.222155182216891d-5)*t+3.157678455317247d-4)
c15  *    *t+4.086264861385136d-4)*t-3.127042731866834d-3)
c15  *    *t+6.278992301413515d-4)*t+1.990621425271641d-2)
c15  *    *t-2.274270581941627d-2)*t-7.948696981403562d-2
c15   y = ((((y*t+1.542619991581390d-1)*t+1.756184631287464d-1)
c15  *    *t-5.052236706541672d-1)*t-1.496959024160505d-1)*t +
c15  *    6.912904544398290d-1
c
c     expansion (0064) evaluated as y(t)  --precision 17e.18
      y = (((((((((((((((+4.97635854909020570d-12*t-
     *    3.25024150273916928d-11)*t-5.15773946723072737d-11)
     *    *t+8.66802872160017711d-10)*t-9.51292671519803048d-10)
     *    *t-1.33268133924677102d-8)*t+4.37061406144179625d-8)
     *    *t+1.18943714086308365d-7)*t-8.66980482244589319d-7)
     *    *t-2.46768077494905499d-8)*t+1.10610939830483627d-5)
     *    *t-1.80475663535516462d-5)*t-9.22213518989192294d-5)
     *    *t+3.15767712665407001d-4)*t+4.08626419412850994d-4)
     *    *t-3.12704269924340764d-3)*t+6.27899244118607949d-4
      y = (((((((y*t+1.99062142478229001d-2)*t-2.27427058211322122d-2)
     *    *t-7.94869698136278246d-2)*t+1.54261999158247445d-1)
     *    *t+1.75618463128730757d-1)*t-5.05223670654169859d-1)
     *    *t-1.49695902416050331d-1)*t + 6.91290454439828966d-1
c
c     expansion (0064) evaluated as y(t)  --precision 19e.19
c19   y = (((((((((((((((-3.312197910145269760d-13*t+
c19  *    9.322431697125376000d-13)*t+7.129287190684631040d-12)
c19  *    *t-3.832893483809505280d-11)*t-5.776706451689124659d-11)
c19  *    *t+8.828258016394519511d-10)*t-9.409317024321298760d-10)
c19  *    *t-1.335230441663953738d-8)*t+4.369495547733467896d-8)
c19  *    *t+1.189696603073404033d-7)*t-8.669723330732857839d-7)
c19  *    *t-2.469445117979233604d-8)*t+1.106108990846271097d-5)
c19  *    *t-1.804755822828769139d-5)*t-9.222135050498203271d-5)
c19  *    *t+3.157677101504443487d-4)*t+4.086264190934070532d-4
c19   y = (((((((((y*t-3.127042698734867396d-3)
c19  *    *t+6.278992441655849988d-4)
c19  *    *t+1.990621424775933255d-2)*t-2.274270582113632274d-2)
c19  *    *t-7.948696981362337488d-2)*t+1.542619991582476318d-1)
c19  *    *t+1.756184631287306123d-1)*t-5.052236706541698621d-1)
c19  *    *t-1.496959024160503295d-1)*t + 6.912904544398289657d-1
c
      s17agf = exp(-1.5d0*x)*y
      go to 180
c
c     4.5 .le. x .lt. 9.0
   60 t = 4.0d0*x/9.0d0 - 3.0d0
c
c      * expansion (0066) *
c
c     expansion (0066) evaluated as y(t)  --precision 08e.09
c08   y = (((((((((((-1.71591702d-4*t+1.40277439d-3)*t+1.10008824d-3)
c08  *    *t-2.11700099d-2)*t+9.40174032d-3)*t+1.98505788d-1)
c08  *    *t-2.54023900d-1)*t-1.27142691d+0)*t+2.52046740d+0)
c08  *    *t+5.04986515d+0)*t-1.33120981d+1)*t-9.34903820d+0)*t +
c08  *    3.10330813d+1
c
c     expansion (0066) evaluated as y(t)  --precision 09e.10
c09   y = ((((((((((((-8.374334944d-5*t-1.715917015d-4)
c09  *    *t+1.674940274d-3)*t+1.100088237d-3)*t-2.151021728d-2)
c09  *    *t+9.401740318d-3)*t+1.987099123d-1)*t-2.540239005d-1)
c09  *    *t-1.271486444d+0)*t+2.520467397d+0)*t+5.049872593d+0)
c09  *    *t-1.331209808d+1)*t-9.349038462d+0)*t + 3.103308130d+1
c
c     expansion (0066) evaluated as y(t)  --precision 12e.13
c12   y = (((((((((((((((-1.330969709207d-6*t+3.506872349310d-6)
c12  *    *t+2.373425502663d-5)*t-9.689412074673d-5)
c12  *    *t-2.446793213233d-4)*t+1.694666431371d-3)
c12  *    *t+1.196008506250d-3)*t-2.152528587425d-2)
c12  *    *t+9.337899864511d-3)*t+1.987160767245d-1)
c12  *    *t-2.540018838573d-1)*t-1.271487738798d+0)
c12  *    *t+2.520463764107d+0)*t+5.049872713290d+0)
c12  *    *t-1.331209785453d+1)*t-9.349038465484d+0)*t +
c12  *    3.103308129503d+1
c
c     expansion (0066) evaluated as y(t)  --precision 15e.16
c15   y = (((((((((((((((-3.041200056077980d-9*t-
c15  *    2.141323494012413d-9)*t+8.754580659780231d-8)
c15  *    *t-6.644291929457326d-8)*t-1.688811588231128d-6)
c15  *    *t+3.812140151154175d-6)*t+2.438263714312923d-5)
c15  *    *t-9.744168921361544d-5)*t-2.453234965855551d-4)
c15  *    *t+1.695181085931925d-3)*t+1.196384074890498d-3)
c15  *    *t-2.152556001404649d-2)*t+9.337770791052389d-3)
c15  *    *t+1.987161593597376d-1)*t-2.540018588890357d-1)
c15  *    *t-1.271487751989074d+0)*t+2.520463761684395d+0
c15   y = (((y*t+5.049872714234347d+0)*t-1.331209785444194d+1)
c15  *    *t-9.349038465503817d+0)*t + 3.103308129502578d+1
c
c     expansion (0066) evaluated as y(t)  --precision 17e.18
      y = (((((((((((((((+9.69081960415394529d-11*t+
     *    3.24436136050920784d-10)*t-3.57419513430644674d-9)
     *    *t-3.84461320827974687d-9)*t+8.88116699085949212d-8)
     *    *t-6.26105174374717557d-8)*t-1.69051051004298110d-6)
     *    *t+3.80731416363041759d-6)*t+2.43840529113057777d-5)
     *    *t-9.74379632673654766d-5)*t-2.45324254437931970d-4)
     *    *t+1.69517926953312785d-3)*t+1.19638433540225211d-3)
     *    *t-2.15255594590357451d-2)*t+9.33777073522844198d-3)
     *    *t+1.98716159257796883d-1)*t-2.54001858882057718d-1
      y = (((((y*t-1.27148775197878180d+0)*t+2.52046376168394778d+0)
     *    *t+5.04987271423387057d+0)*t-1.33120978544419281d+1)
     *    *t-9.34903846550381088d+0)*t + 3.10330812950257837d+1
c
c     expansion (0066) evaluated as y(t)  --precision 19e.19
c19   y = (((((((((((((((-2.065431510328016896d-12*t-
c19  *    1.963423107237753651d-11)*t+1.093007851035075543d-10)
c19  *    *t+4.373329647170916188d-10)*t-3.606725680594113004d-9)
c19  *    *t-4.126855279945173959d-9)*t+8.886072390696521158d-8)
c19  *    *t-6.220832248534852207d-8)*t-1.690557417928922691d-6)
c19  *    *t+3.806954304989044171d-6)*t+2.438408253733900399d-5)
c19  *    *t-9.743775334982467540d-5)*t-2.453242669192700427d-4)
c19  *    *t+1.695179189270538723d-3)*t+1.196384338863463509d-3)
c19  *    *t-2.152555943932841297d-2)*t+9.337770734620025918d-3
c19   y = (((((((y*t+1.987161592548407835d-1)
c19  *    *t-2.540018588819946227d-1)
c19  *    *t-1.271487751978535454d+0)*t+2.520463761683944396d+0)
c19  *    *t+5.049872714233861099d+0)*t-1.331209785444192805d+1)
c19  *    *t-9.349038465503810776d+0)*t + 3.103308129502578375d+1
c
      s17agf = exp(-2.5d0*x)*y
      go to 180
c
c     9.0 .le. x .le. xmax
   80 y = sqrt(x)
      z = 2.0d0*x*y/3.0d0
      g = sqrt(y)
      t = 36.0d0/z - 1.0d0
c
c      * expansion (0068) *
c
c     expansion (0068) evaluated as y(t)  --precision 08e.09
c08   y = (((+7.48168719d-9*t-1.96204961d-7)*t+7.44671177d-6)
c08  *    *t-5.28651766d-4)*t + 2.81558490d-1
c
c     expansion (0068) evaluated as y(t)  --precision 09e.10
c09   y = (((+7.481687192d-9*t-1.962049613d-7)*t+7.446711775d-6)
c09  *    *t-5.286517659d-4)*t + 2.815584896d-1
c
c     expansion (0068) evaluated as y(t)  --precision 12e.13
c12   y = (((((+2.235869654751d-11*t-3.702265779525d-10)
c12  *    *t+7.448149146792d-9)*t-1.957421780856d-7)
c12  *    *t+7.446724351668d-6)*t-5.286518815829d-4)*t +
c12  *    2.815584895850d-1
c
c     expansion (0068) evaluated as y(t)  --precision 15e.16
c15   y = ((((((((-1.164141714555725d-14*t+1.283341003915264d-13)
c15  *    *t-1.558604141003407d-12)*t+2.210202834672839d-11)
c15  *    *t-3.674728275171940d-10)*t+7.448309564417592d-9)
c15  *    *t-1.957435593263806d-7)*t+7.446724319584245d-6)
c15  *    *t-5.286518814099299d-4)*t + 2.815584895850063d-1
c
c     expansion (0068) evaluated as y(t)  --precision 17e.18
      y = (((((((((+1.16537795324979200d-15*t-1.16414171455572480d-14)
     *    *t+1.25420655508401920d-13)*t-1.55860414100340659d-12)
     *    *t+2.21045776110011276d-11)*t-3.67472827517194031d-10)
     *    *t+7.44830865396606612d-9)*t-1.95743559326380581d-7)
     *    *t+7.44672431969805149d-6)*t-5.28651881409929932d-4)*t +
     *    2.81558489585006298d-1
c
c     expansion (0068) evaluated as y(t)  --precision 19e.19
c19   y = (((((((((((+1.501018989977600000d-17*t-
c19  *    1.272409054668800000d-16)*t+1.120347383550464000d-15)
c19  *    *t-1.129150465552332800d-14)*t+1.254713148993136640d-13)
c19  *    *t-1.558954053493440512d-12)*t+2.210455134316880294d-11)
c19  *    *t-3.674726744304796410d-10)*t+7.448308660122589319d-9)
c19  *    *t-1.957435593537174940d-7)*t+7.446724319697523786d-6)
c19  *    *t-5.286518814099285651d-4)*t + 2.815584895850062983d-1
c
c     modified to get scaled ai for x.ge.9          29.10.2005
c      s17agf = exp(-z)*y/g
      s17agf = y/g
       
      go to 180
c
c
c     negative arguments
  100 if (x.lt.xmin) go to 160
      ifail = 0
      if (x.lt.-5.0d0) go to 120
c
c     -5.0 .le. x .lt. 0.0
      t = x/5.0d0
      t = -t*t*t
      t = 2.0d0*t - 1.0d0
      t2 = 2.0d0*t
c
c      * expansion (0062) *
c
c     expansion (0062) evaluated as f(t)  --precision 08e.09
c08   a = -6.56273599d-10
c08   b = t2*a + 2.09250023d-8
c08   c = t2*b - a - 5.42780373d-7
c08   a = t2*c - b + 1.11655763d-5
c08   b = t2*a - c - 1.76193215d-4
c08   c = t2*b - a + 2.03792657d-3
c08   a = t2*c - b - 1.61616261d-2
c08   b = t2*a - c + 7.87369695d-2
c08   c = t2*b - a - 1.88090320d-1
c08   a = t2*c - b + 8.83593329d-2
c08   b = t2*a - c + 9.46330440d-2
c08   f = t*b - a + 7.60869994d-2
c
c     expansion (0062) evaluated as f(t)  --precision 09e.10
c09   a = -6.562735990d-10
c09   b = t2*a + 2.092500233d-8
c09   c = t2*b - a - 5.427803729d-7
c09   a = t2*c - b + 1.116557635d-5
c09   b = t2*a - c - 1.761932151d-4
c09   c = t2*b - a + 2.037926574d-3
c09   a = t2*c - b - 1.616162609d-2
c09   b = t2*a - c + 7.873696951d-2
c09   c = t2*b - a - 1.880903202d-1
c09   a = t2*c - b + 8.835933287d-2
c09   b = t2*a - c + 9.463304396d-2
c09   f = t*b - a + 7.608699941d-2
c
c     expansion (0062) evaluated as f(t)  --precision 12e.13
c12   a = -3.755045810333d-13
c12   b = t2*a + 1.708749758077d-11
c12   c = t2*b - a - 6.562735990133d-10
c12   a = t2*c - b + 2.092500233007d-8
c12   b = t2*a - c - 5.427803728940d-7
c12   c = t2*b - a + 1.116557634725d-5
c12   a = t2*c - b - 1.761932150809d-4
c12   b = t2*a - c + 2.037926574031d-3
c12   c = t2*b - a - 1.616162609419d-2
c12   a = t2*c - b + 7.873696950590d-2
c12   b = t2*a - c - 1.880903202189d-1
c12   c = t2*b - a + 8.835933286664d-2
c12   a = t2*c - b + 9.463304395659d-2
c12   f = t*a - c + 7.608699941417d-2
c
c     expansion (0062) evaluated as f(t)  --precision 15e.16
c15   a = -1.149373682830250d-16
c15   b = t2*a + 7.060906358566960d-15
c15   c = t2*b - a - 3.755045810332901d-13
c15   a = t2*c - b + 1.708749758076624d-11
c15   b = t2*a - c - 6.562735990132918d-10
c15   c = t2*b - a + 2.092500233006599d-8
c15   a = t2*c - b - 5.427803728939972d-7
c15   b = t2*a - c + 1.116557634724685d-5
c15   c = t2*b - a - 1.761932150809126d-4
c15   a = t2*c - b + 2.037926574031449d-3
c15   b = t2*a - c - 1.616162609419080d-2
c15   c = t2*b - a + 7.873696950590187d-2
c15   a = t2*c - b - 1.880903202189157d-1
c15   b = t2*a - c + 8.835933286664339d-2
c15   c = t2*b - a + 9.463304395658582d-2
c15   f = t*c - b + 7.608699941417266d-2
c
c     expansion (0062) evaluated as f(t)  --precision 17e.18
      a = +1.63586492025000000d-18
      b = t2*a - 1.14937368283025000d-16
      c = t2*b - a + 7.06090635856696000d-15
      a = t2*c - b - 3.75504581033290114d-13
      b = t2*a - c + 1.70874975807662448d-11
      c = t2*b - a - 6.56273599013291800d-10
      a = t2*c - b + 2.09250023300659871d-8
      b = t2*a - c - 5.42780372893997236d-7
      c = t2*b - a + 1.11655763472468469d-5
      a = t2*c - b - 1.76193215080912647d-4
      b = t2*a - c + 2.03792657403144947d-3
      c = t2*b - a - 1.61616260941907957d-2
      a = t2*c - b + 7.87369695059018748d-2
      b = t2*a - c - 1.88090320218915726d-1
      c = t2*b - a + 8.83593328666433903d-2
      a = t2*c - b + 9.46330439565858235d-2
      f = t*a - c + 7.60869994141726643d-2
c
c     expansion (0062) evaluated as f(t)  --precision 19e.19
c19   a = -2.053415725200000000d-20
c19   b = t2*a + 1.635864920250000000d-18
c19   c = t2*b - a - 1.149373682830250000d-16
c19   a = t2*c - b + 7.060906358566960000d-15
c19   b = t2*a - c - 3.755045810332901140d-13
c19   c = t2*b - a + 1.708749758076624480d-11
c19   a = t2*c - b - 6.562735990132918003d-10
c19   b = t2*a - c + 2.092500233006598708d-8
c19   c = t2*b - a - 5.427803728939972360d-7
c19   a = t2*c - b + 1.116557634724684695d-5
c19   b = t2*a - c - 1.761932150809126465d-4
c19   c = t2*b - a + 2.037926574031449469d-3
c19   a = t2*c - b - 1.616162609419079569d-2
c19   b = t2*a - c + 7.873696950590187481d-2
c19   c = t2*b - a - 1.880903202189157259d-1
c19   a = t2*c - b + 8.835933286664339033d-2
c19   b = t2*a - c + 9.463304395658582345d-2
c19   f = t*b - a + 7.608699941417266430d-2
c
c
c      * expansion (0063) *
c
c     expansion (0063) evaluated as g(t)  --precision 08e.09
c08   a = +2.18414557d-9
c08   b = t2*a - 6.11127835d-8
c08   c = t2*b - a + 1.37095478d-6
c08   a = t2*c - b - 2.39464595d-5
c08   b = t2*a - c + 3.13306257d-4
c08   c = t2*b - a - 2.90953381d-3
c08   a = t2*c - b + 1.76972907d-2
c08   b = t2*a - c - 6.17055677d-2
c08   c = t2*b - a + 9.52472833d-2
c08   a = t2*c - b - 4.32381694d-2
c08   g = t*a - c + 3.76828718d-2
c
c     expansion (0063) evaluated as g(t)  --precision 09e.10
c09   a = -6.403863754d-11
c09   b = t2*a + 2.184145572d-9
c09   c = t2*b - a - 6.111278350d-8
c09   a = t2*c - b + 1.370954782d-6
c09   b = t2*a - c - 2.394645953d-5
c09   c = t2*b - a + 3.133062570d-4
c09   a = t2*c - b - 2.909533806d-3
c09   b = t2*a - c + 1.769729071d-2
c09   c = t2*b - a - 6.170556772d-2
c09   a = t2*c - b + 9.524728334d-2
c09   b = t2*a - c - 4.323816942d-2
c09   g = t*b - a + 3.768287177d-2
c
c     expansion (0063) evaluated as g(t)  --precision 12e.13
c12   a = -3.262530732733d-14
c12   b = t2*a + 1.569118250997d-12
c12   c = t2*b - a - 6.403863753934d-11
c12   a = t2*c - b + 2.184145572027d-9
c12   b = t2*a - c - 6.111278350334d-8
c12   c = t2*b - a + 1.370954782253d-6
c12   a = t2*c - b - 2.394645953138d-5
c12   b = t2*a - c + 3.133062569753d-4
c12   c = t2*b - a - 2.909533805902d-3
c12   a = t2*c - b + 1.769729070741d-2
c12   b = t2*a - c - 6.170556771641d-2
c12   c = t2*b - a + 9.524728333672d-2
c12   a = t2*c - b - 4.323816942235d-2
c12   g = t*a - c + 3.768287177015d-2
c
c     expansion (0063) evaluated as g(t)  --precision 15e.16
c15   a = +5.830523483771460d-16
c15   b = t2*a - 3.262530732733058d-14
c15   c = t2*b - a + 1.569118250996656d-12
c15   a = t2*c - b - 6.403863753934148d-11
c15   b = t2*a - c + 2.184145572027331d-9
c15   c = t2*b - a - 6.111278350334019d-8
c15   a = t2*c - b + 1.370954782252896d-6
c15   b = t2*a - c - 2.394645953138124d-5
c15   c = t2*b - a + 3.133062569752993d-4
c15   a = t2*c - b - 2.909533805902076d-3
c15   b = t2*a - c + 1.769729070740923d-2
c15   c = t2*b - a - 6.170556771641222d-2
c15   a = t2*c - b + 9.524728333672139d-2
c15   b = t2*a - c - 4.323816942234849d-2
c15   g = t*b - a + 3.768287177015441d-2
c
c     expansion (0063) evaluated as g(t)  --precision 17e.18
      a = +1.23340698467000000d-19
      b = t2*a - 9.05440546731800000d-18
      c = t2*b - a + 5.83052348377146000d-16
      a = t2*c - b - 3.26253073273305810d-14
      b = t2*a - c + 1.56911825099665634d-12
      c = t2*b - a - 6.40386375393414830d-11
      a = t2*c - b + 2.18414557202733054d-9
      b = t2*a - c - 6.11127835033401880d-8
      c = t2*b - a + 1.37095478225289560d-6
      a = t2*c - b - 2.39464595313812449d-5
      b = t2*a - c + 3.13306256975299299d-4
      c = t2*b - a - 2.90953380590207648d-3
      a = t2*c - b + 1.76972907074092250d-2
      b = t2*a - c - 6.17055677164122241d-2
      c = t2*b - a + 9.52472833367213949d-2
      a = t2*c - b - 4.32381694223484894d-2
      g = t*a - c + 3.76828717701544063d-2
c
c     expansion (0063) evaluated as g(t)  --precision 19e.19
c19   a = -1.485996171000000000d-21
c19   b = t2*a + 1.233406984670000000d-19
c19   c = t2*b - a - 9.054405467318000000d-18
c19   a = t2*c - b + 5.830523483771460000d-16
c19   b = t2*a - c - 3.262530732733058100d-14
c19   c = t2*b - a + 1.569118250996656338d-12
c19   a = t2*c - b - 6.403863753934148297d-11
c19   b = t2*a - c + 2.184145572027330536d-9
c19   c = t2*b - a - 6.111278350334018800d-8
c19   a = t2*c - b + 1.370954782252895603d-6
c19   b = t2*a - c - 2.394645953138124487d-5
c19   c = t2*b - a + 3.133062569752992987d-4
c19   a = t2*c - b - 2.909533805902076483d-3
c19   b = t2*a - c + 1.769729070740922505d-2
c19   c = t2*b - a - 6.170556771641222415d-2
c19   a = t2*c - b + 9.524728333672139490d-2
c19   b = t2*a - c - 4.323816942234848936d-2
c19   g = t*b - a + 3.768287177015440633d-2
c
      s17agf = f - g*x
      go to 180
c
c     xmin .le. x .lt. -5.0
  120 y = sqrt(-x)
      z = -2.0d0*x*y/3.0d0
      g = z + pib4
      y = sqrt(y)
      t = -250.0d0/(x*x*x) - 1.0d0
c
c      * expansion (0060) *
c
c     expansion (0060) evaluated as a(t)  --precision 08e.09
c08   a = (((+6.15912654d-9*t-8.78096033d-8)*t+2.32929819d-6)
c08  *    *t-1.83605134d-4)*t + 5.64003555d-1
c
c     expansion (0060) evaluated as a(t)  --precision 09e.10
c09   a = (((+6.159126542d-9*t-8.780960327d-8)*t+2.329298189d-6)
c09  *    *t-1.836051343d-4)*t + 5.640035551d-1
c
c     expansion (0060) evaluated as a(t)  --precision 12e.13
c12   a = ((((((-1.715016966209d-11*t+9.450718282139d-11)
c12  *    *t-6.258520368216d-10)*t+6.017365767755d-9)
c12  *    *t-8.700477862436d-8)*t+2.329351348941d-6)
c12  *    *t-1.836053373353d-4)*t + 5.640035550994d-1
c
c     expansion (0060) evaluated as a(t)  --precision 15e.16
c15   a = ((((((((((-8.563884716731904d-14*t+2.697790028676367d-13)
c15  *    *t-7.081756671882112d-13)*t+3.060690564443398d-12)
c15  *    *t-1.526239087378051d-11)*t+8.762704824694287d-11)
c15  *    *t-6.273414667970969d-10)*t+6.021823925499018d-9)
c15  *    *t-8.700435467216258d-8)*t+2.329350441501844d-6)
c15  *    *t-1.836053373676030d-4)*t + 5.640035550994134d-1
c
c     expansion (0060) evaluated as a(t)  --precision 17e.18
      a = (((((((((((((+4.50071772808806400d-15*t-
     *    1.11777933477806080d-14)*t+1.39959545848483840d-14)
     *    *t-4.93110187870320640d-14)*t+2.02193307034590720d-13)
     *    *t-7.53585452663569920d-13)*t+3.14632365928501299d-12)
     *    *t-1.52351450024952975d-11)*t+8.75801572233507014d-11)
     *    *t-6.27349413509555121d-10)*t+6.02183526555303242d-9)
     *    *t-8.70043536788235270d-8)*t+2.32935044050984079d-6)
     *    *t-1.83605337367638430d-4)*t + 5.64003555099413391d-1
c
c     expansion (0060) evaluated as a(t)  --precision 19e.19
c19   a = ((((((((((((((((-4.145996909772800000d-16*t+
c19  *    8.719038745477120000d-16)*t-1.650739531939840000d-16)
c19  *    *t+1.013102229897216000d-15)*t-7.034668649996288000d-15)
c19  *    *t+1.966332976940851200d-14)*t-5.728775452036198400d-14)
c19  *    *t+1.973978357245783040d-13)*t-7.468191081605683200d-13)
c19  *    *t+3.148571536461581312d-12)*t-1.523807824458362650d-11)
c19  *    *t+8.757958503643302944d-11)*t-6.273487744018275593d-10)
c19  *    *t+6.021835337076397133d-9)*t-8.700435373952972456d-8)
c19  *    *t+2.329350440506434910d-6)*t-1.836053373676367731d-4)*t +
c19  *    5.640035550994133905d-1
c
c
c      * expansion (0061) *
c
c     expansion (0061) evaluated as b(t)  --precision 08e.09
c08   b = ((((-2.77049286d-9*t+2.16663908d-8)*t-2.37768347d-7)
c08  *    *t+4.43089269d-6)*t-1.83241381d-4)*t + 3.89918977d-2
c
c     expansion (0061) evaluated as b(t)  --precision 09e.10
c09   b = (((((+4.606963501d-10*t-2.770492865d-9)*t+2.097534624d-8)
c09  *    *t-2.377683473d-7)*t+4.431151831d-6)*t-1.832413815d-4)*t +
c09  *    3.899189768d-2
c
c     expansion (0061) evaluated as b(t)  --precision 12e.13
c12   b = (((((((((+1.905559246812d-12*t-6.196625335478d-12)
c12  *    *t+1.779405775025d-11)*t-7.999675578189d-11)
c12  *    *t+4.197488492041d-10)*t-2.616556135221d-9)
c12  *    *t+2.100205496934d-8)*t-2.378476393860d-7)
c12  *    *t+4.431146377531d-6)*t-1.832413714432d-4)*t +
c12  *    3.899189768110d-2
c
c     expansion (0061) evaluated as b(t)  --precision 15e.16
c15   b = (((((((((((((+3.969783702995763d-14*t-9.400837697076019d-14)
c15  *    *t+9.852025583444992d-14)*t-3.397009779051110d-13)
c15  *    *t+1.384217031200711d-12)*t-4.804156808506625d-12)
c15  *    *t+1.846523578585801d-11)*t-8.154198792143967d-11)
c15  *    *t+4.193788799892521d-10)*t-2.615846679119911d-9)
c15  *    *t+2.100214476773484d-8)*t-2.378477696549908d-7)
c15  *    *t+4.431146369657840d-6)*t-1.832413714365943d-4)*t +
c15  *    3.899189768110265d-2
c
c     expansion (0061) evaluated as b(t)  --precision 17e.18
      b = ((((((((((((((((-4.12972759036723200d-15*t+
     *    8.36512465551360000d-15)*t-2.05945081774080000d-16)
     *    *t+6.23733840790323200d-15)*t-5.81333983959859200d-14)
     *    *t+1.52893566095288320d-13)*t-4.11064788026333184d-13)
     *    *t+1.33820884559538637d-12)*t-4.74293914921785574d-12)
     *    *t+1.84868021228605050d-11)*t-8.15686769476673166d-11)
     *    *t+4.19373390376196942d-10)*t-2.61584084406303574d-9)
     *    *t+2.10021454539364698d-8)*t-2.37847770210509358d-7)
     *    *t+4.43114636962516363d-6)*t-1.83241371436579068d-4)*t +
     *    3.89918976811026487d-2
c
c     expansion (0061) evaluated as b(t)  --precision 19e.19
c19   b = (((((((((((((((-3.633742725775360000d-16*t+
c19  *    6.329882231439360000d-16)*t+7.678637957447680000d-16)
c19  *    *t-1.037278429052928000d-15)*t-3.007793292574720000d-15)
c19  *    *t+5.516142436417536000d-15)*t-5.629338562412544000d-15)
c19  *    *t+1.627713953735475200d-14)*t-5.046275910502400000d-14)
c19  *    *t+1.403671321108049920d-13)*t-4.167288366073487360d-13)
c19  *    *t+1.346430254448406016d-12)*t-4.740536381002437888d-12)
c19  *    *t+1.848376245973714726d-11)*t-8.156926070839937062d-11)
c19  *    *t+4.193740083371970509d-10)*t-2.615840768348341801d-9
c19   b = ((((b*t+2.100214539177924140d-8)*t-2.378477702149326189d-7)
c19  *    *t+4.431146369627551869d-6)*t-1.832413714365789927d-4)*t +
c19  *    3.899189768110264871d-2
c
      s17agf = (sin(g)*a-cos(g)*b/z)/y
      go to 180
c
c
c     failure exits
  140 ifail = p01abf(ifail,1,srname,0,p01rec)
      s17agf = 0.0d0
      go to 180
  160 ifail = p01abf(ifail,2,srname,0,p01rec)
      s17agf = 0.0d0
c
c
  180 return
c
      end
      double precision function s17ajf(x,ifail)
c     mark 8 release. nag copyright 1979.
c     mark 8a revised. ier-263 (aug 1980)
c     mark 11.5(f77) revised. (sept 1985.)
c     mark 13 revised. use of mark 12 x02 functions (apr 1988).
c
c     airy function aip(x)
c
c     **************************************************************
c
c     to extract the correct code for a particular machine-range,
c     activate the statements contained in comments beginning  cdd ,
c     where  dd  is the approximate number of significant decimal
c     digits represented by the machine
c     delete the illegal dummy statements of the form
c     * expansion (nnnn) *
c
c     also insert appropriate data statements to define constants
c     which depend on the range of numbers represented by the
c     machine, rather than the precision (suitable statements for
c     some machines are contained in comments beginning crd where
c     d is a digit which simply distinguishes a group of machines).
c     delete the illegal dummy data statements with values written
c     *value*
c
c     **************************************************************
c
c     .. parameters ..
      character*6                      srname
      parameter                        (srname='s17ajf')
c     .. scalar arguments ..
      double precision                 x
      integer                          ifail
c     .. local scalars ..
      double precision                 a, b, c, c2, f, g, pib4, t, t2,
     *                                 xmax, xmin, xrelpr, y, z
c     .. local arrays ..
      character*1                      p01rec(1)
c     .. external functions ..
      integer                          p01abf
      external                         p01abf
c     .. intrinsic functions ..
      intrinsic                        abs, cos, exp, sin, sqrt, int
c     .. data statements ..
c     precision dependent constants
c08   data xmin,xrelpr,c2,pib4
c08  */-3.8d3,9.5d-7,2.58819403d-1,7.85398163d-1/
c09   data xmin,xrelpr,c2,pib4
c09  */-4.1d4,1.8d-8,2.588194037d-1,7.853981634d-1/
c12   data xmin,xrelpr,c2,pib4
c12  */-3.2d6,7.3d-12,2.588194037928d-1,7.853981633974d-1/
c15   data xmin,xrelpr,c2,pib4
c15  */-1.6d8,7.1d-15,2.588194037928067d-1,7.853981633974483d-1/
      data xmin,xrelpr,c2,pib4
     */-8.5d+4,2.2d-16,2.58819403792806798d-1,7.85398163397448310d-1/
c19   data xmin,xrelpr,c2,pib4
c19  */-1.9d10,1.7d-18,2.5881940379280679840d-1,7.853981633974483096d-1/
c
c     c2=-aip(0.0)
c     xrelpr=x02ajf()
c     xmin=-amin1((sqrt(pi)/xrelpr)**(4/7),(1.5*(xscmax-pib4))**(2/3))
c     where xscmax is the maximum value of x for which sin(x) and cos(x)
c     can be computed without execution error.
c
c     **** warning - values of xmin given above may need adjusting ****
c
c     range dependent constants
      data xmax/1.041d+2/
c     for icl 1900
cr3   data xmax/41.43d0/
c     for ibm 360/370 and similar machines
cr1   data xmax/41.75d0/
c     for cdc 7600/cyber
cr4   data xmax/100.9d0/
c     for dec10, honeywell, univac 1100 (s.p.)
cr2   data xmax/26.11d0/
c     for burroughs
cr6   data xmax/29.02d0/
c     for univac 1100 (d.p.)
cr5   data xmax/104.3d0/
c
c     xmax.lt.((-ln(xunflo)+0.25*ln(xmax)-1.26)*1.5)**(2/3)
c
c     .. executable statements ..
      if (abs(x).gt.xrelpr) go to 20
      s17ajf = -c2
      ifail = 0
      go to 180
   20 if (x.le.0.0d0) go to 100
c
c     positive arguments
      if (x.gt.xmax) go to 140
      ifail = 0
      if (int(x/4.5d0)-1) 40, 60, 80
c
c     0.0 .lt. x .lt. 4.5
   40 t = 4.0d0*x/9.0d0 - 1.0d0
c
c      * expansion (0074) *
c
c     expansion (0074) evaluated as y(t)  --precision 08e.09
c08   y = (((((((((((((-2.12248991d-5*t+3.75164189d-5)*t+2.25511285d-4)
c08  *    *t-7.03053129d-4)*t-9.74584985d-4)*t+6.69041045d-3)
c08  *    *t-1.66877264d-3)*t-3.83621720d-2)*t+4.80475712d-2)
c08  *    *t+1.28359838d-1)*t-2.80267306d-1)*t-2.06049819d-1)
c08  *    *t+7.63522851d-1)*t+6.47699894d-2)*t - 8.32940737d-1
c
c     expansion (0074) evaluated as y(t)  --precision 09e.10
c09   y = (((((((((((((((+1.796546286d-6*t-9.168551089d-9)
c09  *    *t-2.841108429d-5)*t+3.755080092d-5)*t+2.371888360d-4)
c09  *    *t-7.031047024d-4)*t-9.844659898d-4)*t+6.690449844d-3)
c09  *    *t-1.664140920d-3)*t-3.836218812d-2)*t+4.804639220d-2)
c09  *    *t+1.283598417d-1)*t-2.802671588d-1)*t-2.060498189d-1)
c09  *    *t+7.635228436d-1)*t+6.476998937d-2)*t - 8.329407374d-1
c
c     expansion (0074) evaluated as y(t)  --precision 12e.13
c12   y = (((((((((((((((+3.224603673594d-8*t-9.020464113572d-8)
c12  *    *t-4.289771168958d-7)*t+2.202467170722d-6)
c12  *    *t+1.469354678102d-6)*t-2.917218594950d-5)
c12  *    *t+3.516441915248d-5)*t+2.379583942958d-4)
c12  *    *t-7.009821135980d-4)*t-9.849194795500d-4)
c12  *    *t+6.689356937711d-3)*t-1.663983943024d-3)
c12  *    *t-3.836186616701d-2)*t+4.804636167889d-2)
c12  *    *t+1.283597911449d-1)*t-2.802671558602d-1)
c12  *    *t-2.060498153612d-1
c12   y = ((y*t+7.635228435313d-1)
c12  *    *t+6.476998929783d-2)*t - 8.329407374096d-1
c
c     expansion (0074) evaluated as y(t)  --precision 15e.16
c15   y = (((((((((((((((+2.290465697392943d-10*t-
c15  *    2.125224246145899d-9)*t-1.002844461589536d-10)
c15  *    *t+4.340346402820644d-8)*t-9.301007875553845d-8)
c15  *    *t-4.540813283034086d-7)*t+2.210771084724791d-6)
c15  *    *t+1.500967388763857d-6)*t-2.918333311836674d-5)
c15  *    *t+3.514001228027592d-5)*t+2.379669069788085d-4)
c15  *    *t-7.009702152477689d-4)*t-9.849233975350401d-4)
c15  *    *t+6.689353302104206d-3)*t-1.663982860577803d-3)
c15  *    *t-3.836186549924378d-2)*t+4.804636150855828d-2
c15   y = (((((y*t+1.283597910775252d-1)*t-2.802671558466762d-1)
c15  *    *t-2.060498153580448d-1)*t+7.635228435308777d-1)
c15  *    *t+6.476998929778270d-2)*t - 8.329407374096260d-1
c
c     expansion (0074) evaluated as y(t)  --precision 17e.18
      y = (((((((((((((((-2.31635825886515692d-11*t+
     *    8.43840142802870600d-11)*t+3.68028065271203758d-10)
     *    *t-2.61043232825754937d-9)*t-4.65110871930215858d-10)
     *    *t+4.46164842334855713d-8)*t-9.24599436690579710d-8)
     *    *t-4.55809882095931368d-7)*t+2.21024501804834447d-6)
     *    *t+1.50251398952558802d-6)*t-2.91830008657289876d-5)
     *    *t+3.51391100964982453d-5)*t+2.37966767002002741d-4)
     *    *t-7.00969870295148024d-4)*t-9.84923358717942729d-4)
     *    *t+6.68935321740601810d-3)*t-1.66398286740112083d-3
      y = (((((((y*t-3.83618654865390504d-2)*t+4.80463615092658847d-2)
     *    *t+1.28359791076466449d-1)*t-2.80267155846714091d-1)
     *    *t-2.06049815358004057d-1)*t+7.63522843530878467d-1)
     *    *t+6.47699892977822355d-2)*t - 8.32940737409625965d-1
c
c     expansion (0074) evaluated as y(t)  --precision 19e.19
c19   y = (((((((((((((((+1.227184476371550208d-12*t-
c19  *    1.091696824302960640d-12)*t-3.114028168506664550d-11)
c19  *    *t+9.120711943218056397d-11)*t+3.909610751733971026d-10)
c19  *    *t-2.629195867425256505d-9)*t-5.034987363317134131d-10)
c19  *    *t+4.464633531852510541d-8)*t-9.241850222453362708d-8)
c19  *    *t-4.558402662360608937d-7)*t+2.210214824995905304d-6)
c19  *    *t+1.502534650740876099d-6)*t-2.918298576920276804d-5)
c19  *    *t+3.513910058146488898d-5)*t+2.379667618374016661d-4)
c19  *    *t-7.009698673500186514d-4)*t-9.849233575343883164d-4
c19   y = (((((((((y*t+6.689353216810495620d-3)
c19  *    *t-1.663982867575172949d-3)
c19  *    *t-3.836186548646461013d-2)*t+4.804636150928111428d-2)
c19  *    *t+1.283597910764612381d-1)*t-2.802671558467147832d-1)
c19  *    *t-2.060498153580038879d-1)*t+7.635228435308784797d-1)
c19  *    *t+6.476998929778223388d-2)*t - 8.329407374096259655d-1
c
      s17ajf = exp(-1.375d0*x)*y
      go to 180
c
c     4.5 .le. x .lt. 9.0
   60 t = 4.0d0*x/9.0d0 - 3.0d0
c
c      * expansion (0076) *
c
c     expansion (0076) evaluated as y(t)  --precision 08e.09
c08   y = ((((((((((((+3.21581408d-4*t-4.90628721d-5)*t-5.43917553d-3)
c08  *    *t+5.42240338d-3)*t+5.90505909d-2)*t-1.09528884d-1)
c08  *    *t-4.63556789d-1)*t+1.25326074d+0)*t+2.50137428d+0)
c08  *    *t-9.12669234d+0)*t-8.14385669d+0)*t+4.00134085d+1)
c08  *    *t+1.15396203d+1)*t - 8.17378314d+1
c
c     expansion (0076) evaluated as y(t)  --precision 09e.10
c09   y = ((((((((((((+3.215814083d-4*t-4.906287212d-5)
c09  *    *t-5.439175532d-3)*t+5.422403376d-3)*t+5.905059094d-2)
c09  *    *t-1.095288840d-1)*t-4.635567889d-1)*t+1.253260744d+0)
c09  *    *t+2.501374278d+0)*t-9.126692336d+0)*t-8.143856692d+0)
c09  *    *t+4.001340854d+1)*t+1.153962028d+1)*t - 8.173783145d+1
c
c     expansion (0076) evaluated as y(t)  --precision 12e.13
c12   y = ((((((((((((((((+7.635546207506d-7*t+2.744226966507d-6)
c12  *    *t-2.133395672265d-5)*t-3.376949867175d-5)
c12  *    *t+3.950935316954d-4)*t+4.854867097982d-5)
c12  *    *t-5.546198609632d-3)*t+5.297620784039d-3)
c12  *    *t+5.913110523176d-2)*t-1.094470208249d-1)
c12  *    *t-4.635894223577d-1)*t+1.253232767019d+0)
c12  *    *t+2.501381087949d+0)*t-9.126687748607d+0)
c12  *    *t-8.143857320275d+0)*t+4.001340825533d+1)
c12  *    *t+1.153962029314d+1)*t - 8.173783144446d+1
c
c     expansion (0076) evaluated as y(t)  --precision 15e.16
c15   y = (((((((((((((((+1.058146838625346d-8*t-
c15  *    2.144406933093463d-8)*t-2.510945279460552d-7)
c15  *    *t+8.654139500725779d-7)*t+3.748497405177312d-6)
c15  *    *t-2.153767538129716d-5)*t-3.557397140857629d-5)
c15  *    *t+3.953163489783361d-4)*t+5.033348994401875d-5)
c15  *    *t-5.546343440865714d-3)*t+5.296583053733773d-3)
c15  *    *t+5.913116212974207d-2)*t-1.094466648501401d-1)
c15  *    *t-4.635894354880470d-1)*t+1.253232698252041d+0)
c15  *    *t+2.501381089590538d+0)*t-9.126687741941989d+0
c15   y = (((y*t-8.143857320368572d+0)*t+4.001340825508335d+1)
c15  *    *t+1.153962029314448d+1)*t - 8.173783144445504d+1
c
c     expansion (0076) evaluated as y(t)  --precision 17e.18
      y = (((((((((((((((-4.40679918437492851d-10*t+
     *    1.30954945449348301d-10)*t+1.30052079376596751d-8)
     *    *t-2.21315827945437064d-8)*t-2.56850909380644963d-7)
     *    *t+8.66960855365698346d-7)*t+3.75622307499741911d-6)
     *    *t-2.15396233361107222d-5)*t-3.55804094667597110d-5)
     *    *t+3.95317852914037711d-4)*t+5.03369361986934094d-5)
     *    *t-5.54634417403436820d-3)*t+5.29658186908372832d-3)
     *    *t+5.91311623537658225d-2)*t-1.09446664596286554d-1)
     *    *t-4.63589435529194219d-1)*t+1.25323269822030972d+0
      y = (((((y*t+2.50138108959469254d+0)*t-9.12668774193995449d+0)
     *    *t-8.14385732036876466d+0)*t+4.00134082550833019d+1)
     *    *t+1.15396202931444799d+1)*t - 8.17378314444550419d+1
c
c     expansion (0076) evaluated as y(t)  --precision 19e.19
c19   y = (((((((((((((((+1.434775817842956698d-11*t+
c19  *    2.707949702953199206d-11)*t-5.267664675080702525d-10)
c19  *    *t-2.475216247046065357d-11)*t+1.323118512896994076d-8)
c19  *    *t-2.174231502474418402d-8)*t-2.571916686373826653d-7)
c19  *    *t+8.664061487937340266d-7)*t+3.756548926036674542d-6)
c19  *    *t-2.153912701970422780d-5)*t-3.558061526741608280d-5)
c19  *    *t+3.953175633961339227d-4)*t+5.033702290174771421d-5)
c19  *    *t-5.546344063336346159d-3)*t+5.296581845040024183d-3)
c19  *    *t+5.913116232658550460d-2)*t-1.094466645920601219d-1
c19   y = (((((((y*t-4.635894355251171710d-1)
c19  *    *t+1.253232698219871423d+0)
c19  *    *t+2.501381089594352782d+0)*t-9.126687741939931009d+0)
c19  *    *t-8.143857320368751592d+0)*t+4.001340825508330142d+1)
c19  *    *t+1.153962029314447978d+1)*t - 8.173783144445504193d+1
c
      s17ajf = exp(-2.5d0*x)*y
      go to 180
c
c     9.0 .le. x .le. xmax
   80 y = sqrt(x)
      z = 2.0d0*x*y/3.0d0
      g = sqrt(y)
      t = 36.0d0/z - 1.0d0
c
c      * expansion (0078) *
c
c     expansion (0078) evaluated as y(t)  --precision 08e.09
c08   y = (((-8.16668293d-9*t+2.20231671d-7)*t-8.83992184d-6)
c08  *    *t+7.43456216d-4)*t + 2.82847316d-1
c
c     expansion (0078) evaluated as y(t)  --precision 09e.10
c09   y = (((-8.166682931d-9*t+2.202316705d-7)*t-8.839921836d-6)
c09  *    *t+7.434562160d-4)*t + 2.828473163d-1
c
c     expansion (0078) evaluated as y(t)  --precision 12e.13
c12   y = (((((-2.373322779924d-11*t+3.974072910770d-10)
c12  *    *t-8.131083089680d-9)*t+2.197349114033d-7)
c12  *    *t-8.839935185736d-6)*t+7.434563401542d-4)*t +
c12  *    2.828473163364d-1
c
c     expansion (0078) evaluated as y(t)  --precision 15e.16
c15   y = ((((((((+1.212812185390208d-14*t-1.343275896980817d-13)
c15  *    *t+1.641527817545337d-12)*t-2.346457261984447d-11)
c15  *    *t+3.945073291221193d-10)*t-8.131250999167219d-9)
c15  *    *t+2.197363659323565d-7)*t-8.839935152154458d-6)
c15  *    *t+7.434563399720802d-4)*t + 2.828473163363792d-1
c
c     expansion (0078) evaluated as y(t)  --precision 17e.18
      y = (((((((((-1.20954638924697600d-15*t+1.21281218539020800d-14)
     *    *t-1.31303723724964224d-13)*t+1.64152781754533677d-12)
     *    *t-2.34672185025709461d-11)*t+3.94507329122119338d-10)
     *    *t-8.13125005420910243d-9)*t+2.19736365932356533d-7)
     *    *t-8.83993515227257822d-6)*t+7.43456339972080231d-4)*t +
     *    2.82847316336379200d-1
c
c     expansion (0078) evaluated as y(t)  --precision 19e.19
c19   y = (((((((((((-1.549121811046400000d-17*t+
c19  *    1.316570520903680000d-16)*t-1.163072734915584000d-15)
c19  *    *t+1.176606496065356800d-14)*t-1.313560065860870400d-13)
c19  *    *t+1.641889874438585280d-12)*t-2.346719139293925283d-11)
c19  *    *t+3.945071707222285418d-10)*t-8.131250060562922355d-9)
c19  *    *t+2.197363659606422280d-7)*t-8.839935152272033607d-6)
c19  *    *t+7.434563399720788172d-4)*t + 2.828473163363791998d-1
c
c     modified to get scaled aip for x.ge.9        29.10.2005
c      s17ajf = -exp(-z)*y*g
      s17ajf = -y*g
      go to 180
c
c     negative arguments
  100 if (x.lt.xmin) go to 160
      ifail = 0
      if (x.lt.-5.0d0) go to 120
c
c     -5.0 .le. x .lt. 0.0
      t = x/5.0d0
      t = -t*t*t
      t = 2.0d0*t - 1.0d0
      t2 = 2.0d0*t
c
c      * expansion (0072) *
c
c     expansion (0072) evaluated as f(t)  --precision 08e.09
c08   a = +6.93493716d-10
c08   b = t2*a - 2.01076965d-8
c08   c = t2*b - a + 4.69655736d-7
c08   a = t2*c - b - 8.59527033d-6
c08   b = t2*a - c + 1.18871496d-4
c08   c = t2*b - a - 1.18244098d-3
c08   a = t2*c - b + 7.87645202d-3
c08   b = t2*a - c - 3.14174373d-2
c08   c = t2*b - a + 6.20464642d-2
c08   a = t2*c - b - 4.83824292d-2
c08   f = t*a - c + 2.64808460d-2
c
c     expansion (0072) evaluated as f(t)  --precision 09e.10
c09   a = -1.969428958d-11
c09   b = t2*a + 6.934937158d-10
c09   c = t2*b - a - 2.010769653d-8
c09   a = t2*c - b + 4.696557359d-7
c09   b = t2*a - c - 8.595270331d-6
c09   c = t2*b - a + 1.188714963d-4
c09   a = t2*c - b - 1.182440977d-3
c09   b = t2*a - c + 7.876452021d-3
c09   c = t2*b - a - 3.141743727d-2
c09   a = t2*c - b + 6.204646424d-2
c09   b = t2*a - c - 4.838242918d-2
c09   f = t*b - a + 2.648084601d-2
c
c     expansion (0072) evaluated as f(t)  --precision 12e.13
c12   a = -9.492371230281d-15
c12   b = t2*a + 4.687952604558d-13
c12   c = t2*b - a - 1.969428958427d-11
c12   a = t2*c - b + 6.934937158185d-10
c12   b = t2*a - c - 2.010769652645d-8
c12   c = t2*b - a + 4.696557358962d-7
c12   a = t2*c - b - 8.595270331212d-6
c12   b = t2*a - c + 1.188714962703d-4
c12   c = t2*b - a - 1.182440976973d-3
c12   a = t2*c - b + 7.876452021482d-3
c12   b = t2*a - c - 3.141743726724d-2
c12   c = t2*b - a + 6.204646424453d-2
c12   a = t2*c - b - 4.838242917764d-2
c12   f = t*a - c + 2.648084601235d-2
c
c     expansion (0072) evaluated as f(t)  --precision 15e.16
c15   a = +1.655433262420340d-16
c15   b = t2*a - 9.492371230281425d-15
c15   c = t2*b - a + 4.687952604557881d-13
c15   a = t2*c - b - 1.969428958427300d-11
c15   b = t2*a - c + 6.934937158184919d-10
c15   c = t2*b - a - 2.010769652644762d-8
c15   a = t2*c - b + 4.696557358962321d-7
c15   b = t2*a - c - 8.595270331212026d-6
c15   c = t2*b - a + 1.188714962702695d-4
c15   a = t2*c - b - 1.182440976973327d-3
c15   b = t2*a - c + 7.876452021481851d-3
c15   c = t2*b - a - 3.141743726723965d-2
c15   a = t2*c - b + 6.204646424452958d-2
c15   b = t2*a - c - 4.838242917763518d-2
c15   f = t*b - a + 2.648084601234867d-2
c
c     expansion (0072) evaluated as f(t)  --precision 17e.18
      a = -2.51308436743000000d-18
      b = t2*a + 1.65543326242034000d-16
      c = t2*b - a - 9.49237123028142500d-15
      a = t2*c - b + 4.68795260455788096d-13
      b = t2*a - c - 1.96942895842729954d-11
      c = t2*b - a + 6.93493715818491929d-10
      a = t2*c - b - 2.01076965264476206d-8
      b = t2*a - c + 4.69655735896232104d-7
      c = t2*b - a - 8.59527033121202608d-6
      a = t2*c - b + 1.18871496270269531d-4
      b = t2*a - c - 1.18244097697332692d-3
      c = t2*b - a + 7.87645202148185146d-3
      a = t2*c - b - 3.14174372672396468d-2
      b = t2*a - c + 6.20464642445295805d-2
      c = t2*b - a - 4.83824291776351778d-2
      f = t*c - b + 2.64808460123486707d-2
c
c     expansion (0072) evaluated as f(t)  --precision 19e.19
c19   a = +3.351591447700000000d-20
c19   b = t2*a - 2.513084367430000000d-18
c19   c = t2*b - a + 1.655433262420340000d-16
c19   a = t2*c - b - 9.492371230281425000d-15
c19   b = t2*a - c + 4.687952604557880960d-13
c19   c = t2*b - a - 1.969428958427299544d-11
c19   a = t2*c - b + 6.934937158184919292d-10
c19   b = t2*a - c - 2.010769652644762059d-8
c19   c = t2*b - a + 4.696557358962321038d-7
c19   a = t2*c - b - 8.595270331212026077d-6
c19   b = t2*a - c + 1.188714962702695306d-4
c19   c = t2*b - a - 1.182440976973326921d-3
c19   a = t2*c - b + 7.876452021481851462d-3
c19   b = t2*a - c - 3.141743726723964685d-2
c19   c = t2*b - a + 6.204646424452958052d-2
c19   a = t2*c - b - 4.838242917763517779d-2
c19   f = t*a - c + 2.648084601234867073d-2
c
c
c      * expansion (0073) *
c
c     expansion (0073) evaluated as g(t)  --precision 08e.09
c08   a = -2.06683376d-9
c08   b = t2*a + 6.35924426d-8
c08   c = t2*b - a - 1.58422527d-6
c08   a = t2*c - b + 3.11007119d-5
c08   b = t2*a - c - 4.64189438d-4
c08   c = t2*b - a + 5.00970025d-3
c08   a = t2*c - b - 3.62166343d-2
c08   b = t2*a - c + 1.53114672d-1
c08   c = t2*b - a - 2.69270808d-1
c08   a = t2*c - b - 9.61843661d-2
c08   b = t2*a - c + 2.07099373d-1
c08   g = t*b - a + 9.79943888d-2
c
c     expansion (0073) evaluated as g(t)  --precision 09e.10
c09   a = +5.556077451d-11
c09   b = t2*a - 2.066833763d-9
c09   c = t2*b - a + 6.359244257d-8
c09   a = t2*c - b - 1.584225274d-6
c09   b = t2*a - c + 3.110071191d-5
c09   c = t2*b - a - 4.641894378d-4
c09   a = t2*c - b + 5.009700254d-3
c09   b = t2*a - c - 3.621663427d-2
c09   c = t2*b - a + 1.531146716d-1
c09   a = t2*c - b - 2.692708077d-1
c09   b = t2*a - c - 9.618436611d-2
c09   c = t2*b - a + 2.070993729d-1
c09   g = t*c - b + 9.799438879d-2
c
c     expansion (0073) evaluated as g(t)  --precision 12e.13
c12   a = -1.256839101481d-12
c12   b = t2*a + 5.556077450696d-11
c12   c = t2*b - a - 2.066833763046d-9
c12   a = t2*c - b + 6.359244256854d-8
c12   b = t2*a - c - 1.584225273936d-6
c12   c = t2*b - a + 3.110071191130d-5
c12   a = t2*c - b - 4.641894377873d-4
c12   b = t2*a - c + 5.009700254116d-3
c12   c = t2*b - a - 3.621663427174d-2
c12   a = t2*c - b + 1.531146716420d-1
c12   b = t2*a - c - 2.692708077407d-1
c12   c = t2*b - a - 9.618436611492d-2
c12   a = t2*c - b + 2.070993728793d-1
c12   g = t*a - c + 9.799438878745d-2
c
c     expansion (0073) evaluated as g(t)  --precision 15e.16
c15   a = -4.048118108879710d-16
c15   b = t2*a + 2.426804532876731d-14
c15   c = t2*b - a - 1.256839101480993d-12
c15   a = t2*c - b + 5.556077450695673d-11
c15   b = t2*a - c - 2.066833763045771d-9
c15   c = t2*b - a + 6.359244256854255d-8
c15   a = t2*c - b - 1.584225273936190d-6
c15   b = t2*a - c + 3.110071191129936d-5
c15   c = t2*b - a - 4.641894377872714d-4
c15   a = t2*c - b + 5.009700254115790d-3
c15   b = t2*a - c - 3.621663427173735d-2
c15   c = t2*b - a + 1.531146716419535d-1
c15   a = t2*c - b - 2.692708077406673d-1
c15   b = t2*a - c - 9.618436611491529d-2
c15   c = t2*b - a + 2.070993728792977d-1
c15   g = t*c - b + 9.799438878745478d-2
c
c     expansion (0073) evaluated as g(t)  --precision 17e.18
      a = +5.89382778069400000d-18
      b = t2*a - 4.04811810887971000d-16
      c = t2*b - a + 2.42680453287673090d-14
      a = t2*c - b - 1.25683910148099294d-12
      b = t2*a - c + 5.55607745069567295d-11
      c = t2*b - a - 2.06683376304577072d-9
      a = t2*c - b + 6.35924425685425485d-8
      b = t2*a - c - 1.58422527393619013d-6
      c = t2*b - a + 3.11007119112993551d-5
      a = t2*c - b - 4.64189437787271433d-4
      b = t2*a - c + 5.00970025411579034d-3
      c = t2*b - a - 3.62166342717373453d-2
      a = t2*c - b + 1.53114671641953510d-1
      b = t2*a - c - 2.69270807740667256d-1
      c = t2*b - a - 9.61843661149152853d-2
      a = t2*c - b + 2.07099372879297732d-1
      g = t*a - c + 9.79943887874547828d-2
c
c     expansion (0073) evaluated as g(t)  --precision 19e.19
c19   a = -7.556663563800000000d-20
c19   b = t2*a + 5.893827780694000000d-18
c19   c = t2*b - a - 4.048118108879710000d-16
c19   a = t2*c - b + 2.426804532876730900d-14
c19   b = t2*a - c - 1.256839101480992943d-12
c19   c = t2*b - a + 5.556077450695672951d-11
c19   a = t2*c - b - 2.066833763045770720d-9
c19   b = t2*a - c + 6.359244256854254845d-8
c19   c = t2*b - a - 1.584225273936190130d-6
c19   a = t2*c - b + 3.110071191129935505d-5
c19   b = t2*a - c - 4.641894377872714332d-4
c19   c = t2*b - a + 5.009700254115790345d-3
c19   a = t2*c - b - 3.621663427173734531d-2
c19   b = t2*a - c + 1.531146716419535095d-1
c19   c = t2*b - a - 2.692708077406672564d-1
c19   a = t2*c - b - 9.618436611491528534d-2
c19   b = t2*a - c + 2.070993728792977317d-1
c19   g = t*b - a + 9.799438878745478281d-2
c
      s17ajf = x*x*f - g
      go to 180
c
c     xmin .le. x .lt. -5.0
  120 y = sqrt(-x)
      z = -2.0d0*x*y/3.0d0
      g = z + pib4
      y = sqrt(y)
      t = -250.0d0/(x*x*x) - 1.0d0
c
c      * expansion (0070) *
c
c     expansion (0070) evaluated as a(t)  --precision 08e.09
c08   a = (((-6.45192889d-9*t+9.32082316d-8)*t-2.54024881d-6)
c08  *    *t+2.17448175d-4)*t + 5.64409672d-1
c
c     expansion (0070) evaluated as a(t)  --precision 09e.10
c09   a = (((-6.451928892d-9*t+9.320823157d-8)*t-2.540248815d-6)
c09  *    *t+2.174481747d-4)*t + 5.644096717d-1
c
c     expansion (0070) evaluated as a(t)  --precision 12e.13
c12   a = ((((((+1.766813459961d-11*t-9.772095810519d-11)
c12  *    *t+6.507683040816d-10)*t-6.305347454780d-9)
c12  *    *t+9.237158176565d-8)*t-2.540303782917d-6)
c12  *    *t+2.174483857483d-4)*t + 5.644096716804d-1
c
c     expansion (0070) evaluated as a(t)  --precision 15e.16
c15   a = ((((((((((+8.751349487774515d-14*t-2.760803551839892d-13)
c15  *    *t+7.267435244126106d-13)*t-3.147114759278340d-12)
c15  *    *t+1.573213403103486d-11)*t-9.065025258767507d-11)
c15  *    *t+6.522955114177011d-10)*t-6.309928411561923d-9)
c15  *    *t+9.237114709598275d-8)*t-2.540302850548992d-6)
c15  *    *t+2.174483857814122d-4)*t + 5.644096716803791d-1
c
c     expansion (0070) evaluated as a(t)  --precision 17e.18
      a = (((((((((((((-4.58484390222233600d-15*t+
     *    1.13969221615738880d-14)*t-1.43160328250060800d-14)
     *    *t+5.04734978526300160d-14)*t-2.07055957015081472d-13)
     *    *t+7.73043520694004480d-13)*t-3.23454581960357018d-12)
     *    *t+1.57043540332660220d-11)*t-9.06023827679991573d-11)
     *    *t+6.52303613917050367d-10)*t-6.30993998756281944d-9)
     *    *t+9.23711460831703303d-8)*t-2.54030284953639173d-6)
     *    *t+2.17448385781448409d-4)*t + 5.64409671680379110d-1
c
c     expansion (0070) evaluated as a(t)  --precision 19e.19
c19   a = ((((((((((((((((+4.214626744401920000d-16*t-
c19  *    8.868874517544960000d-16)*t+1.703870799216640000d-16)
c19  *    *t-1.037294095204352000d-15)*t+7.175537879126016000d-15)
c19  *    *t-2.008080126141030400d-14)*t+5.859679064267264000d-14)
c19  *    *t-2.021780760304317440d-13)*t+7.661540824505664000d-13)
c19  *    *t-3.236832326315124736d-12)*t+1.570734036635450298d-11)
c19  *    *t-9.060180074810894339d-11)*t+6.523029632773869775d-10)
c19  *    *t-6.309940060315305720d-9)*t+9.237114614496961892d-8)
c19  *    *t-2.540302849532927329d-6)*t+2.174483857814467223d-4)*t +
c19  *    5.644096716803791099d-1
c
c
c      * expansion (0071) *
c
c     expansion (0071) evaluated as b(t)  --precision 08e.09
c08   b = ((((+2.87032637d-9*t-2.25880643d-8)*t+2.50422709d-7)
c08  *    *t-4.75219262d-6)*t+2.05252801d-4)*t - 5.46414842d-2
c
c     expansion (0071) evaluated as b(t)  --precision 09e.10
c09   b = (((((-4.752484657d-10*t+2.870326372d-9)*t-2.187519158d-8)
c09  *    *t+2.504227090d-7)*t-4.752459947d-6)*t+2.052528014d-4)*t -
c09  *    5.464148416d-2
c
c     expansion (0071) evaluated as b(t)  --precision 12e.13
c12   b = ((((((((+6.344806101374d-12*t-2.314155830801d-11)
c12  *    *t+8.232616021024d-11)*t-4.289653490994d-10)
c12  *    *t+2.711979777723d-9)*t-2.190411852357d-8)
c12  *    *t+2.505042616094d-7)*t-4.752454161195d-6)
c12  *    *t+2.052527911047d-4)*t - 5.464148416073d-2
c
c     expansion (0071) evaluated as b(t)  --precision 15e.16
c15   b = (((((((((((((-4.041501938593792d-14*t+9.578579903898419d-14)
c15  *    *t-1.007291049308017d-13)*t+3.474709891165809d-13)
c15  *    *t-1.416043972365555d-12)*t+4.922305110988257d-12)
c15  *    *t-1.895608039650331d-11)*t+8.390431312406616d-11)
c15  *    *t-4.328493959112903d-10)*t+2.711255286964945d-9)
c15  *    *t-2.190268817356167d-8)*t+2.505043946308762d-7)
c15  *    *t-4.752454343407942d-6)*t+2.052527910979562d-4)*t -
c15  *    5.464148416073098d-2
c
c     expansion (0071) evaluated as b(t)  --precision 17e.18
      b = ((((((((((((((((+4.19612197958451200d-15*t-
     *    8.50454708509081600d-15)*t+2.31421341122560000d-16)
     *    *t-6.39683104557465600d-15)*t+5.92509321833062400d-14)
     *    *t-1.56008660983891968d-13)*t+4.20106807813331968d-13)
     *    *t-1.36926896339755520d-12)*t+4.86000800286762854d-12)
     *    *t-1.89780061819570625d-11)*t+8.39314701970122041d-11)
     *    *t-4.32843814802265754d-10)*t+2.71124934991469715d-9)
     *    *t-2.19026888712002973d-8)*t+2.50504395196083566d-7)
     *    *t-4.75245434337472120d-6)*t+2.05252791097940732d-4)*t -
     *    5.46414841607309762d-2
c
c     expansion (0071) evaluated as b(t)  --precision 19e.19
c19   b = (((((((((((((((-6.422422696755200000d-16*t+
c19  *    1.157018692878336000d-15)*t+1.050474638213120000d-15)
c19  *    *t-1.299716811587584000d-15)*t-5.605056004653056000d-15)
c19  *    *t+1.122309892346675200d-14)*t-1.660001866664345600d-14)
c19  *    *t+4.722878482761728000d-14)*t-1.432823023452692480d-13)
c19  *    *t+4.279212035945297920d-13)*t-1.377620461968010240d-12)
c19  *    *t+4.856938061667872256d-12)*t-1.897491865462963469d-11)
c19  *    *t+8.393217864498137862d-11)*t-4.328444424636872150d-10)
c19  *    *t+2.711249261358701004d-9)*t-2.190268880806947728d-8
c19   b = (((b*t+2.505043952011151565d-7)*t-4.752454343377146794d-6)
c19  *    *t+2.052527910979406482d-4)*t - 5.464148416073097618d-2
c
      s17ajf = -(sin(g)*b/z+cos(g)*a)*y
      go to 180
c
c     failure exits
  140 ifail = p01abf(ifail,1,srname,0,p01rec)
      s17ajf = 0.0d0
      go to 180
  160 ifail = p01abf(ifail,2,srname,0,p01rec)
      s17ajf = 0.0d0
c
  180 return
c
      end
      double precision function s17ahf(x,ifail)
c     mark 8 release. nag copyright 1979.
c     mark 8a revised. ier-263 (aug 1980)
c     mark 11.5(f77) revised. (sept 1985.)
c     mark 13 revised. use of mark 12 x02 functions (apr 1988).
c
c     airy function bi(x)
c
c     **************************************************************
c
c     to extract the correct code for a particular machine-range,
c     activate the statements contained in comments beginning  cdd ,
c     where  dd  is the approximate number of significant decimal
c     digits represented by the machine
c     delete the illegal dummy statements of the form
c     * expansion (nnnn) *
c
c     also insert appropriate data statements to define constants
c     which depend on the range of numbers represented by the
c     machine, rather than the precision (suitable statements for
c     some machines are contained in comments beginning crd where
c     d is a digit which simply distinguishes a group of machines).
c     delete the illegal dummy data statements with values written
c     *value*
c
c     **************************************************************
c
c     .. parameters ..
      character*6                      srname
      parameter                        (srname='s17ahf')
c     .. scalar arguments ..
      double precision                 x
      integer                          ifail
c     .. local scalars ..
      double precision                 a, b, c, c1, f, g, pib4, rt3, t,
     *                                 t2, xmax, xmin, xrelpr, y, z
c     .. local arrays ..
      character*1                      p01rec(1)
c     .. external functions ..
      integer                          p01abf
      external                         p01abf
c     .. intrinsic functions ..
      intrinsic                        abs, cos, exp, sin, sqrt, int
c     .. data statements ..
c     precision dependent constants
c08   data xmin,xrelpr,c1,pib4
c08  */-1.3d4,9.5d-7,3.55028054d-1,7.85398163d-1/
c08  *,rt3/1.73205081d0/
c09   data xmin,xrelpr,c1,pib4
c09  */-2.1d+5,1.8d-8,3.550280539d-1,7.853981634d-1/
c09  *,rt3/1.732050808d0/
c12   data xmin,xrelpr,c1,pib4
c12  */-3.4d+7,7.3d-12,3.550280538878d-1,7.853981633974d-1/
c12  *,rt3/1.732050807569d0/
c15   data xmin,xrelpr,c1,pib4
c15  */-3.9d+9,7.1d-15,3.550280538878172d-1,7.853981633974483d-1/
c15  *,rt3/1.732050807568877d0/
      data xmin,xrelpr,c1,pib4
     */-8.5d+4,2.2d-16,3.55028053887817239d-1,7.85398163397448310d-1/
     *,rt3/1.73205080756887729d0/
c19   data xmin,xrelpr,c1,pib4
c19  */-9.1d+11,1.7d-18,3.550280538878172393d-1,7.853981633974483096d-1/
c19  *,rt3/1.732050807568877294d0/
c
c     c1*rt3=bi(0.0)
c     xrelpr=x02ajf()
c     xmin=-(1.5*xlim)**(2/3)
c     where xlim=amin1(1.0/xrelpr,xscmax-pib4)
c     and xscmax is the maximum value of x for which sin(x) and cos(x)
c     can be computed without execution error.
c
c     **** warning - values of xmin given above may need adjusting ****
c
c     range dependent constants
      data xmax/1.041d+2/
c     for icl 1900
cr3   data xmax/41.25d0/
c     for ibm 360/370 and similar machines
cr1   data xmax/40.875d0/
c     for cdc 7600/cyber
cr4   data xmax/107.25d0/
c     for dec10, honeywell, univac 1100 (s.p.)
cr2   data xmax/25.875d0/
c     for burroughs
cr6   data xmax/38.25d0/
c     for univac 1100 (d.p.)
cr5   data xmax/104.125d0/
c
c     xmax.lt.(ln(xovflo)*1.5)**(2/3)
c
c     .. executable statements ..
      if (abs(x).gt.xrelpr) go to 20
      s17ahf = c1*rt3
      ifail = 0
      go to 180
   20 if (x.le.0.0d0) go to 100
c
c     positive arguments
      if (x.gt.xmax) go to 140
      ifail = 0
      if (int(x/4.5d0)-1) 40, 60, 80
c
c     0.0 .lt. x .lt. 4.5
   40 t = 4.0d0*x/9.0d0 - 1.0d0
c
c      * expansion (0065) *
c
c     expansion (0065) evaluated as y(t)  --precision 08e.09
c08   y = (((((((((((((((+1.38422088d-5*t-1.52122620d-4)
c08  *    *t+4.61824746d-4)*t-5.21151306d-4)*t-3.40879453d-4)
c08  *    *t+3.08759498d-3)*t-8.34204497d-3)*t+1.62813311d-2)
c08  *    *t-1.91001235d-2)*t+1.65727861d-2)*t+1.76135351d-2)
c08  *    *t-3.36674339d-2)*t+1.23830929d-1)*t-6.48340693d-2)
c08  *    *t+2.20310563d-1)*t-1.03883050d-2)*t + 2.06857611d-1
c
c     expansion (0065) evaluated as y(t)  --precision 09e.10
c09   y = (((((((((((((((-1.033575677d-5*t+1.451587143d-5)
c09  *    *t+6.035311430d-5)*t-2.138150731d-4)*t+3.746167984d-4)
c09  *    *t-4.131895119d-4)*t-2.527025277d-4)*t+2.987344743d-3)
c09  *    *t-8.394006367d-3)*t+1.633434810d-2)*t-1.908213689d-2)
c09  *    *t+1.655688106d-2)*t+1.761003766d-2)*t-3.366490356d-2)
c09  *    *t+1.238312699d-1)*t-6.483425000d-2)*t+2.203105505d-1
c09   y = (y*t-1.038830121d-2)*t + 2.068576113d-1
c
c     expansion (0065) evaluated as y(t)  --precision 12e.13
c12   y = (((((((((((((((+9.040592667406d-8*t-2.095971965087d-9)
c12  *    *t-1.344279306650d-6)*t+3.915603328185d-6)
c12  *    *t-4.919595800597d-6)*t-4.055734743052d-6)
c12  *    *t+4.976831410242d-5)*t-1.766902005343d-4)
c12  *    *t+3.865256563256d-4)*t-4.537848117034d-4)
c12  *    *t-2.609369961592d-4)*t+3.013727776098d-3)
c12  *    *t-8.390451250227d-3)*t+1.632398436209d-2)
c12  *    *t-1.908307613157d-2)*t+1.655927252019d-2)
c12  *    *t+1.761018065568d-2
c12   y = (((((y*t-3.366520248042d-2)
c12  *    *t+1.238312588680d-1)*t-6.483423301575d-2)
c12  *    *t+2.203105508832d-1)*t-1.038830149597d-2)*t +
c12  *    2.068576113425d-1
c
c     expansion (0065) evaluated as y(t)  --precision 15e.16
c15   y = (((((((((((((((-1.320349742126036d-9*t+
c15  *    1.145246307919488d-8)*t-3.478298873551377d-8)
c15  *    *t+2.169114819889383d-8)*t+2.226627709289804d-7)
c15  *    *t-1.163903013153024d-6)*t+3.333076006228739d-6)
c15  *    *t-5.191591798727760d-6)*t-3.210934103150892d-6)
c15  *    *t+5.002841027563169d-5)*t-1.774539659437665d-4)
c15  *    *t+3.863613850583029d-4)*t-4.533362130995336d-4)
c15  *    *t-2.608677892827359d-4)*t+3.013555414990117d-3)
c15  *    *t-8.390470442049698d-3)*t+1.632402683723510d-2
c15   y = ((((((((y*t-1.908307275801169d-2)*t+1.655926613091419d-2)
c15  *    *t+1.761018030582423d-2)*t-3.366520194678243d-2)
c15  *    *t+1.238312588867136d-1)*t-6.483423303631481d-2)
c15  *    *t+2.203105508828114d-1)*t-1.038830149573641d-2)*t +
c15  *    2.068576113424603d-1
c
c     expansion (0065) evaluated as y(t)  --precision 17e.18
      y = (((((((((((((((-8.01144609907912212d-11*t+
     *    2.67566208080291037d-10)*t+1.74416971406971503d-10)
     *    *t-3.12642164666800066d-9)*t+1.22114569059570056d-8)
     *    *t-2.93647730218878800d-8)*t+1.76951994785830839d-8)
     *    *t+2.13143266932123830d-7)*t-1.15569603602267288d-6)
     *    *t+3.34394065752949896d-6)*t-5.20143492253259528d-6)
     *    *t-3.21937890029830155d-6)*t+5.00360593064643409d-5)
     *    *t-1.77449408434194908d-4)*t+3.86357389967150628d-4)
     *    *t-4.53337922165622921d-4)*t-2.60866378774883161d-4
      y = (((((((((((y*t+3.01355585350049504d-3)
     *    *t-8.39047077309199055d-3)
     *    *t+1.63240267627966090d-2)*t-1.90830727084112485d-2)
     *    *t+1.65592661387959142d-2)*t+1.76101803014184860d-2)
     *    *t-3.36652019472526494d-2)*t+1.23831258886916327d-1)
     *    *t-6.48342330363017516d-2)*t+2.20310550882807725d-1)
     *    *t-1.03883014957365224d-2)*t + 2.06857611342460346d-1
c
c     expansion (0065) evaluated as y(t)  --precision 19e.19
c19   y = (((((((((((((((+1.255554369395359744d-11*t-
c19  *    8.011446099079122125d-11)*t+1.765385162991274557d-10)
c19  *    *t+1.744169714069715026d-10)*t-2.830581648379219018d-9)
c19  *    *t+1.221145690595700559d-8)*t-2.993369609552015235d-8)
c19  *    *t+1.769519947858308393d-8)*t+2.138629546202686544d-7)
c19  *    *t-1.155696036022672882d-6)*t+3.343310930802372237d-6)
c19  *    *t-5.201434922532595283d-6)*t-3.218988743521712164d-6)
c19  *    *t+5.003605930646434093d-5)*t-1.774495807112131420d-4)
c19  *    *t+3.863573899671506281d-4)*t-4.533378683290547224d-4
c19   y = ((((((((((((y*t-2.608663787748831609d-4)
c19  *    *t+3.013555841835905265d-3)
c19  *    *t-8.390470773091990546d-3)*t+1.632402676448490484d-2)
c19  *    *t-1.908307270841124853d-2)*t+1.655926613864243280d-2)
c19  *    *t+1.761018030141848597d-2)*t-3.366520194724474962d-2)
c19  *    *t+1.238312588869163266d-1)*t-6.483423303630194146d-2)
c19  *    *t+2.203105508828077245d-1)*t-1.038830149573652100d-2)*t +
c19  *    2.068576113424603456d-1
c
      s17ahf = exp(1.375d0*x)*y
      go to 180
c
c     4.5 .le. x .lt. 9.0
   60 t = 4.0d0*x/9.0d0 - 3.0d0
c
c      * expansion (0067) *
c
c     expansion (0067) evaluated as y(t)  --precision 08e.09
c08   y = ((((((((((((-3.94306600d-8*t+1.37016129d-7)*t-1.31138456d-7)
c08  *    *t+7.07251183d-7)*t-8.61095295d-7)*t+6.39892457d-6)
c08  *    *t-2.72586213d-6)*t+4.54427146d-5)*t+2.20271441d-6)
c08  *    *t+2.58826432d-4)*t+7.31025529d-5)*t+1.01013788d-3)
c08  *    *t+2.64794412d-4)*t + 1.97499786d-3
c
c     expansion (0067) evaluated as y(t)  --precision 09e.10
c09   y = ((((((((((((((-5.386179412d-9*t+1.672929400d-8)
c09  *    *t-1.923248721d-8)*t+7.846359964d-8)*t-1.614357153d-7)
c09  *    *t+7.877609106d-7)*t-8.379515554d-7)*t+6.344031576d-6)
c09  *    *t-2.735330021d-6)*t+4.546192716d-5)*t+2.204702664d-6)
c09  *    *t+2.588232302d-4)*t+7.310236883d-5)*t+1.010138077d-3)
c09  *    *t+2.647944165d-4)*t + 1.974997855d-3
c
c     expansion (0067) evaluated as y(t)  --precision 12e.13
c12   y = (((((((((((((((-7.049229269330d-11*t+2.271937575031d-10)
c12  *    *t-3.325700777720d-10)*t+1.000906686735d-9)
c12  *    *t-3.219370202876d-9)*t+1.055312695027d-8)
c12  *    *t-2.346387870820d-8)*t+8.967666376313d-8)
c12  *    *t-1.573025238598d-7)*t+7.777750594092d-7)
c12  *    *t-8.402021219122d-7)*t+6.348852470315d-6)
c12  *    *t-2.734641902315d-6)*t+4.546067626479d-5)
c12  *    *t+2.204591719392d-6)*t+2.588233887008d-4)
c12  *    *t+7.310237683111d-5
c12   y = ((y*t+1.010138069054d-3)
c12  *    *t+2.647944163322d-4)*t + 1.974997855537d-3
c
c     expansion (0067) evaluated as y(t)  --precision 15e.16
c15   y = (((((((((((((((+1.139517939270025d-12*t-
c15  *    5.381756604435661d-12)*t+1.455769613368348d-11)
c15  *    *t-4.223807052000815d-11)*t+1.379534865865128d-10)
c15  *    *t-3.961420776619460d-10)*t+1.202195613858243d-9)
c15  *    *t-3.139316573384860d-9)*t+1.030946153516484d-8)
c15  *    *t-2.352568481920878d-8)*t+8.985281869283160d-8)
c15  *    *t-1.572723933807296d-7)*t+7.776966935191504d-7)
c15  *    *t-8.402113284475065d-7)*t+6.348873625283007d-6)
c15  *    *t-2.734640211318802d-6)*t+4.546067299124476d-5
c15   y = (((((y*t+2.204591548666301d-6)*t+2.588233889576562d-4)
c15  *    *t+7.310237683901337d-5)*t+1.010138069045962d-3)
c15  *    *t+2.647944163321180d-4)*t + 1.974997855537091d-3
c
c     expansion (0067) evaluated as y(t)  --precision 17e.18
      y = (((((((((((((((+3.79210935744593920d-14*t-
     *    4.16346635040194560d-14)*t-3.63110681886588928d-13)
     *    *t+1.38932592029414195d-12)*t-4.00489068810888806d-12)
     *    *t+1.39019501834951721d-11)*t-4.50877182237241508d-11)
     *    *t+1.38942309844733264d-10)*t-3.92503498108710093d-10)
     *    *t+1.20125005161756928d-9)*t-3.14234550677825531d-9)
     *    *t+1.03100587323694771d-8)*t-2.35240060783126760d-8)
     *    *t+8.98525670958611253d-8)*t-1.57273011181242048d-7)
     *    *t+7.77696763289738864d-7)*t-8.40211181188135235d-7
      y = ((((((((y*t+6.34887361301864569d-6)*t-2.73464023289055762d-6)
     *    *t+4.54606729925166230d-5)*t+2.20459155042947089d-6)
     *    *t+2.58823388957588056d-4)*t+7.31023768389466446d-5)
     *    *t+1.01013806904596356d-3)*t+2.64794416332118755d-4)*t +
     *    1.97499785553709145d-3
c
c     expansion (0067) evaluated as y(t)  --precision 19e.19
c19   y = (((((((((((((((+6.859397846269952000d-15*t-
c19  *    1.816576667942912000d-14)*t-8.379841887862784000d-15)
c19  *    *t+7.644281991226982400d-14)*t-2.242078754996224000d-13)
c19  *    *t+1.049853155472310272d-12)*t-4.248935202108211200d-12)
c19  *    *t+1.447019807243606426d-11)*t-4.480918915883361894d-11)
c19  *    *t+1.383288604191720735d-10)*t-3.927199911546022789d-10)
c19  *    *t+1.201696993341906715d-9)*t-3.142228669261424607d-9)
c19  *    *t+1.030983526150730833d-8)*t-2.352404989238148751d-8)
c19  *    *t+8.985264354641923570d-8)*t-1.572729999394743922d-7
c19   y = ((((((((((y*t+7.776967457698192968d-7)
c19  *    *t-8.402111830964599918d-7)
c19  *    *t+6.348873615595104450d-6)*t-2.734640232688499708d-6)
c19  *    *t+4.546067299229118289d-5)*t+2.204591550417416303d-6)
c19  *    *t+2.588233889575983028d-4)*t+7.310237683894697947d-5)
c19  *    *t+1.010138069045963372d-3)*t+2.647944163321187524d-4)*t +
c19  *    1.974997855537091446d-3
c
      s17ahf = exp(+2.5d0*x)*y
      go to 180
c
c     9.0 .le. x .le. xmax
   80 y = sqrt(x)
      z = 2.0d0*x*y/3.0d0
      g = sqrt(y)
      t = 36.0d0/z - 1.0d0
c
c      * expansion (0069) *
c
c     expansion (0069) evaluated as y(t)  --precision 08e.09
c08   y = (((+2.64115416d-8*t+5.51662916d-7)*t+1.76718969d-5)
c08  *    *t+1.12212056d-3)*t + 5.65294558d-1
c
c     expansion (0069) evaluated as y(t)  --precision 09e.10
c09   y = ((((+1.743077447d-9*t+2.641154160d-8)*t+5.494840697d-7)
c09  *    *t+1.767189685d-5)*t+1.122121101d-3)*t + 5.652945576d-1
c
c     expansion (0069) evaluated as y(t)  --precision 12e.13
c12   y = ((((((+1.609168268982d-11*t+1.495249656136d-10)
c12  *    *t+1.714917002326d-9)*t+2.618725414768d-8)
c12  *    *t+5.494981498753d-7)*t+1.767198096169d-5)
c12  *    *t+1.122121099347d-3)*t + 5.652945575585d-1
c
c     expansion (0069) evaluated as y(t)  --precision 15e.16
c15   y = (((((((((+6.612905123362765d-14*t+3.407787039096069d-13)
c15  *    *t+1.960583107281416d-12)*t+1.532493060602128d-11)
c15  *    *t+1.454178114424422d-10)*t+1.715492066388512d-9)
c15  *    *t+2.618985986653073d-8)*t+5.494979901352857d-7)
c15  *    *t+1.767198043666919d-5)*t+1.122121099358909d-3)*t +
c15  *    5.652945575585221d-1
c
c     expansion (0069) evaluated as y(t)  --precision 17e.18
      y = (((((((((((+4.50165999254528000d-15*t+1.56232018374502400d-14)
     *    *t+5.26240712559918080d-14)*t+2.97814898856618752d-13)
     *    *t+1.97577620975625677d-12)*t+1.53678944110742706d-11)
     *    *t+1.45409933537455235d-10)*t+1.71547326972380087d-9)
     *    *t+2.61898617129147064d-8)*t+5.49497993491833009d-7)
     *    *t+1.76719804365109334d-5)*t+1.12212109935874117d-3)*t +
     *    5.65294557558522063d-1
c
c     expansion (0069) evaluated as y(t)  --precision 19e.19
c19   y = ((((((((((((((+1.816434091458560000d-16*t+
c19  *    5.600911698001920000d-16)*t+8.511031988060160000d-16)
c19  *    *t+2.541340898244608000d-15)*t+1.166508156881100800d-14)
c19  *    *t+5.531951001065523200d-14)*t+3.032592303893009920d-13)
c19  *    *t+1.973938410605349888d-12)*t+1.536447880779559629d-11)
c19  *    *t+1.454105767671580526d-10)*t+1.715474292017186649d-9)
c19  *    *t+2.618986160570975596d-8)*t+5.494979933618733560d-7)
c19  *    *t+1.767198043651763370d-5)*t+1.122121099358745869d-3)*t +
c19  *    5.652945575585220631d-1
c
c     modified to get scaled bi for x.ge.9              29.10.2005 
c      s17ahf = exp(+z)*y/g
      s17ahf = y/g
      go to 180
c
c
c     negative arguments
  100 if (x.lt.xmin) go to 160
      ifail = 0
      if (x.lt.-5.0d0) go to 120
c
c     -5.0 .le. x .lt. 0.0
      t = x/5.0d0
      t = -t*t*t
      t = 2.0d0*t - 1.0d0
      t2 = 2.0d0*t
c
c      * expansion (0062) *
c
c     expansion (0062) evaluated as f(t)  --precision 08e.09
c08   a = -6.56273599d-10
c08   b = t2*a + 2.09250023d-8
c08   c = t2*b - a - 5.42780373d-7
c08   a = t2*c - b + 1.11655763d-5
c08   b = t2*a - c - 1.76193215d-4
c08   c = t2*b - a + 2.03792657d-3
c08   a = t2*c - b - 1.61616261d-2
c08   b = t2*a - c + 7.87369695d-2
c08   c = t2*b - a - 1.88090320d-1
c08   a = t2*c - b + 8.83593329d-2
c08   b = t2*a - c + 9.46330440d-2
c08   f = t*b - a + 7.60869994d-2
c
c     expansion (0062) evaluated as f(t)  --precision 09e.10
c09   a = -6.562735990d-10
c09   b = t2*a + 2.092500233d-8
c09   c = t2*b - a - 5.427803729d-7
c09   a = t2*c - b + 1.116557635d-5
c09   b = t2*a - c - 1.761932151d-4
c09   c = t2*b - a + 2.037926574d-3
c09   a = t2*c - b - 1.616162609d-2
c09   b = t2*a - c + 7.873696951d-2
c09   c = t2*b - a - 1.880903202d-1
c09   a = t2*c - b + 8.835933287d-2
c09   b = t2*a - c + 9.463304396d-2
c09   f = t*b - a + 7.608699941d-2
c
c     expansion (0062) evaluated as f(t)  --precision 12e.13
c12   a = -3.755045810333d-13
c12   b = t2*a + 1.708749758077d-11
c12   c = t2*b - a - 6.562735990133d-10
c12   a = t2*c - b + 2.092500233007d-8
c12   b = t2*a - c - 5.427803728940d-7
c12   c = t2*b - a + 1.116557634725d-5
c12   a = t2*c - b - 1.761932150809d-4
c12   b = t2*a - c + 2.037926574031d-3
c12   c = t2*b - a - 1.616162609419d-2
c12   a = t2*c - b + 7.873696950590d-2
c12   b = t2*a - c - 1.880903202189d-1
c12   c = t2*b - a + 8.835933286664d-2
c12   a = t2*c - b + 9.463304395659d-2
c12   f = t*a - c + 7.608699941417d-2
c
c     expansion (0062) evaluated as f(t)  --precision 15e.16
c15   a = -1.149373682830250d-16
c15   b = t2*a + 7.060906358566960d-15
c15   c = t2*b - a - 3.755045810332901d-13
c15   a = t2*c - b + 1.708749758076624d-11
c15   b = t2*a - c - 6.562735990132918d-10
c15   c = t2*b - a + 2.092500233006599d-8
c15   a = t2*c - b - 5.427803728939972d-7
c15   b = t2*a - c + 1.116557634724685d-5
c15   c = t2*b - a - 1.761932150809126d-4
c15   a = t2*c - b + 2.037926574031449d-3
c15   b = t2*a - c - 1.616162609419080d-2
c15   c = t2*b - a + 7.873696950590187d-2
c15   a = t2*c - b - 1.880903202189157d-1
c15   b = t2*a - c + 8.835933286664339d-2
c15   c = t2*b - a + 9.463304395658582d-2
c15   f = t*c - b + 7.608699941417266d-2
c
c     expansion (0062) evaluated as f(t)  --precision 17e.18
      a = +1.63586492025000000d-18
      b = t2*a - 1.14937368283025000d-16
      c = t2*b - a + 7.06090635856696000d-15
      a = t2*c - b - 3.75504581033290114d-13
      b = t2*a - c + 1.70874975807662448d-11
      c = t2*b - a - 6.56273599013291800d-10
      a = t2*c - b + 2.09250023300659871d-8
      b = t2*a - c - 5.42780372893997236d-7
      c = t2*b - a + 1.11655763472468469d-5
      a = t2*c - b - 1.76193215080912647d-4
      b = t2*a - c + 2.03792657403144947d-3
      c = t2*b - a - 1.61616260941907957d-2
      a = t2*c - b + 7.87369695059018748d-2
      b = t2*a - c - 1.88090320218915726d-1
      c = t2*b - a + 8.83593328666433903d-2
      a = t2*c - b + 9.46330439565858235d-2
      f = t*a - c + 7.60869994141726643d-2
c
c     expansion (0062) evaluated as f(t)  --precision 19e.19
c19   a = -2.053415725200000000d-20
c19   b = t2*a + 1.635864920250000000d-18
c19   c = t2*b - a - 1.149373682830250000d-16
c19   a = t2*c - b + 7.060906358566960000d-15
c19   b = t2*a - c - 3.755045810332901140d-13
c19   c = t2*b - a + 1.708749758076624480d-11
c19   a = t2*c - b - 6.562735990132918003d-10
c19   b = t2*a - c + 2.092500233006598708d-8
c19   c = t2*b - a - 5.427803728939972360d-7
c19   a = t2*c - b + 1.116557634724684695d-5
c19   b = t2*a - c - 1.761932150809126465d-4
c19   c = t2*b - a + 2.037926574031449469d-3
c19   a = t2*c - b - 1.616162609419079569d-2
c19   b = t2*a - c + 7.873696950590187481d-2
c19   c = t2*b - a - 1.880903202189157259d-1
c19   a = t2*c - b + 8.835933286664339033d-2
c19   b = t2*a - c + 9.463304395658582345d-2
c19   f = t*b - a + 7.608699941417266430d-2
c
c
c      * expansion (0063) *
c
c     expansion (0063) evaluated as g(t)  --precision 08e.09
c08   a = +2.18414557d-9
c08   b = t2*a - 6.11127835d-8
c08   c = t2*b - a + 1.37095478d-6
c08   a = t2*c - b - 2.39464595d-5
c08   b = t2*a - c + 3.13306257d-4
c08   c = t2*b - a - 2.90953381d-3
c08   a = t2*c - b + 1.76972907d-2
c08   b = t2*a - c - 6.17055677d-2
c08   c = t2*b - a + 9.52472833d-2
c08   a = t2*c - b - 4.32381694d-2
c08   g = t*a - c + 3.76828718d-2
c
c     expansion (0063) evaluated as g(t)  --precision 09e.10
c09   a = -6.403863754d-11
c09   b = t2*a + 2.184145572d-9
c09   c = t2*b - a - 6.111278350d-8
c09   a = t2*c - b + 1.370954782d-6
c09   b = t2*a - c - 2.394645953d-5
c09   c = t2*b - a + 3.133062570d-4
c09   a = t2*c - b - 2.909533806d-3
c09   b = t2*a - c + 1.769729071d-2
c09   c = t2*b - a - 6.170556772d-2
c09   a = t2*c - b + 9.524728334d-2
c09   b = t2*a - c - 4.323816942d-2
c09   g = t*b - a + 3.768287177d-2
c
c     expansion (0063) evaluated as g(t)  --precision 12e.13
c12   a = -3.262530732733d-14
c12   b = t2*a + 1.569118250997d-12
c12   c = t2*b - a - 6.403863753934d-11
c12   a = t2*c - b + 2.184145572027d-9
c12   b = t2*a - c - 6.111278350334d-8
c12   c = t2*b - a + 1.370954782253d-6
c12   a = t2*c - b - 2.394645953138d-5
c12   b = t2*a - c + 3.133062569753d-4
c12   c = t2*b - a - 2.909533805902d-3
c12   a = t2*c - b + 1.769729070741d-2
c12   b = t2*a - c - 6.170556771641d-2
c12   c = t2*b - a + 9.524728333672d-2
c12   a = t2*c - b - 4.323816942235d-2
c12   g = t*a - c + 3.768287177015d-2
c
c     expansion (0063) evaluated as g(t)  --precision 15e.16
c15   a = +5.830523483771460d-16
c15   b = t2*a - 3.262530732733058d-14
c15   c = t2*b - a + 1.569118250996656d-12
c15   a = t2*c - b - 6.403863753934148d-11
c15   b = t2*a - c + 2.184145572027331d-9
c15   c = t2*b - a - 6.111278350334019d-8
c15   a = t2*c - b + 1.370954782252896d-6
c15   b = t2*a - c - 2.394645953138124d-5
c15   c = t2*b - a + 3.133062569752993d-4
c15   a = t2*c - b - 2.909533805902076d-3
c15   b = t2*a - c + 1.769729070740923d-2
c15   c = t2*b - a - 6.170556771641222d-2
c15   a = t2*c - b + 9.524728333672139d-2
c15   b = t2*a - c - 4.323816942234849d-2
c15   g = t*b - a + 3.768287177015441d-2
c
c     expansion (0063) evaluated as g(t)  --precision 17e.18
      a = +1.23340698467000000d-19
      b = t2*a - 9.05440546731800000d-18
      c = t2*b - a + 5.83052348377146000d-16
      a = t2*c - b - 3.26253073273305810d-14
      b = t2*a - c + 1.56911825099665634d-12
      c = t2*b - a - 6.40386375393414830d-11
      a = t2*c - b + 2.18414557202733054d-9
      b = t2*a - c - 6.11127835033401880d-8
      c = t2*b - a + 1.37095478225289560d-6
      a = t2*c - b - 2.39464595313812449d-5
      b = t2*a - c + 3.13306256975299299d-4
      c = t2*b - a - 2.90953380590207648d-3
      a = t2*c - b + 1.76972907074092250d-2
      b = t2*a - c - 6.17055677164122241d-2
      c = t2*b - a + 9.52472833367213949d-2
      a = t2*c - b - 4.32381694223484894d-2
      g = t*a - c + 3.76828717701544063d-2
c
c     expansion (0063) evaluated as g(t)  --precision 19e.19
c19   a = -1.485996171000000000d-21
c19   b = t2*a + 1.233406984670000000d-19
c19   c = t2*b - a - 9.054405467318000000d-18
c19   a = t2*c - b + 5.830523483771460000d-16
c19   b = t2*a - c - 3.262530732733058100d-14
c19   c = t2*b - a + 1.569118250996656338d-12
c19   a = t2*c - b - 6.403863753934148297d-11
c19   b = t2*a - c + 2.184145572027330536d-9
c19   c = t2*b - a - 6.111278350334018800d-8
c19   a = t2*c - b + 1.370954782252895603d-6
c19   b = t2*a - c - 2.394645953138124487d-5
c19   c = t2*b - a + 3.133062569752992987d-4
c19   a = t2*c - b - 2.909533805902076483d-3
c19   b = t2*a - c + 1.769729070740922505d-2
c19   c = t2*b - a - 6.170556771641222415d-2
c19   a = t2*c - b + 9.524728333672139490d-2
c19   b = t2*a - c - 4.323816942234848936d-2
c19   g = t*b - a + 3.768287177015440633d-2
c
      s17ahf = (g*x+f)*rt3
      go to 180
c
c     xmin .le. x .lt. -5.0
  120 y = sqrt(-x)
      z = -2.0d0*x*y/3.0d0
      g = z + pib4
      y = sqrt(y)
      t = -250.0d0/(x*x*x) - 1.0d0
c
c      * expansion (0060) *
c
c     expansion (0060) evaluated as a(t)  --precision 08e.09
c08   a = (((+6.15912654d-9*t-8.78096033d-8)*t+2.32929819d-6)
c08  *    *t-1.83605134d-4)*t + 5.64003555d-1
c
c     expansion (0060) evaluated as a(t)  --precision 09e.10
c09   a = (((+6.159126542d-9*t-8.780960327d-8)*t+2.329298189d-6)
c09  *    *t-1.836051343d-4)*t + 5.640035551d-1
c
c     expansion (0060) evaluated as a(t)  --precision 12e.13
c12   a = ((((((-1.715016966209d-11*t+9.450718282139d-11)
c12  *    *t-6.258520368216d-10)*t+6.017365767755d-9)
c12  *    *t-8.700477862436d-8)*t+2.329351348941d-6)
c12  *    *t-1.836053373353d-4)*t + 5.640035550994d-1
c
c     expansion (0060) evaluated as a(t)  --precision 15e.16
c15   a = ((((((((((-8.563884716731904d-14*t+2.697790028676367d-13)
c15  *    *t-7.081756671882112d-13)*t+3.060690564443398d-12)
c15  *    *t-1.526239087378051d-11)*t+8.762704824694287d-11)
c15  *    *t-6.273414667970969d-10)*t+6.021823925499018d-9)
c15  *    *t-8.700435467216258d-8)*t+2.329350441501844d-6)
c15  *    *t-1.836053373676030d-4)*t + 5.640035550994134d-1
c
c     expansion (0060) evaluated as a(t)  --precision 17e.18
      a = (((((((((((((+4.50071772808806400d-15*t-
     *    1.11777933477806080d-14)*t+1.39959545848483840d-14)
     *    *t-4.93110187870320640d-14)*t+2.02193307034590720d-13)
     *    *t-7.53585452663569920d-13)*t+3.14632365928501299d-12)
     *    *t-1.52351450024952975d-11)*t+8.75801572233507014d-11)
     *    *t-6.27349413509555121d-10)*t+6.02183526555303242d-9)
     *    *t-8.70043536788235270d-8)*t+2.32935044050984079d-6)
     *    *t-1.83605337367638430d-4)*t + 5.64003555099413391d-1
c
c     expansion (0060) evaluated as a(t)  --precision 19e.19
c19   a = ((((((((((((((((-4.145996909772800000d-16*t+
c19  *    8.719038745477120000d-16)*t-1.650739531939840000d-16)
c19  *    *t+1.013102229897216000d-15)*t-7.034668649996288000d-15)
c19  *    *t+1.966332976940851200d-14)*t-5.728775452036198400d-14)
c19  *    *t+1.973978357245783040d-13)*t-7.468191081605683200d-13)
c19  *    *t+3.148571536461581312d-12)*t-1.523807824458362650d-11)
c19  *    *t+8.757958503643302944d-11)*t-6.273487744018275593d-10)
c19  *    *t+6.021835337076397133d-9)*t-8.700435373952972456d-8)
c19  *    *t+2.329350440506434910d-6)*t-1.836053373676367731d-4)*t +
c19  *    5.640035550994133905d-1
c
c
c      * expansion (0061) *
c
c     expansion (0061) evaluated as b(t)  --precision 08e.09
c08   b = ((((-2.77049286d-9*t+2.16663908d-8)*t-2.37768347d-7)
c08  *    *t+4.43089269d-6)*t-1.83241381d-4)*t + 3.89918977d-2
c
c     expansion (0061) evaluated as b(t)  --precision 09e.10
c09   b = (((((+4.606963501d-10*t-2.770492865d-9)*t+2.097534624d-8)
c09  *    *t-2.377683473d-7)*t+4.431151831d-6)*t-1.832413815d-4)*t +
c09  *    3.899189768d-2
c
c     expansion (0061) evaluated as b(t)  --precision 12e.13
c12   b = (((((((((+1.905559246812d-12*t-6.196625335478d-12)
c12  *    *t+1.779405775025d-11)*t-7.999675578189d-11)
c12  *    *t+4.197488492041d-10)*t-2.616556135221d-9)
c12  *    *t+2.100205496934d-8)*t-2.378476393860d-7)
c12  *    *t+4.431146377531d-6)*t-1.832413714432d-4)*t +
c12  *    3.899189768110d-2
c
c     expansion (0061) evaluated as b(t)  --precision 15e.16
c15   b = (((((((((((((+3.969783702995763d-14*t-9.400837697076019d-14)
c15  *    *t+9.852025583444992d-14)*t-3.397009779051110d-13)
c15  *    *t+1.384217031200711d-12)*t-4.804156808506625d-12)
c15  *    *t+1.846523578585801d-11)*t-8.154198792143967d-11)
c15  *    *t+4.193788799892521d-10)*t-2.615846679119911d-9)
c15  *    *t+2.100214476773484d-8)*t-2.378477696549908d-7)
c15  *    *t+4.431146369657840d-6)*t-1.832413714365943d-4)*t +
c15  *    3.899189768110265d-2
c
c     expansion (0061) evaluated as b(t)  --precision 17e.18
      b = ((((((((((((((((-4.12972759036723200d-15*t+
     *    8.36512465551360000d-15)*t-2.05945081774080000d-16)
     *    *t+6.23733840790323200d-15)*t-5.81333983959859200d-14)
     *    *t+1.52893566095288320d-13)*t-4.11064788026333184d-13)
     *    *t+1.33820884559538637d-12)*t-4.74293914921785574d-12)
     *    *t+1.84868021228605050d-11)*t-8.15686769476673166d-11)
     *    *t+4.19373390376196942d-10)*t-2.61584084406303574d-9)
     *    *t+2.10021454539364698d-8)*t-2.37847770210509358d-7)
     *    *t+4.43114636962516363d-6)*t-1.83241371436579068d-4)*t +
     *    3.89918976811026487d-2
c
c     expansion (0061) evaluated as b(t)  --precision 19e.19
c19   b = (((((((((((((((-3.633742725775360000d-16*t+
c19  *    6.329882231439360000d-16)*t+7.678637957447680000d-16)
c19  *    *t-1.037278429052928000d-15)*t-3.007793292574720000d-15)
c19  *    *t+5.516142436417536000d-15)*t-5.629338562412544000d-15)
c19  *    *t+1.627713953735475200d-14)*t-5.046275910502400000d-14)
c19  *    *t+1.403671321108049920d-13)*t-4.167288366073487360d-13)
c19  *    *t+1.346430254448406016d-12)*t-4.740536381002437888d-12)
c19  *    *t+1.848376245973714726d-11)*t-8.156926070839937062d-11)
c19  *    *t+4.193740083371970509d-10)*t-2.615840768348341801d-9
c19   b = ((((b*t+2.100214539177924140d-8)*t-2.378477702149326189d-7)
c19  *    *t+4.431146369627551869d-6)*t-1.832413714365789927d-4)*t +
c19  *    3.899189768110264871d-2
c
      s17ahf = (sin(g)*b/z+cos(g)*a)/y
      go to 180
c
c
c     failure exits
  140 ifail = p01abf(ifail,1,srname,0,p01rec)
      s17ahf = 0.0d0
      go to 180
  160 ifail = p01abf(ifail,2,srname,0,p01rec)
      s17ahf = 0.0d0
c
c
  180 return
c
      end
      double precision function s17akf(x,ifail)
c     mark 8 release. nag copyright 1979.
c     mark 8a revised. ier-263 (aug 1980)
c     mark 11.5(f77) revised. (sept 1985.)
c     mark 13 revised. use of mark 12 x02 functions (apr 1988).
c
c     airy function bip(x)
c
c     **************************************************************
c
c     to extract the correct code for a particular machine-range,
c     activate the statements contained in comments beginning  cdd ,
c     where  dd  is the approximate number of significant decimal
c     digits represented by the machine
c     delete the illegal dummy statements of the form
c     * expansion (nnnn) *
c
c     also insert appropriate data statements to define constants
c     which depend on the range of numbers represented by the
c     machine, rather than the precision (suitable statements for
c     some machines are contained in comments beginning crd where
c     d is a digit which simply distinguishes a group of machines).
c     delete the illegal dummy data statements with values written
c     *value*
c
c     **************************************************************
c
c     .. parameters ..
      character*6                      srname
      parameter                        (srname='s17akf')
c     .. scalar arguments ..
      double precision                 x
      integer                          ifail
c     .. local scalars ..
      double precision                 a, b, c, c2, f, g, pib4, rt3, t,
     *                                 t2, xmax, xmin, xrelpr, y, z
c     .. local arrays ..
      character*1                      p01rec(1)
c     .. external functions ..
      integer                          p01abf
      external                         p01abf
c     .. intrinsic functions ..
      intrinsic                        abs, cos, exp, sin, sqrt, int
c     .. data statements ..
c     precision dependent constants
c08   data xmin,xrelpr,c2,pib4
c08  */-3.8d3,9.5d-7,2.58819403d-1,7.85398163d-1/
c08  *,rt3/1.73205081d0/
c09   data xmin,xrelpr,c2,pib4
c09  */-4.1d4,1.8d-8,2.588194037d-1,7.853981634d-1/
c09  *,rt3/1.732050808d0/
c12   data xmin,xrelpr,c2,pib4
c12  */-3.2d6,7.3d-12,2.588194037928d-1,7.853981633974d-1/
c12  *,rt3/1.732050807569d0/
c15   data xmin,xrelpr,c2,pib4
c15  */-1.6d8,7.1d-15,2.588194037928067d-1,7.853981633974483d-1/
c15  *,rt3/1.732050807568877d0/
      data xmin,xrelpr,c2,pib4
     */-8.5d+4,2.2d-16,2.58819403792806798d-1,7.85398163397448310d-1/
     *,rt3/1.73205080756887729d0/
c19   data xmin,xrelpr,c2,pib4
c19  */-1.9d10,1.7d-18,2.5881940379280679840d-1,7.853981633974483096d-1/
c19  *,rt3/1.732050807568877294d0/
c
c     c2*rt3=bip(0.0)
c     xrelpr=x02ajf()
c     xmin=-amin1((sqrt(pi)/xrelpr)**(4/7),(1.5*(xscmax-pib4))**(2/3))
c     where xscmax is the maximum value of x for which sin(x) and cos(x)
c     can be computed without execution error.
c
c     **** warning - values of xmin given above may need adjusting ****
c
c     range dependent constants
      data xmax/1.041d+2/
c     for icl 1900
cr3   data xmax/41.25d0/
c     for ibm 360/370 and similar machines
cr1   data xmax/40.875d0/
c     for cdc 7600/cyber
cr4   data xmax/107.25d0/
c     for dec10, honeywell, univac 1100 (s.p.)
cr2   data xmax/25.875d0/
c     for burroughs
cr6   data xmax/38.25d0/
c     for univac 1100 (d.p.)
cr5   data xmax/104.125d0/
c
c     xmax.lt.(ln(xovflo)*1.5)**(2/3)
c
c     .. executable statements ..
      if (abs(x).gt.xrelpr) go to 20
      s17akf = c2*rt3
      ifail = 0
      go to 180
   20 if (x.le.0.0d0) go to 100
c
c     positive arguments
      if (x.gt.xmax) go to 140
      ifail = 0
      if (int(x/4.5d0)-1) 40, 60, 80
c
c     0.0 .lt. x .lt. 4.5
   40 t = 4.0d0*x/9.0d0 - 1.0d0
c
c      * expansion (0075) *
c
c     expansion (0075) evaluated as y(t)  --precision 08e.09
c08   y = ((((((((((((((((-8.28572526d-5*t+1.23066317d-4)
c08  *    *t+3.68914283d-4)*t-1.23399722d-3)*t+1.95692777d-3)
c08  *    *t-2.41225482d-3)*t+8.93650437d-4)*t+6.70834839d-3)
c08  *    *t-2.10783559d-2)*t+4.13856269d-2)*t-5.03260250d-2)
c08  *    *t+5.95357471d-2)*t-1.64219313d-2)*t+5.02546768d-2)
c08  *    *t+5.75602138d-2)*t+1.33219991d-1)*t+7.76356352d-2)*t +
c08  *    2.11213324d-1
c
c     expansion (0075) evaluated as y(t)  --precision 09e.10
c09   y = (((((((((((((((+3.276916916d-5*t-8.285725262d-5)
c09  *    *t-2.439494460d-5)*t+3.689142831d-4)*t-9.575073563d-4)
c09  *    *t+1.956927775d-3)*t-2.691816794d-3)*t+8.936504367d-4)
c09  *    *t+6.873090263d-3)*t-2.107835595d-2)*t+4.132860086d-2)
c09  *    *t-5.032602496d-2)*t+5.954683553d-2)*t-1.642193128d-2)
c09  *    *t+5.025359674d-2)*t+5.756021380d-2)*t+1.332200318d-1
c09   y = (y*t+7.763563521d-2)*t + 2.112133242d-1
c
c     expansion (0075) evaluated as y(t)  --precision 12e.13
c12   y = (((((((((((((((+1.462826670400d-7*t-4.733324560052d-7)
c12  *    *t+3.027846740173d-8)*t+2.743786258616d-6)
c12  *    *t-1.025063025979d-5)*t+2.588397520058d-5)
c12  *    *t-3.861207944425d-5)*t-1.460447138501d-5)
c12  *    *t+2.847367889942d-4)*t-9.661781694997d-4)
c12  *    *t+2.046195577249d-3)*t-2.686866977787d-3)
c12  *    *t+8.368339972805d-4)*t+6.871268623867d-3)
c12  *    *t-2.105637302376d-2)*t+4.132902063389d-2)
c12  *    *t-5.033103959362d-2
c12   y = ((((((y*t+5.954677881484d-2)
c12  *    *t-1.642131011197d-2)*t+5.025360068851d-2)
c12  *    *t+5.756017876837d-2)*t+1.332200316502d-1)
c12  *    *t+7.763563578992d-2)*t + 2.112133241761d-1
c
c     expansion (0075) evaluated as y(t)  --precision 15e.16
c15   y = (((((((((((((((+3.335890533389005d-9*t-
c15  *    2.630361495863952d-9)*t-4.550094953862685d-8)
c15  *    *t+1.627224263891501d-7)*t-2.680870352328801d-7)
c15  *    *t-1.493087080843219d-8)*t+2.264307270990385d-6)
c15  *    *t-1.017870631263835d-5)*t+2.656229611064418d-5)
c15  *    *t-3.868528774760518d-5)*t-1.522746743186869d-5)
c15  *    *t+2.847865706404667d-4)*t-9.657954976062851d-4)
c15  *    *t+2.046172651490744d-3)*t-2.687024946251110d-3)
c15  *    *t+8.368410933484976d-4)*t+6.871311754346828d-3
c15   y = (((((((((y*t-2.105637445862890d-2)*t+4.132901314476819d-2)
c15  *    *t-5.033103941426394d-2)*t+5.954677958382690d-2)
c15  *    *t-1.642131012452582d-2)*t+5.025360064765094d-2)
c15  *    *t+5.756017876878077d-2)*t+1.332200316510768d-1)
c15  *    *t+7.763563578991496d-2)*t + 2.112133241760492d-1
c
c     expansion (0075) evaluated as y(t)  --precision 17e.18
      y = (((((((((((((((+2.69330665471830131d-10*t-
     *    1.25313111217921013d-9)*t+1.45057587508619405d-9)
     *    *t+5.82827351134571594d-9)*t-3.96093412314305685d-8)
     *    *t+1.37346521367521144d-7)*t-2.78927594518121271d-7)
     *    *t+2.96531845420687661d-8)*t+2.27734981888044076d-6)
     *    *t-1.02295902888535994d-5)*t+2.65515218319523965d-5)
     *    *t-3.86457370206378782d-5)*t-1.52212232476268640d-5)
     *    *t+2.84765225803690646d-4)*t-9.65798046252914453d-4)
     *    *t+2.04618065580453522d-3)*t-2.68702422147972510d-3
      y = (((((((((((y*t+8.36839039610090712d-4)
     *    *t+6.87131161447866570d-3)
     *    *t-2.10563741100004648d-2)*t+4.13290131622517073d-2)
     *    *t-5.03310394511775398d-2)*t+5.95467795825179773d-2)
     *    *t-1.64213101223235839d-2)*t+5.02536006477020710d-2)
     *    *t+5.75601787687195966d-2)*t+1.33220031651076020d-1)
     *    *t+7.76356357899154668d-2)*t + 2.11213324176049168d-1
c
c     expansion (0075) evaluated as y(t)  --precision 19e.19
c19   y = (((((((((((((((+6.288654595770023936d-12*t-
c19  *    1.304959260868109926d-11)*t-6.504736602488360141d-11)
c19  *    *t+3.672026100369383752d-10)*t-9.643017326883703357d-10)
c19  *    *t+1.120258062178953724d-9)*t+5.087572387539183469d-9)
c19  *    *t-3.894666660677098144d-8)*t+1.385805674137464980d-7)
c19  *    *t-2.798069127700734154d-7)*t+2.823661410021856929d-8)
c19  *    *t+2.278162308945244541d-6)*t-1.022843508010417829d-5)
c19  *    *t+2.655098581420131064d-5)*t-3.864641544537493977d-5)
c19  *    *t-1.522096855596252819d-5)*t+2.847655130144604639d-4
c19   y = ((((((((((((((y*t-9.657981330796182040d-4)
c19  *    *t+2.046180569053732101d-3)
c19  *    *t-2.687024200577000126d-3)*t+8.368390578856538968d-4)
c19  *    *t+6.871311611029716079d-3)*t-2.105637411258398055d-2)
c19  *    *t+4.132901316262300571d-2)*t-5.033103945094734383d-2)
c19  *    *t+5.954677958249391171d-2)*t-1.642131012233522889d-2)
c19  *    *t+5.025360064770288774d-2)*t+5.756017876871987233d-2)
c19  *    *t+1.332200316510760090d-1)*t+7.763563578991546483d-2)*t +
c19  *    2.112133241760491679d-1
c
      s17akf = exp(1.5d0*x)*y
      go to 180
c
c     4.5 .le. x .lt. 9.0
   60 t = 4.0d0*x/9.0d0 - 3.0d0
c
c      * expansion (0077) *
c
c     expansion (0077) evaluated as y(t)  --precision 08e.09
c08   y = (((((((((((+5.68360215d-8*t-1.30852583d-7)*t+5.27020799d-7)
c08  *    *t-7.82169531d-7)*t+5.14268654d-6)*t-4.80077475d-6)
c08  *    *t+4.02384129d-5)*t-1.74504684d-5)*t+2.45332609d-4)
c08  *    *t-2.22924702d-5)*t+1.02535990d-3)*t+5.94033585d-5)*t +
c08  *    2.17420628d-3
c
c     expansion (0077) evaluated as y(t)  --precision 09e.10
c09   y = (((((((((((((+2.644119016d-9*t-9.361485818d-9)
c09  *    *t+4.758160492d-8)*t-1.004277543d-7)*t+5.397456220d-7)
c09  *    *t-8.202005673d-7)*t+5.134010523d-6)*t-4.777956132d-6)
c09  *    *t+4.024144954d-5)*t-1.745712381d-5)*t+2.453321033d-4)
c09  *    *t-2.229163829d-5)*t+1.025359935d-3)*t+5.940332877d-5)*t +
c09  *    2.174206275d-3
c
c     expansion (0077) evaluated as y(t)  --precision 12e.13
c12   y = (((((((((((((((-4.587483847463d-11*t+1.206316319677d-10)
c12  *    *t+4.680709088585d-11)*t-4.708442516275d-10)
c12  *    *t+2.895568794899d-9)*t-8.621188746098d-9)
c12  *    *t+4.693538169664d-8)*t-1.010255154895d-7)
c12  *    *t+5.403929566208d-7)*t-8.199397611097d-7)
c12  *    *t+5.133678810770d-6)*t-4.778014761570d-6)
c12  *    *t+4.024153877188d-5)*t-1.745711822248d-5)
c12  *    *t+2.453320916709d-4)*t-2.229163836555d-5)
c12  *    *t+1.025359935497d-3
c12   y = (y*t+5.940332876684d-5)*t + 2.174206275393d-3
c
c     expansion (0077) evaluated as y(t)  --precision 15e.16
c15   y = (((((((((((((((+1.057514534266208d-12*t-
c15  *    1.022310153837347d-12)*t-7.507152008987017d-12)
c15  *    *t+1.900057920037559d-11)*t-2.360694451816694d-11)
c15  *    *t+4.379670153503323d-11)*t+1.030255470769488d-11)
c15  *    *t-3.261196046082132d-10)*t+2.932153697179152d-9)
c15  *    *t-8.774589414952803d-9)*t+4.691208574230846d-8)
c15  *    *t-1.009277129011836d-7)*t+5.404024108441763d-7)
c15  *    *t-8.199776838811173d-7)*t+5.133676430683508d-6)
c15  *    *t-4.778006092525108d-6)*t+4.024153912047036d-5
c15   y = (((((y*t-1.745711929839133d-5)*t+2.453320916447502d-4)
c15  *    *t-2.229163830475863d-5)*t+1.025359935497389d-3)
c15  *    *t+5.940332876582690d-5)*t + 2.174206275393456d-3
c
c     expansion (0077) evaluated as y(t)  --precision 17e.18
      y = (((((((((((((((-1.12976379481423872d-13*t+
     *    2.84163275199873024d-13)*t+9.21367859618119680d-14)
     *    *t-6.47465116933029888d-13)*t+5.66210442158931968d-13)
     *    *t-3.03158042458901709d-12)*t+1.32640217809876419d-11)
     *    *t-3.03558223041639219d-11)*t+5.32290407073565901d-11)
     *    *t+1.67561690905544950d-11)*t-3.35234276365918044d-10)
     *    *t+2.92807773020050397d-9)*t-8.76900994127464369d-9)
     *    *t+4.69138029321003869d-8)*t-1.00929917942876779d-7)
     *    *t+5.40401934648687824d-7)*t-8.19977129258456927d-7
      y = ((((((((y*t+5.13367651438974580d-6)*t-4.77800617725922708d-6)
     *    *t+4.02415391117897098d-5)*t-1.74571192912274417d-5)
     *    *t+2.45332091645215217d-4)*t-2.22916383050374016d-5)
     *    *t+1.02535993549737948d-3)*t+5.94033287658300975d-5)*t +
     *    2.17420627539345627d-3
c
c     expansion (0077) evaluated as y(t)  --precision 19e.19
c19   y = (((((((((((((((-1.229315605790720000d-14*t+
c19  *    3.961216457034956800d-14)*t-2.999757609055027200d-14)
c19  *    *t+2.668420549260083200d-14)*t-1.567996242108088320d-13)
c19  *    *t+9.278720847537766400d-14)*t+1.003577885031661568d-12)
c19  *    *t-4.270698447555264512d-12)*t+1.276485241683941786d-11)
c19  *    *t-2.901813807482535936d-11)*t+5.361703144039907328d-11)
c19  *    *t+1.578157058060782797d-11)*t-3.354436681900997018d-10)
c19  *    *t+2.928565029455477301d-9)*t-8.768931419340575568d-9)
c19  *    *t+4.691363622446052758d-8)*t-1.009299380899519673d-7
c19   y = ((((((((((y*t+5.404019728525219581d-7)
c19  *    *t-8.199771258384287313d-7)
c19  *    *t+5.133676508771534900d-6)*t-4.778006177621347713d-6)
c19  *    *t+4.024153911228130324d-5)*t-1.745711929120583790d-5)
c19  *    *t+2.453320916451928717d-4)*t-2.229163830503800166d-5)
c19  *    *t+1.025359935497379880d-3)*t+5.940332876583010243d-5)*t +
c19  *    2.174206275393456269d-3
c
      s17akf = exp(+2.625d0*x)*y
      go to 180
c
c     9.0 .le. x .le. xmax
   80 y = sqrt(x)
      z = 2.0d0*x*y/3.0d0
      g = sqrt(y)
      t = 36.0d0/z - 1.0d0
c
c      * expansion (0079) *
c
c     expansion (0079) evaluated as y(t)  --precision 08e.09
c08   y = (((-2.85581677d-8*t-6.13432414d-7)*t-2.07841269d-5)
c08  *    *t-1.56349960d-3)*t + 5.62646283d-1
c
c     expansion (0079) evaluated as y(t)  --precision 09e.10
c09   y = ((((-1.853245534d-9*t-2.855816770d-8)*t-6.111158575d-7)
c09  *    *t-2.078412692d-5)*t-1.563500178d-3)*t + 5.626462831d-1
c
c     expansion (0079) evaluated as y(t)  --precision 12e.13
c12   y = ((((((-1.677876974814d-11*t-1.571874192360d-10)
c12  *    *t-1.823882687437d-9)*t-2.832238657114d-8)
c12  *    *t-6.111305389100d-7)*t-2.078421534063d-5)
c12  *    *t-1.563500176626d-3)*t + 5.626462830949d-1
c
c     expansion (0079) evaluated as y(t)  --precision 15e.16
c15   y = (((((((((-6.790099944496282d-14*t-3.513708536480950d-13)
c15  *    *t-2.033169165455482d-12)*t-1.598818532742826d-11)
c15  *    *t-1.529301093441363d-10)*t-1.824475625752515d-9)
c15  *    *t-2.832508717556440d-8)*t-6.111303742049295d-7)
c15  *    *t-2.078421479652928d-5)*t-1.563500176638754d-3)*t +
c15  *    5.626462830948430d-1
c
c     expansion (0079) evaluated as y(t)  --precision 17e.18
      y = (((((((((((-4.59170437029478400d-15*t-1.59840960512122880d-14)
     *    *t-5.41258863340784640d-14)*t-3.07414589507261184d-13)
     *    *t-2.04866616770522650d-12)*t-1.60321415915690897d-11)
     *    *t-1.52922073861488292d-10)*t-1.82445639488695332d-9)
     *    *t-2.83250890588806503d-8)*t-6.11130377639012647d-7)
     *    *t-2.07842147963678572d-5)*t-1.56350017663858255d-3)*t +
     *    5.62646283094843014d-1
c
c     expansion (0079) evaluated as y(t)  --precision 19e.19
c19   y = ((((((((((((((-1.849640681635840000d-16*t-
c19  *    5.695785064857600000d-16)*t-8.659394156380160000d-16)
c19  *    *t-2.598179597594624000d-15)*t-1.195596625306521600d-14)
c19  *    *t-5.686698289654118400d-14)*t-3.129555128788298240d-13)
c19  *    *t-2.046797238230820096d-12)*t-1.602866530920898304d-11)
c19  *    *t-1.529227279868043343d-10)*t-1.824457435355100693d-9)
c19  *    *t-2.832508894985976426d-8)*t-6.111303775067414234d-7)
c19  *    *t-2.078421479637467103d-5)*t-1.563500176638587334d-3)*t +
c19  *    5.626462830948430143d-1
c
c     modified to get scaled bip for x.ge.9            29.10.2005 
c      s17akf = exp(+z)*y*g
      s17akf = y*g
      go to 180
c
c     negative arguments
  100 if (x.lt.xmin) go to 160
      ifail = 0
      if (x.lt.-5.0d0) go to 120
c
c     -5.0 .le. x .lt. 0.0
      t = x/5.0d0
      t = -t*t*t
      t = 2.0d0*t - 1.0d0
      t2 = 2.0d0*t
c
c      * expansion (0072) *
c
c     expansion (0072) evaluated as f(t)  --precision 08e.09
c08   a = +6.93493716d-10
c08   b = t2*a - 2.01076965d-8
c08   c = t2*b - a + 4.69655736d-7
c08   a = t2*c - b - 8.59527033d-6
c08   b = t2*a - c + 1.18871496d-4
c08   c = t2*b - a - 1.18244098d-3
c08   a = t2*c - b + 7.87645202d-3
c08   b = t2*a - c - 3.14174373d-2
c08   c = t2*b - a + 6.20464642d-2
c08   a = t2*c - b - 4.83824292d-2
c08   f = t*a - c + 2.64808460d-2
c
c     expansion (0072) evaluated as f(t)  --precision 09e.10
c09   a = -1.969428958d-11
c09   b = t2*a + 6.934937158d-10
c09   c = t2*b - a - 2.010769653d-8
c09   a = t2*c - b + 4.696557359d-7
c09   b = t2*a - c - 8.595270331d-6
c09   c = t2*b - a + 1.188714963d-4
c09   a = t2*c - b - 1.182440977d-3
c09   b = t2*a - c + 7.876452021d-3
c09   c = t2*b - a - 3.141743727d-2
c09   a = t2*c - b + 6.204646424d-2
c09   b = t2*a - c - 4.838242918d-2
c09   f = t*b - a + 2.648084601d-2
c
c     expansion (0072) evaluated as f(t)  --precision 12e.13
c12   a = -9.492371230281d-15
c12   b = t2*a + 4.687952604558d-13
c12   c = t2*b - a - 1.969428958427d-11
c12   a = t2*c - b + 6.934937158185d-10
c12   b = t2*a - c - 2.010769652645d-8
c12   c = t2*b - a + 4.696557358962d-7
c12   a = t2*c - b - 8.595270331212d-6
c12   b = t2*a - c + 1.188714962703d-4
c12   c = t2*b - a - 1.182440976973d-3
c12   a = t2*c - b + 7.876452021482d-3
c12   b = t2*a - c - 3.141743726724d-2
c12   c = t2*b - a + 6.204646424453d-2
c12   a = t2*c - b - 4.838242917764d-2
c12   f = t*a - c + 2.648084601235d-2
c
c     expansion (0072) evaluated as f(t)  --precision 15e.16
c15   a = +1.655433262420340d-16
c15   b = t2*a - 9.492371230281425d-15
c15   c = t2*b - a + 4.687952604557881d-13
c15   a = t2*c - b - 1.969428958427300d-11
c15   b = t2*a - c + 6.934937158184919d-10
c15   c = t2*b - a - 2.010769652644762d-8
c15   a = t2*c - b + 4.696557358962321d-7
c15   b = t2*a - c - 8.595270331212026d-6
c15   c = t2*b - a + 1.188714962702695d-4
c15   a = t2*c - b - 1.182440976973327d-3
c15   b = t2*a - c + 7.876452021481851d-3
c15   c = t2*b - a - 3.141743726723965d-2
c15   a = t2*c - b + 6.204646424452958d-2
c15   b = t2*a - c - 4.838242917763518d-2
c15   f = t*b - a + 2.648084601234867d-2
c
c     expansion (0072) evaluated as f(t)  --precision 17e.18
      a = -2.51308436743000000d-18
      b = t2*a + 1.65543326242034000d-16
      c = t2*b - a - 9.49237123028142500d-15
      a = t2*c - b + 4.68795260455788096d-13
      b = t2*a - c - 1.96942895842729954d-11
      c = t2*b - a + 6.93493715818491929d-10
      a = t2*c - b - 2.01076965264476206d-8
      b = t2*a - c + 4.69655735896232104d-7
      c = t2*b - a - 8.59527033121202608d-6
      a = t2*c - b + 1.18871496270269531d-4
      b = t2*a - c - 1.18244097697332692d-3
      c = t2*b - a + 7.87645202148185146d-3
      a = t2*c - b - 3.14174372672396468d-2
      b = t2*a - c + 6.20464642445295805d-2
      c = t2*b - a - 4.83824291776351778d-2
      f = t*c - b + 2.64808460123486707d-2
c
c     expansion (0072) evaluated as f(t)  --precision 19e.19
c19   a = +3.351591447700000000d-20
c19   b = t2*a - 2.513084367430000000d-18
c19   c = t2*b - a + 1.655433262420340000d-16
c19   a = t2*c - b - 9.492371230281425000d-15
c19   b = t2*a - c + 4.687952604557880960d-13
c19   c = t2*b - a - 1.969428958427299544d-11
c19   a = t2*c - b + 6.934937158184919292d-10
c19   b = t2*a - c - 2.010769652644762059d-8
c19   c = t2*b - a + 4.696557358962321038d-7
c19   a = t2*c - b - 8.595270331212026077d-6
c19   b = t2*a - c + 1.188714962702695306d-4
c19   c = t2*b - a - 1.182440976973326921d-3
c19   a = t2*c - b + 7.876452021481851462d-3
c19   b = t2*a - c - 3.141743726723964685d-2
c19   c = t2*b - a + 6.204646424452958052d-2
c19   a = t2*c - b - 4.838242917763517779d-2
c19   f = t*a - c + 2.648084601234867073d-2
c
c
c      * expansion (0073) *
c
c     expansion (0073) evaluated as g(t)  --precision 08e.09
c08   a = -2.06683376d-9
c08   b = t2*a + 6.35924426d-8
c08   c = t2*b - a - 1.58422527d-6
c08   a = t2*c - b + 3.11007119d-5
c08   b = t2*a - c - 4.64189438d-4
c08   c = t2*b - a + 5.00970025d-3
c08   a = t2*c - b - 3.62166343d-2
c08   b = t2*a - c + 1.53114672d-1
c08   c = t2*b - a - 2.69270808d-1
c08   a = t2*c - b - 9.61843661d-2
c08   b = t2*a - c + 2.07099373d-1
c08   g = t*b - a + 9.79943888d-2
c
c     expansion (0073) evaluated as g(t)  --precision 09e.10
c09   a = +5.556077451d-11
c09   b = t2*a - 2.066833763d-9
c09   c = t2*b - a + 6.359244257d-8
c09   a = t2*c - b - 1.584225274d-6
c09   b = t2*a - c + 3.110071191d-5
c09   c = t2*b - a - 4.641894378d-4
c09   a = t2*c - b + 5.009700254d-3
c09   b = t2*a - c - 3.621663427d-2
c09   c = t2*b - a + 1.531146716d-1
c09   a = t2*c - b - 2.692708077d-1
c09   b = t2*a - c - 9.618436611d-2
c09   c = t2*b - a + 2.070993729d-1
c09   g = t*c - b + 9.799438879d-2
c
c     expansion (0073) evaluated as g(t)  --precision 12e.13
c12   a = -1.256839101481d-12
c12   b = t2*a + 5.556077450696d-11
c12   c = t2*b - a - 2.066833763046d-9
c12   a = t2*c - b + 6.359244256854d-8
c12   b = t2*a - c - 1.584225273936d-6
c12   c = t2*b - a + 3.110071191130d-5
c12   a = t2*c - b - 4.641894377873d-4
c12   b = t2*a - c + 5.009700254116d-3
c12   c = t2*b - a - 3.621663427174d-2
c12   a = t2*c - b + 1.531146716420d-1
c12   b = t2*a - c - 2.692708077407d-1
c12   c = t2*b - a - 9.618436611492d-2
c12   a = t2*c - b + 2.070993728793d-1
c12   g = t*a - c + 9.799438878745d-2
c
c     expansion (0073) evaluated as g(t)  --precision 15e.16
c15   a = -4.048118108879710d-16
c15   b = t2*a + 2.426804532876731d-14
c15   c = t2*b - a - 1.256839101480993d-12
c15   a = t2*c - b + 5.556077450695673d-11
c15   b = t2*a - c - 2.066833763045771d-9
c15   c = t2*b - a + 6.359244256854255d-8
c15   a = t2*c - b - 1.584225273936190d-6
c15   b = t2*a - c + 3.110071191129936d-5
c15   c = t2*b - a - 4.641894377872714d-4
c15   a = t2*c - b + 5.009700254115790d-3
c15   b = t2*a - c - 3.621663427173735d-2
c15   c = t2*b - a + 1.531146716419535d-1
c15   a = t2*c - b - 2.692708077406673d-1
c15   b = t2*a - c - 9.618436611491529d-2
c15   c = t2*b - a + 2.070993728792977d-1
c15   g = t*c - b + 9.799438878745478d-2
c
c     expansion (0073) evaluated as g(t)  --precision 17e.18
      a = +5.89382778069400000d-18
      b = t2*a - 4.04811810887971000d-16
      c = t2*b - a + 2.42680453287673090d-14
      a = t2*c - b - 1.25683910148099294d-12
      b = t2*a - c + 5.55607745069567295d-11
      c = t2*b - a - 2.06683376304577072d-9
      a = t2*c - b + 6.35924425685425485d-8
      b = t2*a - c - 1.58422527393619013d-6
      c = t2*b - a + 3.11007119112993551d-5
      a = t2*c - b - 4.64189437787271433d-4
      b = t2*a - c + 5.00970025411579034d-3
      c = t2*b - a - 3.62166342717373453d-2
      a = t2*c - b + 1.53114671641953510d-1
      b = t2*a - c - 2.69270807740667256d-1
      c = t2*b - a - 9.61843661149152853d-2
      a = t2*c - b + 2.07099372879297732d-1
      g = t*a - c + 9.79943887874547828d-2
c
c     expansion (0073) evaluated as g(t)  --precision 19e.19
c19   a = -7.556663563800000000d-20
c19   b = t2*a + 5.893827780694000000d-18
c19   c = t2*b - a - 4.048118108879710000d-16
c19   a = t2*c - b + 2.426804532876730900d-14
c19   b = t2*a - c - 1.256839101480992943d-12
c19   c = t2*b - a + 5.556077450695672951d-11
c19   a = t2*c - b - 2.066833763045770720d-9
c19   b = t2*a - c + 6.359244256854254845d-8
c19   c = t2*b - a - 1.584225273936190130d-6
c19   a = t2*c - b + 3.110071191129935505d-5
c19   b = t2*a - c - 4.641894377872714332d-4
c19   c = t2*b - a + 5.009700254115790345d-3
c19   a = t2*c - b - 3.621663427173734531d-2
c19   b = t2*a - c + 1.531146716419535095d-1
c19   c = t2*b - a - 2.692708077406672564d-1
c19   a = t2*c - b - 9.618436611491528534d-2
c19   b = t2*a - c + 2.070993728792977317d-1
c19   g = t*b - a + 9.799438878745478281d-2
c
      s17akf = (x*x*f+g)*rt3
      go to 180
c
c     xmin .le. x .lt. -5.0
  120 y = sqrt(-x)
      z = -2.0d0*x*y/3.0d0
      g = z + pib4
      y = sqrt(y)
      t = -250.0d0/(x*x*x) - 1.0d0
c
c      * expansion (0070) *
c
c     expansion (0070) evaluated as a(t)  --precision 08e.09
c08   a = (((-6.45192889d-9*t+9.32082316d-8)*t-2.54024881d-6)
c08  *    *t+2.17448175d-4)*t + 5.64409672d-1
c
c     expansion (0070) evaluated as a(t)  --precision 09e.10
c09   a = (((-6.451928892d-9*t+9.320823157d-8)*t-2.540248815d-6)
c09  *    *t+2.174481747d-4)*t + 5.644096717d-1
c
c     expansion (0070) evaluated as a(t)  --precision 12e.13
c12   a = ((((((+1.766813459961d-11*t-9.772095810519d-11)
c12  *    *t+6.507683040816d-10)*t-6.305347454780d-9)
c12  *    *t+9.237158176565d-8)*t-2.540303782917d-6)
c12  *    *t+2.174483857483d-4)*t + 5.644096716804d-1
c
c     expansion (0070) evaluated as a(t)  --precision 15e.16
c15   a = ((((((((((+8.751349487774515d-14*t-2.760803551839892d-13)
c15  *    *t+7.267435244126106d-13)*t-3.147114759278340d-12)
c15  *    *t+1.573213403103486d-11)*t-9.065025258767507d-11)
c15  *    *t+6.522955114177011d-10)*t-6.309928411561923d-9)
c15  *    *t+9.237114709598275d-8)*t-2.540302850548992d-6)
c15  *    *t+2.174483857814122d-4)*t + 5.644096716803791d-1
c
c     expansion (0070) evaluated as a(t)  --precision 17e.18
      a = (((((((((((((-4.58484390222233600d-15*t+
     *    1.13969221615738880d-14)*t-1.43160328250060800d-14)
     *    *t+5.04734978526300160d-14)*t-2.07055957015081472d-13)
     *    *t+7.73043520694004480d-13)*t-3.23454581960357018d-12)
     *    *t+1.57043540332660220d-11)*t-9.06023827679991573d-11)
     *    *t+6.52303613917050367d-10)*t-6.30993998756281944d-9)
     *    *t+9.23711460831703303d-8)*t-2.54030284953639173d-6)
     *    *t+2.17448385781448409d-4)*t + 5.64409671680379110d-1
c
c     expansion (0070) evaluated as a(t)  --precision 19e.19
c19   a = ((((((((((((((((+4.214626744401920000d-16*t-
c19  *    8.868874517544960000d-16)*t+1.703870799216640000d-16)
c19  *    *t-1.037294095204352000d-15)*t+7.175537879126016000d-15)
c19  *    *t-2.008080126141030400d-14)*t+5.859679064267264000d-14)
c19  *    *t-2.021780760304317440d-13)*t+7.661540824505664000d-13)
c19  *    *t-3.236832326315124736d-12)*t+1.570734036635450298d-11)
c19  *    *t-9.060180074810894339d-11)*t+6.523029632773869775d-10)
c19  *    *t-6.309940060315305720d-9)*t+9.237114614496961892d-8)
c19  *    *t-2.540302849532927329d-6)*t+2.174483857814467223d-4)*t +
c19  *    5.644096716803791099d-1
c
c
c      * expansion (0071) *
c
c     expansion (0071) evaluated as b(t)  --precision 08e.09
c08   b = ((((+2.87032637d-9*t-2.25880643d-8)*t+2.50422709d-7)
c08  *    *t-4.75219262d-6)*t+2.05252801d-4)*t - 5.46414842d-2
c
c     expansion (0071) evaluated as b(t)  --precision 09e.10
c09   b = (((((-4.752484657d-10*t+2.870326372d-9)*t-2.187519158d-8)
c09  *    *t+2.504227090d-7)*t-4.752459947d-6)*t+2.052528014d-4)*t -
c09  *    5.464148416d-2
c
c     expansion (0071) evaluated as b(t)  --precision 12e.13
c12   b = ((((((((+6.344806101374d-12*t-2.314155830801d-11)
c12  *    *t+8.232616021024d-11)*t-4.289653490994d-10)
c12  *    *t+2.711979777723d-9)*t-2.190411852357d-8)
c12  *    *t+2.505042616094d-7)*t-4.752454161195d-6)
c12  *    *t+2.052527911047d-4)*t - 5.464148416073d-2
c
c     expansion (0071) evaluated as b(t)  --precision 15e.16
c15   b = (((((((((((((-4.041501938593792d-14*t+9.578579903898419d-14)
c15  *    *t-1.007291049308017d-13)*t+3.474709891165809d-13)
c15  *    *t-1.416043972365555d-12)*t+4.922305110988257d-12)
c15  *    *t-1.895608039650331d-11)*t+8.390431312406616d-11)
c15  *    *t-4.328493959112903d-10)*t+2.711255286964945d-9)
c15  *    *t-2.190268817356167d-8)*t+2.505043946308762d-7)
c15  *    *t-4.752454343407942d-6)*t+2.052527910979562d-4)*t -
c15  *    5.464148416073098d-2
c
c     expansion (0071) evaluated as b(t)  --precision 17e.18
      b = ((((((((((((((((+4.19612197958451200d-15*t-
     *    8.50454708509081600d-15)*t+2.31421341122560000d-16)
     *    *t-6.39683104557465600d-15)*t+5.92509321833062400d-14)
     *    *t-1.56008660983891968d-13)*t+4.20106807813331968d-13)
     *    *t-1.36926896339755520d-12)*t+4.86000800286762854d-12)
     *    *t-1.89780061819570625d-11)*t+8.39314701970122041d-11)
     *    *t-4.32843814802265754d-10)*t+2.71124934991469715d-9)
     *    *t-2.19026888712002973d-8)*t+2.50504395196083566d-7)
     *    *t-4.75245434337472120d-6)*t+2.05252791097940732d-4)*t -
     *    5.46414841607309762d-2
c
c     expansion (0071) evaluated as b(t)  --precision 19e.19
c19   b = (((((((((((((((-6.422422696755200000d-16*t+
c19  *    1.157018692878336000d-15)*t+1.050474638213120000d-15)
c19  *    *t-1.299716811587584000d-15)*t-5.605056004653056000d-15)
c19  *    *t+1.122309892346675200d-14)*t-1.660001866664345600d-14)
c19  *    *t+4.722878482761728000d-14)*t-1.432823023452692480d-13)
c19  *    *t+4.279212035945297920d-13)*t-1.377620461968010240d-12)
c19  *    *t+4.856938061667872256d-12)*t-1.897491865462963469d-11)
c19  *    *t+8.393217864498137862d-11)*t-4.328444424636872150d-10)
c19  *    *t+2.711249261358701004d-9)*t-2.190268880806947728d-8
c19   b = (((b*t+2.505043952011151565d-7)*t-4.752454343377146794d-6)
c19  *    *t+2.052527910979406482d-4)*t - 5.464148416073097618d-2
c
      s17akf = (sin(g)*a-cos(g)*b/z)*y
      go to 180
c
c     failure exits
  140 ifail = p01abf(ifail,1,srname,0,p01rec)
      s17akf = 0.0d0
      go to 180
  160 ifail = p01abf(ifail,2,srname,0,p01rec)
      s17akf = 0.0d0
c
  180 return
c
      end
      integer function p01abf(ifail,ierror,srname,nrec,rec)
c     mark 11.5(f77) release. nag copyright 1986.
c     mark 13 revised. ier-621 (apr 1988).
c     mark 13b revised. ier-668 (aug 1988).
c
c     p01abf is the error-handling routine for the nag library.
c
c     p01abf either returns the value of ierror through the routine
c     name (soft failure), or terminates execution of the program
c     (hard failure). diagnostic messages may be output.
c
c     if ierror = 0 (successful exit from the calling routine),
c     the value 0 is returned through the routine name, and no
c     message is output
c
c     if ierror is non-zero (abnormal exit from the calling routine),
c     the action taken depends on the value of ifail.
c
c     ifail =  1: soft failure, silent exit (i.e. no messages are
c                 output)
c     ifail = -1: soft failure, noisy exit (i.e. messages are output)
c     ifail =-13: soft failure, noisy exit but standard messages from
c                 p01abf are suppressed
c     ifail =  0: hard failure, noisy exit
c
c     for compatibility with certain routines included before mark 12
c     p01abf also allows an alternative specification of ifail in which
c     it is regarded as a decimal integer with least significant digits
c     cba. then
c
c     a = 0: hard failure  a = 1: soft failure
c     b = 0: silent exit   b = 1: noisy exit
c
c     except that hard failure now always implies a noisy exit.
c
c     s.hammarling, m.p.hooper and j.j.du croz, nag central office.
c
c     .. scalar arguments ..
      integer                 ierror, ifail, nrec
      character*(*)           srname
c     .. array arguments ..
      character*(*)           rec(*)
c     .. local scalars ..
      integer                 i, nerr
      character*72            mess
c     .. external subroutines ..
      external                p01abz, x04aaf, x04baf
c     .. intrinsic functions ..
      intrinsic               abs, mod
c     .. executable statements ..
      if (ierror.ne.0) then
c        abnormal exit from calling routine
         if (ifail.eq.-1 .or. ifail.eq.0 .or. ifail.eq.-13 .or.
     *       (ifail.gt.0 .and. mod(ifail/10,10).ne.0)) then
c           noisy exit
            call x04aaf(0,nerr)
            do 20 i = 1, nrec
               call x04baf(nerr,rec(i))
   20       continue
            if (ifail.ne.-13) then
               write (mess,fmt=99999) srname, ierror
               call x04baf(nerr,mess)
               if (abs(mod(ifail,10)).ne.1) then
c                 hard failure
                  call x04baf(nerr,
     *                     ' ** nag hard failure - execution terminated'
     *                        )
                  call p01abz
               else
c                 soft failure
                  call x04baf(nerr,
     *                        ' ** nag soft failure - control returned')
               end if
            end if
         end if
      end if
      p01abf = ierror
      return
c
99999 format (' ** abnormal exit from nag library routine ',a,': ifail',
     *  ' =',i6)
      end
      subroutine p01abz
c     mark 11.5(f77) release. nag copyright 1986.
c
c     terminates execution when a hard failure occurs.
c
c     ******************** implementation note ********************
c     the following stop statement may be replaced by a call to an
c     implementation-dependent routine to display a message and/or
c     to abort the program.
c     *************************************************************
c     .. executable statements ..
      stop
      end
      subroutine x04aaf(i,nerr)
c     mark 7 release. nag copyright 1978
c     mark 7c revised ier-190 (may 1979)
c     mark 11.5(f77) revised. (sept 1985.)
c     mark 14 revised. ier-829 (dec 1989).
c     if i = 0, sets nerr to current error message unit number
c     (stored in nerr1).
c     if i = 1, changes current error message unit number to
c     value specified by nerr.
c
c     .. scalar arguments ..
      integer           i, nerr
c     .. local scalars ..
      integer           nerr1
c     .. save statement ..
      save              nerr1
c     .. data statements ..
      data              nerr1/6/
c     .. executable statements ..
      if (i.eq.0) nerr = nerr1
      if (i.eq.1) nerr1 = nerr
      return
      end
      subroutine x04baf(nout,rec)
c     mark 11.5(f77) release. nag copyright 1986.
c
c     x04baf writes the contents of rec to the unit defined by nout.
c
c     trailing blanks are not output, except that if rec is entirely
c     blank, a single blank character is output.
c     if nout.lt.0, i.e. if nout is not a valid fortran unit identifier,
c     then no output occurs.
c
c     .. scalar arguments ..
      integer           nout
      character*(*)     rec
c     .. local scalars ..
      integer           i
c     .. intrinsic functions ..
      intrinsic         len
c     .. executable statements ..
      if (nout.ge.0) then
c        remove trailing blanks
         do 20 i = len(rec), 2, -1
            if (rec(i:i).ne.' ') go to 40
   20    continue
c        write record to external file
   40    write (nout,fmt=99999) rec(1:i)
      end if
      return
c
99999 format (a)
      end

c****************************************************************
c   Alternative routine for Airy functions (by series)
c   Used only for checkings
c****************************************************************
	subroutine sairy(x,ai,bi,dai,dbi,iscal,ierr)
	implicit double precision(a-h,o-z)
	common /nter/ ka,kb,kc,kd
	parameter (maxt=80)
	data pi/3.141592653589793238462643d0/
	data sqpi/1.772453850905516027298167d0/
	data pi4/0.7853981633974483096156608d0/
        data c1/0.35502805388781723926006318600420d0/
        data c2/0.25881940379280679840518356018919d0/
        data sr3/1.7320508075688772935274463415059d0/
	data eps/3.d-17/
	fx=0.d0
	a=1.d0
	t=a
	fx=fx+t
	ka=maxt
	do k=1,maxt
	k3=3*k
	a=a/((k3-1)*k3)
	t=a*x**k3
	fx=fx+t
	if(abs(t).le.eps*abs(fx)) then
	ka=k
	go to 10
	endif
	enddo
10	gx=0.d0
	b=1.d0
	t=b*x
	gx=gx+t
	kb=maxt
	do k=1,maxt
	k3=3*k
	b=b/((k3+1)*k3)
	t=b*x**(k3+1)
	gx=gx+t
	if(abs(t).le.eps*abs(gx)) then
	kb=k
	go to 20
	endif
	enddo
20	df=0.d0
	c=0.5d0
	t=c*x**2
	df=df+t
	kc=maxt
	do k=1,maxt
	k3=3*k
	c=c/((k3+2)*k3)
	t=c*x**(k3+2)
	df=df+t
	if(abs(t).le.eps*abs(df)) then
	kc=k
	go to 30
	endif
	enddo
30	dg=0.d0
	d=1.d0
	t=d
	dg=dg+t
	kd=maxt
	do k=1,maxt
	k3=3*k
	d=d/((k3-2)*k3)
	t=d*x**k3
	dg=dg+t
	if(abs(t).le.eps*abs(dg)) then
	kd=k
	go to 40
	endif
	enddo
40	ai=c1*fx-c2*gx
	bi=sr3*(c1*fx+c2*gx)
	dai=c1*df-c2*dg
	dbi=sr3*(c1*df+c2*dg)
	iscal=0
	return
	end
