Programming Quantum Computers Essential Algorithms and Code Samples 1st Edition Eric R. Johnston All Chapter Instant Download
Programming Quantum Computers Essential Algorithms and Code Samples 1st Edition Eric R. Johnston All Chapter Instant Download
com
https://textbookfull.com/product/programming-
quantum-computers-essential-algorithms-and-code-
samples-1st-edition-eric-r-johnston/
https://textbookfull.com/product/supervised-learning-with-quantum-
computers-maria-schuld/
textbookfull.com
https://textbookfull.com/product/parallel-computers-architecture-and-
programming-v-rajaraman/
textbookfull.com
https://textbookfull.com/product/ethereum-for-architects-and-
developers-with-case-studies-and-code-samples-in-solidity-1st-edition-
debajani-mohanty/
textbookfull.com
https://textbookfull.com/product/security-and-privacy-select-
proceedings-of-icsp-2020-1st-edition-pantelimon-stanica/
textbookfull.com
Balanced Constitutionalism: Courts and Legislatures in
India and the United Kingdom 1st Edition Chintan
Chandrachud
https://textbookfull.com/product/balanced-constitutionalism-courts-
and-legislatures-in-india-and-the-united-kingdom-1st-edition-chintan-
chandrachud/
textbookfull.com
https://textbookfull.com/product/adopting-elixir-from-concept-to-
production-1st-edition-ben-marx/
textbookfull.com
https://textbookfull.com/product/the-ticklers-jam-murders-peter-
tickler/
textbookfull.com
https://textbookfull.com/product/strategic-management-competitiveness-
and-globalization-concepts-and-cases-14e-michael-a-hitt/
textbookfull.com
https://textbookfull.com/product/mahaviri-hanuman-chalisa-
demystified-1st-edition-nityananda-misra/
textbookfull.com
Programming Quantum
Computers
Essential Algorithms and Code Samples
Figure P-1. Quantum programs can look a bit like sheet music
How This Book Is Structured
A tried-and-tested approach for getting hands-on with new
programming paradigms is to learn a set of conceptual primitives.
For example, anyone learning Graphics Processing Unit (GPU)
programming should first focus on mastering the concept of
parallelism, rather than on syntax or hardware specifics.
The heart of this book focuses on building an intuition for a set of
quantum primitives—ideas forming a toolbox of building blocks for
problem-solving with a QPU. To prepare you for these primitives, we
first introduce the basic concepts of qubits (the rules of the game, if
you like). Then, after outlining a set of Quantum Processing Unit
(QPU) primitives, we show how they can be used as building blocks
within useful QPU applications.
Consequently, this book is divided into three parts. The reader is
encouraged to become familiar with Part I and gain some hands-on
experience before proceeding to the more advanced parts:
Part I: Programming a QPU
Here we introduce the core concepts required to program a QPU,
such as qubits, essential instructions, utilizing superposition, and
even quantum teleportation. Examples are provided, which can
be easily run using simulators or a physical QPU.
Constant width
Used for program listings, as well as within paragraphs to refer to
program elements such as variable or function names, databases,
data types, environment variables, statements, and keywords.
NOTE
This element signifies a general note.
WARNING
This element indicates a warning or caution.
NOTE
For almost 40 years, O’Reilly Media has provided technology and
business training, knowledge, and insight to help companies succeed.
How to Contact Us
Please address comments and questions concerning this book to the
publisher:
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0104 (fax)
We have a web page for this book, where we list errata, examples,
and any additional information. You can access this page at
http://bit.ly/programming-quantum-computers.
To comment or ask technical questions about this book, send email
to [email protected].
For more information about our books, courses, conferences, and
news, see our website at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
Acknowledgments
This book could not have been possible without a supporting team
of talented people passionate about quantum computing. The
authors would like to thank Michele, Mike, Kim, Rebecca, Chris, and
the technical team at O’Reilly for sharing and amplifying our
enthusiasm for the topic. Although the authors are responsible for all
errors and omissions, this book benefited immensely from the
invaluable feedback and inspiration of a number of technical
reviewers, including Konrad Kieling, Christian Sommeregger,
Mingsheng Ying, Rich Johnston, James Weaver, Mike Shapiro, Wyatt
Berlinic, and Isaac Kim.
EJ would like to thank Sue, his muse. Quantum computation started
to make sense to him on the week that they met. EJ also sends
Visit https://textbookfull.com
now to explore a rich
collection of eBooks, textbook
and enjoy exciting offers!
thanks to friends at the University of Bristol and at SolidAngle, for
encouraging him to color outside the lines.
Nic would like to thank Derek Harrigan for first teaching him to talk
binary, the other Harrigans for their love and support, and Shannon
Burns for her pending Harrigan application.
Mercedes would like to thank José María Gimeno Blay for igniting her
interest on computers early, and Mehdi Ahmadi for being a constant
source of support and inspiration.
But clichéd as it may be, most of all the authors would like to thank
you, the reader, for having the sense of adventure to pick up this
book and learn about something so different and new.
Chapter 1. Introduction
Required Background
The physics underlying quantum computing is full of dense
mathematics. But then so is the physics behind the transistor, and
yet learning C++ need not involve a single physics equation. In this
book we take a similarly programmer-centric approach,
circumventing any significant mathematical background. That said,
here is a short list of knowledge that may be helpful in digesting the
concepts we introduce:
What Is a QPU?
Despite its ubiquity, the term “quantum computer” can be a bit
misleading. It conjures images of an entirely new and alien kind of
machine—one that supplants all existing computing software with a
futuristic alternative.
At the time of writing this is a common, albeit huge, misconception.
The promise of quantum computers stems not from them being a
conventional computer killer, but rather from their ability to
dramatically extend the kinds of problems that are tractable within
computing. There are important computational problems that are
easily calculable on a quantum computer, but that would quite
literally be impossible on any conceivable standard computing device
that we could ever hope to build.1
But crucially, these kinds of speedups have only been seen for
certain problems (many of which we later elucidate on), and
although it is anticipated that more will be discovered, it’s highly
unlikely that it would ever make sense to run all computations on a
quantum computer. For most of the tasks taking up your laptop’s
clock cycles, a quantum computer performs no better.
In other words—from the programmer’s point of view—a quantum
computer is really a co-processor. In the past, computers have used
a wide variety of co-processors, each suited to their own specialties,
such as floating-point arithmetic, signal processing, and real-time
graphics. With this in mind, we will use the term QPU (Quantum
Processing Unit) to refer to the device on which our code samples
run. We feel this reinforces the important context within which
quantum computing should be placed.
As with other co-processors such as the GPU (Graphics Processing
Unit), programming for a QPU involves the programmer writing code
that will primarily run on the CPU (Central Processing Unit) of a
normal computer. The CPU issues the QPU co-processor commands
only to initiate tasks suited to its capabilities.
A Hands-on Approach
Hands-on samples form the backbone of this book. But at the time
of writing, a full-blown, general-purpose QPU does not exist—so how
can you hope to ever run our code? Fortunately (and excitingly),
even at the time of writing a few prototype QPUs are currently
available, and can be accessed on the cloud. Furthermore, for
smaller problems it’s possible to simulate the behavior of a QPU on
conventional computing hardware. Although simulating larger QPU
programs becomes impossible, for smaller code snippets it’s a
convenient way to learn how to control an actual QPU. The code
samples in this book are compatible with both of these scenarios,
and will remain both usable and pedagogical even as more
sophisticated QPUs become available.
There are many QPU simulators, libraries, and systems available.
You can find a list of links to several well-supported systems at
http://oreilly-qc.github.io. On that page, we provide the code
samples from this book, whenever possible, in a variety of
languages. However, to prevent code samples from overwhelming
the text, we provide samples only in JavaScript for QCEngine.
QCEngine is a free online quantum computation simulator, allowing
users to run samples in a browser, with no software installation at
all. This simulator was developed by the authors, initially for their
own use and now as a companion for this book. QCEngine is
especially useful for us, both because it can be run without the need
to download any software and because it incorporates the circle
notation that we use as a visualization tool throughout the book.
A QCEngine Primer
Since we’ll rely heavily on QCEngine, it’s worth spending a little time
to see how to navigate the simulator, which you can find at
http://oreilly-qc.github.io.
Running code
The QCEngine web interface, shown in Figure 1-1, allows you to
easily produce the various visualizations that we’ll rely on. You can
create these visualizations by simply entering code into the
QCEngine code editor.
To run one of the code samples from the book, select it from the
drop-down list at the top of the editor and click the Run Program
button. Some new interactive UI elements will appear for visualizing
the results of running your code (see Figure 1-2).
Quantum circuit visualizer
This element presents a visual representation of the circuit
representing your code. We introduce the symbols used in these
circuits in Chapters 2 and 3. This view can also be used to
interactively step through the program (see Figure 1-2).
Circle-notation visualizer
This displays the so-called circle-notation visualization of the QPU
(or simulator) register. We explain how to read and use this
notation in Chapter 2.
Debugging code
Debugging QPU programs can be tough. Quite often the easiest way
to understand what a program is doing is to slowly step through it,
inspecting the visualizations at each step. Hovering your mouse over
the circuit visualizer, you should see a vertical orange line appear at
a fixed position and a gray vertical line wherever in the circuit your
cursor happens to be. The orange line shows which position in the
circuit (and therefore the program) the circle-notation visualizer
currently represents. By default this is the end of the program, but
by clicking other parts of the circuit, you can have the circle-notation
visualizer show the configuration of the QPU at that point in the
program. For example, Figure 1-3 shows how the circle-notation
visualizer changes as we switch between two different steps in the
default QCEngine program.
Figure 1-3. Stepping through a QCEngine program using the circuit and circle-
notation visualizers
Logical bitwise
NOT (also X) qc.not(t)
NOT
Controlled NOT: if
CNOT qc.cnot(t,c)
(c) then NOT(t)
HAD
qc.had(t) Hadamard gate
(Hadamard)
Relative phase
PHASE qc.phase(angle,c)
rotation
Symbol Name Usage Description
Relative phase
Z qc.phase(180,c)
rotation by 180 °
Relative phase
S qc.phase(90,c)
rotation by 90 °
Relative phase
T qc.phase(45,c)
rotation by 45 °
Conditional phase
CPHASE qc.cphase(angle,c1|c2)
rotation
Conditional phase
CZ qc.cphase(180,c1|c2)
rotation by 180 °
Write
WRITE qc.write(t,val) conventional data
to qubits
Root-of-NOT
ROOTNOT qc.rootnot(t)
operation
Conditional
CSWAP qc.exchange(t1|t2, c) exchange: if (c)
then SWAP(t1,t2)
Hardware Limitations
Conversely, the largest actual QPU hardware available at the time of
writing has around 70 physical qubits, while the largest QPU
available to the public, through the Qiskit open source software
development kit, contains 16 physical qubits.3 By physical, as
opposed to logical, we mean that these 70 qubits have no error
correction, making them noisy and unstable. Qubits are much more
fragile than their conventional counterparts; the slightest interaction
with their surroundings can derail the computation.
Dealing with logical qubits allows a programmer to be agnostic about
the QPU hardware and implement any textbook algorithm without
having to worry about specific hardware constraints. In this book,
we focus solely on programming with logical qubits, and while the
examples we provide are small enough to be run on smaller QPUs
(such as the ones available at the time of publication), abstracting
away physical hardware details means that the skills and intuitions
you develop will remain invaluable as future hardware develops.
The long expected favorite and friend of the Jewish people, having
been thus hailed sovereign by their grateful voices, and having
strengthened his throne and influence by his opening acts of
liberality and devotion to the national faith, now entered upon a reign
which presented only the portents of a course most auspicious to his
own fame and his people’s good. Uniting in his person the claims of
the Herodian and Asmonaean lines,――with the blood of the heroic
Maccabees in his veins,――crowned by the imperial lord of the
civilized world, whose boundless power was pledged in his support,
by the obligations of an intimate personal friendship, and of a sincere
gratitude for the attainment of the throne of the Caesars through his
prompt and steady exertions,――received with universal joy and
hope by all the dwellers of the consolidated kingdoms of his
dominion, which had been long thriving under the mild and equitable
administration of a prudent governor,――there seemed nothing
wanting to complete the happy auspices of a glorious reign, under
which the ancient honors of Israel should be more than retrieved
from the decline of ages. Yet what avails the bright array of happily
conspiring circumstances, to prince or people, against the awful
majesty of divine truth, or the pure, simple energy of human
devotion? Within the obscurer corners of his vast territories, creeping
for room under the outermost colonnades of that mighty temple
whose glories he had pledged himself to renew,――wandering like
outcasts from place to place,――seeking supporters only among the
unintellectual mass of the people,――were a set of men of whom he
probably had not heard until he entered his own dominions. They
were now suggested to his notice for the first time, by the decided
voice of censure from the devout and learned guardians of the purity
of the law of God, who invoked the aid of his sovran power, to check
and utterly uproot this heresy, which the unseasonable tolerance of
Roman government had too long shielded from the just visitations of
judicial vengeance. Nor did the royal Agrippa hesitate to gratify, in
this slight and reasonable matter, the express wishes of the reverend
heads of the Jewish faith and law. Ah! how little did he think, that in
that trifling movement was bound up the destiny of ages, and that its
results would send his name――though then so loved and
honored――like Pharaoh’s, down to all time, a theme of religious
horror and holy hatred, to the unnumbered millions of a thousand
races, and lands then unknown;――an awful doom, from which one
act of benign protection, or of prudent kindness, to that feeble band
of hated, outcast innovators, might have retrieved his fame, and
canonized it in the faithful memory of the just, till the glory of the old
patriarchs and prophets should grow dim. But, without one thought of
consequences, a prophetic revelation of which would so have
appalled him, he unhesitatingly stretched out his arm in vindictive
cruelty over the church of Christ, for the gratification of those whose
praise was to him more than the favor of God. Singling out first the
person whom momentary circumstances might render most
prominent or obnoxious to censure, he at once doomed to a bloody
death the elder son of Zebedee, the second of the great apostolic
three. No sooner was this cruel sentence executed, than, with a
most remarkable steadiness in the execution of his bloody plan, he
followed up this action, so pleasing to the Jews, by another similar
movement. Peter, the active leader of the heretical host, ever
foremost in braving the authority of the constituted teachers of the
law, and in exciting commotion and dissatisfaction among the
commonalty, was now seized by a military force, too strong to fear
any resistance from popular movements, which had so much
deterred the Sanhedrim. This occurred during the week of the
passover; and such was king Agrippa’s profound regard for all things
connected with his national religion, that he would not violate the
sanctity of this holy festival by the execution of a criminal, however
deserving of vengeance he might seem in that instance. The fate of
Peter being thus delayed, he was therefore committed to prison,
(probably in castle Antonia,) and to prevent all possibility of his
finding means to escape prepared ruin again, he was confined to the
charge of sixteen Roman soldiers, divided into four sets, of four men
each, who were to keep him under constant supervision day and
night, by taking turns, each set an equal time; and according to the
established principles of the Roman military discipline, with the
perfect understanding that if, on the conclusion of the passover, the
prisoner was not forthcoming, the guards should answer the failure
with their lives. These decided and careful arrangements being
made, the king, with his gratified friends in the Sanhedrim and
among the rabble, gave themselves up to the enjoyment of the great
national festival, with a peculiar zest, hightened by the near prospect
of the utter overthrow of the advancing heresy, by the sweeping blow
that robbed them of their two great leaders, and more especially of
him who had been so active in mischievous attempts to perpetuate
the memory of the original founder of the sect, and to frustrate the
good effect of his bloody execution, by giving out that the crucified
Jesus still lived, and would yet come in vengeance on his murderers.
While such triumphant reflections swelled the festal enjoyments of
the powerful foes of Christ, the unhappy company of his persecuted
disciples passed through this anniversary-week with the most
mournful reminiscences and anticipations. Ten years before, in
unutterable agony and despair, they had parted, as they then
supposed forever, with their beloved Lord; and now, after years of
devotion to the work for which he had commissioned them, they
were called to renew the deep sorrows of that parting, in the removal
of those who had been foremost among them in the great work,
cheering them and leading them on through toil and peril, with a
spirit truly holy, and with a fearless energy, kindred with that of their
divine Lord. Of these two divinely appointed chiefs, one had already
poured out his blood beneath the executioner’s sword, and the other,
their great leader, the Rock of the church, was now only waiting the
speedy close of the festal week, to crown his glorious course, and
his enemies’ cruel policy, by the same bloody doom; meanwhile held
in the safe keeping of an ever-watchful Roman guard, forbidding
even the wildest hope of escape. Yet why should they wholly
despair? On that passover, ten years before, how far more gloomy
and hopeless the glance they threw on the cross of their Lord! Yet
from that doubly hopeless darkness, what glorious light sprang up to
them? And was the hand that then broke through the bands of death
and the gates of Hades, now so shortened that it could not sever the
vile chains of paltry tyranny which confined this faithful apostle, nor
open wide the guarded gates of his castle prison? Surely there was
still hope for faith which had been taught such lessons of undoubting
trust in God. Nor were they thoughtless of the firm support and high
consolations which their experience afforded. In prayer intense and
unceasing, they poured out their souls in sympathetic grief and
supplication, for the relief of their great elder brother from his deadly
peril; and in sorrowful entreaty the whole church continued day and
night, for the safety of Peter.
Castle Antonia.――For Josephus’s account of the position and erection of this work, see
my note on page 95, (section 8.) There has been much speculation about the place of the
prison to which Peter was committed. The sacred text (Acts xii. 10,) makes it plain that it
was without the city itself, since after leaving the prison it was still necessary to enter the
city by “the iron gate.” Walch, Kuinoel and Bloomfield adopt the view that it was in one of the
towers or castles that fortified the walls. Wolf and others object to the view that it was
without the walls; because, as Wolf says, it was not customary to have public prisons
outside of the cities, since the prisoners might in that case be sometimes rescued by a bold
assault from some hardy band of comrades, &c. But this objection is worth nothing against
castle Antonia, which, though it stood entirely separated from the rest of the city, was vastly
strong, and by its position as well as fortification, impregnable to any common force;――a
circumstance which would at once suggest and recommend it as a secure place for one
who, like Peter, had escaped once from the common prison. There was always a Roman
garrison in Antonia. (Josephus, Jewish War, V. v. 8.)
Thus sublimely calm, sat Peter in his prison, waiting for death.
Day after day, all day long, the joyous feast went on beneath
him:――the offering, the prayer and the hymn varying the mighty
course, from the earliest morning supplication to the great evening
sacrifice. Up rolled the glorious symphony of the Levites’ thousand
horns, and the choral harmony of their chanting voices,――up rolled
the clouds of precious incense to the skiey throne of Israel’s
God,――and with this music and fragrance, up rolled the prayers of
Israel’s worshiping children; but though the glorious sound and odor
fell delightfully on the senses of the lonely captive, as they passed
upwards by his high prison-tower, no voice of mercy came from
below, to cheer him in his desolation. But from above, from the
heaven to which all these prayer-bearing floods of incense and
harmony ascended, came down divine consolation and miraculous
delivery to this poor, despised prisoner, with a power and a witness
that not all the solemn pomp of the passover ceremony could
summon in reply to its costly offerings. The feeble band of sorrowing
Nazarenes, from their little chamber, were lifting unceasing voices of
supplication for their brother, in his desperate prospects, which
entered with his solitary prayer into the ears of the God of Hosts,
while the ostentatious worship of king Agrippa and his reverend
supporters, only brought back shame and woful ruin on their impious
supplications for the divine sanction to their bloody plans of
persecution. At last the solemn passover-rites of “the last great day
of the feast” were ended;――the sacrifice, the incense and the song,
rose no more from the sanctuary,――the fires on the altars went out,
the hum and the roar of worshiping voices was hushed, and the
departing throngs poured through the “eternal” and the “beautiful”
gates, till at last the courts and porches of the temple were empty
through all their vast extent, and hushed in a silence, deep as the
ruinous oblivion to which the voice of their God had doomed them
shortly to pass; and all was still, save where the footfall of the
passing priest echoed along the empty colonnades, as he hurried
over the vast pavements into the dormitories of the inner temple; or
where the mighty gates thundered awfully as they swung heavily
together under the strong hands of the weary Levites, and sent their
long reverberations among the walls. Even these closing sounds
soon ceased also; the Levite watchmen took their stand on the
towers of the temple, and paced their nightly rounds along the flat
roofs, guarding with careful eyes their holy shrine, lest the impious
should, under cover of night, again profane it, (as the Samaritans
had secretly done a few years before.) And on the neighboring castle
of Antonia, the Roman garrison, too, had set their nightly watch, and
the iron warriors slumbered, each in his turn, till the round of duty
should summon him to relieve guard. Within the dungeon keep of the
castle, was still safely held the weighty trust that was to be answered
for, on peril of life; and all arrangements were made which so great a
responsibility seemed to require. The prisoner already somewhat
notorious for making unaccountable escapes from guarded
dungeons, was secured with a particularity, quite complimentary to
his dexterity as a jail-breaker. The quaternion on duty was divided
into two portions; each half being so disposed and posted as to
effect the most complete supervision of which the place was
capable,――two men keeping watch outside of the well-bolted door
of the cell, and two within, who, not limited to the charge of merely
keeping their eyes on the prisoner, had him fastened to their bodies,
by a chain on each side. In this neighborly proximity to his rough
companions, Peter was in the habit of passing the night; but in the
day-time was freed from one of these chains, remaining attached to
only one soldier. (This arrangement was in accordance with the
standard mode of guarding important state-prisoners among the
Romans.) Matters being thus accommodated, and the watch being
set for the next three hours, Peter’s two fast companions, finding him
but indifferent company, no doubt, notwithstanding his sociable
position, soon grew quite dull in the very tame employment of seeing
that he did not run away with them; for as to getting away from them,
the idea could have no place at all in the supposition. These sturdy
old veterans had probably, though Gentiles, conformed so far to
Judaical rituals as to share in the comfortable festivities of this great
religious occasion, and could not have suffered any heathenish
prejudices to prevent them from a hearty participation in the joyous
draughts of the wine, which as usual did its part to enliven the hearts
and countenances of all those who passed the feast-day in
Jerusalem. The passover coming so many months after the vintage
too, the fermentation of a long season must have considerably
energized “the pure juice of the grape,” so that its exhilarant and
narcotic powers could have been by no means feeble; and if the
change thus wrought by time and its own inherent powers, at all
corresponds to that which takes places in cider in this country under
the same circumstances, the latter power must have so far
predominated, as to leave them rather below than above the
ordinary standard of vivacity, and induce that sort of apathetic
indifference to consequences, which is far from appropriate in a
soldier on duty over an important trust. Be that as it may, Peter’s two
room-mates soon gave themselves quietly up to slumber. If any
scruple arose in their heavy heads as to the risk they ran in case of
his escape, that was soon soothed by the consideration of the vast
number of impassable securities upon the prisoner. They might well
reason with themselves, “If this sharp Galilean can manage to break
his chains without waking us, and burst open this stout door in spite
of bars, without rousing the sentinels who are posted against it on
the outside, and make his way unseen and unchecked through all
the gates and guards of Castle Antonia――why, let him. But there’s
no use in our losing a night’s rest by any uneasiness about such a
chance.” So stretching themselves out, they soon fell into a sound
sleep, none the less pleasant for their lying in such close quarters;
for it is natural to imagine, that in a chilly March night in Jerusalem,
stowing three in a bed was no uncomfortable arrangement.
Circumstanced as he was, Peter had nothing to do but conform to
their example, for the nature of his attachment to them was such,
that he had no room for the indulgence of his own fancies about his
position; and he also lay down to repose. He slept. The sickening
and feverish confinement of his close dungeon had not yet so broken
his firm and vigorous frame, nor so drained its energies, as to hinder
the placid enjoyment of repose; nor did the certainty of a cruel and
shameful death, to which he was within a few hours to be dragged,
before the eyes of a scoffing rabble, move his high spirit from its self-
possession:――
He slept. And from that dark prison-bed what visions could beguile
his slumbering thoughts? Did fancy bear them back against the tide
of time, to the humble, peaceful home of his early days,――to the
varied scenes of the lake whereon he loved to dwell, and along
whose changeful waters he had learned so many lessons of
immortal faith and untrembling hope in his Lord? Amid the stormy
roar of its dark waters, the voice of that Lord once called him to
tempt the raging deep with his steady foot, and when his feeble faith,
before untried, failed him in the terrors of the effort, His supporting
hand recalled him to strength and safety. And had that lesson of faith
and hope been so poorly learned, that in this dark hour he could
draw no consolation from such remembrances? No. He could even
now find that consolation, and he did. In the midst of this “sea of
troubles,” he felt the same mighty arm now upholding him, that bore
him above the waters, “when the blue wave rolled nightly on deep
Galilee.” Again he had stood by those waters, swelling brightly in the
fresh morning breeze, with his risen Lord beside him, and received
the solemn commission, oft-renewed, to feed the flock that was so
soon to lose the earthly presence of its great Shepherd. In the
steady and dauntless execution of that parting commission, he had
in the course of long years gone on in the face of death,――“feeding
the lambs” of Christ’s gathering, and calling vast numbers to the fold;
and for the faithful adherence to that command, he now sat waiting
the fulfilment of the doom that was to cut him down in the midst of
life and in the fullness of his vigor. Yet the nearness of this sad
reward of his labors, seemingly offering so dreadful an interpretation
of the mystical prophecy that accompanied that charge, moved him
to no desperation or distress, and still he calmly slept, with as little
agitation and dread as at the transfiguration, and at the agony of the
crucifixion eve; nor did that compunction for heedless inattention,
that then hung upon his slumbering senses, now disturb him in the
least. It is really worth noticing, in justice to Peter, that his
sleepiness, of which so many curious instances are presented in the
sacred narrative, was not of the criminally selfish kind that might be
supposed on a partial view. If he slept during his Master’s prayers on
Mount Hermon, and in Gethsemane, he slept too in his own
condemned cell; and if in his bodily infirmity he had forgotten to
watch and pray when death threatened his Lord, he was now equally
indifferent to his own impending destruction. He was, evidently, a
man of independent and regular habits. Brought up a hard-working
man, he had all his life been accustomed to repose whenever he
was at leisure, if he needed it; and now too, though the “heathen
might rage, and the people imagine a vain thing,――though the
kings of the earth set themselves, and the rulers took counsel
together” against him, and doomed him to a cruel death,――in spite
of all these, Peter would sleep when he was sleepy. Not the royal
Agrippa could sleep sounder on his pavilioned couch of purple. In
the calm confidence of one steadily fixed in a high course, and
perfectly prepared for every and any result, the chained apostle gave
himself coolly to his natural rest, without borrowing any trouble from
the thought, that in the morning the bloody sword was to lay him in
“the sleep that knows no earthly waking.” So slept the Athenian
sage, on the eve of his martyrdom to the cause of clearly and boldly
spoken truth,――a sleep that so moved the wonder of his agonizing
disciples, at the power of a good conscience and a practical
philosophy to sustain the soul against the horrors of such distress;
but a sleep not sounder nor sweeter than that of the poor Galilean
outcast, who, though not knowing even the name of philosophy, had
a consolation far higher, in the faith that his martyred Lord had taught
him in so many experimental instructions. That faith, learned by the
painful conviction of his own weakness, and implanted in him by
many a fall when over confident in his own strength, was now his
stay and comfort, so that he might say to his soul, “Hope thou in
God, for I shall yet praise him, who is the help of my countenance
and my God.” Nor did that hope prove groundless. From him in
whom he trusted, came a messenger of deliverance; and from the
depths of a danger the most appalling and threatening, he was soon
brought, to serve that helping-God through many faithful years,
feeding the flock till, in his old age, “another should gird him, and
carry him whither he would not.” He who had prayed for him in the
revelation of his peculiar glories on Mount Hermon, and had so
highly consecrated him to the great cause, had yet greater things for
him to do; and to new works of love and glory he now called him,
from the castle-prison of his royal persecutor.
Ten years.――This piece of chronology is thus settled. Jesus Christ, according to all
common calculation, was crucified as early as the twentieth year of the reign of Tiberius.
Irenaeus maintains that it was in the fifteenth of that reign. Eusebius and Epiphanius fix it in
the eighteenth, or, according to Petavius’s explanation of their meaning, in the seventeenth
of his actual reign. Tertullian, Julius Africanus, Jerome, and Augustin, put it in the sixteenth.
Roger Bacon, Paulus Burgensis, and Tostatus, also support this date, on the ground of an
astronomical calculation of the course of the moon, fixing the time when the passover must
have occurred, so as to accord with the requirement of the Mosaic law, that it should be
celebrated on a new moon. But Kepler has abundantly shown the fallacy of this calculation.
Antony Pagus, also, though rejecting this astronomical basis, adheres to the opinion of
Tertullian, Jerome, &c. Baronius fixes it in the nineteenth of Tiberius. Pearson, L. Cappel,
Spanheim, and Witsius, with the majority of the moderns, in the twentieth of Tiberius. So
that the unanimous result of all these great authorities, places it as early as this last
mentioned year. A full and highly satisfactory view of all these chronological points and
opinions, is given by the deeply learned Antony Pagus, in his great “Critical Historico-
Chronological Review of Baronii.” Saecul. I. Ann. Per. Gr.‒Rom. 5525. ¶ 3‒13.
Now, from Josephus it is perfectly evident that Agrippa did not leave Rome until some
time after the beginning of the reign of Claudius, and it is probable not before the close of
the first year. Counting backwards through the four years of Caligula, this makes five years
after the death of Tiberius, and eight on the latest calculation from the death of Christ; while
according to the higher and earlier authority, it amounts to nine, ten, eleven, or to twelve
years from the crucifixion to Agrippa’s arrival in Judea. And moreover, it is not probable that
the persecution referred to occurred immediately on his arrival. Indeed, from the close way
in which Luke connects Agrippa’s death with the preceding events, it would seem as if he
would fix his “going down from Jerusalem to Caesarea,” and his death at the latter place,
very soon after the escape of Peter. This of course being in the end of Claudius’s third year,
brings the events above, down to the eleventh or twelfth from the crucifixion, even
according to the latest conjecture as to the date of that event. Probably, however, the
connection of the two events was not as close as a common reading of the Acts would lead
one to suppose.
So also Lardner, in his Life of Peter, says, “The death of Herod Agrippa happened before
the end of that year,” in which he escaped. (Lardner’s Works 4to. Vol. III. p. 402, bottom.)
Natalis Alexander fixes Peter’s escape in the second year of Claudius, and the forty-
fourth from Christ’s birth, which is, according to his computation, the tenth from his death.
(Church History, Saec. I. Cap. vi.)
A chain on each side.――That this was a common mode of fastening such prisoners
among the Romans, appears from the authorities referred to by Wolf, (Cur. Philology in Acts
xii. 6,) Kuinoel and Rosenmueller, (quoting from Walch,) and Bloomfield, all in loc.
the deliverance.
Peter was now quietly sleeping between his two guards, when his
rest was suddenly broken by a smart blow on the side, too
energetically given to be mistaken for an accidental knock from the
elbow of one of his heavy bed-fellows. Rousing his senses, and
opening his eyes, he was startled by a most remarkable light shining
throughout his dungeon, which his last waking glance had left in utter
darkness. In this unaccountable illumination, he saw standing before
him and bending over him, a form in which he could recognize only
the divine messenger of deliverance. The shock of such a surprise
must have been overwhelming;――to be waked from a sound sleep
by an appearance so utterly unearthly, might have struck horror into
the stoutest heart; but Peter seems to have suffered no such
emotion to hinder his attendance to the heavenly call. The
apparition, before he could exercise thought enough to sit up of
himself, had raised him up from his bed, and that without the
slightest alarm to his still slumbering keepers,――for “immediately
the chains fell from his hands,”――a motion which by the rattling of
the falling irons should have aroused the sleepers if any sound could
have impressed their senses. The impulse of the now unmanacled
captive might have been to spring forth his dungeon without the
slightest delay, but his deliverer’s next command forbade any such
unnecessary haste. His first words were, “Gird thyself; and tie on thy
sandals.” Before laying himself down, he had, as usual, thrown off
his outer garments and loosened his girdle, so that his under dress
need not so much confine him in sleep as to prevent that perfect
relaxation which is necessary for comfortable repose. Just as now-a-
days, a man in taking up such a lodging as often falls to a traveler’s
lot, will seldom do more than pull off his coat and boots, as Peter did,
and perhaps unbutton his waist-band and suspenders, so that on a
sudden alarm from his rest, the first direction would very properly be,
to “gird himself,” (button his trowsers,) “and tie on his sandals,” (put
on his shoes or boots.) The next direction given to Peter, also, “Cast
thy garment about thee,” (put on thy coat,) would be equally
appropriate. The meaning of all this particularity and deliberation
was, no doubt, that there was no need whatever of hurry or slyness
about the escape. It was not to be considered a mere smart trick of
jail-breaking, by which Peter was to crawl out of his dungeon in such
a hurry as to leave his coat and shoes behind him, but a truly
miraculous providence insuring his deliverance with a completeness
and certainty that allowed him to take every thing that belonged to
him. Having now perfectly accoutred himself in his ordinary style,
Peter immediately obeyed the next order of his deliverer,――“Follow
me.” Leaving his two bed-fellows and room-mates sleeping hard,
without the slightest idea of the evacuation of the premises which
was so deliberately going on, to their great detriment, Peter now
passed out through the open door, following the divine messenger in
a state of mind altogether indescribable, but still with just sense
enough to obey the directions which thus led him on to blissful
freedom. The whole scene bore so perfectly the character of one of
those enchanting dreams of liberty with which painful hope often
cheats the willing senses of the poor captive in slumber, that he
might well and wisely doubt the reality of an appearance so
tempting, and which his wishes would so readily suggest to his
forgetful spirit. But passing on with his conductor, he moved between
the sentinels posted at the doors, who were also equally unaware of
the movement going on so boldly under their noses, or rather over
them, for they, too, were faster bound in slumber than their prisoner
had been in his chains; and he now stepped over their outstretched
bodies as they lay before the entrances. These soldiers, too,
evidently looked upon their duty as a sort of sinecure, rationally
concluding that their two stout comrades on the inside were rather
more than a match for the fettered and manacled captive, and that if
he should be at all obstreperous, or even uneasy, the noise would
soon enough awake them from their nap. And thus excessive
precaution is very apt to overshoot itself, each part of the
arrangement relying too much on the security of all the rest. The two
passengers soon reached the great iron gate of the castle, through
which they must pass in order to enter the city. But all the seeming
difficulties of this passage vanished as soon as they approached it.
The gate swung its enormous mass of metal self-moving through the
air, and the half-entranced Peter went on beneath the vacant portal,
and now stood without the castle, once more a free man in the fresh,
pure air. The difficulties and dangers were not all over yet, however.
During all the great feast-days, when large assemblies of people
were gathered at Jerusalem from various quarters, to guard against
the danger of riots and insurrection in these motley throngs,――the
armed Roman force on duty, as Josephus relates, was doubled and
tripled, occupying several new posts around the temple, and, as the
same historian particularly mentions, on the approaches of castle
Antonia, where its foundations descended towards the terraces of
the temple, and gave access to the colonnades of the temple. On all
these places the guard must have been under arms during this
passover, and even at night the sentries would be stationed at all the
important posts, as a reasonable security against the numerous
strangers of a dubious character, who now thronged the city
throughout. Yet all these peculiar precautions, which, at this time,
presented so many additional difficulties to the escaping apostle,
hindered him not in the least. Entering the city, he followed the
footsteps of his blessed guide, unchecked, till they had passed on
through the first street, when all at once, without sign or word of
farewell, the mysterious deliverer vanished, leaving Peter alone in
the silent city, but free and safe. Then flashed upon his mind the
conviction of the true character of the apparition. The departure of
his guide leaving him to seek his own way, his senses were, by the
necessity of this self-direction, recalled from the state of
stupefaction, in which he had mechanically followed on from the
prison. With the first burst of reflection, he broke out in the
exclamation, “Now I know of a truth, that the Lord has sent forth his
messenger, and has rescued me out of the hand of Herod, in spite of
all the expectation of the Jewish people.” Refreshed and encouraged
by this impression, he now used his thoroughly awakened senses to
find his exact situation, and after looking about him, he made his way
through the dark streets to a place where he knew he should find
those whose despairing hearts would be inexpressibly rejoiced by
the news of his deliverance. This was the house of Mary, the mother
of John Mark, where the disciples were accustomed to assemble.
Going up to the gate-way, he rapped on the door, and at once
aroused those within; for in their sleepless distress for the
imprisoned apostle, several of the brethren had given up all thoughts
of sleep, and, as Peter had suspected, were now watching in prayer
within this house. The noise of a visitant at this unseasonable hour of
the night, immediately brought to the door a lively damsel, named
Rhoda; who, according to the Jewish custom of employing females
in this capacity, acted as portress of the mansion of Mary. Prudently
requiring some account of the person who made this late call, before
she opened the door of the persecuted Christians to an unknown
and perhaps an ill-disposed character, she was struck with almost
frantic joy at hearing the well-known voice of the much mourned
Peter, craving admittance. In the highth of her thoughtless gladness,
she ran off at once to make known the delightful fact to the disciples
in the house, without even seeming to think of the desirableness of
admitting the apostle, perhaps because she very naturally wanted to
tell such pleasant news first herself. Bursting into the room where the
disciples were at prayer for their lamented leader, whom they
supposed to be then fast bound for death in the dungeon of Antonia,
she communicated the joyful fact, that “Peter was before the gate.” A
declaration so extravagantly improbable, at once suggested the idea
of her having lost her wits through her affectionate sorrow for the
sufferings and anticipated death of the great apostle, and they
therefore replied, “Thou art crazy.” Rhoda, somewhat excited by
such a provoking expression of incredulity, loudly repeated her
slighted piece of good news, and so gravely maintained the truth of
it, that some of the more superstitious at last began to think there
must be something in it, and seriously suggested, that it must be a
supernatural messenger come to give them notice of his certain
doom,――“It is his guardian angel.” Peter, however, was all this
while standing outside during this grave debate about his real entity,
and shivering with the cold of a chilly March night, grew quite
impatient at the girl’s inconsiderate folly, and knocked away with
might and main, making a noise of most unspiritual character, till at
last the disciples determined to cut short the debate by an actual
observation; so opening the door to the shivering apostle, the light
brought his material existence to a certainty beyond all doubt. Their
amazement and joy was bursting forth with a vivacity which quite
made up for their previous incredulity; when the apostle, making a
hushing sign with his hand,――and with a reasonable fear, too, no
doubt, that their obstreperous congratulations might be heard in
other houses around, so as to alarm the neighbors and bring out
some spiteful Jews, who would procure his detection and
recapture,――having obtained silence, went on to give them a full
account of his being brought out of prison by the Lord, and after
finishing his wonderful story, said to them, “Tell these things to
James and the brethren.” From this it would seem that the apostles
were all somewhere else, probably having found that a temporary
concealment was expedient for their safety, but were still not far from
the city. His own personal danger was of so imminent a character,
however, that Jerusalem could not be a safe place for him during the
search that would be immediately instituted after him by his
disappointed and enraged persecutors. It was quite worth while,
therefore, for him to use the remaining darkness of the night to
complete his escape; and without staying to enjoy their outflowing
sympathies, he bade them a hasty farewell, and, as the historian
briefly says, went to another place. Where this “other place” was,
he does not pretend to tell or know, and the only certain inference to
be drawn from the circumstance is, that it was beyond the reach or
knowledge of the mighty and far-ruling king, who had taken such
particular pains to secure Peter’s death. The probabilities as to the
real place of his retirement will, however, be given, as soon as the
sequel of events in Jerusalem has been narrated, as far as concerns
the discovery of his escape.
Baronius, (Church Annuals, 44, § 8,) speaking of Peter’s escape from his chains, favors
us with a solemn statement of the important and interesting circumstance, deriving the
proofs from Metaphrastes, (that prince of papistical liars, and grand source of Romish
apostolical fables,) that these very chains of Peter are still preserved at Rome, among other
venerable relics of equal authenticity; having been faithfully preserved, and at last found
after the lapse of four hundred years. The veritable history of this miraculous preservation,
as given by the inventive Metaphrastes, is, that the said chains happened to fall into the
hands of one of Agrippa’s servants who was a believer in Christ, and so were handed down
for four centuries, and at last brought to light. It is lamentable that the list of the various
persons through whose hands they passed, is not given, though second in importance only
to the authentic record of the papal succession. This impudent and paltry falsehood will
serve as a fair specimen of a vast quantity of such stuff, which litters up the pages of even
the sober ecclesiastical histories of many papistical writers. The only wonderful thing to me
about this story is, that Cave has not given it a place in his Lives of the Apostles, which are
made up with so great a portion of similar trash.
Baronius, in connection with this passage, suggests the castle of Antonia as the most
probable place of Peter’s confinement. “Juxta templum fortasse in ea munitissima turri quae
dicebatur Antonia.” (Baronius, Church Annuals, C. 44, § 5.) A conjecture which certainly
adds some weight to my own supposition to that effect; although I did not discover the
coincidence in time to mention it in my note on page 194.
Meanwhile, with the early day, up rose the royal Agrippa from his
purple couch, to seize the first moment after the close of the
passover for the consummation of the doom of the wretched
Galilean, who, by the royal decree, must now yield the life already
too many days spared, out of delicate scruple about the inviolate
purity of that holy week. Up rose also the saintly princes of the
Judaic law, coming forth in their solemn trains and broad
phylacteries, to grace this most religious occasion with their reverend
presence, out of respectful gratitude to their great sovran for his
considerate disposition to accord the sanction of his absolute secular
power to their religious sentence. Expectation stood on tiptoe for the
comfortable spectacle of the streaming life-blood of this stubborn
leader of the Nazarene heresy, and nothing was wanting to the
completion of the ceremony, but the criminal himself. That
“desideratum, so much to be desired,” was, however, not so easily
supplied; for the entrance of the delinquent sentinels now presented
the non-est-inventus return to the solemn summons for the body of
their prisoner. Confusion thrice confounded now fell on the faces that
were just shining with anticipated triumph over their hated foe, while
secret, scornful joy illuminated the countenances of the oppressed
friends of Jesus. But on the devoted minions of the baffled king, did
his disappointed vengeance fall most cruelly; in his paroxysm of
vexation, and for an event wholly beyond their control they now
suffered an undeserved death; making so tragical a catastrophe to a
story otherwise decidedly comical, that the reader can only comfort
himself with the belief that they were a set of insolent reprobates
who had insulted the distresses of their frequent victims, and would
have rejoiced in the bloody execution of the apostle.