Practical Numerical Computing Using Python 1st Edition Mahendra Verma download
Practical Numerical Computing Using Python 1st Edition Mahendra Verma download
https://ebookmeta.com/product/practical-numerical-computing-
using-python-1st-edition-mahendra-verma/
https://ebookmeta.com/product/practical-explainable-ai-using-
python-artificial-intelligence-model-explanations-using-python-
based-libraries-extensions-and-frameworks-pradeepta-mishra/
https://ebookmeta.com/product/architecture-of-advanced-numerical-
analysis-systems-designing-a-scientific-computing-system-using-
ocaml-1st-edition-liang-wang/
https://ebookmeta.com/product/the-practice-of-computing-using-
python-3-regular-edition-william-punch-richard-enbody/
https://ebookmeta.com/product/intelligence-in-energy-1st-edition-
gulgun-kayakutlu/
Rational Points on Elliptic Curves 2nd Edition Joseph H
Silverman John T Tate
https://ebookmeta.com/product/rational-points-on-elliptic-
curves-2nd-edition-joseph-h-silverman-john-t-tate/
https://ebookmeta.com/product/heritage-culture-and-identity-1st-
edition-hamzah-muzaini/
https://ebookmeta.com/product/contraception-and-persecution-1st-
edition-charles-e-rice-alyssa-bormes-steve-mosher/
https://ebookmeta.com/product/suits-a-woman-on-wall-street-1st-
edition-nina-godiwalla/
https://ebookmeta.com/product/music-and-mental-imagery-1st-
edition-mats-b-kussner/
The Independent Republic of Arequipa Making Regional
Culture in the Andes Thomas F Love
https://ebookmeta.com/product/the-independent-republic-of-
arequipa-making-regional-culture-in-the-andes-thomas-f-love/
Contents
Preface
Chapter One
Introduction to Computing
Computer Hardware
Supercomputers & Computation Complexity
Computer Software
Brief Overview of Python
Anaconda Python, Notebooks, and Prutor
Applications of Computers
Chapter Two
Integers
Floating Point and Complex Numbers
Python Variables and Logical Variables
Chapter Three
Chapter Four
Simple Statements
Conditional Flows in Python
Looping in Python
Chapter Five
Functions in Python
Python Namespace and Scope
Recursive Functions
Chapter Six
Chapter Eight
Chapter Nine
Error Analysis
Nondimensionalization of Equations
Numerical Methods
Chapter Ten
Lagrange Interpolation
Splines
Chapter Eleven
Newton-Cotes Formulas
Gaussian Quadrature
Python's Quad & Multidimensional Integrals
Chapter Twelve
Computing Numerical Derivatives
Chapter Thirteen
General Overview
Euler Forward Method, Accuracy & Stability
Implicit Schemes
Higher-order Methods
Multistep Method
Solving a System of Equations
Stiff Equations
Chapter Fourteen
Fourier Transform
One-dimensional Discrete Fourier Transforms
Mutlidimensional Fourier Transform
Chapter Fifteen
Chapter Sixteen
General Overview & Diffusion Equation Solver
Solving Wave Equation
Burgers and Navier-Stokes Equations
Schrodinger equation
Chapter Seventeen
Root Finders
Chapter Eighteen
Shooting Method
Eigenvalue Calculation
Chapter Nineteen
Chapter Twenty
Chapter Twenty-One
Random numbers
Integration Using Random Numbers
Regression Analysis
Applications in Statmech
Machine Learning
Epilogue
Appendix A: Errors in Lagrange Interopolation
Appendix B: Improving Accuracy Using Richardson Method
References
Preface
At present, friendly, yet, powerful tools have been developed for computer
programming. One such tool, the programming language Python is versatile, but
easy to learn. It is being used in wide range of applications: scientific computing,
data analysis, machine learning (ML) and artificial intelligence (AI), internet
programming, GUI, etc. At present, researchers are employing Python for
numerical computing, as well as for AI and ML.
Keeping this in mind, I chose Python as the programming language for
teaching numerical computing in my Computational Physics course
(PHY473A). I also use Python for post processing and for writing large
softwares including parallel programs. The present book is a compilation of the
course material and the tools developed in our computational laboratory. The
contents and the usage of the book is discussed below.
Contents of the book: The book has two parts. The first part covers the Python
programming language in a reasonable detail, while the second part contains the
numerical algorithms and associated Python codes. The book contains
discussions on important numerical tools: interpolation, integration,
differentiation, solvers for ordinary and partial differential equations, Fourier
transforms, boundary value problems, linear algebra, and Monte Carlo methods.
In addition, I also include plotting tools, error analysis, nondimensionalization,
and an overview of computer hardware and software.
The computer programs in the book have been tested. These codes are
available at the website https://sites.google.com/view/py-comp. The website will
also host affiliated material, such as PPTs, video lectures, color figures, etc.
Usage of the book: This book is suitable for advanced undergraduate and
graduate students. It does not assume any programming background, but it does
require basic understanding of calculus and differential equations. The material
could be covered in 40 lectures at a fast pace. However, I recommend that the
instructor and students can skip topics that they find complex or somewhat
unnecessary.
Programming is learnt by practice. Hence, I strongly urge the students to
program enthusiastically. One could start with the examples and then do all the
exercises of the book. In my course, we used Prutor (https://prutor.ai) for
evaluating the exercises submitted by the students. We plan to provide the
exercises of the book on Prutor.
Feedback request: I request the readers to send their comments and feedback to
me at [email protected]. Even though I have strived to make this book error-free, I
am sure some lacuna still remain. I will be grateful if such errors are brought to
my attention.
Mahendra Verma
IIT Kanpur
CHAPTER ONE
Introduction
Synopsis
COMPUTER IS ONE device that has impacted all walks of life. It is employed
for scientific research, e-commerce, banking, cloud computing, etc. On a
personal level, we use computers for surfing internet, emailing, social
networking, etc. See Section Applications of Computers for some of the
computer applications.
ENIAC (Electronic Numerical Integrator and Computer, made in 1945) was
the first general-purpose digital computer. It was used for making Hydrogen
bomb and Monte Carlo simulations. A succession of better and faster computers
have been built since then. Scientists and engineers have used these machines for
research in physics, chemistry, biology, fluids, engineering, geophysics, and
astrophysics. In this book, we will focus on generic computation tools used in
science and engineering.
Both hardware and software have evolved leaps and bounds over the years.
In early days, Fortran, short form for Formula Translation, was the de facto
programming language for scientific applications. Even though Fortran is still a
dominant language in scientific programming, many scientists and engineers
have moved to modern languages such as C, C++, and Python. Among these
languages, Python has become very popular due to its simplicity and availability
of large number of Python modules. In this book, we will use Python language
for writing programs. An added benefit of Python is that it has excellent post-
processing tools, such as plotting, reading/writing data, etc. In addition, Python
is widely used in machine learning (ML) and artificial intelligence (AI). Python
is also becoming popular for high-performance computing (HPC). However, in
this book we will not cover ML, AI, and HPC.
Traditionally, a scientist was either an experimentalist or a theorists. The
former primarily work on experiments, while the latter on theoretical modelling.
However, after the prominence of computers, a new category of researchers
called computational scientists have emerged. These researchers excel in
designing computers and writing large softwares. Another important point to
note is that computers are often used to simulate physical systems, e.g., Earth’s
atmosphere, stars, galaxies, large molecules, automobiles, etc. Thus, computers
perform virtual experiments. Scientists strive to make accurate models of
physical systems using the inputs from experiments and/or computer
simulations. Thus, computers provide an interesting and powerful window of
opportunity for understanding the world.
Often, experiments and computer simulations complement each other. For
example, hydrodynamic experiments can achieve very high Reynolds numbers,
but computer simulations can reach only moderate Reynolds numbers (105).
However, computer simulations can probe velocity field at any point of the flow,
which may not be possible in many experiments (e.g., in an opaque liquid). Also,
it is impossible to perform experiments on a star, but we can comfortably
simulate stars on a computer, at least, approximately.
This book is ideally suited for advanced undergraduate and early graduate
students. Part-I of the book includes discussions on Python language. In this
part, I also cover error analysis and basics of computer hardware, whose
knowledge is required for estimating memory and time complexity of a
computational problem. Part-II of the book covers introduction to computational
methods—numerical interpolation; integration; differentiation; solvers of
ordinary and partial differential-equations; Fourier transforms; linear algebra;
Monte Carlo methods; etc. I have attempted to present these topics coherently by
highlighting connections among them. For example, the formulas of numerical
integration are derived using Lagrange interpolation.
I hope you will enjoy learning these tools.
COMPUTER HARDWARE
FOR AN EFFICIENT use of a car, it is best to know some of its details: its
milage, power of the engine, nature of the brakes, etc. Similarly, an optimal use
of a computer requires knowledge about its memory capacity and power of the
processors. In this chapter, we provide a basic overview of a computer and its
components.
von Neumann Architecture
Let us get a deeper perspectives on the processor, memory, and hard disk.
Processor: The processor, also called central processing unit (CPU), is the most
complex and critical component of a computer. This unit can perform billions of
arithmetic and logical operations per second. For example, the processor adds
two numbers A and B. An important thing to note is that the numbers A, B, and
A+B are stored in a small memory, called registers, of the CPU.
Now we provide a quick overview of the capabilities of one of the best
processors of today. Rome processor (EPY 7002) contains 64 cores residing in
16 blocks of 4 processors each (see Figure 2). The cores of the processor
communicate with each other via the memory block in the middle. Note that
each core has its own L1 and L2 caches, but 4 cores of a block share 16 MB of
L3 cache. Cache, being closer to the core, is faster than RAM. The cores
communicate with each other, as well as to the RAM and PCI devices, via buses.
The clock speed of the processor is 2.5 GHz, which can boosted up to 3.4
GHz. A Rome processor can perform 16 floating-point operations per clock
cycle. Hence, the peak performance of each core can be estimated to be 16x2.24
≈ 35 Giga floating-point operations/second (FLOPS in short). Consequently, a
Rome processor can perform maximum of 35 x 64 cores ≈ 2.24 TeraFLOPS or
TFLOPS. Note however that this is the peak performance, which is not achieved
in typical programs due to various constraints. Such information is useful for
estimating the time for a computing job.
Intel too has fast processors, which are not covered here. Apple’s M1 chip
has 8 compute cores, 8 GPU (graphical processing unit) cores, and 8 neural
engine cores.
Figure 2: Inside Rome 7742 processor, black bidirectional arrows are the buses
that transmit data both ways.
Memory: The data and programs reside in computer’s memory (the green strip
inside the motherboard of Figure 1), also called random access memory (RAM).
The CPU reads the program and data from RAM and write the results back on it.
Note that RAM is active only when the computer is powered on, hence it is a
temporary memory. We need to write the data to the hard disk for permanent
storage.
A laptop or desktop has RAM in the range of 4 Gigabytes to 64 Gigabytes.
Note that 1 byte = 8 bits, and
1 Kilobyte = 1 KB = 210 ≈ 103
1 Megabyte = 1 MB = 220 ≈ 106
1 Gigabyte = 1 GB = 230 ≈ 109
1 Terabyte = 1 TB = 240 ≈ 1012
1 Petabyte = 1 PB = 250 ≈ 1015
1 Exabyte = 1 EB = 260 ≈ 1018
The clock speed of RAM ranges from 200 MHz to 400 MHz, which is slower
than processor’s clock speed. The fastest RAM available at present, DDR4
(double data rate 4), transfers data at the rate of 12.8 to 25.6 Gigabits/second,
which is quite slow compared to CPU’s data processing capability. Following
strategies are adopted to offset this deficiency of RAM:
1. The motherboard has multiple channels or roads for data travel between the
CPU and the RAM.
2. The CPU has its own memory called cache. The data which is needed
immediately is kept in the cache for a faster access.
Hard disk (HD) and Solid-state disk (SSD): HD and SSD are permanent
storage of a computer. Programs and data reside here safely after the computer is
powered off. When a computer is powered on, the required programs and data
are transferred from the HD to the RAM; this process is called boot up. Hence,
the CPU, RAM, and hard disk continuously interact with each other.
A hard disk is an electro-magnetic device in which magnetic heads read data
from the spinning magnetic disks. In these devices, the data transfers rate to
RAM is 100-200 Megabytes (MB) per second. Due to the moving parts, HDs are
prone to failure, specially in laptops during their movements. In the market, we
can buy HDs with capacities ranging from 1 TB to 20 TB.
On the other hand, a SSD is purely an electronic device with no spinning
parts. Hence, SSDs are safer than hard disks, but they cost more. The data
transfer rate in SSD is around 500 MB per second. The capacity of SSD ranges
from 128 GB to 1 TB.
A keyboard, a trackpad, a mouse, and a camera transmit inputs to the CPU via
bluetooth or Universal Serial Bus (USB) or USB-C ports. The CPU processes
these inputs and sends outputs to an external monitor, a TV, a projector, or a
printer. The data is exchanged among the input/output devices via ports,
bluetooth, or wifi (see Figure 3).
Computers come in different avatars, but their basic design remains the
same. Desktops, which are typically more powerful than laptops, sit on desks.
Workstations or compute servers have stronger CPUs and larger memory, hence
they are more powerful than desktops. Supercomputers are built using many
servers. We will provide brief description supercomputers in Section
Supercomputers & Computation Complexity.
Mobiles and tablets too are computers. They too have processors and
memory, and they perform similar operations as a desktop/laptop. However,
these mobile devices are weaker than laptops and consume much less power.
The aforementioned hardware units by themselves cannot perform any task.
A complex program called Operating System (OS) gives life to these systems.
The OS, applications (such as Microsoft Word), and user programs are called
software, and they will be briefly described in Section Computer Software.
Figure 3: (a) Laptop; (b,c) Ports of a laptop. Adopted from a figure of
wikipedia.org
********************
Conceptual Questions
1. List the following for your laptop/desktop and your mobile phone: RAM
size, CPU clock speed, Hard disk, and/or SSD capacity.
2. It is best to see the parts of an opened-up desktop. However, do not open
your laptop because it is tricky.
3. Read more about the processors.
SUPERCOMPUTERS & COMPUTATION
COMPLEXITY
1. 158,976 nodes each with 48-core A64FX processor (2 GHz clock speed).
Total number of cores: 7,630,848; Power: 29.899 kilowatts
2. Total memory: 4,866,048 GB
3. Peak speed: 442,010 Tera floating-point operations per second (TFLOPS)
4. Interconnect: Tofu interconnect D
We remark that supercomputers employ high-end processors, e.g., Rome
processor, discussed in Section Computer Hardware. Graphical processing units
(GPUs) too are being used heavily in supercomputers. Each GPU contains
thousands of processors, and it can perform huge number of floating-point
operations. GPUs are heavily used in machine learning. Nvidia’s top-end GPU
A100 has 6912 compute cores, and its peak double-precision performance is 7.8
TFLOPS.
Example 1: We need to multiply two arrays A and B of sizes 104x104 and store
the result in array C. For this problem we need 3 arrays of 108 elements each.
Storage of 3x108 real numbers requires 8x3x108 = 24x108 bytes of storage,
which is 0.24 GB. For 105x105 arrays, the corresponding requirement is 24 GB.
The simplest algorithm for multiplication of two NxN arrays requires
approximately N3 multiplications and additions. Therefore, for N = 104, we need
1012 floating-point multiplications and additions. We estimate the peak
performance of a typical laptop with a 4-core CPU to be 50 GFLOPS. Hence, in
the best case scenario, the 2x1012 floating-point operations would require
2x1012/(50x109) ≈ 40 seconds. Here, the prefactor 2 is for the addition and
multiplication.
The retrieval and storage the array elements from/to memory require
additional time. In addition, a laptop/desktop also performs other operations such
as system management, internet browsing, email checking, etc. The processor
works on these tasks in a round-robin and time-sharing manner. Consequently,
we expect that multiplication program to take much larger than 40 seconds.
However, we do not expect the run to go much beyond several (say 10) minutes.
For N = 105, the time complexity will be 1000 x 40 seconds ≈ 666 minutes ≈
11 hours. Hence, the space and time requirements for N = 105 are respectively 24
GB and 11 hours that go beyond the capabilities of a typical laptop.
Example 2: For weather prediction, a computer solves the equations for the flow
velocity, temperature, humidity, etc. For the same, Earth’s surface is divided into
a mesh, as shown in Figure 5. High-resolution simulations employ grid
resolution of 3 km x 3 km that leads to 12000x12000 horizontal grid points.
Suppose, we take 1000 points along the vertical direction, then the total number
of grid points for the simulation is 144x109. At each grid point, we store the
three components of the velocity field, pressure, temperature, humidity, and C02
concentration. Hence, to store these seven variables at each grid point, we need
8x7x144x109 = 8.064 TB of memory, which is way beyond the capacity of a
laptop/desktop. Clearly, we need a supercomputer for weather prediction. The
estimation of time requirement for a weather code is quite complex, and it is
beyond the scope of this book.
Figure 5: For weather simulation, a sample grid on the surface of the Earth.
Courtesy: Wikipedia
With this, we close this section.
********************
Conceptual Questions
1. A processor has 20 cores that operate at clock speed of 3 GHz. Each of its
cores can perform 20 floating-point operations per clock cycle. Estimate the
peak FLOPS of the processor.
2. Visit the website top500.org and study the top 10 supercomputers of the
world. Compute the maximum FLOP rating of their processor, and then
compute the peak performances of the supercomputers.
3. Estimate the memory requirements for storing the following arrays:
a. Three-dimensional integer array of size 1000x1000x1000.
b. Three-dimensional float array of size 1000x1000x1000.
c. 108 spins that can take values up or down.
4. We want to search for a word in text of 300 words. How many comparisons
are required in the worst-case scenario?
5. Estimate the number of comparisons required to search for a word in a
dictionary with N words.
6. Consider a matrix multiplication operation A = BxC, where each of them
are NxN matrices. If you were to perform the above multiplication on a
server with 4 TB RAM and 4 Rome processors, estimate the largest
possible N for this server. How long will it take to perform this operation?
COMPUTER SOFTWARE
1. Memory management
2. Process management
3. Management of input/output devices (keyboard, display, printer, mouse,
etc.)
4. Computer security
5. Management of application softwares (to be described below)
6. Interactions with users via input/output devices
7. Compilation and execution of user programs
The leading OS of today’s computers are Unix and Windows. Linux and MacOS
(the OS of Apple Computersis) are another variants of Unix. Unix itself consists
of many programs, which are categorised into two classes: Unix Kernel and Unix
Shell. See Figure 6 for an illustration. Note that OS of mobile devices—iOS,
Android, and Windows—have limited capabilities.
Figure 6: A schematic diagram of various components of Unix OS.
Application Softwares
1. Get numbers A and B from the memory and put them into the CPU
registers.
2. Add the numbers and put result A+B into another register.
3. Transfer the result from the register to the memory.
In [1]: x=3
In [2]: x
Out[2]: 3
In [3]: y=9
In [4]: print(x+y)
12
In the above, the statements after In [1], In [2], In [3], and In [4] are typed by the
user, while Out [2] and the number 12 after In [4] are the response of the
interpreter. Note that the interpreter replies to the user instantly, unlike compliers
who respond to the user after executing the complete code.
In the next section we will provide an overview of Python programming
language.
********************
Conceptual Questions
The other differences between Python 2 and Python 3 are quite technical to be
discussed here. In this book, we follow Python 3.
(base) ~/python
Python 3.7.4 (default, Aug 13 2019, 15:17:50)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more
information.
>>> 2+3/4
2.75
>>>
In this book, we recommend Ipython interactive shell with pylab option, which
imports Numpy and Matplotlib.pyplot modules. Ipython does not consume as
much RAM as GUI packages, e.g., Spyder. For invoking ipython, we type the
following at the terminal prompt:
(base) ~/ipython --pylab
Python 3.7.4 (default, Aug 13 2019, 15:17:50)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.
Using matplotlib backend: MacOSX
In [1]: 2+3/4
Out[1]: 2.75
1. Numpy: Numpy is a short form for Numerical Python. This module contains
mathematical functions, such as sin, cos, log, sqrt, etc. Also, Numpy
contains optimized functions for array operations.
2. math: This module contains various mathematical functions. Many
mathematical functions, e.g., trigonometric, logarithm, exist in both Math
and Numpy, but some exist in only one of them. For example, the function
factorial exists in Math module, but not in Numpy.
3. Matplotlib: This Python module helps create beautiful plots.
4. Scipy: This module contains advanced scientific functions for integration
and differentiation, interpolators, differential equation solvers, linear
algebra operations, special functions, etc.
5. Pandas: This module is useful for data analysis and plotting.
6. Turtle: Using turtle module, we can create geometrical figures.
7. Sympy: This module is used for symbolic processing.
In this book we will deal with Numpy, Math, Matplotlib, and Scipy modules
extensively. To use these libraries, we need to import them. An illustration of
import operation is given below. Here, math module is imported as ma.
In [7]: ma.factorial(5)
Out[7]: 120
Python documentation and Help: Python is one of the best documented
programming languages. There are a large number of websites and books on
various topics of Python. You can just type what you are looking for in google,
and you will find an answer.
Python offers useful online help in the interpreter itself. For example, you
can get description of plot, sqrt, etc. by just typing the requisite functions after ?.
This is useful if you have forgotten the syntax. Two examples are here:
In [**1**]: ? plot
In [**2**]: ? sqrt
Creating a Python File Using an Editor
Note that a Python program needs to be properly indented. That is, we need to
put blocks of code together by placing same number of blank spaces for each
line of the block. In the code of Figure 7, lines 5 to 12 belong to the function
sum_digits(n), hence they are shifted by equal number of spaces, here 4 spaces.
Note however that line 10 is indented further by placing another 4 spaces. This is
because the statement my_sum += int(k) is within the for loop, i.e, it executed for
each k of the loop. Note that you can choose any number of spaces for
indentation; the only condition is that this number must be the same for all the
lines of the code block. Keep in mind that if we do not provide these spaces, the
code will not run. Indentation is a must for Python codes!
We can save the file in the same folder in which Ipython is running. This file
can be executed in Ipython window using a command ``run filename”. For
example, a file named sum_of_digits.py that contains the function definition of
sum_digits() is run in Ipython as follows:
In [116]: sum_digits(128)
Out[116]: 11
Python C
1 An Interpreter language A compiler language
2 No variable declaration Variables need to be declared
3 No need to declare variable type Defining variable type is mandatory
4 Dynamically typed Statically typed
Python has a large set of libraries.
5 Python is used heavily in Machine A limited set of libraries available.
Learning and Artificial Intelligence.
6 Easy syntax Relatively harder syntax
7 Easy testing and debugging Relatively harder to test and debug.
8 Code development is fast Code development is slow
Used for developing systems
9 Used heavily for postprocessing
programming and large codes.
10 Code execution is slow Code execution is fast
Compilers optimise the object codes
Interpreters do not generate as
11 efficient codes as compilers. by taking into considerations the
data structures and loop structures.
Parallel programming in Python
Parallel programming in C using
12 using multithreading and
MPI and OpenMP.
multiprocessing
Reference Type (see Sec. Mutable
13 Value Type
and Immutable Objects in Python)
********************
Other documents randomly have
different content
will keep their eyes from yours; and, in the same way, this law may
be repealed. I can, therefore, see no force in this objection. The
courts of justice undertake to expound the constitution, and shall not
the House of Representatives be as competent to do this as any
court of justice? I will suppose a case, that of a man condemned
under the Sedition law by a tribunal of justice. Suppose men of
different principles come on the bench, would they hesitate to
reverse the preceding decision of the court? Indisputably not. Here,
too, then, we would behold varying and repugnant decisions.
Mr. Eppes.—I have no doubt that every objection which can be
made to a member of this House holding a civil office during his
continuance as a Representative, applies with equal force to his
holding a lucrative contract. The framers of the constitution in
excluding civil officers from the floor of this House, most certainly
intended to prevent any species of dependence which might
influence the conduct of the Representative—to prevent his looking
up for preferment to the Executive, or being biased in his vote by
Executive favor. A lucrative contract creates the same species of
dependence, and every objection which could be urged against an
officer, applies with equal force against contractors, who are
dependent on the Executive will, and particularly carriers of the mail.
While, however, I make this admission, I do not believe we have
power to pass this resolution. The words of the constitution are: “No
person holding an office under the United States shall be a member
of either House during his continuance in office.” These words are
plain and clear. Their obvious intention was to have excluded
officers, and officers only. It would certainly have been equally wise
to have excluded contractors, because the reason for excluding
officers applies to them with equal force. We are not, however, to
inquire what the constitution ought to have been, but what it is. We
cannot legislate on its spirit against the strict letter of the
instrument. Our inquiry must be, is he an officer? If an officer, under
the words of the constitution, he is excluded; if not an officer, we
cannot exclude him by law. It is true, as has been stated, that, by
the constitution, we are made the judges of the qualifications of our
own members. This judgment, however, is confined within very
narrow limits. The constitution prescribes the qualifications of a
member. We can neither narrow nor enlarge them by law. Our
inquiry can go no further than this: has the Representative the
qualifications prescribed by the constitution? An extensive meaning
has been given to the word “office.” How far such a construction of
the meaning of this word is warranted, I leave for others to decide.
That all contractors are not officers, I am certain. A man, for
instance, makes a contract with the Government to furnish supplies.
He is certainly not an officer, according to the common and known
acceptation of that word. He is, however, a contractor, and, under
this resolution, excluded from a seat here. A carrier of the mail
approaches very near an officer. The person takes an oath, is subject
to penalties, the remission of which depends on the Executive. His
duties are fixed and prescribed by law. Near, however, as this species
of contract approaches to an office, I do not consider that the word
“office” in the constitution can include even this species of contract.
I consider the word “office” in the constitution ought to be construed
according to the usual import and meaning of that term; and as I do
conscientiously believe that the word “office” and the word
“contract” cannot be tortured to mean the same thing, I shall vote
against the resolution.
Mr. Alston.—While I am as much opposed as any man to see any
holder of public money within these walls, I cannot justify myself in
declaring what is or what is not the constitution. If in any case this
ought to be done, this surely should be the last. What is its effect?
To deprive a member of his seat on the vote of a bare majority,
when the constitution has declared that “no seat shall be vacated,
but on the vote of two-thirds of the members.” Let this House say
so, and what becomes of a contractor, if any such there be within
these walls? The decision of the House will be in violation of the
constitution. No man who knows me will imagine that I have any
partiality for contractors holding seats within these walls. I have
never held a contract, or received a cent of the public money but for
my wages as a member of this House. I am, therefore, as
disinterested as man can be on this point. If there is a contractor
within the meaning of the constitution, let him be pointed out. I am
not certain how I shall vote upon such a proposition. But I will not
declare beforehand a particular construction of the constitution. If I
believe the case comes within the constitution, of which I am not
certain, I will vote for clearing the House of such a member. But I
will not consent to a majority declaring in this way what they cannot
carry into effect. How can this be done? If you cannot get two-thirds
of the members of this House to vacate the seat, I ask what
becomes of the resolution declaratory of the meaning of the
constitution? But it is idle to pass a declaratory resolution unless it
can be carried into effect. One thing I will say, if the mover will
modify his resolution so as to impose a penalty on any officer who
shall make a contract with a member of Congress, I will give it my
consent. For I wish to see no man in these walls dependent on the
Government. I still adhere to the principle which I set out with,
when I entered into public life, for I became a member of the
legislature of the State which I have the honor to represent at the
age of twenty-one; but there was no office in the gift of any
government which I would possess. This is a principle to which I
strictly adhere, and I do not believe I have any relation on earth who
holds an office, numerous as my relatives are.
Mr. R. Nelson said he was sorry that he could not on this occasion,
consistent with the oath he had taken to support the constitution,
advocate the resolution under consideration. He agreed that it was
highly improper for contractors to hold seats in that House, as there
were many cases in which they could not give a free and impartial
vote; but in his opinion there was no power to exclude members
from a seat, unless that power was contained in the constitution. He
said he would give his idea of the spirit and meaning of the
constitution on this point. They were bound by its letter—where the
letter and the words of it were plain, they were bound strictly to
adhere to them; where, from the wording, the meaning was
doubtful, or difficult, every member was bound to put that
construction which his judgment dictated. But where there was no
difficulty, where the words were plain and obvious, he would ever
raise his hands against what was called the spirit of the constitution,
or, in other words, giving it a meaning which the words would not
bear. If this power existed in the constitution, it must be found under
that section which declares, that “No Senator or Representative
shall, during the time for which he was elected, be appointed to any
civil office under the authority of the United States, which shall have
been created, or the emoluments of which shall have been
increased, during such time; and no person holding any office under
the United States shall be a member of either House, during his
continuance in office.” The question then comes to the single point:
Is a contractor an officer under the constitution? If he is, there is no
doubt he may be excluded from a seat in this House; but if he is not,
he cannot be excluded. What then is the idea of an officer under the
constitution? It either must be recognized by the constitution, or
some law passed in conformity to it, for no man under the
Government has a right without law to create as many offices as he
pleases. The Postmaster-General has a right to contract for carrying
the mail; he may employ for this purpose fifty, five hundred, or five
thousand men. Will any body thence contend that the Postmaster-
General has the right of creating five thousand offices? Our
constitution has been justly extolled as the freest in the world, and
as the best calculated to promote the happiness and security of the
people. It has been called free in contradistinction to those despotic
governments, where all the offices are held up to sale. Is not this
the case with contracts? Are they not uniformly given to the lowest
bidder? What government of principle then is this, which proposes to
put a construction upon the constitution, by which offices under the
Government shall be thus exposed to sale? But are they in truth
officers of the United States, recognized either by the constitution or
laws? No, they are not officers of the United States, they are mere
hirelings of the Postmaster-General; he has not the power of setting
up the constitution to the highest bidder. If so, it is no longer a free
constitution; it does not deserve the eulogiums which have been so
justly passed upon it.
Mr. Early.—I would not rise to trouble you were not the yeas and
nays to be recorded on this question. I am as fully sensible as the
honorable mover of the resolution, or any other gentleman on this
floor, of the extreme impropriety, to say the least of it, of persons
remaining members of this House who hold a contract under the
Government to which any emolument is attached. With him and
them I believe, that of all descriptions of appointment, this is the
most improper to be blended, where the emoluments are not fixed
by law, but rise or fall with circumstances. I am therefore as willing
as any person can be to adopt any measure to effect a remedy of
this evil, which we possess the constitutional right of doing. My
difficulty on this subject is not the same with that presented to the
minds of some gentlemen, that we are not authorized to pass a
resolution putting a construction upon the constitution. On this
subject, by the constitution we are made judges of the qualifications
of the members of this House. If so, we are necessarily judges of
their disqualification also. One power implies the other. I therefore
have no difficulty on this score. The simple question is, in my mind,
whether a contractor is an officer under the constitution? My own
opinion is decidedly in the negative—an opinion formed after the
most mature reflection. I can appeal to you, sir, that I have sought
after truth on this subject with industry; and I can appeal to other
members to attest my having contemplated early in the session the
offering a resolution as the foundation of a law, to give effect to the
object of the gentleman from Virginia, to declare void any contract
made by any officer under this Government with any member of
either House. So far I am prepared to go, if any member shall
introduce such a proposition. The passage of such a law will remove
the inconvenience which might arise from interfering decisions made
in this House at different times, and will prevent the existence of a
different rule in the two branches of the Legislature.
Mr. J. Randolph admitted that this might be, as he was convinced it
was with many gentlemen, and hoped it was with all, a question
admitting of a fair difference of opinion. It was a question that
respected the construction of the Constitution of the United States.
The point in issue, whether a contractor is or is not an officer of the
United States, had been set aside by being begged. Gentlemen
argue as if it was proposed to add a new qualification to holding a
seat on this floor, when in truth, no such question existed; the only
question was, whether there was an existing disqualification. While I
am up, said Mr. R., permit me to say the gentleman from Maryland
has, with a peculiar infelicity, abandoned the ground which he had
first taken. He says that a contract cannot be an office, because the
former are put up to sale; and because no man, under the
constitution, can possess the power of creating an indefinite number
of offices. And yet, how are those men who carry the mail or
discharge the duties of postmasters appointed, but on the mere
dictum of the Postmaster-General? And how are foreign Ministers
appointed? They are not appointed by law. The President nominates
as many as he pleases, and is only limited by the money at his
disposal. As to the offices under the Postmaster-General, as has
been alleged, being let to the lowest bidder, I believe it would be
difficult to establish the allegation. I understand that that is not the
principle on which they have been let out. We are told that a
contract is nothing but a bargain. It certainly is a bargain. But
suppose the office of Postmaster-General, as that seems in this
debate to have engaged so much of the attention of gentlemen,
should be let to the lowest bidder; would the person that discharged
those duties be less an officer of the United States? There is one
office which I believe is always let to the lowest bidder—a common
executioner. Who is he? The deputy of the sheriff: and quo ad hoc,
he is as much an officer as the superior who employs him.
Mr. Elmer said it was perfectly clear to him, that the members of
that House were not at liberty to vote for the resolution under
consideration. Both common sense and the constitution forbade
considering a contract in the light of an office, and he had never
before heard it contended that they were equivalent terms. He
would cordially give his vote for any law which could be
constitutionally passed, to get rid of speculation and corruption of
any sort, but the oath which he had taken to support the
constitution limited his power, which he could not transcend.
Mr. Kelly said he would concisely assign the reasons which would
induce him to vote against the resolution. He did not believe an
officer and a contractor meant the same things. With regard to the
contractors holding a seat on that floor, it might happen that a man
might be a contractor without being in the least disqualified from
impartially discharging all the duties of a member, as the contract
which he formed might be more for the good of others than his own
benefit. He, however, allowed that where a person held a seat, and
made use of the power it gave him to make a contract, he was
highly censurable. Still he was of opinion that it was not in the
power of the House to declare the two appointments incompatible,
unless the constitution expressly authorized them. In examining the
constitution he found no such provision. Though it had been
attempted to be shown that a contractor and an officer were one
and the same, he believed they were very distinct things. A
contractor receives no authority from Government; his contract was
derived from an officer, and all the power he possessed was derived
from him, who was only amenable for the performance of the duty
to the person who appointed him. A contractor could not, therefore,
be considered as an officer under the constitution, amenable to the
United States.
Several allusions, said Mr. K., have been made to cases which have
occurred under the Postmaster-General, but until these shall be
particularly pointed out, it will be impossible for us to decide how we
are to act. I believe that it does not become this House to pass
declaratory acts relative to the constitution. It ought, in my opinion
to stand on its own footing; and every case that is presented ought
to be decided, not by a declaratory act, but by the constitution itself.
My colleague says that the judges of the federal as well as State
courts take an oath as well as we do, to support the constitution;
and that, notwithstanding they are in the daily habit of construing
the constitution. But there is a wide difference between their
deciding particular cases which properly come before them, and this
House going into a general declaration without any such particular
case. Would the judges undertake to declare the meaning of the
constitution without the existence of a particular case calling for
their decision? So that the very thing which the House is about
doing, has been invariably avoided by the judges.
The question was then taken by yeas and nays on agreeing to the
resolution—yeas 25, nays 86.
Tuesday, April 1.
Plurality of Offices.
Mr. Bidwell said he would very concisely assign his reasons for
voting against this resolution. It declares that “the union of a
plurality of offices in the person of a single individual, but more
especially of the military with the civil authority, is repugnant to the
spirit of the Constitution of the United States, and tends to the
introducing of an arbitrary Government.” It appeared to him that this
was not a correct declaration. If the constitution itself be referred to,
it will appear that it recognizes a union of civil and military offices in
the same person. Such a union is to be found in the First Magistrate
of the United States, who exercises the highest Executive civil
functions, and is at the same time Commander-in-Chief of the Army
and Navy, and of the militia while in actual service. The same
principle pervaded the constitution, he believed, of every State.
There was also a union of civil and military authority in several
offices, by acts of Congress. This was the case with the marshals in
certain cases, and officers who are charged with the
superintendence of Territorial affairs. If it were proper, said Mr. B., as
I do not think it is, by a vote of this House, to undertake to define
the constitution, it still appears to me that we cannot consistently
say that the union of a plurality of offices in the person of a single
individual, but more especially of the military with the civil authority,
is repugnant to the spirit of the Constitution of the United States. A
declaration of that kind would be a vote of censure on the people of
the whole United States, for having adopted the Federal
Constitution, on the people of the several States, for having adopted
their constitutions, and on the Legislature under both Governments,
for having passed laws which authorized such a union.
Mr. J. Clay said, the objections of the gentleman arose from not
having properly considered the nature of the union of civil and
military office in the First Magistrate. By the constitution, the military
was placed in strict subordination to the civil power. For this reason
the President of the United States had placed under his control all
the officers of the Army and Navy. The union contemplated in the
resolution before you, said Mr. C., is that which gives the actual
discharge of civil powers to an officer who has actual command of
your army. I ask if it was ever in the contemplation of the
constitution, that the President should in person head your armies
and command your fleets? I believe not. There exists in one of the
Territories such a union as is contemplated in the resolution. In
Louisiana a person holding the office of Governor, is at the same
time Commander-in-chief of the Army of the United States, in virtue
of his appointment of Brigadier-General. Will any man pretend to say
that a union of offices, such as these, the discharge of whose duties
is incompatible, is such a union as is contemplated in the
constitution? No; the union in the constitution was only intended to
give the President a control over the Army and Navy; while this
resolution contemplates the positive and actual union of powers in
the same person, powers which at the same time he may be called
upon to exercise at different and distant places. To separate these
powers is the object of the resolution. I hope the resolution will be
agreed to, and the separation take place.
Mr. J. Randolph.—My friend from Pennsylvania has left me little to
say on the question, and indeed I have heard nothing in the shape
of argument, or assertion, but what I was prepared to hear, and of
which I apprised the House some time ago. It has come out at last
from the lips of a man who has prided himself upon being the
champion of the Constitution of the United States to-day, although
but a few days ago he threatened us with a dissolution of the Union,
that the constitution has no spirit in it. He calls on any man to lay his
finger on that spirit. What does the Constitution of the United States
say? Does it not guarantee to each State a Republican form of
Government? Is there no spirit in this? Is not the constitution then
devised under the influence of a Republican spirit, for the benefit of
the people who are governed by it, and not for the exclusive benefit
of those who administer it? Will any man pretend to say that a
Republic is any thing or nothing? And that it is congenial to such a
Government that the civil and military authority should be vested in
the same hands? Is it not of the very essence of such a Government
that the military should be kept in strict subordination to the civil
power? And have not your laws, which give to marshals in certain
cases a power over the military, been passed to keep the military
under such subjection? How is the military to be kept in such
subjection, when, according to the usage of the Romans, the leader
of an army is the Governor of a province? If the constitution has no
spirit in it, it is a dead, lifeless thing, not worth the protection of any
man of sense. But I am happy that it has a spirit, which I trust will
save this nation, even if its letter shall be killed.
Mr. Quincy said he would merely observe, that, though it were true
that a union of civil and military offices in the same person was
repugnant to the spirit of the constitution, it was not true that a
union of different offices in the same person was repugnant to it.
They had to-day united two offices in the same person, in the bill
relative to the Territory of Michigan. They had heretofore constituted
several of the officers of the Government Commissioners of the
Sinking Fund. He could see nothing in the constitution which
interfered with a plurality of offices, which in many instances was
attended with great practical benefit. As there was therefore in the
constitution nothing explicit against this union, he could not vote for
the resolution.
Mr. Gregg said he believed it was contrary to the spirit of the
constitution, that civil and military offices should be united in the
same person; but, he would ask, what benefit would result from
such a declaration? The power of appointing to office was vested in
the President and Senate, who were sworn to support the
constitution. They were, therefore, the judges of the powers with
which they were invested. In the exercise of this power, they have
actually declared that they do possess it. What does this resolution
amount to? If they undertook to declare the President guilty of such
a flagrant act as involved a violation of the constitution, it was their
business to impeach him. Mr. G. said, as he could see no good likely
to arise from this resolution, he should not vote for it. The practice it
referred to was not new, though he had always thought it wrong. He
recollected, that, some years since, the Governor of the North-
western Territory was likewise Superintendent of Indian Affairs and
Commander-in-chief of the Army, for all which appointments he
drew pay, though no notice had been taken of it. Other instances of
the same kind might be pointed out. He did believe this union was
contrary to the spirit of the constitution—to the true spirit of a
Republican Government—and if the gentleman from Virginia would
bring forward an amendment to the constitution to prohibit such a
union, he would vote for it.
Mr. J. Randolph.—Six years ago, there could not have been a doubt
of the right of this House to pass this resolution—now, the right is
disputed. Have we not a right to pass a resolution referring to the
constitution, in order to bring in a law grounded on it? Do we not do
this every day? One word as to the appointment of General
Wilkinson. Gentlemen are fond of sheltering themselves behind great
names. I have no hesitation in saying I think the Executive was
wrong in making that appointment. I have no hesitation in saying so
here, though gentlemen who join me out of doors are reluctant to
make the same declaration on this floor. I do not think, however, the
persons who made the appointment as reprehensible as the persons
at whose importunate solicitation it was made. I believe that a man
of good sense, and of upright intentions, may be induced to do that
which his own judgment will afterwards condemn. It is well known,
that the ante-chambers of our great men were crowded with
applicants for offices in Louisiana. I have understood that for every
office there were at least one hundred and fifty applications. Thus
much for the idea which has been thrown out of the existence of a
scarcity of characters to supply these offices.
Mr. Varnum considered the resolution as going too far, and said it
was a very common thing for two offices to be united in one man. It
had been usual to unite the diplomatic character with the military
command in our intercourse with the Indians, and a diplomatic
character had likewise been given to our naval commander in the
Mediterranean. Instances of a plurality of offices in one person were
very numerous. If there existed, at present, any case, in which such
a union was incompatible with the discharge of official duties, he
hoped it would be pointed out; whether there was or was not, he
could not say. But where did the responsibility for such appointments
lie? Not that House, but the other branch of the Legislature was
responsible; for the correct discharge of whose duties they were
accountable to the people. Where, then, was the propriety of an
interference by the House? If the President made an appointment
against the spirit of the constitution, the people would know it. Was
it presumable that if a law was to pass this House, predicated on the
resolution under consideration, the other branch of the Legislature
would agree to it, after having sanctioned the appointments at which
it is levelled? Was this House to sit as a court of censure? The
constitution did not delegate such a power. Our very laws, in various
cases, direct the union of office prescribed by the resolution. Ought
we not, then, in the first place, to repeal those laws before we pass
a resolution in direct hostility to them?
Mr. V. said, he had no hesitation to observe, that the military and
civil office should, in general, be kept distinct; but he believed there
were cases where it was necessary. He was perfectly willing to leave
the responsibility where the constitution had placed it—in the hands
of the President and Senate. With regard to the union of the military
office in the cases alluded to, he would not undertake to say
whether it was proper or not. He could readily, however, conceive,
that the union arose from the most correct motive, as the country
was a frontier, which might be menaced with danger, and which
might require the united exercise of the military and civil authority to
repel it.
Mr. J. Clay said he would ask whether the ordinary union of
military and civil powers in the Governors of the Territories was such
as that contemplated in the resolution? The case of the Governor of
Louisiana had been alluded to, where the same person, he believed,
received the pay of Governor and Brigadier. Is that the case with the
other Governors? He believed gentlemen would not say that it was
necessary that the Governor of New Orleans should be a brigadier-
general in the army; and yet they allowed that to be the most
vulnerable point on the frontier. If, then, they say that the union is
necessary in one case, they will admit that it ought to be in the
other.
Mr. Leib said that, viewing the resolution as an abstract
proposition, he had no objection to giving it his support; but if it was
intended as a side attack upon the Administration, he was not
prepared to vote for it. Before he was prepared to act on it under
this view, he wished for facts which were not before the House. He,
therefore, moved a postponement of the resolution till Monday.
The motion to postpone was lost.
The question was then taken on agreeing to the resolution, and
decided in the negative—yeas 31, nays 81.
Wednesday, April 2.
Claim of Beaumarchais.
Charlestown, Va.
Mr. Jackson called for the order of the day, on the report of the
Committee of Commerce and Manufactures, on the petition of
sundry inhabitants of Charlestown, in Virginia, praying that that
place should be made a port of entry.
Mr. Leib moved an indefinite postponement of the report.
Mr. Jackson opposed this motion, and spoke at some length in
favor of the constitutional right of the petitioners to be allowed a
port of entry.
Mr. Crowninshield, though against postponement and in favor of
discussing the principle, contested the right.
Mr. Leib withdrew his motion; when the motion to consider the
report was disagreed to—only 13 members rising in favor of it.
Friday, April 4.
Prohibition of Military Officers from holding Civil Office.
Tuesday, April 8.
Motion to Adjourn.
Ordered, That the Clerk of this House do carry the said resolution
to the Senate, and desire their concurrence.