Download Complete Physics with Excel and Python: Using the Same Data Structure Volume I: Basics, Exercises and Tasks Dieter Mergel PDF for All Chapters
Download Complete Physics with Excel and Python: Using the Same Data Structure Volume I: Basics, Exercises and Tasks Dieter Mergel PDF for All Chapters
com
https://ebookmeta.com/product/physics-with-excel-and-python-
using-the-same-data-structure-volume-i-basics-exercises-and-
tasks-dieter-mergel/
OR CLICK HERE
DOWLOAD NOW
https://ebookmeta.com/product/primary-mathematics-3a-hoerst/
ebookmeta.com
https://ebookmeta.com/product/physics-
galaxy-2020-21-vol-3a-electrostatics-current-electricity-2e-2021st-
edition-ashish-arora/
ebookmeta.com
https://ebookmeta.com/product/essentials-of-excel-vba-python-and-r-
volume-i-financial-statistics-and-portfolio-analysis-lee/
ebookmeta.com
https://ebookmeta.com/product/passions-of-the-tongue-language-
devotion-in-tamil-india-1891-1970-sumathi-ramaswamy/
ebookmeta.com
Jewish Culture between Canon and Heresy 1st Edition David
Biale
https://ebookmeta.com/product/jewish-culture-between-canon-and-
heresy-1st-edition-david-biale/
ebookmeta.com
https://ebookmeta.com/product/omega-protocol-atlantic-island-3-1st-
edition-fredric-shernoff/
ebookmeta.com
https://ebookmeta.com/product/temporary-migrants-from-southeast-asia-
in-australia-pietsch/
ebookmeta.com
https://ebookmeta.com/product/generations-1st-edition-bobby-duffy/
ebookmeta.com
https://ebookmeta.com/product/paddling-alaska-kayak-canoe-paddleboard-
and-raft-the-greatest-fresh-waters-in-the-state-2nd-edition-dan-
maclean/
ebookmeta.com
Czech Republic The Essential Guide to Customs Culture 2nd
Edition Kevan Vogler
https://ebookmeta.com/product/czech-republic-the-essential-guide-to-
customs-culture-2nd-edition-kevan-vogler/
ebookmeta.com
Dieter Mergel
Based on the German language edition: Physik mit Excel und Visual Basic by Dieter Mergel,
© 2017 2017. Published by Springer-Spectrum. All Rights Reserved, and extended with Python solutions.
© Springer Nature Switzerland AG 2022
This work is subject to copyright. All rights are reserved 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 use of general descriptive names, registered names, trademarks, service marks, etc. in this publication
does not imply, even in the absence of a specific statement, that such names are exempt from the relevant
protective laws and regulations and therefore free for general use.
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.
This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
Preface
1 Dieter Mergel, Physik mit Excel und Visual Basic Grundlagen, Beispiele und Aufgaben, Springer
Spektrum (2017), https://doi.org/10.1007/978-3-642-37857-7.
2 Dieter Mergel, Physik lernen mit Excel und Visual Basic, Anwendungen auf Teilchen, Wellen,
v
vi Preface
classes at the university and may also be a good start for students who later choose
to specialize in computational physics.
Our approach is intended to make the student fit for a computer-oriented world,
be it for spreadsheet calculations in business, scientific computing in research, or
mathematics and physics teaching in high school. We take into account that not all
students have the same attitude towards programming; some have to be encouraged
to venture into a new world, whereas others have to be cautioned not to rush into
blind programming.
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 A Two-Track Didactical Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 What Can You Expect? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 What Do You Need? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Tim, Alac, and Mag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5 Didactic Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.6 Subject Matter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.7 Getting Started with Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.7.1 Start Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.7.2 Spreadsheet Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.8 Getting Started with Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.9 Skills to Be Trained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2 Data Structures, Excel and Python Basics . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.1 Introduction: Named Ranges in Excel, Arrays in Numpy . . . . . . . 15
2.2 Characteristics of a Parabola . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2.1 Different Definitions of a Parabola . . . . . . . . . . . . . . . . . . . . 17
2.2.2 Data Structure and Nomenclature . . . . . . . . . . . . . . . . . . . . . 19
2.3 Basic Exercise in Spreadsheet Calculation . . . . . . . . . . . . . . . . . . . . . 19
2.3.1 Cell Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.3.2 Graphical Representation of a Function . . . . . . . . . . . . . . . 22
2.3.3 Smart Legends in Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3.4 Scroll Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3.5 Summary: Cell References and Name Manager . . . . . . . 26
2.3.6 What Have We Learned so Far, and How
to Proceed Further? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.3.7 Python Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.4 Python and NumPy Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.4.1 Basic Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.4.2 Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.4.3 Python Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.4.4 Numpy Constructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
vii
viii Contents
9.6.2
Data Structure and Nomenclature . . . . . . . . . . . . . . . . . . . . . 393
9.6.3
Spreadsheet Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
9.6.4
Python, Internally and Externally Consistent Error
of the Combined Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
9.7 Propagation of Standard Deviations . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
9.7.1 Rules for Propagation of Standard Deviations . . . . . . . . . 397
9.7.2 Data Structure and Nomenclature . . . . . . . . . . . . . . . . . . . . . 402
9.7.3 Spreadsheet Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
9.7.4 Python Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
9.8 Propagation of Confidence Intervals . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
9.8.1 From Variance to Confidence . . . . . . . . . . . . . . . . . . . . . . . . . 407
9.8.2 Sum and Product of Two Measurands . . . . . . . . . . . . . . . . . 408
9.9 Mass of a Thin Film on a Glass Substrate . . . . . . . . . . . . . . . . . . . . . 409
9.9.1 Instructions for Use for Accurate Measurements
and Their Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
9.9.2 Data Structure and Nomenclature . . . . . . . . . . . . . . . . . . . . . 413
9.9.3 Spreadsheet Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
9.9.4 Python Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
9.10 Questions and Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
10 Fitting Trend Curves to Data Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
10.1 Introduction: Linear and Nonlinear Regression . . . . . . . . . . . . . . . . . 419
10.1.1 Straight Line Through Data Points by Sight . . . . . . . . . . . 419
10.1.2 Multilinear Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
10.1.3 Nonlinear Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
10.1.4 Coefficient of Determination R2 . . . . . . . . . . . . . . . . . . . . . . . 422
10.1.5 C-spec Error with Iterative t Adaptation . . . . . . . . . . . . . . . 423
10.2 Linear Trend Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
10.2.1 Creating Data Points and Evaluating Them . . . . . . . . . . . . 424
10.2.2 Data Structure and Nomenclature . . . . . . . . . . . . . . . . . . . . . 426
10.2.3 Spreadsheet Calculation with Linest . . . . . . . . . . . . . . . . . . . 426
10.2.4 Python Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
10.3 Fitting a Polynomial Trend Line to Data Points
with Multilinear Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
10.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
10.3.2 Data Structure and Nomenclature . . . . . . . . . . . . . . . . . . . . . 435
10.3.3 Spreadsheet Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
10.3.4 Python Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
10.4 Exponential Trend Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
10.4.1 Exponential and Logarithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
10.4.2 Exponential or Polynomial? . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
10.4.3 Data Structure and Nomenclature . . . . . . . . . . . . . . . . . . . . . 445
10.4.4 Python Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
10.4.5 Spreadsheet Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
Contents xv
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
About the Author
Dieter Mergel studied physics in Göttingen, obtained his doctorate at the Techni-
cal University of Clausthal in the field of solid-state physics, and worked 11 years
in the Philips Research Laboratories Hamburg/Aachen on automatic speech recog-
nition and optical data storage. Since 1993, he is Professor of Technical Physics
at the University of Duisburg-Essen. His professional activities include research
in the field of solid-state layers and lectures for students in teaching and medical
professions.
xvii
Introduction
1
History
The exercises in this book arise from a German textbook that emerged from courses
for prospective teachers and students of Technical Physics at the University of
Duisburg-Essen with the intention to prepare the students for a computerized world.
The participants in the courses had already been studying physics for at least one
year. However, the explanations of the exercises are so explicit that they should also
be suitable for beginners.
Said courses are based on excel and Visual Basic (VBA). The current English
version includes Python from the very beginning so as to make it more generally
useful for students who later choose to dive deeper into Scientific Computation.
Exercises
The subject matter is presented in nine chapters as a series of exercises. Every exercise
consists of three steps:
1. The physical concept is introduced with mathematical equations and diagrams.
2. An adequate data structure is set up independent of the implementation in a
particular programming platform, but taking care that the same nomenclature
can be used in both mathematical equations and programming. This serves as an
interface to any programming application.
3. Solutions in excel and Python are designed so that a solution in one application
can directly be translated into the other one.
To enable this approach, training in excel emphasizes vectorized code, matrix for-
mulas, and constructs that allow for broadcasting in the same way as Python.
Furthermore, programming VBA macros interacting with spreadsheets introduces
looping, logical queries, and functions.
– training to work with numpy arrays, list slicing and broadcasting in Python,
– working with similar constructs, vector structures, and matrix operations also
in excel,
– learning how to write programs with looping, logical queries, and functions in
Python and VBA for excel,
– training how to lay out spreadsheets clearly so that they are apt for simple
scientific computing,
– developing VBA macros that exchange data with spreadsheets,
– applying standard mathematical methods numerically.
After having successfully completed the exercises, you should have gained so
much self-confidence that you can answer the question “Programming practice?”
with an enthusiastic “Yes!”.
You will need a Physics textbook (anyone will do, e.g., the one you have at hand
during your studies anyway) and two more books on programming as indicated
below.
EXCEL
To work with excel, you only need a computer in which excel has been imple-
mented (any version; the exercises in this book have been checked in excel 2010
and excel 2019) and an introduction to excel (do not buy one before having done
the basic exercise in Sect. 2.3). In particular, you do not need a special development
environment for visual basic, because it is included in all versions of excel.
Python
You will need to install Anaconda, a free and open-source distribution of the Python
and R programming languages that also comprises the Jupyter Notebook by
default. The examples in this book were obtained with Python 3.7 in Jupyter.
You are advised to use both a book and internet courses to broaden your training
systematically. Make your choice after having gone through Exercises 2.4 and 2.5.
You will soon meet two types of students and a tutor who will accompany
us throughout this book. The character named Tim (which stands for “timidus”
or “timida”, meaning shy)) represents those students who are somewhat hesi-
tant, fearing that they may fall short of the requirements, although they study
hard. The character named Alac (which stands for “alacer”, meaning alacritous,
high-flying) is typical of those vehemently self-confident students (men are gen-
erally over-represented) who believe that they already have a superior overview
and do not have to deal with what they consider mere bits and pieces. Mag
(for Magister/Magistra, i.e., the tutor who runs the course) tries to engage with
both characters, encouraging Tim and cautioning Alac, and clarifying that both
approaches are valuable and that every Physics student should venture into the
Computer world.
4 1 Introduction
Tim I see how well some fellow students are juggling programming tools, but
I’d rather stand back. I prefer to learn the stuff from textbooks.
Mag This course is not intended to turn you into a computer nerd. You will not
learn any cool tricks. We restrict ourselves to some basic techniques that are prac-
ticed again and again. The computational techniques do not stand by themselves,
but are always taught in connection with physical problems.
Tim But I have often heard that programming is a black art for which you have
to be specially talented.
Mag Here, you will learn the most basic computer techniques that every
scientist, engineer, and science teacher must master to succeed in their profession.
Mag A master can be recognized by how he/she deals with errors. Any unno-
ticed error in spreadsheet formulas and programs can lead to disaster. It is essential
that you gain experience with data structures and programming constructs.
Mag Yes! By using data structures in spreadsheets and Python programs and
setting up graphical representations that are comprehensible, even when you look
at them after some time. And by developing simple procedures that control the
program flow.
Mag Let’s compare this course with learning a foreign language. How do you
learn foreign languages?
1.4 Tim, Alac, and Mag 5
Alac Learning? For foreign languages, academic learning is useless in the long
run. You simply have to go abroad; the rest follows by itself.
Tim Oh, I couldn’t learn like that. I couldn’t form a proper sentence in a for-
eign language without profound foreknowledge. I would have to learn the correct
grammar and vocabulary first before I would dare to speak.
A good balance
Mag We are trying to find a good balance. You will learn the most straightfor-
ward “sentence” structures, but will also be “sent abroad” right off, and you will
have to make your way there. If you pass this test, you can be confident of being
able to learn the more complex “grammar” if necessary.
Mag Don’t worry! Working through this book will make you fit for a computer-
oriented world, be it for spreadsheet calculations in business or scientific comput-
ing in research. This can be tedious, but it will be worthwhile, whether it be as
early as learning at school or working for a Bachelor’s or Master’s, or even as late
as working on a Ph.D. thesis.
Mag I think so. Anyway, this course is about physics and will help you to pass
your exams.
Workshop atmosphere
Having cleared up the doubts harbored by Tim and Alac, we now explain the didactic
concept of this book.
In the courses at the University of Duisburg-Essen on Physics with Excel and
visual basic, learning was mostly done in a workshop, such as in physics labs for
beginners. The students dealt with the tasks alone or in pairs while in a computer
lab, ideally also helping each other out across groups and consulting the supervisor
when needed. Students could continue to work on their tasks outside of attendance
time so that everyone could work according to their learning progress.
Experience shows that the students enjoy the tasks, and the learning progress is
fastest when all three aspects—programming, physics, and mathematics—are com-
bined. The systematic practice of various isolated spreadsheet and programming
techniques is often perceived as too dull. The combination of calculations and graphs,
realized in nearly all exercises in this book, proved to be particularly instructive.
6 1 Introduction
– a basic course for beginners, in which two tasks from each of the six Chaps. 2, 3,
4, 8, 9 and 10 were worked on and had to be presented to the supervisor;
– an advanced course with two tasks each from Chaps. 5, 6 and 7, and one task that
had not yet been worked on from the chapters of the beginner’s course. Sometimes,
two short exercises were combined into one task.
Broom rules
To many beginners, spreadsheet calculations and, especially, computer programming
seem like witchcraft. We like to address this idea by setting up “broom rules” that
the students hopefully will not forget so easily. Some examples: “ Half, half, full;
the halves count twice” (Runge–Kutta of the 4th order) or “ Mostly, not always.
(“fundamental rule” of statistical reasoning, no statement is 100% sure).
In addition, Mag puts stumbling blocks along the learning path, in talks with the
two student characters, Tim, who learns the material from the beginner’s course dili-
gently, and Alac, who does not hesitate to implement premature ad-hoc solutions. It
is important to emphasize that both attitudes have their advantages and shortcom-
ings, and neither student should feel denigrated. It is just that some students have
to be encouraged to venture into the programming world, whereas others have to be
cautioned against rushing too quickly into coding.
1.5 Didactic Concept 7
Exam questions
At the end of every chapter, a collection of rehearsals and tasks is presented, typically
requested in written and oral examinations.
simulated realistically to obtain data that can be evaluated. Our tools for simulation
are random numbers generated according to the desired distribution.
With linear regression, mathematical functions are fitted to sets of measured values
to get trend lines through data points (Chap. 10). Furthermore, an introduction to
the important technique of non-linear regression with solver functions will be given,
again, in both excel and Python.
Follow-up book A follow-up book, “Physics with Excel and Python, Using the
Same Data Structure. Applications”, is being prepared, dealing, in the same style,
with advanced topics, structured according to physical and mathematical aspects,
such as:
– properties of oscillations,
– motions in the plane,
– the steady-state Schrödinger equation,
– partial differential equations,
– Monte Carlo methods,
– wave optics,
– statistical physics, and
– variational calculus.
In Fig. 1.1, you see the start menu of excel 2019, where the main tab for-
mulas has been activated, and the cursor has been positioned over the group
Ribbon
Formula bar
Command
Column header
Active cell
Handle
Row number
Fig. 1.1 The start menu of excel, with the main tab formulas activated
1.7 Getting Started with Excel 9
function library to show the command math&trig. Arrows indicate the dif-
ferent elements of the start menu, namely ribbon, tab, group, formula bar, and
command, as well as elements of the working area, column header, row num-
ber, active cell, and handle of a cell. To indicate a “click path” in the text,
we write a sequence tab/group/command/function, e.g., formulas/function
library/math&trig/cos to call the cosine function.
Throughout this book, we will take screenshots from excel 2019. Experience
has shown that students can work with these instructions in every version of excel
without major difficulties.
structure of a spreadsheet
In Fig. 1.2 (S), a spreadsheet organization in the structure, often employed in our
exercises, is shown. With (“gamma”), we refer to the straight lines above C14:G14
and to the left of C14: C174.
Above :
Left of :
A B C D E F G H
1 Prespecifications
2 Amplitude of pendulum Ap 1.50
3 Period of pendulum Tp 1.20
4 Period of rotation Tr 9.00 Tp=1.2; Tr=9
5 Time interval dt 0.0173 ="Tp="&Tp&"; Tr="&Tr
6 Suspension point vs. rot. axis xSh 0.00
7 Calculated therefrom
8 Angular frequency pendulum wP 5.24 =2*PI()/Tp
9 Angular frequency rotating disc wR -0.70 =-2*PI()/Td
10
c disc
ot. dis n rot.
. on r tylo o
ndu lum ace pend c e s
11 Pe Tr Tra
t) +xSh *t) t)
(wP * (wR wR*t) (wR* wR*t)
+dt COS xP*COS SIN( Ap*COS Ap*SIN(
12 =B14 =Ap* = =xP* = =
13 t xP xT yT xSt ySt
14 0.000 1.50 1.50 0.00 1.50 0.00
15 0.017 1.49 1.49 -0.02 1.50 -0.02
174 2.768 -0.52 0.18 0.49 -0.53 -1.40
Fig. 1.2 (S) Typical structure of a spreadsheet, here, for the calculation of the trace of a Foucault
pendulum; rows 16–173 are hidden
10 1 Introduction
Fig. 1.3 (P) Log procedure, changes the period of the rotational motion in Fig. 1.2 (S) and logs
the values of x T and yT at the last instant of the calculation period
Below :
Nomenclature
Python-typical terms are printed in the Courier font.
When excel-typical terms are referred to in the text, e.g., function names, they are
set in small caps; examples: if(condition; then; else) . Spreadsheet formulas
are given in the form B15 = [=B14 + dt]. The expression in rectangular brackets
corresponds exactly to the entry in the cell, including the equal sign. The equal sign
specifies that it is a formula that is in the cell.
Three types of figure are distinguished, two of which are denoted by suffixes, (S)
for spreadsheets, e.g., Fig. 1.2 (S), and (P) for the code of Visual Basic programs,
e.g., Fig. 1.3 (P). Figures without a suffix are line drawings or screenshots, e.g.,
Fig. 1.1.
Names given by the programmer are printed in the text in italics, e.g., f, d. Some-
times in excel, names are used that contain a dot, e.g., “T.1” or “x.2”. This is because
T1 and X2 are reserved for cell addresses. The associated variables are referenced
in the text without a dot, but with subscripts, i.e., as T 1 and x 2 .
Physical units
Sometimes, no physical units are specified in the axis labels of the figures. They can
then be deduced from the physical units of the parameters.
You first have to install Anaconda with Python. There are many instructions on
the Internet as to how to achieve that, e.g., https://docs.anaconda.com/anaconda/ins
tall/windows/ or https://www.jcchouinard.com/install-python-with-anaconda-on-
windows/ (2020-09-02).
1.8 Getting Started with Python 11
When the Jupyter Notebook is opened, an overview of the filers and single
files on the localhost is shown. The programs used for this book are in a sub-filer
“Py PhExI” of the main filer “Python”. When we click Python/Py PhEx I, the
window in Fig. 1.4 pops up. To edit an already existing file, we have to click on
that file.
To create a new file, we open the list “New” and click on “Python 3”. A new
window pops up, opening a new file “Untitled22” with an empty program
cell “In [ ]”. The version in Fig. 1.5 is displayed after a small program has
been written into that cell. “In [5]” indicates that the 5th version of the code is
shown. This program is executed by clicking the button “Run”. The result of the
instruction print[x] is displayed in the output cell created automatically below
the program cell.
The different programming techniques are distributed over various exercises. For
the purpose of learning about them and how to revise them, the following lists
of keywords and broom rules have been compiled. They are meant to assist
the readers with the revision of subjects and, of course, their preparation for
examinations.
Fig. 1.5 A program creating an output just below the program cell
Mathematical techniques
Ψ Imaging equation for lenses with plus and minus! (Exercise 3.2).
Functions
Language: English
TO MY FRIEND
LAURITZ MELCHIOR
AND, THROUGH HIM,
TO ALL MY FRIENDS
IN DENMARK
THIS BOOK
IS DEDICATED
MOTTO
to me over the past
Decillions.
There is no better than it
And now. What behaves well
In the past or behaves well
To-day is not such a wonder.
The wonder is always and
Always how there can be
A mean man or an infidel."
Walt Whitman.
CONTENTS
BOOK I: TWO DAYS
CHAPTER PAGE
I The Scarlet Feather 13
IIHenry Himself 28
III Millie 49
IV Henry's First Day 64
V The Three Friends 74
BOOK II: HIGH SUMMER
I Second Phase of the Adventure 83
IIMillie and Peter 97
III The Letters 113
IV The Cauldron 129
V Millie in Love 138
VI Henry at Duncombe 156
VII And Peter in London 163
BOOK III: FIRST BRUSH WITH THE ENEMY
I Romance and Cladgate 175
IILife, Death and Friendship 195
III Henry in Love 212
IV Death of Mrs. Trenchard 222
V Nothing is Perfect 229
VI The Return 236
VII Duncombe Says Good-Bye 247
VIII Here Courage is Needed 259
IX Quick Growth 268
BOOK IV: KNIGHT ERRANT
I Mrs. Tenssen's Mind is Made Up at Last 281
IIHenry Meets Mrs. Westcott 286
III A Death and a Battle 292
IV Millie Recovers Her Breath 302
V And Finds Someone Worse Off Than Herself 309
VI Clare Goes 317
VII The Rescue 320
VIII The Moment 324
IX The Unknown Warrior 328
X The Beginning 333
BOOK I
TWO DAYS
CHAPTER I
THE SCARLET FEATHER
I
Around Wardour Street they hung all the shabby and tattered
traditions of the poor degraded costume romance, but in its actual
physical furniture there are not even trappings. There is nothing but
Cinema offices, public houses, barber shops, clothes shops and
shops with windows so dirty that you cannot tell what their trade
may be. It is a romantic street in no sense of the word; it is not a
kindly street nor a hospitable, angry words are forever echoing from
wall to wall and women scream behind shuttered windows.
Henry had no time to consider whether it were a romantic street or
no. The feather waved in front of him and he followed. He had by
now forgotten that he was hatless and dirty. A strangely wistful
eagerness urged him as though his heart were saying with every
beat: "Don't count too much on this. I know you expect a great deal.
Don't be taken in."
He did expect a great deal; with every step excitement beat higher.
Their sudden reappearance when he had thought that he had lost
them seemed to him the most wonderful omen. He believed in
omens, always throwing salt over his left shoulder when he spilt it
(which he continually did), never walking under ladders and of
course never lighting three cigarettes with one match.
Some way up Wardour Street on the left as you go towards Oxford
Street there is a public house with the happy country sign of the
Intrepid Fox. No one knows how long the Intrepid Fox has charmed
the inhabitants of Wardour Street into its dark and intricate recesses
—Tom Jones may have known it and Pamela passed by it and
Humphrey Clinker laughed in its doorway—no one now dare tell you
and no history book records its name. Only Henry will never until he
dies forget it and for him it will always be one of the most romantic
buildings in the world.
It stood at the corner of Wardour Street and a little thoroughfare
called Peter Street. Henry reached the Intrepid Fox just as the
Flaming Feather vanished beyond the rows of flower and vegetable
stalls that thronged the roadway. Peter Street it seemed was the
market of the district; beneath the lovely blue of the evening the
things on the stall are picturesque and touching, even old clothes,
battered hats, boots with gaping toes and down-trodden heels, and
the barrow of all sorts with dirty sheets of music and old paper-
covered novels and tin trays and cheap flower-painted vases. In
between these booths the feather waved. Henry pursuing stumbled
over the wooden stands of the barrows, nearly upset an old watery-
eyed woman from her chair—and arrived just in time to see the
three pursued vanish through a high faded green door that had the
shabby number in dingy red paint of Number Seven.
Number Seven was, as he at once perceived, strangely situated. At
its right was the grimy thick-set exterior of "The City of London"
public house, on its left there was a yard roofed in by a wooden
balcony like the balcony of a country inn, old and rather pathetic
with some flower-pots ranged along it and three windows behind it;
the yard and the balcony seemed to belong to another and simpler
world than the grim ugliness of the "City of London" and her
companions. The street was full of business and no one had time to
consider Henry. In this neighbourhood the facts that he was without
a hat and needed a wash were neither so unusual nor so humorous
as to demand comment.
He stood and looked. This was the time for him to go home. His
romantic adventure was now logically at an end. Did he ring the bell
of Number Seven he had nothing whatever to say if the door were
opened.
The neighbourhood was not suited to his romantic soul. The shop
opposite to him declaring itself in large white letters to be the "Paris
Fish Dinner" and announcing that it could provide at any moment
"Fish fried in the best dripping" was the sort of shop that destroyed
all Henry's illusions. He should, at this point, have gone home. He
did not. He crossed the road. The black yard, smelling of dogs and
harness, invited him in. He stumbled in the dusk against a bench
and some boxes but no human being seemed to be there. As his
eyes grew accustomed to the half light he saw at the back of the
yard a wooden staircase that vanished into blackness. Still moving as
though ordered by some commanding Providence he walked across
to this and started to climb. It turned a corner and his head struck
sharply a wooden surface that suddenly, lifting with his pressure a
little, revealed itself as a trap-door. Henry pushed upwards and
found himself, as Mrs. Radcliffe would say "in a gloomy passage
down which the wind blew with gusty vehemence."
In truth the wind was not blowing nor was anything stirring. The
trap-door fell back with a heavy swaying motion and a creaking sigh
as though some one quite close at hand had suddenly fainted. Henry
walked down the passage and found that it led to a dusky thick-
paned window that overlooked a square just behind the yard
through which he had come. This was a very small and dirty square,
grimy houses overlooking it and one thin clothes-line cutting the
light evening sky now light topaz with one star and a cherry-
coloured baby moon. To the right of this window was another
heavily curtained and serving no purpose as it looked out only upon
the passage. Beside this window Henry paused. It was formed by
two long glass partitions and these were not quite fastened. From
the room beyond came voices, feminine voices, one raised in violent
anger. A pause—from below in the yard some one called. A step was
ascending the stair.
From within voices again and then a sound not to be mistaken.
Some one was slapping somebody's face and slapping it with
satisfaction. A sharp cry—and Henry pushing back the window,
stepped forward, became entangled in curtains of some heavy
clinging stuff, flung out his arms to save himself and fell for the
second time within an hour and on this occasion into the heart of a
company that was most certainly not expecting him.
II
He had fallen on his knees and when he stumbled to his feet his left
heel was still entangled with the curtain. He nearly fell again, but
saved himself with a kind of staggering, suddenly asserted dignity, a
dignity none the easier because he heard the curtain tear behind
him as he pulled himself to his feet.
When he was standing once more and able to look about him the
scene that he slowly collected for himself was a simple one—a very
ugly room dressed entirely it seemed at first sight in bright salmon
pink, the walls covered with photographs of ladies and gentlemen
for the most part in evening dress. There were two large pink pots
with palms, an upright piano swathed in pink silk, a bamboo
bookcase, a sofa with pink cushions, a table on which tea was laid,
the Pomeranian and—three human beings.
The three human beings were in various attitudes of transfigured
astonishment exactly as though they had been lent for this special
occasion by Madame Tussaud. There was the lady with the green
dress, the girl with the flaming feather and the third figure was a
woman, immensely stout and hung with bracelets, pendants, chains
and lockets so that when her bosom heaved (it was doing that now
quite frantically) the noise that she made resembled those Japanese
glass toys that you hang in the window for the wind to make tinkling
music with them. The only sounds in the room were this deep
breathing and this rattling, twitting, tittering agitation.
Even the Pomeranian was transfixed. Henry felt it his duty to speak
and he would have spoken had he not been staring at the girl as
though his eyes would never be able to leave her face again. It was
plain enough that it was she who had been slapped a moment ago.
There was a red mark on her cheek and there were tears in her
eyes.
To Henry she was simply the most beautiful creature ever made in
heaven and sent down to this sinful earth by a loving and kindly
God. He had thought of her as a child when he first saw her, he
thought of her as a child again now, a child who had, only last night,
put up her hair—under the hat with the flaming feather, that hair of
a vivid shining gold was trying to escape into many rebellious
directions. The slapping may have had something to do with that. It
was obvious at the first glance that she was not English—
Scandinavian perhaps with the yellow hair, the bright blue eyes and
the clear pink-and-white skin. Her dress of some mole-coloured
corduroy, very simple, her little dark hat, set off her vivid colour
exquisitely. She shone in that garish vulgar room with the light and
purity of some almost ghostly innocence and simplicity. She was
looking at Henry and he fancied that in spite of the tears that were
still in her eyes a smile hovered at the corners of her mouth.
"Well, sir?" said the lady in green. She was not really angry Henry at
once perceived and afterwards he flattered himself because he had
from the very first discovered one of the principal features of that
lady's "case"—namely, that she would never feel either anger or
disapproval—at any member of the masculine gender entering any
place whatever, in any manner whatever, where she might happen to
be. No, it was not anger she showed, nor even curiosity—rather a
determination to turn this incident, bizarre and sudden though it
might be, to the very best and most profitable advantage.
"You see," said Henry, "I was in the passage outside and thought I
heard some one call out. I did really."
"Well you were mistaken, that's what you were," said the green lady.
"I must say——! Of all the things!"
"I'm really very sorry," said Henry. "I've never done such a thing
before. It must seem very rude."
"Well it is rude," said the green lady. "If you were to ask me to be as
polite as possible and not to hurt anybody's feelings, I couldn't say
anything but that. All the same there's no offence taken as I see
there was none meant!"
She smiled; the gleam of a distant gold tooth flashed through the air.
"If there's anything I can do to apologize," said Henry, encouraged
by the smile, but hating the smile more than ever.
"No apologies necessary," said the green lady. "Tenssen's my name.
Danish. This is Mrs. Armstrong—My daughter Christina——"
As she spoke she smiled at Henry more and more affectionately. Had
it not been for the girl he would have fled long before; as it was,
with a horrible sickening sensation that in another moment she
would stretch out a fat arm and draw him towards her, he held his
ground.
"What about a cup of tea?" she said. At that word the room seemed
to spring to life. Mrs. Armstrong moved heavily to the table and sat
down with the contented abandonment of a cow safe at last in its
manger. The girl also sat down at the opposite end of the table from
her mother.
"It's very good of you," said Henry, hesitating. "The fact is that I'm
not very clean. I had an accident in Piccadilly and lost my hat."
"That's nothing," said Mrs. Tenssen, as though falling down in
Piccadilly were part of every one's daily programme.
"Come along now and make yourself at home."
He drew towards her, fascinated against his will by the shrill green of
her dress, the red of her cheeks and the strangely intimate and
confident stare with which her eyes, slightly green, enveloped him.
As he had horribly anticipated her fat boneless fingers closed upon
his arm.
He sat down.
There was a large green teapot painted with crimson roses. The tea
was very strong and had been obviously standing for a long time.
Conversation of a very bright kind began between Mrs. Tenssen and
Mrs. Armstrong.
"I'm sure you'll understand," said Mrs. Tenssen, smiling with a rich
and expensive glitter, "that Mrs. Armstrong is my oldest friend. My
oldest and my best. What I always say is that others may
misunderstand me, but Ruby Armstrong never. If there's one alive
who knows me through and through it's Mrs. Armstrong."
"Yes," said Henry.
"You mustn't believe all the kind things she says about me. One's
partial to a friend of a lifetime, of course, but what I always say is if
one isn't partial to a friend, who is one going to be partial to?"
Mrs. Armstrong spoke, and Henry almost jumped from his chair so
unexpectedly base and masculine was her voice.
"Ada expresses my feelings exactly," she said.
"I'm sure that some," went on Mrs. Tenssen, "would say that it's
strange, if not familiar, asking a man to take tea with one when one
doesn't even know his name, and his entrance into one's family was
so peculiar; but what I always say is that life's short and there's no
time to waste."
"My name's Henry Trenchard," said Henry, blushing.
"I had a friend once" (Mrs. Tenssen always used the word "friend"
with a weight and seriousness that gave it a very especial
importance), "a Mr. William Trenchard. He came from Beckenham.
You remember him, Ruby?"
"I do," said Mrs. Armstrong. "And how good you were to him too! No
one will ever know but myself how truly good you were to that man,
Ada. Your kind heart led you astray there, as it has done often
enough before."
Mrs. Tenssen nodded her head reminiscently. "He wasn't all he
should have been," she said. "But there, one can't go on regretting
all the actions of the past, or where would one be?"
She regarded Henry appreciatively. "He's a nice boy," she said to
Mrs. Armstrong. "I like his face. I'm a terrible woman for first
impressions, and deceived though I've been, I still believe in them."
"He's got kind eyes," said Mrs. Armstrong, blowing on her tea to cool
it.
"Yes, they're what I'd call thinking eyes. I should say he's clever."
"Yes, he looks clever," said Mrs. Armstrong.
"And I like his smile," said Mrs. Tenssen.
"Good-natured I should say," replied Mrs. Armstrong.
This direct and personal comment floating quite naturally over his
self-conscious head embarrassed Henry terribly. He had never been
discussed before in his own presence as though he didn't really
exist. He didn't like it; it made him extremely uneasy. He longed to
interrupt and direct the conversation into a safer channel, but every
topic of interest that occurred to him seemed unsuitable. The
weather, the theatres, politics, Bolshevism, high prices, food, house
decoration, literature and the Arts—all these occurred to him but
were dismissed at once as unlikely to succeed. Moreover, he was
passionately occupied with his endeavour to catch the glimpses of
the girl at the end of the table. He did not wish to look at her
deliberately lest that should embarrass her. He would not, for the
world bring her into any kind of trouble. The two women whom he
hated with increasing vehemence with every moment that passed
were watching like vultures waiting for their prey. (This picture and
image occurred quite naturally to Henry.) The glimpses that he did
catch of the soft cheek, the untidy curls, the bend of the head and
the curve of the neck fired his heart to a heroism, a purity of
purpose, a Quixotism that was like wine in his head, so that he could
scarcely hear or see. He would have liked to have the power to at
that very instant jump up, catch her in his arms and vanish through
the window. As it was he gulped down his tea and crumbled a little
pink cake.
As the meal proceeded the air of the little room became very hot
and stuffy. The two ladies soon fell into a very absorbing
conversation about a gentleman named Herbert whose salient
features were that he had a double chin and was careless about
keeping engagements. The conversation passed on then to other
gentlemen, all of whom seemed in one way or another to have their
faults and drawbacks, and to all of whom Mrs. Tenssen had been,
according to Mrs. Armstrong, quite marvellously good and kind.
The fool that Henry felt!
Here was an opportunity that any other man would have seized. He
could but stare and gulp and stare again. The girl sat, her plate and
cup pushed aside, her hands folded, looking before her as though
into some mirror or crystal revealing to her the strangest vision—and
as she looked unhappiness crept into her eyes, an unhappiness so
genuine that she was quite unconscious of it.
Henry leant across the table to her.
"I say, don't . . . don't!" he whispered huskily.
She turned to him, smiling.
"Don't what?" she asked. There was the merest suggestion of a
foreign accent behind her words.
"Don't be miserable. I'll do anything—anything. I followed you here
from Piccadilly. I heard her slapping you."
"Oh, I want to get away!" she whispered breathlessly. "Do you think
I can?"
"You can if I help you," Henry answered. "How can I see you?"
"She keeps me here . . ."
Their whispers had been low, but the eager conversation at the
other end of the table suddenly ceased.
"I'm afraid I must be going now," said Henry rising and facing Mrs.
Tenssen. "It was very good of you to give me tea."
"Come again," said Mrs. Tenssen regarding him once more with that
curiously fixed stare, a stare like a glass of water in which floated a
wink, a threat, a cajoling, and an insult.
"We'll be glad to see you. Just take us as you find us. Come in the
right way next time. There's a bell at the bottom of the stairs."
Mrs. Armstrong laughed her deep bass laugh.
He shook hands with the two women, shuddering once more at Mrs.
Tenssen's boneless fingers. He turned to the girl. "Good-bye," he
said. "I'll come again."
"Yes," she answered, not looking at him but at her mother at the
other side of the table. The stairs were dark and smelt of fish and
patchouli. He stumbled down them and let himself out into Peter
Street. The evening was blue with a lovely stir in it as in running
water. The booths were crowded, voices filled the air. He escaped
into Shaftesbury Avenue as Hänsel and Gretel escaped from the
witch's cottage. He was in love for the first time in his young, self-
centred life. . . .
CHAPTER II
HENRY HIMSELF
In the fifth chapter of the second part of Henry Galleon's Three
Magicians there is this passage (The Three Magicians appeared in
1892):
So much, for Galleon who is already now so shortly after his death
looked upon as an old sentimental fogy. Sentimental? Why certainly.
What in the world could be more absurd than his picture of the
English gazing wide-eyed at the wonder of life? They of all peoples!
And yet he was no fool. He was a Cosmopolitan. He had lived as
much in Rome, in Paris, in Vicenza, as in London. And why should I
apologize for one of the greatest artists England possesses? Other
times, other names . . . and you can't catch either Henry Trenchard
or Millicent—no, nor Peter either—and I venture to say that you
cannot catch that strange, restless, broken, romantic, aspiring,
adventurous, disappointing, encouraging, enthralling, Life-is-just-
beginning-at-last Period in which they had these adventures simply
with the salt of sheer Realism—not salt enough for that Bird's tail.
I should like to find that little picture of Henry Galleon's fairy book
and place it as a frontispiece to this story. But Heaven alone knows
where that old book has gone to! It was perhaps Galleon's own
invention; he was a queer old man and went his own way and had
his own fancies, possessions that many writers to-day are chary of
keeping because they have been told on so many occasions by so
many wise professors that they've got to stick to the Truth. Truth?