Margin of error

The margin of error is a statistic expressing the amount of random sampling error in the results of a survey. The larger the margin of error, the less confidence one should have that a poll result would reflect the result of a survey of the entire population. The margin of error will be positive whenever a population is incompletely sampled and the outcome measure has positive variance, which is to say, the measure "varies".
The term "margin of error" is often used in non-survey contexts to indicate observational error in reporting measured quantities. It is also used in colloquial speech to refer to the amount of space or amount of flexibility one might have in accomplishing a goal. For example, it is often used in sports by commentators when describing how much precision is required to achieve a goal, points, or outcome. A bowling pin used in the United States is 4.75 inches wide, and the ball is 8.5 inches wide, therefore one could say a bowler has a 21.75 inch margin of error when trying to hit a specific pin to earn a spare (e.g.,1 pin remaining on the lane). 
Concept.
Consider a simple "yes/no" poll formula_1 as a sample of formula_2 respondents drawn from a population formula_3 reporting the percentage formula_4 of "yes" responses. We would like to know how close formula_4 is to the true result of a survey of the entire population formula_6, without having to conduct one. If, hypothetically, we were to conduct poll formula_1 over subsequent samples of formula_2 respondents (newly drawn from formula_6), we would expect those subsequent results formula_10 to be normally distributed about formula_11. The "margin of error" describes the distance within which a specified percentage of these results is expected to vary from formula_11.
According to the 68-95-99.7 rule, we would expect that 95% of the results formula_10 to fall within "about" two standard deviations (formula_14) either side of the true mean formula_11.  This interval is called the confidence interval, and the "radius" (half the interval) is called the "margin of error", corresponding to a 95% "confidence level".
Generally, at a confidence level formula_16, a sample sized formula_2 of a population having expected standard deviation formula_18 has a margin of error
where formula_20 denotes the "quantile" (also, commonly, a "z-score"), and formula_21 is the standard error.
Standard deviation and standard error.
We would expect the normally distributed values  formula_10 to have a standard deviation which somehow varies with formula_2. The smaller formula_2, the wider the margin. This is called the standard error formula_25. 
For the single result from our survey, we "assume" that formula_26, and that "all" subsequent results formula_10 together would have a variance formula_28.
Note that formula_30 corresponds to the variance of a Bernoulli distribution.
Maximum margin of error at different confidence levels.
For a confidence "level" formula_16, there is a corresponding confidence "interval" about the mean formula_32, that is, the interval formula_33 within which values of formula_1 should fall with probability formula_16. Precise values of formula_36 are given by the quantile function of the normal distribution (which the 68-95-99.7 rule approximates).
Note that formula_36 is undefined for formula_38, that is, formula_39 is undefined, as is formula_40.
Since formula_41 at formula_42, we can arbitrarily set formula_43, calculate formula_44, formula_25, and formula_46 to obtain the "maximum" margin of error for formula_1 at a given confidence level formula_16 and sample size formula_2, even before having actual results.  With formula_50
Also, usefully, for any reported formula_53
Specific margins of error.
If a poll has multiple percentage results (for example, a poll measuring a single multiple-choice preference), the result closest to 50% will have the highest margin of error. Typically, it is this number that is reported as the margin of error for the entire poll. Imagine poll formula_1 reports formula_56 as formula_57
As a given percentage approaches the extremes of 0% or 100%, its margin of error approaches ±0%.
Comparing percentages.
Imagine multiple-choice poll formula_1 reports formula_56 as formula_63. As described above, the margin of error reported for the poll would typically be formula_64, as formula_65is closest to 50%. The popular notion of "statistical tie" or "statistical dead heat," however, concerns itself not with the accuracy of the individual results, but with that of the "ranking" of the results. Which is in first?
If, hypothetically, we were to conduct poll formula_1 over subsequent samples of formula_2 respondents (newly drawn from formula_6), and report result formula_69, we could use the "standard error of difference" to understand how formula_70 is expected to fall about formula_71. For this, we need to apply the "sum of variances" to obtain a new variance, formula_72, 
where formula_74 is the covariance of formula_75and formula_76. 
Thus (after simplifying),
Note that this assumes that formula_80 is close to constant, that is, respondents choosing either A or B would almost never chose C (making formula_75and formula_76 close to "perfectly negatively correlated"). With three or more choices in closer contention, choosing a correct formula for formula_83 becomes more complicated.
Effect of finite population size.
The formulae above for the margin of error assume that there is an infinitely large population and thus do not depend on the size of population formula_6, but only on the sample size formula_2. According to sampling theory, this assumption is reasonable when the sampling fraction is small. The margin of error for a particular sampling method is essentially the same regardless of whether the population of interest is the size of a school, city, state, or country, as long as the sampling "fraction" is small.
In cases where the sampling fraction is larger (in practice, greater than 5%), analysts might adjust the margin of error using a finite population correction to account for the added precision gained by sampling a much larger percentage of the population. FPC can be calculated using the formula
...and so if poll formula_1 were conducted over 24% of, say, an electorate of 300,000 voters
Intuitively, for appropriately large formula_6,
In the former case, formula_2 is so small as to require no correction. In the latter case, the poll effectively becomes a census and sampling error becomes moot.