Quantum Computing by Practice: Python Programming in the Cloud with Qiskit and IBM-Q Vladimir Silva instant download
Quantum Computing by Practice: Python Programming in the Cloud with Qiskit and IBM-Q Vladimir Silva instant download
or textbooks at https://ebookmass.com
https://ebookmass.com/product/quantum-computing-by-practice-
python-programming-in-the-cloud-with-qiskit-and-ibm-q-
vladimir-silva/
https://ebookmass.com/product/nuclear-electronics-with-quantum-
cryogenic-detectors-vladimir-polushkin/
https://ebookmass.com/product/introduction-to-computing-and-
programming-in-python-global-edition-mark-j-guzdial/
https://ebookmass.com/product/python-programming-and-sql-10-books-
in-1-supercharge-your-career-with-python-programming-and-sql-andrew-
reed/
Learning Scientific Programming with Python Hill
https://ebookmass.com/product/learning-scientific-programming-with-
python-hill/
https://ebookmass.com/product/cloud-computing-theory-and-practice-3rd-
edition-dan-c-marinescu/
https://ebookmass.com/product/mastering-functional-programming-with-
python-brett-neutreon/
https://ebookmass.com/product/programming-and-problem-solving-with-
python-ashok-namdev-kamthane/
https://ebookmass.com/product/etextbook-978-0134379760-the-practice-
of-computing-using-python-3rd-edition/
Vladimir Silva
This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in
any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.
The publisher, the authors, and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.
(1.1)
where
c = speed of light (299792458 m/s)
KB, the Boltzmann constant = 1.38064852 × 10-23 m2 kg s-2 K-1
λ = wavelength
T = temperature in Kelvin degrees
(1.1)
(1.2)
Figure 1-3 A fresh idea on the photoelectric effect earned Einstein the Nobel Prize
in Physics in 1921
Copenhagen Interpretation
This is the earliest consensus about the meaning of quantum
mechanics, and was born out of the golden age of physics with
contributions from Max Planck, Niels Bohr, Werner Heisenberg, and
others in Copenhagen during the 1920s.
Figure 1-5 Schrö dinger wave function ѱ is the cornerstone of quantum mechanics
Figure 1-7 The Dirac equation was the first attempt to inject relativistic space-time
in the context of quantum mechanics
Dirac’s intentions of treating the atom in a manner consistent with
relativity had a profound effect in the structure of matter. His
equation introduced two new mathematical objects which now are
fundamental in physics and quantum field theory:
ak and β: These are 4x4 matrices closely related to Pauli’s matrices.
Remembering Pauli’s exclusion principle, it introduced a new
quantum number to explain electron shell clusters using a 2x2
matrix that was later known as electron spin (or spinor). In the
same line, Dirac’s matrices are called bispinors.
A four-component wave function ѱ: It has four components
because its evaluation at any given point is a bispinor. Physically, it
is interpreted as the superposition of a spin-up electron, spin-
down electron, spin-up positron, and spin-down positron. Note
that Dirac’s four-component wave function differs from Pauli’s
two-component wave function and Schrö dinger’s wave function
for a single complex value.
Hole theory: Dirac’s equation has solutions with negative energies.
To cope with this fact, Dirac introduced the hypothesis of Hole theory.
This theory postulates that the vacuum is a many body quantum
state where all the negative energy electron eigenstates are occupied.
This description came to be known as the Dirac sea. Furthermore,
since Pauli’s exclusion principle forbids two electrons from
occupying the same quantum state, additional electrons will be
forced to occupy a positive eigenstate with positive-energy electrons
forbidden from decaying into negative-energy eigenstates. Dirac
reasoned that there may be unoccupied negative-energy eigenstates
in this sea which he called holes reasoning that they behave like
positively charged particles because positive energy is required to
create a particle-hole pair from the vacuum. He initially thought that
the hole may be the proton; however, it was pointed out later that the
hole should have the same mass as the electron; thus, it could not be
the proton as it is around 1800 times as massive as the electron. This
hole was later identified as the positron which was discovered
experimentally by American physicist Carl Anderson in 1932!
“But we are having a good time!” put in Ruth. It was evident that
she was not in the least remorseful over her mistake.
“But we’ll have to camp here,” answered the captain, sharply. “And
if you knew of what is awaiting you at Silvertown, you wouldn’t want
to lose a single minute more than necessary.”
THE ACCIDENT
It was evening—of the second day of their trip and the scouts
were seated about their camp fire, enjoying the leisure after the
day’s activities. The flame lighted up the immediate circle, and the
tents just beyond; but by way of contrast, it seemed to make the
blackness of the woods and the water still deeper.
“We want to stay just where we are!” replied Marjorie, who was
comfortably leaning against Lily’s back for support.
None of the others had seen the play, and they asked her several
questions about the story.
“It would take an Edith Evans to tell that story well,” sighed Lily;
“it certainly was a pretty one.”
“To win the silver cup at the races, I guess,” put in Ruth. “I’m sure
that’s my greatest desire at present.” Then, becoming very practical,
she added, “Now please tell us all about it, Captain Phillips.”
“Well, I haven’t worked out the exact program,” replied Miss
Phillips; “but I can tell you most of the things it will include.”
“With the same two girls together, just as we are now?” asked
Alice Endicott.
“No—one girl to a canoe, for this event. You can’t very well sit
down when you want to paddle fast—you kneel somewhere in the
middle of the canoe. So, if we can’t hire canoes there, we will have
two races, and then let the winner of each compete.”
“Then there will be another event when there are two girls in each
canoe, and perhaps a relay race. And finally, there will be a
Capsized-canoe Competition. Someone will take the canoe to the
middle of the lake and upset it. As soon as the contestant sees this
take place, she is to kick off her shoes and dive into the lake, right
the canoe, bale the water out, and bring it safely—with its first
occupant in it—to shore. This is undoubtedly the most difficult feat
of all.”
“But how will you decide who has won the cup?” asked Ruth,
when Miss Phillips had finished her explanation.
Miss Phillips blushed. “There, now, I have said too much already.
Suppose we say nothing more about it. It’s time to go to bed,
anyway.”
The scouts did as the captain commanded, pausing only to put out
the fire. They reserved further discussion of the subject of the
matter until they were by themselves.
Early the next morning they were in their canoes again, ready to
start off. This time Miss Phillips kept her map in view so that there
could be no chance of a mistake; and she designated Frances Wright
and Ethel Todd—the two oldest girls in the troop—to take the lead.
For the next few days they progressed steadily onward. Always on
the water by nine o’clock, and pausing only an hour for lunch, they
continued until four; then with the aid of the map, Miss Phillips
watched for the best camping place.
All had gone well thus far; and by Saturday morning they were
practically on schedule time.
“Have you ever been over this stream before, Captain?” asked
Marjorie, as the canoes set off from the shore together.
“Well, then how did you know all about making the map, and the
best sites for our camps, and——?”
“And don’t forget what awaits at the other end,” put in Ruth, with
a tone of joyous anticipation.
“Except for the water meet!” sighed Doris. “Do you know, Captain
Phillips, the idea of our racing and doing all those stunts sort of
scares me—before all those strange people, I mean. Do we all have
to take part?”
The canoes were forced to go in single file now, for the stream
had become very narrow. Miss Phillips and Frieda took the lead, the
former watching cautiously for rapids; for it was somewhere near
here, she thought, that a portage would be necessary. Ruth and Lily
in the Water-Witch were the last in the trail.
“I honestly don’t think it’s fair about Marj!” repeated the former, in
discontent.
“Why, Ruth, of course it is! Marj isn’t any professional, like you
make her out to be! What don’t you consider fair about it?”
“Just this. I think the whole idea of a canoe meet is not Miss
Phillips’s, but Marj’s. Why should the captain have chosen the thing
Marjorie Wilkinson is most proficient in? You can’t tell me! It’s
because Marj paws around her, and makes her do just as she likes!”
“Ruth Henry!” cried Lily, furious at the slur against her best friend.
“Are you serious?”
“Yes, I am, Lil. You’re blinded by her; Marj can do anything with
you that she likes, and you think she’s wonderful. But other people
don’t think so! She’s not half good enough for you, I tell you.” Ruth
lowered her voice and spoke slowly in the hope that her words of
flattery might make a deep impression upon the other. “You’re the
most popular girl in our class, Lily Andrews, and everybody knows it.
But if you don’t pay any attention to anybody except Marj, you’ll lose
all your friends!”
“Now I think it’s all very well to have tests like this Sailor’s test, as
a regular part of scouting,” continued Ruth; “but when it comes to a
big meet, which all Silvertown will witness, I don’t think it’s quite fair
to select canoeing. Why shouldn’t Miss Phillips have chosen tennis?
We’ve never had a tennis tournament.”
“Well, I don’t know, but I wish you’d help me this once. You know
Miss Phillips hates me—” Ruth laughed carelessly, as if the fact did
not cause her any unhappiness—“but she likes you, Lil. So you
suggest a tennis match instead. Won’t you please, Lil?”
“Lil, oh! Lil! Where are you?” called Ruth, as soon as her head
came to the surface.
“Here!” sputtered Lily, her nose and mouth filled with water by the
violent ducking. Then a series of violent chokes on her part
prevented all hope of replying.
“Oh, where can the others be?” cried Ruth, grasping at the canoe
in despair, and looking wildly about for help. But she saw no signs of
the other girls; the Water-Witch had evidently been progressing
more slowly than they had either of them realized.
“Lil, we’ve got to get our stuff—or it will sink so that we can’t find
it!”
“Oh! Oh! What shall we do!” wailed Lily, now able to speak. “Marj!
Marj!” she screamed helplessly.
By this time the rest of the party had run along the shore,
reaching the scene just as Lily, with drenched clothing and streaming
hair, climbed out of the water. Meanwhile Marjorie continued to fish
for the lost articles.
“We’re safe now. Pull her up, Lil!” called Ruth. “Hello, everybody!
Weren’t we crazy, though?”
“It’s a swift part of the stream, and there are lots of sharp rocks,”
explained Miss Phillips, after the scouts had pulled the canoe upon
the bank and dumped out the water. “It is near here where we make
our portage.”
“Oh, no wonder! Well, Marj—” Ruth watched the other girl direct
her canoe to the shore—“did you find everything?”
She looked around anxiously, but the banks on either side of the
stream were sharply and thickly covered with trees. Suddenly she
realized how still everything was; not a leaf was stirring, not a bird
was singing. The girls, too, were absolutely quiet, as if awed by
some approaching calamity. She glanced nervously at the sky; the
sun was still shining brightly, but a glistening white cloud was rapidly
rising out of the east, and increasing in size as it advanced higher
into the heavens. A moment later, the sun was temporarily obscured.
A distant rumble was heard. There was no doubt about it now; a
heavy thunderstorm was approaching.
“We’ll never get dry!” said Lily, dolefully. “Oh, Ruth, aren’t you
getting sort of cold? And with nothing but wet sweaters to put on
——”
“Here’s mine!” offered Alice, handing her sweater to Lily. “And I’ll
get Flo’s for you, Ruth.”
When Marjorie unbarred the bolt of the heavy wooden door, the
first big drops of rain were falling from the black cloud overhead.
The rusty hinges creaked, and the door swung open, revealing an
empty interior of huge proportions. The divisions of the stalls were
still standing, and the floor of the loft was covered with straw.
Although the place was deserted, everything was neat and clean.
“I’m just as glad we don’t have to share our quarters with horses,”
said Alice.
“Let’s hope nobody puts us out,” said Miss Phillips. “As soon as the
storm is over, I’ll go and see if the house to which this belongs is
occupied, for it would seem to me to be wiser to stay here all night
than to pitch tents on wet ground. And especially on Lily’s and Ruth’s
account.”
“Well, suppose you select that stall over there as your boudoir, and
put on dry clothing. If your own bloomers and middies are wet,
borrow somebody else’s. And a good rub with a Turkish towel
wouldn’t hurt.”
The rest of the scouts climbed to the loft, and seated themselves
on some straw near a window, so that they might watch the storm.
Great claps of thunder followed sharp flashes of lightning, but the
girls did not seem the least afraid. Indeed, several of them were
sorry when the storm gave indication of subsiding.
“Yes,” replied the captain; “if we notice which side the wind is
blowing from, and make it so the sparks blow away from the barn,
and not towards it.”
“Oh, here are some dry twigs and a few logs!” said Marjorie, who
had descended the ladder again, and was making a tour of
exploration. “Just the thing for a fire.”
The rain had entirely ceased now, and the sun was shining again.
Marjorie and Alice offered to make the fire while Frieda prepared the
supper. Ruth and Lily spent their time rigging up a place to hang
their wet clothing, and Florence and Miss Phillips went in search of
water.
The fire had been blazing brightly for several minutes when a
gruff, loud voice suddenly startled the girls from their pleasant
conversation.
“Oh, you did, eh? Well, suppose you put it right out again!”
“Please don’t put us out!” she pleaded. “We’re Girl Scouts, and we
give you our word of honor——”
At her words and her tone, the old man’s anger subsided; she
seemed so like a child, asking him for shelter and protection. No one
could resist Doris Sands for any length of time.
“And I’ll see that the fire is entirely put out,” concluded Miss
Phillips, as the man turned to go.
“Oh, country people are always nice,” said Doris; “if you only
understand them right.”
“I don’t think it’s a farm at all,” replied the captain. “I think these
old people live here by themselves, and probably raise a little garden
for their own use. But if it were really a farm, this barn wouldn’t be
empty like this.”
The old people proved to be living just such a life as Miss Phillips
had surmised. Kindly, hospitable, and simple-hearted, they made
their guests quite at home and the girls enjoyed their evening, and
the day that followed. For it was Sunday, and the old couple insisted
that the girls accompany them to the country church and remain
with them for dinner.
It was nearly three o’clock when the scouts made their adieux,
and returned to seek their canoes, for Miss Phillips had decided that
they would make the portage before setting up camp for the night.
“And now for the heavy work!” said Lily, tucking her luggage into
the Water-Witch.
“There are two parts to this test: the first is a general test for
everyone who aspires to proficiency in water sports, and the second
part gives you a choice—in showing your ability to manage a row-
boat, a sail-boat, a canoe, or a motorboat. We shall of course all
select the canoe.”
“Oh, that part is easy,” said Miss Phillips; “I can tell you things like
that. It’s practical demonstrations that I’m afraid of. With the
exception of Alice, you can all swim twenty-five yards with your
clothing on——”
“Does that mean that I’m out of it?” cried the girl, in
disappointment. “Why, I can paddle as well as the rest of the girls!”
“You may qualify for everything else except the swimming, and
then do that on Silver Lake,” said the captain. “Now, to continue—of
course everybody knows the sixteen points of the compass and how
to find the four directions from the sun or stars.”
“Oh, Alice, of course you do!” Miss Phillips’s voice sounded a trifle
provoked. “Where does the sun rise, and how do you find the North
star?”
“Now see whether you can answer these questions. If you were
on a river at night, what color lights would you carry, and on which
side?”
“You show the red light on the port or left side and a green light
on the starboard or right side,” the captain informed them. “And
these lights should show only towards the front and sides. In order
to tell which way a boat is heading they carry a low white light on
the bow which shines straight ahead, and another white light higher
up in the stern which shows on all four sides. If you see a green
light on the left and a red one on the right, with two white lights in
the centre, one above the other, you will know that the boat is
heading towards you. If you are coming up behind it, you will see
only the white stern light.”
“Which side do they pass on?” asked Lily. “Do they observe traffic
rules, like automobiles, and pass to the right?”
“Whenever possible. But if your course should lie to the left you
could signal two blasts of the whistle, which would mean that you
were going to the left. One whistle means to the right. The first boat
which signals is the one which lays the course to be followed, and
the other boat should always answer with the same signal to show
that they understand. If you don’t understand the signals, then blow
four short blasts, which means danger, and the signals can be given
and returned over again.
“Well, we’ve had one storm; let’s hope that we won’t have
another,” said Doris.
“Still, that didn’t hurt us much,” said Miss Phillips. “Listen,” she
continued, “here’s a good one for Ruth and Lily: Why is it dangerous
to move about or stand in a canoe?”
“They must use their arms and hands like foreigners do when they
talk!” said Ethel. “Maybe they stamped their feet for emphasis!”
“We didn’t either!” denied Ruth. “We struck a rock, and that was
all there was to it!” she concluded.
“But we’re just at the interesting part now,” said Miss Phillips. “I
mean about the canoe. And I thought if we discussed all the
questions now, we could take the written part of the test right after
supper.”
Lily Andrew was the first to hand her paper to Miss Phillips, who
was in her own tent. Much as she hated to solicit favors, or to seem
to dictate to her superior officer, she decided that she must do as
Ruth had asked, for a promise is a promise, no matter to whom or
under what circumstances it is made.
“Miss Phillips,” she began, “some of the girls would like to have a
tennis match—er—instead of a canoe meet. They think—that—that
——”
“That it is sort of having two prizes for the same thing. I mean the
merit badge, and the cup, too!”
The next morning was spent in practicing with their canoes. They
tried landing them, pushing them off, upsetting them, and righting
them again, until, at eleven o’clock, Miss Phillips blew the whistle as
a signal to begin the test.
“I’ll take Frieda first,” she said, “so that she can get dinner.”
Frieda, Ruth, Marjorie, Ethel, and Frances all tried the practical
part of the test and, to all appearances, were successful. Miss
Phillips refused, however, to tell them the results until that evening.
Soon after the noon meal, their things were packed again, and
they paddled all afternoon. At five o’clock they reached their
campsite.
“I do hope you aren’t going to be too tired for the scout meeting,
this evening,” said Miss Phillips. “For I have a surprise for you.
Something you will like!”
Three hours later, when the tired girls gathered around the camp
fire, their faces were alight with anticipation. They enjoyed going
over the brief, familiar ceremony at the opening; it gave them a new
thrill to repeat the pledge, the laws, and the motto, and to sing the
Star-Spangled Banner.
Miss Phillips gave a formal report of the money spent, and Frieda
told what supplies she had on hand. Having dismissed the business,
the captain reached into her pocket, and drew out a white envelope.
“Five Girl Scouts have passed the Sailor test, and are to receive
merit-badges. I have the pleasure to present these badges tonight.
Will the following girls please come forward: Marjorie Wilkinson,
Frieda Hammer, Ruth Henry, Ethel Todd, and Frances Wright? The
girls all did creditably, ranking in the order in which I have named
them.”
It had never occurred to any of the girls that they might actually
receive their merit badges on the trip, and the surprise was
delightful. For every Girl Scout knows what a thrill it brings to sew
an additional badge on the sleeve of her uniform, particularly when
there are not many there already.
ADVENTURE ON AN ISLAND
“Our next camping spot,” said Miss Phillips as the party started out
the next morning, “will be an island. Keep watch for it, on the right,
I think, for I am not quite sure of its location.”
“A big island?” inquired Ruth. She had studied the map in detail,
but she did not remember any large islands, or indeed any place
where the stream would be wide enough to contain such a
formation.
“Not very large,” replied Miss Phillips. “But plenty big enough for
our camp. There is a stream branching out somewheres to the right,
which joins this again farther on, and in the middle is an island
about a quarter of a mile long, with lots of shade trees. A very
attractive spot, I believe.”
“Yes; summer before last. And I believe a few other boys besides
scouts went, too; so perhaps your brother was among them.”
Ruth Henry was the first to finish eating. Jumping to her feet, she
hurried down the bank to where her canoe lay and rummaged for
her field-glasses.
But although she looked carefully, and several of the others made
attempts also, they could not distinguish anything which resembled
an island. This was not strange, for it was necessary for them to
paddle for three hours longer before they finally sighted it.
The small island, not much wider than a city square, appeared
most attractive with its shady trees, and sandy sloping shores. The
girls put more energy into their strokes, that they might reach it
more quickly. Marjorie was the first to pull her canoe to shore.
“We’ll make it a game,” said Miss Phillips, when all the girls were
out of their canoes, “to see who can find the most traces of
civilization.”
The girls discovered a little path leading towards the centre of the
island, and followed it. After about two minutes’ walk they found
themselves in a clearing, and Ruth discovered the remains of a fire.
“This is the camping spot, anyway,” said the captain; “so now
suppose we go back for our supplies.”
“No, but it’s a lovely place to be,” put in Marjorie. “Why do you
always want excitement, Ruth?”
“Then see that you don’t cause any more delays,” said Miss
Phillips, rather sharply. She had not forgiven Ruth for what she still
considered a premeditated mistake in losing the way.
Ruth said nothing, but closed her lips tightly. She was very angry
with Miss Phillips, and wished that she might do something to annoy
her. She decided to think up a plan of action.
“If you put the tents up quickly,” said the captain, “there ought to
be time for a swim before supper. How about it, Frieda?”
“All right—if you don’t stay too long. Please be here on the dot of
six,” she warned them, “not a minute later. We’re going to have
corn-fritters and maple syrup for supper!”
A few minutes later, all of the girls except Frieda and the captain
had disappeared, clad in their bathing suits, through the trees that
hid the water from the encampment. They skipped along as fast as
they could, watching out to avoid the sharp rocks which might hurt
their tender feet. One after another they reached the shore, and,
plunging into the water, struck out for the deepest part.
“I’ll race you across the stream, Marj!” challenged Ruth, anxious
for adventure.
“I believe I’ll go too,” said Ethel; and Lily and Doris joined the
party.
“All right; then I’m going. But don’t wait too long!”
But when the rest of the girls gathered around the fire to enjoy
Frieda’s delicious corn fritters, neither of the girls had appeared.
They were almost through with supper, when Ruth, dripping wet,
emerged from among the trees.
“Hurry, Ruth,” she said, “if you want any supper. It’s selfish to
keep Frieda waiting!”
Ruth disappeared into her tent with a pout on her face. Always
Frieda, or Marjorie, or somebody else that the captain seemed to be
concerned about—anybody but her! Then she smiled at the little
secret trick she had played upon them. Miss Phillips was too cock-
sure of herself; she never had anyone cross her! Well, perhaps in
the morning she would find something to her distaste!
“No,” said Miss Phillips; “I think we will all stay here tonight; it will
be safer. And we can have a little stunt night like the one we had
that time at camp.”
But she did not get up immediately; she lay still, contemplating
the very agreeable adventure which was about to take place. As
soon as she heard the others stir, she too began to dress.
As the girls left their tent, they heard their officer’s voice.
“So will I,” chimed in Marjorie, joining the other girl and running
with her towards the water.
Forgetting all about their pails of water, they ran as fast as they
could back to the camp, and shouted their news as soon as they
were within hearing distance. For they felt that not a moment was to
be lost.
Frieda dropped the pan of biscuits she was carrying, and Miss
Phillips looked at the girls as if she thought them crazy. And then the
scouts began to ask them breathless, excited questions.
“But how do you suppose they got away?” asked Ruth. “Could
thieves——?”
“No,” said Miss Phillips; “it is all my fault for not insisting upon
tying them in some way. Evidently the stream has a slight tide, like a
miniature ocean, and they have simply been washed out and down
stream. Yet, I was sure we had pulled them up far enough upon the
banks. But the current is not so very fast; perhaps we can catch
them.”
“Oh, Captain, I could never do that! Oh, what shall we do?” wailed
Alice, helplessly.
“First of all, obey your scout law: A Girl Scout is cheerful. Next, eat
your breakfast that Frieda has prepared for you. And that reminds
me, where is the water, Marjorie?”
The girl started guiltily. “We forgot it!” she admitted. “But we’ll go
back.”
The warm, wholesome food revived the scouts’ spirits, and they
discussed the proposition more hopefully.
“Well, we’ll each do something,” said the captain. “As soon as your
breakfast is digested, we’ll organize into squads. Let me see——”
“But why don’t you take Marjorie with you too?” asked Ruth,
obviously dissatisfied with the plans. “She’s a better swimmer than I
am!”
“I have placed you, Ruth; and you are all to obey my orders. They
are final!”
ebookmasss.com