100% found this document useful (1 vote)
32 views

Practical Numerical Computing Using Python 1st Edition Mahendra Verma - Own the ebook now and start reading instantly

The document provides information about the book 'Practical Numerical Computing Using Python' by Mahendra Verma, which covers Python programming and numerical algorithms for scientific computing. It includes various topics such as error analysis, numerical methods, and applications in machine learning and artificial intelligence. The book is designed for advanced undergraduate and graduate students, offering practical programming exercises and a comprehensive overview of computational tools.

Uploaded by

johenalatev
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
32 views

Practical Numerical Computing Using Python 1st Edition Mahendra Verma - Own the ebook now and start reading instantly

The document provides information about the book 'Practical Numerical Computing Using Python' by Mahendra Verma, which covers Python programming and numerical algorithms for scientific computing. It includes various topics such as error analysis, numerical methods, and applications in machine learning and artificial intelligence. The book is designed for advanced undergraduate and graduate students, offering practical programming exercises and a comprehensive overview of computational tools.

Uploaded by

johenalatev
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 75

Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.

com

Practical Numerical Computing Using Python 1st


Edition Mahendra Verma

https://ebookmeta.com/product/practical-numerical-computing-
using-python-1st-edition-mahendra-verma/

OR CLICK HERE

DOWLOAD EBOOK

Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Practical Explainable AI Using Python: Artificial


Intelligence Model Explanations Using Python-based
Libraries, Extensions, and Frameworks Pradeepta Mishra
https://ebookmeta.com/product/practical-explainable-ai-using-python-
artificial-intelligence-model-explanations-using-python-based-
libraries-extensions-and-frameworks-pradeepta-mishra/
ebookmeta.com

Architecture of Advanced Numerical Analysis Systems:


Designing a Scientific Computing System using OCaml 1st
Edition Liang Wang
https://ebookmeta.com/product/architecture-of-advanced-numerical-
analysis-systems-designing-a-scientific-computing-system-using-
ocaml-1st-edition-liang-wang/
ebookmeta.com

The Practice of Computing Using Python 3 [Regular] Edition


William Punch Richard Enbody

https://ebookmeta.com/product/the-practice-of-computing-using-
python-3-regular-edition-william-punch-richard-enbody/

ebookmeta.com

Intelligence in Energy 1st Edition Gülgün Kayakutlu

https://ebookmeta.com/product/intelligence-in-energy-1st-edition-
gulgun-kayakutlu/

ebookmeta.com
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/

ebookmeta.com

Heritage Culture and Identity 1st Edition Hamzah Muzaini

https://ebookmeta.com/product/heritage-culture-and-identity-1st-
edition-hamzah-muzaini/

ebookmeta.com

Contraception and Persecution 1st Edition Charles E Rice


Alyssa Bormes Steve Mosher

https://ebookmeta.com/product/contraception-and-persecution-1st-
edition-charles-e-rice-alyssa-bormes-steve-mosher/

ebookmeta.com

Suits A Woman on Wall Street 1st Edition Nina Godiwalla

https://ebookmeta.com/product/suits-a-woman-on-wall-street-1st-
edition-nina-godiwalla/

ebookmeta.com

Music and Mental Imagery 1st Edition Mats B. Küssner

https://ebookmeta.com/product/music-and-mental-imagery-1st-edition-
mats-b-kussner/

ebookmeta.com
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/

ebookmeta.com
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

Character & Strings


List
Numpy Arrays
Dictionary
Mutable and Immutable Objects in Python

Chapter Four
Simple Statements
Conditional Flows in Python
Looping in Python
Chapter Five

Functions in Python
Python Namespace and Scope
Recursive Functions
Chapter Six

Good Progamming Practices


Prime Numbers
Searching and Sorting
Chapter Seven

Matplotlib & Field Plots


Miscellaneous Plots
Animation using Python

Chapter Eight

Reading & Writing Text Files in Python


Reading & Writing Numerical Data in Python

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

Solving PDEs Using Spectral Method: Diffusion Equation


Solving Wave, Burgers, and KdV Equations
Spectral Solution of Naiver-Stokes Equation
Spectral Solution of Schrödinger Equation

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

Solving Laplace Equation


Solving Poisson Equation

Chapter Twenty

Solution of Algebraic Equations


Eigenvalues and Eigenvectors

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.

Acknowledgements: For the significant contents of the book, I am grateful to


the PHY473A’s TAs (teaching assistants), especially Soumyadeep Chatterjee,
Abhishek Kumar, and Manohar Sharma. Special thanks to PHY473A’s
enthusiastic students, whose interesting questions led to clarity in the
presentation in the book. I also thank Mani Chandra for introducing me to
Python way back in 2008, and to the members of Simulation and Modelling
Laboratory (https://turbulencehub.org), where coding is done for fun.
Next, thanks to Python creator, Guido van Rossum, and many developers for
creating such a wonderful programming environment, that too for free! Also,
thanks to Anancoda for the free Python distribution, and to the creators of
Scrivener that has made writing a joy. I gratefully acknowledge Wikipedia and
Wikieducator for Figures 3, 4, 5, 33, and 138 of the book.
I am also thankful to my friends, Harshawardhan Wanare, Rajesh Ranjan,
Prateek Sharma, Anurag Gupta, Rahul Garg, and Prachi Garg for the
encouragement, and Manmohan Dewbanshi for help in the manuscript
preparation. Finally, I am grateful to pothi.com, especial Jaya Jha and Pratibha,
for the assistance in publication of this book, and for publishing it in India. The
front cover was prepared using Canva, while the full cover was designed by
pothi.com.

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

“Computers themselves, and software yet to be developed, will


revolutionize the way we learn.”
—Steve Jobs

This chapter gives a brief introduction to computer hardware and


software. We also describe how to install Python on computers.
INTRODUCTION TO COMPUTING

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

The present computers are essentially based on von Neumann architecture


(1945). According to this design, a computer has the following components:

1. Processor: A unit that performs arithmetic and logical operations


2. Memory: Data and program instructions are stored here.
3. Input/Output: Computer takes data from input devices, e.g., keyboard,
mouse; and sends results to output devices, such as, printer, terminal, etc.

The processor, memory, I/O controller (for connecting input/output devices to


the processor), and many other small units reside on a printed circuit board
(PCB) called Motherboard or logic board. A schematic diagram of these units is
shown in Figure 1. Note that hard disk (HD) or solid-state drive (SSD), battery,
wireless device, and camera are kept inside the computer. The processor of a
computer receives inputs from ports, keyboard, and camera through I/O
controller; the processor operates on the inputs, and sends the results to the
memory or to appropriate output units (for example, screen or printer). The
website https://www.nemolaptops.com/post/2018/09/11/antamoy-of-a-laptop
provides a good overview of these units.
Figure 1: A schematic diagram of the internal parts of a computer: Processor,
Memory, Hard Disk, Battery.

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.

Graphical processing units (GPU): It is efficient to off-load video and image


processing to a specialised processor, called Graphical processing units (GPU).
GPUs have many processors that perform certain operations, such as matrix
rotation and Fourier transforms, very efficiently. In the last 15 years, GPUs are
also being used for supercomputing. See Section Supercomputers & Compute
Complexity.
Interface of a Computer: Input/Output Units

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. Why do computers have memory hierarchy—cache, RAM, hard disk?


2. What are the advantages and disadvantages of USB-C port over USB port?
3. What are the similarities and dissimilarities between the functioning of a
computer and a human brain?
Exercises

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

LAPTOPS/DESKTOPS HAVE limited power, hence, they cannot perform


complex tasks, such as banking, weather predictions, simulations of aircrafts.
For such operations, we employ servers or supercomputers, also called high
performance systems. Supercomputing is also called High performance
computing.
Modern supercomputers consist of a large number of processors and memory
units. Fugaku, the fastest supercomputer as on June 2021, consists of large
number of racks, each of which contains many nodes with multiple processors.
Figure 4 illustrates many racks of Fugaku. The nodes are connected to each other
via a fast switch called interconnect, through which the processors exchange
data. Note that Fugaku requires 30 Megawatts of power, which is the power
consumed by a typical small town. For reference, we provide the following
specifications of Fugaku:

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.

Figure 4: Fugaku, the fastest supercomputer as on June 2021. From


wikipedia.org. Work of Hiroko Hama; reprinted under the agreement of CC BY-
SA 4.0 license.
Memory and Interconnect

One of the major bottlenecks in the performance of supercomputers is the slow


data transfer rate from RAM to CPU. As described in the previous section, the
data transfer rate from memory to CPU is several GB’s per second. In
comparison, CPUs can operate on 1000 GB’s of data per second.
Similar bottleneck exists in the interconnects. One of the fastest interconnect,
FDR Infiband, can transfer data at the rate of 56 Gbps (Giga bits per second).
Considering that an interconnect is connected to many nodes, the net
transmission speed is much slower than 56 Gbps.
In contrast, the CPUs can process data at much faster pace. CPU is like a
giant who can compute very fast, but it remains idle because RAM is not giving
it enough data. The performance disparity between the CPU and
RAM/interconnect is one of the biggest challenges of supercomputing. These
bottlenecks are summarised in the following quote, “FLOPS are free, but data
communications are expensive”.
Memory and Time Complexity

It is critical to estimate the memory and time requirements for a numerical


problem. Significant efforts and resources would be wasted if we do not have a
proper estimate of the computation complexity of a given task. For example, the
matrix multiplication of two 105x105 arrays requires 24 GB of RAM (see
Example 1 below), hence we should not try this exercise on a laptop/desktop.
In the following discussion, we present two examples that illustrate how to
estimate the memory and time complexities of a problem. To estimate the
memory requirement, we need to keep in mind that the storage of an integer and
a float normally require 4 and 8 bytes respectively.

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. How are the supercomputers helping scientists and engineers in their


research?
2. How does one estimate the peak computational performance of a
supercomputer? Why don’t we achieve performance close to the peak
value?
3. Why is memory access a major bottleneck for supercomputers?
Exercises

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

COMPUTER SOFTWARE IS a vast field. This section is not meant to discuss


the nuances of various softwares. Rather, we provide provide a bird’s-eye view
of the operating system and Python programming language. In addition, we
relate the programming languages to various programs of a computer.
Operating System and System Software

The Operating System (OS) makes a computer aware of its hardware—CPU,


memory, hard disk—and the connected input/output units—computer screen,
keyboard, mouse, printer, etc. For example, a computer responds to the inputs
from the keyboard; executes programs; etc.
The OS is loaded from the hard disk to the RAM as soon as a computer is
turned on; this process is called boot up. The OS performs the following tasks:

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

Everyday we use computers for many jobs: sending/receiving emails, browsing


internet, watching movies, playing songs, writing documents, and occasionally
programming. Each of these tasks are performed using application softwares.
For example, we write documents using Microsoft Word or Pages (on a Mac);
browse internet using Firefox, Internet Explorer, Safari, etc.; watch movies using
Mplayer, VLC, etc.
In addition to the above, we can employ computers to record videos for
surveillance, and to control robots and home devices such as air conditioners,
TV, etc. Supercomputers are employed for more complex and data-intensive
tasks such as banking, weather forecasting, climate modelling, simulations of
airplanes and cars, etc. Note that the application softwares are at the top of Unix
shell in system hierarchy. See Figure 6.
System Software and Programming Languages

At the base level, a computer understands only two alphabets—0 and 1.


Therefore, all the instructions and data are to be converted to strings of 0’s and
1’s. For example, an addition of two numbers A and B involves the following
operations:

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.

The addition of numbers involves bitwise operations, such as 0+0=0, 1+0=1,


1+1=0 with a carry of 1, etc. Such instructions, coded in binary, are called object
code.
It is cumbersome to write object codes for complex tasks, e.g., weather
forecasting code. Compilers and Interpreters help overcome this difficulty. A
user writes programs in a higher-level language; then Compilers and Interpreters
translate these programs into object codes. These softwares save the programmer
from the drudgery of writing object codes.
The leading programming languages are C, C++, Fortran, Java, Python,
Matlab, etc. In C, C++, and Fortran, complete computer programs is written
first, after which the programs are converted to object codes using compilers.
Hence, C, C++, and Fortran are called compiler languages. On the other hand,
Python and Matlab interpreters execute the codes in pieces, hence Python and
Matlab are called interpreter languages. The following snippet illustrates how a
Python interpreter interacts with a user.

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

1. What are the differences between computer hardware and computer


software? Illustrate your answer using examples.
2. What are the differences between a compiler and an interpreter?
3. List all the application softwares and system softwares that are used often in
your laptop/desktop.
4. Locate Ipython interpreter in your computer.
BRIEF OVERVIEW OF PYTHON

GUIDO VAN ROSSUM created Python programming language, which


appeared in 1991 for the first time. Python is an interpreter language, and it is
very easy to learn and program, which makes it one of the most attractive and
popular languages. Python is used for a large number of applications, for
example,

1. Numerical and scientific computing


2. Data analysis
3. Big data and Machine learning
4. Image processing
5. Software development
6. Interface to experimental devices and control
7. GUI (graphical user interface) development
8. Audio and video applications
9. Internet programming
A Cursory View of Python

As on 2021, Python 3 is the standard and supported version of Python. Some of


the major differences between Python 3 and its earlier version, Python 2, are
given below:

1. In Python 3, the arguments of print statement are within brackets, but it is


not so in Python 2.
2. In Python 2, the division operator, “/” performs integer division for two
integer operands; for real division, one of the operands of “/” must be float
or complex. But, in Python 3, the integer-division and float-division
operators are different, and they are “//“ and “/“ respectively.

The other differences between Python 2 and Python 3 are quite technical to be
discussed here. In this book, we follow Python 3.

Using Python Interpreter: We start Python interpreter from a unix terminal by


typing python at the prompt. After that, we can proceed to write Python
statements. For example:

(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

Python modules: A major benefit of Python is its large number of libraries


—Numpy, Matplotlib, Scipy, Math, Pandas, Sympy, etc. Technically, Python
libraries are called modules. A brief description on some of the important Python
libraries are here.

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 [6]: import math as ma

In [7]: ma.factorial(5)
Out[7]: 120
Other documents randomly have
different content
abused and insulted by them, because you do not meet their demands. In
fact it has become a nuisance of the worst magnitude.”

There is much reason to apprehend that such nuisances must work


their own abatement. If our authorities were strong enough and
independent enough, to lay hold of the boys and girls who constitute the
materials from which street-beggars are manufactured, and compel them
(as a matter of public safety) to submit to the discipline of an educational
and industrial school, it would make a bright opening in the prospect. Or,
if every man, woman and child who is found begging in the street, were
transferred at once to some charitable institution, (if they have infirmities
which prevent them from labor,) or to some working institution, (if they
are able-bodied,) and there put to some wholesome labor in exchange for
their sustenance and clothing, we should not be without hope. But we see
no way of suppressing the evil, if neither of these methods is feasible.

New York Prison Association.— We have seen only newspaper


reports of the proceedings at the eighth anniversary of this active and
very useful Association. We understand that their condemnation of the
yoke and the shower, as modes of punishment, is very emphatic and
unqualified, and among the interesting facts which are drawn from their
report, we select the following:—

In the city of New York, since 1848, disorderly conduct (in


almost every instance the result of strong drink) has steadily
increased from 703 to 2,660, or 278 per cent.; intoxication has
increased about 75 per cent., and the two together from 5,579
to 11,280. By a comparison of the prison statistics for the last
five years, it appears that crimes against property have
increased only about 50 per cent.; but that crimes against the
person have increased 129 per cent., or from 1,300 in 1843 to
2,920 in 1852.

The increase has been the greatest in the highest crimes. Thus
we find assaults to kill were 25 in 1848, and 39, 59, 61 and 75 in
1852, or three-fold. Manslaughter, in 1848, was 3, and then 4,
16, 11 in 1852, almost four-fold. Murder in 1848 was 9, and 9,
15, 21 and 56 in 1852, or more than six-fold.

Ninety per cent. of the whole number committed to this prison


during the past year, were intemperate! The returns of sixteen
State Prisons, for the year 1851, give us a grand total of 4,507
prisoners, 3,006 of whom were imprisoned for offences against
property, and 784 against the person.

It is stated that there is a greater number of cases of bigamy


and perjury in the State of New York, than in all the other
fifteen States; there being twenty-one cases of bigamy in New
York, and only fifteen in the other States; and seventeen cases
of perjury to three in all the other States.

The average period of confinement in Connecticut is six years,


seven months, twenty-nine days; and in the Eastern
Penitentiary of Pennsylvania it is only two years, six months
and three days.

New York State Prisons.— The report of the State Penitentiaries of


New York bear date December 1, and show that 129 more convicts were
in custody at that time than in December, 1851. Of 1843, the whole
number in confinement, 924 were at Sing Sing, 752 at Auburn and 167 at
Clinton. One hundred and forty-three pardons were granted, or about 1
in every 12 convictions! The expenses of all the prisons exceeded the
earnings by several thousands of dollars, showing the fallacy of the
argument so potent with most Legislatures, that by associating prisoners
in labor they become a source of profit, while separating them involves
great expense. The Clinton prison is going largely into the iron business
and wants more hands. We would respectfully suggest, whether there are
not many persons at large in New York, and some quite considerable in
importance and respectable in appearance, too, who would find
appropriate employment there.

There has been some increase in the frequency of punishments by the


yoke, the shower bath, the ball and chain, and solitude.

Of 613 commitments, two-thirds confessed intemperate habits. How


many of the rest were moderate drinkers does not appear. The average
degree of education in the convicts received is less than in some former
reports.

Idiots in New York.—There are two thousand eight hundred idiots in


the State of New York. The report of the superintendent of the Idiot
Asylum, near Albany, contains the following interesting passage:—“We
have taught a child to walk when we had first to awaken or cultivate a
fear of falling, as an incentive to any efforts on her part. We have
awakened perceptions of sounds in ears where the sense of hearing
resided without the use of it. We have developed perceptions of sight
through eyes that had never performed their appropriate office. We have
been teaching children to speak in every stage of articulation. Cases that
three years since only promised to be hopeless, helpless burdens to their
friends all their lives, have been elevated to the rank of happy, useful
members of society. In almost all cases, and with very few, if any
exceptions, those usually called idiots, under the age of twelve or fifteen,
may be so trained and instructed as to render them useful to themselves,
and fitted to learn some of the ordinary trades, or to engage in
agriculture. Their minds and souls can be developed, so that they may
become responsible beings, acquainted with their relations to their
Creator and a future state, and their obligations to obey the laws and
respect the rights of their fellow-citizens. In all cases, we believe, for we
have seen what has been accomplished in apparently desperate cases,
they can be made cleanly and neat in their personal habits, and enabled to
enjoy the bounties of Providence and the Comforts of life, and to cease
being incumbrances and annoyances to the families in which they reside.”

Be beforehand with the Tempter!— A friend tells us of a case in


which a young girl of considerable personal attraction, was rescued from
impending danger. Her mother was a widow with very scanty means of
support. This girl had a taste for, and some skill in music. Had been at the
public schools, and could read and write with facility, and was indeed
respectably educated for one in her station. Her mother had determined
to take boarders, and to give an air of gentility to her house, she had also
made arrangements to hire a piano. The introduction of the class of
boarders which the mother expected, would have exposed the child to
great danger. A Christian friend saw this, and by timely and judicious
efforts succeeded in securing for her a situation where she would be
protected and prepared for usefulness, and for gaining a respectable
livelihood.

How much more hopeful such simple preventive measures are, than
those which (though equally well meant) come later, and are at best but
remedial in their character.

New Penitentiary in Massachusetts.— We notice in the


proceedings of the Legislature of Massachusetts that it is proposed to
build a new State Prison. It is but a year or two since the Charlestown
prison was greatly enlarged, so as to meet what was supposed to be the
demand for convict-accommodation. It is earnestly to be hoped, that if a
new prison should be erected in that State, the principle of separation will
be adopted. If the two systems could be once fairly tried in the actual
presence of the people of that ancient and intelligent Commonwealth, we
should have strong confidence that the groundless prejudices against
convict-separation would disappear, and that her example would be set
as effectually for the furtherance of correct views on the important subject
of prison discipline, as it has heretofore been cited for the furtherance of
misapprehension and error.

State Prison at Charlestown, Mass.— The earnings of the inmates


of the Charlestown State Prison, for the year ending September 30th,
1852, were $6,921.17 over expenses. Of the inmates, 313 are Americans,
170 foreigners, 35 negroes and 12 mulattoes.

We have known a succession of annual reports of State prisons to be


published, in which the earnings of the convicts, over and above the
expenditures were quite “showy,” but by and by came a change in the
administration, and a balance appears against the concern, sufficient to
swallow up all the previously reported excess of earnings. Each report of
a favorable year made its impression on the public mind, and hundreds
of thousands who were misled by it, will never see a notice of the
detection of the error,—to use no harsher term. We do not mean to
intimate that there is any reason to distrust the foregoing item, but simply
to admonish the reader that such statements are always to be taken with
many grains of allowance.

Illinois Penitentiary.— We understand that this institution is


leased for a term of years to a person, who allows the State a certain sum
for the labor of the convicts, &c. The report before us embraces the years
1851 and 1852. On the first of January, 1851, the prison contained 170
convicts. Since that time 38 have died, 41 have been pardoned, 1 has
escaped, and 168 have been discharged by expiration of sentence—
making the whole number discharged within the past two years, 248.
During the same period, 295 have been received, and the whole number
now in confinement is 207. Fourteen only were born in the State of
Illinois!

New State Reform School.— The Legislature of New Hampshire at


its last June session, received a report from a Board of Commissioners for
the establishment of a State Reform School, to be located in the town of
Concord, the cost not to exceed $35,000, and to be planned for the
accommodation of 300 boys, but finished at present for 120. An eligible
site has been obtained, and we hope soon to hear that the institution is
conferring wide and lasting benefits upon the community.

Juvenile Offenders.— At the Somersetshire Sessions, held lately at


Wells, England, an interesting discussion took place on the subject of the
punishment and reformation of juvenile offenders. The subject was
brought before the Court by the reading of a circular, in which the
magistrates were called upon to adopt a memorial to the Marquis of
Lansdowne on this important subject. Mr. Lloyd Baker said he had had
the subject under his consideration for the last fifteen years, and he laid
before the Court statistics referring to the criminal career of a number of
youths at that moment confined in the Gloucester County Prison,
showing that they had been, most of them, previously convicted once or
twice; that this kind of punishment, instead of having a moral effect upon
them, appeared only to have hardened them in crime by their coming in
contact with other bad adult characters, and that their trial and
imprisonment had cost the county from $75 to $100 a-piece. His argument
was in favor of an entirely new system of juvenile reformation. He was
followed by other magistrates, who spoke of the course imposed upon
them, to sentence mere children to confinement in a prison, as a most
unsatisfactory one. There was no moral effect in such punishments, but,
on the contrary, the effect was to break down the first barrier to crime,
and it was found that the shame of imprisonment was overcome. One of
them expressed an opinion that what was wanted was a public receptacle
for offenders of this class who were not properly “prisoners,” but
unfortunate individuals who, by neglect of their parents, had been led
into error. He did not see why it should not be made compulsory upon
such parents who so neglected their offspring as to lead them to crime, to
contribute towards their support in such an establishment, in the same
manner as a runaway parent was called upon to contribute to the support
of his family. The discussion ended in the adoption of a memorial, which
was signed by all the magistrates present, expressing their conviction,
that the present mode of treating and disposing of juvenile offenders was
most inefficient and unsatisfactory.

Singular Avocation and Mode of Life in London.— In a case of


assault brought before a police-court, a most extraordinary character
appeared as a witness. The man is by profession a thorough subterranean
rat-catcher, for the supply of those who keep sporting dogs. One-half of
his life is spent in quest of prey from the whole range of the sewerage of
London. Furnished with a bull’s eye lantern, a good-sized folding trap,
and a short rake, he enters the main sewer, at the foot of Blackfriar’s
Bridge, and pursues his dangerous avocation, waist-deep in mud and
filth of every description. The sewers literally swarm with rats, which he
catches by hand, and places them in his cage as easy as if they were
young kittens. His underground journeys extend for miles. He has been
under Newgate, and along Cheapside to the Mansion House. He has
traversed from Holborn to Islington, closely inspecting all the passages
that enter the grand sewer of the mighty metropolis. On one occasion, an
obstruction occurred to a drain at the foot of Holborn Hill. Terms were
speedily agreed upon, and our subterranean explorer started off to the
foot of Blackfriar’s Bridge, and in half an hour his voice was heard down
the gully-hole; he speedily cleared away the obstruction, and received his
reward, thus saving the expense of breaking up the roadway. It is not,
however, to the rats alone that he pays his attention; he frequently falls in
with a rich prize, particularly in the City sewers. On one occasion he
found a silk purse, containing gold and silver; on another a gold watch
and seals, numbers of silver spoons, rings and other articles of value. He
has been three times attacked with the typhus fever, but rapidly
recovered on each occasion.

Death from Separation!— A London paper tells us, that Mr.


Bedford, the coroner for Westminster, held an inquest lately in Millbank
Penitentiary, touching the death of Thomas Wilkinson, a convict, aged
nineteen years, a clothdresser, who was found one Sunday morning lying
dead and bleeding on the floor of his cell, having cut his throat with a
razor which was given him to shave, during the momentary absence of the
warder in charge. From the question of convict prison discipline having
recently been slightly agitated in the public journals, the separate system
was inquired into by the coroner, who asked Dr. Baily if he could throw
any light on the case, to guide the jury as to the cause of the act. Dr. Baily
thought that it was brooding over the length of his sentence, and stated
further that, during eighteen years, in that prison, from 1824 to 1842, with
an average of 454 prisoners, only three had committed suicide, but then
their sentences were only two, three or four years. Again, in the ten years
as a convict prison, from 1843 to 1853, there had been thirteen suicides. So
that he thought it was more the length of the sentences than the separate
confinement, although he must own that the latter would accelerate or
aggravate any disease which might be on a prisoner, and also tend to
suicide, by giving them an opportunity when they would be brooding
over a long prospect of imprisonment. The jury returned a verdict to the
effect that the deceased destroyed himself during a state of temporary
insanity, brought on by the separate system!

We have put a few words in italics to mark the absurdity of such a


verdict. (1.) No evidence of insanity is stated, except that which the fatal
act furnishes. (2.) As favorable an opportunity is offered, during half of
every twenty-four hours in a congregate, as in a separate prison. (3.) If it
is brooding over an unusually long sentence that produces suicidal
insanity, the verdict should be, that the deceased destroyed himself
during a state of temporary insanity, brought on by a mistake of the law
or of its administrators!

Murders in Philadelphia.— It is our painful duty to record three


deliberate and atrocious murders committed within the bounds of the city
of Philadelphia since our last issue.

The first was committed in broad day, in one of the most frequented
parts of the city, upon a man in his own store, and was attended with
circumstances of ferocity rarely equalled. The perpetrator of the deed has
not been discovered.

The second was the wanton butchery of an unoffending man,


apparently without any motive, except the indulgence of a blood-thirsty
malevolence.
The third was committed upon two unprotected females, and with a
ferocity of which we should hope few human beings are susceptible, even
in their most savage state. The only apparent motive for the cruel and
dastardly deed was a pittance of money. How far the wretched monster
on whom the guilt of this double murder has been fixed by the law and
the testimony, may have been implicated in other deeds of blood ascribed
to him by popular rumor, it is not for us to say, but we suppose there is
no doubt that he was not long since a convict in the State Penitentiary at
Sing Sing, N. Y., and was pardoned by the Executive of that State!

How much of his term of punishment was abridged by this


interposition of extraordinary clemency, we are not informed; but if the
full execution of his sentence would have carried the period of his
confinement beyond the 10th of March, 1853, it is clear that the
abridgment of it opened the way for the terrible deed which we have now
recorded. And are we not justified in holding the pardoning power
responsible, in foro conscientiæ, at least, for the consequences of taking a
convict out of the hands of the ministers of justice, while he is undergoing
wholesome discipline by their order, and sending him back into the
community as one whose punishment was greater than he deserved?
Who knows but that an ill-judged interposition of Executive power may
sometimes breed a contempt for public authority, and stimulate a reckless
convict to more audacious violations of law!

Missouri Insane Asylum.— This institution is located in Fulton. It


was opened a year since, and has received 70 patients. There are 460 acres
of land attached to it, 30 of which are under culture. Dr. T. R. H. Smith is
the principal physician.

Missouri Penitentiary.—
On the 20th of December there were 232 convicts in custody, of whom
146 were from the county of St. Louis. Of the countries of their nativity,
Ireland furnishes the largest number, and Germany the next largest. Of
the States of the Union, Pennsylvania furnishes the largest number. We
are happy to learn that the physician is a decided advocate of convict-
separation.

IT IS SAID,
( A N D W E P R E S U M E O N G O O D A U T H O R I T Y, )

1. —That, on the 12th of November last, notice was given in the


British House of Commons of a bill for the codification of the
criminal laws.

2. —That, in the Massachusetts Legislature, the Committee on


Prisons have reported against allowing the families of convicts a
portion of their earnings.

3. —That, the London Society for improving the condition of the


Insane, have offered a premium of twenty guineas for the best
essay that shall be presented, showing the progressive changes
since Pinel’s time in the moral management of the Insane, and the
various contrivances to dispense with mechanical restraints.

4. —That, the Emperor of France has decided, that out of ten millions
of francs appropriated to the improvement of the lodging-houses
of the laboring classes, three millions shall be put at the disposal of
the Minister of the Interior to procure plans!

5. —That, the inmates of the Cincinnati House of Refuge are 235, and
that the number of juvenile culprits at large is fearfully increasing.

6. —That, the three State prisons of New York, (containing 1783


convicts, of whom only 80 are females,) will require a considerable
sum beyond their earnings for their support, viz.: for the Auburn
prison, $14,000; for the Sing Sing Prison, $7,000; for the Clinton
Prison, $27,000. Yet the Clinton Prison is not regarded as an
unsuccessful experiment!

We hope this important fact will be known to the Missouri


Legislature before they determine to adopt the congregate system,
on the ground of its economy. “As a general thing,” says the report
of a commissioner of Missouri on that subject, “the prisons
employing this” (the associate system) “support themselves.” It is
wise to look before we leap.

7. —That, very favorable commencement has been made in the


establishment of an institution in or near Philadelphia, for the
instruction of idiots and feeble-minded children.

8. —That, the Deaf and Dumb Asylum at Jacksonville, Ill., admitted


during its last term 100 pupils, 94 of whom were from within the
State. The whole number of mutes in the State is estimated at 500.

9. —That, the Illinois Asylum for the Blind has in it 25 pupils. The
whole number of the blind in the State is estimated at only 60. A
building is nearly ready for their accommodation.

10. —That, the Illinois State Lunatic Asylum admitted during the year
138 patients, of whom 38 were restored to sanity, 50 were
discharged, and 82 remain under treatment.

11. —That, the rite of confirmation, as observed in the Established


Church of England, was lately administered by the Bishop of
Manchester to 28 prisoners in the gaol in that town, varying in age
from 14 to 55 years. The whole scene is represented as having been
very impressive.

12. —That, the number of idiots in the State of New York is not less
than 2,800, of whom one-fourth are under 14 years of age. There
are 42 pupils in the State institution for idiots, 30 of whom are
supported by the State. The trustees recommend the purchase of a
building having accommodations for 100 pupils, of whom 64,
(eight from each judicial district,) it is proposed to support at the
expense of the State; and the remaining 36, by friends. The
estimated cost of a suitable building is $20,000; and the annual
appropriation necessary to maintain the establishment will be
$10,000.

13. —That, a new organization of the police of New York


contemplates the total release of the policemen from all political
influence, as it provides that they shall hold their offices during
good behavior, and shall only be removed for neglect of duty or
the violation of police regulations. That the Chief of Police shall be
appointed by the Mayor, with the approval of the Board of
Aldermen, and not the Common Council, as has been the law
hitherto; that every policeman appointed must be a citizen of the
United States, and a resident of the ward for which he has been
nominated. He must also present to the Mayor, with his certificate
of nomination, another, signed by twenty-five reputable citizens,
two-thirds of whom must reside in the ward at the time of signing
the certificate, certifying that they have been personally acquainted
with him five years last past, and that during that time he has
borne a good character for honesty, morality and sobriety. He
must also present to the Mayor a certificate from the Chief of
Police, certifying that the said applicant can read with ease, and
write legibly the English language, that he well understands the
first four rules of arithmetic, and that he is a proper person to
appoint to said office.

These rules if faithfully observed, would probably exclude some of


the present incumbents in most of our cities.

14. —That, the whole number of convicts in the Illinois Penitentiary is


227, and the whole expense of conveying convicts from the
counties in the State to the penitentiary, is $14,990.05! The
Governor thinks it unwise to have a very large number of convicts
congregated in one prison, and he submits to the consideration of
the Legislature, whether the public interest in regard to this subject
would not be better subserved by building another penitentiary, to
be located at some eligible point in the northern part of the State.

We hope one of them, at least, will be established on the


Pennsylvania system.
15. —That, a little ragged urchin, begging in the streets of Detroit, was
asked by the lady of the house (where his baskets had been well
replenished,) if his parents were living? “Only dad, marm,” said
the boy. “Then you’ve enough in your basket now, to feed the
family for some time,” said the lady. “Oh! no I haven’t neither,”
said the lad, “for dad and me keeps five boarders; he does the
housework, and I does the market’n.”

16. —That, a new edifice for the New York Deaf and Dumb Institution
is to be built, the present location having been rendered ineligible
for such a purpose, by the opening of new thoroughfares. The site
selected is in the vicinity of Fort Washington, near the line of the
Hudson River Rail-road, and the cost of the site and building is
estimated at $120,000.

17. —That, on the 1st day of January the population of the New York
City Almshouse was 5557; out-of-door paupers, 1332; total, 6909—
sufficient to stock a large village.

18. —That, the practice prevails among certain of the magistrates of


the county of Philadelphia, (names not given,) of committing to the
county prison persons known to be guiltless of any offence to
justify their commitments—that such persons are sometimes
retained in prison for weeks, and it is added, that this
reprehensible system puts the county to an increased expense,
merely to place costs in the pockets of the committing magistrates.

19. —That, instruction on the Phonetic plan has been given with
much success in several of the penal institutions abroad, among
which are the Preston House of Correction and the Glasgow
Bridewell.

20. —That, not a single case has yet been known of a convict’s losing
his reason as a necessary and natural consequence of being
separated from other convicts.

ACKNOWLEDGMENTS.
We have to express our thanks to various friends for their thoughtful
kindness in forwarding us copies of reports, and among them are the
following:

Annual reports of the Officers of the New Jersey State Lunatic Asylum
for 1852.

Twentieth Annual Report of the State Lunatic Hospital at Worcester,


Mass. for 1852.

Report of the Pennsylvania Hospital for the Insane for the year 1852.

Tenth Annual Report of the State Lunatic Asylum of the State of New
York, 1852.

Annual Report of the State Lunatic Asylum at Harrisburg, Penn.

Twenty-Fourth Annual Report of the Inspectors of the Eastern State


Penitentiary of Pennsylvania, 1852.

Report of the Inspectors of the Western State Penitentiary of


Pennsylvania for 1852.

Sixteenth Annual Report of the Board of Directors of the Pennsylvania


Institution for the Deaf and Dumb, 1852.

Twentieth Annual Report of the Managers of the Pennsylvania


Institution for the Instruction of the Blind for 1852.

Report of the State Prison of New Jersey for 1852.

Sixth Annual Report of the Trustees of the State Reform School at


Westborough, Mass.
Twenty-Seventh Annual Report of the Board of Managers of the Prison
Discipline Society of Boston, 1851-2.

Act of Incorporation, By-Laws, &c., of New York Juvenile Asylum.

Twenty-Eighth Annual Report of the Managers of the Society for the


Reformation of Juvenile Delinquents of New York, 1852.

Annual Report of Board of Managers of Philadelphia Charity Schools,


1852.

Report of Managers of the Magdalen Society for 1852.

Annual Report of the Managers of the Boston Asylum and Farm School
for 1852.

Eight Report of the Baltimore Manual Labor School for Indigent Boys
for 1852.

Report of Commissioners on the State Reform School of Pennsylvania.

Premium for an Essay on Juvenile Delinquency.— At a meeting of


the Board of Managers of the House of Refuge, Philadelphia, the
following preamble and resolution were adopted, viz:

Whereas, The increase of Juvenile Delinquency in all the large cities of


our country, has claimed the attention of philanthropists; and whereas, the
Board of Managers of the House of Refuge, Philadelphia, are desirous
that errors in modes of training the young, and other causes co-operating
to produce the evil referred to, may be presented in such a form as to
claim the serious consideration of parents and guardians throughout the
land; therefore,
Resolved, That the Board of Managers do offer a premium of one
hundred dollars for the best essay, and fifty dollars for that next in order
of merit, to be awarded by a committee of literary gentlemen: Provided,
that such essays shall not exceed fifty octavo pages in length, and shall be
contributed before the first day of July, A. D. 1853; and whether
successful or not in competition, shall be at the absolute disposal of the
Board of Managers.

In accordance with the above preamble and resolution, the premiums


therein named are now offered, without restriction as to the residence of
competitors.

The Rt. Rev. Alonzo Potter, Frederick A. Packard, Esq., and Stephen
Colwell, Esq., have consented to act as the Committee, to examine and
adjudge as to the merits of the Essays offered in competition.

Competitors for the above named premiums, will please address their
manuscripts to “John Biddle, No. 6 South Fifth Street, Philadelphia;” and
send therewith, their names and places of residence, under sealed
envelopes.

As the object of the Board of Managers of the House of Refuge in


offering the above-named premiums, is mainly to call the attention of
parents and guardians to errors in the prevalent modes of training the
young—a subject which should claim the attention of every reader—the
undersigned would call the attention of editors of newspapers generally,
throughout the United States, to this advertisement, and ask the favor of
an insertion of it, or of the more important parts of it, in the columns of
their papers.

By order of the Board of Managers of the House of Refuge.


THOS. P. COPE, President of H. of R.
JOHN BIDDLE, Secretary of H. of R.

Philadelphia, Feb. 17, 1853.

(Continued from second page of cover.)

highly valuable periodical, communicating much and various important


information upon the subject of which it treats. It is the only publication
of the kind in the country, is certainly a very much needed one, and
ought, therefore, to be well sustained by the public.

From the Episcopal Recorder.

This periodical gives a large amount of information on Prison


Discipline, and cannot fail to interest such as grieve over the sufferings
occasioned by crime, and regard the imprisoned criminal as still
belonging to our common humanity, and needing the commiseration of
the wise and good.

From the Public Ledger.

We have received the October number of the Pennsylvania Journal of


Prison Discipline and Philanthropy, published under the direction of the
Philadelphia Society for alleviating the Miseries of Public Prisons. It is
stored with interesting matter.

From the Presbyterian.

We have been reading with great interest the Pennsylvania Journal of


Prison Discipline and Philanthropy.
AN INQUIRY

INTO THE ALLEGED TENDENCY OF THE SEPARATION OF


CONVICTS, ONE FROM THE OTHER, TO PRODUCE DISEASE AND
DERANGEMENT.

By a Citizen of Pennsylvania. Philadelphia: E. C. & J. Biddle. 1849.

It is, as might possibly be anticipated from the residence of the author,


an elaborate and ardent defence of the separate system of confinement.
The charge of its peculiar tendency to induce disease and insanity, is
altogether denied, and the testimony of the successive physicians to the
Eastern State Penitentiary, during a term of nearly twenty years, goes
very satisfactorily to warrant the denial.

The author is not, however, inclined to rest at this, but carries the war
into the enemies’ camp. The chapter entitled Medical Practice, in a
Congregate Prison, is calculated to attract attention, from the positions
laid down in it, and their startling illustrations, deduced from the well
known case of Abner Rogers. It is not the time or the place for us to enter
on this warmly controverted subject, and we have noticed the work only
on account of its bearing on the subject of insanity, and as forming a part
of its literature.—Am. Journal of Insanity, published by the Superintendent of
the New York Lunatic Asylum, July, 1850.

So far as the leading controversy, in regard to the rival systems of


prison discipline, is concerned, it seems to us to cover the entire ground
with singular ability.—Princeton Review.

☞ A few copies of this pamphlet are still on hand, and may be had on
application to the publishers, corner of Fifth and Minor streets, or to any
member of the Acting Committee.
OFFICERS FOR 1852-3.

President—James J. Barclay.

Vice-Presidents—Townsend Sharpless, Charles B. Trego.

Treasurer—Edward Yarnall.

Secretaries and Committee of Correspondence—


William Parker Foulke, Edward Townsend.

Counsellors.
Job R. Tyson, Garrick Mallery.

Acting Committee.

James J. Barclay, Townsend Sharpless, Charles B. Trego, Edwar


Yarnall, William Parker Foulke, Edward Townsend, Job R. Tyso
Garrick Mallery, F. A. Packard, Jeremiah Hacker, William Shippe
Charles Ellis, A. T. Chur, Morris Wickersham, M. W. Baldwi
Mark Balderston, Joshua L. Baily, Thomas Latimer, Josh. T. Jeane
John M. Wetherill, Horatio C. Wood, John Lippincott, John J. Lytl
Henry M. Zollickoffer, William S. Perot, Benjamin J. Crew, Isaac G
Turner, William U. Ditzler.

☞ Quarterly Meeting of the Society, 2nd second day (Monday)


January, April, July and October.

Inspectors of the State Penitentiary for the Eastern District of


Pennsylvania.
John Bacon, Richard Vaux, Hugh Campbell, Singleton A. Merce
Andrew Miller.

Warden—John S. Halloway.

Resident Physician—D. W. Lassiter, M. D.

Moral Instructor—Thomas Larcombe.

Clerk—William Marriott.

Teacher—George Neff.

Visiting Committee of the Eastern Penitentiary.

Townsend Sharpless, Edward Townsend, James J. Barclay, A


Theodore Chur, Joshua J. Jeanes, Matthias W. Baldwin, Joshua
Baily, John Lippincott, John J. Lytle, Horatio C. Wood, Isaac G
Turner, Benjamin J. Crew.

Inspectors and Officers of the Philadelphia County Prison.

President.—Jesse R. Burden, M. D.,

Treasurer.—T. C. Bunting. M. D.,

Secretary.—E. A. Penniman,

Edward C. Dale, Samuel Palmer, Robert O’Neill, Hugh O’Donne


Thomas E. Crowell, Godfrey Metzger, Charles T. Jones, Joseph K
Howell, Joshua S. Fletcher, William Elliott, Samuel McManem
John T. Smith.

Superintendent.—Anthony Freed.
Deputy Superintendents.—William B. Perkins, John Mirkil.

Clerk.—Wm. J. Crans.

Matron.—E. McDaniel.

Physician.—Dr. J. C. Wall.

Moral Instructor.—Rev. Wm. Alexander.

Assistant Keepers—

C. Stagers, William Sharp, H. C. Snyder, Alexander Campbell,


Laird, J. B. Haines, A. Morrison, Alexander Burden, J. Watt, G
Kirkpatrick, William McGrath.

Visiting Committee on the County Prison.

William S. Perot, Dr. William Shippen, Jeremiah Hacker, H. M


Zollickoffer, Thomas Latimer, Paul T. Jones, Morris S. Wickersham
John M. Wetherill, Charles Ellis, B. B. Comegys, William U. Ditzle

Return to top.

Transcribers’ Notes.

The beginning of the third page of the cover was marked


with: (Continued from second page of cover.).

The following table shows changes made by the


transcriber. Page# refers to the number of the printed
page. Page ii is the inside front cover. Page 58 is the
eighth page in this issue which was numbered 58 (for the
year). Page 70 is the twentieth page in this issue which
was numbered 70, and so on. Page iv is the outside back
cover.

Change table
Page# original changed to
ii expresse expressed
58 there their
70 substracted subtracted
74 attractions; attractions;”
76 mismangement mismanagement
76 impunity. impunity.”
82 viz viz.
84 seasonable reasonable
89 homocidal homicidal
95 considered. considered.”
95 years! years!”
96 VIII VIII.
97 Unforfortunately Unfortunately
105 viz viz.
106 That —That
107 That —That
iv Matron Matron.
iv Wickersham Wickersham,
*** END OF THE PROJECT GUTENBERG EBOOK THE PENNSYLVANIA
JOURNAL OF PRISON DISCIPLINE AND PHILANTHROPY (VOL. VIII,
NO. II, APRIL 1853) ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and
with almost no restrictions whatsoever. You may copy it,
give it away or re-use it under the terms of the Project
Gutenberg License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country
where you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute


this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using
the method you already use to calculate your applicable
taxes. The fee is owed to the owner of the Project
Gutenberg™ trademark, but he has agreed to donate royalties
under this paragraph to the Project Gutenberg Literary

You might also like