text:
Periodic Table of Elements - Code Golf
Based on Practical Golf - US States
Your task is to find the abbreviation (symbol) of an element given the element name, up to and including ununoctium (118). Use the periodic table on Wikipedia.
Thanks to squeamish ossifrage, you can find a full list of elements to abbreviations at http://pastebin.com/DNZMWmuf.
You may not use any external resources. In addition, you may not use any built-in data specifically about the elements of the periodic table. Standard loopholes apply.
Input
Input may be from stdin, file, prompt, input etc.
Input Format:
All of the following are valid inputs:
Carbon
carbon
CARBON
cArBOn

Essentially, the element name - case insensitive.
You do not have to handle misspellings or any invalid element name. Invalid input is undefined behavior.
Output:
The symbol for the element. The first character must be capitalized and the rest
must be lowercase.
Example output: C
Test cases:
Carbon -> C
NiTROGen -> N
Sodium -> Na
Gold -> Au
Silver -> Ag
Tin -> Sn

There are many more elements than states, so I expect it to be harder to find a general rule for these.
This is code golf. Shortest code wins!

Here's the full list. It might be more efficient to use the correct spelling of "sulphur"; would that be OK I wonder?

@squeamishossifrage Thanks. Both versions ("sulphur" and "sulfur") are acceptable. Your program does not have to handle both, however, only one.

@Sammitch Why? Built-in means "comes with the language" e.g. in Python, if there was an elements library you can't do import elements. You would have to redefine it on your own.

...impossible to do with regexes. You got us good.

"NiTROGen" seems like it was a copy/paste from an example. How dare you caps more than the first letter and break your own rules!

@Xrylite Try reading the rules: "Input ... the element name - case insensitive ... Output ... The first character must be capitalized and the rest must be lowercase".

What about proper spelling (Aluminium) versus US spelling (Aluminum) ?

Can bogus input have undefined output?  Like, if the user inputs sausage, does the program have to fail?  Is it okay if it happens to print Au?

@codebreaker Yes, if the input is not valid, your program may crash, hang, print Au, or whatever you want. @Paul R If there are many ways to spell an element (e.g. sulphur vs sulfur or aluminium vs aluminum) use whichever makes your program shorter. You do not have to handle both cases.

@soktinpk. I'd recommend following IUPAC rules (they go with aluminium and sulfur).

This is one of the most awesome Golf questions I've seen so far.

CJam, 337 297 293 232 220 201 200 bytes
leu:E2f^3b2+4%_"53N5903CVCT4":i3/=~Ef+b\%]53b"gØâ^ÃP·^À4Î¾^ß^E5^W^Ma{áª^B¤±´oòæ»^XÊQÑ»4Å¾DÙÝòÙ 0^ÝþKa6^Ó£,Ûkû¥¡ùh^E"256b7b6a/0a3**<)5md@5a/,(" ¬^GH/N¿·%^U^RU1²Bd
òë^Ð¼~í^ÌéáU"256b25b'Af+2/='J-'Q/"UU"*\)_5=)*E%2<?(\el

The above code uses caret notation, since it contains control characters.
At the cost of 24 additional bytes (for a total of 224), those characters can be avoided.
leu:E2f^3b2+4%_"53N5903CVCT4":i3/=~Ef+b\%]53b
"' NwEvKv6e8@]jO4G)=b{L!v@hFQ/oCN)*|BRxvNRL+LO7NI(pLs4[d87$Q%8R\t+' M5JU"
{32f-95b}:B~7b6a/0a3**<)5md@5a/,(
"&y.$h*z^t\rQPUc]l8F h$=18C^r|vD~S"
B25b'Af+2/='J-'Q/"UU"*\)_5=)*E%2<?(\el

You can try this code in the CJam interpreter.
Test cases
$ base64 -d > elements.cjam <<< bGV1OkUyZl4zYjIrNCVfIjUzTjU5MDNDVkNUNCI6aTMvPX5FZitiXCVdNTNiImfY4oNQt4A0zr6fBTUXDWF74aoCpLG0b/LmuxjKUdG7NMW+RNnd8tmgMJ3+S2E2k6Ms22v7paH5aAUiMjU2YjdiNmEvMGEzKio8KTVtZEA1YS8sKCIgrAdIL06/tyUVElUxskJkCvLrkLx+7Yzp4VUiMjU2YjI1YidBZisyLz0nSi0nUS8iVVUiKlwpXzU9KSpFJTI8PyhcZWw=
$ cksum elements.cjam
952664534 200 elements.cjam
$ for e in Carbon NiTROGen Sodium Gold Silver Tin; do LANG=en_US cjam elements.cjam <<< $e; echo; done
C
N
Na
Au
Ag
Sn

How it works
The first step is to read the element name from STDIN and apply a rather elaborated hash function, which maps all element names in the range [0, 225]:
l eu :E          " Read a line from STDIN, convert to uppercase and save in E.            ";
2 f^             " XOR each character code with 2.                                        ";
3 b              " Convert to integer; consider the resulting array a base 3 number.      ";
2 + 4 %          " Add 2 and take the result modulo 4. Result: R                          ";
"53N5903CVCT4":i " Push [53 51 78 53 57 48 51 67 86 67 84 52].                            ";
3 / =            " Retrieve the chunk of length 3 that corresponds to R. Result: C        ";
~ E f+           " Add C[2] to all character codes of E.                                  ";
b                " Convert to integer; consider the resulting array a base C[1] number.   ";
\ %              " Take the integer modulo C[0]. Result: M                                ";
] 53 b           " Push H := 53 * R + M.                                                  ";

Many element symbols are formed by the first and second, first and third, first and fourth, first and fifth or first and tenth (which is just the first) character of the element's English name. We are going to represent these elements by numbers from 0 to 4 respectively. All remaining elements (represented by 5) will require a lookup table.
The resulting table can be pushed as follows:
"gØâ^ÃP·^À4Î¾^ß^E5^W^Ma{áª^B¤±´oòæ»^XÊQÑ»4Å¾DÙÝòÙ 0^ÝþKa6^Ó£,Ûkû¥¡ùh^E"256b7b6a/0a3**

The array of character codes gets converted from base 256 to base 7 and 6's are replaced by runs of three 0's.
This is the decision table D:
[4 0 0 0 1 0 0 0 0 0 0 3 0 2 0 1 0 0 0 0 0 0 0 0 4 1 1 0 0 0 0 2 0 4 0 5 2 0 0 3 4 0 0 0 0 4 0 1 0 0 3 1 0 0 2 1 1 1 0 0 0 1 0 5 5 0 0 2 0 0 0 5 5 0 0 0 5 0 3 0 0 0 0 5 0 0 0 0 0 0 0 0 5 2 3 0 1 0 5 0 4 0 0 0 0 4 0 5 0 0 0 0 0 5 0 0 0 2 5 1 4 1 5 0 0 0 5 0 0 5 1 1 0 0 0 0 0 0 2 0 5 0 0 0 3 1 0 2 0 0 0 2 0 0 0 5 0 0 0 0 1 0 0 0 0 0 4 0 2 2 5 2 0 0 5 1 0 0 0 0 4 0 5 0 0 3 5 0 0 5 0 1 0 0 0 2 0 0 0 0 0 5 0 4 0 0 0 0 0 0 0 0 3 0 4 0 0 1 2 2 0 0 0 0 0]

The necessary action for the element with hash 1, e.g., corresponds to the first element of the this array. Array elements that do not correspond to any element's hash are also zero, which allows the (0 0 0) ↦ 6 compression.
Now, we interpret D for hash H.
< ) 5 md     " Push D[:H-1] (D[H-1] / 5) (D[H-1] % 5).                                    ";
@ 5a / , (   " Count the number of 5's in D[:H-1] (by splitting at [5]). Result: I        ";

Next, we push the lookup table. If we append j to single-character symbols and replace Uu with Q, each symbol will be exactly two characters long. It can be pushed as follows:
" ¬^GH/N¿·%^U^RU1²Bd
òë^Ð¼~í^ÌéáU"256b25b'Af+2/

The array of character codes gets converted from base 256 to base 25, the character code of A gets added to all digits (casting to Character in the process) and the result is split into chunks of length two.
This is the lookup table L:
["QP" "YB" "PD" "SN" "QO" "QT" "QS" "SB" "KJ" "TM" "FE" "PB" "AU" "WJ" "CN" "SG" "RF" "CM" "CU" "HG" "NA" "RG" "AG"]

Now, we proceed to compute potential element names.
=                " Push L[I].                                                             ";
'J - 'Q / "UU" * " Remove J's and replace Q's with runs of two U's.                       ";
\ ) _ 5 = ) *    " Push S := (D[H-1] % 5 + 1) * ((D[H-1] % 5 + 1 == 5) + 1).              ";
E %              " Push every Sth character of E.                                         ";
2 <              " Discard all but the first two characters.                              ";

The stack now contains
B M N

where B is the Boolean D[H-1] / 5, M is the name retrieved from the lookup table an N is the element name formed by selecting characters from E.
We're almost done:
?                " If B, push M; else, push N.                                            ";
( \              " Extract the first character from the string.                           ";
el               " Convert the rest to lowercase.                                         ";

But how does it work?

@Claudiu: I've added an explanation.

I've read the first third of the explanation, and so far what I have is "Magic".  Incredible

"AcAlAmSbArAsAtBaBkBeBiBhBBrCdCsCaCfCCeClCrCoCnCuCmDsDbDyEsErEuFmFlFFrGdGaGeAuHf
HsHeHoHInIIrFeKrLaLrPbLiLvLuMgMnMtMdHgMoNdNeNpNiNbNNoOsOPdPPtPuPoKPrPmPaRaRnReRh
RgRbRuRfSmScSgSeSiAgNaSrSTaTcTeTbTlThTmSnTiWUuoUupUusUutUVXeYbYZnZr" = 226 chars. Your solution = 200 chars. There's some proper voodoo going on here.

I've accepted this answer because it appears to be the shortest but feel free to post additional answers.

Using the interpreter you linked and providing the input "helium" for the caret-notation code, I get the output "Hi". This should be "He", shouldn't it?

@Chiru: You cannot copy/paste the caret notation code. You actually have to generate the control characters. That's easier said than done using the online interpreter.

C, 452
A good hash function helps. There may be better ones. (Improvements suggested by @ugoren et al.)
h;main(c){char*p="Sn)Cu&V$U#Mo#Rf#Sg&Cs#Y+FTa%Rb)S'Nd#GaK&Mg'Zr$PtPm%ReUuo#SmDy(Ac$Lu%W&CaRa(Cf)EuB#Ds%Md$Uus*NpIn$H&YbIr*BeEs*Tc#I(FlRuC#ThSrBh/NaCoLrKr&Nb$CePb$Ne'Am)At*PdLa#Tl%HgMt,CrTbBk$Rh&Rn4TeZn$HfAg%Fm)Xe$AlScFePo$As'HeO#LvN&DbGe#Ho&Mn$Cd+Ni$Rg$HsBr$AuSi#Pr&Uup#Se*Ti#Tm$Er$Sb&PPu&Cm$GdBa'Cn&UutLiFr#Ar#Bi#NoOs%Pa4Cl";while((c=getchar())>64)h=(h+c%32+74)*311%441;while(h)if(*p<65?h-=*p++-34,0:1)for(h--;*++p>96;);do putchar(*p++);while(*p>96);}

Ungolfed with comments:
int h;
main(c) {

  /* Hashed element symbols. Characters #$% etc. are used as padding: */
  char *p="Sn)Cu&V$U#Mo#Rf#Sg&Cs#Y+FTa%Rb)S'Nd#GaK&Mg'Zr$PtPm%ReUuo#SmDy(Ac$Lu%W&C"
          "aRa(Cf)EuB#Ds%Md$Uus*NpIn$H&YbIr*BeEs*Tc#I(FlRuC#ThSrBh/NaCoLrKr&Nb$CeP"
          "b$Ne'Am)At*PdLa#Tl%HgMt,CrTbBk$Rh&Rn4TeZn$HfAg%Fm)Xe$AlScFePo$As'HeO#Lv"
          "N&DbGe#Ho&Mn$Cd+Ni$Rg$HsBr$AuSi#Pr&Uup#Se*Ti#Tm$Er$Sb&PPu&Cm$GdBa'Cn&Uu"
          "tLiFr#Ar#Bi#NoOs%Pa4Cl";

  /* This hash function gives a unique result for each element: */
  while((c=getchar())>64) h=(h+c%32+74)*311%441;

  /* Find the corresponding position in the hashed data */
  while(h) {
    if(*p<65?h-=*p++-34,0:1) {      /* Step over an abbreviation */
      for(h--;*++p>96;);            /* Skip padding */
    }
  }

  /* Output first uppercase character and all following lowercase characters: */
  do {
    putchar(*p++);
  } while(*p>96);
}

I used brute force to find this hash; This was the only one with a hash size of ≤512 that had no collisions. I didn't check alternative spellings though, and there might be better functions with different algorithms (e.g. using XOR instead of addition).
The hash function maps text strings to values from 0 to 440. "Tin" hashes to zero, so "Sn" is at the start of the table. The next 7 positions are empty. To keep the code compact, this is indicated by the ASCII value 34+7=41 (")"). Next comes "Copper" (8), four empty cells (34+4=38="&"), and "Vanadium" (13). After calculating a hash, the program steps through the table, subtracting 1 for every capital letter followed by 0 or more lowercase letters, and subtracting (ASCII VALUE)-34 for every non-alphabet character. When the value reaches zero, we have found the correct result.

How did you find that hash function?!

@soktinpk Brute forced it :-) This was the only one with a hash size of ≤512 that had no collisions. I didn't check alternative spellings though, and there might be better functions with different algorithms (e.g. using XOR instead of addition).

Make that 464 ... you have an unnecessary pair of braces.

@JimBalter Ah, I didn't even realise you could do that. Thanks!

If you think about the grammar, it's unambiguous and has to be allowed ... it just looks ambiguous to us. Oh, and you caught another one I didn't! Congratulations on this ... I tried hard to tighten the algorithm but you got everything  right.

@squeamishossifrage can you please explain how did you arrive at the char* in a bit more detail. Thanks. (I hope to learn something new today)

@Harshdeep — The hash function maps text strings to values from 0 to 440. "Tin" hashes to zero, so "Sn" is at the start of the table. The next 7 positions are empty. To keep the code compact, this is indicated by the ASCII value 34+7=41 (")"). Next comes "Copper" (8), four empty cells (34+4=38="&"), and "Vanadium" (13). After calculating a hash, the program steps through the table, subtracting 1 for every capital letter followed by 0 or more lowercase letters, and subtracting (ASCII VALUE)-34 for every non-alphabet character. When the value reaches zero, we have found the correct result.

Any idea why while(h)h-=*p>64?({for(h--;*++p>96;);0;}):*p++-34; seg faults (one less char)? Reference at https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html

Nice one. Save some chars with: 1. (h+c%32+74)*311%441. 2. Drop p and use s. 3. main(c) saves one comma.

Save one more by if(*p<65?h-=*p++-34,0:1) replacing the else. And, I think, one more by replacing :1 with :h--.

I found that (hash+(c&31)+51)*211%324 uses a smaller modulo, but I doubt it would shave off many (any?) bytes...

Thanks for the improvements ugoren! (@tolos — your version works fine too, but the code is liable to throw a seg fault if it encounters any misspellings or spaces; perhaps that's what happened?)

@MooingDuck Are you sure? I counted 23 collisions with those parameters (e.g., "Gallium", "Plutonium" and "Silicon" all produce a value of 6)

@squeamishossifrage: I checked, my program has hashing the abbreviations. :/

@squeamishossifrage: Here's what I bruteforced up to mod 584: http://coliru.stacked-crooked.com/a/0781764beb357213, shortest so far is what you found.

I bruteforced various combinations of + and * up to mod 1000, your equation is tied for the shortest.  Now I'll have to figure out how to work >>, << and ^ into my tests.

One idea I had was to try to assume that every element maps to its first two letters, and then just store the exceptions.  I did a few tests, and that's not as promising an idea as it sounds.  Still, I bet it might beat some answers here if anyone wants to give it a go . . .

444 bytes

JavaScript ES6, 690 708 bytes
for(n=prompt()[l='toLowerCase'](i=0);!(c='HHeLiBeBCNFNeNaMgAlSiPSClArKCaScTiVCrMnFeCoNiCuZnGaGeAsSeBrKrRbSrYZrNbMoTcRuRhPdAgCdInSnSbTeIXeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaWReOsIrPtAuHgTlPbBiPoAtRnFrRaAcThPaUNpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnUutFlUupLvUusUuo'.match(x=/[A-Z][a-z]*/g)['HyHeLitBeryBorCarNitFluNeonSoMagAlSiliPhSuChlArgPotCalcScTitVChrManIroCobNicCoppZinGalGeArsSelBrKRubStYttrZirNioMoTecRuthenRhoPaSilvCadInTinAnTelIoXCaeBaLanCePraNeodPromSaEuGadTerDyHoErThuYtteLuHafTaTuRheOsIriPlaGoMerThaLeBiPolAsRadoFrRadiAcThoProtUrNepPluAmCuBerkCaliEiFeMenNoLawRutherDuSeaBohHasMeiDaRoCopeUnuntFleUnunpLivUnunsUnuno'.match(x).map(a=>a[l]()).indexOf(n.slice(0,i++))]);)
alert(c)

The first array holds the symbols, and the second array holds the minimum letters necessary to tell which element is being referred to. Thanks to core1024 and edc65 for helping shorten it. Test at http://jsfiddle.net/xjdev4m6/2/. Slightly more readable:
n=prompt().toLowerCase()
e='HyHeLitBeryBorCarNitFluNeonSoMagAlSiliPhSuChlArgPotCalcScTitVChrManIroCobNicCoppZinGalGeArsSelBrKRubStYttrZirNioMoTecRuthenRhoPaSilvCadInTinAnTelIoXCaeBaLanCePraNeodPromSaEuGadTerDyHoErThuYtteLuHafTaTuRheOsIriPlaGoMerThaLeBiPolAsRadoFrRadiAcThoProtUrNepPluAmCuBerkCaliEiFeMenNoLawRutherDuSeaBohHasMeiDaRoCopeUnuntFleUnunpLivUnunsUnuno'.match(x=/[A-Z][a-z]*/g).map(a=>a.toLowerCase())
s='HHeLiBeBCNFNeNaMgAlSiPSClArKCaScTiVCrMnFeCoNiCuZnGaGeAsSeBrKrRbSrYZrNbMoTcRuRhPdAgCdInSnSbTeIXeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaWReOsIrPtAuHgTlPbBiPoAtRnFrRaAcThPaUNpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnUutFlUupLvUusUuo'.match(x)
for(i=0;i<7;i++){
  if(c=s[e.indexOf(n.slice(0,i))]){
    alert(c,i=8) // i=8 breaks out of the loop so the result is only alerted once
  }
}

Can you shave some bytes off by using the fact that Neo matches Neodymium, given that Neon has been passed in the list?

@Dancrumb Unfortunately not. The loop starts with the shortest substring, so it will hit Neo before it hits Neon because it has fewer letters.

+1 for the shortest JS so far. Although you can get rid of this if statement (It's a perfect for condition) and also to inline or shift the positions of some variables, to shorten the code ;)

at beginning ).toLowerCase( --> )[L='toLowerCase']( then at end a.toLowerCase( --> a[L]( should cut 4 chars

Ruby 1.9+, 565 471 447  444
A one-liner.  Because nothing is "impossible to do with regexes"...
(Just saved 94 chars by adding another regex) ((and 24 by simplifying them))
p"VAlAmA.sArAcAnt|SbA.tBaB..kBeBiB.hBrBDyD.+sD.bE..sErEuF..mFrFlu|F@FlG.dGaGeG|AuH.fH.sHeHoHInIro|FeIrIKrL.vL.+rLaLiLuL|PbM.gMoM.+dM.nM.+tM|HgC.+sC.dC.+fCeCar|C@C....nCaCu|CmCop|CuCoC.rC.lN.+dN.+pNeN..bNit|N@NoNiOsOP..mPa|PdP...aPrP.uP..tPot|KPoPR.*n$RaR.+gR.eRhR.+bR.+fRuS.mScS.+gSeS..v|AgSiSo|NaS.rSTaT.cT.+bTeThu|TmT..lThTin|SnTiTu|WU.u.oU.u.pU.u.sU.u.tUXeY.+bYZ.nZ.r"
.split(/(?<!\|)(?=[A-Z])/).find{|r|/^#{r}/i.match *$*}.gsub /.*\||\W/,''

(newline after string added for "readability", remove for test)
usage: ruby periodic.rb aluminum $>
Explanation:
Splitting the string on leading capitals returns an array of regex to match against element names. The only alphabetic characters allowed in each are those from the abbreviation*. They are ordered such that the first match found when comparing to the command line argument *$* is the correct one. The trailing gsub strips out the non-alpha characters before printing.
*Odd abbreviations like "Fe" for "Iron" are handled by a | element: "Iro|Fe". The first choice is what is actually matched; the gsub then removes all characters up to the '|', leaving the actual abbreviation.
Test framework (requires @squeamish's list: downloaded as 'table.txt' in the working directory).
def testfunc(name)
  #replace with however you call your code
  return `ruby1.9.3 periodic2.rb #{name}`.chomp()
end

elements= File.new('table.txt').readlines.map{|s|s.chomp}

elements.each{|l|
  a,n=l.split(' ')
  r = testfunc(n)
  print "#{n} => #{a} "
  if r!=a then
    print ("FAIL: gave #{r}\n")
    exit
  else
    print("\tOK\n")
  end
}
print("PASS: #{elements.size} elements matched\n")

Standing ovation if it works for all 100+ cases

Of course it works: http://ideone.com/7FZlAt

One has the audacity to state something can't be done with regex. Thanks for proving them (one said, many thought) wrong :)

Ruby, 1068 bytes
require"zlib"
require"base64"
$><<eval(Zlib::Inflate.inflate(Base64.decode64"eJwlU8tu2zAQ/Bee+QW6CLYTx0FiR7CdtsmNkmhJCEUKfKQViv57Z9YnE+vd2ZnZ0d+1j2Go6oO2bipzpQ5W6SmPU6nU66S0jatzldqiGmLwVb3VJrZ87NAmoyf9Zx0sKm/alRCnqt5riw514lAvqCejtBm8TZU6Dgp984SGjcMuN3WhUhfsGkNaxqpudHG3Eqv6okdHPLVDXxwIuYmAzCalqn7RxnWkuQN2Z3yPxktH8sbjeQWg8QbV+oceY5iJE1kbDICOHpBE3JNka1zG3wHT3ZeF3hOmw7LYiGpB1XeV+sSIcY4rnwydmQn0hPmYLFduEqpOnhdWg4jcYmlclwyRL3iWdiLTc6s07PNYe0E15wjc+kNPsSOrT9Sm0HLXCZ3BrW0P0iBou9FbyIPSkkfYrs6F1vXsPY9C0aC36entNxVs4LjpZ/EKVX8/ybOnLqzHr8/TzCO0FODgvbreb4dV9bO2npx+oWSTzO6g1ER5bnlZn0eDvIgr9wbqN8kCtIEUG/qVKejFFQvRzYyx2fC6FzxLDAuej4VMg8PzqSeYOHAFrTUtEWAPK80QKQeYwf+B+4gVY5HLXGeaicFKfbS0yGaAvRL35mXsJnwNjnwF3+KHlKv6p4aV4iCIp1lQ3yAyTuLrMxY4k2lXk8kABm8KCXY06wCDR0YDmIiqFf+xfUpzgdYtw+QCc9GAdMqGnDZZtPKAzKLxHYp7JvR+nzNjjZVs7XjhKPpGWpgN8tgYGWNu3rVdcuEnt/DjykRtwG/GOdC5EYfvh5nJWjK+/WJYphts3d2YhZQRrMck0eauPXt9z95jz6/EUuEJEszvyOS9xnsIYcH5xmiLhQ9MkWkDqhcYE0YhvmU0U5ITcMWUGeMjTYgzTqAeUA3W5wFgHMPHhxU7prP4DLD3gmZnY/gGNSflxbIMzROCDnWv31JOUk7yDh3fQf37D7D/kWs="))[gets.downcase[1..5].to_sym]

Input via STDIN.
The shortest unique substrings of the element names are from the second to the sixth character (or the end of the name if its too short). So I'm simply getting those and looking them up in a hash. I also compressed the hash because that saves another 200 bytes. Here is what the hash itself looks like:
{ydrog:?H,elium:"He",ithiu:"Li",eryll:"Be",oron:?B,arbon:?C,itrog:?N,xygen:?O,luori:?F,eon:"Ne",
 odium:"Na",agnes:"Mg",lumin:"Al",ilico:"Si",hosph:?P,ulfur:?S,hlori:"Cl",rgon:"Ar",otass:?K,
 alciu:"Ca",candi:"Sc",itani:"Ti",anadi:?V,hromi:"Cr",angan:"Mn",ron:"Fe",obalt:"Co",ickel:"Ni",
 opper:"Cu",inc:"Zn",alliu:"Ga",erman:"Ge",rseni:"As",eleni:"Se",romin:"Br",rypto:"Kr",ubidi:"Rb",
 tront:"Sr",ttriu:?Y,ircon:"Zr",iobiu:"Nb",olybd:"Mo",echne:"Tc",uthen:"Ru",hodiu:"Rh",allad:"Pd",
 ilver:"Ag",admiu:"Cd",ndium:"In",in:"Sn",ntimo:"Sb",ellur:"Te",odine:?I,enon:"Xe",esium:"Cs",
 arium:"Ba",antha:"La",erium:"Ce",raseo:"Pr",eodym:"Nd",romet:"Pm",amari:"Sm",uropi:"Eu",
 adoli:"Gd",erbiu:"Tb",yspro:"Dy",olmiu:"Ho",rbium:"Er",huliu:"Tm",tterb:"Yb",uteti:"Lu",
 afniu:"Hf",antal:"Ta",ungst:?W,heniu:"Re",smium:"Os",ridiu:"Ir",latin:"Pt",old:"Au",ercur:"Hg",
 halli:"Tl",ead:"Pb",ismut:"Bi",oloni:"Po",stati:"At",adon:"Rn",ranci:"Fr",adium:"Ra",ctini:"Ac",
 horiu:"Th",rotac:"Pa",raniu:?U,eptun:"Np",luton:"Pu",meric:"Am",urium:"Cm",erkel:"Bk",alifo:"Cf",
 inste:"Es",ermiu:"Fm",endel:"Md",obeli:"No",awren:"Lr",uther:"Rf",ubniu:"Db",eabor:"Sg",
 ohriu:"Bh",assiu:"Hs",eitne:"Mt",armst:"Ds",oentg:"Rg",opern:"Cn",nuntr:"Uut",lerov:"Fl",
 nunpe:"Uup",iverm:"Lv",nunse:"Uus",nunoc:"Uuo"}

JavaScript (Node.js), 298 bytes
s=>(i=`23>3c9@94=4E33:3Q0I3:9[020G0O3@74M9=4A6@4;7J5H96?9K0L723E4343A4R40A0T9D3J5H4?4?3J329>9P9;359:0B9^3=95h6:9<6M0~D0@0N3<3;0:9@4<4<6H3I3`.replace(/\D/g,s=>"2".repeat(Buffer(s)[0]-56))[h=parseInt(s,36)*184%901])-9?s[0]+[s[i-1]]:`Ag,Fe,Hg,,W,Sn,K,Cu,Pb,,Sb,Au,,Na`.split`,`[h%418%48%15]||'Uu'+s[4]

Try it online!
How?
Element groups
We split the elements into 3 groups:

Group 1: 12 elements whose symbol is the first letter of their name, such as Carbon -> C.

Group 2: 91 elements whose symbol is the first letter of their name, followed by the \$n\$-th letter (0-indexed) with \$1\le n \le6\$. Examples: Helium -> He (\$n=1\$), Zirconium -> Zr (\$n=2\$).

Group 3: 15 elements that do not belong to the other groups, such as Iron -> Fe.

This means that all elements can be encoded with a single digit: we use \$0\$ for group 1, \$n+1\$ for group 2 and \$9\$ for group 3. (Obviously, we'll need some extra data for group 3. More on that later.)
It is worth noting that 44 symbols simply consist of the first two letters of the element name. That's almost 50% of group 2. These ones will be encoded with a "2", so that's the padding character that we want to use in our lookup string.
Hash function, lookup string and compression
We apply the following hash function (found by brute-force) on the input string:
h = parseInt(s, 36) * 184 % 901

The corresponding lookup string is \$899\$ characters long, which is pretty big.
But, by design, we have many runs of consecutive \$2\$'s in there. Our compression strategy is to replace each run of \$2\$'s of length \$2\le n\le70\$ with the character whose ASCII code is \$n+56\$ (that's the range going from ":" to "~").
The compressed string is only \$132\$ characters long.
You can see the decompression process here:
Try it online!
Decoding
Groups 1 and 2 are decoded the same way:
s[0] + [s[i - 1]]

(NB: For group 1, s[-1] is undefined and [undefined] is coerced to an empty string.)
For group 3, we use another hash function and another lookup string (also found by brute-force):
`Ag,Fe,Hg,,W,Sn,K,Cu,Pb,,Sb,Au,,Na`.split`,`[h % 418 % 48 % 15]

There are 4 remaining superheavy elements that are not included above. Because they are referred to by their temporary names and thanks to the systematic nomenclature, we can build the symbols for these ones by concatenating "Uu" with the fifth letter of their name:
    v
Ununtrium   -> Uut
Ununpentium -> Uup
Ununseptium -> Uus
Ununoctium  -> Uuo
    ^
Hence the last part of the code:
|| 'Uu' + s[4]

Python - 652 649 637
My hash table is based on the combination of every second and every third character of the uppercase name:
import re
def f(s,c='S<8F0FCE;2.ACR;J@W$;BI8>GD*?GnHQ<K>&T\(51IAg/Y?S2=169.,325(F(98?>?=^97DUCITX;SJ`0C<P9iLP/G4B,A(-A?(3QLLZ;81D(.4F;L8GaVP[=\=cOX3U,LQl6:E9/OXdSe(4,TSV/=FN98?K.18Q>R$+<GG[IS-4?;4H;T/IMq9<LXMYH4HG<>>KTT,>IIEM,[Nf<,:Z60(A9fImZTMRTcM?[lVg^qC}',e='HHeLiBeBCNOFNeNaMgAlSiPSClArKCaScTiVCrMnFeCoNiCuZnGaGeAsSeBrKrRbSrYZrNbMoTcRuRhPdAgCdInSnSbTeIXeCsBaLaCePrNdPmSmEuGdTbDyHoErTmYbLuHfTaWReOsIrPtAuHgTlPbBiPoAtRnFrRaAcThPaUNpPuAmCmBkCfEsFmMdNoLrRfDbSgBhHsMtDsRgCnUutFlUupLvUusUuo'):
 U=s.upper();X=lambda x:chr(32+sum(ord(u)-65for u in x))
 return re.findall('[A-Z][a-z]*',e)[zip(c[::2],c[1::2]).index((X(U[1::3]),X(U[:-1:2])))]

Here is the corresponding generator:
table = '''
H     Hydrogen
He    Helium
...
Uuo   Ununoctium
'''

table = map(lambda l: l.split(), table.split('\n')[1:-1])

abbr = []
for name in map(str.upper, zip(*table)[1]):
    abbr.append(chr(32+sum(ord(u)-65 for u in name[1::3]))+
                chr(32+sum(ord(u)-65 for u in name[:-1:2])))
print 'c=' + ''.join(abbr)
print 'e=' + ''.join(zip(*table)[0])
print 'Unique' if len(table) == len(set(abbr)) else 'Duplicates'

There's probably room for improvements, especially compressing the two long strings.
Tested with:
for short, name in table:
    if f(name) != short:
        print "Wrong result!"

CJam, 462 449 434 401 391 384 382
With help from Dennis.
Code
Nested ternary ifs are probably not the right way to do this in CJam.
rel_"ruthen"#!"Ru"{_"tel"#!"Te"{__5{\_ceu\@=+_}:U~"PdYbRgCmCn"{\#)!}:X~{;__4U"RnPaCfDs"X{;_3U"NbCsNdPmTbPtTlBkEsFmMdLrMt"X{;2U"MgClCrMnZnAsRbSrZrTcCdSmGdHfReAtNpPuDbBhHsLv"X{;__"sili"#{;__ceu\1=@2=++"SodIroCopSilTinAntThuGolMerLeaTunPotRutSeaHydBorCarNitOxyFluPhoSulVanYttIodUra"\#3d/m[)"_NaFeCuAgSnSbTmAuHgPbWKRfSgHBCNOFPSVYIU"S%\=_"_"={;_1U"Un"={;4="Uu"\+}*}*}"Si"?}*}*}*}*}?}?]W=

With indents:
rel
_"ruthen"#!"Ru"
{
_"tel"#!"Te"
{
  __5{\_ceu\@=+_}:U~
  "PdYbRgCmCn"{\#)!}:X~
  {
   ;__4U
   "RnPaCfDs"X
   {
    ;_3U
    "NbCsNdPmTbPtTlBkEsFmMdLrMt"X
    {
     ;2U
     "MgClCrMnZnAsRbSrZrTcCdSmGdHfReAtNpPuDbBhHsLv"X
     {

       ;__"sili"#
       {
        ;__ceu\1=@2=++"SodIroCopSilTinAntThuGolMerLeaTunPotRutSeaHydBorCarNitOxyFluPhoSulVanYttIodUra"\#3d/m[)"_ Na Fe Cu Ag Sn Sb Tm Au Hg Pb W K Rf Sg H B C N O F P S V Y I U"S%\=_"_"=
        {;_1U"Un"={;4="Uu"\+}*}*
       }
      "Si"?

     }*
    }*
   }*
  }*
 }?
}?
]W=

Many of the symbols are just the first two letters of the element's name. These are handled in the second-deepest layer of nested if statements. Many others are the first and third letter, or the first and fourth letter - these are handled in successive outer layers. Symbols where only the first letter appears, and complete irregulars, are handled in the fifth and third deepest layers respectively.
There are a few where it gets confused (TelLurium vs ThaLlium, or SILicon vs SILver, or RUThenium vs RUTherfordium). These are handled separately.
A lot of golfing could be done here, mostly by reusing code blocks and improving handling of irregulars.

A few tips: 1. Behavior for invalid element names may be undefined, so rather than "RUTHENIUM"= you can use "RUTHEN"#!. 2. You don't need to print explicitly (o) nor remove anything before the actual element name (;"Si"); just append ]W= to the end of your code to remove everything but the topmost stack element. 3. That makes a few block empty. If B is a Boolean, B{...}{}? and B{...}* achieve the same. 4. The ternary if takes blocks or stack elements, so you can shorten {"Si"} to "Si".

@Dennis I think I've added all of that in. The stack management needs work, though - too many _ and ; all over the place

@Dennis And I've shaved off a few characters by changing the default case to lowercase and by using the aliased code blocks more

PHP, 507 485 476 466 characters
Usage: enter the element name as GET parameter '0' - elements.php?0=carbon
Algorithm: Run through the data string, pulling out substring,abbreviation code pairs. If the substring matches the start of the element passed in, use the abbreviation code to determine what to output: If the code starts with a letter, output it as a string. If it is a number N, output the first letter of the element + the Nth letter. The Unun elements are special-cased with the code '|'. If no substring is found that matches the name passed in, output the first two characters of the name as the abbreviation.
Readable Code:
<?
$l=ucfirst(strtolower($_GET[0]));
for(
  $m[3]="AnSbArs2As2Berk3Boh2BoBCad2Cae3Cali4CarCChl2Ch2Cope5CopCuCu5Da4Du2Ei3Fe3FluFGad2GoAuHaf2Ha2HyHIo0IroFeLaw3LePbLiv2Mag2Man2Mei3Men3MeHgNeod3Nep2Nio3NiNOxOPa5PhPPla3Plu2PotKProm3Pro4Rado4Rhe2Roe5Rub2Ruther6Sa2Sea6SilvAgSoNaSt2SuSTec2Ter3Tha3Thu6TinSnTuWUn|UUVVYtte5YYZin2Z2";
  preg_match('/(.[a-z]*)(.[a-z]*)(.*)/',$m[3],$m)
;)
    if(strstr($l,$m[1]))
        echo($x=$m[2][0])>'@'?$x>'{'?"Uu$l[4]":$m[2]:$l[0].$l[$x],die;
echo$l[0],$l[1];

Condensed:
<?$l=ucfirst(strtolower($_GET[0]));for($m[3]="AnSbArs2As2Berk3Boh2BoBCad2Cae3Cali4CarCChl2Ch2Cope5CopCuCu5Da4Du2Ei3Fe3FluFGad2GoAuHaf2Ha2HyHIo0IroFeLaw3LePbLiv2Mag2Man2Mei3Men3MeHgNeod3Nep2Nio3NiNOxOPa5PhPPla3Plu2PotKProm3Pro4Rado4Rhe2Roe5Rub2Ruther6Sa2Sea6SilvAgSoNaSt2SuSTec2Ter3Tha3Thu6TinSnTuWUn|UUVVYtte5YYZin2Z2";preg_match('/(.[a-z]*)(.[a-z]*)(.*)/',$m[3],$m);)if(strstr($l,$m[1]))echo($x=$m[2][0])>'@'?$x>'{'?"Uu$l[4]":$m[2]:$l[0].$l[$x],die;echo$l[0],$l[1];

05AB1E, 121 117 112 110 109 bytes
•S²c¾rƒã∞Øø”.ÑSZl›¹'•2в°T•2nZιć‹ε˜Órv†„₃}Z$+àFQ$•7в1.•®DÝ∍ÌoƵižÒƵaŒ•2ô.;.;6ÝIS¬ì:slƵ{ö•X»²ÄµÕΛεĀδkM•9ävy%}èÙ™

Try it online! or validate all test cases.

Golfscript - 1052 821
{.91<32*+}%:x;'H
He
Li
Be
B
C
N
F
Ne
Na
Mg
Al
Si
P
S
Cl
Ar
K
Ca
Sc
Ti
V
Cr
Mn
Fe
Co
Ni
Cu
Zn
Ga
Ge
As
Se
Br
Kr
Rb
Sr
Y
Zr
Nb
Mo
Tc
Ru
Rh
Pd
Ag
Cd
In
Sn
Sb
Te
I
Xe
Cs
Ba
La
Ce
Pr
Nd
Pm
Sm
Eu
Gd
Tb
Dy
Ho
Er
Tm
Yb
Lu
Hf
Ta
W
Re
Os
Ir
Pt
Au
Hg
Tl
Pb
Bi
Po
At
Rn
Fr
Ra
Ac
Th
Pa
U
Np
Pu
Am
Cm
Bk
Cf
Es
Fm
Md
No
Lr
Rf
Db
Sg
Bh
Hs
Mt
Ds
Rg
Cn
Uut
Fl
Uup
Lv
Uus'n/'hy
he
lit
bery
bor
car
nit
flu
neon
so
mag
al
sili
ph
su
chl
arg
pot
calc
sc
tit
v
chr
man
iro
cob
nic
copp
zin
gal
ge
ars
sel
br
k
rub
st
yttr
zir
nio
mo
tec
ruthen
rho
pa
silv
cad
in
tin
an
tel
io
x
cae
ba
lan
ce
pra
neod
prom
sa
eu
gad
ter
dy
ho
er
thu
ytte
lu
haf
ta
tu
rhe
os
iri
pla
go
mer
tha
le
bi
pol
as
rado
fr
radi
ac
tho
prot
ur
nep
plu
am
cu
berk
cali
ei
fe
men
no
law
ruther
du
sea
boh
has
mei
da
ro
cope
ununt
fle
ununp
liv
ununs
ununo'n/[{x\?)}/]1?=

Explanation:
{        }%                              Map these ops to the input string:
 .91<32*+                                   Add 32 if less than 91 (convert to lowercase, in essence)
           :x;                           Store to x.
              '...'  '...'               The first array is the symbols, the second is the names.
                                         (stripped down to the minimum necessary)
                   n/     n/             Convert them to arrays.
                             {    }/     For each element in the name array...
                              x\?)          ...return 1 if the element is found in the input.
                            [       ]    Gather every element in an array...
                                     1?  Find the 1 in the array (the only element name match)...
                                       = ...then return that symbol in the symbol array.
                               (implied) Print.

OMG, A piece of Golfscript that isn't 10 characters or less!

You can get a massive improvement to that array of strings by using one string with newline as the separator and then doing n/

I did that last time, why the heck didn't I think of that? Updating now.

JavaScript (1100)
Naive implementation shining in its simplicity. Unique sub string from the start of the name is simply mapped to symbol.
e={hy:"H",he:"He",lit:"Li",bery:"Be",bor:"B",car:"C",nit:"N",ox:"O",flu:"F",neon:"Ne",so:"Na",mag:"Mg",al:"Al",sili:"Si",ph:"P",su:"S",chl:"Cl",arg:"Ar",pot:"K",calc:"Ca",sc:"Sc",tit:"Ti",v:"V",chr:"Cr",man:"Mn",iro:"Fe",cob:"Co",nic:"Ni",copp:"Cu",zin:"Zn",gal:"Ga",ge:"Ge",ars:"As",sel:"Se",br:"Br",k:"Kr",rub:"Rb",st:"Sr",yttr:"Y",zir:"Zr",nio:"Nb",mo:"Mo",tec:"Tc",ruthen:"Ru",rho:"Rh",pa:"Pd",silv:"Ag",cad:"Cd",in:"In",tin:"Sn",an:"Sb",tel:"Te",io:"I",x:"Xe",cae:"Cs",ba:"Ba",lan:"La",ce:"Ce",pra:"Pr",neod:"Nd",prom:"Pm",sa:"Sm",eu:"Eu",gad:"Gd",ter:"Tb",dy:"Dy",ho:"Ho",er:"Er",thu:"Tm",ytte:"Yb",lu:"Lu",haf:"Hf",ta:"Ta",tu:"W",rhe:"Re",os:"Os",iri:"Ir",pla:"Pt",go:"Au",mer:"Hg",tha:"Tl",le:"Pb",bi:"Bi",pol:"Po",as:"At",rado:"Rn",fr:"Fr",radi:"Ra",ac:"Ac",tho:"Th",prot:"Pa",ur:"U",nep:"Np",plu:"Pu",am:"Am",cu:"Cm",berk:"Bk",cali:"Cf",ei:"Es",fe:"Fm",men:"Md",no:"No",law:"Lr",ruther:"Rf",du:"Db",sea:"Sg",boh:"Bh",has:"Hs",mei:"Mt",da:"Ds",ro:"Rg",cope:"Cn",ununt:"Uut",fle:"Fl",ununp:"Uup",liv:"Lv",ununs:"Uus",ununo:"Uuo"}
n=prompt().toLowerCase()
for(i in e)n.indexOf(i)?i:alert(e[i])

C# (826)
not the greatest but I thought I'd try it with the handicap of c#.
using System;class P{static string s="HyHHe1Li1Be1BoBCaCNitNOxOFlFNe1SoNaMaMgAl1Sil1PhPSuSChClAr1PotKCal1Sc1Tit1VaVChrCrManMnIrFeCo1Ni1CopCuZiZnGa1Ge1ArsAsSe1Br1Kr1RuRbStSrYtYZirZrNioNbMo1TecTcRut1Rh1PaPdSiAgCadCdIn1TiSnAnSbTel1IoIXe1CaeCsBa1La1Ce1Pra1NeoNdPrPmSaSmEu1GadGdTeTbDy1Ho1Er1ThTmYttYbLu1HaHfTa1TuWRheReOs1Iri1PlPtGoAuMeHgThaTlLePbBi1Po1AsAtRaRnFr1Rad1Ac1Tho1ProPaUrUNepNpPluPuAm1CuCmBerBkCaliCfEiEsFeFmMenMdNo1LawLrRuthRfDuDbSeaSgBohBhHasHsMeiMtDaDsRoRgCopeCnUnUutFle1UnuUupLivLvUnunUus",n,t,k;static void Main(){var d=new System.Collections.Specialized.StringDictionary();while(s!=""){k=g;d[k]=g;if(d[k]=="1")d[k]=k.Substring(0,2);};t=Console.ReadLine();while(t!=""&!d.ContainsKey(t))t=t.Remove(t.Length-1);Console.Write(d[t]);}static string g{get{n="";do n+=s[0];while((s=s.Remove(0,1))!=""&&s[0]>96);return n;}}}

So I wrote a program to turn the full name of elements (e.g. carbon) in to the smallest but still unique string possible and did this for all elements with respect to all the other unique strings. I then serialized that in to a big ugly string where capital letters denote the start of "chunks", with chunks alternating between being keys and values. Like KeyValueKey2Value2 etc.
This script desterilizes that big string and cuts a character off the end of the inputted string until it finds it in the dictionary made from the big string.
(I should add my knowledge of C# isn't amazing and the original submission I made was just using things I knew but I've subsequently had some tricks pointed out to me by others.)

You can golf this further by changing all type definitions to var. You can save a few more by removing braces after single-statement if blocks. If you assign t.Substring(int, int) to a Func<int, int, string> you can save another couple.

I made most variable defs "var" but seems I missed one or two, also totally forgot about bracketless ifs, thanks.

You can shave a further 5 characters by varing the string[] r and a further 3 by varing the string t = Console...., lastly, you'll save 7 more by changing return new string[] into return new[] at the very end.

There are a handful of other minor improvements that you can perform such as moving your if(...) break; logic into the for loop exit conditions. A number of other logic inversions can be applied, such as a do { } while(..) in your extraction method. This is shorter than adding a separate logical operation for the entry case. I have posted an edit to your code that still needs review / acceptance due to my low rep on this site. Got it down to 870 characters.

@Nicholas I'm not sure editing someone else's code golf is polite...

Well it was either that or posting a new answer with a slightly modified version of the OP. Meta Site doesn't exactly give clear guidelines on whether or not we should comment, edit, or post new answers in this case. I assumed the OP could reject improvement edits if he/she does not like or want them.

Haskell, 920 817 807 776 Chars
After working far too long creating a system of rules for what characters of an elements name are included in its symbol, and a bit of tinkering, I managed to write a script that translates element to symbol easily. Iron was a problem for me, because I could sample certain characters from GOld, SilVer, TiN, LEad, SoDium, MerCury, ANtimony, PotaSsium, and TUngsten, converting them to an unused periodic symbol (I chose whichever sampling made it simplest to integrate them into the existing rules), and then translating after symbolic conversion; Iron, however, was a problem, because Ir, Io, and In are all used already. This was initially 920 characters, but I realized that the final pattern match (the largest) didn't need to be there, as it either let things drop through (which it didn't) or matched all of them; therefore, I replaced it with a catch-all wildcard. After that, I further golfed from 817 to 808 by abbreviating some patterns using wild-cards in such a way that they were still unique to that element name (e.g. the only element with a 'w' in its name is Lawrencium, so "*w" matches that in 1 less character than "Law").
Here is my code. I tested it for all of the elements, and I coded it so that it automatically converted its input to titlecase, so no issues with case sensitivity.
EDIT 1
I further reduced it to 776 characters by replacing the case expression in t with a pattern match (this makes sense because the case expression was testing the raw operand as opposed to an expression in terms of the operand), removing unnecessary parentheses, and re-expressing e as a newline-delimited string instead of a list of strings, and later splitting it in the main function. Because these changes are purely golfing, I have left the human-readable version unchanged.
import Data.Char
m _[]=True;m[]_=False;m k@(c:s)x@(y:z)=case y of{']'->m s x;'['->let(i,(_:j))=break(==']')z in(c`elem`i)&&m s j;'?'->m s z;'*'->null z||m k z||m s z||m s x;_->c==y&&m s z};p(a:t)(x:y)=case a of{'.'->x:p t y;'_'->p t y;_->a:p t y};p[]_=[];e="Iro\nUn\nCu Pa Ro Y*e\nR*r\n*pp\nCop Rado\nSea Thu\nCali Da P*ot Tha\nA*s Boh ?ub Ch [CG]ad [HM]a Liv Nep Plu Rhe S[ato] Tec Tin Z\nB*k Cae [ES]i *w Nio [FM]e N*d Pro Pla Ter\nBor Car Flu Hy Io Nit Ox Ph Su [UVY]\n*";s="Fe ._._. .____. .f .u .n ._____. .___. ._. .__. . ..";t"Sv"="Ag";t"Sd"="Na";t"Go"="Au";t"Le"="Pb";t"Mc"="Hg";t"An"="Sb";t"Ps"="K";t"Tu"="W";t"Tn"="Sn";t x=x;main=interact$unlines.map(\(a:b)->let y=toUpper a:map toLower b in t$p(snd.head.filter(any(m y).fst)$zip(map words$lines e)$words s)y).lines

Human-Readable Version (newlines, spacing, verbose names, comments: 2311 Chars)
import Data.Char

-- Test against search-pattern strings
match _ [] = True
match [] _ = False
match k@(c:s) x@(y:z) = case y of
']' -> match s x
'[' -> let (i,(_:j)) = break (==']') z in (c `elem` i) && match s j
'?' -> match s z
'*' -> null z || match k z || match s z || match s x
 _  -> c == y && match s z

-- Write according to name-pattern string
pattern (a:t) (x:y) = case a of
'.' -> x : (pattern t y)
'_' -> (pattern t y)
 _  -> a : (pattern t y)
pattern [] _ = []

-- Search-Patterns for the elements
elements=["Iro", -- Iron -> Fe
      "Un", -- UnUn-Blank-ium (1,3,5)
      "Cu Pa Ro Y*e", -- CuriuM PallaDium RoentGenium YtterBium (1,6)
      "R*r", -- Rutherfordium (1,f)
      "*pp", -- Copper (1,u)
      "Cop Rado", -- Copernicium Radon (1,n)
      "Sea Thu", -- SeaborGium ThuliuM (1,7)
      "Cali Da P*ot Tha", -- CaliFornium DarmStadtium ProtActinium PotaSsium (1,5)

      {- AsTatine ArSenic BoHrium DuBnium RuBidium ChLorine ChRome CaDmium
      GaDolinium HaFnium HaSsium MaNganese MaGnesium LiVermorium NePtunium
      PlUtonium RhEnium SaMarium StRontium SoDium TeChnetium TiN ZiNc
      ZiRconium (1,3) -}

      "A*s Boh ?ub Ch [CG]ad [HM]a Liv Nep Plu Rhe S[ato] Tec Tin Z",

      {- BerKelium CaeSium EinSteinum SilIcon SilVer LawRencium NioBium
      FerMium MenDelevium MeiTnerium MerCury NeoDymium ProMethium PlaTinum
      TerBium (1,4) -}

      "B*k Cae [ES]i *w Nio [FM]e N*d Pro Pl Ter",

      {- Boron Carbon Fluorine Hydrogen Nitrogen Oxygen Phosphorous Sulphur
      Uranium Vanadium Yttrium (1) -}

      "Bor Car Flu Hy Io Nit Ox Ph Su [UVY]",
      "*"] -- Everything else (1,2)

-- respective naming patterns for searches
symbol = "Fe ._._. .____. .f .u .n ._____. .___. ._. .__. . .."

-- Translate fake symbols
translate x = case x of
"Sv" -> "Ag" -- SilVer
"Sd" -> "Na" -- SoDium
"Go" -> "Au" -- GOld
"Le" -> "Pb" -- LEad
"Mc" -> "Hg" -- MerCury
"An" -> "Sb" -- ANtimony
"Ps" -> "K" -- PotaSsium
"Tu" -> "W" -- TUngsten
"Tn" -> "Sn" -- TiN
  _  -> x  -- Keep everything else the same

main = interact $ unlines . map (\(a:b) -> let y = (toUpper a) : (map toLower b) in t $ p (snd.head.filter (any (m y) . fst) $ zip (map words e) $ words s) $ y) . lines

If anyone is interested in an explanation for any part of this, feel free to ask.

JavaScript (E6) 1433
Here is un upper limit
F=n=>'0H0HYDROGEN0He0HELIUM0Li0LITHIUM0Be0BERYLLIUM0B0BORON0C0CARBON0N0NITROGEN0O0OXYGEN0F0FLUORINE0Ne0NEON0Na0SODIUM0Mg0MAGNESIUM0Al0ALUMINIUM0Si0SILICON0P0PHOSPHORUS0S0SULFUR0Cl0CHLORINE0Ar0ARGON0K0POTASSIUM0Ca0CALCIUM0Sc0SCANDIUM0Ti0TITANIUM0V0VANADIUM0Cr0CHROMIUM0Mn0MANGANESE0Fe0IRON0Co0COBALT0Ni0NICKEL0Cu0COPPER0Zn0ZINC0Ga0GALLIUM0Ge0GERMANIUM0As0ARSENIC0Se0SELENIUM0Br0BROMINE0Kr0KRYPTON0Rb0RUBIDIUM0Sr0STRONTIUM0Y0YTTRIUM0Zr0ZIRCONIUM0Nb0NIOBIUM0Mo0MOLYBDENUM0Tc0TECHNETIUM0Ru0RUTHENIUM0Rh0RHODIUM0Pd0PALLADIUM0Ag0SILVER0Cd0CADMIUM0In0INDIUM0Sn0TIN0Sb0ANTIMONY0Te0TELLURIUM0I0IODINE0Xe0XENON0Cs0CAESIUM0Ba0BARIUM0La0LANTHANUM0Ce0CERIUM0Pr0PRASEODYMIUM0Nd0NEODYMIUM0Pm0PROMETHIUM0Sm0SAMARIUM0Eu0EUROPIUM0Gd0GADOLINIUM0Tb0TERBIUM0Dy0DYSPROSIUM0Ho0HOLMIUM0Er0ERBIUM0Tm0THULIUM0Yb0YTTERBIUM0Lu0LUTETIUM0Hf0HAFNIUM0Ta0TANTALUM0W0TUNGSTEN0Re0RHENIUM0Os0OSMIUM0Ir0IRIDIUM0Pt0PLATINUM0Au0GOLD0Hg0MERCURY0Tl0THALLIUM0Pb0LEAD0Bi0BISMUTH0Po0POLONIUM0At0ASTATINE0Rn0RADON0Fr0FRANCIUM0Ra0RADIUM0Ac0ACTINIUM0Th0THORIUM0Pa0PROTACTINIUM0U0URANIUM0Np0NEPTUNIUM0Pu0PLUTONIUM0Am0AMERICIUM0Cm0CURIUM0Bk0BERKELIUM0Cf0CALIFORNIUM0Es0EINSTEINIUM0Fm0FERMIUM0Md0MENDELEVIUM0No0NOBELIUM0Lr0LAWRENCIUM0Rf0RUTHERFORDIUM0Db0DUBNIUM0Sg0SEABORGIUM0Bh0BOHRIUM0Hs0HASSIUM0Mt0MEITNERIUM0Ds0DARMSTADTIUM0Rg0ROENTGENIUM0Cn0COPERNICIUM0Uut0UNUNTRIUM0Fl0FLEROVIUM0Uup0UNUNPENTIUM0Lv0LIVERMORIUM0Uus0UNUNSEPTIUM0Uuo0UNUNOCTIUM'
.match(RegExp('([^0]+)0+'+n,'i'))[1]

Test in FireFox/FireBug console
F('Rutherfordium')

Output
Rf

SmileBASIC, 1763 1418 1204 1128 bytes
INPUT E$Hro$="H
Hiu$="He
Lhi$="Li
Byl$="Be
Bon$="B
Cbo$="C
Nro$="N
Oge$="O
For$="F
Nn$="Ne
Siu$="Na
Mne$="Mg
Ami$="Al
Sic$="Si
Psp$="P
Sfu$="S
Cor$="Cl
Aon$="Ar
Pas$="K
Cci$="Ca
Snd$="Sc
Tan$="Ti
Vad$="V
Com$="Cr
Mga$="Mn
In$="Fe
Cal$="Co
Nke$="Ni
Cpe$="Cu
Zc$="Zn
Gli$="Ga
Gma$="Ge
Aen$="As
Sen$="Se
Bmi$="Br
Kpt$="Kr
Rid$="Rb
Son$="Sr
Yri$="Y
Zco$="Zr
Nbi$="Nb
Myb$="Mo
Thn$="Tc
Rhe$="Ru
Rdi$="Rh
Pla$="Pd
Sve$="Ag
Cmi$="Cd
Iiu$="In
T$="Sn
Aim$="Sb
Tlu$="Te
Iin$="I
Xon$="Xe
Csi$="Cs
Biu$="Ba
Lth$="La
Pse$="Pr
Ndy$="Nd
Pme$="Pm
Sar$="Sm
Eop$="Eu
Gol$="Gd
Tbi$="Tb
Dpr$="Dy
Hmi$="Ho
Eiu$="Er
Tli$="Tm
Yer$="Yb
Let$="Lu
Hni$="Hf
Tta$="Ta
Tgs$="W
Rni$="Re
Oiu$="Os
Idi$="Ir
Pti$="Pt
Gd$="Au
Mcu$="Hg
Tll$="Tl
Ld$="Pb
Bmu$="Bi
Pon$="Po
Aat$="At
Ron$="Rn
Fnc$="Fr
Riu$="Ra
Ain$="Ac
Tri$="Th
Pta$="Pa
Uni$="U
Ntu$="Np
Pto$="Pu
Ari$="Am
Ciu$="Cm
Bke$="Bk
Cif$="Cf
Est$="Es
Fmi$="Fm
Mde$="Md
Nel$="No
Lre$="Lr
Dni$="Db
Sbo$="Sg
Bri$="Bh
Hsi$="Hs
Mtn$="Mt
Dms$="Ds
Rnt$="Rg
Cer$="Cn
Unt$="Uut
Fro$="Fl
Unp$="Uup
Ler$="Lv
Uns$="Uus
Uno$="Uuo
S$=VAR(E$[0]+MID$(E$,3,2))IF"Cm"==S$*!VAL(".1"+E$[1])THEN S$="Ce
IF LEN(E$)>12THEN S$="Rf
?S$

I chose 3 characters which were mostly unique (the 0th, 2nd, and 3rd), which leaves 2 special cases: Cerium/Curium are both "Ciu", and Ruthenium/Rutherfordium are both "Rhe". For Ciu, I check if the second character of the name is "e" or "E", and for "Rhe", I check the length of the name.
VAR(name) returns the variable with that name. Variable names are case insensitive.

Retina, 291 286 276 bytes
.*
$u
Pot
K
op
u
Iro
Fe
Silv
Ag
Tin
Sn
0L`.*f|[RS].*g|[CGP]a.*d|(As|Ch|G|Law|Ma|Me.|Pla?|Prot?|Rado|St|Tha|Unun|Zi).|Flu|N[ei]o?[bdpt]|[ACEH].*s|[BDLRST].[bcehmv]|..+r[bkmn]s?|[CT]h?u.*m|..
\B.*\B

T`l``[FHKNOSVY][at-y]|Cb|Bo|Io|Ph|Ur
So
Na
An
Sb
Tu
W
Go
Au
Mc
Hg
Le
Pb
U.
U$l

Try it online!
Verification script (Python)
Explanation
.*
$u

Convert the first letter of the input to uppercase and the rest to lowercase.
0L`.*f|[RS].*g|[CGP]a.*d|(As|Ch|G|Law|Ma|Me.|Pla?|Prot?|Rado|St|Tha|Unun|Zi).|Flu|N[ei]o?[bdpt]|[ACEH].*s|[BDLRST].[bcehmv]|..+r[bkmn]s?|[CT]h?u.*m|..

Truncate each element name, ending with the intended second letter. The default case .. matches the first two letters of the element name.
\B.*\B

Keep only the first and last letter.
T`l``[FHKNOSVY][at-y]|Cb|Bo|Io|Ph|Ur

Remove the lowercase letters from the single-letter abbreviations.
U.
U$l

Insert the u for the elements that require it.

The rest of the program deals with various special-case replacements. Some of these occur before the main regex because those elements share their first two letters with another.

T-SQL, 900 894 676 bytes
SELECT ISNULL((SELECT LEFT(value,3)FROM
STRING_SPLIT('Sb An-As Ars-At Ast-Bk Berk-Bh Boh-B  Bor-Cd Cad-Cs Cae-Cf Cali-C  Car-Cl Chl-Cr Chr-Cn Cope-Cu Copp-Cm Cu-Ds Da-Db Du-Es Ei-Fm Fe-F  Flu-Gd Gad-Au Go-Hf Haf-Hs Has-H  Hy-I  Io-Fe Iro-Lr Law-Pb Le-Lv Liv-Mg Mag-Mn Man-Mt Mei-Md Men-Hg Mer-Nd Neod-Np Nep-Nb Nio-N  Nit-O  Ox-Pd Pa-P  Ph-Pt Pla-Pu Plu-K  Pot-Pm Prom-Pa Prot-Rn Rado-Re Rhe-Rg Ro-Rb Rub-Rf Ruther-Sm Sa-Sg Sea-Ag Silv-Na So-Sr St-S  Su-Tc Tec-Tb Ter-Tl Tha-Tm Thu-Sn Tin-W  Tu-UuoUnuno-UupUnunp-UusUnuns-UutUnunt-U  Ur-V  V-Yb Ytte-Y  Yttr-Zn Zin-Zr Zir'
    ,'-')m,t WHERE e LIKE SUBSTRING(value,4,9)+'%'),
(SELECT UPPER(LEFT(e,1))+LOWER(SUBSTRING(e,2,1))FROM t))

Returns are for readability only, the second line is one very long string.
STRING_SPLIT is supported in SQL 2016 and higher.
Input is taken via a pre-existing table t with varchar field e, per our IO standards. Output is padded with spaces to 3 characters; the rules were unclear on whether that was ok. If necessary, I can add a TRIM.
The input table is joined with a table generated with a list of all element symbols (padded to 3 characters) with the shortest unique prefix for each element name (X is sufficient for Xenon, but Rutherfordium requires Ruther to distinguish it from Ruthenium).
EDIT 1: Saved 218 characters by removing the 44 entries from the list whose symbol is the first two letters of their name; the ISNULL function is used to see if the first query fails to return a row, and if so, generates the symbol (properly cased) from the input element name.


text:
2D Collision Detection
This challenge is based on actual collision detection I had to write for a simple game recently.
Write a program or function which, given two objects, returns a truthy or falsy value depending on whether the two objects are in collision (i.e. intersect) or not.
You need to support three types of objects:

Line segments: represented by 4 floats, indicating the two endpoints, i.e. (x1,y1) and (x2,y2). You may assume that the endpoints are not identical (so the line segment is not degenerate).
Discs: i.e. filled circles, represented by 3 floats, two for the centre (x,y) and one (positive) for the radius r.
Cavities: these are a disc's complement. That is, a cavity fills all of 2D space, except a circular region, specified by a centre and radius.

Your program or function will receive two such objects in the form of an identifying integer (of your choice) and their 3 or 4 floats. You can take input via STDIN, ARGV or function argument. You may represent the input in any convenient form that is not preprocessed, e.g. 8 to 10 individual numbers, two comma-separated list of values or two lists. The result can be returned or written to STDOUT.
You may assume that the objects are either at least 10-10 length units apart or intersect by that much, so you don't need to worry about the limitations of floating point types.
This is code golf, so the shortest answer (in bytes) wins.
Test Cases
Representing line segments with 0, discs with 1 and cavities with 2, using a list-based input format, the following should all produce a truthy output:
[0,[0,0],[2,2]], [0,[1,0],[2,4]]        # Crossing line segments
[0,[0.5,0],[-0.5,0]], [1,[0,0],1]       # Line contained in a disc
[0,[0.5,0],[1.5,0]], [1,[0,0],1]        # Line partially within disc
[0,[-1.5,0.5],[1.5,0.5]], [1,[0,0],1]   # Line cutting through disc
[0,[0.5,2],[-0.5,2]], [2,[0,0],1]       # Line outside cavity
[0,[0.5,0],[1.5,0]], [2,[0,0],1]        # Line partially outside cavity
[0,[-1.5,0.5],[1.5,0.5]], [2,[0,0],1]   # Line cutting through cavity
[1,[0,0],1], [1,[0,0],2]                # Disc contained within another
[1,[0,0],1.1], [1,[2,0],1.1]            # Intersecting discs
[1,[3,0],1], [2,[0,0],1]                # Disc outside cavity
[1,[1,0],0.1], [2,[0,0],1]              # Disc partially outside cavity
[1,[0,0],2], [2,[0,0],1]                # Disc encircling cavity
[2,[0,0],1], [2,[0,0],1]                # Any two cavities intersect
[2,[-1,0],1], [2,[1,0],1]               # Any two cavities intersect

while the following should all result in a falsy output
[0,[0,0],[1,0]], [0,[0,1],[1,1]]        # Parallel lines
[0,[-2,0],[-1,0]], [0,[1,0],[2,0]]      # Collinear non-overlapping lines
[0,[0,0],[2,0]], [0,[1,1],[1,2]]        # Intersection outside one segment
[0,[0,0],[1,0]], [0,[2,1],[2,3]]        # Intersection outside both segments
[0,[-1,2],[1,2]], [1,[0,0],1]           # Line passes outside disc
[0,[2,0],[3,0]], [1,[0,0],1]            # Circle lies outside segment
[0,[-0.5,0.5],[0.5,-0.5]], [2,[0,0],1]  # Line inside cavity
[1,[-1,0],1], [1,[1,1],0.5]             # Non-intersecting circles
[1,[0.5,0],0.1], [2,[0,0],1]            # Circle contained within cavity

Trickier than I thought at first. Starting with the line/line case, I come upon a surprising number of edge cases. Couldn't you disallow collinear segments? Would make things much easier. ;)

@Emil Sorry, but 9 hours after posting, I'll have to assume that others might have started working on the challenge, and changing the spec (apart from fixing breaking problems) doesn't seem like a good idea to me. Depending on how you do it, parallel line segments should be the only edge case you need to worry about for the line-line collisions, though, I think.

Sure, I wasn't really expecting you change it. I was just a tiny bit frustrated that handling the different variants of collinear line segments doubled the length of my code so far. :) (A great challenge, by the way!)

Doesn't collinear points fall under "doesn't collide by 10^-10"?

@TwiNight Not if the two lines are collinear but don't overlap. E.g. [0,[-2,0],[-1,0]], [0,[1,0],[2,0]]

In short, we can assume parallel lines (collinear or not) to be non-colliding?

@TwiNight Yes, that's fine.

I asked just out of curiosity, as my approach was not solving linear equations, but I later found out that not only do I have to use linear equations but I also have to correctly handle collinear points......

Can we use polymorphism to represent the shapes? As in, data Shape = Line Pt Pt | Circle Pt double | Cavity Pt double; collide :: Shape -> Shape -> Bool?

@JanDvorak I have no clue what syntax this is, but yes, you may use polymorphism.

@MartinBüttner that's a Haskell type declaration. A Shape is either a Line defined by two points, a Circle defined by a point and a number, or a Cavity defined by a point and a number. The collide function takes two Shapes and returns a Boolean.

I assume two cavities always intersect?

@JanDvorak Yes, see the last two truthy examples ;)

A plane-with-cavity intersection might be interesting in 4D. Intersect the planes => if they intersect at a point (the general case), check if the point lies within the cavity of at least one plane.

APL, 279 208 206 203
s←1 ¯1
f←{x←⊣/¨z←⍺⍵[⍋⊣/¨⍺⍵]
2 2≡x:∧/0∧.=⌊(2⊃-⌿↑z)⌹⍣(≠.×∘⌽/x)⍉↑x←s×-/2⊢/↑z
2≡2⌷x:∨/((2⊃z)∇2,x[1]×(2⌷⊃z)+,∘-⍨⊂y÷.5*⍨+.×⍨y←⌽s×⊃-/y),x[1]=(×⍨3⊃⊃z)>+.×⍨¨y←(s↓⌽↑z)-2⌷⊃z
~x∨.∧x[1]≠(.5*⍨+.×⍨2⊃-⌿↑z)<-/⊢/¨z×s*1⌷x}

Line breaks in the function f are for clarity. They should be replaced with the statement separator ⋄
It has been so long since I last made such a complex APL program. I think the last time was this but I am not even sure that was as complex.
Input format
Basically same as the OP, except using 0 for cavity, 1 for disc and 2 for line segment.
Major update
I managed to golf a lot of chars using a different algorithm. No more g bulls**t!!
The main function f is divided into cases:

2 2≡x: Segment-segment
In this case, calculate the vector from the end points of each line and solve a system of linear equations to check if the intersection is contained within the vectors.
Caveats:

The end point of a vector is not considered as a part of the vector (while its origin is). However, if only the tip of a vector is on the other one, the input is invalid according to spec.
Non-degenerate parallel segments always returns false, regardless of collinearity.
If one of the segments is degenerate, always return false. If both segments are degenerate, always return true.

Examples: (Note caveat 1 in action in the figure on the right)

2≡2⌷x: Segment-other
In this case, the other object is a circular one. Check if the end points of the segment is within the circle using distance check.
In the disc case, also construct a line segment of the diameter perpendicular to the given segment. Check if the segments collide by recursion.
In the cavity case, sneak in a "times 0" in the construction of the said segment to make it degenerate. (See why I use 0 for cavity and 1 for disc now?) As the given segment is not degenerate, the segment-segment collision detection always return false.
Finally combine the results of the distance checks and the collision detection. For the cavity case, negate the results of the distance checks first. Then (in both cases) OR the 3 results together.
Regarding the segment-segment caveats, numbers 3 is addressed (and exploited). Number 2 is not a problems as we are intersecting perpendicular segments here, which are never parallel if they are not degenerate. Number 1 takes effect only in the disc case, when one of the given end points is on the constructed diameter. If the end point is well inside the circle, the distance checks would have taken care of it. If the end point is on the circle, since the constructed diameter is parallel to the given segment, the latter must be tangent to the circle with only one point touching the disc, which is not valid input.
Examples:

Default case: Other-other
Calculate the distance between the centers. Disc-disc collision occurs if and only if the distance is smaller than the sum of radii. Disc-cavity collision occurs if and only if the distance is greater than the difference in radii.
To take care of the cavity-cavity case, negate the result of the distance check, AND with each of the identifying integers and then OR them together. Using some logic, one can show that this process returns true if and only if both identifying integers are falsy (Cavity-cavity case), or if the distance check returned true

My understanding is that if your program is written using characters that span Unicode rather than ASCII, the byte count needs to acknowledge the 2-bytes-per-character nature of Unicode.

@COTO I did not specify Unicode. As far as I'm aware, the APL character set does fit into a byte, and there are single-byte code pages which contain all the APL characters, so using that encoding, the byte count is fine. The counting by bytes is mostly relevant for people who encoding stuff in multi-byte strings in "normal" languages, or who use Mathematica's Unicode shortcuts.

@MartinBüttner: So you're saying that even though nobody could reasonably or practically represent the 1-byte-per-char version of the string in any text editor besides one explicitly designed for APL, it counts as 1-byte-per-char because there are 256 or fewer allowed characters in the language spec?

@COTO Well and because encodings do exist according to which a single-byte encoded file could be interpreted. I don't think I'd be willing to go down that route if people had to make up their encoding. Otherwise any program that uses less than 257 distinct characters could claim that (which would be almost any answer on PPCG, I think). I just think we shouldn't penalise APL for predating Unicoding by several decades - back then it made sense to interpret the bytes you had as weird funky characters that work as mnemonics.

@MartinBüttner: I guess if it's a legacy thing. sigh I'd like to win at least one of these challenges without being undercut by some useless-but-for-code-golf gibberish languages. :(

@COTO There's J, which is based on APL and uses only ASCII characters. They usually score similarly, so that would probably beat you as well, even if scored by Unicode. And I should add that neither language was designed for golfing, and AFAIK both are actually used professionally. And the golfing challenges here aren't so much about getting the green checkmark, but more about squeezing every last little byte out of your program with your language's means and beating everyone in the same "weight category", which will usually earn you more upvotes than using a terse language anyway. ;)

Yeah, I know. I was just hoping to win this one. But thanks for being the voice of reason. ;)

@COTO I would say this is choosing the right language for the job, APL has a LOT of vector ops built-in. But without trying I would guess Mathematica or Matlab would beat me. btw golfing APL for Unicode bytes would most likely result in a completely different algorithm

Javascript - 393 bytes
Minified:
F=(s,a,t,b,e,x)=>(x=e||F(t,b,s,a,1),[A,B]=a,[C,D]=b,r=(p,l)=>([g,h]=l,[f,i]=y(h,g),[j,k]=y(p,g),m=Math.sqrt(f*f+i*i),[(f*j+i*k)/m,(f*k-i*j)/m]),u=(p,c)=>([f,g]=c,[i,j]=y(p,f),i*i+j*j<g*g),y=(p,c)=>[p[0]-c[0],p[1]-c[1]],[n,o]=r(C,a),[q,v]=r(D,a),w=(v*n-o*q)/(v-o),z=r(B,a)[0],Y=u(A,b),Z=u(B,b),[v*o<0&&w*(w-z)<0,Y||Z||o<D&&o>-D&&n*(n-z)<0,!Y||!Z,x,u(A,[C,D+B]),B>D||!u(A,[C,D-B]),x,x,1][s*3+t])

Expanded:
F = (s,a,t,b,e,x) => (
    x = e || F(t,b,s,a,1),
    [A,B] = a,
    [C,D] = b,
    r = (p,l) => (
        [g,h] = l,
        [f,i] = y(h,g),
        [j,k] = y(p,g),
        m = Math.sqrt( f*f + i*i ),
        [(f*j + i*k)/m, (f*k - i*j)/m] ),
    u = (p,c) => (
        [f,g] = c,
        [i,j] = y(p,f),
        i*i + j*j < g*g ),
    y = (p,c) => [p[0] - c[0], p[1] - c[1]],
    [n,o] = r(C,a),
    [q,v] = r(D,a),
    w = (v*n - o*q)/(v - o),
    z = r(B,a)[0],
    Y = u(A,b), Z = u(B,b),
    [   v*o < 0 && w*(w-z) < 0,
        Y || Z || o < D && o > -D && n*(n-z) < 0,
        !Y || !Z,
        x,
        u(A,[C,D+B]),
        B > D || !u(A,[C,D-B]),
        x,
        x,
        1
    ][s*3+t]);

Notes:

defines function F that accepts the required arguments and returns the required value
input format is identical to format in the OP, with the exception that the integer type code for each primitive is separate from the tuple. For example, F( 0,[[0,0],[2,2]], 0,[[1,0],[2,4]] ) or F( 1,[[3,0],1], 2,[[0,0],1] ).
code validated on all test cases supplied in the OP
should handle all edge and corner cases, including zero-length line segments and zero-radius circles

Ah, thanks for mentioning those two edge cases. Zero-radius circles don't have to be handled (the post says positive radius), and I'll also clarify that the ends of the line segment will be distinct.

Python, 284
I'm using a pretty garbage algorithm compared to all these geometric tricks, but it gets the right answers even though it takes a over a minute to get through the test cases. The big advantage is that I only have to write the three scoring functions, and the hillclimbing takes care of all the edge cases.
Golfed:
import math,random as r
n=lambda(a,c),(b,d):math.sqrt((a-b)**2+(c-d)**2)
x=lambda(t,a,b),p:max(eval(["n(b,p)-n(a,b)+","-b+","b-"][t]+'n(a,p)'),0)
def F(t,j):
q=0,0;w=1e9
 for i in q*9000:
    y=x(t,q)+x(j,q)
    if y<w:p,w=q,y
    q=(r.random()-.5)*w+p[0],(r.random()-.5)*w+p[1]
 return w<.0001

Ungolfed:
import math
import random as r
def norm(a, b):
 return math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)

def lineWeight(a, b, p):
 l1 = norm(a, p)
 l2 = norm(b, p)
 return min(l1, l2, l1 + l2 - norm(a, b))

def circleWeight(a, r, p):
 return max(0, norm(a, p) - r)

def voidWeight(a, r, p):
 return max(0, r - norm(a, p))

def weight(f1, f2, s1, s2, p):
 return f1(s1[1], s1[2], p) + f2(s2[1], s2[2], p)

def checkCollision(s1, s2):
 a = [lineWeight, circleWeight, voidWeight]
 f1 = a[s1[0]]
 f2 = a[s2[0]]
 p = (0.0, 0.0)
 w = 0
 for i in a*1000:
  w = weight(f1, f2, s1, s2, p)
  p2 = ((r.random()-.5)*w + p[0], (r.random()-.5)*w + p[1])
  if(weight(f1, f2, s1, s2, p2) < w):
   p = p2
 if w < .0001:
  return True
 return False

And finally, a test script in case anyone else wants to try this in python:
import collisiongolfedbak
reload(collisiongolfedbak)

tests = [
[0,[0,0],[2,2]], [0,[1,0],[2,4]],        # Crossing line segments
[0,[0.5,0],[-0.5,0]], [1,[0,0],1],       # Line contained in a disc
[0,[0.5,0],[1.5,0]], [1,[0,0],1],        # Line partially within disc
[0,[-1.5,0.5],[1.5,0.5]], [1,[0,0],1],   # Line cutting through disc
[0,[0.5,2],[-0.5,2]], [2,[0,0],1],       # Line outside cavity
[0,[0.5,0],[1.5,0]], [2,[0,0],1],        # Line partially outside cavity
[0,[-1.5,0.5],[1.5,0.5]], [2,[0,0],1],   # Line cutting through cavity
[1,[0,0],1], [1,[0,0],2],                # Disc contained within another
[1,[0,0],1.1], [1,[2,0],1.1],            # Intersecting discs
[1,[3,0],1], [2,[0,0],1],                # Disc outside cavity
[1,[1,0],0.1], [2,[0,0],1],              # Disc partially outside cavity
[1,[0,0],2], [2,[0,0],1],                # Disc encircling cavity
[2,[0,0],1], [2,[0,0],1] ,               # Any two cavities intersect
[2,[-1,0],1], [2,[1,0],1] ,              # Any two cavities intersect
[0,[0,0],[1,0]], [0,[0,1],[1,1]] ,       # Parallel lines
[0,[-2,0],[-1,0]], [0,[1,0],[2,0]],      # Collinear non-overlapping lines
[0,[0,0],[2,0]], [0,[1,1],[1,2]],        # Intersection outside one segment
[0,[0,0],[1,0]], [0,[2,1],[2,3]],        # Intersection outside both segments
[0,[-1,2],[1,2]], [1,[0,0],1],           # Line passes outside disc
[0,[2,0],[3,0]], [1,[0,0],1],            # Circle lies outside segment
[0,[-0.5,0.5],[0.5,-0.5]], [2,[0,0],1],  # Line inside cavity
[1,[-1,0],1], [1,[1,1],0.5],             # Non-intersecting circles
[1,[0.5,0],0.1], [2,[0,0],1]            # Circle contained within cavity
]

for a, b in zip(tests[0::2], tests[1::2]):
 print collisiongolfedbak.F(a,b)

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Ray-trace a shiny sphere
I downloaded POV-ray and rendered this shiny metal sphere 90s style:

Your task is to do the same thing, but to do it by implementing the rendering engine yourself in as few bytes as possible. You don't have to replicate this exact image - any image of a reflective sphere above an infinite checkerboard will do, as long as it meets the criteria below.
Rules:

The image must depict a reflective sphere hovering above an infinite checkerboard. Both the checkerboard itself and its reflection in the sphere must be shown in the image. It must be visually clear that this is what we're seeing. Beyond this, the details of the geometry, colours, material properties etc. are up to you.
There must be some lighting in the scene: parts of the sphere should be darker than other parts, and visually it should be possible to tell roughly where the light is coming from. Beyond that, the details of the lighting model are up to you. (You can invent your own simplified lighting model if you like.) The sphere doesn't have to cast a shadow.
The above two criteria - whether it really looks like a shiny sphere above a checkerboard illuminated by a light source - will be judged by the community using voting. Therefore, an answer must have a positive score in order to be eligible to win.
The output must be at least 300x300 pixels. It can be displayed on the screen or written to a file, either is fine.
Your code should run in less than an hour on a reasonable modern computer. (This is generous - POV-ray renders the above scene practically instantaneously.)
No built-in ray tracing functionality may be used - you must implement the renderer yourself.
This is code-golf, so the positive-scoring entry with the shortest code (in bytes) wins. However, you're also welcome to play the meta-game of getting the most votes by drawing a pretty picture (while keeping the code short of course).

This challenge might seem ridiculously hard, but since the geometry is fixed, the algorithm for rendering such a scene by ray tracing is pretty straightforward. It's really just a case of iterating over each pixel in the output image and evaluating a mathematical expression to see what colour it should be, so I'm optimistic that we'll see some good answers.

I personally dislike the lighting requirement. I think it adds a lot of extra complexity, for very little gain. Just my opinion, though.

You say colours are up to us. Does that include greyscale images?

@MartinBüttner yes, greyscale images are fine.

@stokastic my hope is that it will be a source of creativity, as people come up with radically simplified but just about convincing lighting models that can be specified in a small amount of code. I've added a note in the question that simplified lighting models are OK.

It has already been done: http://fabiensanglard.net/rayTracing_back_of_business_card/index.php Of course this can be made a bit shorter by reducing it to one sphere, removing antialiasing etc.

@Shugal that's great! But answers to this question can be a lot shorter, as they don't need multiple reflections out any of the other features that program manages to include

@stokastic though having played around with my POV-ray scene a bit more, I really wish I'd asked for a sky gradient instead. It makes much more difference than the lighting, and would be a lot less extra complexity. But never mind, it would be unfair to change it now.

Related: http://codegolf.stackexchange.com/a/36025/21348

Python 2, 484 468 467 bytes

i=int;u=249.3
def Q(A,B):
 a=A*A+B*B+9e4;b=B*u+36e4;I=b*b-a*128e4
 if I>0:
    t=(-b+I**.5)/(5e2*a);F,G,H=A*t,B*t,u*t;J,K,M=F,G+.6,H+2.4;L=a**-.5;k=2*(A*J+B*K+u*M)*L;C,D,E=A*L-k*J,B*L-k*K,u*L-k*M;L=(C*C+D*D+E*E)**-.5;t=(-4e2-G)/D;return(D*D*L*L*u,((i(F+t*C)/200+i(H+t*E)/200)&1)*(u*D*L))[D>0]
 else:return(u*B*B/a,((i(-2e2/B*A)/200+i(-6e4/B)/100)&1)*u*B/a**.5)[B>0]
open("s.pgm","wb").write("P5 800 600 255 "+"".join(chr(i(Q(j%800-4e2,j/800-u)))for j in range(480000)))

Note: after if I>0: there is a newline followed by a single tab char before t=...
Running the program will create an 800x600 image named s.pgm
Started from a "real" ray tracer formulas (tweaked a bit for golfing).
Rendering takes about 3s on my dead old PC (0.7s with pypy).

Beautiful image!

You can save a few bytes without doing the zlib trick by replacing 0000 with e4 throughout.

@Nathaniel:Doh... very big mistake for a code golf :-) Fixed. I've also removed the zlib packing trick because I've to investigate on its legality (the latest version for example when zipped works with standard python but doesn't work with pypy, and that's very strange).

Another code golf trick, you can replace a if b else c with (c,a)[b] so long as you don't rely on short-circuiting to avoid e.g. division by zero errors. Also if A:code;return B\nelse:return C you can replace with code;return(C,B)[A].

@Claudiu: Thanks for the suggestion. I had to change the parameters a bit to avoid a division by zero. I also used a single loop over the image and that saved a lot.

Wow, this is very impressive. I assume you've done assembly programming before? (judging by your username)

qwr: ah... you caught me. Indeed I started programming in asm on an Apple 2, back in 1981 :-D

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Shubbles and Smoles - Part I
The Setup
Consider an oddly-shaped box containing 29 numbered cells as shown in Fig. 1 below.

Inside this 2D box are two species of square-shaped animals: shubbles and smoles. Fig. 1 (a) shows some shubbles in blue, and some smoles in red. Each creature occupies exactly one grid cell. The box may contain anywhere between 0 and 26 shubbles, but will always contain exactly two smoles.
Being subject to gravity, shubbles and smoles sit on the bottom of the box, stacking on top of anything below them. Both species are exceptionally lazy and remain perpetually motionless.
The box also contains a stot, depicted as a black square, that occupies exactly one grid cell. The stot is not subject to gravity.
The box has one opening located at the bottom of cell 28, as depicted in the figure.
To represent the configuration of shubbles, smoles, and the stot in the box textually, we use a 29-character string, one character per grid cell, in the enumerated order, with . representing an empty cell, o representing a shubble, x representing a smole, and @ representing the stot. For example, the configuration of Fig. 1 (a) is represented by the string .........@...o....ooo..xox....
Manipulations
The box can be rotated by any multiple of 90°. While the box is being rotated, the shubbles and smoles remain stationary within their grid cells. As soon as a rotation is complete, they fall directly downward until either i) they are blocked by a wall below, ii) they are blocked by a shubble, smole, or stot below, or iii) they fall through the hole in cell 28 and exit the box. The stot does not fall; it stays fixed in its current cell, even if creatures rest on top of it.
The box cannot be rotated again until the creatures are done falling and have reached a new stable configuration.
Textually, box rotations are denoted by + for a 90° clockwise rotation, | for a 180° rotation, and - for a 90° counterclockwise rotation.
Additionally, the stot can be moved in the four compass directions in increments of one grid cell. A move may not: i) cause a collision between the stot and a creature (i.e. the destination grid cell must be empty), ii) cause a collision between the stot and a wall, nor iii) cause the stot to exit the box through the hole in cell 28.
Also, the stot may not move if it has any creatures resting on top of it (with respect to current gravity).
Textually, stot moves are denoted by < for left, > for right, ^ for up, and v for down. Stot moves are always specified with respect to the "standard" (non-rotated) frame depicted in the figures. That is, if the stot is in cell 10, the move ^ will always move it to cell 5, and the move > will always move it to cell 11. The orientation of the box does not affect the direction of the move.
Sequences of manipulations are encoded using left-to-right character strings. For example, the string +<<^- indicates the box is rotated clockwise 90°, then the stot is moved left twice and up once (with respect to the standard frame), then the box is rotated 90° counterclockwise back into its original orientation.
The Challenge
For perfectly good reasons (that I cannot disclose), we wish to extricate all shubbles from the box without extricating a single smole. To accomplish this, we can use the manipulations specifically described above.
Before solving this problem, it behooves us to simulate how our various manipulations will affect the contents of the box, which is the focus of this challenge.
You must write a program that accepts two arguments from stdin (or equivalent):

a string describing the initial state of the box
a sequence of manipulations

You may assume that both arguments are syntactically valid, that the box starts in the standard orientation, and that the initial state of the box is stable and legal.
The program must output to stdout (or equivalent) either:

(case 1) the final state of the box, expressed as a string, if the sequence of moves is legal (it does not violate the stot move rules) and does not cause any smoles to exit the box. The final orientation of the box is unimportant.
(case 2) a single exclamation mark, !, if the sequence of moves is illegal or causes any smoles to exit the box

Scoring
The winning program is the shortest program by byte count, subject to some extremely lucrative bonus multipliers:

claim a multiplier of 0.65 if instead of printing the encoded output for case 1, the program outputs an ASCII picture of the box in its final state and orientation, using the spec characters for shubbles, smoles, stots, and empty cells, and placing a * in the cell just outside the hole in cell 28. Leading and trailing whitespace is ignored.
For example, if Fig. 1 (a) is rotated 90°, the output would be
   .  .
  .....
  .o...
  xo.@.
 *ooo..
  x  .

claim a multiplier of 0.22 if instead of printing encoded output for case 1, the program outputs an image file or displays a GUI window with a picture of the box in its final state and orientation. The picture should be in the style of Fig. 1 (a), showing the grid cells, walls, and creatures/stot using coloured boxes.
claim a multiplier of 0.15 if instead of printing encoded output for case 1, the program outputs an animated .gif or animated GUI window showing all intermediate states in the simulation at 1 sec intervals. The same picture rules as for the 0.22 multiplier apply. The first frame of the animation should depict the initial state of the simulation. Additionally, the animation should show "hidden" intermediate states, which are

the shubbles/smoles falling into a stable configuration by one cell per animation frame after a rotation
the intermediate 90°-rotated state of the box in a 180° rotation

claim a multiplier of 0.12 if the program produces an animated .gif or animated GUI window of the above style, but runs at 20 fps and shows

smooth, continuous animations of the box rotating
smooth, continuous animations of the stot moving, and of the shubbles/smoles falling into a stable configuration

Shubbles falling through the hole in cell 28 should be shown exiting the box, and should disappear once totally outside. You may choose your own timing for the animation so long as no more than 1 manipulation/sec is performed.

Total score is floor( base score * multiplier ). Only one multiplier may be claimed.
It's a smole world after all. ;)

+1 for the spec, but I won't be participating, probably.

This sounds like fun. Just to make sure: the shape of the box is entirely fixed, yes? So we don't have to account for any other shapes?

@IngoBürk: Correct. The box shape is fixed.

For the image output, can we use your image as a resource (or any kind of resource)  or do we have to draw it entirely in the code? If we can use it, how does it count? I'll try to give this a go, but I'm on vacation right now.

You can use external graphic resources (e.g. images, SVG markup) as long as you include their byte counts in the total for the program. The basic image doesn't have to be terribly complicated. 12 lines making up the grid; the wall; and the coloured boxes inside the box. If you prefer, a coloured box can fill an entire grid cell, and the wall can trace exactly along the border of the outermost cells. Thus the whole picture can be defined by drawing rectangles, lines, and a polyline on a 6x6 square coordinate grid.

One of the bonus specifications mentions a "0.35 multiplier" which does not exist.

@feersum: Good catch. I've fixed it.

So when is part 2 coming? ;)

MATLAB, as yet ungolfed * 0.15
It would be great if someone could hazard a guess as to whether this works right.
n = @()input('', 's');
E = @()fprintf('!');
M = zeros(7,9);
G = M;
I = [9:7:44 17:7:52 18:7:46 12:7:47 20:7:55];
M0 = M;
M0(I) = 1;
M([I 49]) = 1;
G(I) = n()-46;
trot = 0;
Xtr = [0 1-10i 11-7i 8+i];
X0 ='c66++66++oozzoozzn'-i*'YYNNAA--  ++88LLYY'-22+22i;
for a = [97 n()]
    a = find('-|+a^<v>'==a);
    if a<5
        R = @(m) rot90(m, a);
        G = R(G);
        [nr,nc] = size(G);
        M = R(M);
        M0 = R(M0);
        trot = mod(trot+a,4);
        X = exp(i*pi*trot/2)*X0 + 11*Xtr(trot+1);
    else
        z = find(G==18);
        J = z + [-nr,1]*[0,-1;1,0]^(trot+a)*[1;0];
        if ~M0(J) | G(J) | G(z+1)
            E();return
        end
        G(z) = 0;
        G(J) = 18;
    end
    fall = 1;
    while fall
        clf
        plot(X/11,'k','LineW',3);
        for x = 2:nc; for y = 2:nr
             ch = G(y,x);
             if M0(y,x)
                 rectangle('Po',[x,-y,1,1],'F',~ch|ch==[74 1 65]);
             end
        end;end
        pause(1);
        G2 = G;
        for r = nr-1:-1:2
            s = G2 > 30;
            f = G2(r,:) .* (s(r,:) & ~s(r+1,:) & M(r+1,:) & G(r+1,:)~=18);
            if r==size(G,1)-1 & any(f==74)
                E();return
            end
            G2(r:r+1,:) = G2(r:r+1,:) + [-f;f];
        end
        G2 = G2 .* M0;
        fall = any(any(G2 ~= G));
        G = G2;
    end
end

Sample end result for some random moves:
.........@...o....ooo..xox...
+>|<-v+^+

Could you actually show a GIF of the animation?

Cool! I'll check it out these evening (and post a few test cases).

The program isn't require to output an animated .gif, but if you want to generate one, feersum, this article explains how to do so easily.


text:
Print the Retro Rocket
(inspired by this SO question)
You are given as input a single positive integer n.
In as few characters as possible, output a rocket in ASCII art with a head, a tail, and a body composed of n segments. There should be no trailing spaces or newlines.
The head and the tail of the rocket are always the same for any value of n. The body consists of two different types of segments which alternate. The examples should make the structure of the rocket clear.
Output for n = 1:
     /**\
    //**\\
   ///**\\\
  ////**\\\\
 /////**\\\\\
+=*=*=*=*=*=*+
|\/\/\/\/\/\/|
|.\/\/..\/\/.|
|..\/....\/..|
|../\..../\..|
|./\/\../\/\.|
|/\/\/\/\/\/\|
+=*=*=*=*=*=*+
     /**\
    //**\\
   ///**\\\
  ////**\\\\
 /////**\\\\\

Output for n = 2:
     /**\
    //**\\
   ///**\\\
  ////**\\\\
 /////**\\\\\
+=*=*=*=*=*=*+
|../\..../\..|
|./\/\../\/\.|
|/\/\/\/\/\/\|
|\/\/\/\/\/\/|
|.\/\/..\/\/.|
|..\/....\/..|
+=*=*=*=*=*=*+
|\/\/\/\/\/\/|
|.\/\/..\/\/.|
|..\/....\/..|
|../\..../\..|
|./\/\../\/\.|
|/\/\/\/\/\/\|
+=*=*=*=*=*=*+
     /**\
    //**\\
   ///**\\\
  ////**\\\\
 /////**\\\\\

Output for n = 3:
     /**\
    //**\\
   ///**\\\
  ////**\\\\
 /////**\\\\\
+=*=*=*=*=*=*+
|\/\/\/\/\/\/|
|.\/\/..\/\/.|
|..\/....\/..|
|../\..../\..|
|./\/\../\/\.|
|/\/\/\/\/\/\|
+=*=*=*=*=*=*+
|../\..../\..|
|./\/\../\/\.|
|/\/\/\/\/\/\|
|\/\/\/\/\/\/|
|.\/\/..\/\/.|
|..\/....\/..|
+=*=*=*=*=*=*+
|\/\/\/\/\/\/|
|.\/\/..\/\/.|
|..\/....\/..|
|../\..../\..|
|./\/\../\/\.|
|/\/\/\/\/\/\|
+=*=*=*=*=*=*+
     /**\
    //**\\
   ///**\\\
  ////**\\\\
 /////**\\\\\

related post, from our nemesis: http://codereview.stackexchange.com/questions/65040/retro-rocket-ascii-art

Also related.

CJam, 67 63 characters
"дȈ鰚㒄å摒四ㄺ뎞椉ᖛⲠ줥葌⌁掗⦠춻锦䎷겲铣굛쮂먲꿡㦺좒轃汁̕뎕갴瓖邻吟㭰戔蟏㳵回㡚钦״脮烮鋉둎邫"6e4b127b:c~

This should work in the online interpreter.
How it works
After pushing the Unicode string, the snippet
6e4b127b:c~

converts the string from base 60000 to base 127, casts to string and evaluates the result.
The code that get executed is the following:
"..."          " A binary string of length 42.                                            ";
122b7b         " Convert from base 122 to base 7.                                         ";
"\n *./\|"f=   " Replace each digits with the corresponding character.                    ";
60/~           " Split into chunks of length 60 and dump the resulting array.             ";
               " The stack now contains the rocket's head and a body half.                ";
[_W%[\]_W%]    " Push an array of the body half and the reversed body half, a reversed    ";
               " copy of that array and collect both array into another one.              ";
Nf*Nf+         " Join each array of body halves separating by LFs and append LFs.         ";
ri:I*           " Repeat the resulting array I := int(input()) times.                     ";
I<W%           " Keep the first I bodies and reverse their order.                         ";
\a_@\++        " Prepend and append the rocket head/tail.                                 ";
'+"=*"6*'+N+++ " Push S := '+=*=*=*=*=*=*+\n'.                                            ";
*              " Join the array of parts, separating by S.                                ";

You should really count this in bytes, non?

@Claudiu: And ruin my score? :P Answers are scored by their length bytes by default, but the question overrides this by saying in as few characters as possible.

CJam, 121 bytes
5,{_5\-S*\)_'/*"**"@'\*N}%:A['+"+
"]"=*"6**:Lri:M{M(:M;2,{M+2%:J;3,{:I'|J@2\-'.*I'.*?_J"/\\""\/"?JI)3I-?*\++_+'|N}%}%L}*A

Try it online
Takes the input n via STDIN.
I'll add an explanation at some point later. Basically it's all just a bunch of loops in a very naive way. To alternate between the two different body parts, I've got a nested loop over the part and a loop over 0 and 1. Then I just add the outer iterator and the inner one, and use their parity to decide between upwards or downwards pointing triangle.

I got a java.util.NoSuchElementException copy + pasting the code (pointing at Lri)

@Claudiu Did you enter an integer in the "input" field?

Oh yes, that would do it!

Ruby, 203
n,q=$*[0].to_i,"\\/"
h,r,m=1.upto(5).map{|i|(?/*i+"**"+?\\*i).center 14},?++"=*"*6+?+,3.times.map{|i|?|+?.*i+q*(3-i)+?.*(2*i)+q*(3-i)+?.*i+?|}*"\n"
p=m.reverse.tr q,"/\\"
puts h,([r,m,p,r,p,m]*n)[0,3*n],r,h

Ungolfed
I think in this case it's beneficial to have an non-golfed version.
n      = $*[0].to_i
head   = 1.upto(5).map { |i| ("/"*i + "**" + "\\"*i).center 14 }
ridge  = "+" + "=*"*6 + "+"
middle = 3.times.map { |i| "|" + "."*i + "\\/"*(3-i) + "."*(2*i) + "\\/"*(3-i) + "."*i + "|" }.join "\n"
piddle = middle.reverse.tr "\\/", "/\\"

puts head
puts ([ridge,middle,piddle,ridge,piddle,middle]*n)[0,3*n]
puts ridge, head

Explanation
I doubt this is anywhere near efficient, but it was fun nonetheless.

Input is taken from ARGV.
h contains the "head" and "tail" of the rocket, r contains the "ridges" that separate the different parts of the rocket and m and p are the top and bottom parts of the "body" of the rocket.
The body is constructed by cycling through the Array ["ridge", "top of body", "bottom of body", "ridge", "bottom of body", "top of body"] and taking the first 3*n elements.
puts makes sure everything gets its own line.

Python, 120 + 77 + 1 = 198 characters
This ended up being the wrong approach, but I had already finished when Martin posted his answer.
H,L,T,B=open("R","rb").read().decode('zip').split("X")
n=input()
for p in[H]+([B,T,L,T,B,L]*n)[:3*n][::-1]+[L,H]:print p

Requires a file R (+1 for filename) of 77 bytes, which you can generate as follows:
>>> open('R','wb').write('eJxNjMENwDAIA/+ZIm8i4Qm6Bw+PwvDFQRUFydwJwd5VMOO6ILqIRjE+LsEI4zw2fSKJ6Vzpmt4p\ndVlnRikoVWqrK+8s/X1ivozIJuo=\n'.decode('base64'))

JavaScript (E6) 252 257
Overuse of string.repeat
F=p=>{
  R=(n,s='.',a='')=>a+s.repeat(n)+a;
  for(i=f=o=m=n='';++i<6;)
    o+=f+R(6-i,' ')+R(i,u='/')+'**'+R(i,t='\\'),
    f='\n',
    i<4?m+=f+R(2,R(4-i,t+u,R(i-1)),'|',n+=f+R(2,R(i,u+t,R(3-i)),'|')):0;
  s=f+R(6,'=*','+'),
  console.log(o+s+R(p&1,q=m+n+s)+R(p/2,n+m+s+q)+f+o)
}

it's fun, we both have 252b but with completely different approaches :)

JS, WIP, 252b or 173 chars
It's not a function, so you have to set the value of n at the beginning (3 here), then execute it in the console or in nodeJS.
Here's the 252b version:
n=3;r=a="     /**01    //**001   ///**0001  ////**00001 /////**00000";b="1+=*=*=*=*=*=*+1";for(c=[d="|0/0/0/0/0/0/|1|.0/0/..0/0/.|1|..0/....0/..|",d.split("").reverse().join("")];n--;)r+=b+c[n%2]+1+c[1-n%2];(r+b+a).replace(/0/g,"\\").replace(/1/g,"\n")

And here's the 173 chars version (using http://xem.github.io/obfuscatweet/)
n=3;eval(unescape(escape('').replace(/uD./g,'')))

Tested in console. Cool and +1, but usually when the OP asks for an output and not a just return value, an output statement is requested (like console.log or alert - I don't know in nodeJS).

you're right... I allowed myself to consider the console as an output. :p (also, nodeJS can only output on its console afaik)

Javascript (ES3): 243 219 bytes
R=function(n){for(a='',i=5;i--;t=a+=s+'\n')for(s='**',j=6;j--;b=['|../\\..|./\\/\\.|/\\/\\/\\','|\\/\\/\\/|.\\/\\/.|..\\/..'])s=i<j?'/'+s+'\\':' '+s+' ';for(;a+='+=*=*=*=*=*=*+\n',n;)a+=(b[n&1]+b[--n&1]).replace(/[^|]+/g,'$&$&|\n');return a+t}

1:SyntaxError: function statement requires a name, 2:incorrect output, the body segments ahould not be all equal (odd and even are different)

That's because it's intended to be FunctionExpression. But I've added an assignment, so it should work now.
Thanks! I didn't notice that at first.


text:
Anti-aliased ASCII Aureoles
Consider the following ASCII image of five concentric anti-aliased ASCII aureoles:
                 ........
            .@..............@.
        .....                .....
      .@..    ...@@@@@@@@...    ..@.
    .@.    ..@@..        ..@@..    .@.
   .@.   .@@.    ........    .@@.   .@.
  .@    @@    .@@@@@..@@@@@.    @@    @.
 .@    @.   .@@.          .@@.   .@    @.
 @.   @@   @@.   @@@@@@@@   .@@   @@   .@
.@   .@   .@.   @@@.  .@@@   .@.   @.   @.
.@   @@   @@   @@   @@   @@   @@   @@   @.
.@   @@   @@   @@   @@   @@   @@   @@   @.
.@   .@   .@.   @@@.  .@@@   .@.   @.   @.
 @.   @@   @@.   @@@@@@@@   .@@   @@   .@
 .@    @.   .@@.          .@@.   .@    @.
  .@    @@    .@@@@@..@@@@@.    @@    @.
   .@.   .@@.    ........    .@@.   .@.
    .@.    ..@@..        ..@@..    .@.
      .@..    ...@@@@@@@@...    ..@.
        .....                .....
            .@..............@.
                 ........

You must write a program to draw a given subset of the above circles in as few characters as possible.
The input is either five booleans in your choice of formatting (be it 1 1 1 1 1 or [False, True, False, False, True]), with the first boolean corresponding to the inner-most circle, or an integer where the least-significant bit corresponds to the inner circle (e.g. 1 0 0 1 1 is equivalent to 25).
Output for 1 1 1 1 1/31: see above.
Output for 1 0 1 0 1/21:
                 ........
            .@..............@.
        .....                .....
      .@..                      ..@.
    .@.                            .@.
   .@.           ........           .@.
  .@          .@@@@@..@@@@@.          @.
 .@         .@@.          .@@.         @.
 @.        @@.              .@@        .@
.@        .@.                .@.        @.
.@        @@        @@        @@        @.
.@        @@        @@        @@        @.
.@        .@.                .@.        @.
 @.        @@.              .@@        .@
 .@         .@@.          .@@.         @.
  .@          .@@@@@..@@@@@.          @.
   .@.           ........           .@.
    .@.                            .@.
      .@..                      ..@.
        .....                .....
            .@..............@.
                 ........

Output for 0 0 0 1 0/8 (note the leading whitespace):
              ...@@@@@@@@...
           ..@@..        ..@@..
         .@@.                .@@.
        @@                      @@
       @.                        .@
      @@                          @@
     .@                            @.
     @@                            @@
     @@                            @@
     .@                            @.
      @@                          @@
       @.                        .@
        @@                      @@
         .@@.                .@@.
           ..@@..        ..@@..
              ...@@@@@@@@...

The aureoles themselves must be exactly as presented above. However, trailing whitespace is optional. Also, if some outer aureoles are missing, it is up to you whether your program outputs the leading empty lines or the trailing empty lines.

Did you obtain permission from the American Association of Anti-Aliased ASCII Aureoles and Areolas (AAAAAAA) to use their logo?

@COTO I Believe the Big Best Body of Being did Bring Back the Bad Ban on using this logo without permission. Or, in short: BBBBBBBBB.

Criminy crickets! I didn't know the BBBB did BBBB. Now I'll have to create a cringingly corny correction clause and cry for their coolness.

You diabolically dared defy the deviously demanding dataset describing the demerits deemed denunciable during the deconstruction of demotivationally dampening, diaper-rash-engenderingly devilish declamations such as dear Doorknob declaim did?
(strained, I know)

Each entry earns extra exhortations for everyone's exceptionally elongated (and elegantly enumerated) English expressions.

For five fortnights, fanatics fought AAAAAAA/BBBB for fair-use of figures. Finally, failure followed.

Good God! :-p :)

Holy Handgrenades hold heathens hesitantly hovering, hilarity ensues.

I inquire: is it inappropriate if I insolently insert ill-timed "J"s in "I"-juggling iterations? (Just joking, it'd imply irresponsibility!)

Justifying J-jamming as "just joking"?? Jumping Jehosaphat!

Krafty k... Kids knowing kode k... Ah screw it.

JavaScript (E6) 272 314
On par with the other JS answers, a function returning a string. Add 13 byte if an output statement is requested (console.log()).
The function parameter is an array of 5 truthy/falsy values.
Edit Shorter implementation of the same algorithm
The string at line 2 codify the lower right quarter of the rings. The others are obtained thanks to simmetry

' ' space mark line end
digit (1..9) mark a sequence of blank spaces
hex digit (A..F or a..f) mark a sequence of symbols, if lowercase '.' else '@'

Rendering the lines, it checks the boolean params and output symbols or an equal number of spaces
F=f=>
  [for(c of(l=d=0,o=t=[],'A3B3B3B3Aa 1aC3aAa3Aa3Aa D3aB3B3aA1 5aBa3aA4Aa1 aEa4B4Aa2 d4aBa3aAa3 4bBb4aAa4 Dc4bAa6 8e8 cdAa66 d89 '))
   c<'1'?(l=(t=[o,...t,o]).length/5.1|0,d=1,o='')
   :o=(p=(-c||!f[l+=d]?' ':c>'F'?'.':'@').repeat(-c?(d=1,c):(d=0,'0x'+c-9)))+o+p]
  &&t.join('\n')

Test In FireFox/FireBug console
F([1,0,1,0,1]) (or F[1,,1,,1])

Output
                 ........
            .@..............@.
        .....                .....
      .@..                      ..@.
    .@.                            .@.
   .@.           ........           .@.
  .@          .@@@@@..@@@@@.          @.
 .@         .@@.          .@@.         @.
 @.        @@.              .@@        .@
.@        .@.                .@.        @.
.@        @@        @@        @@        @.
.@        @@        @@        @@        @.
.@        .@.                .@.        @.
 @.        @@.              .@@        .@
 .@         .@@.          .@@.         @.
  .@          .@@@@@..@@@@@.          @.
   .@.           ........           .@.
    .@.                            .@.
      .@..                      ..@.
        .....                .....
            .@..............@.
                 ........

How can I run this? If I paste it into Firefox 29's console I get a syntax error.

@Claudiu problems with cut & paste? I tried just now and it works (FireFox 32 with FireBug)

JavaScript (ES5), 359 bytes
Place input into I, get output on stdout/console.
I=[1,1,1,1,1];a='-----  88880----8988888880--  88888--  0--8988- 66677770- 898- 667766- 0-898-6776- 44440  89- 77- 45555540 89- 76-4554-  0 98-77-554-3333089-67-454-3332 089-77-55-33-1'.replace(/-/g,'   ').split(0);for(i=11;i--;)a.push(a[i]+=a[i].split('').reverse().join(''));console.log(a.join('\n').replace(/\d/g,function(d){return I[d>>1]?'.@'[d&1]:' '}))

JavaScript ES6, 567b (WIP)
Execute this code in the JS/NodeJS console to display the result in the console.
the array "a" at the beginning contains the input.
a=[1,0,1,0,1];(z=a=>a+a.split("").reverse().join(""))(b=["                 0000","            010000000","        00000        ","      0100    2223333","    010    223322    ","   010   2332    4444","  01    33    4555554"," 01    32   4554     "," 10   33   554   7777","01   23   454   7776 ","01   33   55   77   9",""].map(z).join("\n")[r="replace"](/0/g,a[0]?".":" ")[r](/1/g,a[0]?"@":" ")[r](/2/g,a[1]?".":" ")[r](/3/g,a[1]?"@":" ")[r](/4/g,a[2]?".":" ")[r](/5/g,a[2]?"@":" ")[r](/6/g,a[3]?".":" ")[r](/7/g,a[3]?"@":" ")[r](/9/g,a[4]?"@":" "))[r]("\n\n","\n")