Introduction to Computation and Programming Using Python Revised and Expanded Edition John V. Guttag instant download
Introduction to Computation and Programming Using Python Revised and Expanded Edition John V. Guttag instant download
https://ebookname.com/product/introduction-to-computation-and-
programming-using-python-revised-and-expanded-edition-john-v-
guttag/
https://ebookname.com/product/programming-in-python-3-a-complete-
introduction-to-the-python-language-2nd-edition-summerfield/
https://ebookname.com/product/intimate-matters-third-revised-and-
expanded-edition-john-demilio/
https://ebookname.com/product/beginning-python-using-
python-2-6-and-python-3-1-wrox-programmer-to-programmer-james-
payne/
https://ebookname.com/product/the-lace-makers-of-
narsapur-2012-ed-edition-maria-mies/
Practice Notes Residential Tenancies 4th Edition Colbey
https://ebookname.com/product/practice-notes-residential-
tenancies-4th-edition-colbey/
https://ebookname.com/product/handmade-baskets-susie-vaughan/
https://ebookname.com/product/water-on-the-moon-2010th-edition-
helen-buckingham/
https://ebookname.com/product/gene-regulation-methods-and-
protocols-1st-edition-minou-bina-auth/
https://ebookname.com/product/asp-net-ajax-in-action-1st-edition-
alessandro-gallo/
Handbook of Psychology volume 4 Experimental Psychology
2nd Edition Weiner
https://ebookname.com/product/handbook-of-psychology-
volume-4-experimental-psychology-2nd-edition-weiner/
Introduction to
Computation and
Programming Using Python
Introduction to
Computation and
Programming Using Python
John V. Guttag
All
rights
reserved.
No
part
of
this
book
may
be
reproduced
in
any
form
by
any
electronic
or
mechanical
means
(including
photocopying,
recording,
or
information
storage
and
retrieval)
without
permission
in
writing
from
the
publisher.
MIT
Press
books
may
be
purchased
at
special
quantity
discounts
for
business
or
sales
promotional
use.
For
information,
please
email
[email protected]
or
write
to
Special
Sales
Department,
The
MIT
Press,
55
Hayward
Street,
Cambridge,
MA
02142.
Introduction
to
computation
and
programming
using
Python
/
John
V.
Guttag.
—
Revised
and
expanded
edition.
pages cm
Includes index.
QA76.73.P48G88 2013
005.13'3—dc23
10
9
8
7
6
5
4
3
2
1
To my family:
Olga
David
Andrea
Michael
Mark
Addie
CONTENTS
PREFACE .......................................................................................................xiii
ACKNOWLEDGMENTS..................................................................................... xv
1
GETTING STARTED .................................................................................... 1
2
INTRODUCTION TO PYTHON ...................................................................... 7
2.1
The Basic Elements of Python ............................................................... 8
2.1.1
Objects, Expressions, and Numerical Types .................................... 9
2.1.2
Variables and Assignment ............................................................ 11
2.1.3
IDLE ............................................................................................ 13
2.2
Branching Programs ........................................................................... 14
2.3
Strings and Input ............................................................................... 16
2.3.1
Input ............................................................................................ 18
2.4
Iteration .............................................................................................. 18
3
SOME SIMPLE NUMERICAL PROGRAMS .................................................. 21
3.1
Exhaustive Enumeration .................................................................... 21
3.2
For Loops............................................................................................ 23
3.3
Approximate Solutions and Bisection Search ...................................... 25
3.4
A Few Words About Using Floats ........................................................ 29
3.5
Newton-Raphson ................................................................................ 32
4
FUNCTIONS, SCOPING, and ABSTRACTION ............................................. 34
4.1
Functions and Scoping ....................................................................... 35
4.1.1
Function Definitions ..................................................................... 35
4.1.2
Keyword Arguments and Default Values ....................................... 36
4.1.3
Scoping ........................................................................................ 37
13 RANDOM WALKS AND MORE ABOUT DATA VISUALIZATION ................. 179
13.1 The Drunkard’s Walk ...................................................................... 179
13.2 Biased Random Walks .................................................................... 186
17.2.3
Shortest Path: Depth-First Search and Breadth-First Search .... 246
18
DYNAMIC PROGRAMMING ..................................................................... 252
18.1
Fibonacci Sequences, Revisited ....................................................... 252
18.2
Dynamic Programming and the 0/1 Knapsack Problem................... 254
This book is based on an MIT course that has been offered twice a year since
2006. The course is aimed at students with little or no prior programming
experience who have desire to understand computational approaches to problem
solving. Each year, a few of the students in the class use the course as a
stepping stone to more advanced computer science courses. But for most of the
students it will be their only computer science course.
Because the course will be the only computer science course for most of the
students, we focus on breadth rather than depth. The goal is to provide
students with a brief introduction to many topics, so that they will have an idea
of what’s possible when the time comes to think about how to use computation
to accomplish a goal. That said, it is not a “computation appreciation” course.
It is a challenging and rigorous course in which the students spend a lot of time
and effort learning to bend the computer to their will.
The main goal of this book is to help you, the reader, become skillful at making
productive use of computational techniques. You should learn to apply
computational modes of thoughts to frame problems and to guide the process of
extracting information from data in a computational manner. The primary
knowledge you will take away from this book is the art of computational problem
solving.
The book is a bit eccentric. Part 1 (Chapters 1-8) is an unconventional
introduction to programming in Python. We braid together four strands of
material:
But the bulk of this part of the book is devoted to topics not found in most
introductory texts: data visualization, probabilistic and statistical thinking,
simulation models, and using computation to understand data.
1 This was Euclid’s purported response, circa 300 BC, to King Ptolemy’s request for an
This book grew out of a set of lecture notes that I prepared while teaching an
undergraduate course at MIT. The course, and therefore this book, benefited
from suggestions from faculty colleagues (especially Eric Grimson, Srinivas
Devadas, and Fredo Durand), teaching assistants, and the students who took
the course.
The process of transforming my lecture notes into a book proved far more
onerous than I had expected. Fortunately, this misguided optimism lasted long
enough to keep me from giving up. The encouragement of colleagues and family
also helped keep me going.
Eric Grimson, Chris Terman, and David Guttag provided vital help. Eric, who is
MIT’s Chancellor, managed to find the time to read almost the entire book with
great care. He found numerous errors (including an embarrassing, to me,
number of technical errors) and pointed out places where necessary
explanations were missing. Chris also read parts of the manuscript and
discovered errors. He also helped me battle Microsoft Word, which we
eventually persuaded to do most of what we wanted. David overcame his
aversion to computer science, and proofread multiple chapters.
Preliminary versions of this book were used in the MIT course 6.00 and the MITx
course 6.00x. A number of students in these courses pointed out errors. One
6.00x student, J.C. Cabrejas, was particularly helpful. He found a large number
of typos, and more than a few technical errors.
Like all successful professors, I owe a great deal to my graduate students. The
photo on the back cover of this book depicts me supporting some of my current
students. In the lab, however, it is they who support me. In addition to doing
great research (and letting me take some of the credit for it), Guha
Balakrishnan, Joel Brooks, Ganeshapillai Gartheeban, Jen Gong, Yun Liu,
Anima Singh, Jenna Wiens, and Amy Zhao all provided useful comments on this
manuscript.
I owe a special debt of gratitude to Julie Sussman, P.P.A. Until I started working
with Julie, I had no idea how much difference an editor could make. I had
worked with capable copy editors on previous books, and thought that was what
I needed for this book. I was wrong. I needed a collaborator who could read the
book with the eyes of a student, and tell me what needed to be done, what
should be done, and what could be done if I had the time and energy to do it.
Julie buried me in “suggestions” that were too good to ignore. Her combined
command of both the English language and programming is quite remarkable.
Finally, thanks to my wife, Olga, for pushing me to finish and for pitching in at
critical times.
1 GETTING STARTED
A computer does two things, and two things only: it performs calculations and it
remembers the results of those calculations. But it does those two things
extremely well. The typical computer that sits on a desk or in a briefcase
performs a billion or so calculations a second. It’s hard to image how truly fast
that is. Think about holding a ball a meter above the floor, and letting it go. By
the time it reaches the floor, your computer could have executed over a billion
instructions. As for memory, a typical computer might have hundreds of
gigabytes of storage. How big is that? If a byte (the number of bits, typically
eight, required to represent one character) weighed one ounce (which it doesn’t),
100 gigabytes would weigh more than 3,000,000 tons. For comparison, that’s
roughly the weight of all the coal produced in a year in the U.S.
For most of human history, computation was limited by the speed of calculation
of the human brain and the ability to record computational results with the
human hand. This meant that only the smallest problems could be attacked
computationally. Even with the speed of modern computers, there are still
problems that are beyond modern computational models (e.g., understanding
climate change), but more and more problems are proving amenable to
computational solution. It is our hope that by the time you finish this book, you
will feel comfortable bringing computational thinking to bear on solving many of
the problems you encounter during your studies, work, and even everyday life.
What do we mean by computational thinking?
All knowledge can be thought of as either declarative or imperative. Declarative
knowledge is composed of statements of fact. For example, “the square root of x
is a number y such that y*y = x.” This is a statement of fact. Unfortunately it
doesn’t tell us how to find a square root.
Imperative knowledge is “how to” knowledge, or recipes for deducing
information. Heron of Alexandria was the first to document a way to compute
the square root of a number.2 His method can be summarized as:
2 Many believe that Heron was not the inventor of this method, and indeed there is some
5 This computer was built at the University of Manchester, and ran its first program in
1949. It implemented ideas previously described by John von Neumann and was
anticipated by the theoretical concept of the Universal Turing Machine described by Alan
Turing in 1936.
4 Chapter 1. Getting Started
• It might crash, i.e., stop running and produce some sort of obvious
indication that it has done so. In a properly designed computing system,
when a program crashes it does not do damage to the overall system. Of
course, some very popular computer systems don’t have this nice
property. Almost everyone who uses a personal computer has run a
program that has managed to make it necessary to restart the whole
computer.
• Or it might keep running, and running, and running, and never stop. If
one has no idea of approximately how long the program is supposed to
take to do its job, this situation can be hard to recognize.
Each of these is bad, but the last of them is certainly the worst, When a
program appears to be doing the right thing but isn’t, bad things can follow.
Fortunes can be lost, patients can receive fatal doses of radiation therapy,
airplanes can crash, etc.
Whenever possible, programs should be written in such a way that when they
don’t work properly, it is self-evident. We will discuss how to do this throughout
the book.
Finger Exercise: Computers can be annoyingly literal. If you don’t tell them
exactly what you want them to do, they are likely to do the wrong thing. Try
writing an algorithm for driving between two destinations. Write it the way you
would for a person, and then imagine what would happen if that person
executed the algorithm exactly as written. For example, how many traffic tickets
might they get?
2 INTRODUCTION TO PYTHON
Now we are ready to start learning some of the basic elements of Python. These
are common to almost all programming languages in concept, though not
necessarily in detail.
The funding of the debt was only one of several parts of the policy
of Hamilton for putting the new government upon a solvent and firm
basis. The session of Congress which began in December, 1790,
witnessed the presentation of his report in favor of a national bank.
This report, like that on the debt, showed careful study of the
subject in its theoretical as well as practical aspects. Hamilton
referred in opening to the successful operation of public banks in
Italy, Germany, Holland, England, and France. He then went on to
point out some of their specific advantages in concentrating capital
and permitting the easy transfer of credit. He declared that such a
bank would afford "greater facility to the government, in obtaining
pecuniary aid, especially in sudden emergencies." It would also
facilitate the payment of taxes, by enabling tax-payers to borrow
from the bank and by the aid which it would give in the transfer of
funds. He did not shrink from declaring that the country would
benefit if foreigners invested in the bank shares, since this would
bring so much additional capital into the United States. Hamilton
then pointed out the vital distinction between government paper
issues and bank paper. He laid down thus the fundamental principle
of a well-regulated bank-note currency:—
"Among other material differences between a paper currency, issued
by the mere authority of government, and one issued by a bank,
payable in coin, is this: That, in the first case, there is no standard to
which an appeal can be made, as to the quantity which will only
satisfy, or which will surcharge the circulation: in the last, that
standard results from the demand. If more should be issued than is
necessary, it will return upon the bank. Its emissions, as elsewhere
intimated, must always be in a compound ratio to the fund and the
demand: whence it is evident, that there is a limitation in the nature
of the thing; while the discretion of the government is the only
measure of the extent of the emissions, by its own authority."
The bank which Hamilton proposed was private in its ownership, but
the United States were to pledge themselves not to authorize any
similar institution during its continuance. The capital of the bank was
not to exceed $10,000,000, for which the President of the United
States might subscribe $2,000,000 on behalf of the government. It
was further provided that three fourths of the amount of each share
might be paid in the public debt instead of gold and silver.
It was the purpose of Hamilton not merely to create a useful
financial institution, in which the government would be able to keep
its deposits, but to weld the monetary system of the country into an
harmonious whole. The result of this, which he foresaw and
intended, was to bind the property-owning classes to the interests of
the new government. The effect was much the same as the creation
of the Bank of England by the loan of its capital to the government,
which bound the moneyed classes firmly to King William, through
the knowledge that the debt and the solvency of the bank depended
on the perpetuation of his government and the exclusion of the
Stuart Pretender. The tendency of Hamilton's project was clearly
seen by Jefferson and other democratic leaders, and did not fail to
arouse their hostility. It was not long before they promptly took sides
against the national bank. Jefferson wrote regarding the meetings of
the cabinet at this time that "Hamilton and myself were daily pitted
in the cabinet like two cocks."
There was something deeper involved, from the standpoint of
Jefferson, than the mere question of bringing the moneyed class to
the side of the government. The latter object was sufficiently
distasteful to him, but the extension of the powers granted by the
Constitution beyond those which were directly enumerated in the
document involved a question of public policy and constitutional law
which afforded the basis for the creation of two great national
parties. The Constitution did not anywhere grant in terms to the
government the power to establish a national bank. Even Hamilton
did not pretend to put his finger on the specific authority for his new
project. He advanced a doctrine which was eagerly embraced by the
party which was growing up around him, but which was as resolutely
opposed by the other party. This was the doctrine of the implied
powers granted to the new government by the Constitution. It is
doubtful whether the Constitution would have been ratified by
Virginia and other states if this doctrine had been set forth and
defended in the state conventions by the friends of the Constitution.
This by no means implies that the policy and doctrine of Hamilton
were not wise and far-sighted. Hamilton had definite aims before
him, and it was his legitimate mission to educate public sentiment up
to the point of accepting those aims and of granting him the means
for carrying them out.
The doctrine of the "implied powers" rested upon the theory that
unless they were directly prohibited by the Constitution, all powers
were granted to the government by implication which were found
necessary and proper for carrying out the powers specifically
granted. Jefferson came to believe, if he did not believe at the
outset, that the government was one of delegated powers which
were strictly limited to those enumerated in the Constitution. The
doctrine of Hamilton, from this point of view, was revolutionary. It
meant the conversion of a government holding limited delegations of
power from the people and the states into a government having
supreme power, capable of taking an infinite variety of measures
whenever Congress, in the exercise of its discretion, believed that
such measures would contribute to the well-being of the Union. The
state governments, coming closer to the people than the federal
government, were most directly threatened by this assumption of
power, and it was as the champions of state rights as well as
democratic ideas that Jefferson and his friends took their ground as
the advocates of the strict construction of the Constitution.
It is not surprising, therefore, that the proposal to create the Bank of
the United States called forth in Congress prolonged and heated
debates. But the policy of Hamilton had been so far successful in
restoring the public credit that he carried the project for the national
bank through both houses, and it was laid before the President for
his approval. Washington had watched with interest the struggle in
the two houses, and was somewhat impressed by the weight of the
argument against the constitutional power of Congress to establish
the bank. The cabinet was divided. Jefferson and Randolph were
against the constitutionality of the bill. Hamilton and Knox were in
favor of it. Washington asked each of them to give him in writing the
reasons for his opinion. He weighed them carefully and then affixed
his signature to the bill (February 25, 1791). The new project
realized all the benefits which Hamilton expected. Washington, in his
tour of the Southern States in the spring of 1791, found the
sentiment for union strengthening and the country recovering from
the prostration of the era of bad money and political uncertainty
which had followed the Revolution. He declared in a letter written
after his return:
"Our public credit stands on that ground, which, three years ago, it
would have been madness to have foretold. The astonishing rapidity
with which the newly instituted bank was filled, gives an unexampled
proof of the resources of our countrymen and their confidence in
public measures. On the first day of opening the subscription, the
whole number of shares (twenty thousand) were taken up in one
hour, and application made for upwards of four thousand shares
more than were granted by the institution, besides many others that
were coming in from various quarters."
How much was likely to be done by a national bank to bind together
the commercial interests of different sections of the country can
hardly be appreciated to-day. At that time there were only four
banks in the country; none of these was ten years old, and their
combined capital was only $1,950,000. The Bank of the United
States was authorized to establish offices of discount and deposit in
all the states and to distribute parts of its capital among eight
branches in the chief cities of the country. It was the drafts of these
branches upon each other, and their means for reducing to a uniform
and reasonable rate the cost of transferring funds, which contributed
to knit all parts of the country together in commercial matters and
so strengthened the bond of political union. The bank did not make
regular reports to the Treasury Department, but its success is
indicated by a special report communicated to Congress by Secretary
Gallatin (January 24, 1811), which showed resources of
$24,183,046. The average annual dividends paid upon the stock up
to March, 1809, were over eight per cent.
So invaluable were the operations of the Bank of the United States
to the public treasury that Jefferson himself when President came to
its support. His support was perhaps never very hearty, and was due
to Albert Gallatin, his Secretary of the Treasury, whose foresight and
ability give him a rank next to Hamilton among the able men who
have presided over the national finances. Gallatin made a strong
report in 1809, recommending that the charter of the bank be
renewed upon its expiration in 1811, with an increase of capital and
wider powers. A new charter was voted in the House, but the bill
was not acted on in the Senate, and before the next session the
opposition of the state bankers had rallied sufficient strength to
defeat the recharter. The second United States Bank was authorized
in 1816, under the administration of Madison and with his approval,
but its career was terminated in 1836, as the result of the political
hostility of President Jackson.
It was not until after the grant of this second charter that the
question of the power of Congress to establish a bank came directly
before the Supreme Court in 1819. At the head of this court sat John
Marshall, who next to Hamilton, perhaps, did more than any other
man to strengthen and extend the powers of the general
government. The jealousy of the state banks had led the State of
Maryland to impose a discriminating tax on the Bank of the United
States. If the right to levy such a tax had been admitted, the Bank
would have been completely at the mercy of the states, and one of
the chief purposes of its creation would have been defeated. In
order to sustain the right of the bank to exemption from taxation, it
was necessary to prove that it was a constitutional instrument of
federal power. Hence the question of the power of Congress to
create such a corporation came directly before the court.
Hamilton found the power to create a bank partly in the preamble to
the Constitution, which declares that the people of the United States
have adopted it in order to "promote the general welfare," but more
particularly in that concluding phrase of the clause defining the
powers of Congress, which declares that that body shall have
authority "to make all laws which shall be necessary and proper for
carrying into execution the foregoing powers, and all other powers
vested by this Constitution in the government of the United States or
in any department or officer thereof." Marshall, in the series of great
decisions by which he strengthened the power of the Union, often
made use of these provisions to justify his reasoning. In one of the
most famous of these decisions (McCulloch vs. Maryland), he
sustained the constitutionality of the bank as an instrument of
federal power and denied the right of the states to levy upon its
property. He declared that the power to tax involved the power to
destroy, and that if the federal government had not the power to
withdraw its creations from discriminating legislation by the states,
the latter might tax the mail or the mints, the papers of the custom-
houses, or the forms of judicial process.
The view of Hamilton regarding the power of the federal government
to create a bank was thus sustained in emphatic terms by the
highest court in the land. It was partly his policy in providing for the
bank and demonstrating its usefulness, with his other measures to
develop the powers of the central government, which made possible
the decisions of Marshall. If the question of the right to incorporate a
bank could have been brought before the court at the beginning,
before the institution had proved its value, and if men like Jefferson
and Madison had been upon the bench, there is at least room for
doubt whether a decision would have been rendered in favor of a
power which is not granted directly to the government by the
Constitution. But by the resolute executive policy of Hamilton and
the broad judicial constructions of Marshall, the functions of the new
government were extended to all those great objects necessary to
create a vigorous and united nation.
The many other measures of Hamilton were directed by the same
singleness of purpose to strengthen the hands of the government
and consolidate the Union. The report on the mint followed the
previous reports of Jefferson in recommending the adoption of the
dollar as the unit of value. Hamilton observed that "upon the whole,
it seems to be most advisable, as has been observed, not to attach
the unit exclusively to either of the metals; because this cannot be
done effectually, without destroying the office and character of one
of them as money, and reducing it to the situation of a mere
merchandise." He believed, however, that care should be taken to
regulate the proportion between the metals with an eye to their
average commercial value. He pointed out the danger of
undervaluing either metal, and the inevitable result, in case of a
difference of ratio in two countries, "if other things were equal, that
the greatest part of the gold would be collected in one, and the
greatest part of the silver in the other."
This discussion of the subject took place at a time when monetary
principles were not very well fixed, when the standard and the state
of the currency had hardly been settled on an orderly basis in any
country, and when the means of transportation for the precious
metals were much slower and less efficient than under modern
conditions, and the cost was much greater. Hamilton endeavored to
find the true commercial relation between gold and silver as a basis
for the coinage values, in the hope that this would not change
sufficiently to upset a bimetallic system founded upon such a basis.
He was not a victim of the delusion that government can arbitrarily
give value by law to money, but declared, "There can hardly be a
better rule in any country for the legal, than the market proportion;
if this can be supposed to have been produced by the free and
steady course of commercial principles."
The report on manufactures and the bill providing for an excise were
parts of the project of Hamilton for building up a vigorous and self-
supporting nation. The report on manufactures was not presented to
Congress until the beginning of the long session at the close of
1791, and was not carried out in legislation. It consisted chiefly of an
argument for the encouragement of young industries in an
undeveloped country. Hamilton strongly favored the diversification of
the industries of the country between agriculture and various forms
of manufacture, because he believed it would contribute to the
solidity of the industrial system and to the financial independence of
the United States. His conception of the best method for promoting
American industries differed materially, however, from more recent
developments of the protective system. He recommended bounties
and premiums in many cases in preference to protectionist customs
duties, in order to avoid the rise in the price of articles to the
consumer which often results from such duties. The customs duties
which he proposed, moreover, ranged only from seven and a half to
fifteen per cent., and the latter rate was to be levied on only a few
articles.
The country was not yet ripe for extensive industrial enterprises. The
manufactures then existing were chiefly for supplying local needs,
the factory system had not been introduced, and the capital had not
been accumulated for the creation of large establishments. The
country needed many foreign manufactured articles to put it upon
the highroad to industrial development, and it was at a much later
period that the manufacturing interests acquired the power which
enabled them to increase the scale of duties. When this time came,
they turned to the arsenal of Hamilton's report for weapons in
support of the policy of diversifying industries; but they used these
weapons in behalf of a scale of duties which was not recommended
by him and they ignored his arguments for premiums and bounties
for the protection of the consumer against excessive prices.
Whether Hamilton would have favored the policy of protection in its
later developments, it is useless to inquire. It is idle to claim for any
thinker of the past that he anticipated all future discoveries and
reasoning in the fields of politics or economics. It is not necessary, in
order to give a statesman a high place in history, to worship blindly
all that he did or said or to make such deeds and words an authority
for later generations. What can be said of Hamilton without
reasonable ground of denial is that he did not recommend in any of
his writings the high scale of duties advocated by some
protectionists in recent years. On the contrary, he urged a scale of
duties which would be treated by the protectionist of to-day as
below even the level of a "tariff for revenue only." That his ideas
were far from extreme is indicated by the project which he drew up
in 1794 for a reciprocity treaty with Great Britain, which proposed to
limit American import duties on the leading textiles and
manufactured articles of metal to ten per cent. of their value. He
even criticised Jefferson's message of 1801 for recommending the
repeal of the internal revenue taxes, upon the ground that the duties
on imports were high and that if any taxes were to be repealed, they
should be those which weighed on commerce and navigation.
A measure which led to more immediate results than the report on
manufactures was the report on the excise. Hamilton found it
necessary, in order to obtain sufficient funds to meet the interest on
the debt and other charges, to recommend an excise tax upon
distilled liquors produced in the United States. The bill passed
Congress in January, 1791, and was soon put in force. Violent
resistance was made in western Pennsylvania, where the
manufacture of whiskey was more extensively carried on than in any
other part of the Union. The federal collector for Washington and
Allegheny was tarred and feathered, and deputy marshals did not
dare serve writs against those guilty of the outrage. Washington's
journey through the South had a good effect in softening the
opposition to the law, which first showed itself in Virginia and North
Carolina; but in Pennsylvania conditions went from bad to worse,
until it became necessary to give the federal government additional
powers for collecting the tax and putting down insurrection. Masked
mobs terrorized those who were inclined to obey the law, and forced
them to publish the injury done to their stills. In order to protect
themselves by embroiling the whole community, some of the
insurgent leaders had the mail stopped, the militia called out on their
side, and threatened to lay Pittsburg in ashes (July, 1794).
The opportunity had come for testing the question whether the
Union was strong enough to put down rebellion by force. It was an
opportunity which Hamilton did not shirk. At his earnest solicitation,
an army was dispatched to the disturbed districts. Washington
showed no hesitation in supporting the authority of the federal
government. He obtained a certificate from a judge of the Supreme
Court, setting forth that the laws of the United States were set at
naught and that the courts were unable to enforce them. He then
issued a proclamation commanding the insurgents to submit to the
laws, and made a requisition for 12,950 militia from Pennsylvania,
Maryland, Virginia, and New Jersey, to move on September 1, 1794,
towards the disaffected districts.
The firmness of Washington put an end to the insurrection. Governor
Mifflin of Pennsylvania, who had hesitated to put down the
disturbances by the strong hand of the state, recovered his courage,
and aided the federal government by proclamations and by his full
quota of troops. Hamilton accompanied the army as it moved
towards the West, and remained with it after Washington turned
back to attend the opening of Congress. The strong display of force
made by the government overawed the insurgents and finally
compelled their submission. Albert Gallatin, although a citizen of the
disaffected section and an opponent of the party in power, exerted
his influence on behalf of order. Negotiations were set on foot
between commissioners of the President, and a committee of
citizens, of which Gallatin was a member. When this committee met
to decide whether they would recommend compliance with the law,
they were surrounded by riflemen who were ready to shoot if their
leaders showed signs of yielding. But they adopted the clever device
of a ballot upon which both yea and nay were written, with the
option of destroying either word. A small majority voted to submit.
Some of the obstinate spirits held out, but as the people fell away
from them, they were arrested and put on trial, and the authority of
the federal government was no longer disputed.
This suppression of the "Whiskey Rebellion," as it was called, was
one of the most important steps in the consolidation of the Union.
Many who had observed the aggressive and comprehensive projects
of Hamilton, and seen them daily binding closer the bonds of union,
did not believe that they would stand the test of armed conflict.
They feared that the power of the government would wither and the
people split into warring factions when men were called upon to
march in arms against their fellow-citizens. The event proved that
the new government had vindicated its right to exist, and that the
sentiment of union was daily gaining a stronger hold upon the hearts
of the people. That this new power had not only built up a cohesive
financial system, but had shown its capacity to put down resistance
to its lawful authority with a strong hand, was largely the work of
Hamilton. It may be said that it was wholly his work, so far as any
great national policy can be projected and carried out by a single
man, independently of the support of his associates in the
government and of the body of public opinion which make possible
the execution of his plans.
The time had come when Hamilton felt that his constructive work
was done. He withdrew from the cabinet (January 31, 1795), and
Oliver Wolcott of Connecticut was appointed his successor. Hamilton
chose the moment for retiring from office with a tact and judgment
unusual with public men. He was moved partly by the desire to
provide for his family upon a more liberal scale than his modest
salary under the government permitted. He was too patriotic,
however, to have abandoned his post until he felt that his
constructive work was complete. It was with conscious satisfaction
that in his report on the public credit at the beginning of 1795 he
was able to marshal the measures already taken towards restoring
order to the national finances and point out their results. The credit
of the country had been raised from the lowest abyss of dishonor to
that of the most enlightened nations of the old world; an adequate
system of taxation had been provided for meeting the public
obligations; the business interests had been knit together in support
of the government by a national bank; a monetary system had been
established; the Treasury had been organized in its various branches
upon a basis which has survived to our day; and finally the strength
of the fabric of the Union and of the financial system had been
subjected to the test of a rebellion which, without serious bloodshed,
but with a strong display of force, had been fully and firmly
subdued.
VI
FOREIGN AFFAIRS AND NEUTRALITY
The ratification of the Jay treaty did much to shake the power of the
Federalists, and for a moment seemed to threaten their ruin. It was
divisions in their own ranks, however, which contributed as much to
this event as any real blunders in public policy. Hamilton was not at
his best in conciliating those who differed from him, and he did not
encounter a more yielding or tactful associate in John Adams.
Hamilton had gone out of his way with little reason at the first
presidential election, in 1788, to secure votes against Adams. His
avowed object was to insure the election of Washington by
preventing a tie vote between Washington and Adams. The original
Constitution authorized each elector to vote for two persons for
President and Vice-President, without designating the office for
which either was voted for. This led to complications which were
corrected by an amendment after the election of 1800. In the case
of the first election, however, few sane men doubted that
Washington would have the majority of the votes, and the only
effect of the intrigue of Hamilton was to reduce the vote for Adams
to a point which almost caused his defeat. Hamilton supported
Adams in the second election, in 1792, and the relations between
the two men were reasonably cordial.
When Washington retired from the presidency, in 1797, the
commanding men in the Federalist party were Hamilton, John Jay,
Thomas Pinckney, and John Adams. Hamilton was the controlling
mind in the consultations of the leaders rather than the sort of man
who appealed to the people. He was not seriously thought of by
himself or others as a candidate for President. Jay was barred by the
odium attaching to the treaty with Great Britain. The choice was
therefore reduced to Pinckney and Adams. Most of the leaders were
for Adams, who was superior to Pinckney in Revolutionary services
and ability. It was determined that the Federalist electors should
vote for both Adams and Pinckney, with the purpose of choosing the
former for President and the latter for Vice-President. Hamilton on
this occasion urged that all the Federalist electors should vote for
both Adams and Pinckney. If each had received an equal number of
votes, the choice would have been thrown into the House and
Adams would probably have been elected. Hamilton erred in letting
it be known that he was indifferent whether the outcome was
favorable to Adams or Pinckney, especially when there was a strong
suspicion that he was really for Pinckney. Party discipline had not
then reached its modern development, and votes were thrown away
by Federalist electors,—in the North to prevent a majority for
Pinckney over Adams and in the South to prevent the same chance
in favor of Adams.
The result of these jealousies was that Adams barely escaped
defeat. He was chosen by a plurality of three, but Pinckney was
beaten, and Jefferson, having the next highest vote, was elected
Vice-President. Adams became firmly convinced that Hamilton was
his personal enemy and would stop at nothing to injure him. That
Hamilton was recognized by all the party leaders as the master mind
and the guiding spirit of the party made no difference to a man of
the hot temper and resolute spirit of John Adams. Tact and
conciliation were as far removed from his nature as from that of any
American public man. The indifference of Hamilton whether he was
beaten by Pinckney, in connection with Hamilton's intrigue in 1788,
had convinced Adams that Hamilton did not feel proper respect for
him, and that he was seeking to dictate the policy of the
administration and to thwart and degrade him. Adams resented any
sort of suggestion or consultation, and took delight in disregarding
the suggestions of Hamilton, while the latter struck back through
several members of the cabinet, who were more in sympathy with
him than with the President.
The country having escaped the danger of immediate war with
England by the Jay treaty, was soon threatened with war with
France. Monroe had been recalled as American Minister at Paris and
Charles Pinckney, who was sent in his place, had been refused a
reception. Some of the Federalists were so incensed against France
that they were eager for war. Hamilton was opposed to war if it
could be avoided, but was in favor of a resolute policy. Adams,
although as far as possible from sympathy with France, believed
every reasonable effort should be made to preserve peace. It was
decided, with the approval of both Adams and Hamilton, to send a
commission of three to Paris, to negotiate. Over the appointment of
this commission new differences broke out between Hamilton and
the President. Hamilton favored the appointment of a Northern and
a Southern Federalist and of a Democrat of the highest standing, like
Madison or even Jefferson. Adams was at first disposed to make
these appointments, but finally took both the Federalists from the
South,—Pinckney of South Carolina and John Marshall of Virginia,—
and selected as the third member a Democrat of comparatively
minor standing, Gerry of Massachusetts.
The commissioners accomplished little good at Paris. They were
insulted and browbeaten and told that only bribery would secure
what they desired. When their treatment became known in the
United States, in the spring of 1798, there was a popular outburst
which restored the Federalists to power in Congress in the following
autumn, with a larger majority than ever before since party divisions
became fixed. Enthusiastic addresses poured in upon President
Adams, war vessels were fitted out by private subscription, and bills
were carried at once for a provisional army, for fortifications, and for
the increase of the navy. Even under this stress of excitement,
however, Hamilton opposed alliance with Great Britain, and
persuaded Pickering, the Secretary of State, to abandon the
advocacy of it.
It was over the organization of the new army that the hostility of
Adams to Hamilton became open and bitter. Washington was
selected as commander-in-chief, but only consented to serve upon
the condition that he should have the choice of the officers who
were to rank next him, and should not be called upon to take an
active part until the army took the field. He recommended to the
President that rank in the Revolutionary army be disregarded and
that the three major-generals to be appointed should be Hamilton,
Charles Pinckney, and Knox. This gave the practical command and
the work of the organization to Hamilton. Adams sent the names to
the Senate, in the order suggested by Washington, and they were
promptly confirmed. When he came to signing the commissions,
however, he took the ground that Knox was the senior officer on
account of his rank during the Revolution. Hamilton would not
consent to this arrangement, and all the Federalist leaders, including
members of the cabinet, remonstrated with the President against it.
One of the saddest results of the quarrel was the alienation from
Hamilton of Knox, who had been a friend of many years and when
Secretary of War in Washington's first cabinet had stood loyally by
Hamilton against Jefferson in the controversy over the financial
projects.
Adams at first seemed to grow more stubborn with the protests
which were made against his action. The leaders finally turned to
Washington. The latter informed the President that if the original
agreement as to the rank of the officers was not kept, he should
resign. Adams, with all his stubbornness and bravery, did not dare
defy the country by forcing Washington from the service. He gave
way, and appointed Hamilton to the first place, but the good feeling
which might have been promoted if he had done so at first was
replaced on both sides by bitterness which was never softened.
Hamilton, as the practical head of the army, showed the same
abounding energy and capacity for organization which he had shown
at the head of the Treasury. He drafted a plan for the fortification of
New York harbor, made an apportionment of officers and men
among the states, and drew up projects for the organization of the
new army, dealing with the questions of pay, uniforms, rations,
promotions, police in garrisons and camps, and the many other
branches of the service. All these projects received the cordial
approval of Washington. When Congress met, Hamilton was ready
with a bill putting the army upon a basis which would permit its
increase or diminution in future without changing the form of the
organization. In the spring of 1799 he was providing for the defense
of the frontiers and planning the invasion of Louisiana and the
Floridas.
The projects of these invasions of Spanish territory justify a
reference to the continental policy of Hamilton. He was among the
first to maintain that the United States should have complete control
of the valley of the Mississippi, and even during his short term in the
Congress of the Confederation the last resolution which he
presented declared the "navigation of the Mississippi to be a clear
and essential right and to be supported as such." It was left for
Jefferson, Hamilton's great opponent, to carry out his conception of
the acquisition of the Mississippi valley by the purchase of Louisiana.
The admirers of Hamilton credit him with a still wider vision of the
future power of the United States, which was eventually to bear fruit
in the Monroe doctrine and in the celebrated declaration of Secretary
Olney in 1895, that "to-day the United States is practically sovereign
on this continent, and its fiat is law upon the subjects to which it
confines its interposition." Hamilton wrote in "The Federalist," before
the adoption of the Constitution, that "our situation invites and our
situation prompts us to aim at an ascendant in American affairs."
The firm attitude of the United States towards France had its effect
at Paris. Talleyrand sent an intimation indirectly to President Adams
that the French government would be glad to receive an American
envoy. Again the impetuosity of Adams divided his party and
intensified his quarrel with the leaders who stood around Hamilton.
The name of Vans Murray was sent to the Senate by the President
for Minister to France, without even consulting the cabinet. Many
doubted the wisdom of snapping up so promptly the offer made by
Talleyrand, and more were incensed at the President's method of
doing it. There was at first a strong disposition among the Federalist
leaders to defeat the nomination in the Senate. Hamilton, however,
checked the indignation of his friends and suggested a way out of
the difficulty by appointing a strong commission.
The downfall of the Federal party and the retirement of Hamilton
from the active control of national policy were at hand. The passage
of the alien and sedition laws, arrogating to the federal government
intolerable powers of interference with the rights of the press and of
free speech, was one of the causes contributing to the revulsion of
feeling in favor of the party of Jefferson. Hamilton opposed the first
drafts of these laws as cruel, violent, and tyrannical, but he did not
disapprove their final form. The Federalists carried the congressional
elections of 1798, under the impulse of the feeling against France,
but began to lose ground soon after. As the presidential election of
1800 approached, a desperate struggle was made to hold New York
for Federalism as the only hope of defeating Jefferson and reëlecting
Adams. The New York election went against the administration, and
Hamilton pleaded in vain with Governor Jay to defeat the will of the
people by calling the old legislature together and giving the choice of
presidential electors to the congressional districts. It was perhaps
the most discreditable proposal which ever came from Hamilton, and
was promptly rejected by Jay.
Hamilton's motive was a sincere fear that the country would go to
ruin and the Constitution be endangered by the triumph of the
political school of Jefferson. This might have been the case if it had
been the first election under the Constitution, but Hamilton himself
had builded better than he knew. The financial projects, the national
bank, the suppression of the "Whiskey Insurrection," and the other
measures taken under Washington and Adams had built up a Federal
Union, whose strength could not be seriously shaken by the transfer
of power from one party to another.
With the shadow of defeat hanging over them, the course of the
Federalist leaders seemed to justify the maxim, "Whom the gods
destroy they first make mad." With the utmost need for harmony
and unity, quarrels broke out which would have wrecked the party
even if there had been otherwise some prospect of its success.
Adams drove McHenry and Pickering from his cabinet because they
had betrayed his secrets to Hamilton, and denounced Hamilton and
his friends as a British faction. Hamilton asked in writing for a denial
or explanation of the charge, but was treated with contemptuous
silence. As the presidential election approached, Hamilton scarcely
concealed his preference for Pinckney, who was again to be voted
for by the electors along with Adams. Hamilton had been so badly
treated by the President that he announced his purpose to prepare a
pamphlet, exposing the failings of Adams and vindicating his own
position.
His best friends stood aghast at the project and labored with him to
abandon it. Hamilton persevered, however, in the preparation of the
pamphlet. He denounced Adams as a man of disgusting egotism,
intense jealousy, and ungovernable temper, and reviewed in a
scathing manner his entire public career, and especially the recent
dismissal of the secretaries who were friendly to Hamilton. After all
this criticism, Hamilton wound up with the lame conclusion that the
electors should vote equally for Adams and Pinckney, in order to
preserve Federal ascendency. He yielded to the protests of his
friends so far as to keep the circulation of the pamphlet within a
small circle, but it was hardly off the press before a copy was in the
hands of Aaron Burr, the Democratic leader in New York, and was
used with effect against the Federalist President.
The downfall of Federalism came with the presidential election of
1800. Jefferson and Burr were the Democratic candidates for
President and Vice-President. Each was voted for by all the
Democratic electors, giving them an equal number of votes and a
majority of the electoral college. This threw the election into the
House of Representatives, which was Federalist but was compelled
by the provisions of the Constitution to decide between the two
leading candidates, Jefferson and Burr. Some of the Federalists were
ready to stoop to any means for striking at Jefferson, the great
representative of Democratic ideals. If the Federalists in Congress
could have effected a combination with the Democrats from states
where Burr was influential, they might have been able to elect Burr
President instead of Jefferson. But the Democrats, even from New
York, voted for Jefferson, and it was evident that he must be chosen
or there would be no election. Feeling in the country ran high, and
there were threats of violence if the election of Jefferson should be
defeated by intrigue.
Hamilton behaved on this occasion with the high sense of public
duty which marked most of his acts. Familiar as he was with the
unscrupulous methods and doubtful character of Burr in New York
politics, he felt that it would be criminal to put him in office. He had
little reason to love Jefferson, who had filled the ears of Washington
with slurs against himself, but he felt that the election belonged to
Jefferson and that his defeat by a political intrigue would be a
greater menace than his election to the system established by the
Constitution. With Bayard of Delaware, the Federalist leader in the
House, Hamilton threw himself strongly into the contest against Burr.
His advice was not at first followed. The House ballotted from the
eleventh to the sixteenth of February without reaching a choice. A
caucus of the Federalists was then held; it appeared that Jefferson
had given some assurances of a conservative policy in office, the
views of Hamilton and Bayard prevailed, and on February 17, 1801,
the Federalist members from several states withheld their votes, and
Jefferson was elected.
The retirement of the Federalists from power substantially ended the
public services of Hamilton. He continued to watch public events
with interest during the remaining five years of his life, and to be
regarded as the leader of the Federalist party, but the party had
shrunk to a corporal's guard in Congress and the long reign of the
Democratic party had begun, which was to be interrupted during
only two presidential terms until the election of Lincoln in 1860.
Hamilton, therefore, at the age of forty-three, had completed his
constructive work and ceased to influence public affairs except by
his writings and speeches. It might almost be said that this work
was done with the close of the administration of Washington in
1797, and that his great fame would have shone with brighter lustre
if he had not lived to take part in the later differences and quarrels
of the Adams administration. His life was not without service,
however, under Adams, since his influence over members of the
cabinet several times restrained rash policies, and between the
conflicting passions of the champions of France and of the friends of
Great Britain, kept the ship of state steady upon a safe course.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookname.com