How to form 6-31G basis set; specific instructions I'm new to basis sets. I read that for 3-21G, given the following basis set for carbon (from Basis Set Exchange):

C    S
    172.2560000              0.0617669        
     25.9109000              0.3587940        
      5.5333500              0.7007130        
C    SP
      3.6649800             -0.3958970              0.2364600        
      0.7705450              1.2158400              0.8606190        
C    SP
      0.1958570              1.0000000              1.0000000


You form three 'atomic orbitals' (is that the right term?) as:

let f(alpha) = (2*alpha/pi)^(3/4) * exp(-alpha*r^2)

O1 = 0.061 f(172) + 0.358 f(25) + 0.7 f(5.5)
O2 = -.39 f(3.66) + 1.21 f(.77) + 1 f(.195)
O3 = 0.23 f(3.66) + 0.86 f(.77) + 1 f(.195)

I truncated the numbers to make it easier to type...


Assuming that is correct, that makes sense to me. But when I look at the 6-31G basis set data for carbon: 

C    S
   3047.5249000              0.0018347        
    457.3695100              0.0140373        
    103.9486900              0.0688426        
     29.2101550              0.2321844        
      9.2866630              0.4679413        
      3.1639270              0.3623120        
C    SP
      7.8682724             -0.1193324              0.0689991        
      1.8812885             -0.1608542              0.3164240        
      0.5442493              1.1434564              0.7443083        
C    SP
      0.1687144              1.0000000              1.0000000        
C    SP
      0.0438000              1.0000000              1.0000000     


From the naming nomenclature, I thought the only difference would be 6 primitive gaussians for the inner shell which I see, but . . . I was not expecting that third SP line. I don't know how to use it.

I want to write:

O1 = .0018 f(3047) ...
O2 = -.119 f(7.86) + ... + 1.0 f(.168)
O3 = 0.068 f(7.86) + ... + 1.0 f(.168)

Just like I did for the 3-21G case.  
Maybe I could add:

O4 = -.119 f(7.86) + ... + 1.0 f(0.0438)
O5 = 0.068 f(7.86) + ... + 1.0 f(0.0438)


But I don't think this is right because I read online that there should be 9 orbitals formed (although they didn't explain how to get them). 

Thanks for the help!

Update
Ok, so I looked up 6-311G instead of 6-31G. However, I still don't see how to form 9 orbitals from 6-31G:

C    S
   3047.5249000              0.0018347        
    457.3695100              0.0140373        
    103.9486900              0.0688426        
     29.2101550              0.2321844        
      9.2866630              0.4679413        
      3.1639270              0.3623120        
C    SP
      7.8682724             -0.1193324              0.0689991        
      1.8812885             -0.1608542              0.3164240        
      0.5442493              1.1434564              0.7443083        
C    SP
      0.1687144              1.0000000              1.0000000  


I really need to see all 9 orbitals written out explicitly. 

Update 2
Ok, with more research I finally found this  

So it looks like I'm missing a function. I need to define:

f1(alpha) = (2*alpha/pi)^(3/4) exp(-alpha r^2)
f2(alpha, x) = (128 alpha^5/pi^3) x exp(-alpha r^2)


Then the 9 orbitals are:

O1 = .001 f1(3047) + .014 f1(457) + ... + .362 f1(3.16)
O2 = -.119 f1(7.68) + -.16 f1(1.88) + 1.14 f1(.54)
O3 = 1.0 f1(.168)
O4 = .068 f2(7.68, x) + .316 f2(1.88, x) + .744 f2(.54, x)
O5 = 1.0 f2(.168, x) 
O6 = .068 f2(7.68, y) + .316 f2(1.88, y) + .744 f2(.54, y)
O7 = 1.0 f2(.168, y) 
O8 = .068 f2(7.68, z) + .316 f2(1.88, z) + .744 f2(.54, z)
O9 = 1.0 f2(.168, z)


Can anyone confirm this? Or, if not confirm, specify what's wrong?

Thanks!
I believe you have not correctly interpreted the first basis set, which should read:

O1 = 0.061 f(172) + 0.358 f(25) + 0.7 f(5.5)
O2 = -.39 f(3.66) + 1.21 f(.77)
O3 = 1 f(.195)


Note that these are only the s-orbitals. Using the coefficients in the right-most column, two triplets of p-orbitals are also present. By doing it this way for the second basis set, which is 6-31G, you would obtain 3 s-orbitals and two triplets of p-orbitals, making it nine AOs in total. Note that all orbitals in a tuple must have the same contraction scheme, otherwise, the calculation would not be rotationally invariant (to within integration accuracy).

Aside: Why does this basis specify s- and p-orbitals this way?
Depending on the integral scheme, one can reuse certain intermediates of some integrals for others and save some computational time. However, modern programs tend to work better with segmented basis sets (i.e. basis sets that do not allow for reuse, because the $\alpha$ exponents are all different). The results are also of higher quality. IMHO, the Pople basis sets are only of historical interest or for hobbyists with very limited resources.