0% found this document useful (0 votes)
98 views

Learn Quantum Computing with Python and Q#: A hands-on approach 1st Edition Sarah C. Kaiser instant download

The document is a promotional material for the book 'Learn Quantum Computing with Python and Q#' by Sarah C. Kaiser and Christopher Granade, which offers a hands-on approach to quantum computing. It includes links to download the book and other related resources. The content covers various aspects of quantum computing, including programming in Q# and applied quantum computing techniques.

Uploaded by

wasakaroyz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views

Learn Quantum Computing with Python and Q#: A hands-on approach 1st Edition Sarah C. Kaiser instant download

The document is a promotional material for the book 'Learn Quantum Computing with Python and Q#' by Sarah C. Kaiser and Christopher Granade, which offers a hands-on approach to quantum computing. It includes links to download the book and other related resources. The content covers various aspects of quantum computing, including programming in Q# and applied quantum computing techniques.

Uploaded by

wasakaroyz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Learn Quantum Computing with Python and Q#: A

hands-on approach 1st Edition Sarah C. Kaiser


pdf download

https://ebookmeta.com/product/learn-quantum-computing-with-
python-and-q-a-hands-on-approach-1st-edition-sarah-c-kaiser/

Download more ebook from https://ebookmeta.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmeta.com
to discover even more!

Hands-on Matplotlib: Learn Plotting and Visualizations


with Python 3 Ashwin Pajankar

https://ebookmeta.com/product/hands-on-matplotlib-learn-plotting-
and-visualizations-with-python-3-ashwin-pajankar/

Dancing with Python Learn Python software development


from scratch and get started with quantum computing 1st
Edition Robert S. Sutor

https://ebookmeta.com/product/dancing-with-python-learn-python-
software-development-from-scratch-and-get-started-with-quantum-
computing-1st-edition-robert-s-sutor/

Hands-on Machine Learning with Python: Implement Neural


Network Solutions with Scikit-learn and PyTorch 1st
Edition Ashwin Pajankar

https://ebookmeta.com/product/hands-on-machine-learning-with-
python-implement-neural-network-solutions-with-scikit-learn-and-
pytorch-1st-edition-ashwin-pajankar/

Narratives of Place in Literature and Film 1st Edition


Steven Allen

https://ebookmeta.com/product/narratives-of-place-in-literature-
and-film-1st-edition-steven-allen/
New Literacies and Teacher Learning Professional
Development and the Digital Turn New Literacies and
Digital Epistemologies Michele Knobel (Editor)

https://ebookmeta.com/product/new-literacies-and-teacher-
learning-professional-development-and-the-digital-turn-new-
literacies-and-digital-epistemologies-michele-knobel-editor/

Production Design & the Cinematic Home 1st Edition Jane


Barnwell

https://ebookmeta.com/product/production-design-the-cinematic-
home-1st-edition-jane-barnwell/

The Law of Higher Education Student Version Student


Version 6th Edition William A. Kaplin

https://ebookmeta.com/product/the-law-of-higher-education-
student-version-student-version-6th-edition-william-a-kaplin-2/

Principles of California Real Estate 19th Edition


Kathryn J Haupt

https://ebookmeta.com/product/principles-of-california-real-
estate-19th-edition-kathryn-j-haupt/

Yorkie Doodle Dandy 8th Edition William A Wynne

https://ebookmeta.com/product/yorkie-doodle-dandy-8th-edition-
william-a-wynne/
T Helper Cells Francesco Annunziato Laura Maggi Alessio
Mazzoni

https://ebookmeta.com/product/t-helper-cells-francesco-
annunziato-laura-maggi-alessio-mazzoni/
A hands-on approach

Sarah Kaiser
Christopher Granade

MANNING
Description Code (Q# and QuTiP) Unitary matrix Mathematical examples

Bit flip X(target); // Q# X|0⟩ = |+⟩


01
(Pauli X) X=
10 X|1⟩ = |–⟩
qt.sigmax() # QuTiP
X|+⟩ = |+⟩
X|–⟩ = –|–⟩

Bit and Y(target); // Q#


 0 –1 i  Y|0⟩ = i |1⟩
phase flip Y=   Y|1⟩ = –i |0⟩
(Pauli Y) qt.sigmay() # QuTiP
1i 0  Y|+⟩ = –i |–⟩
Y|–⟩ = i |+⟩

Phase flip Z(target); // Q# Z|0⟩ = |0⟩


Z= 1 0 
(Pauli Z)  0 –1  Z|1⟩ = –|1⟩
qt.sigmaz() # QuTiP
Z|+⟩ = |–⟩
Z|–⟩ = |+⟩

Hadamard H(target); // Q# H|0⟩ = |+⟩


H = -------  
1 1 1
2  1 –1  H|1⟩ = |–⟩
qtops.hadamard_transform()
H|+⟩ = |0⟩
# QuTiP
H|–⟩ = |1⟩

Controlled- CNOT(control, target); // Q# UCNOT(|0⟩ ⊗ |x⟩) = (|0⟩ ⊗ |x⟩)


 1 0 0 0 
NOT (CNOT) (shorthand)
 0 1 0 0  UCNOT(|1⟩ ⊗ |x⟩) = (|1⟩ ⊗ |¬x⟩)
Controlled X( UCNOT =   UCNOT|+–⟩ = –|––⟩
[control],  0 0 0 1

 0 0 1 0 
target
); // Q#

qtops.cnot() # QuTiP

CCNOT CCNOT(control1, control2, UCCNOT = UCCNOT|000⟩ = |000⟩


(Toffoli) target); // Q# (shorthand)
 1 0 0 0 0 0 0 0  UCCNOT|110⟩ = |111⟩
Controlled X(  0 1 0 0 0 0 0 0 
[control1, control2], target  0 0 1 1 0 0 0 0 
); // Q#  
 0 0 1 1 0 0 0 0 
qtops.toffoli() # QuTiP  0 0 0 0 1 0 0 0 
 0 0 0 0 0 1 0 0 
 
 0 0 0 0 0 0 0 1 
 0 0 0 0 0 1 0 0 
X-rotation Rx(angle, target); // Q#
 cos -- – i sin --   
Rx( |0⟩) = cos -- |0⟩ – i sin -- |1⟩
qtops.rx(angle) # QuTiP  2 2  2 2
Rx( ) =  
 
 – i sin -- cos -- 
 2 2 
Y-rotation Ry(angle, target); // Q#
 cos --  
 – sin --  Ry( |0⟩) = cos -- |0⟩ + sin -- |1⟩
2 2
qtops.ry(angle) # QuTiP 2 2
Ry( ) = 
  
 sin -- cos -- 
 2 2 

Z-rotation Rz(angle, target); // Q# i  /2


 e –i  /2 0  Rz( |0⟩) = e |0⟩
qtops.rz(angle) # QuTiP Rz( ) =  i  /2 
 0 e 
Measure M(target); // Q# n/a n/a
single qubit
n/a
Learn Quantum Computing with Python and Q#
Learn Quantum
Computing with
Python and Q#
A HANDS-ON APPROACH

SARAH KAISER
AND CHRIS GRANADE

MANNING
SHELTER ISLAND
For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
20 Baldwin Road
PO Box 761
Shelter Island, NY 11964
Email: [email protected]

©2021 by Manning Publications Co. All rights reserved.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in


any form or by means electronic, mechanical, photocopying, or otherwise, without prior written
permission of the publisher.

Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning Publications
was aware of a trademark claim, the designations have been printed in initial caps or all caps.

Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books
are printed on paper that is at least 15 percent recycled and processed without the use of
elemental chlorine.

Development editor: Dustin Archibald


Technical development editors: Alain Couniot and Joel Kotarski
Manning Publications Co. Review editor: Ivan Martinović
20 Baldwin Road Production editor: Deirdre S. Hiam
PO Box 761 Copy editor: Tiffany Taylor
Shelter Island, NY 11964 Proofreader: Katie Tennant
Technical proofreader: Krzysztof Kamyczek
Typesetter: Dennis Dalinnik
Cover designer: Marija Tudor

ISBN: 9781617296130
Printed in the United States of America
We dedicate this book to the next generation of quantum developers who are working
to make this field a safer and more inclusive space.
brief contents
PART 1 GETTING STARTED WITH QUANTUM . ..............................1
1 ■ Introducing quantum computing 3
2 ■ Qubits: The building blocks 17
3 ■ Sharing secrets with quantum key distribution 54
4 ■ Nonlocal games: Working with multiple qubits 75
5 ■ Nonlocal games: Implementing a multi-qubit simulator 90
6 ■ Teleportation and entanglement: Moving
quantum data around 108

PART 2 PROGRAMMING QUANTUM ALGORITHMS IN Q#. .......... 131


7 ■ Changing the odds: An introduction to Q# 133
8 ■ What is a quantum algorithm? 152
9 ■ Quantum sensing: It’s not just a phase 185

PART 3 APPLIED QUANTUM COMPUTING . ............................... 217


10 ■ Solving chemistry problems with quantum computers 219
11 ■ Searching with quantum computers 249
12 ■ Arithmetic with quantum computers 278

vii
contents
foreword xv
preface xvii
acknowledgments xix
about this book xxi
about the authors xxv
about the cover illustration xxvi

PART 1 GETTING STARTED WITH QUANTUM .....................1

1 Introducing quantum computing 3


1.1 Why does quantum computing matter? 4
1.2 What is a quantum computer? 5
1.3 How will we use quantum computers? 8
What can quantum computers do? 10 ■
What can’t
quantum computers do? 11
1.4 What is a program? 13
What is a quantum program? 14

ix
x CONTENTS

2 Qubits: The building blocks


2.1 Why do we need random numbers?
17
19
2.2 What are classical bits? 22
What can we do with classical bits? 23 ■
Abstractions are
our friend 26
2.3 Qubits: States and operations 27
State of the qubit 28 The game of operations 30

Measuring qubits 34 Generalizing measurement: Basis


independence 38 Simulating qubits in code 41


2.4 Programming a working QRNG 46

3 Sharing secrets with quantum key distribution


3.1 All’s fair in love and encryption 54
54

Quantum NOT operations 58 ■ Sharing classical bits


with qubits 62
3.2 A tale of two bases 63
3.3 Quantum key distribution: BB84 66
3.4 Using a secret key to send secret messages 71

4 Nonlocal games: Working with multiple qubits 75


4.1 Nonlocal games 76
What are nonlocal games? 76 Testing quantum physics:

The CHSH game 76 Classical strategy 80


4.2 Working with multiple qubit states 81


Registers 81 Why is it hard to simulate quantum

computers? 83 Tensor products for state preparation



85
Tensor products for qubit operations on registers 86

5 Nonlocal games: Implementing a multi-qubit simulator 90


5.1 Quantum objects in QuTiP 91
Upgrading the simulator 96 Measuring up: How can

we measure multiple qubits? 99


5.2 CHSH: Quantum strategy 103
CONTENTS xi

6 Teleportation and entanglement: Moving quantum data


around 108
6.1 Moving quantum data 109
Swapping out the simulator 112 ■
What other two-qubit
gates are there? 115
6.2 All the single (qubit) rotations 117
Relating rotations to coordinates: The Pauli operations 119
6.3 Teleportation 126

PART 2 PROGRAMMING QUANTUM ALGORITHMS IN Q# ...131

7 Changing the odds: An introduction to Q#


7.1 Introducing the Quantum Development Kit
133
134
7.2 Functions and operations in Q# 137
Playing games with quantum random number generators
in Q# 138
7.3 Passing operations as arguments 143
7.4 Playing Morgana’s game in Q# 149

8 What is a quantum algorithm?


8.1
152
Classical and quantum algorithms 153
8.2 Deutsch–Jozsa algorithm: Moderate improvements
for searching 156
Lady of the (quantum) Lake 156
8.3 Oracles: Representing classical functions
in quantum algorithms 161
Merlin’s transformations 162 ■ Generalizing our results 165
8.4 Simulating the Deutsch–Jozsa algorithm in Q# 170
8.5 Reflecting on quantum algorithm techniques 174
Shoes and socks: Applying and undoing quantum operations 175
Using Hadamard instructions to flip control and target 178
8.6 Phase kickback: The key to our success 180
xii CONTENTS

9 Quantum sensing: It’s not just a phase


9.1 Phase estimation: Using useful properties of qubits
for measurement 186
185

Part and partial application 186


9.2 User-defined types 191
9.3 Run, snake, run: Running Q# from Python 197
9.4 Eigenstates and local phases 202
9.5 Controlled application: Turning global phases
into local phases 206
Controlling any operation 210
9.6 Implementing Lancelot’s best strategy
for the phase-estimation game 212
9.7 Summary 215
9.8 Part 2: Conclusion 215

PART 3 APPLIED QUANTUM COMPUTING ......................217

10 Solving chemistry problems with quantum computers


10.1 Real chemistry applications for quantum computing 220
219

10.2 Many paths lead to quantum mechanics 222


10.3 Using Hamiltonians to describe how quantum systems
evolve in time 225
10.4 Rotating around arbitrary axes with Pauli operations 229
10.5 Making the change we want to see in the system 237
10.6 Going through (very small) changes 239
10.7 Putting it all together 242

11 Searching with quantum computers


11.1 Searching unstructured data
249
250
11.2 Reflecting about states 256
Reflection about the all-ones state 257 ■
Reflection about
an arbitrary state 258
11.3 Implementing Grover’s search algorithm 264
11.4 Resource estimation 271
CONTENTS xiii

12 Arithmetic with quantum computers


12.1
278
Factoring quantum computing into security 279
12.2 Connecting modular math to factoring 283
Example of factoring with Shor’s algorithm 287
12.3 Classical algebra and factoring 288
12.4 Quantum arithmetic 291
Adding with qubits 292 Multiplying with qubits in

superposition 293 Modular multiplication in Shor’s


algorithm 296
12.5 Putting it all together 299

appendix A Installing required software 307


appendix B Glossary and quick reference 314
appendix C Linear algebra refresher 327
appendix D Exploring the Deutsch–Jozsa algorithm by example 341
index 351
Other documents randomly have
different content
"ears that would have heard the hunter's, halloo, from Stirling to
Linlithgow. Why, I called to you out of my high window in the High
Street as you rode by, till the echo at the Blackford hills shouted out
Gowrie; and you spurred on as if you had stopped your ears with
wax, like Don Ulysses when in danger of the fair ladies on the shore.
Would to Heaven all our mariners would do the same when they first
land."

"I did not hear you, Hume," answered Gowrie, in a grave tone.
"In truth, my friend, my heart is very sad, and my outward faculties
have little communication with the spirit within. But what makes you
look so joyful?"

"One of the strange revolutions of the court of King Solomon,"


answered Hume; "whether his majesty has found out some
sovereign remedy for dispelling the black humours, or for warming
and comforting the spleen; or whether his favourite brack has cast
him a litter of peculiarly fine pups; or whether Queen Elizabeth has
declared him heir to the throne of England, or the Queen of Sheba
has sent word to say she will be here to-morrow, or--But never
mind, something or another has turned the gall and verjuice into
honey and sweetness, and especially towards your dearly beloved
family. He ran after Beatrice to-day to the queen's very knees,
vowing he would fasten her shoe, while I was forced to stand by
looking demure; and he actually gave Alex a hawk--it is not worth a
bodle, by the way, but still the gift was something, considering who
it comes from."

"I wrote to him from Perth," said Gowrie, "beseeching him to give
me an answer to the suit, which I told you I had preferred, and he
has never replied my letter."

"Done on purpose to fret you," answered Hume; "he said so


before the whole court this very day, and called you a love-lorn
gallant."
"I care not what he calls me," replied the earl, "so that he do but
consent freely."

"He does consent," replied his friend, "and all your troubles on
that score, Gowrie, are at an end. So smoothe your wrinkled brow,
my noble lord, and give cold care to the wind."

"Are you quite sure?" demanded the earl, hardly believing the
joyful tidings.

"Surer than of my own existence; for that I know nothing about,"


answered Hume, "had it not been for that overt act, I should have
doubted his majesty's sincerity, for his sunshine is not always
summer. But deeds speak for themselves. I will tell you how it all
happened.--Three days ago he was in an awful mood, and pulled
more points off his hose than he had money in his coffers to put on
again; but just then came in the news of Stuart of Greenallan's
death without heirs, and all his moveables are seised to the crown,
besides a large sum in ready money, which he left by will to the
king--knowing he would take it if he did not. Well, this windfall
mollified him mightily, and he has been improving ever since. But
this morning he has had a dispute with three ministers touching
church government, and Heaven knows what besides, and he
quoted all sorts of books that nobody ever heard of before--long
screeds of Latin, Greek, and Hebrew, till I believe, upon my life, the
poor bodies were quite, as they said, dumfounded, and fairly gave
in. I would wager my best horse against a tinker's donkey, they did
not understand a word, and the king himself not half of what he
poured forth upon them; but they owned in the end that his majesty
was right and they were wrong, for they could not confute his
arguments or reply to his authorities. One old fellow, indeed, made
some fight for it, and answered in Greek and Hebrew too; but the
king had two texts for every one of his, and so he too was beat in
the end. From that moment he has been all frolic; and this afternoon
he held up your letter before dear Beatrice's eyes, and asked if she
knew who that came from. So she answered, gaily, 'From one of
your majesty's sweethearts, I suppose.' 'Faith, no such thing,' said
James, 'but I'll try and make him a sweetheart before I've done, and
that by giving him his sweetheart too. It's from your own brother,
John, saucy lassie--a most disconsolate epistle, because I forgot to
tell him he should have the bonny bird he's so brodened upon. But
he shall have her notwithstanding; and I trust she'll plague him till
she makes him more complutherable.' Then Beatrice burst into a
peal of laughter, so clear, so merry, so joyful, that it set the whole
court off, king and queen and all, till James, wiping his eyes, told her
to 'haud her guffaw,' or she should not be married herself for a
month after you; and then she laughed more gaily than before, but
petitioned that she might be permitted to write to you, and tell you
of his royal grace. That, the king would not hear of, saying, 'No, I
forbid any one to write him a scrape of a pen. Then shall we have
him coming with a face as long as a whinger, and his heart full of
disloyal repinings, to know if we are minded to condescend to his
request.' But the dear girl answered, with her own good sense,
'More chance of his heart being full of sorrow lest he have offended
your majesty.' However, the king would not consent that any one
should write to you, saying he wished to see what you would do,
and exacted a promise that neither Beatrice nor Alex would say a
word. Me, he did not so bind; but yet it were better not to let him
know that you have been informed."

"I am a bad dissembler, John," replied the earl, "and I fear that
the joy in my heart will shine out on my face, do what I will.
However, I will do my best to look sad; but is not this a strange
person for a king--a strange scene for a court?"

"You would have thought it stranger still, had you but seen the
whole," answered Hume. "All the time he was speaking, he held the
hawk I have told you of on his hand, and kept stroking it down the
back, at which it screamed, and then his gracious majesty called it
sometimes greedy gled, and sometimes courtier, till Herries, who
thinks he can venture anything, asked why he called it courtier."
"What did he answer?" inquired Gowrie.

"Why, he put on what he would call a pawky look," replied the


other, "and said, 'Because it is like the horseleech's daughter, doctor.
It aye lifts up its neb, and scrawks for more.'"

Both Gowrie and Hume laughed gaily at this sally, the one in
hearing and the other in telling; for the young earl's heart was
lightened, and such creatures of circumstance are we, that, with a
mind relieved, a reply seemed to him full of humour, which a minute
or two before he would have thought nought but a coarse and
vulgar jest.

"How did Herries bear the rebuke?" asked Gowrie; "for to him it
must have been a severe one."

"Oh, with his own bitter humour," answered the knight. "He said,
'Ay, sir, it is sad how we are led by example. Every one, man and
beast, follows his master.' To which the king replied, good naturedly
enough, 'Haud yer peace, ye doited auld carle! If you followed your
master I'se warrant you'd no pluck but be plucked--you'd be the doo
and no the gled.' However, I think that Herries is not so great a
favourite as he once was; and I am not sorry for it, for he was ever
an enemy to both your house and mine, Gowrie, and is one of those
cold-blooded, ever-ready men, who never miss an opportunity to do
ill to another by a quiet insinuation pointed by a jest."

"I know him not at all," answered Gowrie. "Alexander and


Beatrice love him not; but one need never fear an open enemy. It is
the covert attack, the blow struck behind one's back, the quiet lie
spoken, forsooth, in confidence, that one fears; for they are like the
poisoned weapon of the Italian bravo, which slays, though the
wound be but a scratch."

"For the present I do not think you need fear him in any way,"
replied Sir John Hume; "but go early to-morrow, Gowrie, and take
advantage of the tide of favour at the flow."
The conversation then took a more general turn. The various
characters of the personages of the court of King James were
discussed by the earl and his friend, and the prospects of the
country generally were spoken of in a lighter and a gayer spirit than
the earl could have shared in an hour before. Some little word--one
of those accidental expressions which often set the mind galloping in
a different direction from that which it was previously pursuing--led
the earl's thoughts suddenly to his brother; and he said, "By the
way, Hume, Beatrice seems to think that Alex is even in less favour
than myself with his majesty, and I could not induce her to explain
the matter fully. She referred me to you, saying you would be able to
inform me what was the cause of James's dislike."

"The simplest in the world," answered Hume. "The king dislikes


him, because he thinks the queen likes him--too much. The truth is,
James is jealous; and, like all suspicious people, hates the object of
his suspicion, endures his presence at the court simply for the
purpose of entrapping him, and watches for every opportunity to
find a motive to take revenge."

"But is there any cause for this suspicion?" asked Gowrie, very
gravely. "Can Alex have been mad enough, wicked enough, to have
afforded any just grounds for such jealousy?"

"On my life I believe not," replied Hume. "The queen makes no


secret of her liking for handsome young men; and Alex is certainly
as fine a looking lad as ever mounted a horse or drew a sword. She
contends strongly, too, for that liberty of action which we northern
people do not conceive a privilege of fair ladies. She will go where
she likes, do what she likes, and see whom she likes, without being
responsible to any tribunal but that of conscience. This is her
doctrine; and, by Heaven, she practises what she preaches. The king
may make himself as absolute as he will out of his own house, but
he will not be despotic there very easily. Then again, her majesty
likes the gallant part of the old chivalry, and thinks that love and
devotion are every lady's due from every courtly gentleman. There
must be a touch of romantic passion in it, too, to please her; and
she goes into these little amourettes in the most light-hearted way
possible, without a thought of evil, I do believe. It is all too open--
too bold, to be criminal. But the king, on the contrary, takes a very
different view of these matters. While he claims to himself the right
of the utmost familiarity of manner and lightness of speech with
man, woman, and child, he would have all ladies as prim and
demure as nuns, and as obedient as a spaniel dog. In point of policy,
Alex committed a great error in attaching himself to the queen
instead of to the king, for, it is sad to say, one cannot be a favourite
with both."

"I would rather he were a favourite with neither," said Gowrie.


"He might serve both, love both, merit the friendship of both; but to
be the minion of either king or queen is not for one of my race."

"Well, well," answered his friend, "he is still a very young man,
but right at heart, I am sure; and I trust he will see that these
gallantries with the queen, however innocent, are, at the least,
improper."

"I must make him see it," said Gowrie, and turned the
conversation, which ended soon after by Hume leaving him to his
own thoughts.

The following morning broke cold and cheerless; but at as early


an hour as was consistent with propriety, Gowrie presented himself
at the palace, and was readily admitted to an audience. The king
was in the act of pushing out of the room, with his own hands, in a
jocular but somewhat rude manner, no less a personage than Sir
Hugh Herries, saying, "There, get along with you. You are a saucy
body, and were we not the best natured monarch that ever lived, we
should not bear with your gibes.--Ah, my Lord of Gowrie! Now
you've come for an answer to your letter, I ween?"
"If it may please your majesty to give me one," answered Gowrie,
with as grave a face as he could put on, while the king retired into
his cabinet again, and took his seat.

"You see, my lord," said James, with a very serious air, "this is a
matter of much importance, and which requires full consideration
and deliberation on our part. Now I'll warrant that you're for wanting
to cut the matter short, and to be married to the lady directly;" and
he looked up slily in the earl's face.

"My own inclination would of course lead as your majesty


supposes," replied Gowrie; "and I think, in many points of view, it
would be the best plan; but the lady herself desires that our union
should be delayed till the month of September next, if it please your
majesty to consent for that time."

"She's a very discreet young lady," said the king. "Feggs! most
lasses would be all agog to be a married woman, and Countess of
Gowrie. Well, my lord, we'll consider of it."

Gowrie now felt alarmed and mortified. Whether the king had
changed his mind since the preceding night, or whether he was
merely sporting with his feelings for his own amusement, the young
lover felt a degree of impatience which he was afraid would break
forth in some angry words if he stayed longer; and therefore, with a
silent bow, but a heated cheek and disappointed air, he retired
towards the door.

James let him reach it and lay his hand upon the lock, but then
stopped him, exclaiming, "Hoot, man, come hither--don't go away in
the dorts, like a petted bairn. Come hither to your king, who is
willing to act as a good and kind father to you and to all his leal
subjects, if they will let him."

Gowrie returned with a brighter look. "There, now," continued


James, who in many instances was acute enough; "you are laughing
now; and I'll warrant that your titty, or the lad Alex, has been telling
you of the grace and favour we intend to show you."

"I can assure your majesty," answered Gowrie, "that I have


neither seen nor heard from my brother or sister during the last four
or five days; but I can perceive, by your majesty's countenance, that
you intend to deal graciously with me in this matter."

"I'm thinking you're a false chiel," said James, laughing; "and you
think that a fine fleeching speech, about my countenance, as you
call it; but I'll tell you what, earl, if I thought my face would tell what
I'm thinking of when I didn't want it, I'd claw the skin off it with my
own ten fingers; for let me inform you, sir, it's a principal point of
kingcraft to be able to speak with a sober and demure countenance,
whatever the matter in hand may be, whether merry and jocose, or
sad and serious. Men should never be able to tell, by the looks of a
sovereign, whether he be thinking of a burial or a marriage, a birth
or a death."

"But wise kings, sire," answered Gowrie, "are ever apt to double
the value of the favours they confer by gracious looks and words."

"That's well said," said the king, with an inclination of his head.
"That's spoken like a prudent and well-nurtured lad; and we do
intend graciously towards you, and will give you proof thereof. We
will consent to your marriage with this lady in the month of
September next, as you suppose; and, moreover, we will give you
that consent in writing, for there are certain conditions which, as you
know well, you yourself agreed to, and which we have embodied
here in this paper, as a sort of proviso, qualifying our consent."

Gowrie was a little startled by this announcement; but the king


soon relieved him from all anxiety, by showing him the paper, which
was to the effect that he, the king, authorized and consented to the
marriage of John Earl of Gowrie and the Lady Julia Douglas, a ward
of the crown, upon the condition that the Lady Julia Douglas should
previously execute, in due form, a renunciation of all claims, founded
upon any grounds whatsoever, to the lands of Whiteburn, and to all
other estates, money, goods, or chattels whatsoever, once in
possession of the last Earl of Morton. Otherwise the authorization
was to have no effect. The sense was enveloped in an immense
mass of legal verbiage, which would have been totally unintelligible
to any one unacquainted with the language of the Scottish courts;
but Gowrie had made a point of bestowing some study upon the
laws of his native land, and the meaning was quite clear to him.

"To these conditions I agree at once, sire," he said; "and am


willing to give your majesty an undertaking, under any penalty you
please, that the renunciation specified shall be made."

James caught readily at this idea; and being fond of showing his
skill in such matters, he at once drew up, with his own hand, the
form of undertaking which was proposed, and to which Gowrie
willingly put his hand, on receiving the written consent of the king to
his marriage.

"And now, my lord, away to Trochrie," cried the king, as Gowrie


kissed his hand, "and bring your bonny birdy out of her nest.--Ay,
you may stare, and look stupified, but if you think you can hoodwink
your king like a gyr falcon on its perch, you'll find yourself mistaken,
like many another man has been.--Well, well, say nothing about it.
We forgive you, man; and if you don't think us the most gracious
monarch that ever lived, you're an ungrateful lad."

"Indeed, sire, I do think your majesty most gracious," replied


Gowrie, a good deal moved; "and I will do my best to prove my
gratitude; but before I go to Trochrie, I had better have this
renunciation drawn up in due form by some people of the law, that I
may at once obtain the Lady Julia's signature, and lay it at your
majesty's feet."
To this plan James cordially acceded; and Gowrie, taking his
leave, was retiring to share his joy with his sister Beatrice, and to
endeavour to persuade his brother to withdraw from the court,
where his presence was a source of jealousy and dissension, when
there was a gentle tap at the door, and an usher put in his head,
saying, "Here is the Italian merchant, may it please your majesty."

"Bring him in--bring him in," cried James. "Stay a little, my good
lord; this is a man from the country you know so well, bringing
wares to show us, and we will have your judgment upon his bonny
toys."

Gowrie would fain have escaped, but there was no resource; and
the Italian merchant, as he was called, though in fact he might have
ranked better as a pedlar, was brought into the king's presence. The
young earl instantly recognised a man from whom he himself had
occasionally purchased wares in Padua, which was at that time
famous for its manufactories of silk; and the merchant himself, after
saluting the king, made him a low bow.

"Ah, you two have met before, I suppose," said the king. "But
come, open your chest, man, and let us see what you've brought."

The goods were soon produced, consisting principally of ribbons


and laces, which might have better suited the examination of a lady
than of a king; and James selected several articles for purchase with
not the very best taste in the world. He asked Gowrie's opinion upon
them before he concluded his bargain; and the earl, though not a
very excellent courtier, was sufficiently learned in that craft not to
speak disparagingly of the king's taste. At length an exceedingly
beautiful ribbon was produced, wrought with figures of blue and
gold, so thick and massive, that it seemed better fitted for a sword-
belt than anything else; but James fixed eagerly upon it, declaring
he would present it to the queen. He soon after suffered the earl to
depart, keeping the Italian merchant with him; and as soon as the
door was closed, he said, in a familiar tone, "You knew that lad in
Italy, I suppose, my man?"

The Italian replied in the affirmative; and James, whose curiosity


was inexhaustible, proceeded to question him upon all he knew
regarding Gowrie's history. The good man had no idea whatsoever of
doing harm; but we all know how one tale leads on another,
especially under the hands of one skilful in extracting anecdotes;
and although almost all the Italian had to say was favourable to the
earl, though he told how he had been elected unanimously Lord
Rector, at a very early period, and how his conduct had given such
satisfaction, that the university had placed his portrait in the great
hall, yet he went on to add that he believed the earl had conceived
some disgust in the end from the treatment of one to whom he was
much attached.

James proceeded to question him eagerly on this hint, and soon


drew forth the Italian's version of the history of poor Manucci. Truth
and fiction were mingled in the usual proportion of a tale so told;
but magic and witchcraft were favourite topics with the king; and
from the gossiping style in which it first began, his conversation
gradually deviated into disquisition, and afterwards almost took the
form of a judicial examination, as he questioned and cross-
questioned the poor merchant in regard to Manucci's skill in
diabolical arts, and Gowrie's connexion with him. The good man,
anxious to curry favour with the monarch, and restrained by no very
great scruples of conscience, would probably have said anything that
the king liked, and certainly, in the matter of suggestion, James did
not fail to supply him with indications of his own opinions.

The belief in such arts as sorcery and witchcraft seems in our


eyes at the present day so ludicrous, that we can hardly bring our
minds to believe that in former times the great mass of all classes,
high and low, were fully persuaded that power could be obtained by
mortals over certain classes of evil spirits. But such was undoubtedly
the case at the time I speak of; and the effect was often most
disastrous. In the present instance, James took care not to inform
the Italian of the conclusions to which he came in regard to Gowrie;
and it may be sufficient in this case to state that when he dismissed
the merchant, he remained with an impression very unfavourable to
the young earl, which, combined with other causes, did not fail to
produce bitter fruit at an after period.

CHAPTER XXXIV.

"Can you tell me where I shall find my sister, Ballough?" said the
Earl of Gowrie, addressing the usher of the queen's chambers, after
he left the king.

"She's gone out with her brother, my lord," replied the officer;
"and I think they took their way to your lordship's lodgings."

"I do not think it, Ballough," said the earl. "I must have met
them; or at least they must have seen my horses at the gate."

"They went the other way, my lord," said the man. "I saw them
go towards the physic garden. I heard the Lady Beatrice say that
that would be the quietest road, as they were on foot."

"Can I pass through there?" asked the earl.

"Not through this passage, my lord," replied the man, "but if you
go round by the portico, you'll find the little gate open, and that will
lead you straight."

The earl accordingly dismissed his horses and servants, and took
his way through a part of the gardens of Holyrood, or "the abbey,"
as it was frequently called in those days, issuing forth into the more
busy part of the town by a gate at some distance from the palace.
The door itself was closed but not locked; and, as he was
approaching it, he heard a voice saying, "We have not starved your
horse, you foul-tongued southron! Now, ride away as fast as you can
go; and mind, if you say one word, you will be put into one of the
dungeons at Stirling, and treated to a taste of the boot you saw the
other day. There, away with you!" And these words were followed by
the loud crack of a whip.

"A whole skin is the best coat that ever was made," said a voice
which Gowrie thought he knew well, and passing through the door
at the same moment, he looked eagerly up the street, his eye
guided by the clattering of a horse's feet at a rapid pace. On that
side appeared no other than the figure of his own man, Austin Jute,
mounted on the very horse which he had ridden to Trochrie; and
turning sharply round, the earl saw on the other hand, walking away
towards the palace, the stout form and club foot of Dr. Herries, and
another gentleman attached to the king's household, named
Graham.

Gowrie asked himself what could be the meaning of this. Could


Jute be really betraying him after serving him so long and so
faithfully. "I will not believe it," he said to himself. "The tricks of
these courts would make a man suspicious of his best friend. Yet it is
very strange--but I will wait and see. I shall soon discover, by the
man's manner, if he is concealing anything from me;" and with
matter for musing, he walked on his way. Neither brother nor sister
did he meet as he went on, but found both waiting for him at his
dwelling in the town.

"We thought to catch you before you set out, Gowrie," said
Beatrice, as soon as she saw him, "for Hume wrote me word this
morning that he had seen you. However, I trust, from your look, that
all is safe and right, and that the king's good humour, which waxes
and wanes like the moon, has not decreased since yesterday."
Gowrie sat down by her side, and told her all that had occurred,
the whole account being tinged with the joyful hopes of his own
heart. Beatrice looked pleased, but less so than he expected; and
she asked, somewhat abruptly, "And now, Gowrie, what do you
intend to do?"

"To set out for Trochrie as soon as this paper of renunciation is


drawn up," he replied; "and then transplant my wild rose to
Dirleton."

"Take my advice, and do no such thing," answered Beatrice.


"Depend upon it, Gowrie, she's safer where she is. You do not know
the king as well as we do. With him the sunshine often
prognosticates worse weather than the clouds; and I very much
doubt his motives in this matter. That you have got his written
consent is a great step, certainly; and we may well be joyful thereat;
but he is famous for baiting traps; and if he once got her into his
power, think what a hold he would have upon you. It would cost him
more men and more money than he can collect, to take her by force
from Trochrie; and he has no excuse for attempting it; but if once
she were at Dirleton, he would soon find means of bringing her to
Edinburgh, and then your freedom of action would be gone."

"You are a wise counsellor, Beatrice," replied her brother; "and I


like your advice well. 'Tis only that Trochrie is such a lonely and
desolate solitude for the dear girl, that makes me hesitate."

"You can easily render it less solitary," said Alexander Ruthven,


laughing. "Go up there yourself, and keep her company."

"If you will come with me, Alex," replied his brother.

The young man coloured and looked embarrassed. "I cannot do


that now, John," he answered. "I was a long time absent from my
post in the winter."
"The truth is, Alex," said Gowrie, frankly, "from all I hear, it seems
to me that it would be better if you were more frequently absent--
nay, if you were to give up this office altogether."

"What! and have they poisoned your mind, too, Gowrie?" cried
the other, impetuously. "I will not go; for by so doing I should only
confirm the falsehoods they have spread. I will not abandon my own
cause, or show a shame of my own conduct, whatever my friends
and relations may do."

"You speak too warmly, Alex," said the young earl. "Your relations
have no inclination to abandon your cause; and I trust and believe
you would never give them occasion to feel ashamed of your
conduct; but I only advise you for your own good. Suspicion is a
dangerous thing in the mind of a king, and, whether justly or
unjustly founded, is to be avoided by all reasonable means. Besides,
were your royal master and lady entirely out of the question, no man
has a right to furnish cause for dissension in any family."

"Oh, if I were out of the way, it would be some other to-morrow,"


answered the young man. "The king's suspicion must have some
object upon which to fix."

"I would have it any other object than yourself, Alex," replied his
brother. "However, I have given you my advice, and you may take it
or not, as you please."

"I shall certainly not withdraw from the court," replied Alexander
Ruthven, in an impatient tone. "I should consider that I was doing
wrong to the character of another whom I am bound to love and
respect. Therefore, to give me that advice, Gowrie, is but talking to
the winds, for in this case I am sure I am right."

"I much doubt it," replied the earl, and there dropped the subject,
for he saw that it would be of no avail to pursue it farther.
Beatrice had remained silent during this brief conversation
between the two brothers, with her eyes bent down on the ground
and her cheek somewhat pale, but the moment it was concluded,
she looked up, recurring at once to what had been passing before.

"I would offer to go with you, Gowrie," she said, "and cheer your
dear Julia in her solitude; but I think I may be more useful to you
both where I am; for, both on your account and on Alex's, my task
must be to watch narrowly everything that occurs, and give you the
first intimation of danger. Whether Alex will receive a warning I do
not know; but you, Gowrie, I am sure, will listen to the very first hint
that I give you. I may not be able to speak plainly. I may be obliged
to write but a few words; but watch and understand, my dear
brother, and if I say, fly, then lose not a moment."

"Why should you suppose I will not attend to your warning,


Beatrice?" asked her brother Alexander, with the irritability of one
who knows that others think him in the wrong, and who is not quite
sure himself that he is in the right.

"How can I suppose you will take a warning," asked his sister,
"when you will take no advice?"

"Because a warning refers to a matter of fact, advice to a matter


of opinion," answered the young man.

"Well, well," answered Beatrice, "do not let us dispute, Alex. I


think, with Gowrie, it would be much better for you to go; but you
may be sure, Alex, that if ever I tell you you are in actual peril,
which I can foresee will be the case some day, I do not speak
without perfect certainty. And now good bye, Gowrie. We must not
be too long away, otherwise the king will think that we are plotting
together."

"You see he suspects every one as well as me," said her young
brother, determined to make out a case in his own favour; "and I am
sure Gowrie is as little a favourite as I am myself. Besides, I do
believe from his conduct yesterday, that James is now convinced his
previous suspicions were unjust, and that he desires to make
atonement."

"Pooh, pooh!" answered Beatrice, tossing her head with a


somewhat scornful smile. "The king never made atonement to any
one. The king always thinks he is right, and has been ever right, and
will be right to the end of his life. He never dreams for a moment
that he can have been wrong, though he may take means to lull the
objects of his dislike or his doubts till they are wholly in his power.--
But now come, Alex, do not let us pursue this subject any farther,
but return quietly to the palace."

Then bidding her elder brother adieu, the lady left him, and,
accompanied by Alexander, walked back almost in silence to
Holyrood; for she herself was full of doubts and anxieties, and
Alexander Ruthven was in that state of irritation which is often
produced, especially in a young mind, by a conflict between a wish
to do right and strong temptations to do wrong.

I need not pause to detail the passing of the day with Gowrie.
The law's delay is proverbial as one of the banes of human existence
in the blessed land wherein we live.--It was so even in his time; and
he found, on consulting with those who had to deal with such
matters, that the drawing up of the renunciation, simple as it
seemed, would require the labour and attention of several days, in
order to couch it in the full and ample terms which he knew would
be required by the king. He had to give long explanations, and to
enter into details which he had not previously considered, so that
the greater part of a spring day was consumed before he left the
dim and dingy den where the man of law held his abode. On his
return to his own house he passed more than an hour in walking up
and down the large and handsome sitting-room, and meditating over
the past and the future. If it be asked whether his thoughts were
sad or bright, I must answer, very much mixed, as is ever the case
with a man of strong sense and active imagination. But Gowrie, it
must be remembered, was in the spring of life, in that bright season
when the song of the wild bird, hope, is the most loud and sweet
and seducing. The circumstances which surrounded him might alarm
or sadden him for the time, but the cheering voice still spoke up in
his heart, and the syren sang not in vain. At length he ordered lights
to be brought, and casting himself into a chair, took up a book--his
favourite Sallust--and began to read. The pages opened at the
Catiline, and the first words struck him, as strangely applicable to
the half-formed resolution which had been floating vaguely in his
mind, of passing life in peaceful retirement.

"Omnis homines, qui sese student præstare ceteris animalibus,


summa ope niti decet vitam silentio ne transeant, veluti pecora, quæ
natura prona, atque ventri obedientia, finxit."

"And yet," he said, "methinks many a man can raise himself


above the brute without mingling in the busy turmoil of the world's
affairs--nay, do more real service to his country and his race in the
silence of deep but peaceful thought than in the noisy contests of
courts and cities."

Then he went on to read, till he came to the splendid description


of Catiline.--"Lucius Catilina, nobili genere natus, magna vi et animi
et corporis, sed ingenio malo provoque," &c.

"What a picture of wickedness," he thought, as he read on; "ay,


and what a picture of the state of Rome under the republic, when it
was possible to say of any one man's life, 'Huic, ab adolescentia
bella intestina, cædes, rapinæ, discordia civilis, grata fuere; ibique
juventutem suam exercuit.' Is this the fruit of free and democratic
institutions?" he thought. "Is a state so nearly approaching to
anarchy, the result of popular government? A despotism were better!
But yet it cannot be so. There must be a mean between the licence
which destroys and the authority which oppresses society, when the
people have sufficient power to guard and support their liberties,
and the magistrates of the land are armed with the means of
checking lawless violence without trenching upon lawful freedom. I
am not a free man if there be others in the land who have the power
to injure me unpunished: my freedom is as much controlled by them
as it could be by any king. It is laws which make real freedom, laws
justly framed and firmly executed, laws above kings and subjects
both.--But let me see what he says more."

He had not time, however, to turn the pages of the book before
the door quietly opened behind him, and a step was heard upon the
floor. He did not turn his head, however; and the person who came
in proceeded round the table to the opposite side of the fireplace,
when Gowrie, suddenly looking up, beheld his servant, Austin Jute.

"Why, how now, Austin?" he exclaimed. "What has brought you to


Edinburgh? Has anything happened?"

"Nothing to my lady, sir," replied the Englishman, comprehending


very well that his sudden appearance might alarm the earl for Julia's
safety, "but a good deal to myself; and I thought it much better to
come and tell you, my lord, rather than go back to my duty, for
nobody can tell how much what happens to one man may do for
another. I'm not in Edinburgh by my own good will, you may easily
believe, for you told me to stay, and I would have stayed; but
necessity has no law, and what can't be cured must be endured. If
other legs run away with me, my legs aren't in fault, and might
makes right, as people say.--Well, my lord, I'm going on. I came
against my will, as I shall set forth presently. The way was this: it is
just four days ago that we saw three or four men riding in that long
dark valley to the north west, and old Mac Duff, your baron bailie,
was thinking to go forth and see what they were about; but knowing
very well that if he were taken and the place attacked, I could not
command the men, or, at all events, that they would not obey, which
comes pretty near to the same thing, I rode out alone to
reconnoitre. I did not think I could be so easily taken in, but this is a
devil of a country, my lord, for such matters. I looked sharp enough
round, as I thought, all the way I went; but it was impossible to go
in and out amongst all the rocks and big stones, and I still caught
sight of the men I had seen from the tower. When I came within
about half a mile of them, they turned round and began to ride
away, as if they were afraid of being caught, and thinking they had
only been upon some marauding expedition with which I had
nothing to do, I did not ride after them more than a couple of
hundred yards; but when I turned to go home again, I saw five men
on foot blocking up the road behind me. I made a dash at them,
thinking to get through, but they were too much for me, my lord,
and they soon had my horse by the bridle, commanding me to
surrender in the king's name. I asked for their warrant, but they only
laughed at me; and the other men on horseback coming up, they
tied my feet under the saddle, and my hands behind my back. The
horsemen rode with me, but the men on foot disappeared."

"Did they go towards the castle?" demanded Gowrie, with some


anxiety. "What men did you leave behind?"

"Oh, the castle is safe enough, my lord," answered Austin Jute.


"There were fifteen men in all in it; and when I went away I said,
'Safe bind, safe find, Mr. MacDuff. Pull up the drawbridge as soon as
I'm out; and if I'm not back in half an hour, send out for some of
your friends round about.' He'd soon have enough to help him; and
there was plenty of provision in the place, besides the beacon on the
top of the turret, which would bring more in a few hours; but they
wanted nothing at the castle, though no doubt they'd have taken my
lady if they could have caught her. That I found out by what I
overheard as they brought me here."

"And what happened to you here?" demanded the earl.

"Why, first they carried me up to a place called the castle, my


lord," answered Austin Jute, "where I was crammed into a dark, cold
hole, and had nothing given me to eat but nasty stuff made of
oatmeal and water; but, at the end of some hours, they took me
down to what they called the abbey, where I was not so well off as

You might also like