One element, a hundred million compounds
Open the PubChem database and count: as of 2026 it lists well over a hundred million distinct compounds, and the great majority contain carbon. Every other element of the periodic table together accounts for a minority. The medicines in a pharmacy, the dyes in clothes, the plastics in a phone, the fuels in a car and almost every molecule in a living cell are organic compounds: compounds built on a framework of carbon atoms, usually with hydrogen, and often with oxygen, nitrogen, sulfur, phosphorus or halogens attached.
The name is a fossil. Early nineteenth-century chemists believed that the compounds of living things needed a "vital force" to form. In 1828 Friedrich Wöhler made urea, a compound known from urine, by heating ammonium cyanate, a salt prepared without any living source. Vitalism did not die that day (historians point out that it faded over decades), but the line between "organic" and "inorganic" slowly became a line between carbon compounds and the rest. In 1857–58 August Kekulé and Archibald Scott Couper independently proposed that carbon is tetravalent and can bond to itself in chains, and in 1874 Jacobus van 't Hoff and Joseph Le Bel argued that carbon's four bonds point to the corners of a tetrahedron. Those two ideas are still the foundation of this level.
This lesson asks three questions. Why carbon? How do chemists draw and name its compounds, so that a structure written in Nairobi is read the same way in Seoul? And how many different molecules can share one formula?
Why carbon?
Carbon has four valence electrons (configuration , from atomic structure), so it completes an octet by forming four covalent bonds. Several features then work together:
- Strong bonds to itself. A C–C single bond takes about 350 kJ/mol to break, comparable to a C–H bond (about 410 kJ/mol) and a C–O bond (about 360 kJ/mol). Chains of carbon are therefore no weaker than the bonds that decorate them, and carbon catenates: it forms long chains, branches and rings of itself.
- Small size. Carbon's small radius lets two carbon atoms overlap their p orbitals side by side, so it forms stable double and triple bonds and the delocalised rings of aromatic compounds.
- A middling electronegativity. On the Pauling scale carbon (2.55) sits close to hydrogen (2.20), so C–H bonds are almost non-polar and unreactive, while bonds to oxygen, nitrogen and the halogens are polar and reactive. A hydrocarbon skeleton is a stable scaffold, and the heteroatoms are where the chemistry happens.
- Kinetic stability. Carbon in a saturated compound has no empty low-energy orbitals and no lone pairs, so many organic compounds survive for years in air at room temperature even though burning them would release a great deal of energy.
Silicon, directly below carbon, is the natural comparison. A Si–Si bond is much weaker (about 225 kJ/mol), while a Si–O bond is much stronger (about 450 kJ/mol). Given any oxygen, silicon ends up bonded to it, which is why the Earth's crust is made of silicates and quartz rather than long silicon chains. Carbon's balance of bond strengths is what lets it build the varied, metastable molecules of life.
Hybridisation and shape
In molecular orbitals you saw that the true orbitals of a molecule spread over all its atoms. For describing the shape around one carbon atom, chemists use a simpler local picture introduced by Linus Pauling in 1931: mix the atom's 2s orbital with some of its 2p orbitals to make hybrid orbitals that point towards the bonded atoms.
Definition— hybridisation
A carbon atom bonded to four atoms is sp³ hybridised: four equivalent hybrids point to the corners of a tetrahedron, 109.5° apart. A carbon with a double bond is sp²: three hybrids in a plane at 120°, and one unhybridised p orbital perpendicular to the plane that forms the π bond. A carbon with a triple bond, or with two double bonds (as in CO₂), is sp: two hybrids at 180° and two p orbitals that form two π bonds.
The angles follow from geometry alone. Four bonds that are as far apart as possible point to alternate corners of a cube, and the angle between two such directions is . More generally, equivalent hybrids with fraction of s character (written sp) are separated by an angle with .
import numpy as np
# Four sp3 hybrids point to alternate corners of a cube.
corners = np.array([[1, 1, 1], [1, -1, -1], [-1, 1, -1], [-1, -1, 1]], dtype=float)
u, v = corners[0], corners[1]
angle = np.degrees(np.arccos(u @ v / (np.linalg.norm(u) * np.linalg.norm(v))))
print(f"angle between two tetrahedral bonds: {angle:.2f} degrees")
# Equivalent sp^n hybrids (s character 1/(n+1)) are separated by cos(theta) = -1/n.
for name, n in [("sp3", 3), ("sp2", 2), ("sp", 1)]:
theta = np.degrees(np.arccos(-1 / n))
print(f"{name:4} s character {1 / (n + 1):.0%} bond angle {theta:6.1f} degrees")More s character also means a hybrid held closer to the nucleus, and so shorter, stronger bonds: typical carbon–carbon bond lengths are 154 pm for C–C, 134 pm for C=C and 120 pm for C≡C. It also makes a C–H hydrogen more acidic: an sp carbon holds the electron pair of its conjugate base closer to the nucleus, which is why the C–H of a terminal alkyne (p about 25) is far more acidic than that of an alkane (p about 50).
Note
Hybridisation is a model for local geometry, not a separate physical process: atoms do not "hybridise" before bonding. Photoelectron spectra of methane show two ionisation energies, not one, exactly as the delocalised molecular orbitals predict. Both pictures are useful, for different questions.
Drawing organic molecules
A molecular formula such as C₄H₁₀O tells you what atoms are present but not how they are joined. Chemists use three levels of drawing.
Skeletal formulas look strange at first and quickly become the fastest way to see a molecule's shape. The rules: every vertex and every line end is a carbon atom unless another symbol is written there; each carbon carries enough hydrogens to make four bonds; hydrogens on carbon are not drawn, but hydrogens on other atoms (OH, NH₂) are. The zigzag is not decoration: it mirrors the real 109.5° angles of an sp³ chain seen side on.
For computers, structures are written as text. SMILES strings write atoms in order with branches in brackets: butan-2-ol is CC(O)CC, ethanol CCO, benzene c1ccccc1. The InChI identifier and its hashed InChIKey give each structure a unique, standard label, which is how databases recognise that two submissions describe the same compound.
From a formula alone you can already learn something about the structure. Every ring or π bond removes two hydrogens from the saturated count of , so
Definition— double-bond equivalents
For a formula (X a halogen), the number of double-bond equivalents (rings plus π bonds) is
Oxygen and sulfur, which form two bonds, do not change it.
Example— Double-bond equivalents of aspirin
Aspirin is C₉H₈O₄, so DBE . Its structure has one benzene ring (one ring plus three C=C, so four) and two C=O groups: six, as the formula promised. A formula with DBE ≥ 4 and few hydrogens is a strong hint of a benzene ring.
Functional groups
Definition— functional group
A functional group is an atom or small group of atoms within a molecule that has characteristic chemical behaviour, largely independent of the rest of the molecule. A homologous series is a family of compounds with the same functional group, differing by CH₂ units, such as methanol, ethanol, propan-1-ol and butan-1-ol.
The value of the idea is transfer: what you learn about one alcohol applies, with small corrections, to all of them. The table lists the groups you will meet most often, with the suffix or prefix that marks them in a systematic name and an everyday example.
| Family | Group | Name ending | Example |
|---|---|---|---|
| alkane | C–C, C–H only | -ane | propane (camping-stove fuel) |
| alkene | C=C | -ene | ethene (the ripening hormone of fruit) |
| alkyne | C≡C | -yne | ethyne (welding gas) |
| arene | benzene ring | -benzene | methylbenzene (toluene, a solvent) |
| haloalkane | C–F, C–Cl, C–Br, C–I | prefix fluoro-, chloro-, … | 1,1,1,2-tetrafluoroethane (a refrigerant) |
| alcohol | C–OH | -ol | ethanol |
| ether | C–O–C | prefix alkoxy- | methoxybenzene (anisole) |
| amine | C–NH₂, C–NHR, C–NR₂ | -amine | dopamine |
| aldehyde | –CHO | -al | vanillin's CHO group |
| ketone | C–CO–C | -one | propanone (acetone) |
| carboxylic acid | –COOH | -oic acid | ethanoic acid in vinegar |
| ester | –COO–C | -oate | ethyl ethanoate (a nail-varnish solvent) |
| amide | –CO–N | -amide | paracetamol, and every peptide bond |
| nitrile | –C≡N | -nitrile | ethanenitrile (acetonitrile) |
| thiol | C–SH | -thiol | the amino acid cysteine |
Real molecules usually carry several groups. Vanillin, the main flavour compound of vanilla, has an aldehyde, an ether and a phenol (an OH on a benzene ring) on one ring. Aspirin has a carboxylic acid and an ester; paracetamol has an amide and a phenol. Learning to see those groups at a glance is the single most useful skill at this level, because the groups, not the carbon skeleton, decide how a molecule reacts.
Analogy, not a formal construction
Think of the carbon skeleton as the frame of a bicycle and the functional groups as the parts bolted to it: brakes, gears, a bell. Frames differ in size and shape, but a brake works like a brake on any of them. A mechanic who knows the parts can fix bicycles they have never seen, and a chemist who knows the functional groups can predict the behaviour of molecules nobody has made before.
Naming by IUPAC rules
A name has to identify one structure unambiguously, and anyone who knows the rules must be able to draw it. The International Union of Pure and Applied Chemistry (IUPAC) maintains those rules; the current recommendations date from 2013. For simple compounds the procedure is short.
- Find the principal characteristic group, the most senior group present, which becomes the suffix. A simplified seniority order: carboxylic acid > ester > amide > nitrile > aldehyde > ketone > alcohol > amine. Other groups (halogens, alkyl branches, and lower-ranked groups such as a second OH written as hydroxy-) become prefixes.
- Choose the parent chain: the longest carbon chain that contains the principal group. Its length gives the stem: meth-, eth-, prop-, but-, pent-, hex-, hept-, oct-, non-, dec- for 1 to 10 carbons.
- Number the chain from the end that gives the lowest locant to the principal group, then to multiple bonds, then to the prefixes taken together, comparing term by term at the first point of difference.
- Assemble the name: prefixes in alphabetical order (ignoring multiplying prefixes such as di- and tri-), the stem, the unsaturation (-an-, -en-, -yn-) and the suffix, with locants in front of what they locate.
Example— Five names, worked
- CH₃CH(CH₃)CH₂CH₂CH₃: the longest chain has five carbons and the branch is a methyl group. Numbering from the left puts it on C2, from the right on C4, so the name is 2-methylpentane.
- CH₃CH₂CH(CH₂CH₃)CH(CH₃)CH₂CH₃: two six-carbon chains tie for longest and give the same molecule, with an ethyl and a methyl branch on adjacent carbons. Either numbering gives the locant set {3, 4}; the tie is broken alphabetically, so the first-cited prefix (ethyl) gets the lower number: 3-ethyl-4-methylhexane.
- CH₃COCH₂CH₂CH₃: a ketone on a five-carbon chain, numbered to give the C=O carbon the lowest locant: pentan-2-one.
- HOCH₂CH₂CH=CH₂: the OH is the principal group and takes locant 1, so the double bond starts at C3: but-3-en-1-ol.
- CH₃CH₂COOCH₃: an ester is named as the alkyl group on oxygen followed by the acid's anion name: methyl propanoate.
Many compounds also keep retained names. Benzene, toluene, phenol and aniline are used everywhere, and under the 2013 rules acetic acid (not ethanoic acid) is the preferred IUPAC name for CH₃COOH, with ethanoic acid still acceptable. Medicines have short international non-proprietary names (INNs) chosen by the World Health Organization, such as paracetamol (called acetaminophen in North America) and ibuprofen, because the systematic name of a typical drug is several lines long.
Isomers: counting carbon skeletons
Definition— constitutional isomers
Isomers are different compounds with the same molecular formula. Constitutional isomers (also called structural isomers) differ in which atoms are bonded to which. Stereoisomers have the same connections but differ in their arrangement in space; they are the subject of the next lesson.
The alkanes CH are the cleanest case. Butane, C₄H₁₀, has two isomers: the straight chain and 2-methylpropane. Pentane has three and hexane five.
How does the count grow? Drawing by hand becomes error-prone around C₈, because the same skeleton drawn in two orientations is easy to count twice. A computer can do it reliably if we describe each skeleton as a graph: carbons are vertices, C–C bonds are edges, and since alkanes have no rings the graph is a tree in which no vertex has more than four neighbours (the hydrogens fill whatever valences remain). Counting alkane isomers is counting such trees up to relabelling.
The program below grows every skeleton with carbons by attaching one new carbon, in every allowed position, to every skeleton with carbons. Many of the new trees are the same molecule drawn differently, so each gets a canonical code: find the tree's centre (strip off end carbons layer by layer until one or two remain), then describe the tree from the centre outwards, sorting the descriptions of the branches so that the order in which they were drawn no longer matters. Two skeletons are the same molecule exactly when their codes match, and a Python dictionary keyed by the code removes the duplicates (the trick from hash tables).
# Count the constitutional isomers of the alkanes CnH(2n+2) by building every carbon
# skeleton (a tree in which no carbon has more than four neighbours) and removing duplicates.
def canonical(adj):
"""A string that is the same for two skeletons exactly when they are the same molecule."""
n = len(adj)
# Find the centre: strip leaves layer by layer until one or two carbons remain.
degree = [len(a) for a in adj]
layer = [i for i in range(n) if degree[i] <= 1]
left = n
while left > 2:
left -= len(layer)
nxt = []
for leaf in layer:
for nb in adj[leaf]:
degree[nb] -= 1
if degree[nb] == 1:
nxt.append(nb)
layer = nxt
def code(v, parent): # rooted-tree code: children's codes, sorted, in brackets
return "(" + "".join(sorted(code(w, v) for w in adj[v] if w != parent)) + ")"
return min(code(c, -1) for c in layer)
def skeletons(n):
"""All carbon skeletons with n carbons, one adjacency list each."""
found = {canonical([[]]): [[]]}
for size in range(2, n + 1):
bigger = {}
for adj in found.values():
for atom in range(size - 1):
if len(adj[atom]) < 4: # carbon makes at most four bonds
new = [list(a) for a in adj] + [[atom]]
new[atom].append(size - 1)
bigger.setdefault(canonical(new), new)
found = bigger
return found
known = [1, 1, 1, 2, 3, 5, 9, 18, 35, 75, 159, 355] # OEIS A000602, n = 1..12
print(" n formula isomers known")
for n in range(1, 13):
count = len(skeletons(n))
print(f"{n:2} C{n}H{2 * n + 2:<4} {count:6} {known[n - 1]:5}", "" if count == known[n - 1] else "MISMATCH")Every row matches the known sequence: 2, 3, 5, 9, 18, 35, 75 and on to 355 isomers of C₁₂H₂₆. Every skeleton with carbons can be made from one with by adding an end carbon (remove any end carbon of a tree and you have a smaller tree), so the growth step misses nothing, and the canonical code guarantees nothing is counted twice.
Building every skeleton stops being practical in the twenties: there are already 366,319 isomers of C₂₀H₄₂. Pólya's method counts them without drawing a single one. First count alkyl groups CH: an alkyl group is a carbon carrying an unordered choice of three smaller groups (a hydrogen counts as an empty group). Then build an alkane around its centroid, a carbon none of whose branches contains half the carbons or more; every tree has one, or else two neighbouring carbons joined by a bond that splits the molecule into equal halves. The "unordered choice" is where symmetry enters, through the cycle index of the symmetric group.
# Count alkanes without building them, by Polya counting.
# a[k] = number of alkyl groups CkH(2k+1); a[0] = 1 stands for a hydrogen atom.
# An alkyl group is a carbon carrying an unordered choice of three smaller groups.
def multisets(a, size, total):
"""Ways to choose an unordered `size` of groups (counted by a) with `total` carbons."""
def p(k, t): # power sums a(x^k), truncated
return a[t // k] if t % k == 0 and t // k < len(a) else 0
def conv(*series):
out = [0] * (total + 1)
out[0] = 1
for s in series:
out = [sum(out[i] * s[t - i] for i in range(t + 1)) for t in range(total + 1)]
return out
s1 = [p(1, t) for t in range(total + 1)]
s2 = [p(2, t) for t in range(total + 1)]
s3 = [p(3, t) for t in range(total + 1)]
s4 = [p(4, t) for t in range(total + 1)]
if size == 3: # cycle index of the symmetric group S3
return (conv(s1, s1, s1)[total] + 3 * conv(s1, s2)[total] + 2 * s3[total]) // 6
if size == 4: # cycle index of S4
return (conv(s1, s1, s1, s1)[total] + 6 * conv(s1, s1, s2)[total]
+ 3 * conv(s2, s2)[total] + 8 * conv(s1, s3)[total] + 6 * s4[total]) // 24
N = 40
a = [1]
for k in range(1, N):
a.append(multisets(a, 3, k - 1))
def alkanes(n):
# Root every skeleton at its centroid: no branch may hold half the carbons or more...
small = a[: (n - 1) // 2 + 1]
count = multisets(small, 4, n - 1)
if n % 2 == 0: # ...unless two halves of exactly n/2 carbons meet at a central bond
count += a[n // 2] * (a[n // 2] + 1) // 2
return count
print("alkyl groups CkH2k+1, k = 0..10:", a[:11])
for n in [6, 10, 12, 20, 30, 40]:
print(f"C{n}H{2 * n + 2}: {alkanes(n):,} constitutional isomers")The two programs agree where both run (5, 75 and 355), and the second reaches 4,111,846,763 isomers of C₃₀H₆₂ and about of C₄₀H₈₂ in a few milliseconds. The alkyl-group counts are useful in their own right: there are 4 butyl groups and 8 pentyl groups, so 4 constitutional isomers of C₄H₉Cl and 8 of C₅H₁₁Cl.
Physical properties from structure
Structure predicts physical properties through the intermolecular forces of gases, liquids and solids. Three rules of thumb cover a great deal.
Longer chains boil higher. London dispersion forces grow with the area over which two molecules touch, so each CH₂ added to a straight chain raises the boiling point, by less each time.
import numpy as np
# Normal boiling points of the straight-chain alkanes, methane to decane (degrees C).
n = np.arange(1, 11)
tb = np.array([-161.5, -88.6, -42.1, -0.5, 36.1, 68.7, 98.4, 125.7, 150.8, 174.1]) + 273.15
print(" n Tb / K rise from the previous one")
for i in range(10):
rise = "" if i == 0 else f"{tb[i] - tb[i - 1]:+6.1f} K"
print(f"{n[i]:2} {tb[i]:7.1f} {rise}")
# Fit a power law Tb = A * n^b (a straight line on log-log axes), ethane to decane.
b, logA = np.polyfit(np.log(n[1:]), np.log(tb[1:]), 1)
A = np.exp(logA)
print(f"\nfit: Tb = {A:.1f} K x n^{b:.3f}; worst error {np.max(np.abs(A * n[1:] ** b - tb[1:])):.1f} K")
print(f"extrapolated to dodecane (n = 12): {A * 12 ** b - 273.15:.0f} C (measured: about 216 C)")
# The same formula, C5H12, in three shapes.
for name, t in [("pentane", 36.1), ("2-methylbutane", 27.8), ("2,2-dimethylpropane", 9.5)]:
print(f"{name:20} {t:5.1f} C")The rise per carbon falls from 73 K (methane to ethane) to 23 K (nonane to decane). From ethane to decane, the boiling point in kelvin grows roughly as , close to , with a worst error of 3.6 K.
Branching lowers the boiling point. The three pentanes all have the formula C₅H₁₂ and the same molar mass, yet pentane boils at 36.1 °C, 2-methylbutane at 27.8 °C and 2,2-dimethylpropane at 9.5 °C. A branched molecule is more nearly spherical, so less of its surface touches its neighbours.
Polar groups and hydrogen bonds raise it much further. Compare molecules of similar molar mass:
| Compound | Formula | Molar mass / (g/mol) | Boiling point / °C | Strongest intermolecular force |
|---|---|---|---|---|
| butane | C₄H₁₀ | 58 | −0.5 | dispersion |
| propanal | C₃H₆O | 58 | 48 | dipole–dipole |
| propanone | C₃H₆O | 58 | 56 | dipole–dipole |
| propan-1-ol | C₃H₈O | 60 | 97 | hydrogen bonding |
| ethanoic acid | C₂H₄O₂ | 60 | 118 | hydrogen-bonded pairs |
The isomers ethanol (boiling point 78 °C) and methoxymethane (about −24 °C) make the same point with identical formulas: only ethanol has an O–H that can hydrogen-bond. The same reasoning predicts solubility in water. Small alcohols, acids and amines mix with water because they hydrogen-bond to it, but each CH₂ adds a patch that water cannot bond to: methanol, ethanol and propan-1-ol mix with water in all proportions, while hexan-1-ol dissolves only to a few grams per litre and octane hardly at all. That balance of a water-loving head and a water-avoiding tail is exactly what makes soaps and cell membranes work, a story that continues in biochemistry.
Melting points follow a different logic, because they depend on how well molecules pack into a crystal. Highly symmetric molecules pack well: 2,2-dimethylpropane, the lowest-boiling pentane, melts at about −17 °C, more than 110 K above pentane's melting point of about −130 °C.
How chemists work with structures today
In research and industry, structures live in software. Chemists draw them in structure editors, which write SMILES, InChI or connection-table files; databases such as PubChem, ChEMBL and the Cambridge Structural Database are searched by structure, substructure and similarity; and electronic laboratory notebooks check that a newly registered compound is not a duplicate by comparing canonical identifiers, the same idea as our canonical code. The open-source toolkit RDKit is the usual way to do this from Python:
# Not run here: needs RDKit (pip install rdkit), which is not available in the browser.
from rdkit import Chem
from rdkit.Chem import Descriptors, rdMolDescriptors
mol = Chem.MolFromSmiles("CC(=O)Nc1ccc(O)cc1") # paracetamol
print(rdMolDescriptors.CalcMolFormula(mol)) # C8H9NO2
print(round(Descriptors.MolWt(mol), 2)) # molar mass in g/mol
print(Chem.MolToInchiKey(mol)) # a standard, hashed identifierA structure is rarely known in advance: it is worked out from mass spectrometry (molecular formula), infrared spectroscopy (functional groups) and above all NMR (which atoms are connected), as described in spectroscopy. Isomer enumeration has a practical side too. Structure-elucidation programs generate every constitutional isomer consistent with a formula and the spectral constraints, then rank them; and Jean-Louis Reymond's group at the University of Bern has enumerated the "chemical universe" of small molecules, 166 billion of them with up to 17 atoms of C, N, O, S and halogens (the GDB-17 database), as a hunting ground for new medicines. That idea returns in AI for chemistry, where generative models propose molecules rather than listing them all.
Common misconceptions
Misconception
"Organic means natural, or safe." In chemistry, organic means a compound of carbon. Many organic compounds are toxic and many inorganic ones are harmless; the word on a food label means something else entirely.
Misconception
"A bent chain in a skeletal formula is a different molecule from a straight one." Single bonds rotate freely, so the same chain can be drawn zigzag, bent or folded. Two drawings show different constitutional isomers only if the connections differ. Check by naming both: if the names agree, the molecules are the same.
Misconception
"The longest chain is the one drawn horizontally." The parent chain is the longest path through the carbon skeleton, wherever it bends. In CH₃CH(CH₂CH₃)CH₂CH₃, the longest chain runs through the "branch" and the compound is 3-methylpentane, not 2-ethylbutane.
Misconception
"Heavier molecules always boil higher." Molar mass is a rough guide only within one family. Ethanoic acid (60 g/mol) boils 118 K higher than butane (58 g/mol), and a branched alkane boils lower than its straight-chain isomer of exactly the same mass.
Exercises
1. Carbon and functional groups
Warm-upHumanAspirin (2-acetyloxybenzoic acid, C₉H₈O₄) has a benzene ring carrying a carboxylic acid group (–COOH) and an ester group (–O–CO–CH₃) on neighbouring carbons. How many of its nine carbon atoms are sp² hybridised?
2. Carbon and functional groups
CoreHumanGive the IUPAC name of CH₃CH₂CH(CH₃)CH₂CH₂OH.
3. Carbon and functional groups
CoreHumanCaffeine has the molecular formula C₈H₁₀N₄O₂. How many double-bond equivalents (rings plus π bonds) does it have?
4. Carbon and functional groups
CoreHumanHow many constitutional isomers have the formula C₄H₁₀O? (Count every alcohol and every ether; do not count mirror-image forms separately.)
5. Carbon and functional groups
CoreHumanButane (58 g/mol), propanal (58 g/mol), propan-1-ol (60 g/mol) and ethanoic acid (60 g/mol) have almost the same molar mass. Which order of normal boiling points, highest first, is correct?
6. Carbon and functional groups
Warm-upHumanParacetamol (acetaminophen) is N-(4-hydroxyphenyl)acetamide, SMILES CC(=O)Nc1ccc(O)cc1. Which functional groups does it contain? Select all that apply.
7. Carbon and functional groups
CoreComputationalWrite two functions.
parse_formula(formula)turns a molecular formula such as"C9H8O4"or"C2H5Br"into a dictionary of element counts,{"C": 9, "H": 8, "O": 4}. Element symbols are a capital letter optionally followed by a lower-case letter; a missing number means 1. (No brackets or charges.)dbe(formula)returns the double-bond equivalents, C − (H + X)/2 + N/2 + 1, where X counts F, Cl, Br and I.
8. Carbon and functional groups
StretchComputationalThe number of constitutional isomers of a chloroalkane CₙH₂ₙ₊₁Cl equals the number of different alkyl groups CₙH₂ₙ₊₁ (each isomer is one alkyl group with the chlorine at its point of attachment). Write alkyl_groups(n) that counts them for n from 0 to 8, with alkyl_groups(0) == 1 (a bare hydrogen). The answers start 1, 1, 1, 2, 4: one methyl, one ethyl, two propyls (propyl and propan-2-yl) and four butyls.
Build the groups, or count them; either way your function must not double-count a group drawn in two ways.
Further reading and resources
- Nomenclature of Organic Chemistry: IUPAC Recommendations and Preferred Names 2013 · Henri A. Favre and Warren H. Powell · 2014The "Blue Book", IUPAC's full rules for naming organic compounds.
- IUPAC Compendium of Chemical Terminology (the Gold Book)Agreed definitions of terms such as functional group, hybridisation and isomer.
- PubChemStructures, names, identifiers and properties for well over a hundred million compounds.
- NIST Chemistry WebBookEvaluated boiling points, enthalpies and spectra; the source of the boiling points used here.
- OEIS A000602: number of alkanes CnH2n+2The known sequence our enumeration is checked against.
- Kombinatorische Anzahlbestimmungen für Gruppen, Graphen und chemische Verbindungen · George Pólya · 1937The counting theorem behind the second program.
- SMILES, a chemical language and information system · David Weininger · 1988
- Enumeration of 166 billion organic small molecules in the chemical universe database GDB-17 · Lars Ruddigkeit, Ruud van Deursen, Lorenz C. Blum and Jean-Louis Reymond · 2012
- RDKitThe open-source cheminformatics toolkit most researchers use to handle structures in Python.