      function f12(x)       
*
* Compute Fermi-Dirac integral F1/2 to accuracy of 10^-4 using 
* rational function approximation of Anita (1993, ApJS, 84, 101).
*
      implicit double precision(a-h,o-z)
      dimension a1(8),b1(8),a2(11),b2(12)
*
* high precision formulae
*
      data an,m1,k1,m2,k2/0.5d0,7,7,10,11/
      data a1/5.75834152995465d+6,1.30964880355883d+7,
     1        1.07608632249013d+7,3.93536421893014d+6,
     2        6.42493233715640d+5,4.16031909245777d+4,
     3        7.77238678539648d+2,1.00000000000000d+0/
      data b1/6.49759261942269d+6,1.70750501625775d+7,
     1        1.69288134856160d+7,7.95192647756086d+6,
     2        1.83167424554505d+6,1.95155948326832d+5,
     3        8.17922106644547d+3,9.02129136642157d+1/
      data a2/4.85378381173415d-14,1.64429113030738d-11,
     1        3.76794942277806d-09,4.69233883900644d-07,
     2        3.40679845803144d-05,1.32212995937796d-03,
     3        2.60768398973913d-02,2.48653216266227d-01,
     4        1.08037861921488d+00,1.91247528779676d+00,
     5        1.00000000000000d+00/
      data b2/7.28067571760518d-14,2.45745452167585d-11,
     1        5.62152894375277d-09,6.96888634549649d-07,
     2        5.02360015186394d-05,1.92040136756592d-03,
     3        3.66887808002874d-02,3.24095226486468d-01,
     4        1.16434871200131d+00,1.34981244060549d+00,
     5        2.01311836975930d-01,-2.14562434782759d-02/
*
* small eta rational function       
*
      if(x .lt. 2.d0)then
        xx = dexp(x)
        rn = xx + a1(m1)
        do 100 i=m1-1,1,-1
          rn = rn*xx + a1(i)
100     continue
        den = b1(k1+1)
        do 200 i=k1,1,-1
          den = den*xx + b1(i)
200     continue
        f12 = xx * rn / den
       else
*
* large eta rational function       
*
        xx = 1.d0 / x**2
        rn = xx + a2(m2)
        do 300 i=m2-1,1,-1
          rn = rn*xx + a2(i)
300     continue
        den = b2(k2+1)
        do 400 i=k2,1,-1
          den = den*xx + b2(i)
400     continue
        f12 = ((x**(an+1.d0)) * rn) / den
      endif

      return      
      end 

************************************************************************

