/
Текст
MATHEMATICA FOR PHYSICS
MATHEMATICA FOR PHYSICS
SECOND EDITION
Robert L. Zimmerman
University of Oregon
Fredrick I. Olness
Southern Methodist University
San Francisco Boston New York
Capetown Hong Kong London Madrid Mexico City
Montreal Munich Paris Singapore Sydney Tokyo Toronto
Acquisitions Editor. Adam Black
Project Editor: Nancy Benton
Production Editor: Joan Marsh
Text Designer: Leslie Galen
Cover Designer: Blakeley Kim
Marketing Manager. Christy Lawrence
Manufacturing Coordinator. Vivian McDougal
Project Coordination and Electronic Page Makeup: Integre Technical Publishing Co., Inc.
The programs and applications presented in this book have been included for their instructional value. They have
been tested with care but are not guaranteed for any particular purpose. The publisher does not offer any
warranties or representations, nor does it accept any liabilities with respect to the programs or applications.
Copyright © 2002 by Addison-Wesley Publishing Company, Inc.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in
any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior
written permission of the publisher. Printed in the United States of America.
Library of Congress Cataloging-in-Publication Data
Zimmerman, Robert L.
Mathematica for physics / Robert Zimmerman, Fredrick Olness-2nd ed.
p. cm.
Includes bibliographical references and index.
ISBN 0-8053-8700-5
1. Mathematical physics—Data processing 2. Mathematica (Computer file) I. Olness, Fredrick Ivet
II. Title.
QC20.Z56 2003
530'.0285'53-dc21 2002004623
123456789 10 —MA— 9897969594
www.aw.com/aw
To Merrie,
and
to Gloria, Jonathan, Jacqueline, and Benjamin
for support and encouragement.
Contents
1 ¦ Getting Started
1.1
1.2
1.3
1.4
1.5
1.6
1.7
Introduction 1
Arithmetic
Functions
Packages
Calculus
Graphics
Exercises
; and Algebra 4
and Procedures 14
23
27
32
39
General Physics 44
2.1 Introduction 44
2.2 Newtonian Mechanics in Inertial Frames 44
2.3 Newtonian Mechanics in Rotating Frames 77
2.4 Electricity and Magnetism 93
2.5 Modern Physics 116
2.6 Exercises 127
Oscillating Systems 130
3.1 Introduction 130
3.2 Linear Oscillations 131
3.3 Small Oscillations 157
3.4 Oscillating Circuits 182
3.5 Exercises 191
Nonlinear Oscillating Systems 193
4.1 Introduction 193
4.2 Nonlinear Pendulum 195
4.3 Duffing Equation 232
4.4 Exercises 255
VII
viii Contents
5 ¦ Discrete Dynamical Systems 258
5.1 Introduction 258
5.2 Logistic Map 260
5.3 Other Maps 276
5.4 Fractals 291
5.5 Exercises 296
6 ¦ Lagrangians and Hamiltonians 298
6.1 Introduction 298
6.2 Lagrangian Problems without Lagrange Multipliers 299
6.3 Lagrangian Problems with Lagrange Multipliers 335
6.4 Hamiltonian Problems 344
6.5 Hamilton-Jacobi Problems 365
6.6 Exercises 375
7 ¦ Orbiting Bodies 377
7.1 Introduction 377
7.2 The Two-Body Problem 378
7.3 Restricted Three-Body Problem 396
7.4 Exercises 433
8 ¦ Electrostatics 435
8.1 Introduction 435
8.2 Point Charges, Multipoles, and Image Charges 437
8.3 Laplace's Equation in Cartesian and Cylindrical Coordinates 467
8.4 Laplace's Equation in Spherical Coordinates 488
8.5 Exercises 511
9 ¦ Quantum Mechanics 513
9.1 Introduction 513
9.2 One-Dimensional Schrodinger's Equation 515
9.3 Three-Dimensional Schrodinger's Equation 549
9.4 Exercises 576
10 ¦ Relativity and Cosmology 578
10.1 Introduction 578
10.2 Special Relativity 579
10.3 General Relativity 597
10.4 Cosmology 621
10.5 Exercises 639
Index 643
Foreword
To be good at physics you no longer have to be good at calculating.
When I started doing physics in the early 1970s, it was generally thought that being able
to do long calculations by hand was an essential skill. But as it happens I was never very
good at such calculations. And so I looked for an alternative, and before long I found one: I
discovered that I did not really need to do the calculations myself—I could get a computer
to do them instead.
My physics papers from the late 1970s were full of elaborate calculations. And from
seeing this many people came to the conclusion that I must be a great calculator. But in
fact that was far from the truth, and what was actually going on was that I was doing all
my calculations by computer.
Of course, in those days it required a considerable amount of programming effort to
get a computer to do one's calculations—particularly when algebra and graphics were
involved. But after a few years I realized that with new generations of computers and
software engineering tools it would actually be possible to build a single software system
that would be able to handle all the various kinds of calculations that one needed to do.
And from this realization I came in the end to develop Mathematica.
So now that Mathematica exists, what does it mean for physics? In the years since the
first version of Mathematica became available (version 1.0 was released on June 23,1988),
a vast amount of new physics has been done with it. Indeed, for example, if one looks today
at any of the leading physics journals, one can tell that a large fraction of the calculations
and pictures in them were done with Mathematica.
But it is not just at the level of research that Mathematica affects the way physics is
done. Anyone who learns physics today can do so in a very different way because of
Mathematica.
And that is the point of this book. What the authors have done is to take the topics from
a mainstream physics course and show how each of them can be handled in a new way
with Mathematica.
The results are impressive. Over and over again what was once a calculation too lengthy
to be reproduced as part of a course now becomes a few lines of Mathematica input that can
be executed in a matter of seconds. And instead of having to explain in painful detail the
mechanics of the calculation, one can concentrate on the conceptual issues that underlie it.
One of the things that one sees in many of the examples in the book is the extent to
which Mathematica has narrowed the gap between physics learning and physics research.
For once a calculation has been set up in Mathematica, one can try the calculation in many
different cases—not just ones already covered in textbooks, but also ones that may never
have been tried before.
ix
Foreword
This book will no doubt be read by many students of physics and many professors.
Students may wonder how many of the calculations it describes could ever have been
done before Mathematica. Perhaps sometimes their professors will tell them tales from the
heroic age of hand calculation. But mostly I hope that students and professors alike will be
able to use the technology that we have built and material of the kind that is included in
this book to learn and discover physics in a new and exciting way.
Stephen Wolfram
Creator of Mathematica
Introduction
Computer algebra software has already had an important impact on the way physics is
taught and research is performed. While computers cannot replace thinking, they signif-
significantly enhance problem-solving abilities of the scientist and student by eliminating the
tedious mathematics. As computers become more powerful and more readily available, the
scope of problems solved in both research and teaching tremendously expands.
This book serves as a guide for using the computer algebra program Mathematica for
physics research and teaching. The flexibility of Mathematica to manipulate analytical,
numerical, and graphical expressions will further broaden the scope of problems that the
student and researcher can solve.
Physics is not a spectator sport. The best way to demonstrate Mathematica is by solv-
solving a variety of physics problems chosen to illustrate its ability to display the output in
many forms. A significant asset of Mathematica is the ease with which results can be vi-
visualized. This feature brings physics problems "alive" so that the reader can interact and
experiment with the solutions. One can change the parameters and immediately observe the
consequences, thereby gaining deeper insight into the physics of the solution. Instead of
being throughly exhausted by the burdensome mathematics required to obtain the answer,
Mathematica enables us to focus our attention on understanding the solution.
HOW TO USE THIS BOOK
This book is intended for undergraduate students, graduate students, and practicing physi-
physicists who want to learn new Mathematica techniques for solving a general class of physics
problems. For the student, we expect this text to be a supplement to the standard course
texts in mechanics, electrodynamics, relativity, and quantum mechanics; the student should
use this book to get ideas on how to use Mathematica to solve the problems assigned by the
instructor. Since we cover the canonical problems from the core courses, the student can
practice with our solutions, and then modify our solutions to solve the particular problems
assigned. This should help the student move up the Mathematica learning curve quickly.
This book is also suitable for a course designed to teach the applications of Mathematica
to physicists.
As such, the design of this book is more like a reference book than a novel to be read
cover to cover. Each problem is self-contained (up to user-defined functions discussed at
the beginning of each chapter), so the reader can go immediately to the portion of the book
that is relevant to his or her problem.
XI
xii Introduction
There are two sections of the book which we recommend all readers examine before
trying the problems.
• The section in this preface on troubleshooting, so that the reader knows where to
turn in case difficulties arise.
• The first chapter contains useful information about style, notation, and short-cuts
that we will make use of throughout the book.
Note that we assume the reader is reasonably familiar with Mathematica (at least at the
level of the tutorial in the Mathematica manual), so we focus on the physics applications
and not on rudimentary Mathematica techniques.
The book consists of two levels of material. The few sections of each chapter are readily
understandable by the undergraduate physics student. The latter portions of the chapters are
intended for advanced undergraduate and graduate physics students, and cover a broader
range of topics.
Each of the chapters 2 through 10 are divided into three parts:
• an introduction to the physics and Mathematica commands;
• solved problems that cover the standard ideas and methods found in the discipline;
• unsolved exercises.
As the reader gains insight into the power of symbolic computations, they can easily extend
the techniques demonstrated here to go beyond these examples and explore more difficult
problems.
ABOUT THE ELECTRONIC SUPPLEMENT
The Mathematica input code for the entire book is available in the electronic supplement
so that you can begin working the examples immediately. We will also post tips and sug-
suggestions about using this book, extensions to other problems and related fields, and bug
fixes (should we encounter any).
The electronic supplement is available as item number 0206-862 from MathSource(TM).
MathSource is an on-line archive of Mathematica related materials contributed by Wolfram
Research and Mathematica users around the world. You can reach this site at:
http://mathsource.wri.com/
The material is also available from the authors web sites at:
http://www.physics.smu.edu/~olness
and
http://darkwing.uoregon.edu/~phys600/
Introduction xiii
HOW TO USE THE ELECTRONIC SUPPLEMENT
To spare the reader tedious typing, we have put all the source code for each chapter into a
single notebook file. This enables the reader to start solving problems immediately without
re-typing the lengthy commands. Furthermore, if there is any confusion about what input
we used to generate these problems, you can simply cross-check with the source code.
For example, if you want to solve Problem 6 in Chapter 7, all you need do is to open
the source code for chapter 7 (ch7.nb), execute the initialization cells, and then proceed
directly to problem 6 (or whatever problem you choose) and begin working.
COMMUNICATION WITH THE AUTHORS
We welcome any comments and suggestions regarding this book. You may contact us via
e-mail or regular mail at:
Robert Zimmerman
Institute of Theoretical Science
University of Oregon
Eugene, OR 97403
bob @ zim.uoregon.edu
Fredrick Olness
Department of Physics
Southern Methodist University
Dallas, TX 75275-0175
olness@mail.physics.smu.edu
We welcome bug reports, and will post such information on the MathSource server (should
we encounter any). However, we are unable to offer any help debugging problems specific
to the compatibility of different Mathematica versions or hardware installations; for this
type of assistance, we must refer you to the previous section on Troubleshooting, or to your
local system manager.
ACKNOWLEDGMENTS
It is our pleasure to acknowledge the people who have contributed to this project. We
thank Fumitaka Umewaka whose masters thesis, "Applications of Mathematica in Teach-
Teaching Physics," at the University of Oregon, initiated this project. We thank Pearson Edu-
Education Japan for publishing the Japanese edition of this book. A special thanks to John
G. Cramer of the University of Washington, who updated many of the commands in the
first edition. We thank our many colleagues at the University of Oregon and Southern
Methodist University, too numerous to name, who have supported the development of this
book. We also extend our gratitude to the graduate students at these institutions who have
tested solutions to several of the problems and to Lester E. Matson for reading some of
Introduction
the Mathematica files and making constructive suggestions. For the second edition, we
would also like to thank the many referees who carefully read the manuscript and provided
valuable feedback, in particular, John Cramer and Paul Abbott, who provided many useful
comments.
Fred Olness would like to thank Davison E. Soper of the University of Oregon for
introducing him to Mathematica. He would like to thank the Lightner-Sams Foundation
for support, and Southern Methodist University for an Instructional Technology Grant.
Fred Olness also acknowledges the U.S. Department of Energy for support of his high
energy physics research; many techniques developed in the course of his research were
incorporated in this book.
At Addison-Wesley, we would like to acknowledge the invaluable contributions by
Adam Black, Nancy Benton, and Joan Marsh.
We also thank those who contributed to the first edition: Stuart Johnson (Physics Editor),
Amy Willcutt, Jennifer Albanese, Nev Hanke, Eileen Hoff, and Laurie Petrycki.
At Wolfram Research, we thank Glenn Scholebo for elegantly converting the Mathe-
Mathematica notebooks into final typeset form for our first edition, and Stephen Wolfram for
contributing the foreword.
At Integre Technical Publishing Company, we thank Don DeLand, Leslie Galen, Karen
Couzin, and Lynn Ryan for their work on the second edition.
Troubleshooting
This manuscript was generated directly from a Mathematica notebook to minimize the
possibility of introducing errors. The draft manuscript was written in Mathematica, and
then converted to Tex using the TexSave feature. Final formatting was performed using
the Tex source.
The final version of the Mathematica code was run using version 4.1, but is fully com-
compatible with all Mathematica versions back to 3.0.
There are subtle differences between different versions and implementations of Math-
Mathematica. This means that on occasion the reader will find that some of the examples pre-
presented in this book need to be slightly modified to adapt to your particular version. We
have tested these examples extensively on different platforms and with different versions
to ensure that they are robust. However, we list below the most common difficulties that
the reader is likely to encounter.
In our examples, we have been careful to present enough intermediate output so that the
reader can cross-check their results for consistency. This allows the reader to isolate any
differences that may arise, and find the cause quickly.
Possible T^X Conversion Errors
The typesetting features of Mathematica significantly enhance the user's ability to read
and understand the Mathematica output. Unfortunately, this also means that the process
of converting the Mathematica code to TjX is significantly more complex. While we have
been very careful to avoid errors, there is the possibility that some characters are corrupted
in the conversion process. Unfortunately, one of the more common errors is to have missing
braces "{" and "}". For this reason, in part, we have posted the complete set of input files on
the web. Should you encounter a "mysterious" problem that you suspect may be linked to
a typographic error, you can use the input source code (which has not had any conversion)
to ensure you have the correct expression. In fact, we recommend you use the input source
code from the web in general to save yourself the effort of re-typing our expressions.
Order of Roots in Solve
A significant difference between different Mathematica versions is the order of the solu-
solutions returned by Solve and DSolve. Throughout the book, you will note we are careful
to select the desired root using the [ [ i ] ] notation. If you have difficulty with the prob-
problems, this is one of the first places to look. Compare the intermediate output displayed in
the book with your results. Use this information to isolate the problem, and determine if it
is due to the ordering of the roots of the Solve command.
xv
xvi Troubleshooting
Debugging Techniques
To save paper (and trees), we have not displayed intermediate output for all expressions.
Additionally, we have not displayed intermediate graphics output using the $Display-
Function->Identity command. While this is a good practice when writing a book,
when we were developing the problems we did display this intermediate output to help
guide us through the problem; only after we obtained our solution did we go back and
"clean up" the output.
How to Debug Modules and User-Defined Functions
In Chapter 3, Section 2, Problem 5, (Understanding the User-defined procedure small-
osc) we discuss how to redefine a Module so that the variables are Global and can be
examined. This allows the reader to debug a Module program by stepping through each
statement of the Module individually to try and isolate the error. This is a very useful
debugging technique.
Commands That Never Return an Answer
In cases where the Mathematica command takes a long time (more than a minute on a
~ 1 GHz Pentium 4) to return an answer, we have indicated this in the text. If you wait
a long time, get no output, and suspect a problem, there are many ways to approach this
problem. The most obvious is to break the procedure up into smaller steps. We often group
commands together to shorten our solution. We must confess that when we initially solved
the problem, we actually performed each step individually, examined the output, and after-
afterwards decided the most efficient set of steps to use and display.
Avoid the FullSimplify Command
In particular, if you are having trouble with lengthy expressions, try to avoid the Full-
Simplif y command. Until you know the scope of your problem, you will find that the
Expand, Together and ordinary Simplify command are much more efficient at re-
reducing the answer. Once you have massaged the result into something Mathematica can
swallow in a single bite, then you may want to try and FullSimplif y the result.
Animation
The details of animating a series of graphics varies widely with different implementations
of Mathematica. In this text we simply show the reader how to generate the sequence
of graphics. The reader must refer to the computer specific user guide for the details of
displaying the animation.
Clearing Variables
If Mathematica is yielding unusual results, a common cause is that there are variable defi-
definitions (possibly from a previous problem) that are conflicting with the assumed definitions
for the present problem. The command Clear [ "Global' *" ] will solve most of these
problems. In fact, each chapter of this book was initially a single Mathematica notebook.
Troubleshooting xvii
Using the Clear [" Global' *" ] command, we were able to run each chapter as a single
Mathematica session from start to finish. (Again, this helped us eliminate errors, and verify
that our examples were correct.) While this command should solve most all problems of
this type, it may be worth restarting the kernel if mysterious problems still persist.
WHAT'S NEW WITH MATHEMATICA IN THE SECOND EDITION
The first edition of our text was produced with Mathematica version 2.2. The current ver-
version of Mathematica has dramatically changed since that time.
• Typesetting. Beginning with version 3.0, Mathematica introduced typeset input and
output. This significantly shortens the length of the output (compare with our first
edition); more importantly, it makes the input and output much more readable. Ex-
Expressions that previously would span multiple pages (or fill the computer screen) are
now succinctly displayed.
• Mathematica has greatly expanded its knowledge base. In the first edition, we often
had to help Mathematica with complex integrals or differential equations. In this
edition, Mathematica is fully capable of evaluating such expressions.
• For our first edition in 1995, it took about an hour on a "modern" computer to execute
a chapter. With improved Mathematica algorithms and improved CPU's, an entire
chapter runs in a few minutes.
WHAT'S NEW WITH THIS BOOK IN THE SECOND EDITION
In this second edition we have significantly expanded the number and variety of problems.
In particular, we have expanded the book from seven to ten chapters; the three additional
chapters are on Nonlinear Systems and Chaos, Discrete Systems, and Chaos and Orbiting
Bodies. New problems and exercises have also been added to all chapters.
CHAPTER
1
Getting Started
1.1 ¦ INTRODUCTION
1.1.1 ¦ Computers as a Tool
The solution of realistic physics problems is often hampered because the algebra is too
complex for anyone but the dedicated researcher. Just as the calculator eliminated labo-
laborious numerical computations, symbolic software programs eliminate arduous algebraic
computations. While computer power is no substitute for thinking, it spares the scientist
from performing mundane mathematical steps, and thereby frees time for creative think-
thinking. The scientist is able to explore complex relationships among quantities, ask "What
if... ?", and obtain an immediate answer. Mathematica is only one of the popular systems
for doing such calculations; other systems include Maple, Derive, Axiom, Macsyma, and
Reduce.
Because there are many ways to solve physics problems, we present a variety of styles
to illustrate different ways of solving similar problems using Mathematica. We emphasize
that the solutions presented here are not necessarily the most efficient for dealing with all
possible instances. While we do discuss writing efficient Mathematica code, we sometimes
sacrifice the most elegant or efficient solution in favor of one that is most easily understood
pedagogically. For example, we introduce some user-defined procedures to automate repet-
repetitive tasks in an intuitive way. Had our goal been to write an efficient "black-box" program
that could handle all possible inputs in an error-free manner, the routines would be less
pedagogical, more complex to read, and encumbered with additional code to trap error
conditions. Where appropriate, we prompt the reader to expand upon our solutions.
Each chapter has a short overview of the major physics and mathematics topics empha-
emphasized in the chapter. The problems are chosen to cover a broad range of physics problems
and to illustrate a variety of Mathematica procedures. Exercises are included at the end of
the chapter to reinforce the techniques developed in the examples, and to suggest additional
applications not covered.
Our goal is to focus on the Mathematica techniques that are most appropriate for solv-
solving physics problems; thus, we assume the reader is familiar with the most basic features
of Mathematica as discussed in The Mathematica Book, Fourth Edition, by Stephen Wol-
Wolfram. At a minimum, the reader should be familiar with the Tour of Mathematica, which is
contained in The Mathematica Book.
1
Chapter 1 Getting Started
1.1.2 ¦ A Note about Notation and Style
Here we make a few notes about what notation we do and do not use throughout the text,
as well as some stylistic issues.
1. We do not use subscript notation for variables. Although this often makes the output
more readable, we encounter some very subtle features when using subscript nota-
notation. Therefore, our preference is to create variables in the form {xl, x2, x3,...} rather
than {xvx2,x3,...}. We explain this in more detail in the next section.
2. Initially we will type certain symbols in their expanded form. For example, the sym-
symbol "->" is equivalent to "-»"; however, we will initially enter this expression in the
format"- >" so the beginning Mathematica user knows exactly what to type.
3. We often use special characters, including letters from the Greek alphabet. These
can be entered using the palettes, or using keyboard short-cuts. For example, the
character 6 can be entered by typing (esc)q(esc), or by typing (esc)\theta(esc), where
(esc) represents the escape key. The latter form may be more familiar to those who
use the TjX typesetting program.
4. In general, we avoid introducing short-hand definitions for commands with a lengthy
name. While we often use such short-cuts in our personal work, doing so here makes
it difficult for the reader who must first look up our definition for our short-cut, and
then look up the Mathematica command. This philosophy is good practice when
you are sharing your notebooks with others. In place of using short-cut commands to
save typing, Mathematica has a very useful menu feature called Complete Selection.
Refer to the description of this command in the Help Browser.
5. We will use the semicolon ";" to suppress unwanted intermediate text and graphics
output. While this makes the book more compact, when you are initially solving a
problem you probably will want to view the intermediate output to check for errors.
6. Our preference is to turn off the automatic spell checking within Mathematica.
Again, this is helpful for debugging, but for a finished product (such as this book), it
is not necessary.
In[l]:= Off[General :: spelll];
Off[General : : spell];
1.1.3 ¦ Notation and Symbols (For Experts Only)
Here we explain some of the subtle features of Mathematica notation. Beware: you should
read this section only if you are an experienced Mathematica user, and need to use sub-
subscript notation for variables, e.g., {xl,x2,x3,...}. Otherwise, you should immediately skip
to the next section.
We include this section here so that if you encounter strange behavior when trying to use
subscript notation for variables, you will know where to look for explanations. This section
also uses some commands that are not introduced until later in this chapter; therefore, you
may find it best to come back to this section after reading the rest of the chapter.
Subscript notation for variables is tricky because you can have two expressions that have
identical output display formats, but they can in fact have very different internal forms.
1.1 Introduction 3
Debugging Mathematica code with such expressions becomes complicated, and this is
why, in general, we do not use subscript notation in this book.
For example, let us try to use the symbol xx as an independent variable. If we enter this
symbol using the basic input palette or with a keyboard short-cut, we obtain
In[2]:= x^/FullForm
Out[2]= Subscript[x, 1]
When we try to use such notation in a simple expression, we are in for some surprises.
The following expression looks simple enough.
In[3] := term = a x1 + b x2 + c x
Out[3]- cx + ax1+bx2
But, if we try to make a substitution for the variable x (without any subscript), which we
intend to be a variable independent of xx, we obtain
In[4]:= term/.{x-»l}
Out [4]= c + a
The result is obviously nonsense.
Next, we make use of the Symbolize function contained in the package Utili-
Utilities'Notation*.
In[5]:= «Utilities'Notation*
In[6] := TSymbolize
"Symbolize[boxrs] forces any box structure matching boxrs to be
treated internally as a single symbol anywhere it appears in
an input expression."
However, when we try this command in a simple manner, the result is an error.
In[7] := Symbolize [xj
Symbolize :: badSymbolizeBoxes : The Symbolize boxes x do not have an em-
embedded NotationBoxTag TagBox. The Symbolize statement Symbolize[x ] may not
have been entered using the palette, or the embedded TagBox may have been
deleted. The embedded TagBox ensures correct parsing and retention of proper
styling and grouping information. 1 1
Out[7]= $Failed
If, instead, we use the Symbolize command from the Notation Palette, we get a vari-
variable that appears to be identical to xx denned above, but has a very different internal form.
In[8] := Xj //FullForm
(* Entered from the Notation Palette *)
0ut[8]= NotationBoxTag[SubscriptBox["x","]]
Chapter 1 Getting Started
Using this form, we can Symbolize the variables xx and x2, and define a new expres-
expression, terxn2, using these variables.
In[9]:= J
Symbolize[x2]
term2 = ax1 + b x2 + c x;
Now the substitution works properly, and Mathematica can distinguish between the
variables x, xx, and x2.
In[10]:= term2/.x-»l
Out [10]=
Again, the moral of the story is that if you are going to use subscript notation
{xvx2,x3,...}, you need to know these subtle features; if you are satisfied to use the
simpler notation {xl, x2, x3,...} you can ignore this entire section.
1.2 ¦ ARITHMETIC AND ALGEBRA
1.2.1 ¦ Arithmetic and Notation
The simplest commands in Mathematica are arithmetic commands. These commands are:
addition (+), subtraction (-), multiplication (space or *), and division (/). For example, type
in the following fraction and press enter (or shift-return keys) to evaluate the command.
In[ll] := 2*6 A2 + 4)/( 12 -4)
Out[ll]= 24
Note in the above example we have used all operations including both space and "*" for
multiplication.
More sophisticated commands are exponent O, square root (Sqrt), factorial (!) and
double factorial (!!). Examples of these commands are
In[12]:= {2~3,Sqrt[2],4!,4!!}
0ut[12]= J8,V2, 24, 8J
Notice in the previous examples we used three different kind of brackets. Each type is
used for a specific purpose:
• Square brackets [...] are for functions or commands like Sqrt[2],
• Curly brackets {...} are used to make lists of objects like {1,2,3}, and
• Parentheses (...) are used to group terms like 2/A + 1).
1.2 Arithmetic and Algebra 5
The command N is used to convert expressions to numerical values (if possible). Wrapping
the function N around the Sqrt function, you get
In[13]:= N[Sqrt[2]]
Out[13]= 1.41421
An alternate way of entering the numerical procedure is to use postfix notation:
In[14]:= Sqrt[2]//N
Out [14]= 1.41421
The postfix form is useful because it allows repeated operations to be efficiently expressed.
In[15]:= 2//Sqrt //N
0ut[15]= 1.41421
While Mathematica only displays a limited number of digits as determined by the Print-
Precision option (which may be found in the Options Inspector), we can view more digits
using a second argument for the N command:
In[16]:= N[Sqrt[2], 50]
Out[16]= 1.414213562373095048801688724209698078569
6718753769
We also show the previous command using the postfix notation.
In[17]:= Sqrt[2]//N[#, 50]&
Out[17]= 1.414213562373095048801688724209698078569
6718753769
In this case, the syntax N[#, 50] & represents a pure function that will take a single
argument—the Sqrt [2], in this case. The argument will be inserted in Slot number
one represented by the symbol #. The symbol & is short-hand notation for the Function
function.
Mathematica has several built-in constants such as:
In[18]:= listl = {I, jt , e, co, GoldenRatio,
EulerGamma,Catalan,°}
Out[18]= {i, n, e, co, GoldenRatio,
EulerGamma, Catalan, deg}
We have named the set listl. The relation lhs = rhs assigns left-hand-side (lhs) to
be the value of right-hand-side (rhs). From then on, lhs is replaced by rhs whenever it
appears. The list can be recalled at a later time by typing listl. To obtain the numerical
values in the list use the command N:
Chapter 1 Getting Started
In[19]:= listl//N
Out[19]= {0. + 1. i, 3.14159, 2.71828, oo,
1.61803, 0.577216, 0.915966, 0.0174533}
You can clear listl from memory by typing:
In[20]:= Clear[listl]
It follows that listl has lost its assignment,
In[21]:= listl
Out[21]= listl
You can evaluate complex values as you do real values. The Mathematica symbol for a
complex quantity is I = if—I (or i found in the menu under Edit->Palettes). These three
input forms represent identical expressions.
In[22]:= {Sqrt[-1], I, i}
Out[22]= {i, i, i}
The same arithmetic commands that work with real numbers also work with complex
numbers. For example,
In[23]:= D1 + 61)/B - 41)
Out[23]= -2 + i
Mathematica defines Abs for absolute value, Conjugate for complex conjugate, and
Re and Im give the real and imaginary parts of a complex number:
In[24]:= {Abs [2 + I] , Re [2 + I] , Im[2 + I],
Conjugate[2 + I] }
Out[24]= {V5, 2, 1, 2-i]
1.2.2 ¦ Algebraic Manipulations
Some useful commands for manipulating expressions are: Expand, ComplexExpand,
ExpandAll, PowerExpand, Factor, Simplify, FullSimplify, and Together.
For example, use the command Expand to expand the expression A + x2M:
In[25]:= eql = Expand[A + x~2) ~5]
Out [25]= 1 + 5x2 +10x4 + 10x6 + 5x8 + x10
where we named the expression eql. The command Factor reduces eql to its original
form (using the postfix form),
In[26]:= eql//Factor
Out [26]= A + x2M
1.2 Arithmetic and Algebra 7
You can also factor eql over the complex numbers if the Gaussianlntegers op-
option of Factor is used:
In[27] := Factor [eql, Gaussianlntegers- >True]
Out[27]= (-i + xM (i + xM
This option was added to Factor with a "rule" of the form "option -> value".
The Options command displays the known options of a specific command:
In[28]:= Options[Factor]
Out [28]= {Extension -» None, Gaussianlntegers -» False,
Modulus -> 0, Trig -> False}
You have additional control of an expansion with Expand [expr,patt]. This com-
command expands expr without expanding any parts of expr that are free of the pat-
pattern patt. For example, the following expression expands only the terms in y, leaving
(l+x) unexpanded:
In[29] := eql = Expand[ (x + 1) ~5 (y+ l)~2,y]
Out[29]= (l+xM+2 (l + xMy+ (l + xMy2
The command Simplify can then be used to restore the original form:
In[30]:= eql//Simplify
Out[30]= A +xM A +yJ
Simpli ?y tries to reduce an expression to the smallest number of terms. If this command
does not work, then try FullSixnplify. Using Simplify and FullSimplify on
complicated expressions may take a long time because the commands have to test a large
number of forms to find the simplest one. With more involved expressions you may want
to exercise more control of the process by using specific commands.
You can broaden the use of Simplify by adding conditions to the variables. For ex-
example, consider
In[31]:= Sqrt[(abcd Cos[6])~2] //Simplify
Out [31]= ^/a2 b2 c2 d2 Cos[6]2
Simplify did not change the expression. If you have additional information about the
variables, Simplify can make use of this:
In[32] : = Simplify [ Sqrt [ (abed Cos [6]) ~2],
{ a > 0, b e Reals, c e Complexes,
jt /2 < 6 < jt } ]
Out[32]= -aVc2d2 Abs [b] Cos [6]
In this case, it can extract a, b, and Cos 16] from the Sqrt, but not c or d.
Chapter 1 Getting Started
Another example is Cos [n n\ and Sin [n n\ when n is an integer. Applying Sim-
Simplify to these functions with the restriction that n is an integer, you get
In[33] := Simplify [{Cos [ n jt], Sin[njr] },
n eintegers]
Out[33]= {(-l)n,0}
The symbol e is a short-hand for the Element function; this symbol is contained in
the Basiclnput palette.
There are several ways to manipulate trigonometric functions. Compare the two cases
where we Factor this expression with and without the option Trig->True.
In[34]:= Factor [Cos [4x] ~2 - 2Cos[4x] Sin [3x] +Sin[3x]~2]
Out[34]= (Cos[4x] -Sin[3x] J
In[35]:= Factor [Cos[4x] ~2 - 2Cos[4x]Sin[3x] + Sin[3x] ~2, Trig- > True]
Out[35]= (cos [|] +Sin [|])
A-2 Cos[2x] - 2 Sin[x] + 2 Sin[3x] J
Using the command TrigFactor is equivalent to Factor with the option Trig
->True.
In[36]:= Cos [4 x] ~2 - 2 Cos [4 x] Sin[3 x] + Sin[3 x] ~2 //
TrigFactor
Out[36]= (cos [ j] + Sin [^1 )
A-2 Cos[2x] -2 Sin[x] +2 Sin[3x]J
Other commands that have the option Trig->True include Expand, ExpandAll,
Apart, Together, Simplify.
If some of the symbols represent complex numbers, then you can use
ComplexExpand to simplify the expression.
In[37]:= CoraplexExpand[Exp[ie]]
Out [37]= Cos [6] +i Sin [6]
In this case, 6 is taken to be a real angle. If some of the symbols represent complex
numbers, then you can use ComplexExpand[expr, {xl,x2,...}] to simplify the
expression. The symbols{xl#x2#...} are assumed to be complex. For example, if we
allow for 6 to be complex, we obtain:
In[38]:= ComplexExpand[Exp[16], 6]
Out [38]= e-Im[e) Cos[Re[6]] +ie-Im[e] Sin [Re [6]]
The type of ComplexExpand output can be controlled with the following options:
In[39]:= Options[ComplexExpand]
1.2 Arithmetic and Algebra 9
Out [39]- {TargetFunctions ->
{Re, Im, Abs, Arg, Conjugate, Sign}}
ComplexExpand will try to return results in terms of the TargetFunctions. For
example,
In[40]:= ComplexExpand[Exp[I 6] , 6,
TargetFunctions -> Abs]
ie jAbs[ei2 _ i-e Abs[e]2i
1.2.3 ¦ PowerExpand
Next, let us say a few cautionary words about the PowerExpand command. This can be
very useful for certain types of expressions.
:= {Sqrt[a~2], Log[a/b],Log[a~b]} //
PowerExpand
Out[41]= {a, Log[a] -Log[b] , b Log[a] }
However, the operations of the PowerExpand command are not always correct. With-
Without PowerExpand, we obtain both roots.
In[42]:= Solve[Sqrt[x~2] == a, x]
Out[42]= {{x^-a}, {x^a}}
With PowerExpand, we miss the negative root.
In[43]:= Solve[Sqrt[x~2] == a//PowerExpand, x]
Out [43]= {{x^a}}
In short, PowerExpand should be used with care.
1.2.4 ¦ Simple Rules
Rules are useful for making temporary substitutions; this allows us to make substitutions
into expressions without those substitutions becoming permanent definitions. A simple
example is to consider
In[44]:= {a, b}/. { a -> b, b -> o}
Out[44]= {b, c}
The substitution operator /. applied the list of rules {a->b#b->c} once to {a#b}.
It is obvious that the rule has only been applied a single time by comparing with multiple
application of this rule as in this command:
10 Chapter 1 Getting Started
In[45]:= {a, b}//. { a -> b, b -> o}
Out[45]= {c, c}
The replacement operator //. applies the list over and over again until the expression
no longer changes. Beware, as expressions such as the following will generate an endless
loop.
In [46]:= a //. {a -> b, b -> a}
(* generates endless loop *)
ReplaceRepeated :: rrlim : Exiting after a scanned 65536 times.
Out [46]= a
1.2.5 ¦ A Homemade Complex Conjugate with SuperStar
We will often find it convenient to take the complex conjugate of an expression where we
assume all complex quantities are explicit. However, the obvious rule, {I -» -i}, does
not always work:
In[47]:= 2 I/.{I -> -1}
Out [47]= 2 i
To see why this fails, we can use the Full Form command to see how Mathematica
represents these expressions internally.
In[48]:= 2 I//FullFonn
Out[48]= Complex[0,2]
In[49]:= {I -> -I}//FullForm
Out[49]= List[Rule[Complex[0, 1] , Complex[0,-1]]]
We see the problem is that Mathematica is searching only for patterns of the form Com-
Complex [0, 1]. This gives us an idea for a rule that will accomplish what we desire.
In[50]:= conjugateRule = {Complex[re., im_]- > Complex[re, -im]};
We verify that conjugateRule works as expected:
In[51]:= 21/.conjugateRule
Out[51]= -2 i
Be sure to use the single replacement operator /. and not //. or you will have an endless
loop.
For many physics problems, we find that this conjugateRule is more useful than
the built-in Conjugate function. For this reason, we find it convenient to create our own
"homemade" conjugate function. We will make use of the SuperStar operator to allow
for an elegant short-hand notation.
1.2 Arithmetic and Algebra 11
In[52]:= Unprotect[SuperStar];
In[53]:= SuperStar/ : exp.* : =
exp/. {Complex[a_, b_] » Complex [a, -b] }
Protect[SuperStar];
The SuperStar/: notation above is redundant, but we include it so it is clear
which symbol is associated with this rule. (Try the definition without this assignment.)
We Protect [SuperStar] so that we don't erase this definition with the Clear
["Global1*"] command.
Let us test that this works. (Note, we enter this symbol as a superscripted asterisk.)
In [54]:= (a + ±b + ele)*
Out[54]= a- i e
Equivalently, we could write:
In [55] .-= SuperStar [a + 1 b + eie]
Out[55]= a- ib + e"ie
Contrast this with the built-in function Conjugate:
In [56] : = Conjugate fa + i b + eiel
Out [56]= e-i conjugate [e] + conjugate [a + i b]
The Conjugate function is more cautious as it does not assume {a, b, 6} are real (as
SuperStar does); however, for our examples, we'll find this SuperStar definition to
be better suited.
1.2.6 ¦ Immediate and Delayed Substitutions
Previously we used the "->" form of the substitution command—this makes an immediate
substitution, as opposed to a delayed substitution. Consider the following substitutions.
First, we use the immediate substitution, "->"
In [57]:= {x, x, x} /. {x -> Random[] }
Out[57]= {0.336606,0.336606, 0.336606}
Notice the elements of the list are identical. Contrast this with the case where we use the
delayed form of the substitution, ": >"
In[58]:= {x, x, x} /. {x :>Random[] }
Out[58]= {0.780078, 0.71793, 0.653235}
Here, the elements are all distinct because the right-hand-side of the rule (Random [ ])
was not evaluated immediately, but was delayed until after the substitution.
12 Chapter 1 Getting Started
1.2.7 ¦ Selecting Parts of Expressions
We often work with only a portion of a complicated expression. The Part command can
be used to extract the individual terms of the complete expression. Consider the relation
In[59]:= eql = alx+ a2x~2 + a3x~3 Sin[x/y];
You can extract the third term by entering
In[60]:= Part[eql,3]
Out[60]= a3x3 Sin [-1
LyJ
or equivalently
In[61]:= eql[[3]]
Out[61]= a3x3 Sin [-1
LyJ
Subexpressions can be obtained as follows:
In [62]:= eql [[3,1]]
Out[62]= a3
If I want the first and third parts, I enter:
In[63]:= eql [[{3,1}]]
Out[63]= alx + a3x3 Sin[-1
LyJ
Notice the additional curly braces {} and compare with the previous expression. If you
didn't know the position of Sin [x/y], then you could have entered
In [64] := position = Position [eql. Sin [x/y] ]
Out [64]= {{3,3}}
You can also replace a term in an expression with a new term using the command Re-
placePart [expr,new,n]. This command replaces the nth part of expr with new.
Let us replace Sin [x/y] with Cos [x/y] in eql at position.
In[65]:= ReplaoePart[eql, Cos[x/y] , position]
Out [65]= alx + a2x2 + a3 x3 Cos [-1
LyJ
1.2.8 ¦ Algebraic Equations
Consider solving algebraic equations such as a x2 + b x + c == 0. The symbol == is
used to define the algebraic equation. (Recall the single symbol = creates an assignment.).
The principal Mathematica commands for symbolically solving equations include Solve,
Reduce, Eliminate, and Roots. If we take the quadratic equation as an example:
1.2 Arithmetic and Algebra 13
In [66] := eql = a x~2 +b x + c==O;
the Solve command returns two solutions.
In[67];= soil = Solve[eql, x]
-b - Vb2"- 4ac-
The solution is returned in the form of a rule, and these rules are strung together into a
list. The substitution operator (->) allows the solution to be substituted at a later time into
any expression containing x. If only the second root is desired, it can be selected using the
Part command discussed earlier; we use the short-hand form of the Part command by
appending [ [ 2 ] ] to the end of the solution:
In[68]:= x/.soll [ [2] ]
-b + Vb2 - 4 a c
Out[68]=
2a
A similar command follows for taking the first solution in the list. The roots can be
verified by substituting soil back into the original equation:
In[69]:= eql/.soll//Simplify
0ut[69]= {True, True}
The solution also follows from the commands Roots and Reduce:
In[70]:= Roots[eql, x]
Out[70]= x== l|x==
2 3. 2. 3l
In[71]:= Reduce[eql, x]
2a
a == O&fcb == 0&&c == 0 |
c
a == 0&&x == —&&b f 0
b
Roots and Reduce returned the logical set of solutions to the equation.The operator II
is the logical OR function, && is the logical AND function, and + (or ! =) means not equal
to. Reduce returns a complete set of solutions and does not assume that the parameters in
an equation are generic; i.e., that {a^O,b^O,...}.
Let us consider the solution for two coupled equations:
In [72] .- = eq2 = {ax + by==c,ax-by==d};
14 Chapter 1 Getting Started
Using Reduce to get the solution, we find
In[73] : = eq3 = Reduce[eq2, {x, y}]
Out [73]= a == 0&&b == 0&.&.C -= 0&&d == 0 | |
a == 0&&d == -c&fcy == -&&;b t 0 | |
b
b == O&fcd == C&.&X == —&&a f 0 | |
a
c + d c-d
x == ——&&y == &&a + 0&&b * 0
2 a 2 b
Reduce tries to search for all possible solutions, and therefore takes longer than Solve.
As before, the desired part of the solution can be extracted using the Part command—we
use the syntax [[4,{1,2}]] to extract the first and second sub-part of the fourth part.
In[74]:= eq3[[4, {1,2}]]
c + d c-d
Out [74]= x == &&y == ——
2 a 2 b
If you want to restrict a and b to be nonzero at the start, then enter
In[75] .-= eq3 = Reduce [{eq2, a * 0, b f 0}//Flatten,
{x,y}]
Out [75]= x == &&Y == &&a t 0&&b t 0
2 a 2 b
where Flatten returns a flat list of equations without any sub-lists.
1.3 ¦ FUNCTIONS AND PROCEDURES
1.3.1 ¦ Built-in Functions
Mathematica has many built-in functions, including Sin [x], ArcCos [x], Cosh [x],
ArcSinh [x], and Bessel J [n,x]. In the following, we input these functions in Stan-
dardForm (so you know exactly what we typed), and the output is displayed in Tradition-
alForm.
In[76]:= listl = {Sin [x] , ArcCos [x] , Cosh [x] ,
ArcSinh [x], Bessel J [n, x] }
Out [76]= {Sin[x] , ArcCos [x] , Cosh[x] ,
ArcSinh [x] , Bessel J [n, x] }
These functions can, of course, return numerical values:
In[77]:= listl/. {x-» 0.5, n-» 2}
0ut[77]= {0.479426,1.0472,
1.12763, 0.481212, 0.030604}
1.3 Functions and Procedures 15
All Mathematica functions start with a capital letter; for this reason, we generally create
variables whose names begin with a lower-case letter to avoid conflicts with any possible
Mathematica definitions.
Information about any specific function can be obtained by prepending ? to the function:
In[78]:= ?Sin
Sin[z] gives the sine of z. More...
By prepending ?? to the function, we can obtain additional information.
In[79]:= ??Sin
Sin[z] gives the sine of z. More...
Attributes[Sin] = {Listable, NumericFunction, Protected}
In this case, we learn that the Sin function has Listable as an Attribute. This
means that the Sin function can be trivially applied to a list of objects:
In [80] .- = list = {0, 45, 90, 180, 270 , 360}*°;
Above, the Degree command " °" is a defined constant that will convert degrees to
radians. We now apply Sin to the list.
In[81]:= Sin[list]
0ut[81]= (o, -^=, 1, 0, -1, 0
Note that in a Fortran or C program this operation would require writing a loop state-
statement. This example gives us a glimpse at the features that make Mathematica programming
much more flexible than traditional programming languages.
1.3.2 ¦ User-Defined Functions
A frequently used feature of Mathematica is the ability to define your own functions. A
simple example is
In [82]:= f 1 [x_] = x*2;
The variable x on the left-hand side of the equation represents a dummy variable; the
fact that this is a dummy variable is indicated by the underscore symbol "_" following the
x. Let's verify that this works:
In[83]: = fl[2]
Out[83]= 4
Had we not included the underscore symbol "_" in the definition, we would obtain a
function that would operate only on the specific variable with the label x and not on any
general variable.
16 Chapter 1 Getting Started
In [84] .-= f2[x] = x*2;
{f2[x],f2[2]}
Out[84]= {x2, f2[2]}
In the definitions of both f 1 and ?2, we used the "=" symbol to make an immediate
assignment. In most cases, this is what you probably want (and it executes faster if it suits
your purpose). However, there are instances where you require a delayed assignment via
use of the ": =" symbol. We illustrate with an example.
In [85]: =
a = l;
f3[x_] :
f 4 [x.]
= If [x
= If [x
?a.
s a.
r-1.
-1,
1];
l];
Here, we have created two functions. The first, f 3 uses the delayed assignment, ": =",
and the second, ?4 uses the immediate assignment, "=". Notice that the variable a is set
before the functions are defined. As long as we don't need to change a, the functions will
work as expected.
:= {f3 [2] , f4 [2] }
0ut[86]= {1, 1}
However, if we want to change the value of a, the function ?4 that uses the immediate
assignment, "=", will not work properly.
In[87]:= a = 3;
{f3[2],f4[2]}
0ut[87]= {-1, 1}
To see why, let's examine what Mathematica knows about the functions.
In [88]— ?f3
Global'f3
f3[x.] := If[x < a, -1, 1]
In [89]:= ?f4
Global> f4
f4[x.] = If[x < 1, -1, 1]
Now the problem is obvious; the function f 3 used the delayed assignment, ": =", so
that it always uses the current value of a. In contrast, the function ?4 used the immediate
assignment, "=", so that it immediately evaluates the right-hand side of the function defini-
definition and substitutes the value 1 for a; once this value of a is "hard-wired" into the function,
no later re-definitions of a will change the function f 4. Let us clear the assignment to a,
In [90]:= Clear [a]
1.3 Functions and Procedures 17
The factorial function provides a nice example of procedural programming. Although
Mathematica has a built-in factorial function (!), we can define our own using only two
definitions.
In[91]:= Clear[fao]
We clear any previous definitions of the function f ac with the command Clear simply
as a precaution.
In [92]:= fao[l] = 1;
fao [n_Integer?Positive] := nfac[n-l]
The first command simply defines the factorial of 1 to be 1. The second command states
that the factorial of n is simply n times the factorial of n-1; this recursion relation defines
the factorial function for any positive integer. To ensure that this definition is applied only
to the case of positive integers, we include some parameter checking in the definition. The
syntax n_Integer ensures that this definition will be used only if the argument is an
integer. The syntax ?Positive performs a test on the argument to ensure it is positive.
The combination of these checks on the input parameter ensures the rule will apply only to
positive integers. We check that this implementation is correct by evaluating:
In[93]:= {4!, fao [4] , fao [4.] , fao [-4] , fao [a] }
Out[93]= {24, 24, fac[4.], fac[-4] , fac[a] }
As promised, only arguments with positive integers are evaluated using this set of rules.
1.3.3 ¦ Pure Functions
In many cases it is desirable to define procedures using pure functions. Pure functions
differ from the ordinary functions we have encountered in only one respect—they do not
have a name. The command Function [x, body] defines a pure function where the
variable is x and body represents the body of the function. A trivial example of a function
with two variables is:
In [94]:= f 1 = Function [ {x, y} , Sin[x/y]];
fl[a,b]
Out[94]= Sin [§1
Clearly, in the definition of the f 1 function, a and b represent dummy variables. A
slightly different notation that accomplishes the same end is
In[95]:= f2 = (Sin[#l/#2]) &;
f2[a,b]
Out[95]= Sin [-1
18 Chapter 1 Getting Started
Pure functions are particularly useful when making substitutions in differential equa-
equations. For example, if we consider the differential equation below, and attempt to change
from the function x[t] to a different function y [t], the obvious substitution does not
work.
In [96]:= eql = x'[t] + ax[t];
eql/.{x[t] ^y[t] + b}
Out[96]= a (b + y[t] ) +x'[t]
However, if we use a pure function to implement the substitution, we obtain the correct
form.
In[97]:= eql/.{x^ (y[#] + bfi) }
Out[97]= a (b + y[t]) +y'[t]
We will return to this point in the following section on differential equations.
We can also use pure functions with the Select function to pick out terms that satisfy
a specific criteria. This is often useful when performing separation of variables in the case
of differential equations. Consider the following expression:
In[98]:= terml = (l + x)~2 A + y) ~2 //Expand
Out [98]= l + 2x + x2 + 2y+4xy + 2x2y + y2 + 2xy2+x2y2
We use Select to extract all terms that do not contain x.
In [99] : = Select [terml, FreeQ [#, x] &]
Out [99]= 1 + 2y+ y2
The expression FreeQ[#,x]& represents a pure function; this will return True if
the subexpression is free of x, and False otherwise. With the help of the logical NOT
function (!) we can also extract all terms that do contain x.
In [100]:= Select [ terml, ! FreeQ [#, x]fi]
Out [100]= 2x + x2 + 4xy + 2x2y+2xy2+x2y2
1.3.4 ¦ Assigning Rules and Restrictions to Functions
We can use the command syntax f: /lhs = rhs to associate the assignment lhs =
rhs specifically to the object f. For example, let us assign properties to i to make it
behave like a complex number V~^- Mathematica already has this symbol defined by
I, but this will give us some practice with function definitions. For i to be a complex
symbol, it must have the properties i1 = -1, i3 = -i, and i4 = +1. Consider the following
assignments to i:
1.3 Functions and Procedures 19
In [101] : = i/ : i~2 = -1;
i/ : i-3 = -i;
i/ : i-4 = 1;
Note that the syntax ": /" is necessary; otherwise Mathematica would attempt to asso-
associate the rule with the system-defined Power function, which is protected. (Try evaluating
i'2=-l.)
This basic pattern for complex multiplication can be extended to higher orders of mul-
multiplications by using Mod. The command Mod [m, n] gives the remainder on division of m
by n. We define the final condition with
In [102] .-= i/ : i~n.Integer := i"Mod[n, 4] /; n < 0 | |4 <n;
The notation n_Integer restricts n to be an integer. The syntax patt /; test
allows us to test whether n is less than zero or greater than 4 before we evaluate this
assignment. To show that our home-made i has the correct properties, we create a table of
tests:
In [103] : = Table [i~n= = I~n, n, -8, 8]/.i- > I
Out [103]= {True, True, True, True, True,
True, True, True, True, True, True,
True, True, True, True, True, True}
This verifies that our definition matches the built-in Mathematica definition.
Let us define the unit step function with the help of the syntax patt /; test. A
possible definition is:
In[104]:= Clear[stepl,step2]
In [105]:= stepl [x_] = 0/;x<=0;
stepl [x.] = 1/; 0 <x;
The restrictions on stepl have been placed on the right-hand side of the equation using
patt /; test.
An alternate definition where the restriction is placed on the left-hand side is:
In[106]:= step2[x. /; x <= 0] = 0;
Step2 [x. /; 0 <x] = 1;
With the format in step2, the right-hand side of these expressions is only evaluated in
the case where the argument satisfies the condition imposed on the left-hand side. We can
observe this with the Trace command. The Trace command generates a list of all ex-
expressions used in the evaluation of the argument, so we can see exactly what Mathematica
is doing.
In[107]:= stepl[-0.1] //Trace
Out[107]= {stepl[-0.1], 0/; -0.1 < 0}
20 Chapter 1 Getting Started
In[108]:= step2[-0.1] //Trace
Out[108]= {step2[-0.1] , {-0.1 < 0, True},0}
A third form of the unit step function can be created with the Which command.
In[109]:= step3[x_] : = Which[x <= 0, 0, x > 0, 1]
In[110]:= step3[-0.1] //Trace
Out [110]= {step3 [-0.1] , Which [-0.1 s0,0,-0.1>0,l],
{-0.1s 0, True}, 0}
Note that If command would also work for this simple example, but the Which com-
command can work in more general situations. Let's use Timing to see how the speed of the
functions compare.
In [111]:= {Tablet stepl[x], {x,-10000, 10000, 1}] //Timing//First,
Table[ step2 [x], {x,-10000, 10000, 1}] //Timing //First,
Table [ step3 [x] , {x,-10000, 10000, 1}] //Timing//First}
Out[111]= {3.76667 Second, 4.56667 Second, 4.18333 Second}
In this case, stepl is the fastest; in general, the speed will depend on the complexity of
your expressions and your tests. However, with these commands, you can easily evaluate
the most efficient means appropriate for your problem.
1.3.5 ¦ Module
Procedures that involve several steps can be conveniently combined using the command
Module. Effectively, you can think of this as a subroutine. Consider a procedure to input
a list of numbers, increment the numbers by a fixed constant, determine the maximum of
the list, and output the new list.
In[112]:= shift[list_] : =
Module [{newList, a = 1, max},
newList = list + a;
max = Max[newList];
Print ["The max of the new list is : ",
max];
Return[newList]
]
In[113]:= shift[{1, 2, 3}]
The max of the new list is: 4
Out[113]= {2,3, 4}
The first item to note in the definition of Module is the list of variables {newList,
a=l# max}; these are local variables defined only within the scope of the module
1.3 Functions and Procedures 21
shift. This important feature allows you to write a subroutine Module without the
danger of conflicting variables. We can verify that these are local to shift by evaluating
the following:
In [114]:= {newList, a, max}
Out[114]= {newList, a, max}
Clearly, these variables are unknown to the outside world. Coming back to the shift
module, in the second line the variable newList is the old list plus a constant a. Note
how the constant a is initialized to 1. In the third line, max is the Max of newLi st. Next,
we print out the statement of the max. Finally, our Module returns the value of newList
as the output.
An alternate definition of this function is:
In [115]:= shift2 [list., a. :1] : =
Module[{newList, max},
newList = list + a;
max = Max[newList];
Print ["The max of the new list is : ",
max];
Return[newLi st]
:= Shift2[{l, 2,3}, 2]
The max of the new list is: 5
Out[lie]= {3, 4, 5}
This function is similar to shift, but we now pass the value of a as a second argument.
We also provide a default value, so if we call shift 2 with a single argument, a takes on
the default value of 1.
:= Shift2 [{1,2,3}]
The max of the new list is: 4
Out[117]= {2, 3, 4}
1.3.6 ¦ rootPlot
Consider an example of a procedure that solves an equation numerically and plots the
roots in the complex plane. Before we create a module to perform these functions, let's go
through the steps individually. For the equation eql, we use NSolve to find the numerical
roots.
In [118] : = eql = 0 == 1 + x + 2x~2 + 3x~3 + 4x~4 + 5x~5;
NSolve[eql, x]
22
Chapter 1 Getting Started
Out[118]= {{x-> -0.789728},
{x^-0.32 6925- 0.674868 i},
{x-> -0.326925 + 0.674868 i},
{x-> 0.321789 - 0.588911 i},
{x-> 0.321789 + 0.588911 i}}
Recall that while it is not possible in general to solve a fifth-order polynomial equation
in closed form, Mathematica has no difficulty obtaining the numerical solution. Next, we
can place the real and imaginary parts of these roots into a list suitable for input for the
ListPlot command.
In[119]:= (list = {Re[x], Im[x]} /. NSolve[eql, x]) //
TraditionalFonn
Out [119] =
-0.789728
-0.326925
-0.326925
0.321789
0.321789
0
-0.674868
0.674868
-0.588911
0.588911
In [120] .= ListPlot [list, PlotStyle -> PointSize [0.03] ] ;
0
0
0
0*8 -0.6 -0.4 -0.2
-0
-0
-0
.6
.4
.2
.2
.4
.6
•
0.2
•
Now that we have stepped through the solution, we can combine these operations into
a single module.
In[121]:= rootPlot[equation., variable.:x,
opts ] := Module[{nSol,list},
nSol = NSolve [equation, variable];
list = {Re[x], lm[x]} /.nSol;
Return[ListPlot[list,
PlotStyle -> PointSize[0.03] , opts] ];
We include the argument opts (with 3 underscores) so that we can pass plot options
to ListPlot. The 3 underscores allow opts to match any sequence of zero or more
Mathematica expressions.
We leave it as an exercise to the reader to verify that the rootPlot [eql] command
generates the same output as above. Instead, we apply this procedure to the example x15 -
1 == 0. The plot of the roots is:
1.4 Packages
In[122] := rootPlot [x15 - 1 == 0, x, AspeotRatio -> l] ;
23
0.5
-1
-0.5
-0.5
•1
0.5
By setting the aspect ratio of the plot to unity, we can see that these roots lie uniformly
on the unit circle in the complex plane.
1.4 ¦ PACKAGES
1.4.1 ¦ Loading Packages
We make frequent use of the standard Mathematica packages. A complete list of Standard
Packages can be found in the Help Browser listed under Add-ons. The commands denned
in these packages must be loaded manually before you have access to them. Loading a
package can be done in several ways. Let us use the Graphics 'Graphics * package
as an example. First, we check to see if the package has already been loaded.
In[123]:= $Packages
Out[123]= {Utilities'Notation' , Global', System'}
Then we load the package using the command Needs:
In [124] := NeedsfGraphics'Graphics'"]
Let's verify that it now appears in the list of the contexts corresponding to all packages
that have been loaded in the current Mathematica session.
In[125]:= $Packages
Out[125]= {Utilities'FilterOptions',
Graphics'Common'GraphicsCommon',
Graphics"Graphics',
Utilities'Notation' , Global' , System'}
24 Chapter 1 Getting Started
Often, however, you will want to read in a particular package only if it is needed. The
command Needs tells Mathematica to read in a package if the context associated with
that package is not already in the list $ Packages. Some packages are not designed to be
loaded twice, and large packages may take a while to load. You should use Needs if you
are unsure whether you have loaded a particular package in your current session. Some
packages are set up so that when they are loaded, other related packages are automatically
loaded at the same time. Packages may have been loaded that you haven't explicitly read
in, so it is best to let Mathematica decide which packages need loading.
To see what functions are denned in Graphics 'Graphics *, we execute:
In[126]:= TGraphics'Graphics'*
Out[126]= BarChart LogLinearPlot
BarEdges LogListPlot
BarEdgeStyle LogLogListPlot
BarGroupSpacing LogLogPlot
BarLabels LogPlot
BarOrientation LogScale
BarSpacing PercentileBarChart
BarStyle PieChart
BarValues PieExploded
DisplayTogether PieLabels
DisplayTogetherArray PieLineStyle
ErrorListPlot PieStyle
GeneralizedBarChart PiScale
Histogram PolarListPlot
LabeledListPlot PolarPlot
LinearLogListPlot ScaledListPlot
LinearLogPlot ScaledPlot
LinearScale SkewGraphics
ListAndCurvePlot StackedBarChart
LogGridMajor TextListPlot
LogGridMinor TransformGraphics
LogLinearListPlot UnitScale
We see that PolarListPlot is denned by this package. To obtain more information
about this command, we use:
In[127]:= TPolarListPlot
PolarListPlot[{rl, r2, ...}] generates a polar plot, assuming that the ri
are equally spaced in angle. More...
Should you want to see the entire package enter !! Graphics * Graphics *.
As a second example, consider the package Calculus'VectorAnalysis' and
use these commands to create a rule that will relate Cartesian coordinates to spherical
coordinates. First, load the package using Needs
In[128]:= Needs["Calculus 'VectorAnalysis*"]
The command CoordinatesToCartesian [pt, coordsys] gives the Cartesian
coordinates of the point given in the coordinate system coordsys. The spherical coordi-
coordinates for {x, y, z} are
1.4 Packages 25
In [129]: = CoordinatesToCartesian [ {r, 6, <!>}, Spherical ]
Out [129]= {rCos[4>] Sin [6] , r Sin [6] Sin[4>] , r Cos [6] }
A rule for converting from Cartesian to spherical coordinates can be constructed using
Thread.
In [130] : = x2rRule =
Thread[{x, y, z}- > CoordinatesToCartesian[{r, 6, <!>}, Spherical] ]
Out[130]= {x->rCos[$] Sin[6],
y->r Sin[9] Sin [$] , z -> r Cos [6] }
Thread threads the rule -> over the components of the lists. For example,
In[131]:= x +y + z~2/.x2rRule//Simplify
0ut[131]= r2
which is what you would expect.
1.4.2 ¦ Contexts
We give only a very brief introduction to the command Contexts. We can see the list of
all Contexts known to Mathematical
In[132]:= Contexts[]
Out[132]= {Algebra'Algebraics'Private',
BoxForaT ,
BrowserCategoryLoad*,
Calculus'VectorAnalysis',
Calculus'VectorAnalysis'Private',
Chase',
Compile',
Conversion',
Debug',
Developer',
DSolve',
EllipFunctionsDump',
We've suppressed some of the output to save space.
You can also ask for the Context (singular) of the command PolarListPlot using
In[133]:= Context[PolarListPlot]
Out[133]= Graphics'Graphics'
Because PolarListPlot was denned by Graphics1 Graphics1, its context is
Graphics 'Graphics *. For a new variable, such as dummy, the context is
26 Chapter 1 Getting Started
In[134]:= Context[dummy]
Out[134]= Global'
Essentially all variables that the user creates will be in the Global * context. We can
use this information to our advantage in the following manner. Suppose you want to start
a new problem, but do not want any definitions created in the previous problem to con-
conflict with the new problem. The task is to clear all user-defined symbols. This is done by
executing the command
In[135]:= Clear [ "Global'*"]
Clear :: wrsym : Symbol SuperStar is Protected.
This has the advantage of clearing all variables denned by the user in the Global *
context, while not removing any commands defined by our packages because they are in
separate contexts such as Graphics 'Graphics *. Should you want also to remove all
the definitions created by the package Graphics * Graphics *, you can do this with the
command
In[136]:= Clear["Graphics'Graphics' *"]
The Clear [ "Global * * " ] command works nicely for cleaning our slate. However,
you may not want to erase all the user-defined commands. You can solve this problem
using Protect to keep these functions from being erased. For example, we define the
function dummy and Protect it
In[137]:= dummy[x.] = x;
Protect[dummy];
Now we can clear all Global variables:
In[138]:= Clear["Global'*"]
Clear :: wrsym : Symbol dummy is Protected.
Clear :: wrsym : Symbol SuperStar is Protected.
without erasing our definition for dummy,
In[139]:= ?dummy
Systern'Convert'TeXDump'ConvertMessageText[Global'dummy]
Attributes[dummy] = {Protected}
dummy[x_] = x
1.4.3 ¦ Shadowing
A common problem is the shadowing of a Mathematica command. For example, let us
execute the command EasterSunday before it is properly denned.
In[140]:= EasterSunday[2002]
Out [140]= EasterSunday[2002]
1.5 Calculus 11
Now, when we load the package Miscellaneous 'Calendar*, we obtain a shad-
shadowing warning message.
In[141]:= Needs["Miscellaneous'Calendar*»]
EasterSunday :: shdw : Symbol EasterSunday appears in multiple contexts
{Miscellaneous'Calendar', ... }; definitions in context Miscellaneous-
'Calendar' may shadow or be shadowed by other definitions.
When we try and use the EasterSunday command, we do not obtain what we want.
In[142]:= EasterSunday[2002]
Out[142]= EasterSunday[2002]
The problem is that there are two EasterSunday commands; one in the Global *
context, and one in the Miscellaneous 'Calendar * context.
In[143]:= Context[EasterSunday]
Out[143]= Global'
If we Remove the EasterSunday command in the Global * context,
In [144] .-= Remove [EasterSunday]
we are left with the EasterSunday command in the Miscellaneous 'Calendar *
context:
In[145]:= Context[EasterSunday]
Out[145]= Miscellaneous'Calendar'
Now this works as expected.
In [146]:= EasterSunday[2002]
Out[146]= {2002, 3, 31}
1.5 ¦ CALCULUS
1.5.1 ¦ Derivatives and Integrals
We will now examine some common techniques using derivatives and integrals. The gen-
general command for differentiation is D [ ?, {x, n} ]. Here are a variety of ways to compute
the first derivative of the function f [x] =x"n; they are all equivalent.
In[147] := f [x_] = x~n;
{D[x"n, {x, l}],D[x"n,x],D[f [x],x],
f [x] }
Out[147]= {nx+n, nx-1+n, nx, nx~1+n}
28 Chapter 1 Getting Started
The second derivative of x"n can also be written in a variety of ways.
In[148]:= {D[x"n, {x, 2}] , D[f [x] , x] , f" [x] }
-2+n
Out[148]= { (-1 +n) nx
(-l+n)nxin, (-1+n) nx+n}
Mixed derivatives are computed using the form: D [ f, {x, n}, {y, m} ].
In[149] := tennl =xy + yx + x/y;
D[terml, {x, 2},y]
Out [149]= 20x3+24xy3
Its mixed derivative is of order two in x and order one in y.
The syntax of the integration command for a definite integral is Integrate[f[x],
{x,xO,xl}], and Integrate[f[x],x] for an indefinite integral. For example:
In[150] := eql = Integrate [xa, {x, 0, 1},
GenerateConditions -»True]
Out [150]= If [Re [a] >-l, , f xadxl
L 1 + a Jo J
Note that Mathematica realizes the generic form of the answer is only true for particular
conditions. In particular, when a=-l, the integral is a logarithmic function.
In [151]:= eq2 = integrate [x,x]
Out [151]= Log[x]
If you want only the generic form of the integral, you can tell Mathematica not to
generate conditions.
In[152]:= eql = Integrate[xa,{x, 0, 1},
GenerateConditions -> False]
Out [152]=
1 + a
You can also explicitly tell Mathematica that Re [a] > -1:
In[153]:= Integrate[xa,{x, 0, 1},
Assumptions -> {Re [a] > -1}]
1
Out [153] =
1 + a
The command Integrate will also perform multiple dimensional integrals. Consider
the following example.
In[154] := Integrate [ 1, {x, 0, 1}, {y, 0, Vl-x2}]
Out [154]= j
1.5 Calculus 29
The outer variable y is integrated first, followed by the integration over x.
If an analytic solution is not found and you know the values of all the parameters, then
you can numerically integrate the function using NIntegrate. Consider the example:
In[155] := NIntegrate [Sin[z Sin[xy]], {x, 0, 1},
{y, 0,x}, {z, 0,x y}]
Out[155]= 0.0142666
1.5.2 ¦ Differential Equations
Mathematica can numerically and (in some cases) analytically solve differential equations.
Consider the harmonic oscillator equation,
In [156]:= eql = y" [t] + w2 y [t] == 0;
(Note, we indicate the second derivative using two single quote marks, y#' [t], not a
double quote mark, yn [t]) with the initial conditions
In[157]:= initial = {y[0] ==y0,y'[0] ==v0};
Appending the oscillator equation to the initial conditions, you get the list
In[158]:= eq2 = Append [initial, eql]
Out[158]= {y[0] ==y0,y'[0] == vO, <j2 y[t] +y"[t] ==0}
The analytic solution of eq2 follows from applying DSolve to the list:
In[159]:= eq3 =DSolve[eq2, {y[t] }, t] //Flatten
yO to Cos [t <j] + vO Sin[t to] i
Out [159]= |y[t]
The command Flatten removed one set of {} brackets in the result of DSolve.
1.5.3 ¦ Changing Variables and Pure Functions
It is often useful to express functions in a pure form when changing variables in a differ-
differential equation. For example, consider the differential equation
In[160]:= eql = ax"[t] tbx'tt] +ox[t] == 0;
Express this equation in terms of a new function y[t] denned by x[t]=y[t]+2. The
straightforward substitution x[t]->y[t]+2 does not generate what you want as it does not
transform the derivatives of x.
:= eql/.{x[t] ->y[t] +2}
Out[161]= c B +y[t] ) +bx' [t] tax" [t] == 0
The substitution works if you express the change in its pure form:
In[162]:= eql/.{x-> (y[#] + 2fi) }
30 Chapter 1 Getting Started
Out[162]= c B +y[t] ) +by'[t] +ay"[t] ==0
Note the parenthesis outside the symbol &, which delimits the Function. An alternate
form that produces equivalent results is:
In[163]:= eql/.{x-> Function [{t}, y [t] +2]}
Out[163]= c B + y[t] ) +by' [t] +ay"[t] ==0
You can use DSolve to easily get the correct form of a pure function.
In[164]-.= DSolve[{x[t] ==y[t] +2},x,t] //Flatten
Out[164]= {x-> Function [{t}, 2 + y[t] ] }
1.5.4 ¦ Numerical Solutions of Differential Equations
If a numerical solution is required, then NDSolve can be used. Consider the coupled
differential equations,
In[165]:= eql = {x"[t] == -x[t] -x[t] y[t],
y"[t] == -y[t] -x[t]y[t]};
along with the initial conditions,
In[166]:= initial = {x[0] == 2,x'[0] == 0,y[0] == 1,
y'[0] == 0};
The numerical solution of eql for t=0 to 20 is given by:
In[167] := ndsol =
NDSolve [Join [eql, initial], {x,y}.
Out [167] = {x -> InterpolatingFunction [
{{0., 20.}}, <>],y->
InterpolatingFunction[{{0.,20 .}}, <>] }
The numerical data are expressed by an InterpolatingFunction, whose values
are found by interpolation. The graphs for x[t] andy[t] are:
In[168]:= Needs["Graphics'Legend'"]
In[169] := Plot [{x[t] , y[t] }/.ndsol //Evaluate,
{t, 0,20},
PlotStyle ->
{{},{Dashing[{0.02}],
Thickness[0.008]}},
PlotLegend-» {"x[t]", "y[t]"},
LegendPosition -> {1, 0}
1.5 Calculus
31
-Graphics-
Here we have loaded the package Graphics'Legend' to make a legend for this plot.
The solid curve is the x[t] coordinate and the dashed curve is the y[t] coordinate. We
modified the line style of the graph with the PlotStyle command; this is a list contain-
containing the empty list, {}, which generates the solid curve, and {Dashing[{0.02}], Thick-
ness[0.008]}, which generates the thick dashed curve. The command Evaluate is required
to force the substitution of the ndsol rule.
You can also plot the solution in the {x#y} plane using ParametricPlot:
In[170]:= ParametricPlot[
{x[t],y[t]}/.ndsol //Evaluate,
{t,0,20}];
We ended the plotting command with a semicolon; this prevents "-Graphics-" from
being displayed below the figure. Compare with the previous figure without the semicolon.
One interesting feature of an InterpolatingFunction is that you can treat it just
as any other analytic function; in particular, you can differentiate it. Below, we plot the first
derivatives of x [ t ] and y [ t ]:
In[171] := Plot [{x' [t] .y1 [t] }/.ndsol //Evaluate,
{t, 0,20},
PlotStyle ->
{{ },{Dashing[{0.02}],
Thickness[0.008]}}];
32
Chapter 1 Getting Started
1.6 ¦ GRAPHICS
1.6.1 ¦ Using the Plot Command
We have already used the graphic commands Plot and ListPlot in the previous exam-
examples. Let us return to Plot to learn more details about the command. The command works
for singular, discontinuous, interpolating, conditional, and interpolating functions, and can
be embellished with various options. To view the options for Plot enter:
In[172]:= Options[Plot]
Out [172]= JAspectRatio-
GoldenRatio'
Axes -> Automatic, AxesLabel -> None,
AxesOrigin -> Automatic,
AxesStyle -»Automatic,
Background -> Automatic,
ColorOutput -> Automatic, Compiled -> True,
DefaultColor -»Automatic, Epilog -» {},
Frame -> False, FrameLabel -> None,
FrameStyle -> Automatic,
FrameTicks -»Automatic, GridLines -»None,
ImageSize -> Automatic, MaxBend -> 10 .,
PlotDivision -» 30 ., PlotLabel -» None,
PlotPoints -> 25, PlotRange -> Automatic,
PlotRegion ->Automatic,
PlotStyle -> Automatic, Prolog -> {},
RotateLabel -> True, Ticks -> Automatic,
DefaultFont :-> $DefaultFont,
DisplayFunction :-> $DisplayFunction,
FormatType :-> $FormatType,
TextStyle :-> $TextStyle|
Numerous rules can be used to control the output. In this example, we use the option
PlotStyle to change the thickness and color.
1.6 Graphics
33
In[173]:= ptl = Plot [ 1 / A - x~2) , {x, -10, 10},
PlotStyle- >
{ Hue[0.8] ,Thickness[0.008] }];
Note that although this function is infinite at x={+l# -1}, Mathematica has no diffi-
difficulty drawing it.
While you cannot see the color of the line in this black and white book, it is still useful
to know how to deal with colors. In our own notebooks, we often find it useful to define
the following commands:
In [174] := colors =
{red, green, blue, cyan, magenta, yellow} =
{RGBColor[l, 0, 0],RGBColor[0, 1, 0],
RGBColor[0, 0, 1] , CMYKColor [1, 0, 0, 0],
CMYKColor[0, 1, 0, 0],
CMYKColor[0, 0, 1,0]}(
A quick way to see these different colors is with the command:
In[175]:= Plot [Table [ix , {i, 6}] //Evaluate,
{x, 0, 1}, PlotStyle -> colors ];
0.2
0.4
0.6
O.i
(You will have to execute this on a color monitor to see what these lines really look like.)
For a wider range of colors, you can use the function Hue [h] where the parameter h
ranges between 0 and 1. Hue provides a simple way to generate an arbitrary number of
34
Chapter 1 Getting Started
different colors. The following example will generate n colors, where n can be as large as
you like.
In [176] := n = 13;
hues = Table [Hue [i/n], {i,n}];
Plot[Table[i x, {i, n}] //Evaluate,
{x, 0, 1}, PlotStyle- >hues];
12
10
8
6
4
2
0.2
0.4
0.6
1.6.2 ¦ Animated Plots
A very powerful feature of Mathematica is the ability to animate plots. The basic idea
is that you first generate an array of graphics, and then Mathematica will display them
sequentially to simulate motion. The package Graphics * Animation* has some useful
commands that help display animations. We load this with the Needs command.
In[177]:= Needs["Graphics'Animation1"]
This package contains the command Animate, which we can use to animate a traveling
wave. Here, we generate a number of plots that can then be animated. We set f rames=l
here simply to save space; the command will work for arbitrary frames.
In [178] := frames = 1;
Animate [Plot [Cos [2jt(x-t)], {x, -2, 2},
PlotRange- >{-!,!},
Axes->False],
{t, I/frames, 1, I/frames}]
1.6 Graphics 35
A more interesting example is demonstrating how a standing wave is composed of two
individual plane waves moving to the left and the right.
This package contains the command Animate, which we can use to animate a trav-
traveling wave. Here, we generate a number of plots that can then be animated. We set
frames=l. 1 here simply to save space; the command will work for arbitrary frames.
In[179]:= f rames = 1.1 ;
Animate[
Plot [ {Cos [2jt(x -1) ], Cos [2jt(x + t) ],
Cos[2jr(x-t)] +cos[27T(x + t)]},
{X,-2, 2},
PlotRange-> {-2,2},
Plotstyle ->
{blue, green, {red. Thickness [0.008] }},
Axes -> False],
{t, I/frames, 1, I/frames}]
In this figure, the green and blue curves represent traveling waves moving to the left and
right. The red curve is the sum of the blue and green, and represents a standing wave.
1.6.3 ¦ Vector Field Plots
A useful two-dimensional plot for physics applications is PlotVectorField. We define
a two-dimensional vector field as follows:
In[180] := vector = {1/x, 1/y};
We then load the package Graphicsl PlotFieldl.
In[181]:= Needs["Graphics * PlotField»"];
The package Graphicsl PlotFieldl contains the command PlotVectorField.
For example, we have:
In[182]:= PlotVectorField[vector, {x, -5, 5,2},
{y, -5, 5, 2},
ScaleFunction -> (Is), PlotPoints -> 20];
36
Chapter 1 Getting Started
V y_
V \
* ' 4 4
tl 4
'4 ' 4
'4 '*
\ \ \ \ \ \ y^^_
t * ^ 'i } "t "- v
^ i
i i
i *
i i
! i f / ^ ' ^ l
i i i I tr ' ^
i / / / /*'J*"'^
/ / / Z^*''
—
4 f
t j ¦ t
t i
.\\\
The option ScaleFunction is a function used to determine the length of the vectors.
Here we have set this function equal to a constant (one) so that all the vectors are the
same length; this is sometimes useful when the function has singular values such as we
encounter in the case of a point charge. (As an exercise, re-generate this plot without the
ScaleFunction option.)
You can also plot a three-dimensional vector field with the package: Graphics-
*PlotField3Dl.
In[183]:= Needs[raphios*PlotField3D*"];
In[184]:= Plot6radientField3D[
1/Sqrt [x~2 + y~2 + z~2] ,
{X, -5, 5, 2}, {y, -5, 5, 2}, {z, -5, 5, 2},
ScaleFunction -> (Is),
VectorHeads -> True];
1.6 Graphics
37
Because this function is singular at the origin, it is particularly useful to set Scale-
Function to a constant. (Again, re-generate this plot without the ScaleFunction
option.)
1.6.4 ¦ Three-Dimensional Graphics Using Plot3D and ParametricPlot3D
To illustrate the use of three-dimensional graphics, we plot the imaginary part of the Sqrt
function.
In[185] := Plot3D[Sqrt[x+ Iy]//Im, {x, -1,1},
{y,-1, 1},
PlotPoints ->25,
AspectRatio -> 1,
AxesLabel -> {"Re", "im", ""}];
Re
This clearly illustrates the branch cut running along the negative real axis. A better way
to illustrate this is with the CylindricalPlot3D command denned in the Graph-
Graphics'ParametricPlot 3D* package.
In[186]:= Needs["Graphics'ParametricPlot3D1"]
In[187] := CylindricalPlot3D[Sqrt [r Exp[I6] ]//Un,
{r, 0, 10}, {6, -jt, 7t},
PlotPoints -> 25,
AspectRatio -> 1];
38
Chapter 1 Getting Started
-10
Another useful plotting command from the Graphics'ParametricPlot3D*
package is the SphericalPlot3D command. We will use this to view the Spheri-
calHarmonicY functions.
In[188]:= SpherioalPlot3D[
SphericalHarmonicY[2, 0, 6, <t>] //Abs //
Evaluate,
{6, 0, jt}, [<l>, 0, 2jt}, PlotPoints -> 50,
Boxed -> False, Axes -> False];
We used several options to enhance the plot.
The last example that we give is a parametric curve in space.
In[189]:= ParametricPlot3D[
{COS[2t + JT/4] + t/100, 2Cos[2t] + t/200, COS[3t]},
{t, 0, 100},
PlotPoints-> 3000];
1.7 Exercises
39
0.5
-0.5
1.7 ¦ EXERCISES
The solutions to many of these exercises can be found at our web site.
1.1 Real Expressions
(a) Reduce the following expression and show it is a real number l/(V3 + i) .
(b) Find the roots for the cubic equation, and show they are real: 22-10;c-20;c2 + ll;c3 ==0.
1.2 Series
(a) Find the first ten nonzero terms of the Taylor series expansion of Cos [x] and Sin [x].
(b) Determine the general expression for the nth term, and reconstruct the series by summing
this infinite series.
1.3 Integration
Integrate the function tfx A - t)~l~a+c t~1+a over the variable t for {t, 0,1} with the assump-
assumptions:
{Re[a]>0 && Re[-a+c]>0 && Re[x]<0}.
1.4 Superposition of Waves
Consider two oscillations of slightly different frequencies described by:
Cos [(«+<$«) t] + Cos[w t].
Plot the superposition of these two functions along with the enveloping curve for your choice
of parameters.
1.5 Tables of Zeros for Several Functions
Consider the functions HermiteH [n, x], BesselJ[n, x], LegendreP [n, x], and
LaguerreL[n,x].
(a) Plot these functions for the first four integer values of n.
40 Chapter 1 Getting Started
(b) Use Fin&Root to find the first zeros for each of these functions for the first four integer
values of n. Assume x is positive. Make a table of the zeros.
(c) Confirm the results in part b by using NSolve to find all the zeros.
1.6 Plot of Roots
Consider the equations
In[190] : = eql = x~7 +x~3 +x~2 + 1 == 0;
Plot the roots in the complex plane using x for the real axis and y for the complex axis.
1.7 Coupled Equations
Consider a unit circle (x2 + y2 = 1) and a parabola (x = Ay7- - 1). Find the intersection of these
two curves with the help of the package Graphics'ImplicitPlot'. Graph the solution.
1.8 Statistical Data
Consider a list of 1000 integers that have values between 1 and 20.
In[191] : = r = Table [Random [Integer, 1, 20], 1000];
Find the mean value of the list. Use the command Frequencies found in the Statis-
Statistics'DataManipulation' package to get a list of the distinct elements in the list.
Also find the frequencies with which they occur. Make a BarChart (found in Graph-
Graphics' Graphics * ) of the frequencies.
1.9 Differential Equations
Consider the differential equation m z''[t]==-m g-b z'[t]. Find the solution and plot
z [t] and z' [t] using suitable numerical values for {m, g, b}.
1.10 Coupled Differential Equations
Consider the two coupled differential equations x''[t]==-a x[t]+b y'[t] and
y"'[t]==-a y[t]-b x' [t]. Form one complex equation using the variable u=x+I
y and solve.
1.11 Trajectories and Vector Field Plots for Coupled Differential Equations
Consider the coupled equations y'[t] = y[t] - x[t] and x'[t] = 5y[t] - 3x[t]. Solve the equations
with arbitrary initial conditions. Plot the trajectories {x, y] for several different starting points.
Compare the trajectories with a vector field plot of [y - x, 5y - 3x}.
1.12 Heat Equation
Consider the heat equation ut - c uxx = 0 in the region 0 < x < 1 and for t > 0. Here,
the subscript notation on u represents a derivative with respect to either time (t) or space (x).
Assume the boundary conditions, u(x, 0) = a sinB7r x), w@, t) = w(l, t) = 0.
(a) Solve the equation using Laplace transforms.
(b) Numerically solve the equation for a=l and c=l.
(c) Compare and comment on the solutions to parts a and b.
1.13 Wave Equation
Consider the wave equation utt-c2uxx = 0 in the region 0 < x < lforf > 0. Here, the subscript
notation on u represents a derivative with respect to either time (f) or space (x). Assume the
boundary conditions u(x, 0) = asinB7rx), ut(x, 0) = 0, w@, t) = u(\,t) = 0 and
(a) Solve the wave equation using Laplace transforms.
(b) Numerically solve the equation for a=l and c=l.
(c) Compare and comment on the solutions to parts a and b.
1.7 Exercises 41
1.14 Fit to Data
Consider the data table:
In [192] := data =
Table[
{x, 5 Sin[3 7r x] +
Randam[Real,{-0.2,0.2}]}//N//
Chop[#, 10~-3]6, {x, 0,0.5, 0.05}];
(a) Fit the data to a power series in x. Plot the data points and the fitted curve to the data on the
same graph.
(b) Use NonlinearFit (found in the package Statistics 'Nonlinear Fit') to fit
the data to the function a Sin [b x]. Plot the fit and data on the same graph.
1.15 Rules Used to Solve Problems
Consider a list of 13 random integers between 0 and 100:
In[193]:= list = Random[Integer , {0, 100}]S/9
Range[13];
Find a rule that returns the four numbers in the sequence that sum to 100, or determine no such
solution exists.
1.16 Procedures to Select Numbers
Consider a list of 30 random numbers in the range from 0 to 20.
In [194] := list = Table [Random[Real, {0,20}], {i,30}];
Write a procedure that retains only those elements in the list that have values between 6 and
15, and rank these elements from largest to smallest. (Hint: use Select and Sort.)
1.17 Procedure to Select Certain Pairs of Points
Consider 1000 random pairs of real numbers in the range 0 to 1.
In[195] : = pairs = Table[Random[] , 1000, 2] ;
Select from the a list of pairs {x, y] those that satisfy the condition y > x.
(a) Plot the points above the line with one color, and those below with another.
(b) Use Module to make a user-defined function to select those points above the line. Com-
Compute the percentage of pairs above the line, and compare with your theoretical expectation.
1.18 Change
Make a procedure to count change. Initially, you may use U.S. currency, where a quarter is 25
cents, a dime is 10 cents, a nickel is 5 cents, and a penny is 1 cent. Given any amount of money,
determine how many quarters, dimes, nickels, and pennies are required for the change. Apply
it to several examples. Generalize this problem so that a quarter, dime, nickel, and penny have
a value equal to an arbitrary number of cents, and solve (e.g., quarter = 37 cents, dime = 13
cents, nickel = 8 cents, penny = 1 cent). For simplicity, assume quarter > dime > nickel >
penny = 1 cent.
1.19 Toss of a Die
The random roll of a die can be simulated by Random [ Integer, {1,6}].
42 Chapter 1 Getting Started
(a) Compute the average value of the throws of a die as a function of the number of throws,
and plot the result. Compare this with the theoretical expectation of the average of 3.5.
(b) Generate 25 sets each of 10 throws, 100 throws, 1000 throws, and 10000 throws. For each
set of 25 throws, display a bar chart displaying the frequency of each number thrown {1, 6}.
(c) For each set of 25 throws, compute the standard deviation of the average value of the sets.
How does this standard deviation compare to yjn, where n is the number of throws?
1.20 Three Dice
(a) Find the probability that when three dice are tossed, the sum of the numbers is 14.
(b) Generalize the above to the case where the sum of the numbers is n.
(c) Find the probability that in throwing a die three times in a row, you get a sequence of
ascending numbers, e.g., {2, 3, 5}.
1.21 Playing Darts and the Calculation of n
We can compute n using a Monte Carlo technique by throwing a dart at a square dart board,
and counting the number of times the dart lands within an inscribed circle. The ratio of these
areas is n/4.
(a) Generate 10,000 pairs of {x, y] points within a square centered at the origin with length 2
for each side.
In [196] : = list =
Table [{Random [Real, {-1,1}],
Random [Real, {-1, 1}] }, {i, 10}] ;
For this list, compute the number of pairs which lie within the unit circle centered at the
origin. The ratio of this number to the total number of pairs is our estimate of the ratio tt/4.
(b) Plot the [x, y} pair, and color the pairs inside the unit circle a different color than those
outside the unit circle.
1.22 Dropping Needles
Buffon's needle problem, first stated in 1777, involves dropping a needle on a lined sheet of
paper and determining the probability of the needle crossing one of the lines on the page.
Assume the length of the needle is one unit, and the distance between the lines is also one unit.
(a) How often will the needles hit the lines?
(b) Graph the simulation.
1.23 Pascal's Wager
If you throw a single die, the probability is 1/6 that a 1 will appear on the die. If you throw two
die, the probability is A/6J = 1/36 that a 1 will appear on both dice. This might lead one to
believe that given 18 throws of the dice, the probability is 18/36 = 1/2 that we get a 1 to appear
on both dice. This logic is flawed,
(a) Generate 1000 pairs of numbers in the range 1 to 6 to represent the throws of two dice.
In [197] .= pairs = Table [Random [Integer, {1, 6}] ,
{1000}, {2}]
Compute the percentage of pairs that have a 1 appear on both dice.
1.7 Exercises 43
(b) Solve the problem analytically, and find the number of throws necessary so that the proba-
probability of obtaining pairs that have a 1 to appear on both dice is 1/2 = 50%. Compare this
result with part a.
1.24 The Birthday Problem
Consider a random group of n persons. What is the minimum value of n such that there is at
least a 50% chance that two of the people in the group have the same birthday? (That is, the
day and month of their birthdays match, not the year.) Hint: the answer is smaller than most
people would guess.
CHAPTER
2
General Physics
2.1 ¦ INTRODUCTION
A brief view of the Mathematica language was presented in Chapter 1. In Chapter 2, we use
Mathematica to solve simple problems encountered in undergraduate physics. We choose
problems from classical mechanics, electricity and magnetism, and modern physics. The
simplicity of the problems allows the reader to concentrate on the Mathematica commands;
the more difficult problems are introduced in subsequent chapters.
This chapter is divided into four sections—Newtonian Mechanics in Inertial Frames,
Newtonian Mechanics in Rotating Frames, Electricity and Magnetism, and Modern
Physics. At the beginning of each section, a brief overview of the topic is presented.
A few remarks and an outline of the solution is given after the statement of the problem.
Suggested exercises are found in final section.
As in the previous chapter, we start by turning off the spell checker.
In[l]:= Off[General :: spelll];
Off[General :: spell];
2.2 ¦ NEWTONIAN MECHANICS IN INERTIAL FRAMES
2.2.1 ¦ Overview
Basic to any presentation of mechanics is Newton's Second Law, which states that an
external force acting on a particle will cause the momentum of the particle to change:
' dt
where p = mv is jhe momentum. In the special case of constant mass, this takes the
more familiar form F = ma. The force and momentum are vector quantities, and are rep-
represented by lists in Mathematica. The second law represents a set of three, second-order
differential equations for three-dimensional problems. As these are second-order differen-
differential equations, their solution requires the initial values of the position and velocity vectors.
Velocity and acceleration must always be defined relative to some frame of reference.
An inertial reference frame is one in which Newton's laws hold. All frames of reference
moving uniformly (no acceleration) relative to an inertial reference frame are likewise
44
2.2 Newtonian Mechanics in Inertial Frames 45
inertial. There is no preferred reference frame; this principle led to Einstein's theory of
relativity.
One of the simpler classes of problems is the motion of particles moving in a constant
gravitational field. The equations of motion for a particle moving in the {x, y} plane are
x"[t] = 0 and y"[t] = -g, where y is the projectile height, and x is the horizontal distance.
Once launched, objects such as baseballs, golf balls, or bullets are subject only to the
downward acceleration of gravity (if air resistance is neglected). In practice, however, the
air produces a resisting force. For low speeds the resisting force is proportional to the speed.
In other cases it may be proportional to the square of the speed, or some other power.
The equations of motion can be simplified if the force is conservative; that is, if it can
be written as F = - W, where V is the scalar potential. In a conservative force field the
total mechanical energy is conserved. An example of a conservative force is Newtonian
gravity between a particle of mass m and another of mass M separated by a distance r. The
gravitational force is
F = -G—
The total energy, kinetic energy plus potential energy, is conserved.
PROBLEM 1 Escape Velocity. Neglect air resistance and consider a particle tossed up-
upward from the surface of the Earth. From the conservation of energy it follows that the sum
of the kinetic and potential energies are constant. Use the conservation of energy to show
that the escape speed for the particle is about 7 miles/sec, or 11 km/sec.
Remarks and Outline The solution follows from applying energy conservation at the
Earth's surface and at infinity. The gravitational potential energy is U = — ^f^-. The numer-
numerical evaluation illustrates the use of the add-on packages Miscellaneous* Physical-
Constants1 and Miscellaneous'Units'.
Solution
As explained in Chapter 1, we clear any Global* variables that may have been previ-
previously denned in Mathematica.
In[2]:= Clear["Global'*"] ;
The kinetic energy T, potential energy U, and total energy of the particle at the Earth's
surface is
In[3] := T= (l/2)m v~2;
U = -G M m/r;
energy = T + U
mv2 GmM
0ut[3]= — —
If a particle just escapes from Earth's gravitational field, then the energy at infinity is
zero. The conservation of energy gives the equation energy=O, which can be solved for
the velocity v,
46 Chapter 2 General Physics
In[4]:= sol = Solve[energy == 0, v] [ [2]]
Out [41= v^ V V
where v is the escape velocity. Note we have kept only the positive solution by selecting
the second solution returned by Solve.
We now use the package Miscellaneous'PhysicalConstants'
In[51: = Needs["Miscellaneous'PhysicalConstants'"];
to evaluate the physical constants. We can see what constants are denned in the add-on
package using the command:
In[61:= PMiscellaneous'PhysicalConstants**
We've suppressed the output to save space.
We define a rule values to make the substitutions of the physical constants:
In[7] := values = {6-» GravitationalConstant,
r -> EarthRadius,
M -> EarthMass,
Newton -> KilogramMeter/Second~2};
Now we apply the substitutions to the result for the velocity:
In[8] := vO = v/.sol//.values//PowerExpand
„, 11180.7Meter
Out[8]=
Second
We use the command Power Expand to help cancel out the units; this command should
be used with care as it can lead to incorrect expressions when it expands noninteger powers.
The escape speed can be converted to different units with the command Convert
found in the package Miscellaneous 'Units'.
In[91:= Needs["Miscellaneous'
We can find the syntax and related information for the Convert command as follows.
In [10] : = TConvert
Convert[old, new] converts old to a form involving the combination of units
new. More...
We now convert the escape speed to km/s
In [11] .- = Convert [vO , KiloMeter/Second]
11.1807KiloMeter
Out[ll]=
Second
2.2 Newtonian Mechanics in Inertial Frames
and also to British units.
In [12] : = Convert [vO, Mile/Second]
6.94736Mile
47
Out [12] =
Second
PROBLEM 2 Projectile in a Uniform Gravitational Field. Consider a particle of mass
m moving in a constant gravitational field. Assume the motion is in the {x, z) plane. The
equations of motion arex"[t] = 0 and z"[t] = -g where z is the projectile height, and x is
the horizontal distance.
(*0.z0)
a. Solve the equations of motion for the trajectories that have the same initial and final
position but different final times. Plot the trajectories for several different final times.
b. Solve the equations of motion for trajectories with a given initial speed and angle.
Find the position of maximum height. Plot the trajectories for different initial angles,
and find the angle 6 that yields the maximum height.
Remarks and Outline We use DSolve to give the analytic solution for the equations
of motion. The boundary conditions (i.e., initial position and velocity) will allow us to
determine the constants of integration. There are several ways to plot the results and we
invite the reader to explore possibilities other than those presented here.
Solution
In[13]:= Clear["Global'*"] ;
a. The equations of motion for a particle of mass m moving in a constant gravitational
field are
In[14] := eql = {mx"[t] == 0,mz"[t] == -ing};
where z is the projectile height, and x is the horizontal distance. If the position at time t=0
is {x, z}={0,0} and the final position at time t=tl is {xl, zl} then the boundary
conditions are
In[15] := initiall = {x[0] == 0, x[tl] == xl, z[0] == 0, z[tl] == zl};
48 Chapter 2 General Physics
Joining eql with initiall and applying DSolve to the equations of motion, you get
In[16] := dsoll = DSolve [Join [eql, initiall], {x[t], z[t]}, t]//Flatten
r txl -gtlt2 +gtl2t + 2zlti
0ut[16]= [x(t) -+ —, z(t) -> — ^ }
Simplifying the results by grouping the terms in powers of time, you get
In[17]:= Map [Collect [#,t] ft, dsoll, {2}]
txl t(gtl2 + 2zl) gt2 i
)^z(t)^<^^}
0ut[17] =
The Map function applies the Collect function to the argument (dsoll) at level
{2}. This is complicated to say, but easier to understand with an example. Let's try the
same command, but replace the Collect function with a fake function "collect" (low-
(lowercase) so we can see where Hap maps this function.
In[18] := Map [collect [#, t]ft, dsoll, {2}]
txl
Out[18]= [collect (x(t) , t) -> collect
collect (z (t) , t) -> collect
tl
-gtlt2 + gtl2t + 2zlt
2tl
Plotting several curves on a single graph is a good way of observing the dependence on
a specific parameter such as the final time tl. Let us plot the trajectories for three different
final times tl= {5,10, 15} seconds, and for values of the parameters given by:
In[19] .- = valuesl = {xl-» 300, zl -> 0, g -> 9.8};
We could just use the command Plot (enter ?Plot to see its definition), but instead
we display the curves by plotting the projectiles at discrete time values; this is more work,
but the separation between the plot points allows us to infer the velocity at that position. We
plot the trajectories evaluated at discrete time points using ListPlot. The coordinates as
a function of t for these values become
In[20]:= coordl[t_, tl.] = {x[t] , z[t] }/.dsoll/.valuesl
9.8ttl2 - 9.8t2tli
}
Out[20]=
The path depends on the variable tl. We choose time values from 0 to tl in steps of
0.5 seconds, and form a table of discrete points along the trajectories.
In[21]:= points[tl_] : =
Table[coordl[t, tl] , {t, 0, tl, 0.5}]
A graph for the discrete points follows immediately from ListPlot.
2.2 Newtonian Mechanics in Inertial Frames
49
In[22]:= plotl[tl_] : =
ListPlot [points [tl] //Evaluate,
Plotstyle-> {Hue[0.8], PointSize[0.02]},
GridLines -> Automatic,
Display-Function -> identity]
The command plotl [tl] generates one plot for each value of tl. Note here that we
include the option Display-Function -> Identity to suppress the individual plot
generated by plotl from appearing separately. The best way to see what this does is to
execute the following command with and without this option in plotl.
A list of three plots with times tl= 5, 10 and 15 is generated by.
In [23] := Show [{plotl [5] , plotl [10] , plotl [15] },
Epilog->{
Text["tl= 5", ooordl[5/2,5],
TextStyle -> {FontWeight -> "Bold"}] ,
Text["tl = 10", ooordl[10/2, 10],
TextStyle -» {FontWeight -» "Bold"}] ,
Text["tl = 15", ooordl[15/2, 15],
TextStyle -> {FontWeight -> "Bold"}] },
DisplayFunction-> $DisplayFunction,
PlotRange -> All] ;
259
209
159
109
59
•UL
*>.
•tl
50
100 150 200 250 300
where the command Epilog was used to add labels to the curves. Notice we use a very pow-
powerful feature of Mathematica to place the text to label the curves. The coordinate of each
text label is computed by Mathematica individually; this ensures that if we later change the
values of specific parameters that the labels will be correctly placed in the new plot. Also
note that we must include the option DisplayFunction ->$DisplayFunction to
output the complete plot to the notebook, since we denned the plotl function with the
option DisplayFunction -> Identity.
b. Let us solve the equations of motion with initial speed vO and angle 6.
In[24] .-= initial2 = {x[0] == 0,x'[0] == vOCos [6] , z[0] == 0, z'[0] == v0Sin[6]};
The solution of eql with these initial conditions is:
50 Chapter 2 General Physics
In[25]:= dsol2 = DSolve[Join[eql, initial2] , {x, z}, t]//Flatten
Out[25]= [x-> Function [{t}, tvOCosF) ] ,
z -> Function [{t}, - BtvOSinF) - gt2 ) 1 }
Notice in the above result for dsol2 the solutions are returned in the form of a Func-
Function; this is because we asked for solutions of {x, z} rather than {x [t ], z [t ]}. (Com-
(Compare with the previous result for dsoll.) This has the advantage that it makes substitutions
easier when dealing with derivatives, as we will now demonstrate.
The time it takes to reach the highest point follows from taking the time derivative of
vertical coordinate z [t] and setting this to zero:
In[26] .- = eq2 = z' [t] == 0/.dsol2
0ut[26]= -BvOSinF) - 2gt) ==0
Note, the above substitution for z'[t] would not have worked if the solutions of {x, z}
were not returned as functions. Specifically, this does not work using the dsoll solution.
In[27]:= z'[t] == 0/.dsoll
Out [27]= z'(t) == 0
Continuing with the solution for the time it takes to reach the highest point, we solve
eq2 for the time:
In[28]:= tsol = Solve [eq2, t]//Flatten
Out [28]= 11 -» [
1 g >
The position of maximum height is obtained by evaluating {x, z} at this time:
In[29]:= {x[t],z[t]}/.dsol2/.tsol//Simplify
Out [29] = (V°2COS(9)Sin(9) v°2sin2(9)|
1 g 2g J
Let us plot three trajectories that have 6 equal to {n/S, 2n/S, 3n/$}. The positions of the
trajectories are plotted at discrete time points. We choose the numerical parameters,
In[30] := values2 = {g- >9.8, vO- >100};
and find that the coordinates for the trajectory with angle 6 are
In[31]:= ooord2 [t_, 6.] = {x[t] , z [t] }/.dsol2/.values2
Out[31]= [lOOtCos F) , - B00tSinF) - 9.8t2)}
Again we plot discrete time points along the trajectories for times from 0 to 20 seconds
in steps of 1/2 sec. We first define a function plot2 that will generate a graph for a specific
value of ft.
2.2 Newtonian Mechanics in Inertial Frames
51
In [32]:= plot2 [6-] : =
ListPlot[
Table[coord2[t, 6], {t, 0, 20, 1/2}] //Evaluate
PlotStyle -> {Hue[0.8], PointSize[0.02] },
GridLines -> Automatic,
Display-Function -> identity]
The graphs for 6 equal to {n/S, 2n/S, 3n/8} are given by:
In[33] := Show[plot2 [#]6/8{7t/8, 2jt/8, 3jt/8},
Epilog->{
Text [ = jt/8", coord2[5, jt/8],
TextStyle -> {FontWeight -> "Bold"}] ,
Text [ = 2jt/8", ooord2[5, 2jt/8] ,
TextStyle -> {FontWeight -> "Bold"}],
Text [ = 3jt/8", ooord2 [5, 3jt/8] ,
TextStyle -> {FontWeight -> "Bold"}] },
PlotRange -> {{0, 1000}, {0, 500}},
DisplayFunction- > $DisplayFunction,
FrameLabel-> {"x[t]", "z[t]"}
500
400
300
200
100
6=3.
•
•
• •
l'/e
.•
\
¦
• •
•
•
•
•
•
«
200 400 600 800 1000
Note that 6 = 2n/S = n/4 gives the largest range of these three values of 6. We can
prove this value of 6 is optimal as follows. First, we set our solution for {x, z\ equal to the
point of maximum horizontal distance: {xMax, 0}.
In[34] := eq3 = coord2 [t, 6] == {xMax, 0}//Thread
Out[34]= [lOOtCos F) ==xMax, - B00tSinF) - 9.8t2) == o}
and solve for {t,xMax}:
In[35]:= sol3 = Solve [eq3, {t, xMax}]
Out[35]= {{xMax-> 0., t -> 0.},
2040. 82 Cos F) Sin F) , t -» 20 .4082 Sin F) }}
52 Chapter 2 General Physics
The second solution corresponds to the physical one:
In[36]:= xMax = xMax/.sol3//Last
Out[36]= 2040.82CosF) Sin(S)
We find the extremum by finding where the derivative of xMax is zero.
In[37]:= -/. Solve [D[xMax, 6] == 0, 6]//Rationalize
7T
113'
«¦»»'-H-r Ml
We find the values of 6/n that maximize the horizontal distance are {-3/4, -1/4, 1/4,
3/4}. For our situation, 6/n = 1/4 represents our physical solution.
PROBLEM 3 Reflecting Trajectories. A girl stands a distance xO from a vertical wall
and throws a ball. The ball leaves the girl's hand at a height yO above the ground with
initial horizontal velocity vxO; assume the initial vertical velocity, vyO, is zero. When
the ball hits the wall, the horizontal component of velocity is reversed and the vertical
component remains unchanged. Solve for the motion. Plot the motion for several different
initial velocities.
VxO
Solution
In[38]:= Clear["Global' *"];
Let the coordinates of the particle be {x[t],y[t]}, where x[t] describes the hori-
horizontal motion and y [t ] describes the vertical motion. The initial position of the particle
at time t=0 is {x0,y0}, and we will take the wall to be at position x=0. The general
equations of motion in the {x,y} plane are given by.
In[39]:= {xEq, yEq} = [x[t] == xO + vxOt + -axt2,
y[t] = =y0+vy0t+-ayt2};
rules = {vyO -» 0, ax -» 0, ay -» -g};
{xEq, yEq} = {xEq, yEq}/.rules
gt2
Out[39]= (x(t) == tvxO +xO,y(t) == yO - — j
2.2 Newtonian Mechanics in Inertial Frames 53
In the above, we have made substitutions to reflect the fact that the initial vertical ve-
velocity is zero (vy0->0), the horizontal acceleration is zero (ax->0), and the vertical accel-
acceleration is due to gravity (ay-> -g). Since the wall does not affect the vertical motion, we
can find the solution for y [t ] immediately.
In[40] := ySol = DSolve [yEq, y, t] //Flatten
Out [40]= [y-> Function f{t},yO - ^— 1 }
The wall does change the sign of the velocity in the x-direction; therefore, the following
equation for x only is applicable before the ball hits the wall.
In[41] := xSol = DSolve[xEq, x, t] //Flatten
Out[41]= {x -> Function [ {t}, tvxO +xO] }
After the ball hits the wall, the horizontal velocity is reversed. Since we have placed the
wall at x=0, we can simply flip the sign of the x-component of position and velocity. We
do this with an If statement based upon whether the time is less than or greater than the
time the ball hits the wall, tWall.
In [42]:= position [t_] : =
If [t <tWall, {+x[t],y[t]},
{-x[t],y[t]}]/.ySol/.xSol
The time at which the ball hits the wall is when x [t ] =0.
In[43]:= tWall = t/. Solve [x[t] == O/.xSol, t] [ [1] ]
Out [43]= --^-
vxO
We choose some arbitrary numerical values for the parameters,
In[44] := values = {xO -» -100, g-» 9.8, yO -» 100}
Out[44]= {x0 -> -100, g-> 9.8, yO -> 100}
and we define a function that generates a plot for a specific value of the horizontal velocity,
vxO.
In [45] : = plot [v_] : = ParametrioPlot [
position[t] //.values/. {vxO -»v}//Evaluate,
{t, 0, 5},
DisplayFunction -> Identity] ;
We now plot the trajectories for a range of horizontal velocities.
54
Chapter 2 General Physics
In[46]: = Show[Table[plot[v], {v, 5, 50,5}],
DisplayFunction -> $DisplayFunction,
PlotRange-* {{-125, 0}, {0, 100}},
Epilog-> {Thickness [0.02], Hue [1.],
Line[{{0,0}, {0,100}}]}
100
-120 -100 -80 -60 -40 -20
Notice how we used the Epilog command to draw a colored line to represent the wall.
-bz'
mg
PROBLEM 4 Falling Projectile with Linear Air Resistance Drag. A particle of mass m
is subject to the constant pull of gravity (with acceleration g) and the force of air resistance.
The particle is dropped from a point x=0 and z=zO. The initial velocity is zero. The force
of the air resistance is assumed to be linearly dependent on the speed. The motion of the
projectile is described by the equation:
mz"[t] = -mg - bz'[t]
where -m g is the gravitational term, and -b z' [t] is the air resistance term. Assume
that b is greater than or equal to zero.
a. Solve the equations of motion for the particle's position and velocity if the initial
conditions are z' [0] =0 and z [0] =zO. Find the terminal velocity. Take the limit
of the solution as b->0 (i.e., no air resistance) to find the free fall solution.
b. Plot the particle's position as a function oft for b={0,l/2,l}.
c. Plot the particle's speed as a function of t for b={0,l/2,l}.
d. Construct an artificial table of data points for {t,z[t]} with an experimen-
experimental error in z[t] of 10%. Use Nonlinear Fit from the package Statis-
Statistics'NonlinearFit* to determine the coefficient of drag b from the data
points. Assume the form of the nonlinear fit is al + a2 t + a3 Exp[-a4
t].
Remarks and Outline This problem illustrates the use of the commands Limit,
Series, and Nonlinear Fit found in the add-on package Statistics ^Non-
linearFit V DSolve gives the analytic solution for the equations of motion in a
constant gravity field. Graphic options are used to embellish the plots.
2.2 Newtonian Mechanics in Inertial Frames 55
Solution
In[47]:= Clear["Global»*"] ;
a. The motion of the projectile is described by the equation:
In[48]:= eql = {m z" [t] = =-m g-b z'[t]};
Assume the initial position and velocity are
In [49]:= initial = {z[0] ==zO,z'[O] ==0};
The speed and position of the falling particle follow from applying DSolve to eql with
the appropriate initial conditions:
In [50]:= z[t_] =
z[t]/.DSolve[Join[eql, initial],{z},
t] //First //Simplify
zOb + gm I - e » m + m - bt
Out[50]= *
b2
In[51]:= v[t_] = z'[t]//Simplify
Out [51] =
_bt \
— 1 + e m gm
Obviously, we require b->0 for a physical solution so that the exponential term remains
finite. We can find the terminal velocity by taking the limit of the velocity as t->oo. Note
we first rescale the time by denning the positive parameter r=b t /m, and then take the
limit.
In [52] : = vTerminal = Limit [v [t] /. {t -> z m/b} , z -» <x>]
Out[52]= -??
b
The terminal velocity is finite because as a falling object picks up speed due to the con-
constant gravitational force, the resistive force grows in magnitude. Eventually the two forces
cancel, resulting in zero vertical acceleration, and thus constant downward component of
velocity. Our solution reduces to the standard free-fall solution in the limit b->0. To show
this, take the limits of zf and vf as b->0.
In [53]:= {zff, vff} = Limit [{z [t] , v[t] }, b -> 0]
Out [53]= {zO-^-,-gt}
The parameters {zff,vff} are the speed and position for the case of zero air resistance.
b. Plot the vertical position z [t] versus t for b={0,1/2,2} and for the following
values of the parameters:
56
Chapter 2 General Physics
In[54] := values = {g -» 9.8, m-» 1, zO -» 0} ;
For b nonzero, the time and position {t, z [t ]} are given by
In[55]:= pointZ [b_, t_] = {t, z[t] }/.values
9.8(-bt-e"bt + 1) I
Out[55]= t.
b2
Note that this definition of point will be indeterminant when b=0; therefore, for the
special case b=0, we define:
In[56]:= pointz[0, t_] = {t, zff }/.values
Out[56]= {t, -4.9t2}
Note that while the general definition of point [b_] will be ill-defined for b=0, Math-
ematica always applies specific definitions first; therefore, when b=0, the second definition
will always be used rather than the first.
For convenience, define a function to make a plot of{t#z[t]} for arbitrary values of
b:
In [57]:= plotZ [b_, hue.] : =
ParametricPlot [pointZ [b, t], {t, 0, 10},
Plotstyle ->
{Hue[hue],Thickness[0.008]},
DisplayFunction -> Identity
];
The arguments for the plotZ are b and the hue of the curve. To view the results we
apply Show with the option DisplayFunction->$DisplayFunction. Let us plot
several paths with different values of b. The list of plots for b= {0,1/2,1} is:
In[58]:= parti=
Show[Table[plotZ[b, b/2 ],
{b, 0,1, 1/2}],
DisplayFunction -> $DisplavFunction
-50
-100
-150
-200
-250
8 10
2.2 Newtonian Mechanics in Inertial Frames
We next define the text for the graphics.
In[59]:= textZ = {
Text[FontForm["b = 0",
{"Times -Bold", 12}], pointz[0, 7]],
Text[FontFonn ["b =1/2",
{"Times -Bold", 12}] , pointz[0.5, 7]]
Text [FontFonn["b = 1",
{"Times -Bold", 12}] , pointz[l, 7]]
}//Graphics;
57
Note how we compute the placement of the text labels dynamically with the point
function; this ensures that they will be properly placed even if we change parameters and
generate different curves. Combining the graphs and text, we obtain:
In[60]:= Show[{parti,textZ},
Frame -> True,
GridLines -»Automatic,
FrameLabel ->
{"time", "height",
"EffectofAirResistance", ""},
RotateLabel -> False,
DisplayFunction -> $DisplayFunction
o
-50
-100
height -150
-200
-250
-300
Effect of Air Resistance
N
\
\
0
4 6
time
10
We have included some Options in the Show command to enhance the plot.
c. We next plot the velocity as a function of time for b={0,1/2,1}. For b nonzero,
the time and position {t, z [t] } are given by:
In[61]:= pointV[b_, t.] = {t, v[t] }/.values
Note that this definition of pointV will be indeterminant when b=0; therefore, for the
special case b=0, we define:
58
Chapter 2 General Physics
In[62]:= pointv[0, t_] = {t, vff}/. values
Out[62]= {t,-9.8t}
Again, note that while the general definition of pointV[b_] will be ill-defined for
b=0, Mathematica always applies specific definitions first; therefore, when b=0 the sec-
second definition will always be used rather than the first.
For convenience, define a function to make a plot of {t, v [t] } for arbitrary values of
In [63]:= plotV[b_, hue_] : =
ParametricPlot[pointv[b, t], {t, 0,10},
PlotStyle ->
{Hue [hue] , Thickness [0.008] },
DisplayFunction -> Identity
Let us plot several paths with different values of b. The list of plots for b={0,l/2,l} is:
In[64]:= part2 =
Show[Table[plotV[b, b/2 ] ,
{b, 0, 1, 1/2}],
DisplayFunction -> $DisplayFunction
-20
-40
-60
-80
-100
We next define the text for the graphics.
In[65]: = textv = {
Text[FontForm["b = 0",
{"Times-Bold", 12}] , pointv[0, 7]],
Text[FontForm["b =1/2",
{"Times-Bold", 12}], pointv[0.5, 7]],
Text [ FontForm ["b = 1",
{"Times -Bold", 12}] , pointv[l, 7]]
}//Graphics;
2.2 Newtonian Mechanics in Inertial Frames
59
Note how we compute the placement of the text labels dynamically with the point
function; this ensures that they will be properly placed even if we change parameters and
generate different curves. Combining the graphs and text, we obtain:
In[66]:= Show[{part2,textV},
Frame -> True,
GridLines -> Automatic,
FrameLabel ->
{"time","speed",
"EffectofAirResistance", ""},
RotateLabel -> False,
Display-Function -> $DisplayFunction
Effect of Air Resistance
speed
0
-20
-40
-60
-80
-100
tin
\
0 2 4 6
time
10
We have included some Options in the Show command to enhance the plot.
d. For the specific case b=l/2, let us construct an artificial table of data points for the
time and position {t, zb} with a 10% Gaussian experimental error to simulate an actual
experimental measurement. We will use the command NormalDistribution, which
is found in the package Statistics'NormalDistributionV
In[67] := « Statistics'¦NormalDistribution1
We define the command gaussian that will generate a table of random numbers cen-
centered about 1 with a standard deviation of 0.1.
In[68]:= gaussian : =
Random[NormalDistribution[1, 0.1] ]
Table [gaussian, {i, 10}]
Out[68]= {0.93877, 1.02,0.971886, 1.00302,1.12965,
1.06752,0.816305,0.969329,1.05662,1.20211}
We next generate a table of data centered about z [t] with a gaussian error distri-
distribution.
60 Chapter 2 General Physics
In[69]:= data =
Table[{t, z[t]gaussian}, {t, 0, 40, 1}]/.
values/. {b-» 1/2};
listplot=ListPlot[data,
PlotStyle -> {PointSize[0.03] }];
20 30 40
-200
-400
-600
-800
Let us see if we can reproduce the analytic expression by fitting the data with some
function. We load the package Statistics'NonlinearFit1, which contains the
command NonlinearFit.
In[70]:= «Statistics'NonlinearFit'
We are interested in the command NonlinearFit and we can see the command usage
by entering:
In[71]:= TNonlinearFit
We've suppressed the output to save space.
We will now fit the data table to the functional form: al+a2 t+a3 Exp[-a4 t].
In[72] .-= fit = NonlinearFit [data,
al + a2t+ a3Exp[-a4t], {t},
{al, a2, a3,a4}]
Out [72]= -21. 0617t - 80 . 8972e~°-069815t + 93 . 0795
To see if this fit is close to the analytic solution, we plot the two results:
In[73]:= fitPlot =
Plot [{fit, z[t]}/.values/.{b-» 1/2}//
Evaluate, {t, 0, 40},
PlotStyle -> {{RGBColor [0, 0, 1] },
{RGBColor[l, 0, 0], Thickness[0.008]}}];
2.2 Newtonian Mechanics in Inertial Frames
61
-200
-400
-600
10
20
30
40
The curves match so closely, it is better to examine the ratio:
In[74]:= Plot [fit/z [t] /.values/, {b -> 1/2}//
Evaluate, {t, 0,40}];
1
0.5
-0.5
-1
10 20 30 40
We see the ratio matches very precisely except where z [t] is approximately zero, as
expected.
Finally, we overlay all the plots:
In[75]:= Show[listplot,fitPlot,
GridLines -> Automatic,
Frame -> True,
FrameLabel ->
{"time", "height", "ExperimentalData",
""},
RotateLabel -> False
0
-200
height -400
-600
-800
Experimental Data
a •
10
20
30
40
62
Chapter 2 General Physics
PROBLEM 5 Falling Projectile with Quadratic Air Resistance Drag. A particle of
mass m is subject to the force of gravity (with acceleration g) and the force of air resistance.
The particle is tossed upward and then allowed to drop back to earth. Also, assume the
particle is constrained to move only along the direction of the gravitational force. Assume
the force of the air drag is opposite the direction of motion, and proportional to the square
of the speed. The motion of the projectile is described by the equations
Upward motion
Downward motion
= -g--z'[tf
l = -*+^M2
where we assume b is positive. The two cases are necessary to ensure the drag is opposite
the direction of motion.
drag
gravity
a. Solve for the particle's upward position and velocity.
b. Find the time for the particle to reach the top of its trajectory, and then solve for the
downward position and velocity.
c. Plot the particle's motion and compare with the motion when there is no air resis-
resistance.
Remarks and Outline This problem is more complicated than the previous problem with
linear drag. This problem has both upward and downward motion that must be treated
separately because the direction of the drag is opposite the particle's direction of motion;
hence, the equations of motion are also more difficult to solve.
Solution
In[76]:= Clear["Global'*"];
a. The motion of the projectile is described by the equation:
In [77]:= eql[sign_] =
|m z" [t] == -m g- sign b z' [t]2j;
2.2 Newtonian Mechanics in Inertial Frames
63
where we insert the parameter sign to allow for upward (sign=+l) or downward
(sign=-l) motion.
Assume the initial position is zO, and the initial velocity is vzO . We can solve for the
position using DSolve.
In [78]:= dsolOfc =
DSolve[Join[eql[+l], {z'[0] ==vzO}],
{z}, t] //First //Simplify
Out[78]= [z -> Function [{t}.
bc2 +mLog
Cos
-Vb^/gt
Here, we discovered (by trial and error) that Mathematica found it easier to solve this
equation with only a single boundary condition, z# [O]==vzO. We now substitute this
solution into the remaining boundary condition,
In[79]:= o2sol=
Solve[z[0] == zO/.dsolOfc, o2] //First //
Simplify
mLog
Out [79]= c2->z0
and find that the final constant c2 is related to the initial height zO. We make this replace-
replacement in dsolUp:
In[80] := dsolOfc = dsolOfc/.c2sols
The solution for the position and velocity in the case of upward motion is:
In[81]:= {zOfc, VOfc} = {z[t], z'[t] }/.dsolDt>//
FullSimplify
Out [81]= -
bzO + -mLog
bvzO2
gm
1 +
mLog
Cos
- Tan"
VbvzO
- Tan
64 Chapter 2 General Physics
As a check, we verify that the result reduces correctly to the free-fall case without air
resistance.
In[82] : = {zOpO, VOpO} = Limit [{zOp, VOp}, b -> 0]
Out[82]= | - ^— + vzOt + zO, vzO - gt}
b. The solution for downward motion can be obtained from the previous result by re-
reversing the sign of the sign parameter. We can solve for the position using DSolve.
For the case of downward motion, the boundary conditions are slightly different; when the
projectile reaches the top of the trajectory at time timeTop, the velocity is initially zero
(z' [timeTop] =0), and the position is equal to zMax (z [timeTop] =zHax).
In[83]:= dsolDown=
DSolve[Join[eql[-l], {z'[timeTop] ==0}],
{z}, t] //First //Simplify
Out[83]= [z -> Function [{t}.
bc2 -mLog
Cosh
Again, we discovered (by trial and error) that Mathematica found it easier to solve this
equation with only a single boundary condition, z' [timeTop] ==0. We now substitute
this solution into the remaining boundary condition,
In[84]: = o2sol=
Solve[z [timeTop] == zMax/.dsolDown, e2]//
First//SiJBplify
Out[84]= {c2 -> zMax}
and find that the final constant c2 is simply the maximum height zHax. We make the
replacement in dsolDown:
In[85]:= dsolDown=dsolDown/.c2sol;
The solution for the position and velocity for the case of downward motion is:
In[86]:= {zDown, vDown} =
.dsolDown//FullSimplify
Out [86]= jzMax-
mLog
Cosh
timeTop-1)
2.2 Newtonian Mechanics in Inertial Frames 65
As a check, we verify that the result correctly reduces to the free-fall case without air
resistance:
In[87] := {zDownO, vDownO} =
Limit [{zDown, vDown}, b-> 0]
Out[87]= jzMax g(t - timeTopJ, g(timeTop - t)|
We can also find the terminal velocity by first re-scaling the time variable, and then
taking the limit as time becomes infinite.
In[88]:
Out[88]= -
:= vTerminal = Limit [vDown/.(t-» ")l ], z -> col
c. We plot the vertical position z [t] versus t for the following values of the parame-
parameters:
In[89] := values = {g -» 9.8, m-» 1, zO -» 0, b -» 0.1,
vzO -> +20};
The time the projectile reaches the top is determined when the upward (vXJt>=0) velocity
is zero:
In[90] .= timeTop = t/. Solve[VOp == 0/.values, t] //First
Out[90]= 1.12246
We can use this result to determine the maximum height (zMax),
In [91]:= ZMax = zOp/.values/. {t-»timeTop}
Out[91]= 8.12816
We now create functions that yield the full position and velocity results for any given
time:
In [92]:= zFull [tln_] t =
If [tin < timeTop, zUp, zDown] /.values/.
{t -»tin}
vPull[tIn_] : =
If [tin < timeTop, vup, vDown] /.values/.
{t-»tln}
Likewise, we create a similar set of functions that yields the position and velocity in the
case where there is no air resistance; for this simpler case, we need not distinguish upward-
and downward-going solutions.
In[93]:= zFullO [tin.] := zDpO/.values/. {t-» tin}
vPull0[tIn_] s= ropO/.values/, {t -»tin}
66
Chapter 2 General Physics
We now compare graphically the full solution with and without air resistance.
In[94]:= Plot[{zFull[t],zFullO[t]}, {t, 0,7},
PlotStyle-* {{Thickness [0.008]}, {}}];
20
-20
-40
-60
-80
-100
Similarly, we compare the full solution for the velocity with and without air resistance.
In[95] := Plot [{vPull [t] , vFullO [t] }, {t, 0,7},
PlotStyle-> {{Thickness [0.008]}, {}}];
20
10
-10
-20
-30
-40
-50
Clearly, the case with air resistance (thick line) has a terminal velocity that we find to
be:
In[96]:= {vPull[100] ,vTerminal}/.values
Out[96]= {-9.89949,-9.89949}
PROBLEM 6 Rocket with Varying Mass. A rocket is fired vertically upward with a
mass loss of -dm[t]/dt due to exhaust. At time t, it has velocity v relative to the Earth
(inertial frame). The exhaust leaves the rocket with velocity u relative to the Earth (inertial
frame). Let ve be the exhaust speed relative to the rocket or u= (v-ve). The sign of ve
has been chosen to be positive, so the exhaust velocity is directed toward Earth. The change
in mass —dm[t]/dt is a loss so it has a negative value (-dm[t]/dt < 0).
a. Show that the rocket's equation of motion is:
dv
dm
m — = +ve— m g
dt dt
2.2 Newtonian Mechanics in Inertial Frames 67
b. Assume a constant mass loss, and use DSolve to find x and v. Find the height of
the rocket when all the mass of the rocket has been used as fuel.
c. Plot the distance versus height for different exhaust speeds.
d. Solve the rocket equation by assuming it can be written as a power series in t.
Remarks and Outline The equations of motion are obtained by applying Newton's sec-
second law, dp/dt = F, to the combined Rocket+exhaust system. The solution of the differen-
differential equation is given by DSolve, and the results are plotted using ParametricPlot.
The solution can also be obtained by assuming a power series expansion in t. The series
solution reduces to a set of algebraic equations, and the exact solution is recovered after
summing the infinite series.
Solution
In[97]:= Clear["Global»*"] ;
a. Let v and m be the velocity and mass of the rocket at time t, ve be the exhaust
velocity relative to the rocket, and u be the velocity of the exhaust gas relative to the Earth,
i.e., u= (v-ve). At time t the mass is m, and at time t+<5t, the rocket mass is (m-<5m) and
the exhaust mass is (+<5m). The momentum of the rocket-exhaust system at time t and at
t+<5t are:
In[98]:= p[t] = m[t]v;
p[t+ 5t] = (m[t] -fim) (v + 5v) + (+5m) (v-ve);
In the expression for the final momentum, p[t+<5t], the first term represents the
rocket's momentum with the new mass value (m[t] -<5m) and new velocity (v+<5v). The
second term represents the momentum of the exhaust of mass (+<5m) moving with velocity
u= (v-ve) in Earth's inertial frame. The differential relations are
In [99]:= 5v = x"[t]5t;
fim = -m'[t]5t;
The momentum change is:
In [100]:= Ep = (p[t + 5t] - p [t]) //ExpandAll
Out[100]= m' (t)x" (t)Et2 + vem' (tNt +m(t)x" (tNt
Applying Newton's second law, dp/dt = F, we set the rate of momentum change equal
to the external gravitational force, F=-m g, and take the limit <5t->0:
In[101] := eql = -m[t]g == 5p/Et//EjcpandAll
Out[101]= -gm(t) ==vem'(t) + 6tx" (t)m' (t) +m(t)x"(t)
In[102]:= eql = eql/.5t-» 0
Out [102]= -gm(t) ==vem'(t) +m(t)x"(t)
68 Chapter 2 General Physics
where m' [t] is the rate of decrease of rocket mass. We observe that eql is the desired
equation of motion.
b. If we take the rate of mass change to be m' [ t ] = + Am and the initial mass at time
zero to be m [ 0 ] =mO, then the time dependence of the mass of the rocket is:
In[103]: = dsoll=
DSolve[{m'[t] ==-Am, m[0] == mO}, m, t] //
Flatten
Out [103]= {m-> Function [{t}, mO - tAm] }
The dsoll is expressed in pure form so that this substitution will work for derivatives
of m. We use dsol 1 to eliminate m[t] and m' [t] in eql:
ln[104]:= eq2 = eql/.dsoll//Simplify
Out [104]= (gt + ve)Am+ (tAm - mO)x" (t) == gmO
and we then solve for x'' [t]:
In [105]:= eq3 =
(Solve [eq2, x" [t] ] //First //First) /.
Rule -> Equal
gmO - (gt + ve) Am
Out [105]= x"(t) = =
tAm-mO
The substitution Rule-> Equal changes the rule to an equation. Applying DSolve to
eq3 with the initial conditions x[0]==0 andx' [0]==0, the solution for x[t] follows:
In[106]:= position =
x[t]/. DSolve [{eq3,x[0] ==0,x'[0] ==0},
x, t] //First //FullSimplify
Out [106]= (tBve-gt)Am+
2Am
2ve (mO - tAm) (Log (mO - tAm) - Log (mO) ) )
The speed follows from the time derivative of the position:
ln[107] := speed = D[position, t] //Simplify
Out [107]= -gt + veLog(mO) - ve Log (mO - tAm)
Notice, all the rocket's fuel is consumed after a time t=mO/Am. The rocket's height
when this occurs is
In [108] := height = Limit [position, t- >mO/Am]
Out[108]= -m°(gm°
2 Am2
2.2 Newtonian Mechanics in Inertial Frames 69
c. We use the command ParametricPlot to plot position versus speed for
different values of the exhaust speed ve. We choose the arbitrary parameters:
In [109] := values = {mO -» 100, Am-»10,g-»9.8};
and let t vary between t=0 and t=tf, where the time t?=mO/Am is the time it takes for
the rocket's mass to be consumed:
In[110]:= tf = (mO/Am)/.values
Out[110]= 10
A plot command that graphs the position and speed for a given value of ve is
Infill] := plotl [vein.] : =
ParametricPlot[
{position,speed}/.values/.
{ve -> vein}//Evaluate,
{t, 0, tf},
PlotStyle -> Thickness [0.01],
DisplayFunction -> Identity
The value of vein is input for the plotl function, and the rule ve->veln is used
to replace ve in the expressions for {position, speed}. We next use the Graphics
primitive to place a line at the elevation when the fuel is exhausted.
In[112]:= elevation [ve.] =
{Thickness[0.004],Hue[0.8],
Line[{{height,0},{height,10000}}]}/.
values// Graphics;
Superimposing the graphs for ve={100,200,300,400} and adding grahics options,
we get
In [113] : = Show [Table [ {elevation [ve], plotl [ve] } ,
{ve, 100, 400, 100}],
Frame -> True,
FrameLabel -> {"position", "speed",
"",""},
RotateLabel -> False,
PlotRange -> {{0, 4000}, {0, 4000}},
DisplayFunction -> $DisplayFunction
70
Chapter 2 General Physics
500 1500 2500 3500
position
d. We expand the equations of motion given by eq3 in a time series expansion and
solve for the unknown coefficients. We retain terms up to sixth order; this is sufficient to
demonstrate the pattern, and it is easy to increase the order. We take the following initial
conditions:
In[114] := initial = {x[0] ->0,x'[0] ->0};
order = 6;
We move the right-hand side of eq3 to the left-hand side and perform a Series expansion
in time:
In [115] := eq4 =
Series[eq3[[l]] -eq3[[2]], {t, 0, order}] /.
initial//Simplify
Out [115]=
x<3>@)-
veAirr
mO2
t +
veAm4
mO4
120
1
mO6
<8>
720
@) -
veAm
mO7
t6 +O(t7)
The solution of this differential equation now reduces to a set of algebraic equations by
setting the coefficient of each power of time to zero. We must solve for these variables:
In[116]:= variables=
Table[D[x[t], {t, n}], {n, 0, order + 1}]/.
Out[116]= {x@), x'@), x"@) , xC> @) , xD) @) , xE> @), xF> @), xG> @) }
The solution for the coefficients of t are given by
2.2 Newtonian Mechanics in Inertial Frames 71
In[117]:= soil =Solve[eq4 == 0,variables][[1]]
Solve :: svars : Equations may not give solutions for all "solve" variables.
veAm-gmO „, veAm2
^xC>@)
r „
Out [117]= |x"@)
mO ' '"' mO2
D) 2veAm3 ,R, ._, 6veAm4
3 ,x@)^
m0J mO4
,..,,„,
The series expansion solution for x [t] is
In[118]: = seriesl=
(x[t] + O[t]"order)/.soil/.initial//
ExpandAll
/ veAm g \ 2 veAm213
Out[ 118 = - =- t2 + -— +
\ 2mO 2 / 6mO2
veAm3t4 veAm4t5 R
i- + z~ +O(t6)
12mO3 20m04
You can sum this expansion to get an exact solution by noticing that the «th term has
the form
In [119]:= term[n_] =
—^-;
n(n+ 1)
except for the leading term that contains an extra factor: - A/2) g t2.
Let us verify that our expression matches the original series.
In[120]:= series2 = -A/2) g t~2 + Sum [term [n] , {n, 1, order - 2}] ;
seriesl == series2 //Normal //ExpandAll
Out[120]= True
We sum the infinite series to get the exact solution:
In[121]:= exact2 =
-(l/2)g t~2 + Sum [term [n] , {n, 1, o>} ]//
FullSimplify
tBve- gt)Am + 2ve(mO - tAm) Log (l- -^s)
Out [121]= !^!
2Am
which agrees with the previous solution obtained analytically in the previous section.
In[122]:= ((position == exaot2)
//HapAll[Together, #] &
//PoworExpand
//FullSimplify
)
Out[122]= True
72
Chapter 2 General Physics
PROBLEM 7 Keplerian Orbits. Consider the nine planets of our solar system.
a. For each of the nine planets of our solar system, verify Kepler's third Law, which
states:
jq Planet ~ ^Sun
Here, a is the semi-major axis, T is the period, and G is Newton's gravitational
constant.
b. Plot the orbits of the planets; let the unit of distance be one Astronomical Unit. To
make the plots readable, plot the inner four planets on one graph, and the outer five
on another graph.
Remarks and Outline While this problem is straightforward to compute for any single
planet, Mathematica is adept at handling lists, so we can use this problem to show off
this feature. Specifically, we use the arrays {mass,axes,period,e} to simplify this
calculation. Note how Mathematica threads most operations over lists automatically; in a
Fortran or C program, you would have to write a loop to perform the same operation.
Solution
In[123]:= Clear ["Global* *"];
a. We start by denning the following variables containing the necessary data. (Don't
type this data table in by hand; get the input files from our web site listed in the preface.)
In [124] : =
(*
Mercury
Venus
Earth
Mars
Jupiter
Saturn
Uranus
Neptune
Pluto
mass
= {3.3*10-23,
= {4.87 * 10-24,
= {5.974 * 10-24,
= {6.419 * 10-23,
= {18.99*10-26,
= {5.68 * 10-26,
= {8.68*10-25,
= {10.2 * 10-25,
= {1.27 * 10-22,
axes
0.5791*
1.0821*
1.496* 1
2.2794 *
7.784*1
14.27 * 1
28.71* 1
44.98* 1
59.506 *
10-11,
lO'll,
o-ii.
10-11,
o-ii.
o-ii.
o-ii.
o-ii.
10-11,
period
0.241,
0.615,
1.,
1.881,
11.86,
29.42,
83.75,
163.7,
248.,
6 *)
0.206};
0.007};
0.017};
0.093};
0.048};
0.054};
0.047};
0.009};
0.249};
This table lists the mass in kilograms, the semi-major axis in meters, the period in years,
and the eccentricity. You can consolidate the data for the nine planets by combining the nine
lists:
In[125] := data = {Mercury, Venus, Earth, Mars,
Jupiter, Saturn, Uranus, Neptune, Pluto};
It is also convenient to define a list of names of the planets."
In[126] := names = {"Mercury", "Venus", "Earth",
"Mars","Jupiter","Saturn","Uranus",
"Neptune","Pluto"};
2.2 Newtonian Mechanics in Inertial Frames
Now we can display this data in a convenient TableForm.
73
In [127]:= TableFor
m[data.
TableHeadings ->
{name
Out [127] =
Mercury-
Venus
Earth
Mars
Jupiter
Saturn
Uranus
Neptune
Pluto
is, {"Mass", '
Mass
3.3 xlO23
4.87 xlO24
5.974 x 1024
6.419 x 1023
1.899 x 1027
5.68xlO26
8.68xlO25
1.02 xlO26
1.27 x 1022
¦Axes", "Period"
Axes
5.791 x 1010
1.0821 xlO11
1.496 x 1011
2.2794 xlO11
7.784x10"
1.427xlO12
2.871 xlO12
4.498 xlO12
5.9506xl012
."}}]
Period
0.241
0.615
1.
1.881
11.86
29.42
83.75
163.7
248.
6
0.206
0.007
0.017
0.093
0.048
0.054
0.047
0.009
0.249
By transposing the data table, we can define the following variables:
In [128] .-= {mass, axes, period, e} = Transpose [data] ;
For example, we display the array period:
In[129]:= period
Out[129]= {0.241, 0.615, 1., 1.881, 11.86, 29.42, 83.75, 163.7, 248.}
We load the package Miscellaneous 'Units» to help us with conversion of units,
and we also load the package Miscellaneous * PhysicalConstants *, which con-
contains GravitationalConstant.
In[130]:= «Miscellaneous'Units'
« Miscellaneous'PhysicalConstants*
We collect some useful substitutions into values:
In[131]:= values = {
year2sec -> Convert [Year, Second] ,
6 -> GravitationalConstant,
Newton -> KilogramMeter/Second2 ,
AstronomicalUnit- > Convert [AstronomicalUnit, Meter] } ;
values //TableForm
Out[131]= year2sec -> 31536000Second
6 . 673 x 101Meter2Newton
G-> =
Kilogram
KilogramMeter
Newton -> =
Second
AstronomicalUnit -> 1.49598 x 10 Meter
74 Chapter 2 General Physics
Kepler's third law states:
4a3n2
= M + MPlanet
where the mass of the sun is MSun = 1.99 x 1030kg, and Newton's gravitational constant is
G 6.67xl(T^r.
kg
The data for the ratio 4a3n2/T2G for each planet follows from:
In[132]:= kepler =
4a3*2
—=—/. {a -» axes * Meter,
T -»period * year2sec}//.values
Out[132]= {1.98908x1030Kilogram,
1.99286 x 1030Kilogram, 1.99168 x 1030Kilogram,
1. 99118 x 1030Kilogram, 1.99464 x 1030Kilogram,
1.99716 x 1030Kilogram, 2.00704 x 1030Kilogram,
2.02016 x 1030Kilogram, 2.038 x 1030Kilogram}
We define solarMass to be the mass of the sun, MSm = 1.99 x 1030kg, and compare each
element in the list kepler with this value:
In [133] := solarMass = 1.99 * 1030Kilogram;
r kepler
TableForm ,
LsolarMass
TableHeadings -> {names}] //
PaddedForm[#,{4,3}]&
Out[133]= Mercury-
Venus
Earth
Mars
Jupiter
Saturn
Uranus
Neptune
Pluto
1.000
1.001
1.001
1.001
1.002
1.004
1.009
1.015
1.024
The results agree fairly well with the mass of the Sun for all the planets, and they
would be even closer if the parameters we input in the data table for the planets were more
accurate.
b. The relation between the radius, r, of the orbit and the angle, 6, depends on the
semi-major axis a, and the eccentricity, e:
a{l-e2)
A +?COS[0])
2.2 Newtonian Mechanics in Inertial Frames
75
As Mathematica is adept at handling lists, it is trivial to perform the computation for all
this planets at once. Note how we use the arrays {mass,axes,period,e} to simplify
this process.
In[134] := r =
Out[134]=
a(l-ea)
(l + eCos[6])
{a -> axes * Meter,
e -» 6}//.values
5.54525xl010Meter
0.206COS (9) + 1 '
1.08205 xlO^Meter
0.007 Cos (9) +1 '
2.25969 x 10"Meter
0.093 Cos(9) +1 '
1.42284 x 1012Meter
0.054 Cos (9) + 1 '
4.49764 x1012Meter
0.009 Cos(9) +1 '
T -> period * year2sec.
1.49557 xlO^Meter
0.017 Cos (9) +1 '
7.76607 xl0"Meter
0.048 Cos (9) +1 '
2.86466 x 1012Meter
0.047 Cos (9) + 1 '
5.58166 xlO12Meteri
0.249Cos(9) +1 1
We can convert from {r,6} coordinates to {x,y}={r Cos[0], r Sin[0]} as
follows:
In [135] := points =
Outer [#1 * #26, -.— ,
L AstronomicalUnit
{Cos[6], Sin[6]}]/.values
Out[135] =
0.206Cos(9) +1
0.723304Cos(9)
0.370677Cos(9) 0 .370677 Sin (9)
0.206Cos(9) +1
0.723304 Sin(9)
0.007 Cos (9) +1
0.99972 5 Sin(9)
0.017 Cos (9) + 1
1.51051Sin(9)
0.093 Cos (9) +T
5.19129Sin(9)
0.048 Cos (9) +1
9.51109 Sin(9)
0.054 Cos (9) +T
19.1491 Sin (9)
0.047 Cos (9) + 1
30.0648 Sin(9)
0.009 Cos (9) + 1
37.3111Sin(9)
0.007 Cos (9) +1
0.999725Cos(9)
0.017 Cos (9) +1
1.51051 Cos(9)
0.093 Cos (9) + 1
5.19129Cos(9)
0.048 Cos (9) +1
9.51109 Cos(9)
0.054 Cos (9) +1
19.1491 Cos (9)
0.047 Cos (9) +1
30.0648 Cos(9)
0.009 Cos(9) +1
37.3111Cos(9)
0.249COS (9) + 1 0.249Cos(9) + 1
Here, we use the command Outer to multiply the list of r values with the list of
coordinates{x,y}={r Cos [0], r Sin [0]}. Finally, we can display the orbit of the
planets as follows:
76
Chapter 2 General Physics
In[136]:= plotl = ParametricPlot[
points [[{1, 2, 3, 4}]]//Evaluate,
{6, 0, 2k], PlotRange ->A11,
AspectRatio -> 1];
The previous plot displays the first four orbits, and the next plot displays the outer five
orbits.
In[137]:= plot2 = ParametrioPlot[
points [[{5, 6, 7, 8, 9}]]//Evaluate,
{6, 0, 27T}, PlotRange -» All,
AspectRatio -» 1] ;
-40
You can display both plots side by side with the command GraphicsArray,
2.3 Newtonian Mechanics in Rotating Frames
In[138]:= Show[6raphiosArray [{plotl, plot2 }]] ;
77
2.3 ¦ NEWTONIAN MECHANICS IN ROTATING FRAMES
2.3.1 ¦ Overview
An inertial reference frame is one that is not accelerating; in such a special reference frame,
Newton's laws apply. In many cases, it is useful to discuss the motion of a particle, or sys-
system of particles, relative to a rotating coordinate system—this is a noninertial reference
frame. In this case, Newton's laws must be modified to yield correct results in the nonin-
tertial reference frame.
For example, Newton's second law in a rotating coordinate system becomes:
ma
= F — ml —^x r I - 2m(cox v) - mojx{ojx r)
V dt I
where o> is the angular velocity of the moving system and a is the acceleration relative
to the moving coordinates. If the angular velocity o> is assumed to be constant, the second
term on the right-hand side (proportional to dto/dt) vanishes. The last two terms are called
the coriolis and centripetal forces, respectively. The following terminology is often used.
Transverse force = -m((dto/dt)x r)
Centrifugal force = -mojx(cox r) (directed away from the center)
Centripetal force = +mtox(a)x r) (directed toward the center)
Coriolis force = -2m(cox v).
These forces are referred to as "fictitious forces" because they are a consequence of the
nonintertial frame; they are not present when using an inertial coordinate system.
PROBLEM 1 Projectile Motion as Measured by an Observer on Earth.
Earth is a sphere rotating about the z-axis with constant angular velocity w0.
Assume the
78 Chapter 2 General Physics
N I G>
Inertial Reference Frame
a. Find the equations of motion for a projectile as measured by an observer on Earth's
surface. Solve the equations by assuming a series expansion in time. Make a two-
dimensional plot of the approximate results for trajectories in the Northern and
Southern Hemispheres.
b. Solve for the exact answer at the North Pole and make a three-dimensional plot of a
trajectory.
c. Solve for the exact answer at the equator and make a three-dimensional plot of a
trajectory.
Remarks and Outline The equations of motion follow from Newton's second law as
expressed in a rotating coordinate system. In general the solution is very complex; however,
an approximate solution can be obtained by assuming a power series in time. The equation
can be solved exactly using DSolve for the special cases in which the motion is at the
poles or at the equator. This problem illustrates the use of vector products, the time series
expansion of differential equations, and three-dimensional graphics.
Solution
In[139]:= Clear["Global* *"] ;
a. Assume the Earth is a sphere rotating about the z-axis with constant angular velocity
ojO . Choose a coordinate system on Earth with the z-axis along the vertical, the x-axis
pointing south, and the y-axis pointing east. The position vector r and the Earth's rotation
vector o> in this rotating coordinate system are
In[140]:= r[t_] = {x[t] , y[t] , s[t] };
a [t.] = {-aO Sin [6] , 0, aO Cos [6] };
where the angle 6 is the colatitude, and f - 6 is the latitude. Here, we write o> [ t ] since this
is in general a function of t. For the present problem, o> [t] is a constant and to' [t] =0.
We simply compute each term in the modified form of Newton's second law:
ma
= \F\ -m\——xr\-'2m{ojxv)-mojx{ojxr)
V )inertial ^ at >
2.3 Newtonian Mechanics in Rotating Frames 79
We begin with the fictitious forces. The transverse force vanishes because we have a con-
constant angular velocity:
In [141] := f Transverse = -mCross [u' [t] , r[t]]
Out[141]= {0, 0, 0}
The coriolis and centrifugal forces are:
In [142] : = f Coriolis = -2mCross [a [t] , r' [t] ]
Out[142]= {2maHCos (9)}/(t) ,
-2m(wOCos (S)x' (t) + wO Sin (9) z' (t) ) , 2mwOSin (ejy7 (t) }
In[143]:= fCentrifugal=
-mCross [u [t] , Cross [a [t] , r [t] ] ] //
Simplify
Out[143]= {moH2 Cos (9) (Cos (9)x(t) + Sin (9) z (t)) ,
moH2y(t) , maH2Sin(9) (Cos (9)x(t) +Sin(9)z(t) ) }
Finally, the inertial force is
In[144] := fInertial = {0, 0, -mg};
Combining all these terms into Newton's second law, we obtain the equations of motion:
In[145]:= eql = m r"[t] - fInertial - fTransverse-
fCoriolis - fcentrifugal
Out[145]= {-mCos(9) (Cos(9)x(t) + Sin (9) z (t) )(J02-
2mCos (e)y' (t)u0 + mx" (t) , -my(t)w02 +
2m(w0Cos(9)x' (t) +w0Sin(9)z' (t) ) + my" (t) ,
-mSin(9) (Cos(9)x(t) + Sin (9) z (t) )uO2-
2mSin(9)y/ (t)w0 + gm + mz" (t) }
For the initial conditions, we take:
In[146] := initialRule =
Thread/9{r[0] -» 0, r'[0] ^ {1, 0, 0}}//
Flatten
Out[146]= {x@) -> 0, y@) ^ 0, z@) -» 0,
x' @) -»1, y7 @) -» 0, z' @) ^0}
We construct a time series solution in t to order nOrder for arbitrary 6.
In [147]:= nOrder = 0 ;
Note that we use a low-order expansion here to keep the expressions simple; it is trivial
to redo the calculation for higher orders. The expanded equations of motion become
80 Chapter 2 General Physics
In[148] := eq2 =
(Series [eql/m, {t, 0, norder}] == 0
/.initialRule//Normal //Thread//
Simplify)
Out[148]= {x" @) == 0, 2wOCos (9) +y" @) == 0, g+ z" @) == 0}
The variables for which we must solve are:
In [149] := vars =
Table [D[{x[t],y[t],z[t]}, {t,i}],
{i, 2, nOrder + 2}]/.t -» 0//Flatten
Out[149]= {x"@),y"@), z"@)}
and the solution is
In ^1507 : = sol = Solve [eq2, vars] // First
Out[150]= {x" @) -> 0, y" @) -> -2wOCos (9) , z" @) -> -g}
We create a function point that gives the {x, y, z} coordinate of the trajectory as a
function of time and angle. To the prescribed order, this expression is:
In[151]:= point [t_,6_] =
Series [r[t], {t, 0, nOrder + 2}]/.sol/.
initialRule//Normal
Out[151]= [t, -t2w0Cos (9) , -^—}
Notice the rotation modifies the motion along the y-axis. For Cos[0] > 0 the deflection
is clockwise, and for Cos[0] < 0 the deflection is counterclockwise.
To visualize the motion, we plot the trajectory in the {x, y} plane. Let us compare the
paths of a particle in the Northern Hemisphere @ = |) with a particle in the Southern
Hemisphere F = ^f). We define a plot function (lowercase to distinguish this from
Mathematical Plot function) that will show the trajectory as a function of the angle 6.
In [152] : = plot [e_] : = ParametricPlot [
{fiH-» 1, b-» 9.8}//Evaluate,
{t,0,20},
PlotStyle->{Thickness[0.016]},
AxesLabel -» {"x. South", ny. East"},
PlotRange-* {{0, 20}, {+200, -200}},
Ticks -> False,
DisplayFunction- >Identity]
We apply the plot function to a particle in the Northerm Hemisphere F= |, ai0=l) and
to a particle in the Southern Hemisphere {6=^f, o>0=l). Displaying the results, we get
2.3 Newtonian Mechanics in Rotating Frames 81
In[153] : = {plot [7T/4] , plot [37T/4] }//
Graphic sAr ray// Show;
y,East
¦ x,South
In the Northern Hemisphere (plot on the left), the trajectory is deflected to the right of its
initial path relative to the Earth's surface. In the Southern Hemisphere (plot on the right),
a horizontally moving particle is deflected to the left of its original direction of motion.
b. Next, we solve the equations of motion for the exact solution at the North Pole F = 0)
with the following initial conditions:
In[154] : = initial =
Thread/9
{r[0] == 0, r' [0] == {vxO, 0, 0}}//
Flatten
Out [154]= {x@) ==0,y@) ==0,z@) ==0,
x' @) == vxO, Y1 @) == 0, z' @) == 0}
The equations at the North Pole are
In [155] := eqNorth = Join [Thread [eql ==0], initial]/.
e-> o
Out[155]= {-mx(t)wO2 - 2my' (t)w0 + mx" (t) == 0,
-my(t)wO2 + 2mx' (t)w0 + my" (t) ==0,
gm+z"(t)m==0,x@) == 0, y@) ==0,
z@) == 0, x' @) == vxO, y' @) == 0, z' @) ==0}
An exact analytic solution is
In [156]:= solNorth =
DSolve[eqNorth, {x[t],y[t], z[t]}, t]//
First// FullSimplif y
Out[156]= |x(t) -» tvxOCos(twO) ,
y(t) -» -tvxOSin(twO) , z (t)
gt2
To generate numerical results, we choose some arbitrary parameters:
In[157] := values = {g-» 9 .8, zO-» 500, vxO -»1};
The {x, y, z} coordinates of the trajectory at the North Pole are:
82
Chapter 2 General Physics
In [158]:= pointNorth [ t_, wO_] =
r[t]/.solNorth/.values
Out[158]= {tCos (twO) , -tSin(twO) , -4.9t2}
We use ParametricPlot3D to graph the general space curve {x, y, z) at the North
Pole for zero rotational velocity (oiO = 0):
In[159]: = plotl = ParametricPlot3D[
pointNorth[t, 0] //Evaluate,
{t, 0, 10},
BoxRatios -> {1, 1, 1}] ;
-200
-400
2.5
We make a similar plot, but this time with a nonzero rotational velocity (o>0 = 0.01).
We also include some style information {Thickness [. 02] } to distinguish this curve.
In[160]:= plot2 =ParametriePlot3D [
Join[pointNorth[t, 0.01] ,
{Thickness [0.02]}] //Evaluate,
{t, 0, 10},
BoxRatios -> {1, 1, 1}];
2.3 Newtonian Mechanics in Rotating Frames
o
83
-200
-400
Finally, we use Show to overlay the plots so we can compare the effect of the rotating
reference frame.
Show[{plotl,
FaceGrids-
BoxRatios-
ViewPoint-
AxesLabel-
Plot2},
>{{0, 1,
> {1, 1, 1
>{1.5, -
0}, {-1,0,0}},
l.,0.7}.
> { "x - south" , "west" ,
nz-vertical"}
r
\
"X"
\
x-south
°2.5 5 7 5
-0.75 west
The thin trajectory on the right is for no rotation (o>0 = 0), and the thick trajectory on
the left is with rotation (o>0 = 0.01).
c. We now solve the equations of motion to obtain an exact solution at the equator
F = |) with the same initial conditions as in Part b. The equations at the equator are
84 Chapter 2 General Physics
In[162]:= eqEquator=
Join[Thread[eql == 0], initial]/. 6 ->jt/2
Out [162]= {mx"(t) == 0, -my(t)wO2 + 2mz'(t)wO + ray" (t) == 0,
-mz (t)wO2 - 2my' (t)wO + gm + mz" (t) == 0,
x@) == 0,y@) == 0, z@) == 0,
x'@) ==vx0,y'@) ==0,z'@) ==0}
and the solution is
In [163] : = solEquator =
DSolve[eqEquator, {x[t]#y[t]# z[t]}, t]//
First// FullSimplif y
g(Sin(twO) - twO Cos(twO))
Out[163]= |x(t) -> tvxO, y(t)
z(t)
wO2
g(Cos(tw0) + twO Sin (twO) -1)
wO2 J
The coordinates of the trajectory are
In[164] := pointEquator [t_, <tf0_] =
r[t]/.solEquator/.values
Out [164]= (t 9-8(sin(t(J°) -twOCos(twO))
L wO2
9.8(Cos(twO) + twO Sin(twO) - 1) -|
wO2 J
Here, we must exercise care to correctly obtain the limit oi0-»0:
In [165]:= pointEquator [t_, 0] =
Limit [pointEciuator [t, aiO] , aiO -> 0]
Out [165]= {t,0,-4.9t2}
Again, we use ParametricPlot3D to plot the general space curve {x, y, z}- While
this problem is virtually identical to Part b above, we will use a slightly more sophisticated
approach to generate the plots. We define a function plotEquator that takes arguments
for the angular velocity o>0 and the style (style) of the line.
In [166]:= plotEquator [a>0-, style_] : =
ParametricPlot3D[
join [pointEquator [t, oH], {style}]/.
values//Evaluate,
{t, 0, 10},
BoxRatios -> {1, 1, 1},
DisplayFunction -> Identity];
The plots for trajectories with rotation (o>0 = 0.01) and without rotation (o>0 = 0) are
shown.
2.3 Newtonian Mechanics in Rotating Frames
85
In 1167] := Show[
{plotEquator[0,
{Thickness[0.02],Hue[0.6]}],
plotE<iuator[0.01,
{Thickness[0.01], Hue[0.4]}]},
FaceGrids- > {{0, -1, 0}, {-1, 0, 0}},
BoxRatios- > {1, 1, 1},
Viewpoint- > {1, 0.7, 0.7},
AxesLabel- > {"x- South", "y-East",
"z-Op"},
DisplayFunction-> $DisplayFunction];
10
y-East 15
2.5
x-South
The thick trajectory on the left is for no rotation (o>0 = 0) and the thin trajectory on the
right is with rotation (o>0 = 0.01).
PROBLEM 2 Foucault Pendulum. Assume the Earth is a sphere rotating about the z-
axis with angular velocity o>0. Its rotation and gravity are assumed to be constant. Choose
a coordinate system with the z-axis along the vertical, the x-axis pointing toward the south,
and the y-axis pointing toward the east.
86
Chapter 2 General Physics
N to
Inertial Reference Frame
Earth Reference Frame
a. Find the equations of motion for a pendulum as measured by an observer on the
Earth's surface. Simplify the equations in the limit of small oscillations by neglecting
o>Q terms and assume the motion is confined to the horizontal plane. Show that in this
approximation, the motion of the bob is described by the two equations
x"[t] = -to2x[t]
cos[6]y'[t]
y"[t-\ = -oj2y[t]-2clJocos[0]x'[t]
where o>2 = | is the frequency-squared of the pendulum bob (a result familiar from
introductory physics).
b. Combine the real coordinates x[t] and y[t] into the single complex variable
u [ t]=x[t] + I y [ t ], and show that the equations in Part a reduce to one com-
complex equation for u [ t ]:
co2u[t] + 2ico0 cos[0]u'[t] + u"[t] = 0
Solve the u[t] equation and find expressions for x[t] and y [t]. Assume the
initial conditions are x[0]=0, x'[0]=0, y[O]=yO, andy'[0]=0.
c. Plot the motion of the pendulum at three angles: 6 = 0 (North Pole), 6 = § (Equator),
and 6 = n (South Pole).
Remarks and Outline French physicist Jean Bernard Foucault designed a pendulum in
1851 to prove that the Earth rotated about an axis. The pendulum consisted of a large
weight suspended by a long cable attached to a ceiling several stories high. The slow ro-
rotation of the plane of oscillation was the evidence Foucault needed to prove the Earth's
rotation. It is based on the concept that when a body is set in motion, it will move contin-
continuously in a straight line provided no outside forces alter the direction. Hence, the Foucault
pendulum must swing in a constant direction. If the Foucault pendulum is initially swing-
swinging toward a specific star, its direction will remain pointed toward that star until acted on by
an outside force. The rotation of the plane of oscillation is the result of the Earth rotating
in this plane.
The equations governing the Foucault pendulum are complicated. Mathematica can
solve the general system of equations, but to help make the physics evident, we will ex-
examine the solution in the limit of small oscillations. Specifically, we reduce the coupled
2.3 Newtonian Mechanics in Rotating Frames 87
equations of motion into a single complex equation. We then graph the trajectory of the
pendulum for the case of the equator and the North and South Poles. The graph of the
trajectory can also be computed from the original equations of motion without any simpli-
simplifications if the command NDSolve is used to get a numerical answer; we leave this as an
exercise to the reader.
Solution
In [168] : = Clear ["Global' * "] ;
a. Assume the Earth is a sphere rotating about the z-axis with constant angular velocity
o>0. Choose a coordinate system on Earth with the z-axis along the vertical, the x-axis
pointing south, and the y-axis pointing east. The position vector r and the Earth's rotation
vector o> in this rotating coordinate system are
In[169]:= r[t_] = {x[t] , y[t] , z [t] };
<tf[t_] = {-<tfOSin[6], 0,fiHCos[6]};
where the angle 6 is the colatitude, and f - 6 is the latitude. Here, we write o> [ t ] since this
is in general a function of t. For the present problem, o> [t] is a constant and o>' [t] =0.
We simply compute each term in the modified form of Newton's second law:
ma
(~~*\ (do —*a —*¦ —*¦ _i. _i. _i.
F\ -m\——xr)-2m{a>xv)-ma>x{a>xr)
/inertial V ut I
We begin with the fictitious forces. The transverse force vanishes because we have a
constant angular velocity:
In [170] := f Transverse = -mCross [<*)' [t] , r[t]]
Out [170]= {0, 0, 0}
The coriolis and centrifugal forces are:
In [171] : = f Coriolis = -2mCross [o> [t] , r' [t] ]
Out [171]= {2m?jOCos(e)y' (t) ,
-2m(wOCos(e)x' (t) +(j0Sin(9)z' (t) ) , 2mwOSin(e)y/(t) }
In [172]:= f Centrifugal =
-mCross [a[t] , Cross [u[t], r [t] ] ] //
Simplify
Out [172]= {m?j02Cos(9) (Cos(S)x(t) +Sin(9)z(t) ) ,
imj02y(t) ,iau02 Sin(9) (Cos(S)x(t) +Sin(9)z(t) ) }
The inertial forces are the force of gravity plus the tension force in the string:
In[173] := fGravity = {0, 0, -ing};
fTension = tension({0, 0, 1} -r[t]/L);
f Inertial = f Gravity + fTension
88 Chapter 2 General Physics
r tensionx(t) tensiony(t) / z(t) \ i
Out [173]= K—-, ^—- , tension 1 — - gm
L L L \ L / J
Combining all these terms into Newton's second law, we obtain the equations of motion.
In[174] := eql =
0 == m r" [t] - f Inertial - fTransverse-
fCoriolis - fCentrifugal//Thread
Out [174]= {o == -mCos(e) (Cos(S)x(t) +Sin(9)z(t) ) uO2 -
tensionx(t)
2mCos(9)y' (t)wO+ —- + mx" (t) ,
L
, tensiony(t)
0 == -my(t)wO2 + ^—- +
L
2m(wOCos(e)x' (t) +(jOSin(9)z' (t) ) + my" (t) ,
0 == -mSin(e) (Cos(S)x(t) + Sin(9)z(t) ) uO2 -2m
Sin(9)y'(t)wO + gm- tension (l - ^L\ + mz" (t)}
For the initial conditions, we take:
In[175]:= initialRule =
Thread/9{r[0] -^ 0, r'[0] -> {1, 0, 0}}//
Flatten
Out[175]= {x@) -»0,y@) -» 0, z@) -»0,
x'@) -» 1, y'(O) -» 0, z'@) ->0}
We assume the motion is confined to the horizontal plane, so we eliminate the z-dependence
via the rule
In[176]:= zSol = DSolve [{z [t] == 0}, z, t]//First
Out[176]= {z^ Function[{t}, 0]}
Additionally, if the motion is confined to the horizontal plane we can (to leading order)
set Sin[0] to zero. Furthermore, to simplify the calculation, we keep only linear terms
in o>0 by setting coO2 to zero. Applying these simplifcations to the equations of motion we
obtain
In[177] := eq2 = eql/. [uO2- >0,Sin[6] -»o}/.zSol
Out[177]= {o== tenS1°nx(t) -2maHCos(e)y'(t) +mx"(t),
0 == tenS1°ny( +2mo)OCos(e)x'(t) +my"(t) ,
L
0 == gm - tension >
We solve these equations for x'' [t] and y'' [t] and also eliminate the tension.
2.3 Newtonian Mechanics in Rotating Frames 89
In[178]:= eq3 =
Solve [eq2, {x" [t], y" [t] }, tension] /.
{Rule -> E<iual}//First
gx(t) - 2LwOCos(9)y/(t)
Out[178]= x"(t) == -
,
L
gy(t) + 2LwOCos(9)x'(t)
Finally, we will find it convenient to introduce o>2 = g/L.
In[179] := eq4 = eq3/. (g -> <u2l}//Simplify
Out [179]= {x(t)(J2 +x"(t) == 2wOCos(9)y'(t) ,
y(t)w2 + 2wOCos(9)x' (t) + y" (t) ==0}
While Mathematica can actually solve this system of equations with DSolve, the so-
solution is long and complex, and not terribly useful in this format. We give the command
below, but do not display the result.
In[180] : = DSolve[eq4, {x, y},t];
(*Not Displayed*)
We will find a better way to handle these equations in the following section.
b. The solution is much simpler if we treat the above equation of motion as a single
complex equation. We take the second equation from eq4 and multiply this by I to form
the imaginary equation (imEq):
In[181] : = iiBEq = I eq4 [ [2] ] //Thread[#, Equal] &
Out [181]= i(y(t)w2 + 2w0Cos(9)x' (t) + y" (t) ) ==0
We take the first equation from eq4 for the real equation (reEq),
In[182]:= reEq = eq4[[1]]
Out [182]= x(t)(J2+x"(t) == 2w0Cos(9)y'(t)
and combine the two into a single complex equation, eq5.
In[183] := eq5 = reEq + imEq//Thread[#, Equal]fi//
Simplify
Out [183]= x(t)w2 +x" (t) + i(y(t)w2 + 2uO Cos (9) x' (t) + y" (t) ) = =
2w0Cos(9)y'(t)
We introduce the complex variable u[t]=x[t] + I y[t], and obtain a simplified
complex equation:
90
Chapter 2 General Physics
In[184] := eq6 =
eq5/. DSolve [u[t] = =x[t] + Iy[t],x, t] [[
1]]//Simplify
Out [184]= u(t)w2 + 2iwOCos (9) u'(t) + u" (t) == 0
If we assume the initial conditions {x[0] =0, x' [0] =0, y [0] =y0, y' [0] =0},
this is equivalent to
In[185]:= initial = {u[0] == I y0,u'[0] ==0};
The solution for the equations of motion are given by DSolve:
In [186] := dsol =
DSolve[Join[{eq6}, initial], {u[t]}, t]//
First
Out [186]= {u(t)
-w02Cos2 (9)
yO
(9)
w0Cos(9)-
-u2-w02Cos2 (e)-2iu0 Cos (9)
wOcos(
9) + ie
--"Cos2 (9)
-w02Cos2 (9)
J-u2-u02Cos2 (e)-2iuOCos(9)
/-w2 -w02Cos2 (9)
If we keep only the leading terms in o>0 we find:
In[187] := uSol = (u[t]
/.dsol
//PowerExpand
//ExpToTrig
//ExpandAll)
2.3 Newtonian Mechanics in Rotating Frames 91
Out [187]= -iyOCos (tw- twOCos(9)) +
iyOwO Cos (9) Cos (tw - twO Cos (9) )
-iyOCos (to.
2w
) + twO Cos (9) )-
iyOwO Cos (9) Cos (tw
-yO Sin(tw-
yOwOCos (9)
2w
- twO Cos
Sin(tw -
2w
+ twOcos (9) )
(9))-
twOCos(9))
-yOSin(tw + twOCos(9) )-
y0w0Cos(9)
Sin(tw+
twO Cos (9) )
The real part of the equation is x [ t ]
In[188] := x = reSol = uSol/. {Complex[a., b.] » a}
Out [188]= --yOSin(tw - twOCos (9) )-
yOwO Cos(9) Sin(tw - twOCos(9))
2w
-yOSin(tw + twOCos (9) )-
y0w0Cos(9) Sin(tw + twO Cos (9) )
2w
and the complex part is y [ t ].
la[189] := y = imSol = (uSol - reSol) /I//SijBplify
Out [189]= yOCos(tw) Cos (twO Cos (9) ) +
yOwO Cos (9) Sin (tw) Sin (twO Cos (9) )
Ui
Let's combine these solutions to describe the {x, y} trajectory of the pendulum.
In [190] : = point = {x, y} ;
Notice that the terms with the coefficient coO/co are comparatively small; if we make this
simplifying assumption, the structure of this solution is apparent.
la[191] := point/ A > 0 t//FullSimplify //
la) J
TableForm
Out [191]= yOCos (tw) Sin(twOCos(9) )
yO Cos (tw) Cos (twO Cos (9) )
92 Chapter 2 General Physics
In this simplified form of the solution, the physical aspects of the problem are apparent.
First, we observe that both coordinates {x, y] oscillate with angular frequency to = -^g/L,
which is the well-known result for a simple pendulum. The plane of this pendulum oscil-
oscillation rotates with an effective angular frequency coeffective = o>0 cos@). The plane rotates
in the clockwise direction when viewed from above die Earth in the Northern Hemisphere
(Cos[6]>0), and rotates in the counterclockwise direction when viewed from above the
Earth in the Southern Hemisphere (Cos[6]<0).
c. Let us examine graphically the precession of the pendulum for three angles:
6 = 0 (North Pole),
6 = f (Equator),
6 = n (South Pole).
We choose the following arbitrary parameters.
In [192] : = values = {a -» Sqrt [g/L] , L -» 1, g -» 9.8,
We define the plot function:
In[193] := plot [6in_, options. :{}] : =
ParametricPlot[
point//.values/. {6 -> 6in}//Evaluate,
{t, 0, 10},
Ticks -> False,
PlotStyle-> {options},
PlotRange-> {{-1,1}, {-1, 1}},
AxesLabel -> {"x-axis, south",
"y-axis,east"}];
The plot function plots the motion of the pendulum bob in the {x, y] plane for colatitude
e.
We display the precession at the North Pole F=0),
In[194] := plot[0];
y-axis, east
x-axis, south
2.4 Electricity and Magnetism
the South Pole F = n),
In [195] .- = plot[jr];
93
y-axis, east
x-axis, south
and the equator F=n/2).
In [196] .= plot [jt/2. Thickness [0.02]];
y-axis, east
x-axis, south
Note that the precession in the Northern Hemisphere is in a clockwise direction, and in
the Southern Hemisphere the precession is in a counterclockwise direction; at the Equator
there is no precession.
2.4 ¦ ELECTRICITY AND MAGNETISM
2.4.1 ¦ Overview
Electric forces arise between objects having an electric charge. Consider two point charges,
qx and q2,vaa vacuum separated by a distance r. The electrostatic force experienced by one
charge due to the other is given by Coulomb's law, F = kiq^/r2), where k is a constant
with appropriate units. (In MKS units, k = (l/4ne0).) While this formula is similar to
Newton's gravitational law, F = G(mlm2/r2), an important difference is that Coulomb's
law can be both attractive and repulsive (as charges can be positive or negative) while
Newton's gravitational law can only be attractive (as masses can only be positive). If qx
and q2 have the same sign, the two charges repel; if they have opposite signs, then they
attract.
94 Chapter 2 General Physics
A nonzero electric field, E, exists at any point where a test charge, if placed at that
point, would experience an electrical force. The direction of the electric field is the same
as the direction of the force experienced by a positive test charge placed at the point. If a
charge q is placed at a point where the electric field is E, the charge will experience a force
F given by F = q E; hence, we can define the electric field via the relation E = F/q.
In the simple case of a point charge q, the electric field has only a radial component
and its magnitude is E = kiq/r2). The electrostatic force is conservative, and so can be
represented by a potential function, V = k{q/r). If we know the potential, we can find the
electric field from it via E = - V V.
We can also calculate the electric field with Gauss' law, which states (in integral form)
(?
J
= (? E ¦ dS =
J
= gew
e'osed
In words, this states that the electric flux, <frE, denned by § E ¦ dS, is proportional to the
charge enclosed by the surface, Qenciosed, up to a proportionality constant (l/e0) that varies
with the particular units chosen. Gauss' law is particularly useful to calculate the electric
field when there is a high degree of symmetry.
The motion of a charged particle in an electric and magnetic field is described by the
Lorentz force law:
F =qE +q~v Y.B.
Combining this with Newton's second law, F = m a, we obtain the equations of motion:
mr" = F = qE + q~v X B.
In the case of magnetostatics, B can be derived from a vector potential A by the relation
B = V x A. A simple example illustrating this relation is the computation of B from
a vector potential A for a small current element. For an infinitesimal current segment of
length (dl)' carrying a current / located at (r)', the infinitesimal magnetic vector potential
AA at position r created by the current element is
Integrating along the current gives the total magnetic vector potential. We shall present an
example of this later in the text.
PROBLEM 1 Charged Disk. A disk of radius R is uniformly charged with a constant
surface charge given by density cr = (Q/nR2), where Q is the total charge.
2.4 Electricity and Magnetism
95
dr
a. Find the potential and electric field along the axis of the disk.
b. Take the limit R->oo to get the field for a uniformly charged plane.
Remarks and Outline This simple problem illustrates the use of the command Grad
found in the package Calculus *VectorAnalysis *.
Solution
In [197] := Clear [-Global' * "] ;
a. Consider an infinitesimal charged ring of thickness dr, charge dq, and radius r
centered around the origin of the disk. The potential at position z along the z-axis produced
by this ring is:
In [198] := dV = » ;
The charge on the ring is related to the surface charge by
In [199] : = dq = 2jt r dr a;
where o~ is the surface charge density. Recall, cr = q/A, so dcr = dq/dA. Since A = nr2,
then dA = Inrdr, then dcr = dq/Bnrdr).
Because the distance from the ring to the field point on the z-axis is the same for all
points on the ring, the potential from the differential ring is
In [200]:= —
dr
Out [200] =
2k7rra
To get the total potential on the axis of the disk, integrate dv/dr from r=0 to R:
In[201]:= diskPotential=
rdv i
Integrate I —, {r, 0, R} |//PowerExpand
Out [201]= 2k7r(VR2
Note, we use the PowerExpand command to reduce V? to z.
96 Chapter 2 General Physics
The electric field on the axis is obtained from the gradient of the potential; the gradient
command Grad is found in the package Calculus * VectorAnalysis *.
In[202]:= Needs["Calculus"VectorAnalysis1"];
The electric field is then
In[203]:= Edisk=
-Grad[diskPotential, Cartesian[x, y, z] ]
Out[203]= 0, 0, -2k7T
>}
b. To get the electric field for a plane, let the radius of the disk go to infinity. Taking the
limit of the z-component of the electric field, we get
In [204] := Eplane = Limit [Edisk, R-> oo]
Out[204]= {0, 0, 2k7ra}
It follows from the symmetry of a plane that the electric field has only a z component.
For those familiar with MKS units, we make the replacement k -> (l/4ne0) to obtain the
familiar result:
In[205]:= Efclane/.i* -> }
Out[205]= (o, 0, —)
PROBLEM 2 Uniformly Charged Sphere. Consider a sphere of uniform charge den-
density and radius R.
a. Find the electric field for r>R and r<R and plot the results.
b. Find the potential for r>R and r<R and plot the results.
c. Make a two-dimensional plot of the equipotential surfaces and the electric field on
the same graph.
d. Make a three-dimensional plot of the potential surfaces and electric field.
2.4 Electricity and Magnetism 97
Remarks and Outline This problem illustrates the use of discontinuous functions. The
electric field has only a radial component, and its value is obtained from Gauss's law.
The potential is obtained from integrating the electric field. We illustrate how to combine
different graphics with the Show command.
Solution
In[206]:= Clear ["Global'*"];
a. By symmetry, the only nonzero component of the electric field is the radial compo-
component. In this simple case, Gauss's law becomes E A = Q, where A is the surface area of
the sphere, Q is the charge enclosed by the surface, and E is the radial component of the
field. When Gauss's law is applied to a spherical surface of radius R, we get two equations
depending on whether the field point r is less than or greater than R.
In [207]:= eql = {
47ir2Eoutside = = qTotal (*r > R*) ,
47rr2Einside = = qEnclosed(*r |
The notation (*...*) was used to embed a comment into the equation. The total
charge and the enclosed charge are given by.
In[208]:= qTotal = p;
47TT3
qEnclosed = p;
where p is the volume charge density (Q/V) of the sphere. Solving eql for the radial
component of the electric field, we get
In [209] : = sol = Solve [eql, {Einside, Eoutside} ] //
First
Out [209]= (Eoutside->—y, Einside->—}
I 3r 3 J
where Eoutside is the electric field for r>R and Einside is the electric field for r<R. The
general radial electric field for all r is:
In [210]:= eField[rr_, RR. :1, pp_ :1] : =
If[rr s RR,Einside,Eoutside]/.sol/,
{r -» rr, R -» RR, p -» pp}
Note we use the dummy variables rr, RR, and pp as arguments of the eField func-
function. The values of r, R, and p are then replaced by the input values of rr, RR, and pp,
respectively.
98
Chapter 2 General Physics
The plot of the radial component of the electric field (for the default R=l and p = 1)
follows from
In[211] := pi = Plot [eField[r], {r, 10, 3J|;
0.3
0.25
0.2
0.15
0.1
0.05
0.5
1.5
2.5
We can enhance the plot by adding a color region to distinguish the inside and outside of
the sphere:
In[212]:= mediuml=
{Hue[0.2],
Polygon[{{l, 0.51}, {1, 0}, {3, 0},
{3,0.51}}]};
medium2 =
{Hue[0.5],
Polygon[{{0, 0.51}, {0, 0}, {1, 0},
{1,0.51}}]};
Putting the plots together, we have
In [213] := Show[
{Graphics[{
mediuml,
medium2.
Text["Inside",{0.5,0.4}],
Text["Outside", {2.,0.4}]}],
Pi
AxesLabel ->
{"Distance","ElectricField"},
Axes -> True];
Electric Field
O.r'
O.'-Insiue j'j ..-.¦:;ie
o.:
o.
o.
r Distance
2.4 Electricity and Magnetism
99
Note that the plot pi is listed last so that it is shown on top of the shaded polygons.
b. The potential is obtained from integrating the radial component of the electric field
from infinity to r: V [r] = - J^E dr. For r>R, we get
In [214]:= vOut[r_, R_] =
-Integrate[Eoutside/.sol, {r, <x>, r}]
Out [214] =
3r
For the case r<R, the region of integration must be done in two parts. The first part re-
requires an integration of Eoutside from r ={oo, r}. This term is given by vOut [R, R].
The second term is an integration of Einside from r ={R, r}. The potential for r<R is
a combination of these two terms and it follows that V [r] = V[R] - f?E -dr. Therefore,
In [215]:= vln[r_, R.] =
(vOut[R, R] - integrate[Einside/.sol,
{r,R,r}])//Simplify
Out [215]= -i (r2 -3R2)p
6
The potential for all r is
In [216]:= v[r_, R_] : = If [r <R, vln[r, R] , vOut [r, R] ] ;
Here, use the If construction to define potential in a piecewise manner. The plot of the
potential forp = 1 and R =1 is
In[217]:= p2 = Plot [v[r, l]/.p-»l, {r, 10"s,3}]/
0.5
0.4
0.3
0.2
0.5
1.5
2.5
Overlaying the plot with colored regions, you have
100 Chapter 2 General Physics
In[218]:= Show[{
Graphics [ {
mediuml,
medium2.
Text ["Inside", {0.5, 0.3}],
Text["Outside",{2.,0.3}]}],
p2
},
AxesLabel ->
{"Distance", "PotentialField"},
Axes -> True
Potential Field
0.5b--
Outside
.- Distance
c. We use ContourPlot and PlotGradientField to make a two-dimensional
plot of the equipotential surfaces and the electric vector field. The potential in Cartesian
coordinates is
In[219]:= w[x_, y_, z_ : 0, R- :1, pp. :1] : =
If [r < R, vln[r, R] //Evaluate,
vOut [r, R] //Evaluate] /.
K2+y2 + z2,
>PP\
and we have replaced r=-yx2 + y2 + ?¦. An If statement has been used to choose between
the inside and outside solution found in Part b. The default parameters are z=0, R=l, and
p = 1. The graphics for the equipotential surfaces are given by vPlot:
In[220]:= vPlot = ContourPlot [w [x, y] , {x,-2,2},
{y, -2,2},
PlotPoints -> 30,
ColorFunction -> Hue,
ContourSmoothing -> True,
DisplayFunction -> Identity];
The plot has been suppressed with the option DisplayFunction-^Identity.
The graphics for the electric field are given by ePlot with the help of PlotGradi-
PlotGradientField, which is found in the package Graphicsl PlotFieldl.
In[221]:= Needs["Graphics»PlotField'"];
2.4 Electricity and Magnetism
101
In [222] : = ePlot = PlotGradientField [ - w [x, y] ,
{X, -2,2}, {y, -2,2},
ScaleFunction-> (Is),
DisplayFunction -> Identity] ;
Combining the electric field and equipotential surfaces, we get:
In[223]:= Show[{vPlot,©Plot},
DisplayFunction -> $DisplayFunction];
-1
-2
-1
Of course, the colors are not visible in this black and white book.
d. We can display the three-dimensional electric field using the command PlotGra-
dientField3D, found in Graphics »PlotField3DV
In[224]:= Needs["Graphics %PlotField3D»"];
In[225]:= ©Plot3D = PlotGradientField3D[
-w[x, y, z], {x, 0, 2}, {y, 0, 2},
{z, 0, 2},
VectorHeads -> True,
ScaleFunction-> (Is),
DisplayFunction -> Identity];
The equipotential surfaces are calculated in two steps. First, we define the radial position
vector:
In [226]:= point [r_, R_ :1] : =
{rSin[6] Cos[«>],rSin[e]
rCos [6]
The equipotential surfaces are formed by rotating the position vectors to form spherical
surfaces:
102 Chapter 2 General Physics
In[227]:= potPlot3D[r_] : =
ParametricPlot3D[
point [r] //Evaluate, {6, 0, jt/2},
{<l>, 0, jt/2},
PlotPoints -> 12,
Display-Function -> identity]
Set the equipotential surfaces at r equal to { 0 • 5, 1.0, 1.5, 2 • 0}. Display ing
the superposition of the electric field and equipotential surfaces, we get:
In [228] := Show[
OPlot3D,
Table [potPlot3D[r], {r, 1/2,2, 1/2}],
PlotRange-* {0, 1},
DisplayFunction -> $DisplayFunction];
PROBLEM 3 Electric Dipole. Consider a dipole that consists of a positive and a nega-
negative charge of equal magnitude separated by a distance d.
¦ "a
a. Find the potential, and plot the equipotential lines in the y=0 plane. Make a three-
dimensional plot of the electric field.
b. Express the potential in spherical coordinates and expand in powers of d/r, keeping
only the leading order term. Calculate the electric field.
c. Animate the static electric field of a rotating dipole. That is, consider a dipole which
is rotating about the y-axis with angle 6, and plot the electric field of this dipole in
the {x, z\ plane for a sequence of 6.
Remarks and Outline This problem illustrates the use of commands found in the
packages Calculus * VectorAnalysis *, Graphics * PlotField *, and Graph-
2.4 Electricity and Magnetism
103
ic s * PlotField3D *. The electric field is computed from the potential using the relation
E = -VV.
Solution
In[229]:= Clear["Global% *"];
a. It is useful to define the potential for a monopole charge q located at the point
{x#y# z}. Using the superposition principle we can build up complex multipole systems
from this simple function. We define
In[230] := monopole [q_, pO- : {0, 0, 0},
:{x,y, z}] : =
V(po-pi).(po-pi)
monopole gives the potential for a point charge q located at the point {x, y, z}. A dipole
can then be formed by combining two monopoles:
In[231]:= dipole=
(monopole[-q, {0, 0, -d/2}] +
monopole[+q, {0, 0,
q
Out[231]=
x2+y2+ f-z
-y2
The plot of the equipotential lines in the plane y=0 for q=l and d=l is
In [232] : = ContourPlot [dipole/. {q -» 1, d -» 1, y -» 0 } //
Evaluate,
{x, -2,2}, {z, -2,2},
PlotPoints -> 45,
Contours -> 21,
ColorFunction -> Hue,
Axes -> True,
AxesLabel -> {"x-axis", "z-axis"}];
104
Chapter 2 General Physics
The plot of the electric field is given by the command PlotGradientField3D,
found in the package Graphics * PlotField3D *:
In[233]:= Needs["Graphics%PlotField3D%"];
In[234] := plot =
PlotGradientField3D[
-dipole/.{q-» 1, d-» 1}//Evaluate,
{x, -0.5,0.5}, {y, -0.5, 0.5},
{z,-l.,l.},
PlotPoints -> 6,
ColorFunction -> Hue,
VectorHeads -> True,
ScaleFunction-> (is),
BoxRatios -> {1, 1, 2}
Note that ScaleFunction^ A&) is used to rescale the length of all vectors
by the trivial function A&); i.e., they will all have length one. This is useful when
you encounter singularities; otherwise, most of the vectors will appear to have zero
length, except for those near the singularity. (The best way to understand what the
ScaleFunction-* A&) command does is to reexecute the command without this
option.)
We can adjust the Viewpoint to try and get a better look at this plot:
In[235]:= Show[plot. Viewpoint->{0,3, 0}];
2.4 Electricity and Magnetism
105
b. To express the potential in spherical coordinates, we make use of the command Co-
ordinatesToCartesian found in the package Calculus * VectorAnalysis *.
In[236]:= Needs["Calculus »vectorAnalysis%"];
The CoordinatesToCartesian [point] command gives the Cartesian coordi-
coordinates of point in the default coordinate system. Using this command we can make the
handy replacement rule:
In [23 7] : = x2rRule =
Thread[
{x, y, z} -> CoordinatesToCartesian [
{T,e,(p}, Spherical]]
Out [237]= {x-> rCos (tp) Sin(9) , y -> rSin(9) Sin(ip) , z -> rCos (9) }
It follows from dipole that the potential in spherical coordinates is:
In[238] := potential = dipole/.x2rRule//Simplify
Out[238]= 2q
1 1
d2 - 4rCos(9)d + 4r2 ^d2 + 4rCos (9)d + 4r2
Expanding to lowest order in 1/r, the potential becomes:
In[239]:= dipoleR =
Series [potential, {r, <x>, 2}] //Normal //
Simplify
dqCos(9)
Out [239] =
r2
106 Chapter 2 General Physics
The electric field is determined by taking the negative of the gradient of the potential,
E = -VV.
In[240] : = eField = -Grad[dipoleR, Spherical [r, 6, q>] ]
c. To animate a rotating dipole, locate the charges in the {x, z} plane and rotate the
dipole around the y-axis. The expression for a dipole with unit charge and separation of
one unit in the {x, z} plane as a function of 6 is
In[241]:= rotDipole [6.] =
(monopole[ + l, 1/2{+ Sin[6], 0, +Cos[6]}] +
monopole[-l,
l/2{-Sin[S], 0, -COS [6]}]);
We use the Do command to generate a series of plots that Mathematica will then display
in sequence to simulate the animation. We show the result here for only a single frame (to
save space).
In[242]:= frames = 1;
DO[
PlotGradientField[
- rotDipole [6] /. {y -> 0 } ,
{x, -2,2}, {z, -2,2},
PlotPoints -» 14,
VectorHeads -> True,
ScaleFunction-> (Is)]
, {6, 27r/frames, 2jt, 27r/frames}]
~^v\\ \ W / / //^^
_^-.x\ \ \ i / / y^^^
_^^N \ ) / / /^^^
_-^.>\ \ \ / / ^ -> . _^
/ / / /*"--- ^-—-x \ \ \
/////// \ \\ \ \ \ \
\ \ \ \ \ \\///////
\ \ \ ^x^y^cy / / /
x""""^*^/ / \ \^—*^*" /
r^^//1 \ \\v^H
You can display the animation in Mathematicals front end by selecting the graphics
cells and using the "Animate Selected Graphics" command from the front-end menu.
2.4 Electricity and Magnetism 107
PROBLEM 4 Magnetic Vector Potential for a Long Straight Wire. Consider a long
straight wire of length 2 L with a current j0.
-L , \ +L
a. Determine the magnetic vector potential along a line perpendicular to the midpoint
of the wire. Assume L is sufficiently large so that end effects can be neglected.
b. Calculate the B field from B = V x A and take the limit as L goes to infinity.
c. Plot the B field of the infinitely long wire in both two and three dimensions.
d. Calculate the B field of an infinitely long wire in cylindrical coordinates.
Remarks and Outline This problem illustrates the use of command Curl in both
Cartesian and Cylindrical coordinates. The Curl command is found in the pack-
package Calculus * VectorAnalysis *. The vector potential is obtained from integrating
over the length of the wire. The curl of the vector potential gives the B field.
Solution
In[243]:= Clear["Global1*"];
a. Choose the origin of the coordinates at the midpoint of the wire, and let the z-axis be
along the direction of the wire. It follows from symmetry that the vector potential along the
line perpendicular to the midpoint of the wire has only a z-component. The z-component
of the vector potential is obtained at a distance r by integrating over the current running
along the z-axis from -L to +L. That is,
or more precisely:
In[244]:= Az[r_] = Integrate [ {z, -L, L}1
L Vz2 + r2 J
Out[244]= 10 (Log (l + A/L2 + r2) - Log l\jh2 + r2 - l) )
108 Chapter 2 General Physics
The magnetic vector potential A in Cartesian coordinates {x, y, z] is
ln[245]:= A[x_,y_, z_] = {o, 0,Az
Out[245]= [o, 0,
10
Log (l + i/l2 +x2 +y2) - Log (i/l2 + x2 + y2 - l) ) ]
b. The magnetic field follows from taking the Curl of the vector potential B = VxA.
Curl is found in the package Calculus * VectorAnalysis *.
In[246]:= Needs["Calculus'VectorAnalysis»"];
B[x_, y_, z-] =
Curl [A[x, y, z] , Cartesian [x, y, z]]//
Simplify
Out[246]= -
2I0Lx
(x2 + y2 ) ^L2 + x2 + y2
,0}
The B field in the limit L->oo becomes
In[247]:= Baa[x_, y_, z.] = Limit [B[x, y, z] , L -> oo]
r 2I0y 2I0x i
Out [247]= - Y — j-,0
1 x2 + y2 x2 + Y '
c. For a current of 10=1, the three-dimensional plot of the magnetic field is obtained
with the command PlotVectorField3D, which is found in the package Graph-
Graphics lPlotField3DV
In[248]:= Needs["Graphics%PlotField3D%"];
In[249]:= pi = PlotVectorField3D[
Bco[x,y, zl/.IO^l,
{x, -1, 1}, {y, -1, 1}, {z, -1, 1},
PlotPoints -> 6,
VectorHeads -> True,
Viewpoint -» {1, 1, 3},
ColorFunction -> Hue,
ScaleFunction-> (Is),
Viewpoint -> {2, 2, 16}
2.4 Electricity and Magnetism
109
The two-dimensional plot of the magnetic field in the {x, y) plane is obtained by tak-
taking only the first two components of the Boo vector field (using the Part command,
[[{1,2}]]) and using the command PlotVectorField (found in the package
Graphics * PlotField *):
In[250]:= Needs["Graphics %PlotField%"];
PlotVectorField[
Boo[x,y, z][[{1,2}]]/. io^l,
{x,-3, 3}, {y, -3,3},
PlotPoints ->20,
VectorHeads -> True,
ColorFunction -> Hue,
ScaleFunction-> (Is)
r t
r f
110 Chapter 2 General Physics
d. The magnetic field in cylindrical coordinates follows from taking the Curl of the
vector potential in Cylindrical coordinates. The vector potential expressed in cylin-
cylindrical coordinates {r, 6, z) is obtained trivially from the {x, y, z) coordinate representation
because this problem has only a z-component, which is the same in both Cartesian and
Cylindrical coordinates.
In[251] := Acylind [r_] = {0, 0,Az[r]}
Out [251]= {o, 0, 10 (Log (l + ^L2 + r2) -Log Nh2 + r2 - l) ) }
Taking the Curl of Acylind in Cylindrical coordinates, and taking the limit as
L->oo, we get
In [252]:= Boylind[r_] =
Curl [Acylind [r] , Cylindrical [r, 6, z] ] //
Limit [#, L->o>]&
Out[252]= (o, —, o}
I r J
As expected, Bcylind has only a 6 component.
PROBLEM 5 Motion of a Charged Particle in a Uniform B Field. Consider the mo-
motion of a charged particle in a constant magnetic field. Combining Newton's second law,
F = ma, with the Lorentz force law, F = Eqv x B (assuming E = 0), the motion is
described by the equation:
where B is the magnetic field. Assume that B is constant and is along the z-direction.
a. Solve the equations of motion. Let the initial position be {x, y, z) = {0,0,0}.
b. Graph the resulting trajectory along with the magnetic field.
Solution
In[253]:= Clear["Global'*"] ;
a. Define the acceleration, velocity, and magnetic vectors,
In[254].-= acceleration = {x" [t] , y" [t] , z" [t] };
velocity = {x' [t] , y1 [t] , z' [t] } ;
magneticField = {0, 0, B};
The equations for the components follow from
2.4 Electricity and Magnetism 111
In [255] : = eql =
acceleration = =
q/mCross [velocity, magneticField] //
Thread
Out[2551= x"(t) == ~~ ' ' ,y"(t) == - ^ ' ' , z" (t) == 0
l m m J
We will find it convenient to introduce o> implicitly denned by the relation o>=B q/m.
In[256]:= eql = eql/. {B ->m/q u}
Out[256]= {x" (t) == wy7 (t) , y" (t) == -wx' (t) , z" (t) == 0}
The initial conditions are:
In[257] := initial = {
x[0] == 0,x'[0] == vOx,
y[0] ==0,^10] == vOy,
z[0] == 0, z'[0] == vOz};
The solution for the variables is:
In[258]:= dsol=
DSolve[Join[{eql,initial}],
{x[t],y[t],z[t]},t]//Flatten//
FullSimplify
Out[258]= (x(t) -> -C^(^)v0y + v0y + v0xSin(t(,) ^
-1) 4
b. The trajectory can be plotted using the command ParametricPlot3D. We arbi-
arbitrarily choose the values
In [259] : = values = {B -» m/q a, a -» 1, vOx -» 1,
v0y-»l, vOz
Note, we take vOz to be relatively small compared to vOx and vOy (different values to
see the effect of this parameter). The graphics for the trajectory are given by
In[260]:= plotl=ParametricPlot3D[
{x[t], y [t], z [t], {Thickness [0.02] }}/.
dsol/. values// Evaluate,
{t, 0, 8jt},
PlotPoints -> 100] ;
112
Chapter 2 General Physics
This trajectory can be combined with the magnetic field using the command PlotVec -
torField3D found in the package Graphics lPlotField3DV Note the magnetic
field is a constant in the z-direction, so we plot the vector field {0,0,1} to represent this.
In[261].= Needs[raphios'PlotField3D'"]
plot2 = PlotVectorField3D[
{0, 0, 1}//Evaluate,
{x, -2, 2}, {y, -2, 2}, {z, 0, 2},
VectorHeads -> True,
PlotPoints -> 4
Combining the graphics, we have:
In[262] :- Show [plot 1, plot2];
2.4 Electricity and Magnetism
113
-2
PROBLEM 6 Motion of a Charged Particle in a Uniform B Field and Time Varying E
Field. Consider the motion of a charged particle in a uniform magnetic field with a time
varying electric field. Combining Newton's second law, F — ma, with the Lorentz force
law, F = qE + q v x B, the motion is described by the equation
mr" = qE + q~r' X B
Take the electric field to be in the x-direction with time dependence of the form Ex =
E0Cos[cof\, where o> is the applied frequency. Take the magnetic field to be constant and
in the z-direction. Solve the equations of motion for a particle that starts from rest and is
located at the origin. Plot the results for different values of the parameters {to, E, B).
Solution
In[263] := Clear ["Global' * "] ;
We define force vector F, the position vector r, the velocity v, the electric field EF, and
the magnetic field BF:
In[264]:= F = {Fx, Fy, Fz};
r= {x[t],y[t],z[t]};
EF= {Ex, Ey, Ez};
BF= {BX, By, Bz};
v = D[r, t]
Out[264]= {x'(t) , y'(t), z'(t)}
The force on a charged particle in an electromagnetic field is
114 Chapter 2 General Physics
In [2 65] : = F = q EF + q Cross [v, BF]
Out [265]= {Exq+ (Bzy'(t) - Byz' (t) )q, Eyq + (Bxz'(t) -Bzx'(t))q,
Ezq+ (Byx'(t) -Bxy'(t))q}
and from Newton's second law, F = ma, the nonrelativistic equations of motion are:
In[266]:= eql = F-m D[r, {t, 2}] == 0//Thread;
eql //ColumnFonn
Out[266]= Exq+ (Bzy'(t) - Byz'(t) )q - mx" (t) ==0
Eyq+ (Bxz'(t) - Bzx'(t) )q-my" (t) ==0
Ezq+ (Byx' (t) - Bxy7 (t) )q-mz" (t) == 0
The initial conditions are:
In[267] := initial = {
x[0] == 0,x'[0] == 0,
y[0] ==o,y'[o] ==o,
z[0] == 0, z'[0] == 0};
For our particular case, the components of the fields are:
In[268] : = fields =
Thread/9{BF -> {0, 0, m oH/q},
EF -> {E0 Cos [a t], 0, 0}}// Flatten
Out [268]= JBx-> 0, By -> 0, Bz -
Ex->E0Cos (tw) , Ey-> 0, Ez -> o]
where we have replaced B with (m o>0/q) for convenience. We combine all the equations
and initial conditions into a single equation list:
In[269].= eqs = Join[eql,initial]/.fields
Out [269]= {EOqCos (tw) +mw0y'(t) -mx"(t) = = 0,
-mwOx' (t) -my" (t) == 0, -mz" (t) == 0, x@) == 0,
x' @) == 0, y@) == 0, y' @) == 0, z@) == 0, z' @) ==0}
The path of the charged particle is given by:
In[270] := dsol =
DSolve[eqs, {x[t],y[t], z[t]}, t]//
Flatten//FullSimplify
E0q(Cos (twO) -Cos(tw))
Out[270]= |x(t)
EOqwO Sin(tw) - EOqwSin (twO) i
mrj3 - m/JwO2 ' J
2.4 Electricity and Magnetism 115
Let us plot the orbits for several different choices of to. We take an arbitrary choice for
the parameters:
In [2 71]:= values = {m-» 1, BO -» 1# wO -» 1# q-» 1};
We can define the point of the trajectory in {x, y, z) coordinates as follows:
In[272]:= point [t_,w_] =
{x[t],y[t],z[t]}/.dsol/.values
rCos(t) - Cos (tw) Sin(tw) - wSin(t) i
<¦ u2 -1 ' op - @ J
There are two special cases to consider: to = 0 and to=toO. We must use the Limit here
to avoid an Indeterminate expression.
In[273]:= point [t_, 1] = Limit [point [t, <u] , a -» 1]
0ut[273]= [-tSin(t) , - (tCos (t) - Sin(t) ) , o]
In[274]:= point [t_, 0] = Limit [point [t, <u] , a -» 0]
Out[274]= {1-Cos(t) , Sin(t) - t, 0}
Since Mathematica applies specific rules before general rules, these last two definitions
for point will override the general case above—this ensures that we do not encounter
any singularities when to -* {0,1}. We are now ready to define the plot function.
In[275]:= plot [«)_] : = ParametrioPlot [
point [t, <u] [[{1,2}]]//Evaluate,
{t, 0, 20jt},
PlotLabel -> oi.
Ticks -> None,
DisplayFunction -> Identity];
Note, we select the first and second elements of point as we are making two-
dimensional plots in the {x, y] plane. We can now generate a table of plots
In[276] := table = Table [plot [u] , {u, 0,4, 1/3}];
and display the orbits.
In[277]:= Show[GraphicsArray[Partition[table, 3] ] ] ;
116
Chapter 2 General Physics
1/3
4/3
B ^
10/3
2/3
5/3
8/3
11/3
2.5 ¦ MODERN PHYSICS
¦
PROBLEM 1 Carbon Dating. The decay rate of radioactivity is n[t] = noe at, where
a = 1/t is the decay constant related to the half-life by
a = 1 = log[2]
T Tl/2 '
The half-life of radioactive carbon-14 A4C) is t1/2 = 5750 years. If measurements show
the fraction of radioactive carbon left in a fossil is (n[f]/n0) = {0.1,0.2,..., 1}, then how
old is the fossil? Display the result as both a table and a graph.
Solution
In[278]:= Clear["Global»*"] ;
The decay rate for 14C is n[t] = nOe'1".
In [279]:= n[t_] = nOExp[-at]
Out [279]= e"atn0
We can relate a to the half-life t1/2 = 5750 years by noting that when the time t =
r1/2 = 5750 years, the concentration will be half the original concentration.
In[280]:= eql = 1/2 n[0] == n[5750]
nO
Out [280]= — == e"
an0
We then find the solution for a:
In[281] : = aSol = Solve [eql, a] //Flatten
Out[281]= {a
2.5 Modern Physics 117
and substitute this back into the original equation:
In[282]:= n[t_] = n[t]/.aSol
Out [282]= 2-t/5750n0
As we are more interested in the relative concentration of 14C, we eliminate nO=n [0]
and nl=n [t] in favor of ratio=nl/nO:
In[283] := eq2 = Eliminate [{nl = =n[t], ratio = =nl/nO},
nO]
Out [283]= ratio == 2-t/575°
Thus, knowing the ratio, we can find the age of the sample.
In[284] : = ageRule = Solve [eq2, t] //First
5750 Log(ratio) ]
Out [284]= [t -> -:
Log B) J
In[285]:= time[ratio_] = t/. ageRule
_5750 Log(ratio)
Log B)
To compute a table of ages for the fraction ratio, we compute:
In[286] := data =
Table[{ratio,time[ratio]},
{ratio,0, 1, 1/10}]//N;
and then display the results with TableForm.
In[287]:= TableForm [data.
TableHeadings- >
{{},{"FraotionLeft","Age(yrs)"}}
TableAlignments -> {Right, Bottom}
]//PaddedForm
Out[287]= FractionLeft
0.0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
[#,{6,1}]*
Age(yrs)
CO
19101.1
13351.1
9987.6
7601.1
5750.0
4237.6
2958.8
1851.1
874.0
1.0 0.0
We use the option TableAlignments together with PaddedForm to align the num-
number for easy reading.
118
Chapter 2 General Physics
Next, we graph the output. It will be convenient to work in units of the half-life,
t0=5750 years; note how we adjust the Ticks and the GridLines to units of the
half-life.
In[288] : = tO = 5750;
Plot[n[t]/nO, {t, 0, 5tO},
AspectRatio -> 1,
Background-* Hue[0.2, 0.5, 1],
Ticks -> {Range [0, 5tO, tO] ,
Table[l/2~i,{i, 0, 3}]},
AxesLabel -> {"Age(yrs) ", "ratio = nl/n0"},
PlotStyle-* {Thickness [0.02], Hue [0.9]},
GridLines -* {Range [0, 5tO, tO] ,
Table[l/2~i,{i,0,5}]}
ratio=nl /nO
5750
f7250
PROBLEM 2 Stable Isotopes. We will demonstrate the properties of a standard add-on
package, Miscellaneous xChemicalElementsx.
a. Make a plot of the stable isotopes in {proton, neutron} space. Let the horizontal axis
be the proton number and the vertical axis be the neutron number.
b. Show the odd-even effect by counting the number of stable nuclei with
even protons-even neutrons,
even protons-odd neutrons,
odd protons-even neutrons,
odd protons-odd neutrons.
2.5 Modern Physics 119
Solution
In[289]:= Clear["Global'*"] ;
a. This problem needs the information found in the add-on package Miscella-
Miscellaneous 'ChemicalElements *.
In[290]:= Needs["Miscellaneous'ChemicalElements'"]
Mercury :: shdw : Symbol Mercury appears in multiple contexts
{Miscellaneous*ChemicalElements', Global*}; definitions in context
Miscellaneous'ChemicalElements* may shadow or be shadowed by other
definitions.
Since we denned the variable Mercury previously in the Keplerian Orbits prob-
problem in Section 2.2, our definition shadows that defined in the package Miscella-
Miscellaneous'ChemicalElements V The solution is to Remove the global variable Mer-
Mercury as follows:
In[291]:= Remove[Global'Mercury]
The commands denned by this package can be displayed with
In[292].- = TMiscellaneous'ChemicalElements'*
(¦Output not shown*)
We've not shown the output, to save space. We now demonstrate some of the commands
in the package; for example, the element with atomic number 26 (and its standard abbrevi-
abbreviation) is given by:
In[293]:= {Elements [ [26] ],
ElementAbbreviations[[26]]}
0ut[293]= {Iron,Fe}
and its stable isotopes are
In[294]:= Stablelsotopes[Fe]
0ut[294]= {54,56,57,58}
Mathematica knows about 112 elements:
In[295]:= Length[Elements]
0ut[295]= 112
The number of neutrons in each isotope of Iron (Fe) is
120 Chapter 2 General Physics
In[296]:= Stablelsotopes[Fe] - 26
Out[296]= {28, 30, 31, 32}
and the number of protons is trivially:
In [297]:= Stablelsotopes [Fe] * 0 + 26
Out[297]= {26, 26, 26, 26}
We can automate this procedure as follows:
In [298] : = neutrons [n_] : =
Stablelsotopes[
ElementAbbreviations[[n]]] - n
protons [n_] : =
Stablelsotopes[ElementAbbreviations[[
n]]] * 0 + n
(note the trick of multiplying by zero just to get an array of proper length for the protons)
and define the function pairs
In [299]:= pairs [n.] : =
Transpose[{protons[n], neutrons[n]}]
pairs [26]
Out [299] =
26
26
26
26
28 '
30
31
32
Let us plot the isotopes in {proton, neutron} space:
In[300] := ListPlot [pairs [26]//Evaluate,
PlotStyle -> Pointsize [0.03] ,
AxesLabel -> {"proton", "neutron"},
PlotLabel -> "Iron(Fe)"
neutron irOn (Fe)
32 •
31 •
30 •
29
^ 10 20 '30 40 5T PrOt°n
2.5 Modern Physics
121
We can easily do the same for all the elements. The array data contains all stable pairs
{protons, neutrons}.
In [3 01]:= data =
Table [pairs [i], {i. Length [Elements] }]//
Flatten [#, 1]&;
The plot in {proton, neutron} space is:
In[302]:= plotl = ListPlot[data,
PlotStyle -> PointSize [0.015],
AxesLabel -> {"proton", "neutron"}.
Plot Label -> "AllElements",
AspectRatio -> 1,
Display-Function -> $DisplayFunction,
Epilog-» Line[{{0, 0}, {100, 100}}]
neutron A11 Elements
120
100
80
60
40
20
20 40 60 80
proton
The solid line is the (neutron-number = proton-number) line. The Coulomb repulsion
makes it more favorable for the nuclei to have more neutrons than protons. Magnifying the
middle of the graph, we get a more detailed view:
In[303]:= Show[plotl,
PlotRange-» {{20, 30}, {20, 40}}];
122
Chapter 2 General Physics
neut
40
37.5
35
32.5
30
27.5
25
22.5
:ron
•
All Elements
• •
• •
•
. . I . ^
b. The collection of all stable data pairs {protons, neutrons} are stored in the array
data. We start by computing the number of isotopes with an odd number of both protons
and neutrons. We use the Select function to extract the pairs with the given criteria. The
actual pairs are shown here:
In[304]:= Select[data,
(OddQ[#[[l]]]SftOddQ[#[[2]]])S]
Out[304]=
1 1
3 3
5 5
7 7
57 81
odd protons-odd neutrons: If we are only interested in the count, we can extract this
information with the Length command:
In[305]:= Select [data,
@ddQ[#[[l]]]6S0ddQ[#[ [2] ]])*]//
Length
Out[305]= 5
even protons-even neutrons: The case of even protons-even neutrons is nearly identical:
In[306]:= Select [data,
(EvenQ[#[[l]]]fcSEvenQ[#[ [2] ]])*]//
Length
Out[306]= 154
odd protons-even neutrons: For the next two cases, we use a different command syntax
just for variety; the preceding commands will work just as well.
2.5 Modern Physics 123
In [307]:= Length [
Cases[data,
{x-, y.} /; OddQ [y] && EvenQ [x] ] ]
Out[307]= 53
even protons-odd neutrons:
In[308]:= Length[
Cases[data,
{x-, y.}/; EvenQ [y] && OddQ [x] ] ]
Out[308]= 49
Obviously the even-even nuclei are the most abundant, and the odd-odd nuclei are quite
rare.
PROBLEM 3 The Bohr Atom. The Bohr theory of the hydrogen atom is a mixture of
classical physics and the energy-quantization ideas introduced by Planck. The Bohr theory
is based on the following three postulates.
a. An electron in an atom can move about the nucleus in stable circular orbits without
radiating. These are called the discrete stationary states of the atom.
b. The allowed stationary states are those for which the angular momentum is quan-
quantized: I = tnvr = nti.
c. Whenever an electron jumps from an initial (higher) energy orbit et to a final (lower)
energy orbit e,, a photon of energy hv is emitted such that hv = et — e,.
Consider an electron that is bound to the nucleus with an attractive force of the form:
kiZe2/^), where e is the elementary unit of charge, r is the distance between the nucleus
and the electron, Z is the charge of the nucleus in units of e (i.e., the number of protons),
and k is the Couloumb constant (equal to l/Ane0 in MKS units). Let us assume that the
(very heavy) nucleus remains at rest and the electron revolves around the nucleus in a
circular orbit.
a. Using Bohr's method of quantization, derive the equation for the energy levels in
terms of «, where n is the n'th Bohr orbit. Make a plot of the energy levels.
b. Derive the frequency of the radiation, a>, associated with a transition from the Bohr
energy level of nt to n^.
Remarks and Outline One equation for the parameters is given by equating the centrifu-
centrifugal force with the Coulomb force; a second equation comes from the Bohr quantization
rule. Solving these two equations gives the quantized expressions for v and r. The energy
is the sum of the potential and kinetic energies.
124 Chapter 2 General Physics
Solution
In[309]:= Clear["Global'*"] ;
a. We start by using Newton's second law, F = ma, where F is given by the Coulomb
force, and the centrepital acceleration a = v2/r.
z
In [3101:= coulomb = k
r2
force = m a;
v2
a = —;
r
eql = coulomb == force
Out[310]=
The angular momentum is I = r x p = mvr.
In[311]:= angularHomentum = m v r;
Quantizing the angular momentum in units of ti = h/Bn), we have
In[312]:= eq2= angularHomentum == n h
Out[312]= mrv == nfi
where n is a positive integer, n={l,2,3, ...}. An equation for {v, r\ follows from
solving the algebraic equations eql and eq2:
In[313] := rulel = Solve[{eql, eq2}, {v, r}]//First
Out[313]= {r
n2fi2 e2kZ
—= , v -»
e kmZ nfi
The total energy of the nth orbit is the sum of the kinetic and potential energies:
In[314]:= kineticEnergy= —m v2;
Z e2
potentialEnergy = -k ;
totalEnergy =
kineticEnergy + potentialEnergy
Out [3141= ^—--—?
Expressing the energy in terms of n, we find
In[315]:= energy[n.] = totalEnergy/. rulel//SijBplify
2.5 Modern Physics 125
To make a plot of the energy, we choose the specific values for the constants that can be
found in the add-on package Miscellaneous * PhysicalConstants *,
In[316]:= Needs["Miscellaneous'PhysicalConstants*"];
In [317] : = values = {
e -> ElectronCharge,
m-> ElectronMass,
k-» 1/D*60),
eO -> VacuumPermittivity,
h -> PlanckConstantReduced,
We will define a function that gives the energy in units of electron volts with the help of
the Miscellaneous'Units* package:
In[318]:= Needs["Miscellaneous'Units'"];
We now define the function
In[319] := energyEV[n_] := Convert [energy [n]//.values, ElectronVolt];
Let us check to see if energyEV gives the expected ionization energy for hydrogen:
In [320] := energyEV [1] //NumberForm[#, 3] ft
Out[320]= -13.6ElectronVolt
Pictorially, the energy values of the hydrogen atom in units of electron volts are
Table — — l-^-, {a, 10} //
L ElectronVolt J
Evaluate,
{x, 0,1},
PlotRange -> All,
Axes -> {False, True}] ;
0
-2
-4
-6
-8
-10
-12
This shows the energy levels in a simple, graphical way. The full quantum wave func-
functions for the hydrogen atom are obtained later in the text in Chapter 9.
126 Chapter 2 General Physics
b. The angular frequency, o>, of the radiation associated with the transition from orbit ni
to rif follows from Bohr's postulate, twj = AE
In[322] := eq3 = h a == energy 1^] - energy [nf]
e4k2mZ2 e4k2mZ2
0ut[322]= uh == =-^ ~—o-
2h2nj 2fi2n2
This is trivial to solve for the angular frequency, o>.
In[323] := Solve [eq3, u] //First //Simplify
. e*k2mZ2(n2-n2),
Out [323]= lw-> rrrV^
L 2fiJn?n2 -1
PROBLEM 4 Relativistic Collision. A particle at rest with mass m2 is hit by a second
relativistic particle with mass m1 and speed fiv For convenience, we will express our ve-
velocities relative the the speed of light, c, so we have yS = v/c. Upon collision, m1 and m2
coalesce into one particle with rest mass m3 moving with speed yS3 relative to the observer.
Show that m3 andyS3 for the composite particle are given by
= Jml: + mi + 2m,m,y, and yS3 = ' ' '
where
Remarks and Outline This problem illustrates the use of four-vectors and tensors. The
results follow from the conservation of four-momentum and the relation y1 = A/J1 - fij)¦
Solution
In[324]:= Clear [ "Global'*"];
The four-momentum for the initial particles are
In[325]:= pi = ml y!{1, 0, 0, 01};
p2 =m2{l, 0, 0, 0};
The momenta is written in four-vector notation: p1 = {e, px, py, pz}. The energy of par-
particle with rest mass ml is El=ml yl, and the three-momentum of ml is in the z-direction
with magnitude pzl=ml yl /?1. The four-momentum of the final particle is
In[326]:= p3 = Bl3 Y3{1, 0, 0,
2.6 Exercises 127
Conservation of four-momentum gives the equation p\ + pi = py-
In [327] : = eql =pl+p2==p3// Thread
Out [327]= {m2 + mlyl ==m3y3. True, True,ml/31yl ==m3/33y3}
We get two nontrivial equations from the conserved four-momentum; two more equa-
equations follow from the relation between y and/?:
ln[328]:= eq2 =
The solution for >33 and m3 easily follows from these four equations
In[329] := eq3 = Join [{eql, eq2}] //Flatten
Out [329]= |m2 + mlyl ==m3y3. True, True, ml/Slyl ==m3/33y3,
,1,1
and we find for/?3 and m3, after eliminating y3,
In[330] := sol=Solve[eq3, {03, m3}, {y3}] [[2]]//
Simplify
Out [330]= (m3 -> ~Jml2 + 2m2ylml + m22 , /33
m2 + mlyl
We take the second solution (with the notation [ [2] ]) to obtain a positive solution for
m3.
2.6 ¦ EXERCISES
2.1 Exploding Projectiles
A projectile is launched at v=20 m/s at an angle of 0=30 degrees with the horizontal. In the
course of its flight it explodes, breaking into two fragments, one of which has twice the mass
of the other. The two fragments land simultaneously. The lighter one lands x=20m from the
launch point in the direction the projectile was fired. (Note, you are not given the time the
projectile explodes; while this does affect the specific trajectory, it does not affect the final
landing point. You may wish to verify this for a variety of explosion times.)
(a) Where does the other fragment land?
(b) Plot the motion of the two fragments and the motion of the center of mass point for a
variety of explosion times.
(c) Make a function that will plot the motion of the two fragments and the motion of the center
of mass when the initial velocity, mass of fragments, and position of one of the fragments
is given.
128 Chapter 2 General Physics
2.2 Intersecting Trajectories (Shoot the Monkey)
A hunter with a gun wishes to shoot a monkey hanging from a branch. The hunter aims right at
the monkey and fires the dart. At the instant the monkey sees the flash of the hunter firing the
gun, the monkey lets go of the branch and drops to the ground.
(a) Show that the monkey will be hit regardless of the angle of the dart to the monkey and the
dart's initial velocity, so long as it is great enough to travel the horizontal distance to the
tree before the dart hits the ground.
(b) Plot the points for the positions of the dart and monkey when those positions are separated
by equal time intervals. Choose the time intervals so the last point is the intersection of the
dart and monkey.
(c) Display the plot for several different initial values of the dart and for several different
heights of the monkey.
2.3 Principle of Galilean Invariance
Two balls are released simultaneously from a platform above the Earth's surface. One is merely
dropped from rest, while the other is launched with an initial horizontal velocity vO. Graph the
stroboscopic images of the two balls at successive instants of time and show that they fall
downward in unison, reaching equal heights at the same time. Consider several different values
of vO.
2.4 Elastic Collision
A ball moving with nonrelativistic velocity v0 makes an off-center, perfectly elastic collision
with another ball of equal mass initially at rest. The incoming ball is deflected at an angle 6l
from its original direction of motion.
(a) Find the velocities and trajectories of the balls after the collision.
(b) Plot the trajectories and center of mass point for different v0 and for different 0l.
2.5 Projectile and Earth's Rotation
If a projectile is fired due east from a point on the Earth's surface at a northern latitude A, with
a velocity of magnitude v0, and at an angle of inclination to the horizontal of a, show that the
lateral deflection d when the projectile strikes the Earth is
_ 4vqW sin[A] cos[a] sin[a]2
g2
where a> is the rotation speed of the Earth, and g is the gravitational acceleration of 9.8m/s2.
If the range of the projectile is R for the case a> = 0, show that the change of range due to the
rotation of the Earth is
/ 1R I l1 \
AR = J wcos[A]\Jcot[a] - - tan[a]3/2 .
\ g \y 3 /
2.6 Projectile Thrown up an Incline Plane
An inclined plane makes an angle a with the horizontal. A projectile is launched from the
bottom of the incline with speed v0 in a direction making an angle (S with the horizontal. Find
the distance where the projectile hits the incline. What angle achieves the maximum distance?
2.7 Falling Object with Air Resistance as Observed from the Rotating Earth
An object of mass m, initially at rest, is dropped from height h to the Earth's surface at colatitude
0. Let a> be the rotational speed of the Earth. The particle is acted on by a constant pull of gravity
2.6 Exercises 129
with acceleration g, and by air resistance. The force of the air drag is assumed to be proportional
to the speed, v. Find the deflection after time t, neglecting terms of order a>2 and higher.
2.8 Projectile Thrown up with Air Resistance
A particle of mass m is acted on by a constant pull of gravity with acceleration g and air
resistance. The particle is thrown vertically upward with speed v0. The force of the air drag is
assumed to be proportional to the speed. Find the maximum height and the time taken to reach
this maximum height.
2.9 Quadrupole
Consider three charges located on the z-axis. One negative charge of magnitude q, is located at
position +s\ the other, of the same magnitude, is at position -s. A positive charge of magnitude
Iq is located at the origin. The field point is at r, and it is assumed that the separation s of the
charges is small compared to the distance r.
(a) Find the potential and electric field to leading order in powers of s/r.
(b) Plot the equipotential surfaces and the electric field lines.
2.10 Motion of a Charged Particle
A particle of electric charge q, and mass m moves with velocity v in an electric and magnetic
field having electric intensity E and magnetic intensity B. Suppose that B and E are constant
and in the directions of the negative y and positive z axis, respectively. Prove that if the particle
starts from rest at the origin then it will describe a cycloid in the {x,z} plane. The equation of
a cycloid is x = b@ - Sin[0]), z = b(l- Cos[0]), where 0 = qBt/m, b = rnE/(qB2), and t is the
time.
2.11 B Field of a Spinning Disk
A thin disk of charge density cr, radius R, and thickness t < R rotates with an angular velocity
a) about the z-axis. Find the B field on the axis of the uniformly rotating disk and plot the
results.
CHAPTER
3
Oscillating Systems
3.1 ¦ INTRODUCTION
Vibrations or oscillations of mechanical and electrical systems constitute one of the most
important fields of study in all physics. Patterns of movement that repeat over and over
again are common in celestial mechanics, mechanical systems, quantum mechanics, and
electrodynamics. Virtually every system possesses the ability to vibrate; a mosquito's
wings, for example, vibrate hundreds of times per second and the Earth, after being jolted
by an earthquake, vibrates at the rate of about one oscillation per hour. The feature that all
such phenomena have in common is periodicity, a pattern of movement or displacement
that repeats itself over and over again. In this chapter we study a number of aspects of
periodic motions in linear systems.
The equations describing oscillating systems are usually complicated. In many cases,
they can be analyzed with potential or phase space diagrams. Potential diagrams can be
used to analyze the oscillatory motion and to find positions of equilibrium. The system
is in equilibrium when the net force acting on it vanishes. If the system is initially at the
equilibrium position with zero initial velocity, then the system will remain in equilibrium
indefinitely. The equilibrium is stable if a small disturbance of the system from equilibrium
results in only small bounded motion about the rest position. The equilibrium is unstable if
an infinitesimal disturbance eventually produces unbounded motion. The potential has an
extremum at both of these equilibrium positions. When the extremum of the potential is a
minimum, the equilibrium is stable; when it is a maximum, the equilibrium is unstable.
In some cases, it is advantageous to study the motion in terms of its phase plane. For
example, consider a system having one degree of freedom that is described by a differential
equation of the form,
x"[t]+f[x[t],x'[t]]=0
If you define v[t] = x'lt], then this equation can be expressed as two first-order-
equations:
v'[t] = -f[x[t],v[t]] and x'[t] = v[t]
The [x[t], v[t]} plane is called the phase plane, and the changing state of the system
makes a curve in the phase plane called a trajectory. The trajectory displays the depen-
dependence between the position and velocity. Equilibrium occurs when the velocity v and force
f[x, v] are simultaneously equal to zero and correspond to points in the phase plane where
f[x, v] = 0 and v = 0.
130
3.2 Linear Oscillations 131
The methods used to obtain the solutions in this chapter are not unique; you are encour-
encouraged either to change the Mathematica commands and find procedures that will further
illuminate the physics, or to find other commands that will make the calculations faster.
The speed of the calculation can be obtained from the command Timing. There are three
sections on problems: Linear Oscillations, Small Oscillations, and Oscillating Circuits. At
the beginning of each problem section we include an overview of the topic and may include
several user-defined functions. This chapter concludes with a section on Exercises. Before
starting this chapter you might want to turn off the spell checker:
In[l]:= Off[General : : "spell"];
Off[General :: "spelll"];
3.2 ¦ LINEAR OSCILLATIONS
3.2.1 ¦ Overview
Our attention in this section is directed toward linear systems. The physical reason is that
linear systems arise in a variety of mechanical systems. They are due to restoring forces
that are proportional to the displacement from equilibrium. Such motion is almost always
possible if the displacements are sufficiently small. A physical model is a simple harmonic
oscillator, where a mass is connected to some elastic object of negligible mass fixed at the
other end and constrained so that it may only move in one dimension. The importance of
this problem is that equations of a similar form arise when a particle moves through any
region whose potential has a local minimum. Similar equations also arise in the study of
LCR circuits. The letters L, C, and R refer to the symbols used to identify the electrical in-
inductance, capacitance, and resistance, respectively. In many systems it is only approximate
but perhaps a close analogy to the true motion.
A more realistic physical model is one that includes dissipative forces: the damped
harmonic oscillator, where the dissipative force is directly proportional to the velocity of
the mass and in the opposite direction. This produces another differential equation with
an exact solution. We now have an equation that yields different behaviors for different
parameter values. Another common mechanical problem arises when a damped harmonic
oscillator is driven by some time-dependent external force: the driven harmonic oscillator.
The most important case is that of a force that oscillates in a sinusoidal manner. This
differential equation also has an exact solution. Much of the discussion in this section will
probably be familiar ground, but it is important to be quite certain of it before proceeding
to nonlinear systems.
It is useful to create user-defined procedures for those calculations that are used re-
repeatedly in the section. It is not necessary to understand the details of these user-defined
procedures until you have done all the problems; then you can go back and examine the
procedures. To understand them in detail, go through the steps one at a time. Try to make
the procedures more time efficient, add default conditions, and add options to the proce-
procedures. They can be downloaded on the author's website. The three procedures used several
times in this section are phasePlot, timePhasePlot, and doublePlot:
132 Chapter 3 Oscillating Systems
3.2.2 ¦ Initialization of User-Defined Functions
3.2.2.1 ¦ phasePlot for One-Dimensional System
The procedure phasePlot [q , p , tList , opts ] plots the phase trajectory {q,p}
where tList gives the starting and stopping times and is of the form {t, tMin, tMax}.
The variable opts allows you to include options for ParametricPlot. This routine is
simply a specialized use of ParametricPlot; however, you will often find it useful for
oscillating systems:
In[2]:= phasePlot [q_, p., tList-List, opts ] : =
ParametricPlot [ {p, q} //Evaluate,
tList,opts,
PlotRange ->A11,
Plotstyle- >
{Hue[Random!]],Thickness[0.01]},
Axes -> False,
PlotLabel -> "Phase Trajectory",
Frame -> True,
FrameLabel-» {"p", "q"} ]
To see how to apply the procedure, consider the harmonic functions q [ t ] •¦
Sin [2 ;rt] andp[t] = q# [t]. The phase diagram is
In[3]:= phasePlot [Sin [2 jt t],D[Sin[2 jt t],t],
{t, 0, 3}, GridLines -» Automatic] ;
1
0.5
-0.5
-1
Phase Trajectory
-6-4-2 0 2 4 6
P
3.2.2.2 ¦ timePhasePlot: Time Behavior of Phase Plot for a One-Dimensional System
The procedure timePhasePlot [q,p, tList,opts] plots the time evolution of the
phase trajectory where tList gives the starting and stopping times and is of the form
{t,tMin,tMax}. This routine is simply a specialized application of Parametric-
Plot3D; however, you will often find it useful for oscillating systems:
3.2 Linear Oscillations
133
In [4] : = timePhasePlot [q_, p., tList-List,
opts ] : =
ParametricPlot3D[
{p,q, tList [[1]],
{ Hue[0.8],Thickness[0.003]}}
Evaluate,
tList,opts,
PlotRange ->A11,
PlotLabel -> " Phase [t ] " ,
AxesLabel^{"p[t]", "q[t]», "t "},
PlotPoints -> 300,
BoxRatios-> {1, 1, 1}]
To see how to apply the procedure, consider the harmonic functions q=Sin [2 n t]
and p = q# [t]. The time-evolved phase diagram is
In[5]:= timePhasePlot [Sin[2 jt t],D[Sin[2 jt t],t],
{t,0,3}];
Phase [t]
P [t]
3.2.2.3 ¦ doublePlot: Combination of the Phase Plot and the Time B Behavior of the
Phase Plot
The procedure doublePlot [q, p, tList ] combines phasePlot and timePhase-
timePhasePlot with GraphicsArray:
134
Chapter 3 Oscillating Systems
In [6]:= doublePlot [q_, p_, tListJ.ist] : =
Show[
GraphicsArray [ {
phasePlot [q, p, tList,
Display-Function- > identity,
FrameTicks ->None] ,
timePhasePlot [q, p, tList,
DisplayFunction- >identity.
Ticks-> None] }
To see how to apply the procedure, consider the harmonic functions q[t]
Sin[2 n t] andp[t] = q' [t]. The phase plot and time evolution are
In[7]:= doublePlot [Sin [2 n t],D[Sin[2 jt t],t],
{t, 0,3}];
Phase Traj ectory
q[t] Phase[t]
P[t]
3.2.2.4 ¦ Protect Commands
Finally, we apply Protect to the user-defined procedures to kept them from being deleted
with Clear [ "Global»* " ] :
In [8] := Protect [phasePlot, timePhasePlot, doublePlot] ;
PROBLEM 1 Linear Oscillator. Consider a linear oscillator described by the equation
x"[t]+oj20x[t]=0.
a. If the initial conditions are chosen to be x[0] = xO and ^[0] = vO, show that the
solution is x0cos[co0t] + v0sy]. Plot the solution.
b. Show the solution can also be written as Acos[o>0f + 5], where x[0] = Acos[<5] and
x'[0] = -A o>0 sin[<5]. A is called the amplitude, and 6 is called the phase.
c. Use LaplaceTransf orm to solve the equation.
Remarks and Outline DSolve expresses the solution in terms of two constants. By a
proper choice of constants, you can have the solution represented in terms of either a phase
and amplitude or in terms of the initial conditions x[0] and x'[0]. Another method used to
3.2 Linear Oscillations 135
solve the differential equation follows from taking the Laplace transform. This method is
certainly not practical for this simple example, but may be useful for more complex differ-
differential equations. The graphics makes use of the add-on package Graphics 'Arrow*.
Solution
In[9]:- Clear["Global»*" ]
a. The linear oscillator equation is
In[10]:= eql=x"[t] + uO2 x[t] ==0 ;
If you let the initial conditions be
In[ll]: = initiall = {x[0] ==x0,x'[0] ==v0};
the solution follows from applying DSolve to eql:
In[12]:= dSoll=
DSolve[ {eql ,initiall}//Flatten,
x[t], t]//Flatten
xO ojO Cos(t ojO) +v0 Sin (t ojO ) I
Out[12]= x(t)
ojO
Let us plot the simple harmonic motion for the values xO = 0, o>0 = 1 and vO =
1. To embellish the graph we add arrows found in the add-on package,
In[13]:= Needs["Graphics'Arrow'"]
The commands in this package are
In[14]:= ?Graphics'Arrow**
Graphics'Arrow'
Absolute Arrow HeadCenter HeadLength HeadScaling HeadShape HeadWidth Rela-
Relative ZeroShape
We are interested in the command Arrow:
In [15] := ?Arrow
Arrow[start, finish, (opts)] is a graphics primitive representing an arrow
starting at start and ending at finish. More...
Define three arrows at the origin pointing along the tangent to the curve, along the x-
axis, and along the y-axis. The graphics for the arrows are
In [16] : = arrow = {
{Hue[0.2],Arrow[{0,0}, {0.5, 0.5}]},
{Hue[0.4],Arrow[{0,0},{2,0}]},
{Hue[0.6],Arrow[{0, 0}, {0, 0.5}]}
136
Chapter 3 Oscillating Systems
The curve for x [ t ] is
:- Plot[x[t]/.dSoll/.{xO -> 0,
{t, -2 JT, 2 7t},
Epilog -> arrow];
Epilog has been used to add the graphics for the arrows. The motion is simple har-
harmonic.
b. Instead of expressing the motion with both Sin and Cos terms, we could have con-
constructed a solution with just a Cos term. If we write the initial conditions as
In[18]:= initial2 = {x[0] ==A Cos[S],
x'[0] == -A 00 Sin[S]};
then the solution that follows from DSolve is
In[19]:= dSol2=
DSolve [ {eql, initial2 } //Flatten, x [t] ,
t]//Flatten //Simplify
0ut[19]- {x(t) ->A Cos(<5 + t ojO)}
where 6 is called the phase and A is called the amplitude.
c. In this part of the problem we use LaplaceTransf orm to solve the differential
equation. This is certainly unnecessary for this simple equation, but it does illustrate the
use of the LaplaceTransf orm to solve differential equations. Take the Laplace-
Transform of eql:
In[20]:= lapTx = LaplaceTransform[eql, t, s]
Ou t [2 0] = LaplaceTrans form [x(t) , t, s] s2-x@) s +
ojO2 LaplaceTransf orm [x(t) , t, s] - x' @) ==0
and solve for LaplaceTrans form [x [ t ], t, s ]:
In[21]:= lapSol=
Solve [lapTx, LaplaceTrans?orm[x[t],
t, •]][[!]]
3.2 Linear Oscillations 137
s x @) + x' @) I
0ut[21]= \ LaplaceTransform[x(t) , t, s]
s2 + ojO2
Taking the inverse using the command InverseLaplaceTransform, you get the
solution
In[22]:= InverseLaplaceTransform [
LaplaceTransform[x[t], t, s]/.lapSol,
s, t] //Apart
Sin(t ojO) x' @)
Out[22]= Cos(t ojO) x@) +
ojO
PROBLEM 2 Series Expansion Solution. You may often solve differential equations
using a time series expansion. The following procedure automatically performs the neces-
necessary operations. Enter the user-defined function,
In[23]:= Clear["Global* * " ]
dif f SeriesOne [eq_, z , t_, initialx., initials, order.] : =
Module [ {tempser, tempeq , tempvar, tempsol, tempinit },
tempser = z- > Series [z, {t, 0, order}];
tempeq = ( (eq[[l]] -eq[[2]]) //.tempser) ==0 ;
tempvar = (Table [D[z, {t, j}], {j, 2, order + 2}]/.t- > 0)//Flatten;
tempsol = Solve [tempeq, tempvar]//Flatten;
tempinit = {Head[z] [0]- > initialx, Head[z]'[0] - >initialv};
z/.tempser/.tempsol/.tempinit ]
and protect it.
In[24]:= Protect[diffSeriesOne ];
The input eq is a second-order differential equation, z is the function, t is the inde-
independent variable, initialz and initialv are the initial conditions, and order is the
order of the series solution. This procedure assumes the solution can be written as a power
series.
a. Explain how dif f SeriesOne works by examining the intermediate steps in the
solution of
y"[t] + y y'[tf + w2y[t~\ == +a y'[tfy[t]
b. Consider the linear oscillator equation
x"[t]+oj20x[t]=0
and find its time series expansion. Get the exact answer by using Sum to sum the
terms to infinity.
138 Chapter 3 Oscillating Systems
Solution
In[25]:= Clear["Global'*"]
a. To understand how diffSeriesOne works, examine the intermediate steps. To do this,
re-execute a slightly modified command, diffSeriesOne2. This time, however, delete all the
local variables in the Module and then re-execute the example.
In[26] : = Clear [-Global» * "]
dif f SeriesOne2 [eq_, z_, t_, initialx-, initialv_, order_] : =
Module[ { },
tempser = z- > Series [z, {t, 0, order} ] ;
tempeq=( (eq[ [1] ] - eq[ [2] ]) //.tempser) == 0 ;
tempvar = (Table[D[z, {t, j}], {j, 2, order + 2}]/.t- > 0)//Flatten;
tempsol = Solve[tempeq, tempvar]//Flatten;
tempinit = {Head[z] [0]- > initialx. Head[z]' [0] - >initialv};
z/.tempser/.tempsol/.tempinit
Notice that Module [ {}, ... ] has been written above so you can access the interme-
intermediate results. Enter the equation
In[27] := eql =y"[t] +Y y'[t]~2 + w~2 y[t] = =
a y'[t]~2 y[t];
and apply the user-defined function
In[28]:= dif fSeriesOne2 [eql, y[t] , t, yO, vO,
2]
Out [28]= yO + vO t + - (ayO vO2 - y vO2 - w2 yO) t2 +O(t3)
The step tempser is the series expansion of y [ t ] to the appropriate order:
In[29]:= tempser
Out[29]= y(t) ^y(O) +y'@) t + |y"@) t2 +O(t3)
The command tempeq simply takes the two parts of the input equation, puts them on
the left-hand side of the equation, and then expands with tempser:
In[30]:= tempeq//Short [#, 3] ft
3.2 Linear Oscillations 139
Out[30]= (y@) w2 +yy' @J -ay@) y' @J + y" @) ) +
(-ay' @K +w2 y' @) + 2yy" @) y'@)-
2ay@)y"@) y'@) +y<3> @)) t +
, 5 ,
y @) i«r - - ay"@)V@) +
y (y" @J + y/ @) y<3> @) )-
ay@) (y"@J +y'@) y<3» @)) +
2
yD)@)
t2 +O(t3) = = 0
The independent variables that you want to solve for are stored in tempvar:
In [31] := tempvar
Out[31]= {y" @) , yC> @) , yD) @) }
The coefficients of t are set to zero and solved in tempsol:
In [32 ] : = tempsol // Short [ #, 7 ] &
Out[32]= {yD> @) ->2ay@Kw4-2yy@Jw4+y@) w4-
8 a2 y@K y' @J w2 + 16ayy@J y' @J w2 +
3yy'@)V-8y2y@)y'@Jw2-
8ay@)y'@Jw2-6y3y'@L + 6a3y@Ky'@L-
18a2yy@Jy'@L-7ayy'@L +
7a2y@) y'@L + 18ay2y@) y'@L, yC) @) -»
y'@) (-2ay@J w2 + 2yy@) w2 - w2 + 2 y2 y' @J +
2a2y@Jy'@J+ay'@J-4ayy@) y'@J),
Y"@) ->-y@) w2-yy'@J+ay@) y'@J}
The result follows from substituting this solution, along with the initial conditions, into
the series expression for the function:
In[33]:= y[t]/.tempser/.tempsol/.tempinit
Out [33]= yO + vO t + - (ayO vO2 -y vO2 - w2 yO) t2 +O(t3)
This agrees with
In[34]:= dif fSeriesOne [eql, y[t] , t, yO, vO,2]
Out [34]= yO + vO t + - (ayO vO2 -yvO2 -w2 yO) t2 +O(t3)
b. Clear the variables from the previous calculation
In[35]:= Clear["Global'*"]
The series expansion solution of
In[36]:= eq2 = x" [t] + uO2 x[t] ==0;
140 Chapter 3 Oscillating Systems
follows from the user-defined function diffSeriesOne. Apply diffSeriesOne
function to eq2 and evaluate to order 9, and you get
In[37]:- approxsol=
diffSeriesOne[eq2,x[t], t, xO, vO,9]//
Collect[#1, {x0,v0}]&
Out [37] =
xO
t
8ojO8 t
40320
a^t9
362880
6 ojO6 t
720
ojO6 t7
5040
4w04
24
ojO4 t
1 i?n
t2
5
ojO2
2
ojO2
6
+ 1
t3
Terms are kept to order 9 and grouped according to their initial conditions. Notice
that this series solution can be expressed in terms of two sums:
(-i)n (twoJ11
In[38]:= tennX[n_] = * ' K " ' ;
Bn) !
tenrtV n_ =
0H Bn+ 1) !
as is verified by making the finite sum
In[39]:= f initesum = Sum[ (xO tennX[n] + vO tenKV[n]),
{n, 0,4}];
and comparing it with approxsol
In[40] := finitesum == approxsol//Simplify
Out [40]= True
To get the exact answer, Sum the terms to infinity:
In[41]:= exactSum =
Sum [ (xO termX [n] + vO tennV [n]) ,
{n, o, oo}] //PoworExpand //Apart
vO Sin(t ojO)
Out[41]= xO Cos(tajO) +
ojO
PROBLEM 3 Potential and Phase Diagrams for the Linear Oscillator. Consider a
linear oscillator described by the equation m/[(] + kx[t] - 0.
a. Find the conserved energy by reducing this second-order equation to a first-order
differential equation. Identify the expressions for the kinetic and potential energies
from the conserved energy.
b. Plot the potential energy function and describe the system's behavior.
c. Plot the phase diagram using ContourPlot and ShadowPlot3D.
3.2 Linear Oscillations 141
Remarks and Outline An expression for the conserved energy follows from multiplying
the equation of motion by x' [t] and then integrating. The potential and kinetic energy
follow from the energy expression. A qualitative description of the motion follows from
a plot of the potential energy. Trajectories in phase space follow from plotting the curve
{x[t],x' [t]}. The relation between x[t] and x' [t] follows from the energy ex-
expression. ContourPlot and ShadowPlot3D are two graphic commands that can be
used to display the phase plots. This problem makes use of the add-on packages Graph-
Graphics vFilledPlot vand GraphicslGraphics3DV
Solution
In [42]:= Clear ["Global' *"]
a. The oscillator equation is
In[43]:= Force = m x"[t];
Spring = -k x[t];
eql= Force == Spring
Out [43]= mx"(t) ==-kx(t)
To reduce the problem to a first integral, multiply by x' [t], integrate, and set the results
equal to a constant (the energy):
In[44]:= energy = Integrate[ x' [t] (m x" [t] +k x[t]) ,
t]
Out[44]= - kx(tJ +-m x'(tJ
The kinetic energy T follows from integrating Force and the potential energy V follows
from integrating Spring:
In [45]:= T = Integrate [ x' [t] Force , t];
V = - Integrate [ x' [t] Spring , t];
{T,V}
0ut[45]= {|m x'(tJ, i}
The conserved energy is the sum of the kinetic and potential energies:
In [4 6] : = energy = T + V
Out[46]= -kx(tJ + -m x'(tJ
b. The graph for the potential function follows from applying Plot to V. To embel-
embellish the plot, use the command FilledPlot found in the add-on package Graph-
Graphics lFilledPlotV
In[47]:= Needs["Graphics * FilledPlot»"]
142
Chapter 3 Oscillating Systems
We are interested in
In[48]:= TFilledPlot
FilledPlot[function,{var,varmin,varmax}] generates a plot with the area be-
between the curve and the var axis filled. FilledPlot[{fl,f2,...}, range] gen-
generates a plot with the areas between curve fl and f2, f2 and f3, etc. filled.
The shade of the fill and other specifications can be given by the Fills op-
option. More...
The graph for k = 1 and m = 1 is
In[49]:= FilledPlot [V/. {x[t] -> x, k -> 1, m-> 1},
{x, -1, 1},
PlotStyle- > {Thickness[0.02]},
Fills-> {Hue[0.8]},
Frame -> True ,
RotateLabel -> False ,
PlotLabel -> "V",
FrameLabel -> {"x-axis", "Potential"} ];
0.5
Potential
0.4
0.3
0.2
0.1
-1 -0.5 0 0.5 1
x-axis
The motion is confined to the white region by the dark potential curve. The motion is
bounded for all initial conditions. There is one stable equilibrium position at the minimum
of the potential located at x = 0.
c. ContourPlot and ShadowPlot3D are two graphic commands that can be used
to make phase plots. Consider the phase plot that follows from ContourPlot; you get
contours of constant energy when ContourPlot is applied to energy. Set the values
of m and k equal to 1, and then define the replacements x [t] ->x and x' [t] ->v,
In [50] := values = {m-» 1, k-» 1, x[t] -» x, x'[t] -» v};
it follows
3.2 Linear Oscillations
143
In[51]:= ptl = ContourPlot[
Evaluate [energy/.values], {x, -1, 1},
{v, -1, 1},
ColorFunction-> Hue,
Contours->30,
PlotPoints->30,
ContourStyle - > { Thickness[0.006]},
Axes -> True,
AxesLabel -> {"x[t]», "v[t]"}];
v [t]
0.
-0.
x [t]
We have used several ContourPlot options. The list of options for ContourPlot
follow from entering Options [ContourPlot].
The phase plane {x,v} is filled with nested circles. Each circular phase trajectory
corresponds to a particular value of the conserved energy. The point at the center {x [ t ] =
0, x' [ t ] = 0} represents the position of equilibrium and corresponds to zero energy.
Periodic motion results from all initial conditions except the equilibrium position at the
center.
A second way you can graph the phase plane is to plot the energy surface as a function
of {x[t], x' [t] } and then project the surface onto the plane {x [t], x' [t]}. The
command for the energy surface follows from ShadowPlot3D found in the package
GraphicsvGraphics3Dl:
In[52]:= Needs["Graphics*Graphics3D*"]
In[53]:= ?ShadowPlot3D
ShadowPlot3D[f, {x, xmin, xmax}, {y, ymin, ymax}] plots the function f over
the the x and y ranges with polygons shaded according to the height of the
surface, with a projection of the surface onto the x-y plane. More...
Applying ShadowPlot3D to energy, you get
144 Chapter 3 Oscillating Systems
In[54] := ShadowPlot3D[energy/,values, {x, -1, 1},
{v, -1, 1},
PlotLabel -> "Energy Surface",
Axes -> True,
AxesLabel -> {"x[t]», "v[t]», "energy"},
ShadowPosition -» 1];
Energy Surface
v ty *
The energy surface is projected onto the plane at the top of the plot and represents the
contour plot of the surface.
PROBLEM 4 Damped Linear Oscillator. Consider a damped linear oscillator, where
the dissipation is proportional to the velocity. The equation of motion for the damped os-
oscillator is
x"[t]+yx'[t]+co02x[t]=0.
The damping is characterized by the coefficient y.
a. Solve the equation with initial conditions x[0] = xQ, x'[0] = vO, and describe the
behavior of the solution for the three cases:
(i.) under-damped case, when y1 < 4o>02;
(ii.) critically-damped case, when y2 = 4o>02; and
(iii.) over-damped case, when y2 > 4o>02.
b. Plot the solutions for the under-damped and over-damped cases.
c. Plot the phase space diagram for the under-damped case.
d. Express the second-order damped oscillator equation as two first-order equations
x' [i\ = v[t] and V [t] = -y v[t] - coO2 x[t]
3.2 Linear Oscillations
145
Let the parameters be y = 0.1, coO = 1 (under-damped case) and use the command
PlotVectorField found in the add-on package Graphicsv PlotFieldv to
plot the tangent to the trajectory. Combine the vector field plot with a plot of some
trajectory.
e. Use Laplace transforms to solve the damped equation.
Remarks and Outline The damped harmonic oscillator equation has an exact analytic
solution. The solution yields different behaviors for different parameter values. When the
damping factor equals zero, the system reduces to the case of the simple harmonic oscil-
oscillator: continuous oscillation at the natural frequency with constant amplitude. When the
damping factor is greater than zero the system may or may not oscillate. Depending on the
relation between the damping factor and the natural frequency, there are three cases to con-
consider: 1. under-damped case, y2 < 4oi02; 2. critically-damped case, y2 = 4o>02; and 3. over-
damped case, y2 > 4tuO2. The general solution follows from DSolve. The expression for
the phase plot follows from the user-defined functions timePhasePlot and phase-
Plot. This problem makes use of the add-on package Graphicsl PlotFieldl.
Solution
In[55]:= Clear[-Global'*" ]
a. Consider the damped oscillator equation,
In[56] := eql = x" [t] + y x'[t] + uOx[t] == 0;
and apply the command DSolve:
In[57] := xsol =
DSolve [{eql, x[0] ==x0,x'[0] ==v0},
x[t],t][[l]] //Simplify
Out[57] =
It is convenient to introduce the quantity o>:
In[58]:= uRule = Solve I
Out[58]= |wO -> ^ ^/y2 + 4 0J j
Our solution now reduces to:
== a, ao] [ [2] ]
146 Chapter 3 Oscillating Systems
In[59] := xsol = xsol /.fi)Rule//ExpToTrig //
FullSimplify
e~^ Bx0u Cos (tw) + B vO +xOy) Sin(t w) )
2 u
The result has been reduced to a form where the interpretation is obvious. Notice the
undamped oscillator is recovered in the limit of y->0:
In[60] : = xsol/.y- > 0//PowerExpand//ExpandAll
Out[60]= xO Cos(tw) + v0 Sln<tM)
0)
For the under-damped case (y2 < 4o>02 or to real) the solution is an exponentially
damped amplitude times an oscillating term with angular frequency of to = yjtoO1 — ^.
The amplitude of the oscillation is exponentially damped by the factor e~ ?.
The critically-damped case (y2 = 4o>02 or to = 0) has an exponential type of decay
In[61]:= Limit [xsol, y-> 2uO]
e-two ,xqu cos(tw) + (vO +x0w0) Sin(tw) )
Out[61]=
u
The over-damped case (y2 > 4a»02 or to imaginary) is just a continuation of the
critically-damped case and the solution just decays without oscillating.
b. Consider the under-damped case (y2 < 4o>02 or to real). Let
In [62] := values = |x0 -» 1, aO -» 1, vO- > 0,
--?}¦
The user-defined graphics procedure for the plot of this under-damped case is
In[63]:= pt[yl_/; 0 <= yl <2] : =
Plot[xsol//.values/.{y- >yl}//
Evaluate,
{t, 0, 15},
PlotStyle->
{Hue[Random[]], Thickness[0.03]},
PlotRange- >A11,
DisplayFunction- > Identity ]
The plot is a function of the damping constant. A restriction has been placed on the
value of the damping constant so that it is defined only for the under-damped case. The
solution is plotted for time running from t = 0 to t = 15. An array of under-damped
graphics starting at y = 0 and approaching the critical value at y = 2 is
3.2 Linear Oscillations
147
In[64]:= Show[
GraphicsArray[
{{Pt[0],pt[0.2], pt[0.4]},
{pt[0.8],pt[1.4],pt[1.9]}}
-0.2
2 4 6 81OLZL4
The oscillations become more and more damped and eventually disappear as y ap-
approaches the critical value at 2.
Consider the over-damped case (y2 > 4o>02 or o> imaginary). The plots for several over-
damped cases, starting near the critical value y = 2 and ending at y = 6, follow from
In[65]:= Plot[
(xsol//.values)/.
Y- >Range[2.0001, 6.0001 , 0.4] //
Evaluate,
{t, 0, 15},
PlotStyle- >
Tablet Hue[i], {i, 0, 1, 1/12}]//
Evaluate
10 12
14
The top curve so for y = 2.0001 and the bottom is for y = 6.0001.
c. It is useful to plot the two-dimensional phase trajectory and the three-dimensional
time evolution of the phase trajectory. Both of these graphs are displayed as a graphics
array using the user-defined command doublePlot:
148
Chapter 3 Oscillating Systems
In[66]:= {x, v} = {xsol, D[xsol,t]}//.values/.
{Y^0.2}
Out[66]= {0.502519 e~°-lt
A.98997 Cos@.994987 t) +0.2 Sin@ .994987 t) ),
0.502519 e"°-lt: @.198997 Cos@.994987 t) -
1.98 Sin@.994987 t) ) -0.0502519 e"°-lt:
A.98997 Cos@.994987 t) +0.2 Sin@ .994987 t) )}
In[67]:= doublePlot[x, v, {t, 0.01,30}];
Phase Trajectory
q [t
Phase [t]
P [t]
d. Let us consider a vector field plot of the damped equation and compare it with some
trajectory. Pick the parameters to be y = 0 • 1, o>0 = 1 and let the trajectory have the
parameters and initial conditions.
In[68] := values2 = |y-» 0.1, aO -» 1, xO -» 1, vO
0,
The phase plot {x, x'} for this trajectory is
In[69]:= traj =ParametricPlot[
{ xsol, D[xsol, t] }//.values2 //
Evaluate,
{t, 0, 60},
PlotStyle-> {Thickness [0.008],
6rayLevel[0]},
DisplayFunction -> identity];
where the output has been suppressed. Combine the plot of this trajectory with a vector
field plot of the damped oscillator. The second-order damped oscillator equation can be
expressed as the two first-order equations: x'[t] = v[t] andv'[t] = -y v[t]-
o>02x[t]. For the parameters y = O.landwO = 1 (under-dampedcase) the two first-
order equations become: x'[t] = v[t] and v'[t] = -0.5 v[t] -x[t].The
vector field plot follows from applying PlotVectorField (found in the add-on pack-
package Graphics vPlotFieldv)
In[70]:= Needs["Graphics'PlotField'"]
3.2 Linear Oscillations
to the damped equation,
In[71]:= Clear[x, v] ;
149
ptl=PlotVectorField[
{v, -0.5 v - x} //Evaluate,
{x,-1, 1}, {v,-1,1},
DefaultColor -> Hue[0.6],
plotPoints -> 20,
AspectRatio -> Automatic,
Axes -> Automatic,
AxesOrigin-* {0, 0},
ScaleFunction -> (Is),
' 'r ¦ r *['/??¦
i ill ih 4/1 lif/^
4 . , ./. i.f/nf
» k V y V >^v N> ^ ,
V \ \ \ \ \ "> ^»^_^ ¦.
m) low 'h • i
^><¦¦/¦¦
We added the particular trajectory with Epilog. Notice how the arrows are tangent to
the path. The match would be even closer if more points were kept in the vector field plot.
e. Use Laplace transforms to solve for the damped equation given by eql:
In [72]:= eql
Out[72]= x(t) (JO2 +y x'(t) +x"(t) == 0
The LaplaceTransf orm of eql gives an algebraic equation,
In[73]:= lapTx = LaplaceTransform[eql, t, s]
Out[73]= LaplaceTransform[x(t),t, s] s2-
x@) s +uO2 LaplaceTransform[x(t) , t, s] +
y (s LaplaceTransform[x(t) , t, s] - x@) ) - x' @) == 0
You solve for LaplaceTransf orm [x [ t ], t, s ]:
150 Chapter 3 Oscillating Systems
In[74]: =
Out [74] =
lapSol=
Solve[lapTx,LaplaceTransform
t, s]][[l]]//Si»q?lify
\ LaplaceTransform[x(t) , t, s] -»
.[x[t].
sx@)
s
+ y x @) + x' @)
2 +ys +uO2
Taking the inverse, you get the solution
In[75]:= sol= InverseLaplaceTransform[
LaplaceTransfonn[x[t], t, s]/.lapSol,
s, t]
Out[75]=
PROBLEM 5 Damped Harmonic Oscillator and Driving Forces. Consider the mo-
motion of an under-damped harmonic oscillator with a harmonic forcing term. The motion is
described by the equation
x"[t] + yx'[t] + co02x[t] = QOcos[codt]
where 4o>02 > y.
a. Solve this equation with arbitrary initial conditions. Separate the solution into those
terms that have the coefficient Q0 and those that do not have this coefficient. The Q0
terms correspond to the particular solution, and the terms that don't have a Q0 term
correspond to the solution of the homogeneous equation.
b. Assume the particular solution can be reduced to the form A Cos {cod t+0] and
solve for the amplitude A and phase <f>.
c. Plot the solution as a function of coO and t. Plot the amplitude A as a function of coO
and y. Notice the resonance behavior at coO= aid.
d. Pick parameters to illustrate the transient and steady-state behaviors and plot x[t]
and its phase trajectory.
Remarks and Outline The driven harmonic oscillator with a harmonic driving term has
an exact analytic solution. The solution has two parts: transient and steady-state. The tran-
transient portion, which has the same solution as the damped harmonic oscillator and dies out
exponentially, depends on the initial conditions. The steady-state portion has an ampli-
amplitude that remains constant and does not depend on the initial conditions. Thus, no matter
what initial conditions the oscillator had, it will eventually acquire behavior that is wholly
3.2 Linear Oscillations
151
dependent upon the driving force. The amplitude that the oscillator eventually acquires de-
depends on the relation of the driving frequency to the natural frequency of the oscillator and
on the damping factor.
The hard part of this problem is not the solution of the differential equation; rather,
it is the simplification of the terms. The simplification is done by separating the solution
into those terms that contain QO and those that do not have this constant. The QO terms
correspond to the particular solution and the other terms correspond to the solution of the
homogeneous equation. The simplification of the homogeneous solution is straightforward.
The simplification of the particular solution follows from noticing that it is of the form A
Cos [cod t+0]. Equating this form to the particular solution you get two algebraic equa-
equations when you set the coefficients in front of the Sin [cod t] and Cos [cod t] terms to
zero. These equations can be solved for <p and A. The solution is plotted with the com-
command Plot 3D. The plot of the phase trajectory follows from the user-defined procedures
phasePlot and timePhasePlot listed at the beginning of this section.
Solution
In[76]:= Clear["Global'*"]
a. The damped harmonic oscillator with a forcing term is
In [77] := eql = x"[t] +Y * [t] +fiH2x[t] ==
QO Cos [aid t];
The solution of this equation follows from DSolve.
In[78] := eq2 = x[t] /. DSolve [eql, x[t] , t]//First//
Simplify
Out[78]= e
QO ( (uO2 -ud2) Cos(twd) +yud Sin(twd) )
wO4 - 2 wd2 wO2 + wd4 + y2 <jd2
This solution simplifies if you separately consider the homogeneous terms and the terms
that follow from the particular solution. The homogeneous terms follow from setting the
forcing term to zero,
In[79]:= eq3=eq2/.Q0- > 0
Out[79]= e
where cl = C[l] and c2 = C[2] are arbitrary constants. The rest of the terms in eq2
correspond to the particular solution and are proportional to QO
In[80]:= eq4 = (eq2 -
152 Chapter 3 Oscillating Systems
QO(wO-wd) (wO + wd) Cos(twd) + Q0ywd Sin(t wd)
Out[80]— -. -. ~ ~ ~
wO4 + wd4 + (y2 - 2 wO2 ) wd2
b. The homogeneous solution simplifies if you express the answer in terms of o> =
-y coO2 - 2j- and define two new constants AO and BO by:
In[81]:= oRule =
Solve [|o! == - (AO + iBO),
o2 == | (AO-iBO)}, {C[1],C[2]}]
Out [81]= {ci -» - (AO + i BO), c2 -> - (AO - i BO) }
In[82] ;= uRule = Solve [a/uO2 - — == a, ao] [[2]]
Out[82]= [uO^> | a/y2 +4w2}
The homogeneous solution becomes:
In[83]:= homogSol=
eq3 //.cRule /.aiRule //ComplexExpand//
Simplify //PoworExpand
Out[83]= e~? (AO Cos(tw) + BO Sin(tw))
The constants AO and BO are determined by the initial conditions.
To simplify the particular solution, we try reducing eq4 to the form
In [84]:= eq5 = A Cos [ud t + <t>] //TrigEacpand
Out[84]= A Cos@) Cos(twd) -A Sin(</>) Sin(twd)
How are A and <p related to the original variables? Equating eq4 and eq5, you get
In[85] := eq6 = eq4 - eq5 ==0
Out [85]= -ACos@) Cos (twd) + A Sin@) Sin(twd) +
QO (wO - wd) (wO+wd) Cos(t wd) + QO y wd Sin(twd)
(JO4 + (Jd4 + (y2 - 2 (JO2 ) wd2
= = 0
Two independent equations are obtained from eq6 if you consider the orthogonal
Sin[t aid] and Cos [t aid] dependence:
In[86] := eq7 = {
eq6/.{Sin[^t]- > 0, Cos[^t]- >!},
eq6/.{Cos[.t]- > 0, Sin[.t]- >1}}
3.2 Linear Oscillations 153
r QO (wO -wd) (wO + wd)
Out[86]= —?—i—j ~ - -A Cos (</>) == 0,
LwO4+wd4+ (y2-2w02) wd2 V
—I /^ = -2 + A SinW == o|
wO4 + wd4 + (y2 - 2 wO2 ) wd2 v ' J
Solving these two equations for A and <f>, you get
In[87]:= eq8 = Solve [eq7, {A, <*} ] [ [4] ] //Simplify //
PowerExpand
QO
Out [87]= {a-
34 - 2 wd2 wO2 + wd4 + y2 wd2
wO2 — wd2
O4 - 2 wd2 (JO2 + wd4 + y2 ud2
where we have kept the positive root for A. Further simplification occurs if you replace
ArcCos by ArcTan using the rule
r [ Vl - x2 ) i
In [88]:= rule = | Cos (x4 -> Tan j ;
In[89]:= solA*= eq8/.rule// Simplify//
PowerExpand
r QO
Out[89]= JA-> -
- 2 wd2 wO2 + wd4 + y2 wd2
>Tan
Using this relation for A and <p, the particular solution becomes
In[90]:= partSol = A Cos [aid t + <t>] /.solA*
QO Cosltwd + Tan-1!-^))
Out [90]=
(JO2 + (Jd4 + y2
The general solution genSol is a superposition of the particular solution partSol
and the homogeneous solution homogSol:
In [91] := genSol = partSol + homogSol
QO Cos t wd + Tan^1 \aa ,
Out[91]= X \wo -a* II .
y (JO4 - 2 wd2 wO2 + wd4 + y2 wd2
e~^ (A0 Cos(tw) +B0 Sin(tw))
This is about as simple as you can get.
154
Chapter 3 Oscillating Systems
c. To plot the solution as a function of o>0 and t, let
In [92] := values = [a-» 3, QO -» 1, wd -» 1, AO -» 0,
BO -» 1, fi> -» -w fi>02
Applying the command Plot3D to genSol with these values, you get
In[93] := Plot3D[genSol//.values//, {y -» 0.1}//
Evaluate,
{t, 0,30}, {fiH, 0.5, 1.5},
PlotPoints -> 40,
AxesLabel -> {"Time", "wO", "x[t] "},
FaoeGrids -> {{0, 1, 0}, {0, -1, 0}},
Viewpoint -> {1, 0-4, 0.6}];
Time
0.6
The oscillations are not simple harmonic but contain transient effects. Notice the res-
resonance behavior at o>0 = aid = 1. The resonance behavior follows from the form of
In[94] : =
Plot3D[ A/.solA*/.values //Evaluate,
{Yt 0.001, 0.5}, {<u0, 0.5, 1.5},
PlotPoints -» 25,
PlotRange -> {0, 15},
AxesLabel -» {"yV "«0"# "Amplitude"},
FaoeGrids -» {{-1, 0, 0}},
Viewpoint -> { 0.5, 1, 0.4} ];
3.2 Linear Oscillations
155
coO
1.4
0.5
The resonance occurs at coO = cod = 1, and its height diverges as y->0. The diver-
divergence is clipped, since PlotRange is set to {0,15}.
d. To illustrate the transient and steady-state behavior of genSol, define the plot func-
function
In[95]:= pt [name., opts ] : =
Plot[
name//.values//.{Y-» 0.1, uO -» 2} //
Evaluate,
{t, 0, 80},
opts.
Ticks -> None,
DisplayFunction->Identity];
Apply pt to genSol, partSol, and homogSol,
In[96] := Show[
Graphics[{
Rectangle[{0, 0}, { 1, 1},
pt [genSol, PlotStyle- > Hue [0.8],
Ticks -> Automatic ] ],
Rectangle[{0.6, 0.7}, {1, 1},
pt[partsol, PlotStyle- >Hue[0.4],
Background -> Gray Level [0.9]]],
Rectangle[{0.6,0}, {1, 0.3},
pt [homogSol, PlotStyle- > Hue [0.8],
Background -> GrayLevel [0.9]]]
156
Chapter 3 Oscillating Systems
-0.5
-1
We have used the graphic command Rectangle to arrange the positions of the three
graphics:
In[97]:= TRectangle
Rectangle[{xmin, ymin}, {xmax, ymax}] is a two-dimensional graphics primi-
primitive that represents a filled rectangle, oriented parallel to the axes. Rect-
Rectangle [{xmin, ymin}, {xmax, ymax}, graphics] gives a rectangle filled with
the specified graphics. More...
The main plot is the complete solution, and the inserts are the homogeneous and par-
particular solutions. For t<50, both the transient and steady-state solutions are obvious in
the general solution; for t>50, the solution is dominated by the particular (steady-state)
solution.
The phase trajectory follows from the user-defined commands timePhasePlot and
phasePlot, which are combined in doublePlot:
In [98] := q = genSol//.values//, {y -» 0.1, aH -> 2} ;
P = D[q, t];
doublePlot [q, p, {t, 0, 80} ] ;
Phase Trajectory
P[t]
The first plot illustrates the phase plot with both the steady-state and transient effects,
and the second shows how the transient effect dies off with time. After the transient effects
have become small, the phase plot becomes
In[99]:= phasePlot[q, p, {t, 200,250},
AspectRatio -> Automatic];
3.3 Small Oscillations
157
0.3
0.2
0.1
O1 0
-0.1
-0.2
-0.3
/
\
-0
Phase
.3-0.2-0.1
Trajectory
\
\
0 0.1 0.2 0.3
P
3.3 ¦ SMALL OSCILLATIONS
3.3.1 ¦ Overview of Small Oscillations and Normal Modes
The restoring forces in any actual physical system are only approximately linear functions
of displacement. Systems involving stretching, compressing, bending, or twisting result in
nonlinear systems. Nevertheless, it is remarkable that a vast variety of physical systems
reduce to restoring forces proportional to their displacement for small displacements and
hence lead to simple harmonic vibration. In this chapter we shall consider several examples
of such motion.
Linear systems with many degrees of freedom, such as coupled oscillators, are most
conveniently described by finding the normal modes of the system. Let us consider those
linear systems in which the oscillatory motion is described by a potential and the motion
takes place in the neighborhood of an equilibrium point. The motion can be described by
coordinates qt[t](i = 1,2,3,...«), where qt[t] is measured from the equilibrium position.
If the forces are linear functions of the displacements, the expressions for the potential V
and the kinetic energy T will be quadratic in qt[t]: iV);-g,-[f]^[f] and ^T^q^qyU]. The
coefficients Vtj and TVj form the potential and kinetic energy matrices, respectively.
The equations of motion for this system of coupled linear oscillators can be expressed
in terms of the potential and kinetic energy matrices:
Only for certain initial conditions will the system oscillate at one natural frequency.
When it does, we speak of a normal mode of oscillation. Let the parameters o>j, o>2, o>3,...,
be the normal frequencies of oscillation. For each o>(, there is a corresponding normal
mode of oscillation in the coordinates {#n[f], qa[t], qi3[t], qi4[t], ¦¦¦}, where i indicates the
eigenmode for particles {1,2, 3...}. All of the particles in a normal mode vibrate with the
158 Chapter 3 Oscillating Systems
same frequency. A complete solution of the motion involves a superposition of normal
modes.
You often want to solve for the eigenvalues and eigenvectors for systems in the limit of
small oscillations. It is useful to create a user-defined procedure to do this. The user-defined
procedure is defined below.
3.3.2 ¦ Initialization of User-Defined Funtions for Small Oscillations and Normal Modes
3.3.2.7 ¦ Eigenvalues and Eigenvectors for Small Oscillating Systems
Given the expressions for the kinetic and potential energies of the system, the procedure
smallOsc[T#V#{ql[t] ,q2 [t], • • .}#{ql0,q20, • • -},t] finds the eigenfre-
quencies and eigenvectors:
In [100] := smallosc [T_, V_, coord-List, equlib-List,
t_:t] : =
Module [ {q, p, dim, equlibRule, Vij ,
Tij, matrix, aJSol, freq, vector,
eqs, vSol},
q = coord;
p = D[coord, t]; dim = Length [q];
equlibRule = Thread [coord -> equlib];
Vij = Outer[D[V, #1, #2]ft, q, q];
Tij = Outer [D[T, #1, #2] ft, p, p ] ;
matrix = Vij - u2 Tij/.equlibRule;
oi2Sol =
Simplify[Solve[Dot[matrix] == 0, fiJ]];
freq = ai2/.ai2Sol; vector = Array [a, dim];
eqs = Simplify[
ExpandAll[
Thread[0 == matrix.vector]]];
vSol = Table[
Solve[Join [eqs/.<u2Sol[[i]],
{vector.vector ==1}]
, vector] [[2]], {i, l,dim}];
{freq, vSol} ]
Protect the user-defined procedure from being deleted with
In[101]:= Protect[smallosc];
To see how to apply the procedure consider the kinetic and potential energies,
In[102] : = T= |m ql'(tJ + ^m q2'(tJ;
V= |kl (q2(t) -ql(t)J;
Applying the user-defined procedure, we get
3.3 Small Oscillations
159
In[103]:= smalloso [T, V, {ql [t] , q2 [t] }, {0, 0},
t]
Out [103] =
0
2kl
The first list in the output is the square of the eigenfrequencies, and the remaining lists
are the associated eigenvectors.
PROBLEM 1 Two Coupled Oscillators along a Line. Consider the vibrations of two
particles of mass m connected to each other by a spring of stiffness jfcl. Each particle is
also connected to the wall by two more springs with equal spring stiffness kl. Let x[l]
and x[2] be the displacements from the equilibrium configuration for the two particles.
Consider small vibrations along the line of the particles.
kl
xl
x2
a. Derive the algebraic equations for the eigenfrequencies and eigenvectors. Solve for
the eigenfrequencies and eigenvectors using the command Solve.
b. Use the command Reduce to solve the algebraic equations for the eigenfrequencies
and eigenvectors.
c. Use the user-defined function smallOsc to solve for the eigenfrequencies and eigen-
eigenvectors.
d. Write the general solution and plot the motion for the normal modes and for a mix-
mixture of normal modes.
Remarks and Outline The algebraic equations follow from expanding the kinetic T and
potential energies V for the system about the point of equilibrium. The Tij and Vi j
matrices for small oscillations follow from the coefficients in front of the quadratic terms
in *[i]'[f] and x[i] [t]. The eigenfrequencies follow from solving Det [Vi j -o>2Tij ]
= 0. The algebraic equations for the eigenfrequencies and eigenvalues can be solved using
the commands Solve or Reduce. Alternately, the user-defined command smallOsc
summarizes these steps and returns the eigenfrequencies and eigenvalues for the system.
The solution also follows from the commands Eigenvalue and Eigenvector, or the
command Eigensystem. The general solution is a linear combination of terms of the
form cos[ toi t + <f>i], where toi are the eigenfrequencies and <f>i. are the phases.
160 Chapter 3 Oscillating Systems
Solution
In[104]:= Clear["Global **"]
a. The kinetic and potential energies for the coupled oscillators are
In[105] := T= | m x[l]'[t]2 + | m x[2]'[t]2;
V= |k2x[l][t]2 + |2
|kl (x[2][t] -x[l]
where the coordinates and momenta
In[106]:= q = {x[l] [t],x[2] [t]};
P = D[q, t];
are the displacements from the equilibrium configuration. Note here the use of the
x[i] [t] notation. This allows you to use the i index to label the coordinates and
momenta, while still taking advantage of the derivative shorthand notation *[i]'[f]: The
Tij and Vi j matrices for small oscillations follow from the coefficients in front of the
quadratic terms in x[i]' [t] and x [ i ] [ t ]:
In[107]:= Tij = Outer [D[T, #1, #2]ft, p, p]
Vij = Outer [D[V, #1, #2] ft, q, q]
°""""- C I)
The eigenvector matrix is
In[108] := (matrix = Vij - u2 Tij) //MatrixForm
-kl X
Out[108]= (kl + k2
I -kl kl + k2-mw2 I
where o>2 is the square of the eigenfrequency.
The eigenfrequencies follow from setting the determinate of matrix equal to zero and
solving for o>2 :
In[109] := 0JSol = Simplify [Solve [Det [matrix] == 0, oJ] ]
k2 1 r 2 kl + k2 ¦
Out [109]= {{w2-»—},(w2
m J ^ m
The square root of o>2 gives the two eigenfrequencies.
The eigenvector {al, a2 } for the first eigenfrequency, o>2 = k/m, follows from solv-
solving the algebraic equations (Af,- -v ¦ = 0):
3.3 Small Oscillations 161
In[110] : = vector = Array [a, 2];
eq = Thread[0 == matrix.vector]
Out[110]= {0 == (kl + k2 -mw2) a(l) -klaB) ,
0 == (kl + k2-mw2) a B) -kla(l) }
To obtain the appropriate eigenvector, you must substitute the appropriate eigenvalue for
a>2. Here you solve for the first eigenvector in eq by substituting with o>2Sol [ [ 1] ] :
In[lll] := eql = Simplify [ExpandAll [eq/.aJSol [ [1] ]]]
Out[lll]= {kl (a(l) -aB)) ==0,kl (aB) -a(l)) ==0}
The normalization equation is
In[112]:= eqNonn = {vector.vector == 1};
Solving eql for the eigenvector (i.e., the components of vector), you have
In[113] : = evlrule = Solve [Join[eql, eqNonn] , vector] [ [2] ]
Out[113]= {a(l) ->—,aB) ->—}
The eigenvector for the second normal frequency follows from eq by replacing the
eigenvalue with o>2Sol [ [2] ]:
In [114]:= eq2 = Simplify [ExpandAll [eq/.aJSol [ [2] ]]]
Out[114]= {kl (a(l) +aB)) ==0,kl (a(l) +aB)) ==0}
The components for the eigenvector {a [ 1 ], a [ 2 ] } are
In[115] := ev2rule = Solve [Join[eq2, eqNonn] , vector] [[2]]
Out[115]= (a(l) -»—,aB) ->—-=\
b. Instead of first solving for the eigenfrequencies and then eigenvectors, Reduce does
both calculations simultaneously. Applying Reduce to the matrix equation,
In[116]:= eq3 = Thread[0 == matrix.vector]
Out[116]= {0 == (kl +k2 -mw2) a(l) -klaB) ,
0 == (kl +k2 -mw2) a B) -kla(l) }
and reducing for {o>2, al, a2}, you get the relevant solutions
In[117]:= (sol = Reduce [Flatten [{eq3, eqNonn}],
{<u2,a[l], a[2]}] [[{8, 10}]])//
ColumnForm
162 Chapter 3 Oscillating Systems
k2 1 1
UJ == — Aa(l) == —= A a B) == —= ,
n,,f m7,_ ni -J2 v2
Out [117]- 2kl+k2 1 1
u2 == Aa(l) == —= A a B) == —= Akl*OAm*O
m V2 V2
c. The eigenfrequencies and eigenvectors also follow immediately from the user-defined
function smallOsc. Applying smallOsc to T and V, you get
In[118]:= eq4 = smallOsc [T, V, {x[l] [t],x[2] [t]},
{0,0}, t]
k2 2 kl + k2
Out [118]= - m
The command smallOsc returns two lists. The first list is the set of squared eigenval-
eigenvalues; the second is the set of eigenvectors, in the same order. These solutions agree with the
results derived in Parts a and b.
d. The general solution is a linear combination of terms of the form cos[o>lf + <f>l] and
cos[o>2f+<f>2], where o>l and o>2 are the two eigenfrequencies. By defining the eigenmatrix:
In[119] : = eigenmatrix = vector//, {evlrule, ev2rule}
1 1
Out[119]=
V2" V2
1
V2 V2
the general solution is
In[120]:= xRule =
{xl[t]#x2[t]}-»
Transpose[eigenmatrix].
{ol Cos [wit
Thread //Simplify
cl Cos @1 + t wl) + c2 Cos @2 + tw2)
Out[120]= (xl(t) -
x2(t)
V2
cl Cos @1 + twl) - c2 Cos @2 + tw2)
V2
where cl and c2 are the relative amplitudes of the two normal modes. The eigenfrequen-
eigenfrequencies, o>l and oil, are
In[121]:= freqrule=
Thread [{oil, ai2}-> (Sqrt [oJ]/.oJSol) ]
f /k2 / 2 kl + k2 -i
Out[121]= wl-»A/ — 'w2-» /
L A/ m A/ m >
The two normal modes correspond to the special cases c2 = 0 and cl = 0.
3.3 Small Oscillations
Consider the value of the parameters given by
163
In[122] := values = {kl -> 1, k2 -> 1, m-» 1, *1 -> 0, 42 -> 0};
For simplicity, you collect all the appropriate rules into allRules:
In[123] : = allRules = Join[xRule, freqrule, values] ;
Next, examine the first normal mode {cl = 1, c2 = 0}. Use Plot to plot the mo-
motion of the two coordinates {xl [t] ,x2 [t] } on the same graph separated by a distance
ofx = 2.
In[124]:= ptla =
Plot[
{xl[t] +1, x2 [t] - 1}//.allRules//.
{ol -»1# c2 -» 0} //Evaluate,
{t, 0, 20},
PlotStyle -> { {Thickness [0.01], Hue [0.6] },
{Thickness[0.005], Hue[0.9]}}
1.5
1
0.5
-0.5
-1
-1.5
10
The top graph corresponds to the motion of x [ 1 ] and the bottom left is x [ 2 ]. From
both plots, you can see that the motion is simple harmonic and the objects are in phase.
Another way to display the motion is to use the command ParametricPlot and
map the trajectory of this system in the {xl [t], x2 [t] } plane. This path is known as
a Lissajous figure, developed by the French physicist Jules Lissajous. A Lissajous pattern is
a graph of one displacement plotted on the y axis combined with the second displacement
plotted on the x-axis. In general, if the displacements are both periodic functions of the
formx = Sin [oil t+c] andy = Sin[o>2 t], then different patterns are generated
for different values of o>l and o>2 and phase shift c. The simplest patterns are formed
when the ratio of o>l and o>2 are rational numbers. Applying ParametricPlot to our
example with {cl->l#c2->0}, you get
164
Chapter 3 Oscillating Systems
In [125] : = ptlb = ParametricPlot [
{xl[t],x2[t]}//.allRules//.
{ol -> 1, c2 -» 0} //Evaluate,
{t, 0, 20},
AxesLabel -> {xl, x2}];
0
0
0
-0.6 -0.4 -0.2,
yS*-®
yS 0
yS 0
x2
.6
.4
.2
.2
.4
.6
0.2 0.4 0.6
xl
The straight line means the two displacements are in phase.
Next, examine the second normal mode {cl = 0, c2 = 1} using the same types
of graphics. The plot for the amplitudes follows from
In[126]:= pt2a =
Plot[
{xl[t] +I,x2[t] -l}//.allRules//.
{ol -> 0, o2 ->1} //Evaluate,
{t, 0, 20},
PlotStyle -> { {Thickness [0 .01] , Hue [0.6]},
{Thickness[0.005], Hue[0.9]}},
DisplayFunction->Identity];
and the Lissajous path is
In[127]:= pt2b = ParametricPlot[
{xl[t],x2[t]}//.allRules//.
{cl -» 0, c2 -»1} //Evaluate,
{t, 0, 20},
DisplayFunction->Identity] ;
Displaying the two graphs side by side, you get
In[128]:= Show[GraphicsArray[{pt2a, pt2b} ] ] ;
1.5
1
0.5
^AAAAA
-0.5
-1
-1.5
-0.4
-0.6
J..20.40.6
3.3 Small Oscillations
165
The second normal mode (graphs on the left) is out of phase—one displacement is
maximum while the other is a minimum. The straight line in the Lissajous figure is again
indicative of the out of phase motion.
Finally, examine a mixed mode {cl = 1, c2 = 1}. The plots for the displacements
are
In [1291:= pt3a =
Plot[
{xl[t] +1, x2[t] -
{cl -> 1, c2 -> 1} //Evaluate,
{t, 0, 20},
PlotStyle-> {{Thickness [0.01], Hue[0.6]},
{Thickness[0.005],Hue[0.9]}} ] ;
The motion is a combination of harmonics with different frequencies.
The phases and multiple frequencies create a Lissajous pattern that is not a simple curve;
the pattern fills a rectangle.
In[1301.• = pt3b = ParametricPlot[
{xl[t],x2[t]}//.allRules//.
{cl -> 1, c2 -> 1} //Evaluate, {t, 0, 50} ] ;
PROBLEM 2 Three Coupled Oscillators along a Line. Consider the vibrations of
three particles that are coupled by springs. Two particles of mass m are symmetrically
166 Chapter 3 Oscillating Systems
located on each side of a third particle of mass M. All three particles are on a straight line.
The three particles are joined by two springs with equal force constants k. Consider only
vibrations along the line of the particles. Let x [ 1 ], x [ 2 ], and x [ 3 ] be the displacements
from the equilibrium configuration for the three particles.
xl x2 x3
a. Find the kinetic and potential energies for the system. Solve for the eigenfrequencies
and eigenvectors.
b. Write the general solution and plot the motion for the normal modes and for a mix-
mixture of normal modes.
c. Animate one of the solutions.
Remarks and Outline The eigenfrequencies and eigenvectors follow from the user-
defined command smallOsc. The general solution is a linear combination of the normal
modes.
Solution
In[131]:= Clear["Global **"]
a. The kinetic and potential energies are
In[132]:= T = - m (x[l]'[t]a +x[3]'[t]a)n
^M x[2]'[t]2;
V =
I*
(x[3] [t] -x[2][t]J) ;
where the coordinates are the displacements from the equilibrium positions. Again use the
notation x [i] [t] so that you can easily index the coordinates. The eigenfrequencies and
eigenvectors follow from the user-defined function smallOsc:
In[133]:= solution = smallosc[T, V,
]},{0, 0, 0},t]
3.3 Small Oscillations
167
Out [133] =
-L,aC) * aB) *
V2 V2 m2 + M2 V2 V2 m2 + M2 V2 m2 + M2 ,
The first list is the square of the eigenfrequencies, o>2; the second contains the eigen-
eigenvectors. The first eigenfrequency, o>2= 0, with eigenvector {4=, 4=, 4=}, is not really an
oscillation but represents a translational motion of all three masses.
b. The general oscillatory motion follows from a superposition of the normal modes.
Form the eigenmatrix:
In[134] := eigenmatrix = Array[a, 3]/. solution[ [2] ]
Out[134]=
1
vf
V2
M
1
vf
0
V2m
1
vf
M
V2 V2 m2 + M2 V2 m2 + M2 *s[
The general solution follows from
In[135]:= xRule=
{xl [t] , x2 [t] , x3 [t] } ^
Transpose[eigenmatrix] .
{cl t + ^1, c2 Cos [ai2 t + tf>2],
c3 Cos [&>3 t + 03] } //Thread
Out[135]
xl(t) ^
clt
c2 Cos@2
c3m Cos@3
x2(t)
clt
V2 V2 V2 m2 + M2
V2 c3 m Cos @3 + t 0J)
— ,x3(t)
V3 V2 m2 + M2
cl t + 01 c2 Cos @2 + t 0J) c3m Cos @3 +
V3 a/2 V2 V2 m2 + M2
where the frequencies are given by solution [ [1] ]:
In[136] := freqrule = {al, u2,
Thread
0ut[136]=
Vsolution[ [1] ] //
k - +-
\ M m
168 Chapter 3 Oscillating Systems
The normal modes correspond to {cl = l#c2 = 0#c3 = 0}, {cl = 0, c2
= 1, c3 = 0} and {cl = 0, c2 = 0, c3 = l}. Note that {cl = 1, c2 =
0, c3 = 0} corresponds to a zero frequency and is a pure translation.
Plot the motion of the three coordinates with the parameters given by
In[137] := values = {k-» 1, m-» 1, M-» 3, 01 -» 0,
02-> 0,03 ->0};
Collect all relevant rules into allRules:
In[138] := allRules = Join[xRule, freqrule, values];
A user-defined procedure to plot {xl[t], x2 [t], x3 [t] } versus t on the same
graph is
In[139]:= xPlot [Cl_, C2_, C3-] : =
Plot[
{xl[t] + 2,x2[t],x3[t] -2}//.
allRules//.
{ol ->C1, o2 ->C2, c3 -»C3} //Evaluate,
{t, 0,20},
PlotStyle -> {
{Thickness [0.01], Hue[0.3]},
{Thickness[0.009], Hue [0.6]},
{Thickness [0.007] , Hue [0.9] }},
AxesLabel -> {t,x},
DisplayFunction->Identity];
The procedure xPlot plots {xl[t], x2[t], x3 [t]} as a function of time. The
trajectories are displaced relative to each other along the vertical axis. The input for the
plot function is {C1#C2#C3} .
Another way to display the motion is to use a three-dimensional Lissajous figure. The
user-defined procedure is
In [140] : = xLPlot [C1-, C2., C3-, opts ] : =
ParametricPlot3D[
{xl [t], x2 [t], x3 [t] }//.allRules//.
{cl -> Cl, c2 -> C2, c3 -» C3} //Evaluate,
{t, 0, 20},
BoxRatios -> {1, 1, 1},
AxesLabel -> {xl, x2, x3},
opts,
DisplayFunction->Identity];
The user-defined xLPlot plots {x [ 1 ], x[2]# x[3]} using a three-dimensional
parametric plot. The input opts allows you to add options to the graphics.
3.3 Small Oscillations 169
Let us apply the two plot functions to the trivial first normal mode {cl = 1, c2 =
0, c3 = 0}. The plots for the motions are
In[141]:= Show[GraphicsArray[
{xPlot[l, 0, 0],
xLPlot [1,0,0, Ticks -> None ] } ] ] ;
2.
10 15 20
The curves on the left are for {x[l],x[2],x[3]} versus t. The top curve is x[l]
followed by x [ 2 ] and x [ 3 ]. Note that this corresponds to a pure translation for all co-
coordinates, which is why the eigenfrequency was zero. The parametric plot on the right is
trivial for this case.
Next, display the second normal mode {cl = 0, c2 = l#c3 = 0}. The two
plots are
In[142]:= Show[GraphicsArray[
{xPlot[0, 1,0],
xLPlot [0, 1, 0 , Ticks -> None,
Viewpoint -> {1, 1, 1}] }
10 15
20
x2
Note, masses 1 and 3 are out of phase, while mass 2 (center curve) is stationary with
respect to the others.
Display the third normal mode{cl = 0, c2 = 0#c3 = l}:
In[143]:= Show[GraphicsArray [
{xPlot[0, 0, 1],
xLPlot [0, 0, 1 , Ticks -> None ] } ] ];
170
Chapter 3 Oscillating Systems
-1
-2
nki
Masses 1 (top curve) and 3 (bottom curve) are in phase, while mass 2 is out of phase.
Finally, display a mixed mode {cl = 0, c2 = 1, c3 = 1} (keep cl = 0, since this mode is
trivial). The plots for {41], x[2], x[3]} are
In[144]:= Show[ xPlot [0, 1, 1] ,
DisplayFunction -> $DisplayFunction] ;
and the parametric plot follows from
In [145]:= Shaw [xLPlot [0, 1, 1,
Viewpoint -> {1, 1, 1 }],
DisplayFunction -> $DisplayFunction];
0.4
xl
3.3 Small Oscillations
171
c. To animate the solution, use ListPlot inside a Do loop to generate the individual
graphic frames. Here, take the mixed mode {cl = 0, c2 = 1, c3 = 1}. Choose
the number of frames to be
In[146] := number = 1
(* for more frames make number larger *) ;
then
In[147]:= Do[ListPlot[
{{xl[t] -2,0}, {x2[t],0},
{x3[t] + 2, 0}}//.allRules
//. {cl -> 0, o2 -> 1, o3 -> 1}
//Evaluate,
Plotstyle-> {PointSize[0.05] },
PlotRange-> {{-4,4}, {-1, 1}}],
{t, 0,1- 1/number, I/number} ] ;
-4
1
0.75
0.5
0.25
-0.5
-0.75
-1
Only one frame has been kept. To animate the results double-click on any of the graphics
and use the menu to adjust the speed.
PROBLEM 3 Three Coupled Oscillators along a Circle. Three mass points have equi-
equilibrium positions at the vertices of an equilateral triangle. They are connected by equal
springs that lie along the arcs of the circle circumscribing the triangle. Mass points and
springs are constrained to move only on the circle so that the potential energy of a spring
is determined by the arc length considered.
a. Let two of the masses be the same and the third mass be different from the first two.
Determine the eigenfrequencies and normal modes for small oscillations in the plane
of the circle.
b. Take the limit as all the masses become equal.
c. Plot the normal mode solutions.
172
Chapter 3 Oscillating Systems
ml
Solution
In[148]:= Clear ["Global1 *"]
a. Choose polar coordinates with the origin at the center of the circle and let r be the
radius of the circle. Let 6 [ 1 ], 6 [ 2 ] and 6 [ 3 ] be the angular displacement as measured
from the equilibrium positions. The kinetic and potential energies are
In [149] := T =
r
(m 6[l]'[t]2+m 6[2]'[t]3
ml 6[3]'[t]2) ;
v =
kr
F[3][t] -6[2][t])
where the coordinates are the displacements measured from the equilibrium positions. The
eigenfrequencies and eigenvectors follow from the user-defined function smallOsc:
In [150] := eql =
smallosc [T, V, {6[1] [t],6[2] [t],e[3] [t]},
{0, 0, 0}, t] //SdjBj?lify//PowerEjcpand
3.3 Small Oscillations
173
Out[150] =
1
1
, a
, a
k
B) ->
3k
m
B) ->
I ml +
1
m)
aC) -> —=
= ,aC) ^0
aC)
Vm - ml
a B)
V4 m3 - 4 ml m2 + 2 ml2 m - 2 ml3
Vm - ml ml
V4 m3 - 4 ml m2 + 2 ml2 m - 2 ml3 '
Vm - ml ml
V4 m3 - 4 ml m2 + 2 ml2 m - 2 ml3
The elements in the first list contain the squares of the eigenfrequencies; the remain-
remaining lists are the eigenvectors. The zero eigenfrequency is not an oscillation but is just a
displacement of the particles in the same direction.
To get the equal mass case you set ml = m,
In [151] := solution = Limit [ eql, ml - > m ] //
PowerExpand
0
Out[151]=
1
3k
m
3k
m
This solution is very degenerate and it is obvious that any permutation of the particles
is also a solution.
b. Consider the equal mass case and plot one of the normal mode solutions. The general
oscillatory motion follows from a superposition of the normal modes. Form the eigen-
matrix:
In[152] := eigenmatrix = Array[a, 3] /. solution[ [2] ]
111
Out [152] =
V2
VI
o
174 Chapter 3 Oscillating Systems
The general solution follows from
In[153]:= solrule=
{61[t],62[t],63[t]}^
Transpose[eigenmatrix].
{cl t + phasel, c2 cos [?req2 t + phase2] ,
c3 Cos [?req3 t + phase3 ] } //Thread;
where the frequencies are given by solution [ [1] ]:
In [154] : = f reqrule =
{freql, ?req2, freq3} ->
Sqrt [solution[ [1] ] ] //Thread
Out[154]= (freql-» 0, freq2-» VI./-,
Note that cl corresponds to a pure translation with zero frequency. The normal mode
oscillations correspond to {cl = 0#c2 = l#c3 = 0}, and {cl = 0, c2 =
0, c3 = 1}. To be specific, we choose the following values:
In [155] : - valuerule = {k -» 1, m -» 1, phasel -» 0,
phase2 -> 0, phase3 -> 0} ;
A plot function for 01 [t], 02 [t] and 03 [t] is
In[156]:= xPlot [C1-, C2., C3-] : =
Plot[
{61 [t] + 2, 62 [t] , 63 [t] - 2} /.solrule/.
f reqrule//. valuerule//.
{cl -> Cl, c2 ->C2, c3 ->C3} //Evaluate,
{t, 0,20},
PlotStyle -> {
{Thickness[0.012]},
{Thickness[0.008]},
{Thickness[0.004]}},
DisplayFunction->Identity];
Display the nontrivial normal modes {cl = 0, c2 = 1, c3 = 0} and {cl =
0, c2 = 0, c3 = 1}:
In[157]:= Show[GraphicsArray [
{xPlot[0, 1, 0],xPlot[0, 0, I] }]];
\AAAAA
/\k\l
VlV
-2
\AAAAA
3.3 Small Oscillations
175
The top curves are for 01 [ t ] followed by 62 [ t ] and 03 [ t ]. The normal mode motion
for {cl = 0, c2 = l#c3 = 0} (left graph) has masses 1 and 2 out of phase while
mass 3 is stationary with respect to the others. The second normal mode solution with {cl
= 0, c2 = 0, c3 = 1} (right graph) has masses 1 and 2 in phase while mass 3 is
out of phase.
PROBLEM 4 Double Pendulum. Consider a double pendulum consisting of a massless
rigid rod. The first segment of the rod has one end fixed and the other supporting a particle
of mass ml. The length of this segment is LI. Attached to ml is another segment of
length L2. At the other end of the second segment is a particle of mass m2. Assume the
motion is confined to a plane.
a. Find the normal modes for small oscillations.
b. Plot the normal modes and mixed modes for the motion of the mass points for one
cycle.
c. Animate one of these solutions.
Remarks and Outline The eigenfrequencies and eigenvectors follow from the user-
defined command smallOsc. The general solution is a linear combination of the normal
modes.
Solution
In[158]:= Clear["Global'*"]
176
Chapter 3 Oscillating Systems
a. The coordinates of the masses are {xl#yl} and {x2#y2}. Let 01 [t] and 02 [t]
be the angles between the vertical line formed by the first and second rods, respectively.
Expressing the mass points in polar coordinates, you have
In[159]:= xl = LI Sin[61[#] ]fi;
yl = LI Cos[61[#] ]&;
x2 = xl[#] +L2 Sin[62 [#]]&;
y2 -yl[#] +L2 COS[62[#]]& ;
Use pure functions so that these definitions also apply to derivatives. For simplicity, let
LI - L2 = len:
In[160] : = LI = L2 = len;
The kinetic and potential energies for the two masses are
: = Tl = 1/2 ml(xl'[t]
T2 = 1/2 m2(x2'[t]~2 +y2'[t]~2}
VI = -mlgyl[t];
V2 = -m2gy2[t] ;
T = Tl + T2 ;
V = VI + V2;
The eigenfrequencies and eigenvectors follow from the user-defined command smal-
lOsc:
In[162]:= solution = smallOsc [T, V, {61[t] , 62 [t] },
{0,0}, t]
g I ml + m2 -
Out [162] =
len ml
g ml + m2 +
/ml + 2 m2 Vml + 2 m2 -
b. To construct the general solution, define the eigenmatrix:
In[163] := eigenmatrix = Array [a, 2] //. solution! [2] ]
Out [163] =
3.3 Small Oscillations 177
The general solution will be a linear combination of normal modes with relative ampli-
amplitudes {cl#c2}:
In[164]:= thetaRule =
Transpose[eigenmatrix].
{cl Cos [oil t + 4>1] , c2 Cos [u2 t + <t>2] } //
Out [164]= | 61 (t) ¦
1 Vml + 2 m2
62 (t) ->
Vml + m2 (cl Cos @1 + t oil) + c2 Cos @2 + t oi2) ) \
Vml + 2 m2 '
where o>l and o>2 are the eigenfrequencies and <f>l and 02 are the phases of the normal
modes.
The frequencies are given by the first list of the results returned by smallOsc:
In[165]:= freqrule = {til, u2} -> Sqrt [solution[ [1] ] ] //
Thread
I g (ml + m2 -
Out [165]= wl->J—*
I V l
+ m2 I
lenml
I g (ml + m2 + Vm2 Vml + m2 I
w2^ J—^ '
\l lenml
Plot the motion of the two mass points for the values
In [166] := values = {ml -» 3 , m3 -» 1, len -> 1, g -> 1,
4>l-> 0,^2 -> 0};
Collect all relevant rules into allRules:
In[167] := allRules = Join [thetaRule, values, f reqrule] ;
Next create a graphic object that represents the two rods of the pendulum. The
line comes from connecting the origin {0,0} with the coordinates of the first rod
{xl [t] ,yl [t]}, and the second rod {x2 [t] #y2 [t]}. Make this graphic object
a function of {cl, c2 } so that you can vary the relative weights of the normal modes.
In [168]:= line[ol_, o2.] =
Line[{{0, 0},{xl[t],-yl[t]},
{x2[t], -y2[t]}}] //.allRules;
The graph for the normal mode described by {cl = 1, c2 = 0} is
178
Chapter 3 Oscillating Systems
In [169]:= Show[
Graphics[Table[N[line[l,0]],
{t, 0,4, 0.1}]]];
Note that this is a symmetric mode in the sense that the two rods are moving in the same
direction.
The graph for the second normal mode described by {cl = 0, c2 = 1} is
In[170]:= Show[
Graphics[Table[N[line[0, 1] ],
{t,0,2.5,0.2}]]];
Note that this is an antisymmetric mode in the sense that the two rods are moving in
opposite directions.
The graph for a mixture of normal mode states {cl = 1/2, c2 = 1/2} is
:= Show[
Graphics[Table[N[line[0.5,0.5]],
{t, 0, 6, 0.2}]]];
3.3 Small Oscillations
179
This motion appears complex; however, this solution can be understood more com-
completely by animating this mode.
c. The animation of this last case follows from enclosing the Show command inside a
Do loop:
In[172]:= frames = 1;
Do[Show[Graphics[N[line[0.5, 0.5]],
PlotRange- > -2, 2, 0, -2]], t, 1, 25, 2 5/frames];
Only one frame has been kept. Increase the number of frames. To animate the results
double-click on any of the graphics and use the menu to adjust the speed. Note the charac-
characteristic behavior. The top rod leads, and then the bottom rod follows. It appears as though
only one rod is moving significantly at any time.
PROBLEM 5 Understanding the User-Defined Procedure smallOsc[ ]. How does
the user-defined function smallOsc work?
Solution
In [173]:= Clear ["Global' *"]
To see how this works examine the intermediate results. Do this by eliminating the local
variables by executing a related function small0sc2 with the modification:
180 Chapter 3 Oscillating Systems
In[174] := small0sc2 [T_, V_, coord-List, equlib-List,
t. :t] : =
Module[{},
q = coord;
p = D[coord, t]; dim = Length[q];
equlibRule = Thread[coord -> equlib] ;
Vij = Outer [D[V, #1, #2]S,q, q] ;
Tij = Outer [D[T, #1, #2]S, p, p ] ;
matrix = Vij - <u2 Tij /.equlibRule;
aJSol =
Simplify [Solve [Dot [matrix] ==0,aJ]];
freq = aJ/.ai2Sol; vector = Array [a, dim];
eqs = Simplify [
ExpandAll[
Thread[0 = = matrix.vector]]];
vSol=Table[
Solve[Join[eqs/.u2Sol[[i]],
{vector.vector == 1}]
, vector] [[2]], {i, l,dim}];
{freq,vSol} ]
Here the local variables have been removed from the statement Module [{}...].
Consider two equal masses that are described by the kinetic and potential energies:
In[175] := T = - m ql'[t]2 + - m q2'[t]2;
2 2
The eigenvalues and eigenfunctions for small oscillations are
In[176]:= smallosc2 [T, V, {ql[t] , q2 [t] }, {0, 0},
t]
2*1
Out [17 6] =
Examining the internal variables, it is obvious that q is the coordinate list, p is the
velocity (momentum) list, and dim is the dimension of normal modes:
In[177] : = {q, p, dim} //ColumnForm
{ql(t),q2(t)}
Out [177]= {ql'(t),q2'(t)}
2
The equilbList is the list of equilibrium positions; convert this into equlibRule
so that you can make the appropriate replacements:
3.3 Small Oscillations 181
In[178]:= equlibRule
Out[178]= {ql(t) -»0,q2(t) -» 0}
Vi j and Ti j are the potential and kinetic energy tensors, respectively:
In [179] := {Vi j , Ti j } // ColunmForm
/ kl -kl \
oatnm- Uln kl ]
\0 m /
Note the use of Outer to compute the derivative of these matrices with respect to the
appropriate coordinates. The matrix is formed from Vt ¦ - co2T;, and the solutions of the
determinate of this matrix yield the square of the eigenfrequencies:
In [180] := fiJSol
Out[180]= ({w2 -»0}, (w2 -» ^L}\
i i m J J
This procedure may fail if the algebraic solution cannot be found or is returned with
complex terms even though the solutions are real. To find the eigenvectors, solve the equa-
equation matrix, vector = 0 with various a>2 values given in a>2Sol. For example, the
eigenvector associated with the first eigenfrequency is
In[181]:= Solve[Join[eqs/.w2Sol[[1]],
{vector.vector == 1}], vector]
Out[181]= {{a(l) ->--^=,aB) ->—7=}/
Note that you get two solutions. Select the second of these with [ [2] ]. Using the
Table command, collect all eigenvectors associated with all eigenfrequencies. You finally
get the list of eigenfrequencies and eigenvectors:
In[182] : = {f req, vSol}
0
Out [182]=
Certainly this procedure can be made more time efficient and additional defaults and
options can be added to the procedure. The eigensystem could have been solved using
the built-in functions Eigensystem, Eigenvectors, and Eigenvalues. The user-
defined procedure will fail in special cases so you are encouraged to write conditional
statements to handle these cases. Again, we emphasize that our goal is to solve the physics,
not to write an all-purpose foolproof package.
182 Chapter 3 Oscillating Systems
3.4 ¦ OSCILLATING CIRCUITS
3.4.1 ¦ Overview
One of the most familiar oscillating electrical systems is a circuit with a resistance, capac-
capacitance and inductance. The analysis of such a system has a remarkable similarity to the
mechanical systems we have been concerned with so far. One of the simpler circuits con-
consists of a time-dependent emf V[t], a resistance R, and a capacitor C, connected in series.
The equation for the charge is
The capacitor is a device for storing electric charge and the associated electrostatic
potential energy. If you replace the capacitor with an inductor, then the circuit is described
by
V[t]=Rq'[t}+Lq"[t]
The charge q[i\ is related to the current I[t] by
In the case of a series circuit that contains all four—an electromotive force V[t], in-
inductance L, capacitance C, and resistance R—then the basic equation for the charge q[t]
is
This is precisely like the basic differential equation for a harmonic oscillator that has a
damping and a driving term. The charge q plays the role of the displacement x, L appears
in the place of mass, C replaces the spring constant k, and the resistor R causes damping.
PROBLEM 1 Series RC Circuit. Consider a circuit consisting of a time-dependent emf
V [t], a resistor R, and a capacitor C, connected in series.
a. Solve for the charge q[t] with an arbitrary V[t].
b. Evaluate the general solution found in Part a when V[t] = VO Cos [a* t] and
q[0] = qO.
c. Make a two-dimensional plot of the charge as a function of t. Make a three-
dimensional plot of the charge as a function of t and C.
Remarks and Outline Part a shows how DSolve returns a symbolic solution for the
first-order RC differential equation.
Solution
In[183]:= Clear["Global* *"];
3.4 Oscillating Circuits 183
a. The charge q[t] in the RC circuit obeys the differential equation
In[184]:= eql=V[t] == Rq' [t] + q[t] /C
Out [184]= V(t) == 3iH +Rgf(t)
Solving eql for q [t] with an arbitrary voltage V [t], you get
In[185] : = dsol = DSolve [eql, q[t] , t] [[1]]
Out[185]= |q(t) ->e~^* c1 +
b. The dsol for the potential VO Cos [a* t] becomes
In [186]:= V[t_] = VO Cos [u t] ;
q[t_] =q[t]/.dsol//Simplify
Out[186]= q2 r2^
R2(J2c1C2-e cr RVOu Sin(K$1757w) C2 +
en rvOw Sin(tw) C2 - e^Wr1 VO
Cos (K$1757 w) C + e^ V0 Cos (t w) C + c^
Expressing C [ 1 ] in terms of the initial conditions q [ 0 ] = qO, you get
In[187]:= olSol = Solve[q[0] == qO, C[l] ] [ [1] ]
tPW1 RVOu Sin(K$1757w) C2
Out[187]=
Cz Rz W1 + 1
^^w1 vO Cos(K$1757w) C VO C
Cz Rz W1 + 1 Cz Rz Uz + 1
qO
C2 R2 (j? + 1 C2 R2 UJ + 1
and the solution for the charge becomes
In[188]:= q[t_] = q[t]/.olSol//FullSimplify
Out [188]= , , 9 (e*c% (c2 qO R2 u2 + qO-
C2 R2 or + 1 \ \
CVO tCen VO (Cos(tti) tCRu Sin(tw) ) ) )
c. The plot of the charge as a function of time for the parameters
184
Chapter 3 Oscillating Systems
In[189] := valuesl = {qO-» 1, VO-» 1, C-» 1, R-» 1, w
is
In[190] := Plot[q[t]/.valuesl //Evaluate,
{t, 0,6},
AxesLabel -> { "time", "charge"},
PlotLabel-» "RCLoop"];
-» 6};
RC Loop
time
A three-dimensional plot of the charge as a function of the variables t and C is
In[191] := values2 = {qO -»1, V0 -» 1, R-» 1, a -» 6};
In[192] := Plot3D[q[t]/.values2 //Evaluate,
{t, 0, 6},
{CO.01,0.25},
AxesLabel -> {"Time", "Capacitance",
"Charge"},
Ticks-> {Automatic, {0.01, 0.1, 0.2 },
Automatic},
FaceGrids -> {{0, -1, 0}},
Viewpoint -» {0.3, -1, 0.3},
PlotPoints -> 35] ;
Capacitance
Time
PROBLEM 2 Series RL Loop. Consider a circuit consisting of a time-dependent emf
V[t] = V0 Cos[o> t], a resistor R, and an inductor L connected in series.
3.4 Oscillating Circuits 185
a. Solve for the charge q [t] and the current q' [t].
b. Make a two-dimensional plot of the charge and current as a function of t for the
initial condition q [ 0 ] = 0.
c. Take the Fourier transform of the data formed by the solution of the charge found in
part b. Include a random error to make the data table appear more like the results of
an actual measurement.
Remarks and Outline This problem follows from applying DSolve to the circuit equa-
equation. In part c, you see how the Fourier transform shows the periodic behavior of the oscil-
oscillating system. We make use of the package Statistics * Normal Distribution*
to generate a normal error distribution.
Solution
In[193]: = Clear["Global* *"] ;
a. The time dependence of the charge is described by the equation
In[194] : = eql = V[t] == Lq"[t] +Rq'[t]
Out [194]= V(t) ==Rq'(t) +Lq"(t)
Assume the voltage V[t] and initial conditions are
In[195]:= V[t_] = VO Cos [o> t] ;
initial = {q[0] == qO, q' [0] == iO} ;
Applying DSolve to eql, you get
In [196]: = qsol =
(DSolve[{eql,initial}//Flatten,
q[t],t]//Flatten// Simplify)
Out[196]= je'TT eT VO Sin(tw) R
w I I - 1 + e" iO L (R2 + L2 u2 ) +
R LVO + e" qo (R2 + L2 co2 )
LRVOu Cos(tW) /(Rll (R2 +L2 @2) )
The current follows from the derivative of the charge:
In[197] := isol = D[qsol, t]//Fullsijoplify
186
Chapter 3 Oscillating Systems
Out[197]= -=
R2
R2 + L2
|i0R2-V0R+
|
VO (R Cos(tw) +Lw Sin(tw) )
b. For the values of the parameters,
In[198] := values = {R-» 0.1, L-» 2, VO -» 1, w-» 1,
iO -> 0.1, q0-» 0};
the graphics for the current and charge are
In[199] := Plot[{qsol, isol}/.values //Evaluate,
{t, 0, 20},
PlotStyle -> {
{Hue[0.3], Thickness[0.01]},
{Hue[0.9], Dashing[{0.03}],
Thickness[0.02]}},
Frame -> True,
FrameLabel -> { "Time" , " " },
GridLines -> Automatic];
1.5
0.5
-0.5
A
/
\. I**
~/\
m %
t %
\ /
V
r
r\
\i
\ I
10
Time
15
20
Here you see that the current (dashed line) oscillates in a regular fashion, but the charge
through the circuit (solid line) is slowly accumulating.
c. It follows from qsol that the charge has periodic terms of the form Cos [o> t]
and Sin[o> t]. The Fourier transform is the basic tool for analyzing such oscillating
systems. To Fourier-analyze the time dependence of the charge, generate a 300-item list
of q [t] for the parameters given by values. We add a random error using the package
Statistics'NormalDistributionV
In[200]:= «Statistics'NormalDistribution1
3.4 Oscillating Circuits
187
In[201]:= fourierdata =
Table[
qsol
RandomArray[NormalDistribution[
1, 0.1], 1] [[1]] /.values//N,
{t, 0, 100 JT, 100jt/300}] ;
The Fourier transform of the data and the plot of its absolute value is
In[202]:= ListPlot[
Abs[Fourier[fourierdata]],
PlotJoined -> True,
PlotStyle -> Hue [Random] ,
PlotRange -> {0, 5}];
50 100 150 200 250 300
This graph shows a strong peak at 50 and another at 250 due to aliasing; this result is
expected from the Fourier transform of the data generated.
PROBLEM 3 RLC Loop. Consider an RLC circuit consisting of an emfV = 0, a resis-
resistor R, an inductor L, and a capacitor C connected in series.
a. Solve the RLC circuit by taking the Laplace transform of the circuit equation.
b. Make a two-dimensional plot of the charge and current as a function of time. Make
a three-dimensional plot of the charge as a function of t and L.
Remarks and Outline Although DSolve will solve the RLC differential equation,
LaplaceTransf orm is used to illustrate how this method can be used to solve certain
differential equations.
Solution
In[203]: = Clear["Global* *"] ;
a. The differential equation for the charge q [t] in an RLC circuit is
188
Chapter 3 Oscillating Systems
In[204] := eql = Lq"[t] + Rq'[t] +q[t]/C == 0;
Taking the Laplace transform of eql, you get
In[205] := eq2 = LaplaceTransform[eql, t, s] //Simplify
Out[205]= - ( (Cs (R + Ls) + 1) LaplaceTransform[q(t) , t, s] -
C (Rq@) +L (sq@) +q'@)))) ==0
It follows from the algebraic solution of eq2 that the Laplace transform of q [t] is:
In[206] : = solO =
Solve [eq2, LaplaceTransform[q[t], t, s] ] [ [
1]]
Out[206]= | LaplaceTransform[q(t) , t, s] ->
C (Rq@) +L (sq@)
Cs(R + Ls)+l I
Assume the initial conditions
In[207] := initial = {q[0] ^q0,q'[0] ->i0};
and take the inverse Laplace transform of solO:
In[208]: = eq3 =
InverseLaplaceTransform[
LaplaceTransform[q[t], t, s]/.solO/.
initial, s, t] //Fullsimplify
Out [208] =
B iOL + qOR)
The expression for the charge is rather cumbersome, but can be simplified if you define
the frequency o>02 = 4^5f2. This notation is implemented with the rule
In[209] := freqrule = CR2 -4L-» -4CL2u02;
3.4 Oscillating Circuits 189
With this change in notation the expression for the charge simplifies to
In [210] := charge =
eq3//.freqrule//PowerExpand //
ExpToTrig// FullSimplify
e-fi B LqOwO Cos (t wO) + B iO L + qO R) Sin(t wO) )
Out [210]=
The current follows from the time derivative of the charge:
In[211] := current = D[charge , t]//FullSimplify
Out[211]= = (e~n D iOL2 (JO Cos(twO)-
4 l/ uO \
B iOLR + qO (R2 + 4 L2 wO2)) Sin(twO) ) '
b. Consider the parameters
In[212] := values = {R-» 1, C-» 1, L-» 4, qO-» 1, iO -» 0};
for the plots of the charge and current. The value of o>0 follows from
In [213] := airule =
Solve [Vcr2 -4L == 2i VclwO#wo] [[1]]
The labels for the graphs follow from
In[214]:= text =
{Text[StyleForm["Charge" ,
FontFamlly- > "Times - Bold",
Fontsize->15] , {5,0.8}] ,
Text[StyleForn["Current" ,
FontFamily- > "Times - Bold",
Fontsize->15 ] , {8,0.3}]};
Adding the labels to the curves with the option Epilog, the plot of the charge and current
is
190
Chapter 3 Oscillating Systems
In[215] .- = Plot [{charge, current}/.airule/. values//
Evaluate,
{t,0.001,20},
Plotstyle -> {
{Hue[0.3],Dashing[{0.01}],
Thickness[0.01]},
{Hue[0.9],Dashing[{0.02}],
Thickness[0.008] }},
Frame -> True,
FrameLabel -» {"Time", ""},
GridLines -> Automatic,
Epilog -> text];
0.6
0.4
0.2
0
-0.2
-0.4
* Chi
\
\
\ \
Currei
<' A
h /
it
"V.
10
Time
15
20
To study the effects of inductance on the charge, consider a three-dimensional plot of
the charge as a function of the variables time and inductance L. For the parameters
In[216] := values2 = {R-» 1, C-» 1, qO -» 1, iO -» 1};
the plot of the charge is
In[217] := pi = Plot3D[charge/.<urule/.values2 //
Evaluate,
{t, 0.01,30},
{L, 1, 4},
Viewpoint -» {1, +3, 1},
FaceGrids-> {{0,0,1}, {0, -1,0}},
AxesLabel -> {"Time", "Inductance",
"Charge"},
PlotPoints -> 30];
3.5 Exercises 191
3.5 ¦ EXERCISES
The solutions to many of these exercises can be found on our web site.
3.1 Blocks Connect with a Spring on a Table
Two identical blocks A and B, both of mass M, are connected by a spring of length L and spring
constant k. Initially, they are at rest on a frictionless straight track. At t = 0, block A is hit
sharply, giving it an instantaneous velocity vO to the right. Find the motion for subsequent
times.
3.2 Falling Blocks Connect with a Spring
Two masses ml and m2 in a uniform gravitational field are connected by a spring of unstretched
length h and spring constant k. The system is held by ml so that m2 hangs down vertically,
stretching the spring. At t = 0, both ml and m2 are at rest and ml is released, so that the
system starts to fall. Find the subsequent motion.
3.3 Parabolic Coordinates and Harmonic Oscillator
Parabolic cylindrical coordinates {?, r\, z) are denned by the equations x = %r\, y = \{jf- - ?2),
and z = z. Consider a three-dimensional isotropic harmonic oscillator.
(a) Express the equations of motion in parabolic cylindrical coordinates.
(b) Solve the equations and plot several solutions.
3.4 Forced Oscillator
Consider the motion of a forced oscillator
x"[t] + ojO2 x[t] = — cos[(ot]
m
(a) Find the general solution.
(b) Assume wO ^ u> and plot the motion. Illustrate the beats and the envelope.
3.5 Pendulums and Spring
Consider a pair of identical simple pendulums of mass m and length b connected to each other
through a massless spring, whose spring constant is k.
(a) Write the solution in the form of its normal modes.
(b) Graph the normal modes and a mixed mode solution.
192 Chapter 3 Oscillating Systems
3.6 Five Particles Connected with Springs
Consider the vibrations of five particles that are coupled by springs. The first particle has mass
m, the second M, the third m, the fourth M, and the fifth m. All five particles are on a straight
line and the particles are joined by four springs with the same force constants k. Consider only
vibrations along the line of the particles.
(a) Find the kinetic and potential energies for the system. Solve for the eigenfrequencies and
eigenvectors.
(b) Write the general solution and plot the motion for the normal modes and for a mixture of
normal modes.
(c) Animate one of the solutions.
3.7 Vibrating Atoms on an Equilateral Triangle
The equilibrium configuration of a molecule is represented by three atoms of equal mass on the
vertices of an equilateral triangle connected by springs of equal force constant. Consider only
vibrations in the plane of the particles.
(a) Find the kinetic and potential energies for the system. Solve for the eigenfrequencies and
eigenvectors.
(b) Write the general solution and plot the motion for the normal modes and for a mixture of
normal modes.
(c) Animate one of the solutions.
3.8 Vibrating Charged Spheres
Two small metal spheres of equal mass m and equal charge Q are suspended by insulating threads
of equal length b from two points separated by a distance a on the same horizontal line.
(a) Find the kinetic and potential energies for the system. Solve for the eigenfrequencies and
eigenvectors.
(b) Write the general solution and plot the motion for the normal modes and for a mixture of
modes.
(c) Animate one of the solutions.
3.9 Quadratic Damping
The form we used in the damped harmonic oscillator for the damping force, the term propor-
proportional to x' [t], was chosen mainly for analytic simplicity, although it is a fair approximation.
Discuss the damped harmonic oscillator when the damping term is proportional to x'lt]2.
3.10 Motion of a Charged Particle in a Harmonic Potential
A particle in an isotropic three-dimensional harmonic oscillator potential has a natural frequency
of ojO . Assume the particle is charged and that crossed static electric and magnetic fields are
applied. Find the vibration frequencies with these electromagnetic fields present. Discuss the
results for the limits of strong and weak fields.
CHAPTER
4
Nonlinear Oscillating Systems
4.1 ¦ INTRODUCTION
The study of systems whose behavior is described by nonlinear differential equations in-
involves a deeper investigation of vibrational processes than does the study of linear systems.
Given the initial conditions, the solution of a time dependent differential equation describes
the state of the system at a later instant. In a linear system the sum of two solutions is again
a solution, but this principle of superposition fails to hold for nonlinear systems. Conse-
Consequently, the outcomes of nonlinear systems cannot be understood by adding together two
solutions. For nonlinear systems, each solution must be sought on an individual basis. In
this chapter we consider oscillating systems that are described by nonlinear differential
equations.
For systems described by nonlinear differential equations, it is advantageous to study
the solutions in terms of phase planes. Such a representation appeals to geometric intu-
intuition, simplifies the interpretation, and allows one to classify the different behaviors. For
example, consider a system with one degree of freedom described by a second-order dif-
differential equation of the form
x"[t]+f[x[t]x'[tlt] = O
If you define v[t] = x![i], then this equation can be expressed as two first-order equations
= -/[*, v] and *[t]=v[t]
Each point in the plane {x, v} represents an individual state, or an initial condition of the
system. The curve in the {x, v} space is called the orbit or trajectory. Once the initial position
and velocity of each particle are given, the future motion is determined, at least in principle.
The collection of all possible states is called the phase space of the system. If v'[t] = 0 and
x'lt] = 0 then the point is an equilibrium point (critical point). As the parameters are
changed in a system, the stability of the equilibrium points can change as well as their
number.
193
194 Chapter 4 Nonlinear Oscillating Systems
A periodic trajectory is a closed curve that returns to itself precisely in a time T, called
the period. A periodic trajectory can be stable or unstable, depending on whether nearby
trajectories tend toward or away from the periodic cycle. An attractor is a set of points
in phase space toward which a trajectory evolves as time gets large. Thus in a dissipative
system the long-term behavior of a trajectory may settle into an attractor. For example,
imagine a ball rolling inside a bowl with no angular momentum. If you start the ball at
a point in the bowl with a velocity too small to reach the edge of the bowl, the ball will
eventually settle to the bottom of the bowl. This position at the bottom of the bowl is an
attractor. The neighborhood of initial conditions that eventually approach the attractor is
the basin of attraction.
Some motions are explained, while others—such as the shifting patterns of a waterfall—
are irregular and appear to defy any rule. A small difference in their initial conditions can
lead to enormously different results. In practice this leads to a state of the system that is
essentially unknown after a very short time, and it becomes impossible to make predictions.
This sensitivity on the initial conditions is called chaos. The behavior of a chaotic system is
not random, since the trajectory of a chaotic system with identical initial conditions always
lead to the same results. The idea that deterministic systems can behave in an apparently
unpredictable and chaotic manner was first noticed by the French mathematician Henri
Poincare. However, chaos was not fully appreciated until the widespread availability of
computers that could perform numerical simulations and demonstrate chaos in various
physical systems.
Chaos has broad implications for many fields of science, and within the past decade or
so the field has undergone explosive growth. One important application of chaos in physics
is to quantum systems. According to the correspondence principle, there is a limit where
classical behavior as described by Hamilton's equations becomes similar. The semiclassi-
cal limit can be highly nontrivial when the classical problem is chaotic. The study of how
quantum systems, whose classical counterparts are chaotic, behave in the semiclassical
limit has been called quantum chaos.
Several tools can be developed to examine nonlinear systems. If the solution of the dif-
differential equation contains terms periodic in time, then to simplify its phase diagram it
is useful to make a stroboscopic map. The map effectively looks at points in phase space
with a stroboscope tuned to a period T. This map is called a Poincare section. The Poincare
section simplifies the phase diagram by sampling time intervals equal to the period of the
driving frequency. If you are dealing with a periodic change, then this sequence consists
of n dots being indefinitely repeated in the same order. If the evolution is chaotic, then
the Poincare section is a collection of points that show patterns with no obvious repeti-
repetition.
This chapter considers two well known nonlinear systems and is divided into two prob-
problem sections: 4.2, Nonlinear Pendulum, and 4.3, Duffing Equation. Exercises are included
in section 4.4.
Before starting the problems you might find it convenient to turn off the spell checker:
In[l]:= Off[General :: "spell"];
Off[General :: "spelll"];
4.2 Nonlinear Pendulum 195
4.2 ¦ NONLINEAR PENDULUM
4.2.1 ¦ Overview
This section deals with the fairly simple nonlinear differential equation governing the mo-
motion of a pendulum. Consider a planar pendulum of length L and mass m that moves in a
vertical plane. It is described by the second-order equation
ff'[i\ + j Sin[6[t]] = 0
Li
where g is the acceleration of gravity and L is the length of the pendulum. The function
6 [ t ] is the angular displacement measured from its position of equilibrium at 6= 0, which
corresponds to a pendulum hanging straight down. The equations of motion for a planar
pendulum are nonlinear. This is a result of the force of gravity pulling straight down and
the pendulum bob swinging in an arc so the restoring force is proportional to the sine of
the displacement angle. If the standard pendulum motion is enhanced by adding a damping
term proportional to 6' [t], then the equation for the damped pendulum becomes
ff'[t] +yff[t]+ a)lSin[e[t]] = 0
The damping insures that phase trajectory will eventually approach an attractor. We
finally consider the driven pendulum
6"[t] + yff[t] + co20Sm[e[t]] = f0Cos[codt]
The interesting behavior in the forced pendulum is the occurrence of chaotic states
where nearby initial conditions lead to widely varying behaviors. It is quite remarkable
that such complexity arises from a fairly simple physical object.
The basic problems to be studied are to:
1. find the conditions of equilibrium of the system and investigate their stability;
2. investigate the change in the system as the initial conditions are varied; and
3. investigate the dependence of the solution on the damping and forcing parameters.
The problems are arranged in order of increasing complexity. We start with the behavior
of an unforced and undamped pendulum, and then proceed to the damped pendulum, and
finally to the driven pendulum. Each new problem provides more insight into nonlinear
motion and gives more examples on how Mathematica is applied to physics.
It is useful to create user-defined procedures for calculations that are used in more than
one problem in this section. Several user-defined procedures are used repeatedly for the
pendulum equations. Basically, all of these procedures numerically solve the pendulum
equation and plot some form of the results. It is not necessary to understand the details
of these procedures until you have done all the problems; then you can go back and ex-
examine the steps. To understand them in detail, go through the steps one at a time. Try to
make the procedures more time efficient, add default conditions, and add options to the
196 Chapter 4 Nonlinear Oscillating Systems
procedures. These user-defined procedures must be entered before many of the problems
in this section will work. They have been placed on the author's web sites and can be down-
downloaded. They also can be downloaded from the publisher's web site. The user-defined pro-
procedures we have constructed for the nonlinear pendulum are anglePend, phasePend,
poincarePend, reduce, anglePendR, phasePendR, poincarePendR:
4.2.2 ¦ Initialization of User-Defined Functions
4.2.2.1 ¦ User-Defined Procedure for the Pendulum's Angle-Time Graph
The procedure anglePend numerically solves the force pendulum and returns a plot of
its angle:
In[2] := anglePend[{60-, d60_}, {Y-, fO_, fiH
tmax_, step., opts ] : =
Module[{temp},
temp = NDSolve[
{de'[t] +y de[t] +uo sin[e[t]] ==
fO Cos[twd] ,
e'[t] ==ae[t],e[0] ==eo,
ae[o] ==deo},
{de[t],e[t]},
{t, 0, tmax}, MaxSteps -> step
]//Flatten ;
Plot[{6[t] }/.temp //Evaluate,
{t, 0,tmax},
opts,
DisplayFunction -> Identity]
]
The list {60, d#0} gives the starting angle and its starting derivative. The list {y, f 0,
o>0, aid} gives the damping coefficient, the applied force, the natural frequency, and the
forcing frequency for the pendulum equation. The input tmax gives the maximum time,
and step gives the maximum number of steps used to numerically solve the differential
equation. The default setting for MaxSteps is 1000 for ordinary differential equations. You
apply Show with the rule DisplayFunction -> $DisplayFunction to display
the graph. The input opts allows you to add options to the graphics.
4.2.2.2 ¦ User-Defined Procedure for the Pendulum's Phase Diagram
The user-defined procedure phasePend returns a plot of its phase diagram.
4.2 Nonlinear Pendulum 197
In [3] := phasePend [ {60_, d60.}, {Y-, fO_, <tfO_, <ud-},
tmax., step , opts ] : =
Module[{temp},
temp = NDSolve[
{de'[t] +y de[t] +uO~2 Sin[6[t]] = =
?0 Cos [t aid] ,
e'[t] == de[t],e[0] == eo,
de[0] == deo},
{de[t],e[t]},
{t, 0, tmax} , MaxSteps -> step
]//Flatten ;
numgraph =
ParametricPlot[
{6[t] ,de[t]}/.temp//Evaluate,
{t, 0,tmax},
opts,
Display-Function -> identity]
]
The input is the same as for anglePend.
4.2.2.3 ¦ User-Defined Procedure for the Pendulum's Poincare Diagram
The user-defined procedure poincarePend returns a Poincare diagram:
In [4 ] : = poincarePend [ { 60 ., d60. } ,
{Y_, f0_, art)., ud_}, start., tmax.,
step., opts ] : =
Module[{tempi,temp2},
tempi = NDSolve[
{de'[t] +y ae[t] +uo sin[e[t]] ==
?0 Cos [t aid],
e'[t] ==de[t],e[0] ==eo,
de[o] == deo},
{de[t],e[t]},
{t, 0,tmax},
MaxSteps -> step
] // Flatten ;
temp2 = Tablet {e[t] ,de[t] }/.tempi,
{t, start, tmax, 2 7r/oid} ] ,-
ListPlot[temp2,
PlotStyle- >PointSize[0.02], opts]
The input is the same as for anglePend with an additional variable start. Instead of
starting the time points at t=0 the graph starts at t=start. This allows a starting time to
be picked so the transient motion has died out.
198
Chapter 4 Nonlinear Oscillating Systems
4.2.2.4 ¦ User-Defined Procedure to Map the Pendulum to the Interval —n andn
This procedure restricts the position of the pendulum x to the interval of —it and it:
In [5]:= reduce [x_] = Mod [x , 2jt, -jt]
Out[5]= Mod(x, 2tt,-7T)
Let's check this graphically.
In[6]:= Plot[reduce[x], {x, -4jt , 4 jt}.
Ticks-* {Table[ijr, {i, -4, 4}] , None}] ;
7T -E 7T -
4.2.2.5 ¦ User-Defined Procedure for the Pendulum's Reduced Angle-rime Graph
The user-defined procedure anglePendR returns a plot of the pendulum angle where the
angle has been restricted to the interval of —it and it:
In[7] := anglependR[{60., d60.}, {Y-, f0_, uO., 0)d.},
tmax_, step., opts ] : =
Module[{temp},
temp =
NDSolve[
{de'[t] +y de[t] +uO Sin[S[t]] = =
f 0 Cos [t aid] ,
e'[t] ==de[t],e[0] ==eo,
de[0] == deo},
{de[t],e[t]},
{t, 0, tmax},
HaxSteps -> step
]//Flatten ;
Plot[reduce[6[t]/.temp] //Evaluate,
{t, 0, tmax},
opts,
Display-Function -> identity]
The input is the same as for anglePend.
4.2 Nonlinear Pendulum 199
4.2.2.6 ¦ User-Defined Procedure for the Pendulum's Reduced Phase Diagram
The user-defined procedure phasePendR returns a plot of the phase diagram where the
points are restricted to the interval of -n and n:
In [8] .- = phasePendR [{60., deo.}, {Y-, fO_, 0H., o>d.},
tmax_, step., opts ] : =
Module[{temp},
temp =
NDSolve[
{de'[t] +y de[t] + uO~2 Sin[6[t]] ==
?0 Cos [t aid] ,
e'[t] == de[t],e[0] == eo,
de[0] == deo},
{de[t],e[t]},
{t, 0, tmax},
HaxSteps -> step
]//Flatten;
ParametricPlot[
{ reduce [e[t] /.temp ], de [t] /.temp}//
Evaluate, {t, 0, tmax},
opts,
DisplayFunction -> Identity]
The input is the same as for phasePend.
4.2.2.7 ¦ User-Defined Procedure for the Pendulum's Reduced Poincare Diagram
The user-defined procedure poincarePendR returns a plot of its Poincare diagram re-
restricted to the interval of -n and n:
200 Chapter 4 Nonlinear Oscillating Systems
In[9] := poincarePendR [ {60., d60.},
{Y-, fO_, aO., ad.}, start., tmax_,
step., opts ] : =
Module[{tempi,temp2},
tempi=
NDSolve[
{d6'[t] +y d6[t] + <uO Sin[6[t]]
?0 Cos [t aid] ,
e'[t] == de[t],e[0] == eo,
de[0] ==deo},
{de[t],e[t]},
{t, 0,tmax},
HaxSteps -> step
]//Flatten;
temp2=
Table [ {reduce [6[t]/.tempi] ,
de[t]/.tempi} ,
{t, start, tmax, 2 jt/okI} ] ;
ListPlot[temp2,
PlotStyle- >pointsize[0.02], opts]
The input is the same as for poincarePend.
4.2.2.8 ¦ Protect User-Defined Procedures
Finally we apply Protect to the user-defined procedures to keep them from being deleted
with Clear [ -Global * *" ]:
In [10] : = Protect [anglePend, pbasePend, poincarePend, reduce, anglePendR,
phasePendR, poincarePendR] ;
We also suppress some warning messages with the following commands.
In[ll]:= Off[Clear : : wrsym]; Of f [SetDelayed :: write];
PROBLEM 1 Analytic Solution for the Planar Pendulum. Consider a planar pendu-
pendulum of length L and mass m that moves in a vertical plane. If gravity is the only force, then
the motion is described by the second-order equation
6"[t] + -Sin[0[f]] = 0
i
where g is the acceleration of gravity, and 0[t] is the angular displacement measured
from its position of equilibrium at 0=0; this corresponds to a pendulum hanging straight
down.
4.2 Nonlinear Pendulum
201
a. Show that the conserved energy of the pendulum can be written as
En = ^
Make a phase diagram using the energy expression. Graph the phase diagram on a
cy Under.
b. Integrate the energy expression to get an analytic expression for 6 [t].
c. Find the period for the nonlinear pendulum, and plot the results as a function of the
amplitude.
d. If 6 is small, then Sin [6] can be approximated by 6 and the linear pendulum equa-
equation becomes
e"[t] + ^e[t] = o
Compare the linear and nonlinear solutions for the pendulum.
e. Compare the Fourier series of the nonlinear and linear solutions.
Remarks and Outline An expression for the conserved energy follows from multiplying
the equation of motion by 8' [t] and integrating. The pendulum system has two equilib-
equilibrium points, one is stable and the other is unstable. The stable one is at 6=0 and corresponds
to a pendulum hanging straight down at rest. The other fixed point at 6 = n is unstable and
corresponds to a pendulum resting straight up. The exact solution follows from integrating
the energy expression which gives an elliptic integral.
Solution
In[12]:= Clear["Global'*"]
a. Consider the nonlinear pendulum equation
In[13] := NLeq = 6"[t] + g/L Sin[6[t]] == 0
out[i3]=
202 Chapter 4 Nonlinear Oscillating Systems
where 6 [t] is measured relative to the downward vertical. To reduce the pendulum equa-
equation to a first integral, multiply by 6' [t] and integrate the left-hand side of NLeq,
In[14]:= eql=
En == F' [t] NLeq[ [1] ] //ExpandAll //
Integrate [#, t]&)
Out[14]= En ^ie'(tK-gC°S(e(t))
2 L
where En, the constant of integration, is equal to the total energy of the pendulum. The first
term on the right side of eql is the potential energy and the second is the kinetic energy.
Since the energy is a constant, you can replace En with the angle at the highest point
of its swing where 6' [t]=0. If 60 is the highest point of the oscillation, then En=
-f Cos [60]. You can describe this energy expression with the rule
In[15]:= Erule = {En-»-g/L Cos[60]};
Notice the energies for a motionless bob F' [t] =0) at the bottom F[t]=0) and at the
top F[t ] = n) of the pendulum are
In[16]:= En/.Erule/. {60 -> {0,7t}}
A phase portrait for the pendulum follows from applying the command ContourPlot
to the energy expression. The command ContourPlot graphs the curves {6[t] ,6' [t]}
for different values of the energy (different initial conditions). Each value of the energy
gives a different trajectory. Assume g=l and L=l and apply ContourPlot to the right
side of the energy equation given by eql. You get the following phase portrait.
In[17]:= pt = ContourPlot[
eql [ [2] ] /. {g -> 1, l -> 1}//Evaluate,
{6[t],-4jT, 4 jt}.
Contours -> Range [-1, 3, 0.5],
FrameTicks ->
{7T Range[-4, 4 ], Automatic},
ColorFunction -> Hue,
PlotPoints -> 100,
FrameLabel -» {", '"},
Display-Function -> identity ];
Several options have been added to embellish the graph. The option Contours ->{...}
is used to exhibit n contours with specified values of the energy. Displaying the graph, we
obtain
4.2 Nonlinear Pendulum
203
In [18]:= Show[pt,
Graphics[{Hue[0.2],PointSize[0.02],
Hap [Point, { jtB # + 1), 0 } &/@
Range[-2,1]]}],
Graphics[{Hue[0.8],PointSize[0.03],
Hap [Point, {2 rtt, 0 } &/@
Range[-2,2]]}],
Display-Function -> $DisplayFunction];
2 7T 3 7T 4 7T
-47T-37T-27T -7T 0 7T 2 7T 3 7T 4 7T
For each value of the energy (initial conditions) there is a curve in the {6[t], 6' [t]}
plane. The curves with E > 1 correspond to orbits with initial velocities so large that
the pendulum revolves without end. If 0 < E < 1 then the orbits are closed and the
pendulum periodically oscillates back and forth. The points with 6'=0 and 0=0, ±n,
±2n, ±3n are critical points. We have denoted these points by adding dots to the graph.
The position at the bottom of the pendulum's motion correspond to 8=0, ±2n, ±in, ...
and mark the stable points. The points at the top of the pendulum correspond to 6= ±n,
±3n,... and are unstable points.
The physical pendulum repeats every 2n interval, so the information about the oscil-
oscillation is contained in the interval {—n, n}. You can display these restricted trajectories by
drawing the curves on a cylinder that repeats every 2n interval. Do this by first drawing a
cylinder, and then adding the trajectories. Consider the graphics for a cylinder
In[19]:= cylind= ParametricPlot3D[
{v. Sin[6], Cos[6]},
{6, -jt, jt},
{v,-3,3},
DisplayFunction -> Identity ];
Show[cylind,
DisplayFunction -> $DisplayFunction];
204
Chapter 4 Nonlinear Oscillating Systems
Combining the cylinder with the phase trajectories, we obtain
In[20]:= Show[ cylind,
6rapfaics3D [
{AbsoluteThickness[3],
Cases [Graphics [pt], .Line, oo] /.
{0-,-<r-} :>{v, 1.02 Cos [6],
1.02Sin[6] }}],
Viewpoint -> {1, 1, 1},
Display-Function -» $DisplayFunction
b. Even though the pendulum is nonlinear, it has an analytic solution expressed in terms
of an elliptical function. To get an analytic expression for 8 [t], start with the energy equa-
equation
given by eql • Solving the energy equation for 8' [t] and replacing En with its expres-
expression for 80, you get
4.2 Nonlinear Pendulum 205
ln[21]:= eq2 =
Solve[eql, e'[t]] [[2]] /.Erule//
Simpl if y // Power Expand
Out[21]- fa,(tM^V5VCM(a(t))-CM(90)
^ -\/Ti
The expression for t follows from inverting the right-hand side of eq2 and integrating,
In[22]: = eq3 =
t = = Integrate [ #J^r//-*<l2 ,
{6[t],0,e}l //SiJiB>lify//PowerEjfpaiid
Vl Csc
Oat 122]= t ==
eo
F
f|Csc2
©0
V9
Solving for 6, you get
In[23]:= eq4 =
Solve [eq3, 6, InverseFunctions -»True ] //
Flatten
Sin
eo
Out[23]= (e->2am = |CsCM^--
L a/L \ 2
A user-defined function for 6 is
In[24]:= NLesol [tl_, 61-, o>- ] =
e/.
Solve [eq3, e, InverseFunctions -» True] [ [
1]] /.{t -» tl, 60 -»€
PowerExpand
(81 \ / 81
— |Csc2 —
2 / \ 2
where o>2 = |. You can substitute NL#sol back into the original equation to verify the
validity of the solution.
In[25]:= NLeq[ [1] ] / .6 -> ((NLesol [#, 60 , 0) ])&)/.
g -» u2 L// SlJlB)lif y
Oat [25]= 0
The solution you have constructed for 0[t] corresponds to the following initial condi-
conditions {0[O],6'[0]}:
206
Chapter 4 Nonlinear Oscillating Systems
In[26]:= initial=
{ NL6sol[0, 60,
D[NLesoi[t, e
Thread
o//
Out[26]= |e@) == 0, e'@) == 2u Sin l~
where o>2 = |. These initial conditions correspond to a pendulum that starts at the bot-
bottom @[O] =0) and is given an initial push, either in the clockwise or counterclockwise
direction. The size of the push is parameterized with 60.
Let us plot the solution for different values of 60/n={0.1, 0.3, 0.5, 0.7,
0.9} (i.e., different initial pushes). We form the list of solutions
In [27] : = list = Table [ NLOsol [t , i 7r, 1 ] ,
{1,0.1,0.9,0.2}] ;
and display the results with Plot.
ln[28]:= Plot [list//Evaluate,
{t, 0, 16},
AxesLabel -> {"t", "},
PlotStylo ->
({Thickness[#/100], Hue[#]}& /&
Rang©[0.1, 0.9, 0.2] //Evaluate)
As the size of the push gets larger the value of the amplitude increases.
c. The time for the pendulum to go from 6=0 to 60 follows from setting 6 = 60 in eq3,
In[29]:= eq3 [ [2] ] /. {6- > 60}
Out[29]=
f jF(f |Csc2(f
4.2 Nonlinear Pendulum
207
Since this is 1/4 of a full swing, the period for one complete cycle is four times this
value.
In[30]:= period= 4 eq3 [ [2] ]/. {6- >60}
Csc ^
Out [30] =
eo
F
^|Csc2
eo
Plotting the period as a function of 00, you get
In[31] := Plot [ period /.{g-» 1, L-» 1} //Re //
Evaluate,
{60, 0. ,7r},
GridLinos -» Automatic,
AxesLabel -> {0", "Period"},
PlotStyle-* {Hue[0.6], Thickness[0.01]},
Ticks -> {7r/4 Range [0, 4, 1] ,
7T Range[0, 10,2]},
PlotRange -> {{0, 7r}, {0, 10 7r}},
Epilog-» {Hue [0.8], Thickness [0.01],
Line[{ {0, 2tt}, {tt, 2tt}} ]}
Period
IOtt
8tt
2tt
T
7T
~2
3tt
4
The horizontal line is the period for the equivalent linear pendulum (T=27r). Notice it
takes an infinite amount of time to come to rest at the highest apex 6 = n.
d. To compare the linear and nonlinear solutions, define the linear equation
In[32] := Leq = 6" [t] + g/L6[t] == 0;
The user-defined function for the linear solution is
In[33] : = L6sol [tl_, 6o_, @- ] =
DSolve[{Leq, 6[0] ==0,
e'[0] == 2&1 sin[eo/2]},e[t],t]
l]]/.{t-» tl,60-»eo, g-» L4T2 }//
PowerExpand
208 Chapter 4 Nonlinear Oscillating Systems
Out[33]= 2 Sin — Sin(tlw)
where to2 = |. The command for the nonlinear solution follows from NL6>sol. The graph-
graphics for the linear and nonlinear equations are
In[34] := ptl =
Plot[
{ L6SO1 [t, 7T/2, 1] , NLesol [t, 7T/2, 1] } //
Evaluate,
{t, 0, 4tt},
PlotStylo -> {
{Dashing[{l.,0.}],
Thickness[0.01]},
{Dashing[{0.06,0.03}],
Thickness[0.001]}},
Frame -»True,
Display-Function -» Identity
where o>=l and 80=|. To embellish these graphics, add the graphics for discrete time
points for both the linear and nonlinear motions:
In[35]:= Lpts =
{#, L6SO1 [#, 7T/2, 1] }& /»
Range[0, 47r, 0.5]//Flatten//
Partition[#, 2]&//Chop;
NLpts=
{#, NLesol [#, 7T/2, 1] }&/»
Range[0, in, 0.5]//Flatten//
Partition[#, 2]&//Chop;
Combining the graphics and displaying the results, you get
In[36]:= Show[
Ptl,
Epilog-* {Hue[0.6], PointSize[0.02],
Hap[ Point, join [NLpts , Lpts ] ] },
DisplayFunction -» $DisplayFunction
4.2 Nonlinear Pendulum
209
10 12
The solid curve is for the linear pendulum and the dashed curve is for the nonlinear
pendulum. The points are equally spaced in time.
e. To study the generation of higher harmonics with increasing nonlinearity, you can
expand 0[t] into its Fourier spectrum. This is most easily accomplished by using the
Mathematica command Fourier:
In [37]:= ?Fourier
Fourier[list] finds the discrete Fourier transform of a list of complex num-
numbers. More...
The data for the spectrum of the nonlinear pendulum is
In[38]:= fourierdataNL=
Table[NL6sol[t, 0.99tt, 1] //N,
{t, 0, 100, 100/511}] ;
The Fourier transform of the absolute value of the data is
In[39]:= ptNL=
ListPlot[Fourier[fourierdataNL] //Abs,
Plotjoined -»True,
Plotstylo ->Hue [Random [ ] ],
PlotRange ->All
25
20
15
10
5
100 200
300 400
500
210
Chapter 4 Nonlinear Oscillating Systems
Enlarging the structure on the left side of the graph, you get
In[40] := Show[ptNL, PlotRange-» {{0, 45}, {0, 8 }}];
10
20
30
40
Compare this with the pure harmonic that follows from the linear pendulum
In 141]:= fourierdataL =
Table [L6sol [t, 0.997T, 1] //N,
{t, 0, 100, 100/511}] ;
Displaying the linear and nonlinear pendulums, it follows
In[42]:= ptL=
ListPlot[Fourier[fourierdataL] //Abs,
Plot Joined -»True,
PlotStyle ->Thicfcness[0.01],
PlotRange-> {{0,45}, {0, 10 }},
Epilog-»ptNL[ [1]]
10
8
6
4
2
j
J \ »
i \
\ j
10 20
30
40
where the nonlinear plot has been included with Epilog. The single dark peak is the
linear pendulum.
PROBLEM 2 Damped Pendulum. If the standard pendulum motion is enhanced by
adding a damping term proportional to ff[t\, then the equation for the damped pendulum
4.2 Nonlinear Pendulum 211
becomes
6"[t] + yff[t\ + wO2Sin[0[f]] = 0
The damping in the pendulum ensures that its phase space trajectory will eventually ap-
approach an attractor.
a. For this part of the problem, pick y = 0.2 and o>0 = 1 and choose the initial condi-
conditions to be 6[0] = 0.9n and ^[0] = 0. Numerically solve and plot the results. Make a
user-defined function to plot 6[t~\. Apply the command to the list of initial conditions
0[O] = 0 and ^[O] = {-6, -3, -1,1, 3,6}.
b. Plot the phase trajectory for the initial conditions 6[0] = 0.9n and ^[0] = 0.0.
Make a user-defined function that plots the phase trajectory. Set y = 0.3 and ojO =
1, and apply this command to the list of initial conditions <p[0] = 0 and ^[0] =
{-6, -3, -1,1,3,6}. Illustrate the basin about one of the attractors by plotting the
trajectories for a range of initial values of ^[0] that lead to the same phase space
attractor.
c. Make a phase portrait for the damped oscillator using the command PlotVector-
Field. Combine the vector field graph with the trajectories discussed in Part b.
Solution
In[43]:= Clear["Global»* " ]
a. You want to solve the equations for a damped pendulum and display the motion for
a given set of initial conditions {0[O], ^[0]}. In particular set 0[O] = 0.9n, ff[0] = 0,
y=0.2, and o>0=l, and consider the differential equation
In[44]:= eql=
{e"[t] + y e'[t] +uo'2 sin[e[t]] == o,
e[0] == o.97r,e'[O] == 0}/.
{Y-»0.2,(»0 -» 1}//Flatten;
If you apply NDSolve to eql,
In[45] := solDP = NDSolve [ eql, e[t] , {t, 0,40}]//
Flatten;
and then plot the result, you get
In[46]:= Plot [ e[t]/.solDP //Evaluate,
{t, 0, 40},
AxesLabel -» {"t", "},
PlotRange -»All,
PlotStyle -» { Thickness [0.01],
Hue[Random[]]}
212
Chapter 4 Nonlinear Oscillating Systems
e
The pendulum starts from rest at 0 [ 0 ] = 0.9 n and swings through the bottom to the
other side. This pattern repeats over and over with the amplitude becoming progressively
smaller. The swing eventually comes to rest at the bottom of the pendulum's swing.
Assume a nonzero initial velocity as if the pendulum had received a sharp kick. In
particular consider the graphics of 6[t] for the initial conditions 0[O] =0 and ^[0]=
{-6, -3, -1, 1, 3, 6}. This list contains initial conditions for motions moving
in both the counterclockwise and clockwise directions. To construct these solutions, gather
the steps used in the previous calculation and make a general user-defined function. The
user-defined function that summarizes these steps is
In[47]:= angle[{60-, v0_}, {y_, w0_}, tmax_,
opts ] : =
Module[{numsol},
numsol=
NDSolvo[
{e"[t] + y e'[t] +wo~2 sin[e[t]] == o,
e[0] ==eo, e'[0] ==vo},e[t],
{t, 0,tmax}];
numgraph=
Plot[
e[t]/.numsol,
{t, 0,tnax},
opts,
Display-Function -»Identity]
The initial conditions are entered as a list in {60, vO } and the pendulum parameters are
entered in the second list {y,ioO}. The time span is from t=0 to t=tmax.
Assume the initial conditions 0[O] = 0, ^[0] = {-6, -3, -1,1,3,6} and apply angle.
If you set y = 0.3, and a>0=l then the list of graphics is
4.2 Nonlinear Pendulum
213
In[48]: = grlist =
angle[ {0, #} , {0.3,1}, 23,
AxesLabel -> {"t", "},
GridLinos -» Automatic,
PlotStyle-* {Thickness[0.01],
Hue[Random[]] },
Ticks-* {7r Range[0, 8, 2],
2 7r Range[-2, 2 ] },
PlotRango -> All ,
DisplayFunction -»Identity
]& /» {-6,-3,-1,1,3,6} ;
Displaying the results for 6It], you find
In[49]:= Show[grlist,
DisplayFunction -» $DisplayFunction] ;
4tt
2 7T
-2tt"
-4tt
All but two of the initial kicks were of sufficient value that the pendulum made one or
more full revolutions before coming to rest at the bottom of the pendulum's swing. Depend-
Depending on the number of rotations and whether the motion was clockwise or counterclockwise,
the paths converge to the values 6=0, ±2n, ±&n.
b. You can plot the phase trajectory using ParametricPlot and the solution for
the previously solved differential equation. Consider the phase trajectory with the initial
conditions 0[O] = 0.9n and 6 • [ 0 ] = 0. The plot of {6[t], 6 • [ t ] } follows from
In[50]:= ParametricPlot[
{6[t]/.solDP, D[6[t]/.solDP, t] } //
Evaluate,
{t,0,40},
AxosLabol -> {", '"},
Ticks -» {7r Range [-2, 2, 1/4] , Automatic},
PlotRango-* All,
PlotStyle-* {Hue [0.8], Thickness [0.009] }
214
Chapter 4 Nonlinear Oscillating Systems
The phase trajectory spirals toward the attractor located at 0 and 6' equal to zero.
Consider the phase trajectory for another set of the initial conditions: 6[0] = 0,
Before you do this example, gather the steps in the previous calculation and make a gen-
general user-defined procedure. A user-defined function constructed to plot the general phase
trajectory {6[t],0' [t]} is
In 151]:= phase [ {60_, v0_} , {y_, 4»0_} , tmax_,
opts—] : =
Module[{numsol},
numsol=
NDSolvo[
{V[t] +y v[t] +4)<r2 Sin[6[t]] == 0,
e'[t] ==v[t],
e[0] ==eo,v[o] == vO},
{t, 0, tmax}] //Flatten;
numgraph = ParametricPlot[
{6[t] ,v[t]}/.numsol//Evaluate,
{t, 0,tmax},
opts,
Display-Function -» Identity]
Applying phase to the trajectory with the initial conditions 0[O] = 0, ^[0]=4 and with
parameters {y=0.2, o>0 = 1}, it follows
In [52]:= ptl =
phase[{0, 4}, {0.2, 1}, 40,
PlotRange->A11,
AxesLabel -> {", '"},
PlotStylo -» {Thickness [0.009], Hue[0.7] },
Ticks-* {7r Range[0, 4 ], Range[-2, 4 ]},
GridLinos -» Automatic, PlotPoints -» 200,
Display-Function -» $DisplayFunction
4.2 Nonlinear Pendulum
215
-Jr
The initial kick ensured that the pendulum went over the top twice before converging
to the point at 6' =0 and 0=4 n. The damping term ensures that the trajectory eventually
converges to the attractor.
Let us consider the phase space trajectories for several different initial values. Assume
0[O] = 0 and ^[O] = {-6, -3, -1,1,3,6} and apply phase
In[53]:= pfalist=
phase[{0,#}, {0.3,1}, 23,
AxesLabel -> {", '"},
PlotStyle-* {Thickness [0.008],
Hue [Random[] ] },
Ticks -> {7r Range [-8, 8, 2],
Range[-6,6 ] },
PlotRange ->All
]& /9 {-6, -3/ -1, 1,3, 6} ;
Displaying the results, you find
In[54]:= pt2 = Show[
pfalist,
GridLinos -» Automatic,
Display-Function -» $DisplayFunction
n
6-
1
1
u
\
216
Chapter 4 Nonlinear Oscillating Systems
Four of the initial kicks were sufficiently large that the pendulum completed one and
two full revolutions before being attracted to the attractors at 9= ± 2n and ±4 n. Some
of the rotations were clockwise and the others were counterclockwise.
A range of initial conditions converge to the same attractor. The collection of points is
called the basin of the attractor. To illustrate this property consider the attractor in phase
space located at {6 = 2n, 8' =3}. Assume an initial displacement 0[O] = 0 with a range
of values near ff [0]=3. The list of initial conditions is
In[55]:= list = {0,3 + #}&/»
Rang© [-0.51 , 0.51 , 0.2] ;
The graphics for the collection of trajectories follows from applying phase
In[56]:= grlist =
phase[#, {0.2, 1},155,
PlotPoints -> 100,
AxesLabel -¦ {", '"},
PlotStyle-t {Thickness [0.005],
Hue[0.9]}
] ft/8 list i
Displaying the results, you get
In[57] := pt3 = Show[
grlist,
Graphics [ Point [ { 2 7T #, 0 } ] &/»
Range [0,2] ],
PlotRange -»All,
Ticks -» {7r Range [0, 4 ],
7r/4 Range[0, 4 ] },
Display-Function -» $DisplayFunction
The damping term causes these trajectories to spiral inward to the attractor at 9= 2n
and0'=O.
4.2 Nonlinear Pendulum
217
c. The phase portrait reveals all the attractors and their basins. You can draw the phase
portrait using the built-in command PlotVectorField (found in the package Graph-
Graphics 'PlotField'),
In[58].= NeedsfGraphics'PlotField]
It follows that
In[59]: = pt4 = PlotVectorField[
{y, -0.2y -1 Sin[jt] },
{at, 0, 5 7T},
{y, -1, 5},
PlotPoints-* 20,
ScaleFunction -> @.4#&),
ScaleFactor -»None ,
Display-Function -»identity
Displaying the phase portrait along with several trajectories computed in Part b, you
find
In[60]:= Show[pt4,ptl,pt3,
Display-Function -» $DisplayFunction] ;
^- ^ i> ^c^
nm
The arrows are tangent to the phase trajectories. The points {6=0, ±2n, ±4 n,
...} and 8' =0 are the attractors to which the trajectories spiral toward. In each region of
an attractor there is a basin of initial condition and trajectories with these initial conditions
eventually converge to the specific attractor. The curve dividing one basin from another is
called a separatrix.
PROBLEM 3 Periodic Solutions for the Driven Pendulum.
havior of a driven pendulum described by the equation
Let us investigate the be-
be+ T & W + "
= /„ cos[6,/]
a. Choose the parameters y= j,/0= l,^o= 1» wd = f wim me initial conditions
0[O] = 0 and ^[0] = {n/2, 3/2n, 2n, 3n}. Use the user-defined function anglePend
denned at the beginning of this problem section to plot 9.
218 Chapter 4 Nonlinear Oscillating Systems
b. Use the user-defined function phasePend denned at the beginning of this problem
section to plot the phase trajectories for the parameters denned in Part a.
c. Use the user-defined function poincarePend defined at the beginning of this
problem section to make Poincare maps for the system in Part a.
Solution
In[61]:= Clear["Global'*"]
a. The user-defined function that plots 0[t] follows from anglePend. Consider the
parameters y = 1/2, f 0=1, o>0=l, o>d=2/3 and insert the initial conditions 0[O] = 0,
ff[Qi\={n/2, 3/2n, 2n, 3n} into the user-defined function. You get the following list
of graphics:
In[62]:= ptl=
anglePend[{ 0, # tt}, {0.5 , 1, 1,2/3},
100 , 5000,
AxesLabel -> {", '"},
Plot Rang© -> All,
Ticks -> {tt Range [0, 20 , 5] ,
7T Range [0, 10,2 ]},
Plotstylo ->Hue [Random [ ] ]
]& /» {1/2,3/2,2,3};
Displaying the results, it follows
In[63]:= Show [ptl, DisplayFunction ->
$DisplayFunction] ;
6tt
47T
\ i'\ A A A A A A A A A
U \ / \ / \ / \ / \ / \ / \ / \ / \ / \
a7\AA7W\AAA
XT
The solution corresponds to a pendulum that swings over the top a number of times
before settling into periodic motion.
b. To plot the phase trajectories use the user-defined function phasePend. Consider
the parameters y = 1/2, f 0=1, o>0=l, o>d=2/3 and insert the initial conditions 0[O] = 0,
ff[Qi\={n/2, 3/27T, 2n, Zn} into phasePend:
4.2 Nonlinear Pendulum
219
In[64]:= pt2 =
phasePend[{0,#7r}, { 0.5 , 1,1,2/3},
400 , 5000 , AxesLabel -> {", '"},
PlotRango -»All,
Ticks -> {7r Range [0, 6 ] , Automatic},
PlotPoints -> 150,
Plotstylo ->Hue [Random []]
]& /» {1/2,3/2,2, 3};
Displaying the results, it follows
In [65] := Show [pt2 , DisplayFunction ->
$DisplayFunction];
After the pendulum loops over the top a number of times, it settles into periodic motion
about one of the attractors located at 8 = 0, 2n, 4n and Sn.
c. The Poincare section simplifies the phase diagram by sampling the phase space at time
intervals equal to the period of the driving frequency. The Poincare section is a stroboscopic
map and only extracts those points in the phase diagram that are commensurate with the
driving frequency. The user-defined function for the Poincare map is poincarePend.
Inserting the previous parameters into this function, it follows
In [66] := pt3 =
poincarePend[
{ 0, #tt}, {0.5 ,1, 1,2/3}, 100,
400, 5000,
PlotRange->{{-25,25}, {-3,3}},
DisplayFunction -» Identity
]&/» {1/2,3/2,2,3};
Displaying the results, you get
In[67]:= Show[
GraphicsArray[Partition[pt3,2]] ,
DisplayFunction -» $DisplayFunction
220
Chapter 4 Nonlinear Oscillating Systems
3
2
1
-20-101
-2
-3
3
2
1
-20-10 1
-2
-3
10 20
10 20
*
3
2
1
-20-10_1
-2
-3
-:
2
1
-20-10 1
-2
-3
10 20
10 20
•
All the Poincare graphs show only one point, which is indicative of periodic motion
with period one. We can overlay the points on a single plot as follows:
In[68] := Show[pt3, Display-Function -» $DisplayFunction] ;
-20
-10
-1
-3
10 20
PROBLEM 4 Looping Solutions for the Driven Pendulum. Consider the solutions of
the driven pendulum
*"M + 7 ff[t] + 4Sin[0M] = /„ cos[a>dt]
that loop over the top in a repetitious manner. In particular, choose the initial conditions
0[O] = 0, ^[0] = 0 and let the parameters be y = \, fQ = 1.44, to0 = 1, and tod = §. These
values correspond to a pendulum that rotates over the top each cycle so the coordinate 8
increases without limit.
a. Plot 0 using the user-defined function anglePend. Notice, values of 6 differing by
2n represent the same physical point. Use the user-defined function anglePendR to
restrict 6[t] to the interval {-n, n}. Compare this graph with the results that followed
from the unrestricted motion.
b. Use the user-defined functions phasePend and phasePendR to plot the phase
trajectory and the restricted phase trajectory, respectively.
c. Use the user-defined functions poincarePend and poincarePendR to plot the
Poincare map and the restricted Poincare map, respectively.
4.2 Nonlinear Pendulum 221
Solution
In[69].= Clear["Global»*"]
a. Consider the initial conditions {0[O] =0, ^[0] = 0} and set the parameters y = 1/2,
f 0=1.44, ld0=1, cod=2/3. To plot 0 apply the user-defined function anglePend:
In[70] := eql =
anglePend[ {0, 0} , { 1/2, 1.44 , 1, 2/3},
50 , 10000 , AxesLabel-» {"t", "},
Ticks -> {Automatic, -n Range[0, 10, 2 ] },
Plotstyle-* { Thickness[0.01]},
Display-Function -» $DisplayFunction
The magnitude of 0 [t] continues to get larger as the pendulum loops over the top on
each cycle.
The pendulum looks periodic but strictly speaking the solution is not periodic because
the 0 values do not repeat. However, the 0 values differing by 2n represent the same physical
point, so the points differing by 2n can be considered to be the same. Let us plot 0 [ t ] using
the user-defined procedure that maps 0 onto the interval —n to n. The user-defined function
is anglePendR. Applying anglePendR to the previous parameters, you get
In[71] := eq2 =
anglePendR[ {0, 0} , { 1/2, 1.44, 1, 2/3},
50,6000 ,
Ticks -» {7r Range [0, 20 , 5] ,
Range[-30, 0,5]},
Plotstylo -» Thickness [0.01]
Displaying these results along with the results of eql, you find
In[72]:= Show[ eql,eq2,
DisplayFunction -» $DisplayFunction];
222
Chapter 4 Nonlinear Oscillating Systems
-2 7T
-47T
-67T
-8tt
-10 7T
U) \ TO ^^0^ <io\
50
The mapping of 6 [ t ] to the physical interval {-n, n} reveals the periodic nature of the
looping motion.
b. What does the phase trajectory look like? You can plot the trajectory using the func-
function phasePend or you can restrict the map to the interval —n to n using phasePendR.
Applying these two user-defined procedures to the motion, you get
In[73] := eq3 =
#[{0,0} ,
{ 1/2, 1.44 , 1, 2/3}, 100 , 6000 ,
PlotRango->A11,
Ticks -> None, PlotPoints -> 150,
Plotstylo ->Hue [Random [ ] ]
] & /& {phasePend, phasePendR} ;
Displaying the results, it follows
In[74]:= Show[GraphicsArray[eq3]];
The curve on the left is the unrestricted phase trajectory and the one on the right is the
restricted phase.
A careful observation of the restricted trajectory suggests that the solution repeats every
second period of the driver. This is clear when you magnify the restricted trajectory edge.
In[75]:= Show[
eq3[[2]],
PlotRange-> {{-1, 0 }, {-1, 1}},
DisplayFunction -» $DisplayFunction
4.2 Nonlinear Pendulum
223
11 ill ill I I
Notice the two bands.
c. Further support for the period two motion follows from a Poincare map. The user-
defined functions for the Poincare map is poincarePend and the restricted map follows
from poincarePendR. The Poincare map is
In[76]:= poincarePend[{0, 0} ,
{ 1/2, 1.44 , 1, 2/3}, 400, 500 , 6000 ] ;
-1.775
-1.8
-1.825
-1.85
-1.875
-1.925
-310 -300 -290 -280 -270
This shows a pattern of two rows of dots. The restricted map reveals the basic period
two motion.
In[77]:= poincarePendR[{0, 0} ,
{ 1/2, 1.44 , 1, 2/3}, 400, 500 , 6000 ] ;
-1.
-
-1.
-1
-1.
0.2 0.4 0.6 0.8
-1.
775
1.8
825
.85
875
925
1.2 1.4
224 Chapter 4 Nonlinear Oscillating Systems
PROBLEM 5 Chaotic Motion for the Driven Pendulum. One of the characteristics of
the driven pendulum
6"[t] + yff[t] + io2oSin[0[t]] = /o cos[^]
is the occurrence of chaotic states where nearby initial conditions lead to widely varying
behaviors. You can approach chaotic behavior by changing the amplitude of the driving
term /0. The Poincare maps for different values of/0 illustrate the path to chaos. Consider
the initial conditions 0[O] = n/2, ^[0] = 0 with parameters y = 0.2, io0 = 1, iod = 0.694.
a. Show that for 0 < /0 < 0.6 the pendulum's motion eventually either damps to an
attractor or is captured into periodic motion about an attractor. In particular consider
/0 = 0,0.1, 0.2, and 0.3.
b. Consider the motion for /0 = 0.69 and show it corresponds to a period three cycle.
c. Show that the motion for f0 = 0.74 is chaotic.
d. Show that the motion for /0 = 0.982 is a looping solution whose restricted Poincare
map is period 2.
Solution
In[78] := Clear ["Global' *"]
a. Consider the initial conditions 0[O] =n/2, ff[0] = 0 with the parameters y=0.2,
o>0=l, a>d=0.694. If f0=0, 0.1, 0.2, and 0.3 then the graphics for 0[t] follow
from
In[79]:= eql = angloPond[
{TT/2,0},
{ 0.2, #, 1, 0.694}, 50 , 10000 ,
PlotRango -» All
]&/» Range [0, 0.3, 0.1] ;
Displaying the results, you get
In[80]:= Show[GraphicsArray[Partition[eql,2]] ,
DisplayFunction -» $DisplayFunction];
4.2 Nonlinear Pendulum
225
After the transients die away the solutions either damp to the origin (top left) or become
periodic about the origin. The corresponding phase trajectories follow from
In [81]:= eq2 = phasoPond[
{TT/2,0},
{ 0.2, #, 1, 0.694} , 600,10000,
PlotRango -> All ,
Ticks -> {7r Range [-1/2, 1/2, 1/4],
None},
PlotPoints -> 100
]&/e Range[0, 0.3, 0.1];
Displaying the results, it follows
In[82]:= Show[GraphicsArray [Partition[ eq2, 2] ] ,
DisplayFunction -» $DisplayFunction];
Likewise, the Poincare maps are simple points
In[83]:= eq3 = poincarePend[
{7T/2, 0},
{ 0.2, #, 1, 0.694} , 500, 600,
10000 ,
Ticks -»False ,
PlotRange->{{-l,l}, {-1,1}},
DisplayFunction -» Identity
]& /» Range[0, 0.3, 0.1];
In[84]:= Show[GrapfaicsArray[Partition! eq3, 2] ]
DisplayFunction -» $DisplayFunction];
226
Chapter 4 Nonlinear Oscillating Systems
b. As f 0 increases to a value of 0 • 69 the periodic cycles become more complex. The
graph for 8 is
In[85]:= angloPond[
{7r/2,0},
{ 0.2, 0.69, 1, 0.694}, 200 , 10000 ,
Ticks -> {Automatic, n Range [0, 2, 1/2 ] } ,
PlotPoints -> 150,
Display-Function -» $DisplayFunction
The phase trajectory reveals more information about the periodicity,
In[86]:= phasePend[
{7T/2, 0},
{0.2,0.69,1,0.694}, 700,8000,
PlotRango -»All,
PlotPoints -» 200,
Display-Function -» $DisplayFunction
4.2 Nonlinear Pendulum
227
A period three cycle is suggested and is confirmed by the Poincare map
In [87]:= poincaroPond[
{TT/2,0},
{0.2,0.69,1,0.694}, 200,700,
10000,
PlotRange-» {{-5 , 10}, {-3, 3}} ,
DisplayFunction -» $DisplayFunction
-4
-2
-1
-2
10
After the transient disappears the periodicity settles into a state of three cycles.
c. You get a chaotic attractor for f 0=0 • 74. The graph of 8 is
In[88]:= anglePend[
{tt/2,0},
{0.2, 0.74, 1, 0.694},300 , 12000,
AxesLabel -> {"t", "},
Ticks -» {Automatic, 7r Range [-5, 5,1 ] } ,
DisplayFunction -» $DisplayFunction
228
Chapter 4 Nonlinear Oscillating Systems
The pendulum does not appear to have any repeatable structure. The lack of structure is
also supported by its phase trajectory (restricted to the interval {-n, n}\
In[89]:= phasePendR[
{TT/2,0},
{0.2,0.83,1,0.694}, 300,10000,
PlotRango -> All,
Display-Function -» $DisplayFunction
The Poincare map is a collection of points with no obvious repetition,
In[90]:= poincarePendR[
{TT/2,0},
{ 0.2, 0.8, 1, 0.694}, 100, 300,
10000,
PlotRango -> All,
Display-Function -» $DisplayFunction
4.2 Nonlinear Pendulum
229
••
•
•
-2 -1
2.
1.
0.
5
2
5
1
5
5
•
•
• •
1 2
d. At f 0 =0 • 982 the motion starts to loop.
In[91]:= anglePend[
{TT/2,0},
{ 0.2, 0.982 , 1, 0.694}, 50 , 12000 ,
AxesLabel -> {"t", "},
Ticks -> {Automatic, n Range [-1, 1, 1/2 ] } ,
DisPlayFunction -» $DisplayFunction
10
20 30
40
50
Restricting 0[t] to the interval {-n, n}, the graph of 6becomes
In[92]:= anglePendR[
{tt/2,0},
{ 0.2, 0.982 , 1, 0.694}, 50 , 12000 ,
AxesLabel -» {"t", "},
Ticks -» {Automatic, n Range [-1, 1, 1/2 ] } ,
Display-Function -» $DisplayFunction
230
Chapter 4 Nonlinear Oscillating Systems
The motion appears to be periodic.
The trajectory for phase space is
In[93]:= phasePend[
{7T/2, 0},
{0.2,1,0.982,0.694}, 300,12000,
PlotPoints -> 150,
Display-Function -» $DisplayFunction
Again, restricting the motion to the interval {-n, n}, the trajectory is
In[94]:= ptl= phasePendR[
{TT/2,0},
{0.2,1,0.982,0.694}, 300,12000,
PlotPoints -> 150,
DisplayFunction -» $DisplayFunction
4.2 Nonlinear Pendulum
231
The motion appears to be periodic. In fact, you discover more details in the motion by
magnifying the edge of the trajectory.
In[95]:= Show[
ptl,
PlotRange-> {{ 1, 3 }, {-1, 1}},
Display-Function -» $DisplayFunction
There are two bands that suggest the motion is of period 2. This periodicity is confirmed
with the restricted Poincare map,
In 196]:= poincaroPondR[
{TT/2,0},
{0.2, 1, 0.985, 0.694}, 200, 300 ,
12000 ,
PlotRange->{{-3,3}, {-3,3}},
DisplayFunction -» $DisplayPunction
232
Chapter 4 Nonlinear Oscillating Systems
-3 -2 -1
-1
-2
-3
12 3
4.3 ¦ DUFFING EQUATION
4.3.1 ¦ Overview
In the previous section we studied the properties of the nonlinear pendulum. Another clas-
classical system used to illustrate nonlinear effects is the Duffing oscillator. In 1918 Duffing
studied a mechanical oscillator consisting of a thin metallic strip attached at each end to
a solid support. Near the middle of the metal strip was an electromagnet powered by an
alternating current. As the current in the magnet went through a cycle, the magnetic field
coupled to the strip and caused the strip to flex. The displacement of the strip stretched the
metal, which produced a restoring force that was proportional to the displacement cubed.
The unforced Duffing oscillator with a cubic restoring term is described by the nonlinear
equation
q"[t]-aq[t]+bq[tf=O
In the following problems we let b > 0 and consider both positive and negative values
of a. This system is conserved and does not lose energy. If energy is lost due to internal
heating then the damped Duffing equation becomes
q"[t]-aq[t]+bq[tf+cq'[t] = O
Finally, if we include a forcing term, then the driven Duffing equation becomes
q"[t] - a q[t] + b q[tf + c q'[t] = f0 cos[wdt]
Each new solution of the Duffing equation provides further insight into nonlinear motion
and gives more examples on how Mathematica is applied to physics. It is useful to create
three user-defined procedures for this section, since these procedures are used in more than
one problem. Basically, all of these procedures numerically solve the Duffing equation and
plot the results in different forms. These user-defined procedures must be entered before
many of the problems in this section will work. They have been placed on the author's
web sites and can be downloaded. The user-defined procedures that we have developed are
dispDuf f, phaseDuf f, and poincareDuf.
4.3 Duffing Equation 233
4.3.2 ¦ Initializations for the Duffing Equation
4.3.2.1 ¦ User-Defined Procedure to Plot the Duffing Displacement Motion
The procedure dispDuf f:
In[97]:= dispDuf f [{qO., pO_}, {a_, b., c_, fO., wd.}, tmax_, step., opts ] : =
Module[{temp},
temp = NDSolvo[
{p'[t] -aq[t] + bq[t]~3 + c p[t] == fO Cos[twd],
q'[t] ==p[t],q[0] = =qO,p[O] ==pO},
{p[t],q[t]}, {t, 0, tmax},
HaxSteps -» step
]//Flatten ;
numgraph=
Plot [q[t] /.temp //Evaluate, {t, 0, tmax},
opts,
DisplayFunction -» Identity
numerically solves the forced Duffing equation and returns a plot of its displacement.
The list {q0#p0} gives the starting displacement and its starting derivative. The list
{a,b,c,f0,wd} gives the parameters for the Duffing equation. The input tmax gives
the maximum time, and step gives the maximum number of steps used to numerically
solve the differential equation. Apply Show with the rule DisplayFunction - >
$DisplayFunction to display the graph. The input opts allows you to add options
to the graphics.
4.3.2.2 ¦ User-Defined Procedure to Plot the Duffing Phase
The user-defined procedure phaseDuf f:
In[98] := pnaseDuf f [{q0_, pO.}, {a., b., c, f0_, &id.}, tmax., step., opts ] : =
Module[{temp},
temp = NDSolvo[
{p'[t] -a q[t] +bq[t]~3 +cp[t] == fO Cos[tud] ,
q'[t] ==p[t],q[0] ==q0,p[0] ==p0},
{p[t],q[t]}, {t, 0, tmax},
MaxSteps -» step
]//Flatten;
ParametricPlot [{ q[t] , p[t] }/.temp //Evaluate, {t, 0, tmax},
opts,
DisplayFunction -»Identity]
returns a plot of its phase diagram. The input is the same as for dispDuf f.
234 Chapter 4 Nonlinear Oscillating Systems
4.3.2.3 ¦ User-Defined Procedure to Plot the Duffing Poincare Map
The user-defined procedure poincareDuf f:
In[99]:= poincareDuf f [{qO-, pO-}, {a., b_, c.# fO-, tod.}, start., tmax.,
step., opts ] : =
Module[{tempi,temp2},
tempi = NDSolve[
{p'[t] -a q[t] tbq[t] + c p[t] == fO Cos [tad],
q'tt] ==p[t],q[0] = =qO,p[O] = =pO},
{p[t],q[t]}, {t,0,tmax},
HaxSteps -> step
]//Flatten;
temp2 = Tablet {q[t] ,p[t]}/.tempi ,
{t, start, tmax, 2 n/ud}
];
ListPlot[temp2,PlotStylo-> PointSize[0.02],opts]
returns a Poincare diagram. The input is the same as for phaseDuf f with an additional
variable start. Instead of starting the time points at t=0, the graph starts at t=start. This
allows a starting time to be picked so the transient motion has died out.
4.3.2.4 ¦ Protect User-Defined Procedures
Finally we apply Protect to the user-defined procedures to keep them from being deleted
with Clear [ "Global »*¦¦].
In[100] .-= Protect [dispDuff, phaseDuf f, poincareDuf f] ;
Off [Clear :: wrsym]
PROBLEM 1 Potential and Phase Diagrams for the Duffing Oscillator. Consider a
system described by the Duffing nonlinear equation of motion,
q"[t]-aq[t]+bq[t]3=O
Assume b > 0 and let a be either positive or negative.
a. Find the Duffing potential and plot it as a function of a and q. Illustrate the double-
well and single-well behaviors.
b. Plot the phase portraits for the single- and double-well potentials. Do this by making
a ContourPlot for the phase trajectories with the same energy. Embellish the
portrait by superimposing the contours on an energy surface.
c. Numerically solve the phase trajectories for a single-well potential. Plot a particular
solution and its phase diagram.
4.3 Duffing Equation 235
d. Numerically solve the phase trajectories for a double-well potential. Plot a particular
solution and its phase diagram.
e. Animate one of the solutions.
Remarks and Outline An expression for the energy follows from multiplying the equa-
equation of motion by q' [t] and then integrating. Potential and phase diagrams are graphed
using the commands Plot, Plot3D, and ContourPlot. The graphics need the add-on
package Graphics * Legend V The shape of the potential depends on whether a is pos-
positive or negative. The two-well potential with a > 0 has three equilibrium positions: two
are stable and the third equilibrium position at the origin is unstable. The one-well poten-
potential with a < 0 has only one stable equilibrium position. The numerical solution follows
from applying NDSolve to the nonlinear equation. The solution is returned in terms of an
interpolating function.
Solution
In[101] : = Clear ["Global' * "]
a. The Duffing equation is described by the acceleration
In[102]:= Ace = q" [t];
and the two forces,
In[103]:= Flinear= aq[t];
Fnonlinear = -bq[t]3;
The force term has been separated into a linear and nonlinear term. The equations of motion
follow from Newton's second law,
In[104] : = oqMotion = Ace - Flinear - Fnonlinear == 0
Out[104]= bq(tK -aq(t) + q" (t) ==0
To reduce the problem to a first integral, i.e., to find the conserved energy, multiply
the equations of motion by q' [t], integrate, and set the results equal to a constant (the
energy):
In[105]: = energy =
Integrate[
q' [t] (Ace - Flinear - Fnonlinear) , t]
Out [105]= -bq(tL--aq(tJ + -q'(tJ
The kinetic energy T follows from integrating Ace and the potential energy follows from
integrating Flinear and Fnonlinear:
236
Chapter 4 Nonlinear Oscillating Systems
In[106] := {T = Integrate [ q'[t] Ace , t] ,
VO = - Integrate [ q' [t] Flinear, t],
VI = - Integrate [ q' [t] Fnonlinear , t] }
Out[106]= {iq'(tJ, -iag(tJ, i
To graph the potential, fix b=0.05. Next apply Plot3D to the total potential VO +
Vl and vary q and a:
In[107]:= Plot3D[V0 +Vl//.{q[t] -> q, b -> 0.05} //
Evaluate,
{q, -15, 15},
{a,-1,4},
AxesLabel -> {"q", "a", "Potential"},
BoxRatios -> {1, 1, 1},
PlotRange -> {-100, 50},
Viewpoint -> {0, 3, 1}
Potential
-50
-100
The three-dimensional plot illustrates how the shape of the potential changes from a
one-well potential with a < 0 and then for a > 0 to a two-well potential. A qualitative
change in the dynamics is produced when the potential makes this change. The value a=0
is called a bifurcation value and this particular bifurcation point is known as a pitchfork.
To illustrate the two types of potentials you graph one potential curve with parameters
{b=0.05, a=-l} and the other with {b=0.05, a=4}. Add to the Plot command
the option PlotLegend found in the add-on package Graphicsl Legendl:
In[108] .-= NeedsfGraphics'Legend'"]
4.3 Duffing Equation
The potential curves follow from
237
In [109]:= Plot[
V0+Vl//.{q[t] -»q, b->0.05}/.
a -> {-1, 4} //Evaluate,
{q, -15, 15},
Ticks-> None,
PlotStyle->{
{Dashing[ {0.01} ], Hue[0.6]},
{Dashing[ {0.03} ] , Hue[0.9] }},
PlotLegend- > {" a = -1", " a = 4"},
LegendPosition->{0.1, 0.3}] ;
The two-well potential (a > 0) has three equilibrium positions: two are stable, while
the third position at the origin is unstable. For the potential with a < 0 there is only one
stable equilibrium position.
It is useful to have a physical picture to think about. Imagine a bead sliding on a wire in
the shape of the double-well. The bead can exist at rest at the bottom of the wells and at the
top of the well. If the bead at the top is slightly displaced to the left it will be attracted to
the left well and then continue to oscillate between the two wells. In general the beads in
the wells will oscillate in the wells if they do not have sufficient energy to go over the top
of the well. For the one-well potential, the bead slides in one dimension along the sides of
a bowl. The only place the bead can remain at rest is at the bottom of the bowl. In general
the bead will oscillate back and forth in the bowl.
b. One way to make phase portraits for these two characteristic potentials is to apply
ContourPlot to the energy. Define the notation and fix the value of b.
In[110] : = values = {q[t] -»q, q'[t] -> v, b-» 0.05};
Consider the contour graphics for a=-l (single-well potential) and a=4 (double-well po-
potential):
238
Chapter 4 Nonlinear Oscillating Systems
In[111]:= contour =
ContourPlot[
energy//.values//. { a -» # } //
Evaluate,
{q,-15, 15},
{v, -15, 15},
Contours -» 10 ,
PlotPoints -> 20,
ColorFunction -»Hue,
Display-Function- > Identity
]& /» {-1,4};
Displaying the two graphs, it follows
In[112]:= Show[GraphicsArray[contour]];
-15!
-1510-5 0 5 1015 -1L--.-- -¦ - -J-5
The contour plot on the left is for the single-well potential and the one on the right is
for the double-well.
The contour graphs can be embellished if we superimpose the phase contours on a
surface-energy plot. Consider the two-well potential with a=4 and b=0.05. The Con-
ContourPlot is
In[113]:= ptl= ContourPlot[
energy //.values//. { a -» 4 } //
Evaluate,
{q, -15, 15},
{v, -15, 15},
Contours -» 10 ,
DisplayFunction -» Identity
and the energy surface is
4.3 Duffing Equation 239
:= pt2 =
Plot3D[energy//.values//. { a-» 4 }//
Evaluate,
{q, -15, 15},
{v, -15, 15},
PlotPoints-» 20,
ColorFunction -»
(If [# < 0.226, Hue [0.9], Hue [0.1]]&),
Display-Function -»identity
Combining the contour lines in eql with the energy surface in eq2, it follows
= Show
Pt2,
6rapfaics3D
{AbsolutoThicknoss[3],
Cases[Graphics[ptl],_Line,
CO]/.
{ q-Real, v.} :>
{q,v, 15 -2q2 + 1/2 v2 + 0.0125
Viewpoint -> {0, 1, 0.8},
Display-Function -» $DisplayFunction
-1
-10
This energy surface clearly illustrates the motion of a bead sliding on a wire with the
shape of the double-well. If the bead's energy is not sufficiently large it will form a periodic
oscillation in one or the other well—the bead will be trapped in the well. On the other hand,
if the motion is sufficiently large the bead will oscillate between both wells.
c. Let us consider a numerical example of the Duffing motion. Instead of solving the
second-order Duffing equation, you can consider two equivalent first-order equations. The
equations of motion written as two first-ordered equations are:
240 Chapter 4 Nonlinear Oscillating Systems
In[116]:= eql = {eqMotion/.{q"[t] ->p'[t]},
q'[t] ==p[t]}
Out [116]= |bq(tK-aq(t) +p'(t) = =0,q'(t) ==p(t)}
Assume the initial conditions
In[117] : = initial = {p[0] == 0.001, q[0] == 0};
and combine them with the Duffing equations,
In[118] := eq2 = Join [eql, initial] ;
Consider the case of a single-well with a=-l and b=0.05. Applying NDSolve to
eq2, you get
In[119] : = ndsoll =
NDSolvo[eq2//.{b-» 0.05, a-» -1},
{q[t],p[t]}, {t, 0,30}]//Flatten
Out[119]= {q(t) -> InterpolatingFunction [ @. 30. ) , <>] [t] ,
p(t) -> InterpolatingFunction [ @. 30. ) , <>] [t]
The solution is returned in terms of an InterpolatingFunction. You will find it
convenient to define the displacement function ql and velocity function pi for this single-
well case:
In[120]:= ql[t_] =q[t]//.ndsoll;
pl[t_] = p[t]//.ndsoll;
To plot q and p versus t you define the general user-defined plot function
In[121]:= pt[var_, opts—] : =
Plot[var[t], {t, 0, 30}, opts,
DisplayFunction->Identity]
The graphs of ql and pi versus t for the single-well potential are
In [122]:= Show[
Graphic sArray[
{pt[ql,PlotStylo->Hue[0.7] ] ,
pt[pl, PlotStyle- >Hue[0.9] ] }
0.001
0.0005
-0.0005
-0.001
0.001)
0.0005
0
-0.0005
-0.001
A !A A
EfttiB
4.3 Duffing Equation
241
d. Let us now consider the double-well potential with a=4 and b=0.05. Applying
NDSolve to eq2, you get the following numerical solution for this double-well potential,
In[123] := ndsol2 =
NDSolve [eq2//.{b-» 0.05, a -> +4},
{q[t],p[t]}, {t, 0,30}]//Flatten;
Define the interpolating functions
In[124]:= q2[t_] = q[t] //.ndsol2;
p2[t_] = p[t]//.ndsol2;
where q2 and p2 are the displacements and velocity for the double-well case. The plots of
q2 and p2 versus t for the double-well potential are
Jn[125]:= Show[GraphicsArray[
{pt[q2,PlotStyle- > Hue [0.7] ] ,
pt[p2, PlotStyle- >Hue[0.9] ] }
10
5
-5
-10
5 3f0
10
5
-5
-10
j\
C
k)
i i
\
The left-hand graph is for the displacement q2 versus t and the right-hand graph is for
the velocity p2 versus t. Notice how the graphs are sharply peaked. The two-well motion
is certainly more complex than the one-well case but the motion is still periodic and repeats
with a definite period.
Using our analog of a sliding bead you see that the bead slides through one well and up
to the top of the double-well. At the top of the double-well the bead slows and then falls
toward the other well, picking up speed as it falls. The bead continues to oscillate between
the two wells because there is no dissipative term to decrease the energy. The behavior
of the solution depends on the initial conditions (energy). To analyze the details of the
periodic motion consider its phase trajectory:
In[126]:= ParametricPlot[
{ q2 [t] , p2 [t] } //Evaluate,
{t, 0, 30},
AxesLabel -» {"q", "p"} ,
AspoctRatio -» Automatic
242
Chapter 4 Nonlinear Oscillating Systems
e. To animate the motion define the user-defined function oscMovie:
In[127]:= oscMovie [f_, tMax., frames-,
range.:Automatic] :=
Module [{t,i},
Do[
t = itMax/frames;
plot[i] =
Show[
Graphics [
{PointSize[0.05],
Point[{N[f[t]],0}]},
PlotRange-* {range, {-1, 1}}],
Axes -»True
]*
{i,l, frames}]
Given a periodic function f of variable t, this procedure animates the motion in one
dimension. The input tMax is the final value of t, the range determines the size of the
graphic window, and frames is the number of frames. This function is a straightforward
application of a Do loop for graphics.
Consider the animation for q2. To generate the graphic frames, apply oscMovie:
In[128]:= frames = 1;
oscMovie [q2, 30, frames, {-15, 15}];
4.3 Duffing Equation 243
-15 -10 -5 ^ 5 10 15
-0.25
Only one frame is displayed. To view the animation increase the number of frames and
double click on one of the cells. You get a movie of a bead sliding back and forth from one
well to the other.
PROBLEM 2 Phase Diagram and Orbits for the Damped Duffing Equation. The
equation for the damped Duffing equation is
q"[t]-aq[t]+bq[t]3 + cq'[t] = O
Assume c>0 (damping) and let a be either positive (double-well) or negative (single-well).
a. Set {b=0.05, c=0.15} and a=4 for the double-well potential and a=-l for
the single-well potential. Make two phase portraits for these parameters using the
command PlotVectorField.
b. Use the user-defined function dispDuff with f0 = cod=0, a=4, and b=0.05
to graph examples of displacements that oscillate in the right well, left well, and
both wells. Use the user-defined function phaseDuf f defined at the beginning of
this section with /0=0 and o>d=0 to display the phase trajectories for your various
solutions.
Solution
In [129]:= Clear ["Global'*"]
a. You cannot directly get a phase portrait from an analytic expression, because there is
no conserved energy. However, the phase portrait does follow from PlotVectorField
found in the add-on package Graphics1 PlotField1:
In[130] := Needst'Graphics'PlotField'1"]
PlotVectorField plots a set of arrows that are tangent to the phase trajectories.
Consider b=0.05 and c=0 • 15 and a=4 for the double-well potential and a=-l for the
single-well potential. The phase portraits follow from
244
Chapter 4 Nonlinear Oscillating Systems
In[131]:= lista =
PlotVoctorFiold[
{P, #q- 0.05 q~3-0.15 p },
{q, -13, 13},
{p, -20 , 20 } ,
PlotPoints -> 10,
ScaloFunction -> @.2#&),
ScaleFactor ->None,
Display-Function -»identity
]& /» {4,-1};
Displaying the results, it follows
In[132]:= ptl = Show[GraphicsArray[lista]];
The graph on the left is for the double-well and the one on the right is for the single-
well. Notice, regardless of the initial conditions the orbits lose energy through dissipation
and eventually spiral to the attractors at the bottom of the wells. Referring to the model
of a sliding bead, the bead loses energy due to dissipation and eventually ends up at the
bottom. The exception is for the double-well, where the bead can remain at rest at the top
of the well. This result is analogous to the phase portrait for the damped pendulum except
there are not as many attractors.
b. Let us consider the double-well potential and plot the orbits that spiral around the
left well, right well, and both wells before converging to either the right or left wells.
The solution follows from applying NDSolve to the damped Duffing equation. We have
made a general user-defined function, dispDuf f, to numerically solve the general forced
Duffing equation,
q"[t] - a q[t] + b q[tf + c q'[t] = f0 cos[adt]
and then plots the solution. In this problem we consider the special case where f0 = cod=0.
4.3 Duffing Equation 245
Let {a=4, b=0 • 05} and consider examples where the orbits are around the left well,
right well, and both wells. After some trial and error, you find that the list of initial condi-
conditions {qO, pO} for the four cases are
ln[133]:= values = {{-4,4}, {4,4}, {4,23},
{-4,-23}};
The graphics for the four displacements are
In[134] .- = listb =
dispDuff[
# ,
{4, 0.05, 0.1, 0, 0}, 30, 1000 ,
PlotStylo -» Hue [Random [ ] ],
PlotRango ->All
]& /0 values;
Displaying the results for the first two cases,{qO,pO}-»{-4, 4} and {q0,p0}-»
{4,4}, you get
In[135]:= Show[
PlotRange -> {{0, 30}, {-14, 14}},
Display-Function -» $DisplayFunction
10
5
10 15 20 25 30
-5 '
-10
The plot for the top curve corresponds to the initial values {qO,pO}={4,4}. The
displacement is confined to the right well and eventually decays to the attractor at the
bottom of this well. The plot for the bottom curve corresponds to the initial condition
{q0, pO}={ -4,4 }. Its displacement is confined to the left well and decays to the attractor
at its bottom.
Displaying the results for the last two cases,{qO,pO}-»{4,23} and {q0,p0}-»
{-4,-23}, you get
246
Chapter 4 Nonlinear Oscillating Systems
ln[136]:= Show[
PlotRange-» {{0, 30}, {-14, 14}},
DisplayFunction -» $DisplayFunction
10
5
-5
-10
AAAAAA
rftvv
KtfllVVV
15
VV
A
20
V
/ \ / \ / '¦
25
\ A A /
vw
30
\
Both motions start out oscillating between both wells and then decay to the at-
tractors located at the bottom of the right or left wells. The plot for the curve with
{q0#p0}={4,23} decays to the attractor at the left. The plot for the curve with
{q0#p0}={4, -23} decays to the attractor on the right.
The phase diagrams reveal the details of these motions. The phase diagrams follow
from applying ParametricPlot to the {q,p} solutions. We have made a general user-
defined function, phaseDuf f, to make the phase graphics for the general forced Duffing
equation
q"[t] ~ a q[t] + b q[tf + c q'[t] = /„ cos[a>dt]
In this problem you are considering the special case where f0 = a)d=0, a=4 and b=0.05.
The initial conditions are given by the rules in values. The phase diagrams for these four
solutions are
In[137] := listc =
phaseDuff[
# ,
{4, 0.05, 0.1, 0,0}, 30, 1000,
PlotStylo -» Hue [0.6],
PlotRango -» All
]& /0 values;
Displaying all four phase trajectories, you get
In[138] := Show[6raphicsArray [Partition[ listc, 2] ] ,
DisplayFunction -» $DisplayFunction ] ;
4.3 Duffing Equation
247
This again confirms our description of the motion. The phase trajectories can be thought
of as showing the bead moving back and forth before it settles to the bottom of the well.
The bead in the last two graphs moves between both wells before falling into one or the
other well. The trajectories for any combination of initial conditions will eventually decay
to one or the other of the attractors.
Let us combine the bottom right phase trajectory with the phase portrait given by
In[139]: = Show[
{ listc[[4]] ,
PlotRango-* {{-15, 15}, {-20, 20}},
DisplayFunction -» $DisplayPunction
Each attractor has a basin of initial conditions that lead asymptotically to that attractor.
PROBLEM 3 Driven Duffing Orbits with No Damping. Let us consider the driven
Duffing equation
q"[t] ~ a q[t] + b q[tf + c q'[t] = f0 cos[w/]
with no damping, so c=0. There is no dissipation to cause the bead to settle into an attractor
so the long time behavior of the motion is governed by the periodic forcing term.
248 Chapter 4 Nonlinear Oscillating Systems
a. Consider the single-well potential with a=-l and set b= 1, /0=l/4,0)d=2. Choose
the initial conditions {q[0]= 2.038, q'[0] =-1.5} and plot the displacement
and phase trajectory. Show that the phase trajectory is confined to an elliptical band
and discuss the structure of the phase trajectory by enlarging a portion of the graph.
Examine its periodic structure by making a Poincare map of the solution.
b. Consider a second example of a weak double-well potential with {a=l/5, b=l,
/0=l/4, o)d=2} and for zero damping, c=0. Repeat the calculation in Part a for the
initial conditions {q[0] =0.99, q' [0]=0}.
Solution
In[140]:= Clear [-Global **-]
a. If you assume the initial conditions are q[0] =2.038 and q' [0]=-1.5 then the
plot of the displacement follows from the function dispDuf f:
In[141]:= dispDuff[
{2.038,-1.5},
{-1,1,0, 1/4, 2 }, 100, 10000 ,
PlotPoints -> 200,
DisplayFunction - > $DisplayFunction
The displacement appears to be periodic with a beat in the oscillation.
To exam the periodicity consider its phase trajectory that follows from phaseDuf f,
In [142] := ptl =
phaseDuff[
{2.038,-1.5},
{-1,1,0, 1/4, 2 }, 100 , 10000 ,
PlotPoints -> 300,
DisplayFunction - > $DisplayFunction
4.3 Duffing Equation
249
Although the phase trajectory is not a single path, it is clear that the trajectory is confined
to an elliptical band. To view the detailed structure of the band-like structure enlarge the
left end of the elliptical disk,
In[143]:= phaseDuff[
{2.038,-1.5 },
{-1,1,0, 1/4, 2}, 100, 10000 ,
PlotPoints-* 300,
PlotRange-> {{1.93, 2.2}, {-3 , 3 }},
Display-Function -» $DisplayFunction
2.2
There appears to be structure in the band! To further illuminate the structure, plot the
end structure for time periods of t=20 and t=50. The two graphs follow from
In[144]:= list =
phaseDuff[
{2.038, -1.5 },
{-1,1,0,1/4, 2}, #,10000,
PlotPoints -> 300,
PlotRange-> {{1.93,2.2}, {-3,3}}
]& /» {30,50};
Displaying the results, you get
In[145] : = Show[GraphicsArray [ list ] ];
250
Chapter 4 Nonlinear Oscillating Systems
2.2 1
2.2
The complex periodic structure is clearly revealed with its Poincare section,
ln[146] := pt2 =
poincareDuff[
{2.038,-1.5},
{-1,1,0, 1/4, 2 }, 0 , 300, 10000 ,
DisplayFunction - > $DisplayFunction
•-..
>
1.9 1.95
#2
2.05 2.1 2.15
Superimposing the Poincare map on the band to see the relation between the map and
phase trajectory, it follows
In[147]:= Show[ptl, pt2,
PlotRange-> {{1.8, 2.4}, {-3 , 3 }} ] ;
1.8 1.
b. Consider the second example for a small double-well with {a=l/5, b=l, c=0,
fO=l/4, wd=2}. If you assume the initial conditions are q[0]=0.99 and q' [0]=0
then the plot of its displacement follows from
4.3 Duffing Equation
In[148]:= dispDuf f [
{0.99 , 0},
{1/5 ,1,0, 1/4, 2}, 200, 10000 ,
PlotPoints -> 200,
DisplayFunction - > $DisplayFunction
251
0.5
-0.5
As in Part a, the path appears to be somewhat periodic with a beat in the motion.
To exam the periodicity consider its phase trajectory,
In[149]:= pt3 =
pfaaseDuff[
{0.99 ,0},
{ 1/5,1,0, 1/4, 2 }, 300, 10000 ,
PlotPoints -> 200,
DisplayFunction - > $DisplayFunction
The complex structure in this band is revealed by its Poincare map.
In[150] := pt4 =
poincaroDuff[
{0.99 ,0},
{ 1/5,1,0, 1/4, 2 }, 0 , 350, 10000 ,
DisplayFunction -» $DisplayFunction
252
Chapter 4 Nonlinear Oscillating Systems
0.6
0.4
0.2
-0.75 -0.5 -0.25
-0.2
—• •"•«^~0-4
...«* -0.
0.25 0.5 0.7
PROBLEM 4 Two Well Driven Duffing Oscillators with Damping. Consider the
driven Duffing equation with damping,
q"[t] - a q[t] + b q[tf + c q'[t] = /„ cos[udt]
Let the parameters be {a=l/2, b=l/2, c=0.3, wd=l} with the initial conditions
q [ 0 ] = -0.13 and q' [0]=-0.7 and investigate the changes in the motion caused by
small changes in the driving amplitude. This will lead to chaotic motion as it did in the
case of the driven pendulum.
a. Consider two values of the amplitude, /0=0.05 and 0.24, and plot the displace-
displacements, phase trajectories, and Poincare maps. Show that the two motions are periodic
and correspond to a period one cycle and period two cycle, respectively.
b. Increase the amplitude a little further by letting /0= 0.29 and 0.32. Plot the
displacements, phase trajectories, and Poincare maps. Show that the motion for the
first case is chaotic and the second is a looping motion with a period three cycle.
Solution
In [151]:= Clear [-Global'*"]
a. Consider the driven Duffing equation with parameters a=l/2, b=l/2, c=0.3,
f 0= .4, and wd=l. If you assume the initial conditions q [0] =-0.13 andq' [0] =-0.7
then the graphics for the two displacements with f 0=0.05 and 0.24 follow from
In[152]:= lista =
dispDuff[
{-0.13,-0.7},
{ 0.5, 0.5, 0.3, #, 1 }, 50 , 10000,
Plotstylo -> Hue [Random [ ] ] ,
PlotPoints-* 200
]& /» {0.05 ,0.24 };
Displaying the results, you get
In[153]:= Show[GraphicsArray[Partition[lista, 2] ] ];
4.3 Duffing Equation
253
3.
-0.2
-0.4
-0.6
-0.8
-1
-1.2
-1.4
10 20 30 40 50
I \ A A A
\/ V V V
\ A A
v v v
-0.2
-0.4
-0.6
-0.8
-1
-1.2
-1.4
10 20
0 40 50
\
\ WV\
After the transients die out, the displacements appear to go into periodic motion around
the left well. The right graph appears to have both a large and a small component in the
oscillation.
To get a better idea of the periodic structures, consider the phase trajectories that follow
from the command phaseDuf f. The phase trajectories for these two examples are
In[154] : = lista =
phaseDuff[
{-0.13,-0.7},
{ 0.5, 0.5, 0.3, #, 1 }, 300 , 10000,
PlotPoints -> 200
]& /» {0.05 , 0.24 };
Displaying the results, it follows
In[155]:= Show[GraphicsArray[ lista ] ] ;
The graph on the left corresponds to a trajectory that goes into periodic motion about the
attractor. It has a period one structure. The graph on the right has a double structure. The
Poincare plots for the trajectories follow from the user-defined function poincareDuf f.
Applying this procedure to these examples, you get
In [156]:= listb =
poincareDuff[
{-0.13,-0.7},
{ 0.5, 0.5, 0.3, #, 1 }, 100, 400 ,
10000, PlotRange-» {{-2, 2}, {-1, 1}},
Ticks -» False,
Display-Function -» Identity
]& /» {0.05,0.24};
Displaying the results, it follows
In[157]:= Show[GraphicsArray[ listb] ];
254
Chapter 4 Nonlinear Oscillating Systems
The Poincare plot on the left returns one point so you know that the motion completes
its cycle in the same time as the forcing function completes its cycle. It has period one
motion. The Poincare map on the right is for period two motion and repeats every second
cycle of the forcing function.
b. Consider the driven Duffing equation with a further increase of the driving amplitude
to f 0=0.29 and 0.32. The graphics for these displacements follow from
In [158] := listc =
dispDuff[
{-0.13,-0.7},
{ 0.5, 0.5, 0.3, #, 1 }, 50 , 10000,
PlotStylo -> Hue [Random [ ] ] ,
PlotPoints -» 200
]& /» {0.29 , 0.32};
In[159] := Sfaow[6rapfaicsArray [ listc ] ];
1
0.5
0.5
-1
A A A
rj \i
2jO 30 40^-
\bU
\
The left graph suggests the motion goes randomly from one well to the other and back
again. The right graph has a more periodic nature but with structure in the path.
To get a better idea of the periodic nature of the structure, consider their phase trajecto-
trajectories,
In [160] := listd =
phaseDuff[
{-0.13,-0.7},
{ 0.5, 0.5, 0.3, #, 1 }, 300 , 10000,
PlotPoints ->200
]& /& { 0.29 ,0.32};
In[161] := Show[GraphicsArray [ listd ] ];
4.4 Exercises
255
The left phase diagram appears chaotic, as the orbit has an inclination to jump somewhat
randomly from one well to the other. The right phase orbit is more regular and appears to
be period three.
The type of motion follows from its Poincare map. Applying the user-defined function
poincareDuf f to these examples,you get
In [162] := liste =
poincareDuff[
{ -0.13,-0.7},
{0.5,0.5,0.3,#,1}, 100,400,
10000, PlotRange-» {{-2, 2}, {-1, 1}},
Ticks -»False,
DisplayFunction -» Identity
]& /» {0.29,0.32};
Displaying the results, it follows
In[163] := Show[GraphicsArray [ liste ] ];
-•,*
Our suspicions are confirmed. The chaos motion has structure but does not appear to
repeat. The period three example repeats every third cycle of the forcing function.
4.4 ¦ EXERCISES
The solutions to many of these exercises can be found at our web site.
4.1 van der Pol Oscillator and Limiting Cycles
The van der Pol oscillator is a classical example that illustrates the concepts of limiting cycles.
These equations appear in the study of some oscillating electrical circuit. The system can be
represented by two first-order equations,
x'[t]=y[t]
256 Chapter 4 Nonlinear Oscillating Systems
The van der Pol equation represents a system with a limiting cycle. Let the parameters be a=2 and
(O0=l and consider two trajectories that are singled out by the initial conditions {x [0] =0. 06,
y[0]=0}and{x[0]=0, y[0]=4}.
(a) Find the numerical solutions for these two cases and plot x [t] and y [t].
(b) Compare their phase trajectories,{x [t],y[t]}.
4.2 Springs
A particle of mass m is held at rest by two identical springs, each of natural length b with spring
constant k. The whole system is on a smooth table. The particle is pulled directly to the side and
released.
(a) Show the motion can be described by the equation
mx"[t] + 2kx[t] 1-
1
= 0
(b) Make a phase portrait and numerically solve the equations for several different phase trajec-
trajectories.
(c) Add damping and forcing terms to the equation and discuss the nonlinear properties of the
solution.
4.3 Buckling Column System
Consider the oscillations of a single, flexible, column that supports a mass within a horizontally
constrained space. The dynamics are described by the equations:
dx
where x represents the sideways displacement of the column, and y the velocity of its movement.
The parameters m and c (c>0) represent mass and friction, respectively.
(a) Make a phase portrait for the buckling column model and discuss its behavior.
(b) Numerically solve for several different phase trajectories.
(c) Add a forcing term to the equation and discuss the nonlinear properties of the solution.
4.4 Nonlinear Equation
Consider the nonlinear system
dx _
(a) Find the potential and analyze the dynamics.
(b) Make a phase portrait and discuss its properties.
4.5 Inverted Pendulum
Consider a plane pendulum of a light stiff rod of length L with a mass m attached to its end.
Assume the pivot oscillates vertically as &cos[(odt] with frequency (od and amplitude A.
4.4 Exercises 257
(a) Show that the motion is described by
4>"[t] + (to2 ~ju2dcos[wdf]jsin[0] = O
(b) Find the conditions under which the inverted vibrating pendulum is stable and analysis its
motion.
4.6 Driven Nonlinear Equation
Consider the nonlinear equation
x"[t] + Xx[t] + col 4'K1 + kx[t]2) + cx'lt] = A cos[t co]
(a) Set A=0, make a phase portrait, and discuss the solution.
(b) How do the phase space trajectories change if A is nonzero?
CHAPTER
5
Discrete Dynamical Systems
5.1 ¦ INTRODUCTION
A dynamical system can be described by a discrete or continuous change. In the previ-
previous chapter we dealt with the behavior of nonlinear systems, where the continuous time
evolution was described by differential equations. We considered the behavior of the non-
nonlinear pendulum and the Duffing equations, and graphed examples of phase trajectories
that included fixed points, periodic motion, and chaotic behavior. Discrete maps were used
to make Poincare sections, which are snapshots of the phase plane taken at each drive
period; the maps reduced the periodic behavior to the study of points. Maps are discrete
time analogs of a continuous system. Any numerical solution of a differential equation that
uses discrete time steps in the approximation is effectively a map. Maps help explain, for
example, why a continuous-time system, which should not exhibit chaos, may have numer-
numerical solutions which do. Many of the earliest numerical studies of chaos began by studying
maps. In this chapter we explore the best known discrete systems.
A map is an equation of the form xx = f[xo] that gives the state xx resulting from the
initial state xo. The map f[x] starts from some initial condition, feeds that number into
the map to produce a second value, feeds that value back into the map to produce a third
point, and so on. The orbit of the map is the sequence of points generated from an initial
condition. A point on the orbit of a discrete map is indexed by an integer n, which may be
thought of as the discrete analog of time.
Maps that start from different initial conditions eventually settle into one of three dif-
different types of behavior: fixed points, periodic orbits, or chaotic behavior. A fixed point
is like an equilibrium point. For example, a harmonic oscillator with zero velocity located
at its equilibrium position will remain at that point. Fixed points are unchanged by their
maps and satisfy equations of the form /[/[.. ./[*]]] = x, where / is the map. Certain fixed
points are attracting; if you start from a point close to a fixed point, then the orbit will be
attracted to the fixed point. The damped pendulum is an example where the swing eventu-
eventually comes to rest at its attractor. Repelling structures tend to evolve away from the fixed
point, like the motion near an unstable equilibrium position. Periodic orbits occur when
points alternate between two or more fixed values. The properties of the orbit can change
as the parameters of the map are varied. The values of a parameter where the nature of
the motion changes are known as bifurcation points. For instance, at a bifurcation point a
period one orbit can split into a period two orbit and eventually become chaotic.
Chaos, the unpredictable long time behavior, is a consequence of the system's sensitivity
to initial conditions. No matter how precisely you measure the initial condition in these
systems, your prediction of its subsequent motion goes radically wrong after a short time.
258
5.1 Introduction 259
In this chapter we consider two ways to quantify chaos, one with its Lyapunov exponent,
and the other with its entropy. The Lyapunov exponent quantifies the divergence of orbits
in chaotic systems. More precisely, consider a map f[x] and allow the system to evolve
from two slightly differing initial states, x and x + s. After n iterations the diverging orbits
may be characterized by
where fn(x) = /[/[.../[*]]]. The parameter An represents the rate of divergence. In the
limit that e goes to zero, the Lyapunov exponent is determined by the derivative of the map
, 1, _/»(* +e)-/»(x)
^-ln
n
dx
The Lyapunov exponent is defined as A = Limit[An, n -* oo]. It can be shown that this is
equivalent to
A = lim - V In
n-*oo n *-^
i=0
dx
The expression A measures the exponential separation rate between two nearby orbits.
If A is negative, then the orbits converge, and the dynamical system is insensitive to its
initial conditions. However, if A is positive, then the distance between nearby orbits grows
exponentially, and the system is sensitive to the initial conditions.
Another way to quantify the disorder in chaos is by its entropy. If p is a list of probabil-
probabilities {/>,}, then the entropy is defined as
entropy = -
Entropy measures the homogeneity of the system's distribution into its various states. A
system with very low entropy is usually found in one of a small number of possible states,
and is said to be more predictable than a system that wanders around among a large number
of states. If the system has only one allowed state we say it is perfectly ordered—we know
in advance what state the system is in and hence have gained no new information. If the
subintervals are equally probable then the entropy has its maximum value.
A study of chaos would not be complete without a comment about fractals. Chaotic
systems almost inevitably give rise to fractals. Fractals exhibit self-similarity and are inde-
independent of scale—if you concentrate on one portion of the fractal the resulting pattern is
similar to the original. In this chapter we consider the two canonical examples of this class,
the Mandelbrot and Julia sets.
There are three sections on problems: Logistic Map, Other Maps, and Fractals. At the
beginning of each problem section we include an overview of the topic followed by several
representative problems. This chapter concludes with a set of exercises.
Before starting this chapter you might want to turn off the spell checker.
In[l]:= Off[General :: spell];
Off[General :: spelll];
260 Chapter 5 Discrete Dynamical Systems
5.2 ¦ LOGISTIC MAP
5.2.1 ¦ Overview
In this section, we illustrate the various behaviors that maps can have by considering the
simple logistic map. The map is denned by
where fi is a parameter in the range 0 to 4 and xn is between 0 and 1. All initial conditions
eventually settle into one of three types of behavior:
1. Fixed points are points where the iterations approach a stable value like the motion
of an overdamped harmonic oscillator.
2. Periodic orbits are points where the iterations alternate between two or more fixed
values.
3. Chaotic orbits are points where the iterations continue to vary wildly.
PROBLEM 1 Logistic Map. Consider the logistic map described by xn = fi xn_i(l ~
*n_i), where fi is a parameter to be set anywhere from 0 to 4 and the range of x is between
0 and 1. As fi varies, there are bifurcation points where the behavior of the orbit changes.
a. Define a user-defined function that returns n iterations of the logistic map. Let fi =
2.9 and find the first 50 iterations starting at x0=0.1. Show that the iterations
approach a fixed point at 0.655. Define a user-defined function that automatically
graphs the orbit. Apply the user-defined procedure to this example.
b. As fi increases the orbit period doubles, changing from 2 to 4, from 4 to 8, etc.
Eventually the orbits become chaotic. Let/* = 3.4 and plot the period two orbit. Let
fi = 3.54 and plot the period four orbit. Plot a period eight orbit by setting fi = 3.55.
Finally, show that/* = 3.57 leads to a chaotic orbit.
Solution
In[2]:= Clear["Global'* "]
a. Define the logistic map
In[3]:= map[fi_] := \i # A - #)&;
If you start the map at xO, then the first two iterations give
ln[4]:= {xO, map[n] [xO],map[/j] [map[ n] [xO]]}
Out[4]= [xO, A-xO) xOfJ, A -xO) xOfJ2 A - A -xO)
5.2 Logistic Map 261
This sequence of iterations can be expressed very succinctly using NestList. Starting
at xO and applying NestList to the logistic map n times, you get the following user-
defined function for the orbit,
In [5]:= orbit [n., xO-, n. ] : =
NestList [ v* A - #) &, x.0 , n ]
where xO is the starting point and n is the number of iterations. For example, the first two
iterations are
In [6] : = orbit [fi , xO , 2 ]
Oat 16] = [xO, A -xO) xOfi, A -xO) xOfJ2 A - A - xO) xO fi) }
Consider the map for fi = 2.9 with a starting point at x0=0.1. The first 20 points are
In[7]:= orbit [2.9 ,0.1,20]
Out[7]= {0.1, 0.261, 0.559349, 0.714785, 0.591215,0.700871,
0.607987,0.691183,0.619003,0.683931,0.626891,
0.678306, 0.6328, 0.673856, 0.637345,0.670296,
0.640898, 0.667428, 0.643707, 0.66511, 0.645942}
The points appear to be approaching a fixed point. You can find the fixed point by
considering 300 iterations or so, and drop all but the last 8 points. Doing this, you get the
limiting value or fixed point
In[8]:= Take[orbit[2.9,0.1, 300 ], -8]
Out[8]= {0.655172, 0.655172, 0.655172,0.655172,
0.655172,0.655172, 0.655172,0.655172}
To plot the orbit, you can define a user-defined procedure that applies List Plot to
the iteration points. Adding some additional options, the user-defined function is
In [9]:= orbitplot [fi_, start., n_ , Opts—] : =
ListPlot [NestList [ \i# A - #) &, start , n ] ,
Qpts ,
PlotStylo -» {AbsolutoPointSizo [4] ,
RGBColor[l, 0, 0]},
GridLinos- >Automatic,
Epilog -»
ListPlot [NestList [^# A - #) &, start,
n],
PlotJoined -»True ,
Display-Function -» Identity
262
Chapter 5 Discrete Dynamical Systems
Applying orbitplot to this example, it follows
In [10]:= orbitplot [2.9 , 0.1, 50,
AxesLabel -> {n, xL } ];
0.7
0.6&
0.6&
0.64
0.62-
50
The graph illustrates how the orbit converges to the attracting fixed point at 0.655. This
graph is very similar to a damped oscillator where the amplitude of the oscillations goes to
zero.
b. To show a period two orbit, let the starting point be x0=0.1 and set fi=3.4. The
graphic for the first 50 iterations is
In[ll] := list = orbitplot [3.4, 0.1, 50,
PlotRango -» {Automatic, {0, 1}},
AxesLabel -> {n, xL}];
20
30
40
SO
The asymptotic points appear to be oscillating between two values. To locate the values,
consider the first 200 iterations and drop all but the last 8 iterations:
ln[12]:= eql= Take[orbit[3.4,0.1, 200 ] , -8]
Out[12]= {0.451963, 0.842154,0.451963, 0.842154,
0.451963, 0.842154,0.451963,0.842154}
The period two orbit oscillates between 0.84 and 0.45. An alternate way of extracting
just these two values is to apply Union to this list,
5.2 Logistic Map 263
In [13] ;= Onion [eql,
SameTest -> (Abs [ ( #2 - #1) ] < 10-12&) ]
Out[13]= {0.451963,0.842154}
A period four orbit follows from choosing a starting point at x0=0.1 and setting
fi=3.54. The orbit plot for the first 50 iterations is
In[14]:= list = orbitplot[3.54,0.1, 50,
PlotRange -» {Automatic, {0, 1}} ,
AxesLabel -» {n, xi}];
10 20 30 40
The asymptotic points appear to be oscillating between four values. If you consider the
first 200 iterations and drop all but the last 8 iterations then the four limiting values follow
from
In[15]:= eq2 = Take[orbit[3.54,0.1, 200 ], -8]
Out[15]= {0.521835,0.883312,0.364874,0.820363,
0.521682, 0.883336, 0.36481,0.820302}
This period four orbit oscillates between the four points,
In [16]:= Onion [eq2,
SameTest -> (Abs [ (#2 - #1) ] < 10~4&] ]
Out[16]= {0.36481, 0.521682, 0.521835, 0.820302,0.883312}
To illustrate a period eight orbit let the starting point be x0=0.1 and set fi=3.55. The
orbit plot for the first 50 iterations is
In[17]: = list = orbitplot[3.55,0.1, 50,
PlotRange -» {Automatic, {0, 1}},
AxesLabel -» {n, xi}];
264
Chapter 5 Discrete Dynamical Systems
20
30
40
50
The asymptotic points appear to be oscillating between eight values. If you consider
the first 1000 iterations and drop all but the last 16 iterations, you get the pattern for the
limiting values
In[18]:= eq3 = Take[orbit [3.55, 0.1, 1000 ], -16]
Out[18]= {0.540475, 0.881684,0.370326,0.827805,
0.506031,0.887371,0.3548,0.812656,
0.540475, 0.881684, 0.370326, 0.827805,
0.506031,0.887371,0.3548,0.812656}
The orbit oscillates between the eight points:
In [19]:= Union [eq3,
SameTost -> [ Abs [ (#2 - #1) ] < lCT12*) ]
Out[19]= {0.3548,0.370326,0.506031, 0.540475,
0.812656,0.827805,0.881684,0.887371}
An additional increase in fi eventually leads to chaotic orbits. Let the starting point be
x0=0.1 and set fi=3.7. The orbit plot for the first 200 iterations is
In[20] : = list = orbitplot [3 .7, 0.1, 200,
PlotRange -> {Automatic, {0, 1}}] ;
100 ISO
200
There doesn't appear to be any repeatable order to the points.
5.2 Logistic Map 265
PROBLEM 2 Logistic Fixed Points. Fixed points are like equilibrium points in phase
space; if the system starts at that point it will remain there. If the map starts at a fixed point
the map does nothing. For example, if xO satisfies the equation f [xO,/j] =xO, where f is
the logistic map, then xO is a fixed point of period one. A period n point is a point xO that
after n iterations the map comes back to xO. For example, a period two fixed point satisfies
the equation f[f[xO,/j],/j] =xO. The general periodic point satisfies an equation of the
formf [f [...?[xO] ...]] = xO.
a. Find all period one and period two fixed points for a general fi. Define a procedure to
return the nth fixed point if the value fi is given. Set fi=7/2 and find the fixed points
for periods 1 through 4.
b. There is a graphic way to determine the solution of the fixed point equation x=
f [ f [... [x] ...]]. If you plot the left and right sides of this equation, then the
fixed point is determined by the intersection of the curves. Graph the period one
fixed points for /*=7 12. Define a user-defined function for period n fixed points. Let
li=l 12 and illustrate the period 1 through 4 fixed points.
c. To see how the fixed points change as fi changes, graph the period two fixed points
for fi=2.5,3, and 3.5.
Solution
In[21]: = Clear["Global•*"]
a. The period one fixed point satisfies the equation f [x] =x, where f is the logistic
map. Since the map is given by fi x(l-x) the equation for the period one fixed point
becomes
In[22]:= period[1] =
fixO(l-xO) ==xO//Solve [#,xO]& //
Flatten
Out[22]= (xO^O, xO^ ^^}
There are two fixed points, one at 0 and the other atiL^-. The fixed point at the origin is
repulsive because points near the origin always tend away from it. The fixed point at i~
is an attracting point because starting points near this value converge to this fixed point.
Period two fixed points follow from applying the map f [ f [xO ] ] =xO twice:
In[23]:= Nest [ f*# A - #)&, xO, 2 ] == xO
Out[23]= A -xO) xOfJ2 A - A -xO) xOfj) == xO
The solution for the period two fixed point is
266 Chapter 5 Discrete Dynamical Systems
In[24]:= eql=
Nest [ v# A - #) &, xO, 2 ] == xO//
Solve [#, xO]& //FullSimplify
Flatten
r u -1
Out[24]= 4x0->0,x0-> , xO
I- u
-1 fj-V(fJ-3) (fJ + 1) +1
xO -»
-3) (ju + 1) +1
iiLli}
Note the solution for the period two points contains period one fixed points.The true
period n points are points that are not periodic for any smaller value of n.The true period
two points are
ln[25]:= period[2] = Complement [eql, period[1] ]
Out [25]= (xO ¦
rQ _^
¦xO-
li-~fi
ii + V
>
:^-3) (^
2fi
(AJ -3) (,
+ 1) -.
j + 1)
- 1
+ 1
Let us construct a numerical function that returns the solutions for the general fixed
point equation ?[?[...?[x]...]] =x. The user-defined function is
In[26] := f ixedpoint [f*_, n_, opts ] r =
Module [ {tempi, xO },
tempi = Nest [ n# A - #) &, xO, n ] == xO//
NSolvo[#, xo, opts]& ;
Select [xO/.templ, Abs[lm[#]] <10~10&]
where n is the period of the fixed point. Select was applied to eliminate the complex solu-
solutions.
The period 1 through 4 fixed points for/*=7/2 are
In[27]:= {ptl, pt2, pt3, pt4} = fixedpoint [7/2, #] &/8Range [4]//Rationalize;
{ptl, pt2, pt3, pt4}//ColumnForm
In - - -\
Out[27]= 1 ' 7' 7' 7-1
{0, 0.38282, 0.428571, 0.500884, 0.714286, 0.826941, 0.857143, 0.874997}
The period one fixed points are at {0, f}. Eliminating the lower period, you see that the
true period two points are {|, |}:
5.2 Logistic Map
267
In [28] : = Complement \ pt2 , ptl ,
SameTest -> (Abs [ ( #2 - #1) ] < 10~3&]
Out[28]= {-, -}
There are no period three points, but the period four points are:
In [29] : = Complement [pt4, pt2 ,
SameTest -> (Abs [ ( #2 - #1) ] < 10~4&] ]
Out[29]- {0.38282, 0.500884, 0.826941, 0.874997}
b. There is a graphic way to solve the fixed point equations x=f [ f [... [x] ...]].
If you plot the left and right sides of x=f [f [ • •. [x] ...]], then the fixed points are
determined by the intersection of the curves. Let fi=7/2 and find the graph for the period
one fixed points. The period one equation is x=|x A-x). If you combine the graph of
the right side of this equation with the graph for a straight line x, then you get
In[30]:= Plot [ {7/2#A-#)&[*] , x) , [x, 0, 1},
PlotStylo -» {Thickness [0 .01] ,
RGBColor[l, 0, 0]},
GridLinos -» Automatic,
Epilog-* {PointSize[0.04],Hue[0.3],
Hap[Point,
Transpose[{fixedpoint[7/2,1],
fixedpoint [7/2,1]}]]}
/
0
/
2 0
//
4 0
X
6 0
\
\
8 :
The intersections give the two period one fixed points.
A function that graphically solves for the period n fixed point is
268
Chapter 5 Discrete Dynamical Systems
In[31]:= fixedpointG[f*_, n_, Qpts—] : =
Plot [ {x. Nest [ \i # A - #) &, x, n ] } //
Evaluate, {x, 0,1},
Qpts,
Plotstyle ->
{{Thickness[0.01], Hue[Random[]]},
{Huo[Random[]]}},
DisplayFunction->Identity ,
Epilog-» {PointSize[0.04],Hue[0.3],
Hap [Point,
Transpose [ { f ixedpoint \\i, n] ,
fixedpoint[n, n] } ] ]}
]
Consider the fixed points for periods one through four. The graphic solutions for periods
one, two, three, and four follow from
In[32]:= list =
fixedpointG[7/2, # , PlotLabel -> #]& /»
Range [4, 1,-1] ;
Displaying the results with GraphicsArray, you get
In[33]:= Show[GraphicsArray[Partition[list, 2] ] ];
0.2 0.40.60.8 1
0.2 0.4 0.6 0.8 1
The intersection of the straight line and curves give the fixed points. The graph at the
top left starts with the fixed point 4 solutions followed to the right by fixed point 3. The
bottom left is for fixed point 2 and fixed point 1 is the right graph. Superimposing all the
graphs illustrate how the lower period fixed points also occur in the solutions for the higher
periods.
In[34] := Show[ list , Display-Function ->
$DisplayFunction];
5.2 Logistic Map
269
0.2 0.4 0
c. One can see period two points being "born" by watching the graph for f [f [x] ]
change as the parameter fi passes through 3. Consider the fixed point graphics for fi=2.5,
3 and3.5:
In[35] := Iist2 = fixedpointG[#, 2,
Ticks -> {{0,1/2,1} , {0,1/2,1}},
PlotRange-> {{0,1}, {0,1}},
PlotLabel -> # ] & /» {2.5,3, 3.5} ;
Displaying the results, it follows
In [3 6] : = Show [ Graphic sArray [
{Iist2[[2]] ,
PlotRango -» All ] ;
2.5
1
1
2
r
/
3
\ x
1
\
\
\
\
]
3.5
The graph starts out at fi=2.5 with only period one fixed points. As fi increases to 3 the
center of the graph dips down and the ends increase in height until finally at /i=3.5 the
curve and straight line intersect at four locations, creating two period one fixed points and
two period two fixed points.
270 Chapter 5 Discrete Dynamical Systems
PROBLEM 3 Logistic Cobwebs. The logistic map has a visual equivalent for displaying
its orbit and fixed points. Draw a line from x on the x-axis to the function on the y-axis. Take
the y value and feed it back to the function and draw a horizontal line from {x, f [x] }
to the line y=x. This takes you to the point {f [x], f [x]}. The vertical line drawn from
that point to the function takes you to {f [x], f [f [x] ] }. If the process is continued,
then the lines form a pattern called cobwebs. If there are period n points, then the pattern
of cobwebs will repeat.
a. Define a user-defined function for the cobweb. Let fi =7/2 and start the iterations
at x= |, |, and \. These three starting points illustrate period 1, period 2, and period
4 fixed points.
b. Let fi=3.99 and plot its chaotic cobweb.
Solution
In[37] := Clear [-Global• * "]
a. Let xO be the starting point of the logistic map. Notice the coordinates for the lines de-
described in the problem form a pattern like {{x0,0}# {xO,f [xO] }, {f [xO] ,f [xO] },
{f [xO], f [f [xO] ]}, .. •}. To make a user-defined function, describe the pattern
with a list, partition the list, and then join the coordinates with a line. The user-defined
function is
In[38]:= cobweb[f_ , x0_, n_, opts ] '.=
Module [ {tempi, temp2, points, b ,x},
tempi [s-] := Nest[f [#] &, xO , s ];
temp2 =
{tempi [# ] . tempi [# ] . tempi [# ].
tempi [# + l]}&/8Range [1, n] ;
points =
{xO, 0,x0, f [xO], temp2 }//Flatten //
Partition[#,2]& ;
Plot[{x, f[x]}, {x, 0,1},
Epilog->{Hue[0.9], Line[points]},opts]
where f is the map. The cobweb starts at xO and then performs n iterations. The argument
opts means that you can add options to the cobweb.
Let/i =7/2 and start the map at x= 5/7. After 30 iterations the cobweb-diagram is
In[39]:= cobweb [7/2 # A-#)&, 5 /7, 30 ] ;
5.2 Logistic Map
271
0.2
0.4 0.6
Since x=5/7 is a period one fixed point, the iterations do not change the pattern. The
fixed points for period 2, and period 4 orbits are | and \. The graphics for these cobwebs
follow from
In[40]:= list =
cobweb[7/2 #(l-#)ft, #,10,
DisplayFunction ->Identity ] &/»
{3/7, 1/2};
Displaying the results, you get
In[41]:= Show[GraphicsArray[list ]];
1
0.8
0.6
0.4
0.2
0.20.40.60.8 1
0.2 0.4 0.6 0.8 1
These graphics single out the period 1, period 2.
b. As fi increases, the system eventually bounces about forever, but never repeats. For
example, consider the cobweb for /*=3.99:
In[42]:= cobweb[ 3.99 #(!-#)&, 1/2,150 ];
0.2 0.4 0.6 0.8
There does not appear to be any asymptotic pattern.
272 Chapter 5 Discrete Dynamical Systems
PROBLEM 4 Logistic Bifurcations. An elegant way to examine the behavior of the map
as ii changes is to make a bifurcation diagram. A bifurcation diagram plots fi on the hor-
horizontal axis and xn points on the vertical axis. Define a bifurcation diagram and plot the
results for the logistic map.
ln[43]:= Clear["Global* *"]
Solution
Consider a user-defined function that calculates an orbit with 100 points starting at the
initial point 0.62. Take the last 25 orbit points so that the transients have died away. The
command that does this is
In[44]: = Lvalues =
Compile[{^},
({H, #}&) /»
Drop[NestList[fi#(l-#)&, 0.62, 100],
75]];
The procedure has been compiled to make it faster. The bifurcation diagram follows
from generating a table of these values for different fi.
In[45]:= bifurcation[f*0_, m_, n_] : =
Flatten [Table [Lvalues [f*], {n,n0,nl, (jil -n0) /n}] , 1]
The starting value is fiO, the final value is //I, and n is the number of /^-divisions.
Let us apply bifurcation for n=400 and with/* in the interval {3, 3.99}:
In[46] := Spoints = bifurcation[3, 3.99, 400];
Plotting the points, it follows
In[47]:= ptl = ListPlot [Spoints ,
GridLinos -»Automatic,
PlotStylo ->
{Hue[0.9],&bsolutePointSize[1.4]},
Epilog-> {
Thickness[0.007],
Line[{{#,0},{#,l}}]& /9
{3.45, 3.54, 3.564 }}
5.2 Logistic Map
273
t
0.8-
3
¦—- .
2 3
MM
""""I
4
•*-
KM
61
3l6 3!8 4
We have added three vertical lines at fi ={3.45, 3.54, 3.564} to show the beginning
bifurcation points. The region beyond 3.57 has windows of periodic behavior interspersed
with the chaos.
PROBLEM 5 Logistic Lyapunov Exponent and Entropy. Let us quantify the chaos by
calculating the Lyapunov exponent and the entropy.
a. The expression for the Lyapunov exponent is given by the expression
n-\
1 " .
= lim - ) In
dx
Calculate and plot the Lyapunov exponent over a range of fi values from 3.5 to 4.
b. Calculate and graph the entropy, - ?"=1 PiloglpJ, where pi is probability for how
many times each of the fi-bins is hit by the map. Compare the entropy graph with the
Lyapunov graph.
Solution
In [48]:= Clear ["Global'*"]
a. Let us define a user-defined function for the Lyapunov exponent:
n-\
1 " .
A = lim - } In
The first step is to define the map
dx
In[49] := f[fi_] :=fi*#(l
Next take the Log of the absolute value of its derivative,
In[50]:=
The Lyapunov exponent for fi between 3.5 and 4 follows from the table of values
274
Chapter 5 Discrete Dynamical Systems
In[51]:= data = Table[
1/1000 LGder[^][
NostList [fi * # A - #) &, 0.1, 999]]/.
List-* Plus}, {n, 3.5, 4., 0.001}];
where the command List->Plus was used to sum the terms. Plotting the results, you
find
In[52]:= ptl • ListPlot[data,
PlotRange- > {-1 , 1},
PlotJoined- >True,
PlotStyle -> Thickness [0.001] ,
AxesLabel -> {\i, A}] ;
Slightly separated trajectories converge if A is negative. If A is positive then nearby tra-
trajectories diverge and the evolution is sensitive to initial conditions, and is therefore chaotic.
The sharp dips indicate positions of superstable orbits.
b. Let us calculate the entropy over the range 3.5 < fi < 4. The entropy follows from
- 2"=i Pi log[p,]. Define the entropy function
In[53]:= Entropy[p.List] :=-p.Log[p]
where p is the list of probabilities for how many times each of the /i-bins is hit by the map.
You must now calculate data for a range of fi values. First, construct a list of iterates for
the map starting at x0=0.1,
In [54]:= fdata[fi_] : =
Drop [NostList [^#(l-#)&, 0.1, 500], 400]
where the orbits had 500 values but only the last 100 points were kept to avoid the tran-
transients.
Now bin fi. This step requires the command BinCounts found in the add on package:
In[55].= Needs["Statistics'DataManipulation'"]
The BinCounts command does the following:
5.2 Logistic Map
275
In[56]:= ?BinCounts
BinCounts[{xl, x2, . ..}, {xmin, xmax, dx}] gives a list of the number of el-
elements in the data {xl, x2, •••} that lie in bins from xmin to xmax in steps
of dx. The bin boundaries are {xmin < x <= xmin + dx, ..., xmax - dx < x <=
xmax}. BinCounts[{{xl, yl}, {x2, y2}, ...}, {xmin, xmax, dx}, {ymin, ymax,
dy}] gives a two-dimensional array of bin counts for the bivariate data {{xl,
yl}, {x2, y2}, ...}. In general, BinCounts gives a p-dimensional array of
bin counts for p-variate data. More...
The probability for how many times each of the /i-bins is hit by the map follows from
In 157]:=
Select[
1/500 BinCounts [ f data [fi] ,
{0., 1, 1/500}] ,Positive]
where the bin width is -^. The Select command was used to eliminate the BinCounts
that were zero. The entropy data follows from
In[58]:= entropylist = Table[{n. Entropy[prob[fi]] },
{H, 3.5, 4, 0.005}];
You get the entropy plot by applying ListPlot to entropylist,
In[59]:= pt2 =ListPlot[entropylist.
Plot Joined -»True,
GridLines -»Automatic,
PlotStyle -> Thickness [0.005],
AxesLabel -> {\i, "Entropy"}] ;
Entropy
/
/
J
1
6 3
7
3
8
3
9
The dip in entropy occurs at values of fi where the bifurcation diagram has windows.
The entropy is largest in the chaotic region where trajectories lose information about their
previous history.
To compare the entropy and Lyapunov exponent diagrams, you superimpose the previ-
previous plots ptl and pt2:
276
Chapter 5 Discrete Dynamical Systems
In[60]:= Show[ptl,pt2,
PlotRange-» {{3.5, 3.9}, {-1.5, 1.5}},
Ticks -> {Automatic, None}];
The top curve is the entropy and the bottom is the Lyapunov exponent diagram.
5.3 ¦ OTHER MAPS
5.3.1 ¦ Overview
In this section we consider four well-known maps: Salmon, sine-circle, Taylor-Greene-
Chirikov, and the Henon maps. The first map is a generalization of the logistic map and is
denned by the iterations
Since this map has been used to describe the development of a salmon population, it is
called the salmon map.
The one dimensional sine-circle map is denned by
where the angular coordinate 0 is limited to the range of 0 ^ 6 < 1. The boundaries at 0
and 1 are assumed to be periodic. This map with its Sin[27r0n_1] term is reminiscent of the
pendulum equation. A similar periodic boundary condition was applied to the motion of a
pendulum because the physical range of its angle was between {—n, n}. The properties of
the sine-circle map are parameterized with two constants {Cl, K} in contrast to the single
parameter fi for the logistic and salmon maps. The value of K gives the strength of the
nonlinear term. Each orbit has a winding number
where /"[0O] is the sine-circle map without its periodic boundary conditions. The winding
number is like counting the number of times a pendulum loops over the top.
5.3 Other Maps 277
The Taylor-Greene-Chirikov and the Henon maps are two-dimensional maps. The two-
dimensional Taylor-Greene-Chirikov map is a generalization of the sine-circle map and is
denned by the iterations
0»+i=0» + *»+*sfr[<y & iB+1 =in + k sin[0J
where 6 and i have periodic boundary conditions over the interval 0 to 7m. Finally, the two-
dimensional Henon map is one of the icons of chaos theory, and no treatment of dynamical
systems is complete without it. The two-dimensional Henon map is defined by
yn & yn+l=bxn
PROBLEM 1 Salmon Map. Consider the salmon map xn+l = xn exp[//(l - xn)~\.
a. Plot orbits for // = 1.8, // = 2.2, // = 2.6, and // = 2.99 and describe the results.
b. Plot its bifurcation diagram.
c. Plot the Lyapunov exponent and compare it to the bifurcation diagram.
d. Illustrate the structure in chaos by comparing two series, one white noise (random
numbers taken from a normal distribution with mean 1 and standard deviation 0.5)
and the other points taken from the salmon map with // = 2.9. Plot the return maps,
where the return map is a plot of the pairs, {xf xi+l}.
Solution
In[61]:= Clear [ "Global **"]
a. Define the salmon map.
ln[62]:= map[n-] := #Ejfp[n A - #) ]&
Let the starting points be x0=0.4 and consider the orbits for // = 1.8, // = 2.2, fi = 2.6,
and fi = 2.99. The user-defined function to graph the orbit is
In [63] := orbitG [n_, start., n_ , Qpts ] : =
ListPlot [NostList [map [fi ] , start , n ] ,
Qpts , Display-Function- > Identity]
Consider the values fi = 1.8,// = 2.2,// = 2.6, and// = 2.99:
In[64]:= values = {1.8,2.2 , 2.6,2.99};
The graphics for the four orbits follow from
In[65]:= list = orbitG[#,0.4, 50,
Plot Style->AbsolutePointSize [2] ,
Ticks -»False ,
PlotLabel -»#
] & /0 values ;
278
Chapter 5 Discrete Dynamical Systems
Displaying the results, you get
In[66]: = Show[Graph!csArray [
2
2.
.2
99
•• *
If fi is 1.8, there is one fixed point. The orbits with/* = 2.2 and/j = 2.6 show period 2
and period 4 orbits, respectively. The value of the fixed points follow from looking at the
last four points of the orbits. The points for/* = {1.8,2.2,2.6} are
In[67] := Take [NestList [map [#], 0.5 , 200 ], -
{1.8,2.2 , 2.6}//ColumnForm
Out[67]= {1.50294, 0.497059, 1.50294, 0.497059}
{1.90477, 0.181222,1.52317, 0.390846}
The orbit with/* = 2.99 is chaotic.
b. The bifurcation diagram allows you to see the change in the salmon map as fi varies.
Start by evaluating the orbit for 200 points and take the last 25:
In[68]:= Svalues = Compile^}, ({fi, #}&)/»
Drop [NestList [#Exp[^(l -#)]&, 0.5, 200] , 175] ];
The starting point was chosen at xO=0.5 and the procedure was compiled to make it faster.
The bifurcation diagram follows from generating a table of these values for different fi,
In[69] : = bifurcation[f*0_, /il_, n_] : =
Flatten [Table [Svalues [/i], {n,nO,nl, (f*l - n0) /n}], 1]
The starting value is fiO, the final value is //I, and n is the number /^-divisions. If you take
1000 values of fi from the interval A.9, 3.5) then you get the following list of points.
In[70]:= Spoints = bifurcation[1.9, 3.5,1000];
The bifurcation diagram follows from displaying the data points:
5.3 Other Maps
In[71] := ptl =ListPlot[Spoints,
GridLinos -» Automatic,
PlotStylo ->
{Hue[0.9] , AbsolutePointSize[0.5]} ] ,-
279
2.25 2 5 2.
c. Let us calculate the Lyapunov exponent to illustrate the sensitivity of the map to the
initial values. If you define the map and the Log of the absolute value of its derivative, then
you get two functions,
ln[72]:= f [fi-] :=# Eafptu A -#)]&;
fder[n_] := Log[Abs[ A - n #)
-#)]]]&
The values of the Lyapunov exponents follow from
In [ 73] := points [n0_] : =
Table[
ll*. Apply [Plus,
fder[fi ] [NestList[f [fi ], 0.1,nO -1]]/
nO]}, {fi,2 ,3.5, 1/nO}];
where nO is the number of points. The Lyapunov plot for 300 points follows from applying
ListPlot to points,
In[74]:= pt2 = ListPlot [points [300] ,
PlotJoined->True,
PlotStylo -» Thickness [0.006] ] ;
0.5
280
Chapter 5 Discrete Dynamical Systems
To compare the Lyapunov plot with the bifurcation diagram, superimpose the two dia-
diagrams
In[75]:= pt3 = Show[ptl, pt2] ;
d. To illustrate the structure in chaos compare a series of points taken from white noise
and a second series of points taken from the salmon map with fi = 2.9. The white noise is
determined by taking random values from a normal distribution with mean 1 and standard
deviation 0.5. To find the random numbers from a normal distribution, load the package
In[76] := Needs ["Statistics'NormalDistribution]
The command NoxmalDistribution is the relevant command:
In[77]:= ?NormalDistribution
NormalDistribution[mu, sigma] represents the normal (Gaussian) distribution
with mean mu and standard deviation sigma. More...
A table of 500 white noise random points follows from the table
In[78] := WNdata = Table[Random[NormalDistribution[l, 0.5] ] , 500] ;
Five hundred points for the salmon map with fi = 2.9 are given by
In[79] := chaos = Nest List [map [2.9] , 0.95, 500];
Displaying the two sets of values, you get
In [80] := Show[
GraphicsArray[
ListPlot[#,
Plotstyle ->AbsolutePointSize [2] ,
Ticks -> {{100, 300, 500}, {0, 1,2}},
DisplayFunction -» Identity
]& /& {WNdata, chaos}
5.3 Other Maps
281
100 300 500
It is not obvious that one has structure and the other does not. However, you can observe
a clear difference between these two sets of values if you plot the return map. The return
map is a plot of the pairs, {xt, xi+l}. The return maps for these two sets of points follows
from
:= Show[GraphicsArray[
ListPlot[Transpose[
{Drop[#1, -1] , Drop[#l, 1] }] ,
PlotRange-»All,
AxesOrigin -> {0, 0},
Plot Stylo -> AbsolutePointSize[2],
Display-Function ->Identity
]& /» {WNdata, chaos}
The points for the white noise in the left figure are concentrated around the point {1,1}
but don't display any other structure, while the chaotic values in the right figure lie on the
salmon curve.
PROBLEM 2 Sine-Circle Map. Consider the sine-circle map
where the angular coordinate 6 is restricted to the range 0 < 6 < 1. Periodic conditions at
the boundaries 0 and 1 are assumed.
a. Let {K = 0, ?1 = ^} and draw the cobwebs. Show that the orbit repeats after 7
iterations. In fact, the map for {K = 0, ?1 = |}, where p and q are integers, al-
always repeats after q iterations. Consider a second map with ?1 = Sqrt[2] and draw
its cobwebs. The value of ?1 is irrational and the orbit never repeats. The orbit
is said to be quasiperiodic. To conclude, set K = .9 and draw the cobwebs for
?1 = {0.04,0.61,0.65}.
282
Chapter 5 Discrete Dynamical Systems
b. Let ?1 = 0.5 and draw the bifurcation diagram as a function of K.
c. Set K = 1.2 and plot the winding number w = lim,,^ ^"tfl°]~flQ for a range of ?1
values and for 80 = 0.3.
Solution
In[82]:= Clear["Global'*"]
a. The user-defined function for the sine-circle map is
In[83]:= map[Q., K.] : =
tt + Q-K/B7T) Sin[2 7T#]), 1 ]&
where Mod is used to impose the periodic boundary condition. Thus, the mapping moves
the trajectory around the circle in steps of size ?1.
Consider cobwebs for two cases: {K=0, ?1=1/7} and the irrational value{K=0, ?1
= Sqrt [2]}. This problem requires the user-defined procedure cobweb derived in a
previous problem:
In[84] := cobweb[f-, x0_, n_, opts ] : =
Module[ {tempi, temp2,points, s,x},
tempi [s-] := Nest[f [#] &, xO, s];
temp2 =
{tempi [# ] , tempi [# ] , tempi [# ] ,
tempi [# +1] }&/8Range [1, n] ;
points =
{xO , 0 , xO , f [xO ] , temp2 } // Flatten //
Partition[#,2]& ;
Plot[{x, f[x]}, {x, 0,1},
Epilog->{Hue[0.9], Line[points]},opts]
The cobweb for the rational value of ?1 returns a periodic orbit:
In[85] := cobweb [map [1/7, 0], 1/10, 50] ;
0.2 0.4 0.6 0.8
5.3 Other Maps
283
The case with K=0 consists of simply adding the number ?1 to the previous angle value.
For ?1= 1 /7, you have a periodic orbit where the angle 6 repeats after 7 cycles. This periodic
behavior is verified by looking at the map. Only seven values follow from the Union of
400 iterations
In[86]:= Take [NestList [map [1/7, 0] , 1/10 , 400] ]//
Union
' J LlO 70 70 70 70 70 70 J
It is obvious that the orbit repeats after every 7 points.
Consider the irrational value ?1= Sqrt [ 2 ]. Its cobweb follows from
In[87]:= cobweb[map[Sqrt[2],0], 1/10 ,50 ] ;
1
0.8
0.6
0.4
0 .2.
si
H
—;
id
0
7
0 4
w
A
fl
0
8
1
The orbit never repeats for an irrational value Cl.
To see the affects of the nonlinear term K on the iterations, let K=0.9 and draw the
cobwebs for Cl = {0.04,0.61,0.65}. The graphics for all three cobwebs are
In[88]:= list =
cobweb[map[#, 0.9] ,0.45, 50,
Ticks -» {{0, 0.5, 1}, Automatic},
PlotLabel -»#,
Display-Function -» Identity
]& /8 {0.04, 0.61, 0.65} ;
Displaying the results, you find
In[89]:= Show[GraphicsArray[
{{list[[1]]}, list[[{2, 3}]]}]];
284
Chapter 5 Discrete Dynamical Systems
0.04
1
0.8
0.6
0.4
0.2
0.65
.5
D.5 ]
In the graph at the top left (O. = 0.04) there is a fixed point at 0.045:
In[90] .¦= Take [NostList [map [0.04, 0.9 ], 0.45 , 200],
-9]
Out[90]= {0.0450434,0.0450434, 0.0450434,0.0450434,0.0450434,
0.0450434, 0.0450434,0.0450434,0.0450434}
The bottom right (il = 0.65) repeats after 3 cycles:
In[91]:= Take[NestList[map[0.65, 0.9 ], 0.45, 200],
-9 ]//Onion
Out[91]= {0.414541,0.649123,0.99127}
The bottom left map (fl = 0.61) doesn't repeat and the trajectory eventually fills the
complete range of 8.
b. To see how the properties of the orbit change as K varies, consider its bifurcation
diagram. Set ?1 = 0.65 and let K vary from 0 to 6. To speed up the calculation define the
compiled sine-circle procedure
In[92]:= orbit =
Compile[{K},
Map[{K, #}&,
Drop [ NestList [
Mod[ ( # +0.65-K/Btt) Sin[27r#] ) ,
l]&,0.1,100], 75]
This map evaluates 100 orbit points but keeps only the last 25 values. The bifurcation
follows from
In[93]:= bifurcation[K0-, K1-, n_] : =
Flatten[Table[orbit[K],
{K, K0, Kl, (Kl - K0) /n}] , 1]
5.3 Other Maps 285
and its diagram is
In[94]:= ListPlot[bifurcation[0, 6, 800] , PlotStyle- >AbsolutePointSize[l.l] ];
Notice the beginning periodic behavior followed by chaotic behavior mixed with win-
windows of nonchaotic behavior.
c. Let us calculate the winding number = lim^^ ^"[ o]~ ". The user-defined function is
In [95]:= wind [ ?2., K. , 6-] : =
Module[{tempi },
tempi =
NostList[ ( #+ n-K/Btt) Sin[2 7T#] )&,
6,699];
A/600 ) ( Last [ tempi] - First [tempi])
If you let K=l. 2 and 0=0.3 then the winding numbers for different values of CL are
In[96] := ptl =
ListPlot[{#,wind[#, 1.2 ,0.3]}&/e
Rang©[0.25 , 0.75,0.008],
Plot Joined -»True,
PlotStyle -» {Thickness [0.006], Hue [0.6] } ,
GridLines -»Automatic ,
AspectRatio -> 1 ];
286
Chapter 5 Discrete Dynamical Systems
7
j
0
r
j
4 0
J
— 1
5 0
_J
r
6 0
r
J
7
The result is a monotonic increasing staircase. The level parts of the curve correspond
to frequency-locking plateaus, over which the winding number does not change for a sub-
substantial range of ?1. These plateaus are called the Devil's Staircase.
PROBLEM 3 Taylor-Greene-Chirikov Map. Consider the two-dimensional Taylor-
Greene-Chirikov map
*» = en-i + '«-i + * sin[0n_i] and in = in_x + k wa[0n-i\
where 6 and i have periodic boundary conditions over the interval from 0 to 2n.
a. Fix k=0.97 and plot the orbit in the plane {6, i} for several different starting
points. Randomly select the starting points {60, i0} restricted to the range 0 and 2n.
b. Fix k=0.97 and plot just the 8 values that follow from the map. Consider two ex-
examples, one with starting points {80, i0] = {3,1} and the other with starting points
{0.65, 3}.
c. Let {K = 0.47,8 = 0.2} and plot the winding number w = lim^^ /"[fl°]~fl° for a range
of i values.
Solution
In [97]:= Clear ["Global' * -]
a. Define the Taylor-Greene-Chirikov map with the user-defined function,
In [98]:= map[k_] [{6., i.}] =
{ Mod [6 + i + k Sin [6] , 2 7r] ,
Mod[i + k Sin[e],2 7T]};
5.3 Other Maps
287
where we have used Mod to return the orbit after the value of 2n. Let k=0.97 and imple-
implement the iterations with NestList:
In[99]:= orbit [60-, iO-] : =
NestList[map[0.97 ] , {60, iO},150]
The values {60, iO} are the starling points, the value of k is 0.97, and the number of
iterations is 150. The plot of the orbit as a function of {8, i} follows from
In[100]:= orbit6[60_, i0_. Opts—] : =
ListPlot [ orbit [ 60, iO ] ,
Opts , Frame -»True, Axes -»None,
FrameLabel -> {", "i"} ,
PlotStylo -> {Hue [Random [ ] ] ,
PointSize[0.009 ]} ,
Display-Function -» Identity
where {60, iO} are the starling values. You next want to plot {6, i} when the starting
points are randomly selected in the interval from 0 to 2n. Picking 60 random starting points,
the {6, i} graph follows (it takes several seconds),
:= Show[
orbitG[Random[Real, {0, 2tt}],
Random[Roal, {0, 2 tt}] ]&/8Rango[60 ],
DisplayFunction -» $DisplayFunction,
GridLines -»Automatic,
AspectRatio -»Automatic] ;
^
^*T^«»L_,vl
««»t; %». T«
12 3 4
e
The closed loops correspond to stable regions with fixed periodic points at their centers.
The hazy regions are unstable and chaotic.
288
Chapter 5 Discrete Dynamical Systems
b. To plot the orbit in the 0-n plane you must take just the 6 values from the orbit. The
user-defined function to take the 6 values is
In[102]:= Che[{60_, iO_}] := Map [First, orbit [60, iO] ]
Consider the two different starting points {60, iO} ={3,1} and {0.65, 3}. The graphics
for the last 40 orbit points are
In[103] := ptl = ListPlot[Tafce[Che[#],-40] ,
Plot Joined -»True,
AxesLabel -» { n, 6 },
Display-Function -» Identity
]& /» {{3, 0.1}, {0.65,3}} ;
Displaying the results, it follows
In[104]:= Show[GraphicsArray[{ptl } ] ] ;
e
6
5
4
3
2
1
2.9
10 20 30 40
The graph on the left is for the starting point {80, ±0} = {3,0.1} and the graph on the
right is for {0.65, 3}. Notice the variety of behaviors that follow from the map.
c. Let us graph the winding number. The user-defined winding function is denned as
the w = lim^^ /"[<^]~<?0, where the restriction of the map to the {0,2n] range has been
dropped. The user-defined function follows from
In[105]:= wind[ K. , 6-, i-] : =
Module[{mapl, orbit2, wind3, ea, pb},
mapl[{ea_, pb-}] : =
{ ea + pb + K Sin [ ea] , pb + K Sin [ ea] } ,•
orbit2 - Nest List [mapl, {6 , i }, 400 ] ;
wind3 = Map [First, orbit2] ;
A/400 ) ( Last [ wind3] - First [wind3])
If you let K=0.47 and 0=0.2 then a plot for different values of i follows from
In [106]:= ListPlot [{#, wind [ 0.45 ,0.2, #]}&/»
Rang©[0.15, 0.24, 0.005],
Plot Joined -» True,
PlotStyle-* {Thickness[0.005],
Hue[0.6]},
PlotLabel -> {"K= 0.47, 6 = 0.2"},
AxesLabel -> {i. None }];
5.3 Other Maps
289
{K=0.47,6=0.2}
which is similar to the Devil's Staircase in the circle map.
PROBLEM 4 Henon Map. Consider the two-dimensional Henon map xn+l = \-ax\
a. Plot the orbit in the{x,y} plane for {b=0.3, a=1.4} and with starting points
{x, y}= { 0, 0.1}. Enlarge a portion orbit to show more details.
b. Construct a bifurcation diagram for the Henon map by plotting the x-values of the
orbit (after allowing transients to die away) as a function of the control parameter a
andforb=0.3. Choose the starting point at {x,y}= {0.3, 0.6}.
Solution
In [107] := Clear ["Global* * "]
a. Define the Henon map
ln[108]:= map[a_,b-]
- ax2 + y,bx J
The orbit follows from applying NestList to the map. Let us plot the orbit in the {x, y}
plane for {b= 0.3, a=l.4} with starting points {x,y}={0, 0.1}. The plot for 20,000
points is
In [109] := ptl =
ListPlot[
NestList [map [1.4, 0.3], { 0,0.1},
20000 ],
PlotStylo ->AbsolutePointSize [2],
GridLinos -» Automatic ];
290
Chapter 5 Discrete Dynamical Systems
As smaller and smaller portions are enlarged the orbit shows more and more detail.
Magnifying a portion of the orbit, it follows
In[110]:= Show[ptl,
PlotRange-* {{0.3, 0.47}, {0.2, 0.217}},
GridLinos -» Automatic] ;
0.215
0.2125
0.21
0.2075
0.205
0.2025
p
\
\
••
JS
*.•
0.3250.350.375 0.4 0.4250.45
Further enlargement produces more structure.
b. Let us construct a bifurcation diagram for the x-component of the Henon map. Fix
b=0.3 and choose the starting point at {x,y}= {0.3, 0.6}. The user-defined function
that takes just the x-values of the map is
Infill] := Hx[a_] .- =
Hap[First,
Drop [ NostList [ map [a, 0.3 ] , {0.3, 0.6},
200],150] ]
The ^-bifurcation diagram follows from
In[112] := bifurcation[a0_,al-,n_] : =
Flatten[Table[Hx[a],
{a, a0,al, (al-aO)/n}], 1]
If you set xi=300 and let a vary from 1.05 to 1.1, then the bifurcation points are
In[113]:= pts = bifurcation [1.05, 1.1, 300 ] ;
5.4 Fractals
Displaying the results, you get
In[114]:= ListPlot [pts,
PlotStylo -> AbsolutePointSize [1.4] ,
AspoctRatio -» 1,
Ticks -»{{}, Automatic } ] ;
291
0.5
-0.5
Notice how some of the attractors abruptly appear and then disappear. This type of event
is called a crisis.
5.4 ¦ FRACTALS
5.4.1 ¦ Overview
Chaotic systems almost inevitably give rise to fractals. Fractal analysis is often useful in
describing the geometric structure of a chaotic system. They exhibit serf-similarity and
are independent of scale—if you concentrate on one portion of the fractal, the resulting
pattern is similar to the original. Nature abounds with serf-similarity, including coastlines,
clouds, lightning bolts, and snowflakes. In 1975 Benoit Mandelbrot coined the term fractal
to describe such irregular shapes. The essential feature of a fractal is the existence of a
similar structure at all length scales. That is, a fractal object has the property that a small
part resembles a larger part, which in turn resembles the whole object. Fractal images can
be obtained by iterating a function applied over and over to itself.
We consider just two examples of maps that have self-similar structure, the Mandelbrot
and Julia sets. The Mandelbrot set is constructed from the map zn+i = zj, + c, where c is a
point in the complex plane and the iterations start at z0 = 0. Each complex number c is in
the Mandelbrot set if its iteration remains finite. The Julia set is also constructed from the
map zn+i = Z2n + c, where c is a point in the complex plane. For the Julia set the c is fixed
292 Chapter 5 Discrete Dynamical Systems
but the starting value Zq is changed. The value of Zq is in the Julia set if its iteration remains
finite.
PROBLEM 1 Mandelbrot Set. Consider the map zn+i = z2n + c, where c is a point in the
complex plane and the starting point is z0 = 0. Each point c that remains finite is in the
Mandelbrot set.
a. Find the algorithm that for each c it checks if the orbit escapes. It is impossible to
apply the Mandelbrot process because you cannot iterate the map an infinite number
of times to see if the point goes to infinity. However, it can be shown that if the
distance of the point from the origin becomes greater than two, it will grow without
limit. As a result of this, if the absolute value of zn reaches the value of two before
the first 70 iterations, then we can stop the process and this value of c is not in the
set. Show that the value of c = ^ belongs to the set but c = 1 does not.
b. Assign a color according to the number of iterations performed on each value of c.
Plot the results using Plot 3D and DensityPlot. To observe the self-similar
structure magnify a portion of the set near the boundary.
Solution
In[115]:= Clear["Global'*-]
a. To find whether c is in the Mandelbrot set, you need only to check whether any point
of the iterations has absolute value larger than 2. Once this occurs, you are guaranteed that
the orbit escapes to infinity and the corresponding c does not belong to the Mandelbrot set.
The compiled algorithm for first 70 iterations of the orbit are
In[116] := MandO = Compile[{{c,-Complex}},
FixedPointList[#'2 + c&, 0, 69,
SameTest- > (Abs[#2] >2.&)]] ;
This procedure uses the command FixedPointList to generate the iterations of
the map. FixedPointList is like NestList but has the additional option of same
test. The FixedPointList function iterates the map 70 times or until the SameTest
criteria is satisfied. The value of c belongs to the set if all 70 iterates are returned. If this
is the case then the absolute value of the final iterate will be less than 2. If the points are
diverging the same test will stop the list before all 70 iterations are reached. The value of
c=l/10 belongs to the set since after 70 iterations its value is less than 2. The last iterate
has the value
In[117]:= Take [MandO [ 1/10 ],-1]//Chop
Out[117]= {0.112702}
The value of c=l does not belong to the set since
5.4 Fractals
293
In[118]:= MandO[ 1 ]//Chop
Out[118]= {0, 1., 2., 5. , 26.}
After just three iterations the value of the map is greater than 2.
b. We can assign a color to the map according to how many iterations are needed for the
absolute value of the map to become greater than 2. A small number of iterations means
that the point is rapidly going to infinity. On the other hand, if c belongs to the Mandelbrot
set, the distance from the origin will never become greater than two, no matter how many
iterations are done. The number of iterations follow from
In[119]:= Mandelbrot [c] := Length[MandO[c] ]
We now use Plot3D to display this result. Let c=x+ I y, where x is in the range
{-2,0.5} and y ranges from {-1.1,1.1}. The Mandelbrot graph is
In[120]:= Plot3D[Mandelbrot[x + I y] ,
{x,-2., 0.5}, {y,-1.1, 1.1},
Aspect Ratio- >Automatic,
ColorFunction->Hue,
PlotRange ->All ,
PlotPoints -> 100] i
.5
-2
-1.
-1
-0.5
-0.5
0.5
The points that have 70 iterations are in the set.
Another way to make a visual display follows from DensityPlot:
In[121] .- = DensityPlot [ Mandelbrot [x + Iy] ,
{x,-2,0.5}, {y,-1,1},
Mesh-> False,
AspectRatio- >Automatic,
Frame -»True,
ColorFunction- >Hue,
PlotPoints -> 100 ];
294
Chapter 5 Discrete Dynamical Systems
0.5
-0.5
-2 -1.5 -1 -0.5
0.5
The center of the image are all those complex numbers whose first 70 iterations lie
within a circle of radius two, centered at 0.
To observe the self-similar structure, magnify a portion of the set near the boundary:
In[122]:= DensityPlot[Mandelbrot[x + I y] ,
{x,-1.45,-1.25}, {y,-0.12,0.12} ,
Mesh- > False,
AspectRatio- >Automatic,
Frame -»True,
ColorFunction- >Hue,
PlotPoints -> 100];
0.1
0.05
0
-0.05
-0.1
-1.45 -1.4 -1.35 -1.3 -1.25
Notice how the pattern is repeated.
PROBLEM 2 Julia Set. The Mandelbrot set is the domain of convergence of the series
built up from the map zn+1 = z^+c, where c is a point in the complex plane and the iterations
start at zo= 0. If the iteration remains finite, then c is in the Mandelbrot set. When making
a Julia set we fix c but let the value of z$ change. If the points of the map for fixed c and
starting value z$ remain finite, then z0 is in the Julia set.
5.4 Fractals 295
a. Find the algorithm that for each z0 checks if the orbit escapes within the first 50
iterations. Letc = -1 and show that z0 = 0.1 is in the set but Zq = 1.9 is not.
b. Set c = -1 and use Plot3D and DensityPlot to display the set.
Solution
In[123]:= Clear ["Global* *"]
a. For a given c the following algorithm checks whether a point zO is in the complex
plane and the Julia set.
In[124]:= Juliao = Compile[{{zO,.Complex} },
FixedPointList[#'2 + c&, zO, 50,
SameTest- > (Abs[#2] >2.6)]] ;
If c=-l, then z0=l/10 belongs to the set
In[125] := c = -l;
Juliao[0.1]//Chop
Out[125]= [o.l, -0.99, -0.0199, -0.999604, -0.000791863,
-0.999999, -1.25409 xlO6, -1., 0, -1. , 0, -1.,
0, -1., 0, -1., 0, -1., 0, -1., 0, -1., 0, -1., 0,
-1. , 0, -1. , 0, -1., 0, -1., 0, -1. , 0, -1., 0, -1. ,
0, -1., 0, -1., 0, -1., 0, -1., 0, -1., 0, -1., o}
but zO=l. 9 does not belong to the set since Abs [x] is greater than two after the first
iteration.
In[126]:= Juliao[1.9 ]//Chop
Out [126]= {1.9}
b. To visualize the set, define the procedure
In [127] -•= Julia = Compile [{{zO, .Complex}},
Length[FixedPointList[#'2 + c&,zO,
50,SameTest- >(Abs[#2] > 2.&)]]];
If c=-l then the set is visualized with Plot3D
In[128] := c = -1;
Plot3D [Julia [x + I y] ,
{x, -2.,2},{y, -1,1},
AspectRatio- >Automatic,
ColorFunction- > Hue,
PlotPoints -» 100,
PlotRange -> All ];
296
Chapter 5 Discrete Dynamical Systems
-2
-1
Note that the Julia set need not be connected while the Mandelbrot set is.
The Dens ityP lot follows from
In[129] := DensityPlot [Julia[x + Iy] ,
{x,-2,2}, {y,-1,1},
Mesh- > False,
AspectRatio- >Automatic,
Frame -»True,
PlotPoints -> 100,
ColorFunction- > Hue] ;
-2
-1
5.5 ¦ EXERCISES
The solutions to many of these exercises can be found on our web site.
5.1 Gaussian Map
Consider the Gaussian map xn+l = Exp[-b x%\ + c. This map is characterized by two control
parameters, labeled b and c.
(a) Draw the cobwebs for b = 7.5, c = 0 and c = -0.5.
(b) Make a bifurcation diagram for b = 7/2 as a function of c.
5.5 Exercises 297
(c) Plot the Lyapunov exponent
X = lim - > In
dx
and the entropy.
5.2 Return Maps for the Henon Map
Consider the two-dimensional map xn+l = \-ax^+yn and yn+l = b xn. Illustrate the structure in
the chaos by making return maps. The return maps are plots of the pairs, (xt_n, xi+n). Do this for
a= 1.4, b = 0.3, starting point {0,0.1}, and n = 1,2, 3 and 4.
5.3 Cubic Maps
Explore the cobwebs, bifurcation diagrams, Lyapunov exponents, and entropies for the following
cubic maps:
Mapl: xn+l = ^n(l-xn) @<r<4)
Map 2: ^ = -^,A-**) @<r<4.5)
Map3: xn+l = xn{\ - 0 + p%) @<p<4)
5.4 Two-Dimensional Map
Explore the orbits, bifurcation diagram, Lyapunov exponent, and entropy for the following two-
dimensional controlled Logistic map: xn+l = r xn(l - xn) - b xn + yn and yn+l =bxn.
5.5 Tent Map
Explore the cobwebs, bifurcation diagram, Lyapunov exponent, and entropy for the following
Tent map:
Xn+l=2tXn fOT X^\
and
for x>\
where 0 < t < 1.
CHAPTER
6
Lagrangians and Hamiltonians
6.1 ¦ INTRODUCTION
Classical mechanics serves as the starting point for several branches of physics. This chap-
chapter illustrates the application of Mathematica to problems in advanced mechanics. We con-
consider problems solved with Lagrangians, Hamiltonians, and Hamilton-Jacobi equations.
Our approach to mechanics closely parallels the discussions found in the typical texts on
classical mechanics.
It is very convenient to express Newton's Laws of motion in terms of a scalar quantity
called the Lagrangian. The Lagrangian for a system described by n generalized coordinates
qt and q\ is L[q', q, t], where q't = ^. The generalized coordinates can be distances, angles,
or other quantities relating to the description of the motion. If the forces are conservative,
then they can be expressed in terms of a potential V. The Lagrangian becomes L = T - V,
where T is the kinetic energy and V is the potential. The equations of motion follow from
Lagrange's equations:
d I dL \ (dL\_
To describe systems with constraints the Lagrangian method can be generalized by
adding Lagrange multipliers to handle the constraints.
Another formulation of Newton's Laws follows from the Hamiltonian. The Hamiltonian
is defined in terms of the Lagrangian L[q', q, t~\ by
1=1
where pt are the generalized momentum and are related to the generalized coordinates by
Pi ~ dL[<dj'^ ¦ Eliminate the q\ variables in H and then express H in terms of the canonical
coordinates {q, p}, i.e., H[q, p, t\. The equations of motion follow from
, dH[q,p,t] dH[q,p,t]
The Hamilton-Jacobi technique seeks a transformation to a new set of canonical vari-
variables {#, p] -» {Q, P], where the new Hamiltonian is zero. These new canonical variables
{Q, P] will be constants, and the problem is reduced to solving algebraic equations.
298
6.2 Lagrangian Problems without Lagrange Multipliers 299
This chapter is divided into four problem sections: 6.2, Lagrangian problems without
Lagrange multipliers, 6.3, Lagrangian problems with Lagrange multipliers, 6.4, Hamilto-
nian problems, and 6.5, Hamilton-Jacobi problems. Exercises are included in section 6.6.
Before starting the problems you might find it convenient to turn off the spell checker:
In[l]:= Off[General :: spell];
Off[General : : spoil1];
6.2 ¦ LAGRANGIAN PROBLEMS WITHOUT LAGRANGE MULTIPLIERS
6.2.1 ¦ Overview
A system of n particles is described by at most 3n coordinates {xp ..., x3n}. Not all these
coordinates are independent; constraints may restrict them. These constraints are easiest
to handle when they are of the form f[xv ¦ ¦., x3n, t~\ = 0, in which case, they are called
holonomic. Constraints not expressible in this fashion are called nonholonomic. If there
are k holonomic constraints, then k of the 3n coordinates can be eliminated, leaving 3n-k
independent variables {qv ..., q^n_k] known as the generalized coordinates for the motion.
The transformation from the 3n coordinates x; to the 3n - k generalized coordinates q;
is represented by the transformation equations x; = x;[qv ...,qin_k,t]. The generalized
coordinates can be distances, angles, or other quantities relating to the description of the
motion. The number of generalized coordinates is the number of independent degrees of
freedom.
In terms of generalized coordinates qt, the equations of motion follow from the 3n - k
equations
dt\dqr) \dqj) ^
where T is the kinetic energy and Q- are the generalized forces. If Fj is the j-component
of the force, then the generalized force Q- is denned by
If some of the forces are conservative, then they can be expressed in terms of a potential
—» —*
V, where F = -VV. Expressing the conservative forces by a potential V and nonconser-
vative forces by the generalized forces Q;, the equations of motion follow from Lagrange's
equations:
The Lagrangian L = T - V describes the conservative forces.
300 Chapter 6 Lagrangians and Hamiltonians
All the problems in this section are for conservative forces so Lagrange's equation re-
reduce to the form
d_(dL\_(dL\
dt\dq/) [dqj)
6.2.2 ¦ Initialization for Lagrangian Problems
The Mathematica command to calculate these equation is EulerEquations, found in
the add-on package Calculus * VariationalMethods *. Before starting these prob-
problems load the add-on package
In[2]: = Needs["Calculus'VariationalMethods'"]
The EulerEquations command is
In[3]: = ?EulerEquations
EulerEquations[f, u[x], x] or EulerEquations[f, u[x,y,...], {x,y,...}] re-
returns the Euler-(Lagrange) equation obeyed by u[x] for the functional de-
defined by f. EulerEquations[f, {u[x,y,...],v[x,y,...], ...}, {x,y,...}] re-
returns a list of Euler equations obeyed by the functions {u[x,y,...], v[x,y,.
. . .}. More...
For example, consider the Lagrangian,
In[4]:= L = m/2 x'[t]~2 - k/2 x[t]~2
Out 14] = --kx[t]2 +-mx'[t]2
The equations of motion follow from
In[5] := EulerEquations [L, x[t] , t] //ExpandAll
Out 15] = -kx[t] -mx"[t] ==0
A command to compute the first integrals is also found in the add-on package. First inte-
integrals follows from the command Firstlntegrals:
In[6]:= ?FirstIntegrals
Firstlntegrals[f, u[x], x] or Firstlntegrals[f, {u[x],v[x],...}, x] returns
a list of first integrals corresponding to those coordinates u, v, ... of
the integrand f that are ignorable; when f is independent of x and depends
on the coordinates and their first derivatives only, the first integral cor-
corresponding to x is also returned. More...
You get the following first integral (conserved energy) for our example,
In[7] := Firstlntegrals [L,x[t], t]//ExpandAll
Out[7]= [Firstlntegral[t] ->-kx[t]2 + -mx'[t]2}
6.2 Lagrangian Problems without Lagrange Multipliers 301
PROBLEM 1 Particle Sliding on a Movable Incline. Consider a particle of mass m
sliding on a smooth inclined plane of mass M, that is itself free to slide on a smooth hori-
horizontal surface. The length of the incline is L0, the height is h, and the angle of the incline
{x,y}
M
x\
a. Write the Lagrangian and derive the equations of motion for the particle and incline.
b. Find two first integrals for the problem.
c Solve the equations of motion and calculate how long it takes the particle to reach
the bottom of the incline.
Solution
In[8]:= Clear["Global'* "]
a. Consider a particle of mass m sliding on a smooth inclined plane with mass M that
slides on a smooth horizontal surface. The length of the incline is L0, the height is h,
and the angle of the incline is 0. Let xl be the coordinate position to the bottom edge
of the incline. Let {x,y} be the Cartesian coordinates for the sliding particle, where x is
the horizontal coordinate and y is the vertical coordinate. The kinetic energy and potential
energy are
ln[9]:= T= ^M xl' [t]2 + i m (x' [t]2 +y' [t]2) ;
V = mgy[t];
The problem simplifies if we let one of the coordinates be the distance along the incline.
Call this coordinate s [t]. The particle's coordinates {x,y} are related to s [t] by
In[10]:= change =
{x-> ((xl[#] + (L0-s[#])Cos[e])&),
y-» (((L0-s[#]) Sin[e])&)};
where s=0 is at the top of the incline and s=L0 is at the bottom. Let the generalized
coordinates be xl and s. In terms of xl and s, the Lagrangian is
In [11]:= L = T-V/.change//Sljnplify
302 Chapter 6 Lagrangians and Hamiltonians
Out 111]= - (-2 gm (L0 - s[t] ) Sin[e] +Mxl' [t]2 +
m (s'[t]2 -2 Cos [9] s'[t] xl'[t] +xl'[t]2))
The equations of motion follow from EulerEquations:
In[12]:= eql = EulerEquations[L, {xl[t], s[t]}, t]
Out[12]= {m Cos[9] s" [t] - (m + M) xl"[t] ==0,
m (g Sin[S] -s"[t] + Cos[9] xl" [t] ) == 0}
that reduce to
In[13]:= eqMotion = Solve[eql, {xl" [t] , s" [t] }] //Flatten
gm Cos[9] Sin[9]
Out [13]= [xl"[t]
s"[t] -
-m -M + mCos [9] 2
g (m + M) Sin[9] i
-m-M + mCos[9]2 J
b. One first integral follows from the conserved horizontal momentum and the other
from the conservation of energy. Notice the total horizontal momentum,
In[14]:= xmomentum = Mxl'[t] + mx'[t]/.change//
Simplify
Out[14]= -m Cos [G] s'[t] + (m + M) xl' [t]
is a constant as is verified by taking its derivative and using the equations of motion
In[15]:= D[xmomentum,t]/.oqMotion//Simplify
Out [15]= 0
Likewise, the conserved energy is a second first integral,
In[16] := energy = T + V/.change//Sijm?lify
Out [16]= - B gm (L0-s[t] ) Sin [9] + Mxl'[t] 2 +
m (s' [t]2 -2 Cos [9] s' [t] xl' [t] + xl' [t]2) )
Again, verifying it is a constant by taking its derivative and using the equations of mo-
motion, you get
In[17] := D[energy, t]/.change/.eqMotion//
Simplify
Out [17]= 0
In a less physical manner, these same two first integrals also follow from the add-on
command Firstlntegrals:
In[18] := Firstlntegrals [L, {xl[t], s[t]}, t]
6.2 Lagrangian Problems without Lagrange Multipliers 303
Oat [18]= [ Firstlntegral [xl] -»
m Cos [9] s' [t] - (m + M) xl' [t] ,
Firstlntegral [t] -»
- BgL0mSin[e] -2gms[t] Sin[e] +
ms'[t]2 - 2m Cos [9] s' [t] xl' [t] +
mxl'[t]2 +Mxl'[t]2) J
c. The solutions for the particle's and incline's motion are trivial and follows from ap-
applying DSolve to eqMotion. If we start the motion at the top (s[0] = 0) of the incline with
zero speed, it follows
In[19]:= Sol=DSolve[
{ ( eqMotion/.Rule -> Equal) ,
s[0] ==0,s'[0] = =0,xl[0] ==0,
xl' [0] == 0}//Flatten, {xl [t] , s[t]},
t ]//Simplify //Flatten
gmt2 Sin[29]
Out [19]= |xl[t]
s[t]
-2 (m+ 2M) + 2m Cos[2 9] '
g (m + M) t2 Sin[S] i
-m-2M + m Cos [2 9] J
The particle reaches the bottom after a (squared) time of
In[20]:= (((s[t] /.Sol) == L0//Sinq?lify
//Solve [#/.t~2 ->x, x]&
)/.x-»t~2 //Flatten //
FullSimplify)
2L0 (M Csc[9] +m Sin[9] ) -i
Out[20]= [t2
g (m + M)
PROBLEM 2 Bead Sliding on a Rotating Wire. The upper end of a straight frictionless
wire is fixed at point A and the wire makes an angle t/f with the downward vertical drawn
from A. The wire rotates around the vertical axis with constant angular velocity to. A bead
of mass m is constrained to move on the wire.
a. Solve for the bead's motion assuming the initial conditions are r[0]= rO and
r'[0]= vO.
b. Let rO be zero at t=0 and find the time it takes for the bead to move a distance Len.
Evaluate the time for the special case \j/=0.
c. Let v0=0 and r0=0 at t=0 and graph the motion of the bead as a function of time.
Remarks and Outline Use spherical coordinates {r, 8,0} to express the position of the
bead. The variable r is the distance along the wire, 6 is the constant angle the wire makes
304
Chapter 6 Lagrangians and Hamiltonians
with the vertical, and 0 = o>t. Instead of 8, use the angle denned relative to the downward
vertical ft. There is only one generalized coordinate, r [ t ]. The equation for r [ t ] follows
from the add-on command EulerEquations. The equation of motion is solved with
DSolve.
Solution
In[21]:= Clear["Global'* "]
a. Assume a spherical coordinate system with the origin at the vertex of rotation A. Let
r be the distance to the bead from point A. Let 8 be the angular variable, where 8 is the
angle the wire makes with respect to the downward vertical. The Cartesian coordinates
{x,y, z} for the bead can be expressed in terms of {x,8,0}, where the <f> coordinate is
tut.
In[22] : = x2rRulo=
{x,y, z}-»{(r[#] Sin [6] Cos [*>#])&,
(r[#] Sin [e] Sin [&>#])&,
(r[#] Cos[©])&}//Thread;
The coordinates have been expressed in their pure form to enable substitutions in dif-
differential expressions. Instead of 8 use the angle denned relative to the downward vertical
In[23]:=
= 6 -> (tt -
Since ft is assumed to be fixed the only independent variable is r [t].
The kinetic and potential energies and the Lagrangian are
In[24]:= T = jn(x'[t]Jty'[t]!tz'[t]2)i
V = mgz[t] ;
L = T-V/.x2rRule/.^Rule//Sijnplify
6.2 Lagrangian Problems without Lagrange Multipliers 305
Out[24]= - m
Bg Cos[i/f] r[t] + w2 r [t] 2 Sin [i/r] 2 + r' [t] 2)
The equation for r [t] follows from the command EulerEquations:
In[25]:= eql= EulerEquations[L, r[t], t]
Out [25]= m (g Cos[i/r] + u2 r[t] Sin[i/r]2 - r" [t] ) ==0
Solve eql for r" [t]:
In [2 6] := rSol =
( Solve [eql, r" [t] ] [ [1, 1] ] //
ExpandAll) //.Rule -> Equal
Out[26]= r"[t] ==gCos[i/f] +<j2r[t] Sin[i/f]2
Assume the initial conditions are r [0] =0 and V [0] =v0 and apply DSolve to rSol.
Solving for r [t], you get:
In[27] := eq2 =
DSolve[ {rSol, r[0] == 0, r'[0] ==v0},
r[t],t][[l#l]] //Simplify //
PovrarExpand
This expression reduces to
In[28]:=
Di7f- F7R1
rRule =
eq2.
r[t] ->-
-t u
MapAt [ Collect [#, {Exp[-x_] }] &,
2]
g Cot [i/f] Csc[i/f]
vO Cs
w2
g Cot [i/f] Csc[i/f]
2 6J
.c[i/f]3 vO Cos [2 ill] Csc[i/f]3
4 U ibJ
Sin[*]
g Cot [i/f] Csc[i/f]
2(J2
vOCsc[i/f]3 vO Cos [2 ill] Csc[i/f]3
4 a>
b. The time it takes for the bead to go a distance Len follows from setting Len=r [t]
and solving for t,
306 Chapter 6 Lagrangians and Hamiltonians
In[29]:= tRulo=
( Solve[Lon == r[t]/.rRulo, t ,
InvorsoFunctions -» True] [ [2] ] //
Simplify
//PowerExpand
)
Out[29]= (t-» -(csc[i/f]
( - Log [2] -Log[g Cos[i/r] + vO u Sin[i/r] ] +
Log [2 g Cos[i/f] +
w B Lend) + V2~ VB vO2 + Len2 u2 + 4
g Len Cos [i/r] - Len2 w2 Cos [
2i/f]) Csc[i/f]) Sin[i/f]2
We want the time to be positive so we kept the positive solution. To find the time for the
special case of \j/=0, apply Series to tRule:
In[30] := Series[t/.tRule, {$, 0, 0} ] //Normal//
Simplify
-vO + V2 g Len + vO2
Oat 130] ¦*—=
g
This is the expected free-fall solution.
c. Plot the three-dimensional motion for the bead with the parameters:
In[31] := values = {$-* 7T/13, g-» 1, a -» 2, vO -» 0};
The position of the bead at time t is
In[32]:= position=
{x[t],y[t], z[t]}//.x2rRule//.rRule/.
.values;
Plot this in three dimensions with the output suppressed:
In[33] := pi = ParametricPlot3D [position //Evaluate,
{t, 0,6},
Boxed -»True,
Axes -»False,
BoxRatios -» {1, 1, 1},
DisplayFunction -» Identity];
To embellish this plot, we plot the positions at discrete time points using
6.2 Lagrangian Problems without Lagrange Multipliers
In[34]:= discretePoints=
Table[position, {t, 0, 6, 0.5}];
discrotoGraphics=
Graphics3D[{PointSizo[0.03],
Point/@discretePoints}];
Overlaying discreteGraphics with the original plot pi results in
307
In[35]:= Show[discrotoGraphics, pi,
BoxRatios -> {1, 1, 1}] ;
PROBLEM 3 Bead on a Rotating Hoop. A bead of mass mis constrained to move on a
hoop of radius r. The hoop rotates with constant angular velocity o> around a vertical axis
that coincides with the hoop's diameter. The only external force is gravity.
a. Construct the Lagrangian and derive the equations of motion. Also find the energy
and verify that it is conserved.
b. Define a potential for the system and find the equilibrium points. Show the charac-
characteristics of the potential change at o> = o>c, where cj2c = j and g is its acceleration
constant. Graph the potential for the two types of potentials.
c. Make a phase portrait for the motion.
d. Numerically solve for ft [t] and ft' [t] and plot the data, where ft is the azimuthal
angle measured relative to the downward vertical.
e. Animate the numerical results.
308
Chapter 6 Lagrangians and Hamiltonians
Remarks and Outline Choose spherical coordinates {r, 8, <p} with the origin at the cen-
center of the hoop. Let r be the radius of the hoop and <p be given by a> t. Change 8 to
the downward directed angle if/ = n - 8. The bead's motion is described by one inde-
independent variable ^[t] and the equations of motion follow from the add-on command
EulerEquations. The expression for the conserved energy follows from the expres-
expression for the Haxniltonian. An effective potential follows from the energy expression.
Solution
In[36]:= Clear["Global'*"]
a. Let the origin of the coordinates be at the center of the hoop and r be the radius of
the hoop. The coordinates of the bead are given by
In [3 7] : = x2rRulo =
{x,y, z} -> {(r Sin[6[#]] Cos [(»#])&,
(r Sin[6[#]] Sin[&>#])&,
(r Cos[6[#]])&}//Thread;
It is more convenient to measure the azimuthal angle 8 relative to the downward vertical
8= n - i/f.
In[38]:= tfrRule = {6 -> (tt- *[#]& ) };
The kinetic and potential energies follow from
6.2 Lagrangian Problems without Lagrange Multipliers 309
in [39]:= T =
^m (x'[t]2 ty'tt]2 + z'[t]2)//.x2rRule/.
tfrRule//Simplify
Out 139]= ^mr2 (u2 Sin [i/r [t] ] 2 + f [t] 2)
in[40] := V = mgz[t]//.x2rRule/.tfrRule//Sijm?lify
Out[40]= -gmr Cos[i/r[t] ]
and the Lagrangian is
In[41]:= L= (T-V)
Out[41]= gmr Cos[i/f[t] ] +
-mr2 (<j2Sin[i/f[t]]2+i/[t]2)
The equation of motion follows from applying EulerEquations to L
In[42] : = eql = EulerEquations [L, i^[t], t]
Out[42]= mr ( (-g + rw2 Cos[i/f[t] ] ) Sin[i/r[t] ]-
rtl/'[t]) ==0
and solving for if/" [t] :
In[43]:
(Solve [ eql, r' [ t ]]// Flatten) /.
[g -»&ic2 r|//ExpandAll
Out[43]= {i/f"[t] ^
-we2 Sin[i/r[t]] + u2 Cos[i/f[t]] Si
We have set ljc2 = *.
The energy of the system follows from H = if/ |p - L:
In[44]:= energy =
(lK[t] D[L, |^[t]] -L)/.{g-»(»c2 r]//
Simplify
Out[44]= -- mr2
B we2 Cos[i/f[t] ] +io2 Sin[i/f[t] ]2 -i/[t]2)
To verify that energy is conserved we take the derivative of energy and use i^Sol to
show its time derivative is zero:
In[45]:= D[energy, t] /.i/tSol/. {g -» uc~2 r} //
Simplify
310 Chapter 6 Lagrangians and Hamiltonians
Out[45]= 0
This same result is returned by the command Firstlntegrals
In[46]:= Firstlntegrals[L, tfr[t] , t] /.{g-» we2 r]//
Simplify
Out [46]= [ Firstlntegral [t] ->--mr2
B we2 Cos[i/f[t] ] + w2 Sin[i/r[t]]2 -i/[t]2)}
b. The terms independent of velocity in the expression for the energy give the effective
potential, Vef f:
ln[47]:= Veff = energy//. {# [t] -> 0}//EjfpandAll
Out[47]= -mr2 uc2 Cos[i/r[t] ] - -mr2w2 Sin[i/r[t] ]2
The equilibrium positions are determined by setting ^jif- to zero. The derivative of the
potential is
In[48] : = dVef f = D[Vef f , #[t] ]
Out[48]= mr2 uc2 Sin[i/r[t]]-
mr2w2 Cos[i/f[t] ] Sin[i/f[t]]
Setting the derivative to zero and solving for ft, it follows
ln[49]:= sol = Solve [dVeff ==O,tfr[t],
InvorsoFunctions -» True ]
r r r ojc2 11
Out[49]= {i/f[t] ^0}, i/f[t] ^-ArcCos \—r \,
If ^f is less than one, then there are three equilibrium positions: one at the bottom and
two along the sides. There is another equilibrium point at the top of the hoop ft = n so the
total number of equilibrium positions is four:
In[50]:= eqRule = Join[{{^[t] ->7r}},sol]
Out[50]= |{i/f[t] ->7t}, {i/f[t] ->0},
r r (oc2 11
i/f[t] ^-ArcCos —5- ,
Substitute eqRule into dVef f to verify they are solutions:
6.2 Lagrangian Problems without Lagrange Multipliers 311
In[51]:= dVeff == 0//.eqRule
Out[51]= {True, True, True, True}
Let us plot the potential as a function of ft and o>. Without the loss of generality, set
In[52] ;= valuosl = {r-» 1, we -> 1, m-> 1};
Let ^ range from -n to 7r and o> range from o>c to 3o>c. The plot of the potential is
In[53] .- = Plot3D[Vef f /.valuesl//Evaluate,
{*[t], -7T, 7T}, {41,1, 3},
ColorFunction -»Hue ,
Ticks-* {7r Range [-1, 1, 1/2] , Automatic,
Automatic }];
The potential has an unstable equilibrium position at the top of the hoop (ft = +n) and
another equilibrium position at the bottom of the hoop (ft = 0). The other two equilibrium
positions are stable but exist only if o>2 is greater than (x?c. Notice a bifurcation point occurs
ato>c = 1.
To plot the potential diagram for the two characteristic kinds of potentials we consider
two values for o>: o> = 0.2 (o> < o>c, slow spin) and o> = 2 (o> > o>c, fast spin). The potential
plots for these two cases are
In[54]:= Plot[
(Veff//.valuesl/.4)-»#)& /» {2,0.2}//
Evaluate,
{*[t], -7T, 7T},
Ticks -> {{ -7T , 0, 7r}, Automatic},
Epilog-> {
Hue[0.6] , AbsolutePointSize[6],
Hap[Point,
{^[t] ,Veff}/.eqRule/.valuesl/.
a ->2] }
312
Chapter 6 Lagrangians and Hamiltonians
The double-well potential corresponds to the fast spin and the single-well potential is
for slow spin. The dots mark the equilibrium points. For the fast spin case the equilibrium
points at the top and bottom are unstable positions. The two stable positions are to the right
and left of the bottom where the gravitational and centrifugal forces balance. For slow spin
the stable equilibrium position is at the bottom.
c. Making a phase portrait follows from the Mathematica command ContourPlot.
A ContourPlot of the energy plots the curves {ft [ t ], ft' [ t ]} for different values of
the energy. For the preceding two examples the phase portraits are
In[55]:= ptl=
ContourPlot[
energy/.valuesl/. {m-> 2, r-» 1 }/.
(&>-»#) //Evaluate,
{<Jr[t],-47T, 4 7r},{iK[t],-3, 3},
FrameTicks -» {n Range [-4, 4, 2] ,
Automatic},
ColorFunction -»Hue,
PlotPoints -> 100,
FrameLabel -> {-#", "tfr7"} ,
Display-Function -» Identity ]& /9
{2, 0.2 };
Displaying the graphs, it follows
In[56]:= Show[GraphicsArray[ ptl ] ] ;
-4 7T -2 7T 0 2 7T 4 7T
! & 19§f ir f|f f j|
2
1
. 0
-1
-2
-47T-2 7T 0 2 7T 47T
6.2 Lagrangian Problems without Lagrange Multipliers 313
The graph on the left is for the double-well potential with o> = 2 and the one on the
right is the single-well potential with o> = 0.2. The large values of ft correspond to repeated
motion around the top of the loop. If the initial energy is sufficiently large the bead will
continue to loop over the top and without dissipation will never come to rest.
The physical points repeat every 2n interval, so it is convenient to draw the energy
contours on a cylinder that repeat every 2n. The graphics for a cylinder are
In[57]:= cylind= ParametricPlot3D[
{v, Sin[u],Cos[u]},
{U, -7T, 7T}, {v, -3, 3},
DisplayFunction -> Identity ] ;
Combining the cylinder with the phase trajectories for the double-well, it follows
In[58]:= Show[cylind,
Graphics3D[
{AbsolutoThicknoss[3],
Cases[Graphics[ptl[[1]]],-Line,
oo]/.
{x_,y_} :>{y, 1.02 Cos[x],
1.02 Sin[x] }}
] ,
Viewpoints {1,1,1},
DisplayFunction -» $DisplayFunction];
where the curves were lifted slightly above the cylinder with the value of 1.02. The contours
that circle the cylinder have sufficient energy to go over the top of the hoop repeatedly. The
orbits that don't circle the cylinder are bounded by one or both the potential wells.
d. Solve ft numerically for the rapidly spinning loop. If we let
In[59] := values2 = {&>-»2
then the values of the equilibrium points are
314 Chapter 6 Lagrangians and Hamiltonians
In[60]:= oqRulo/.valuos2//N
Out[60]= {{i/f[t] -»3.14159},
-l.31812}, {i/f[t] -»1.31812}}
The equation for ft follows from ^Sol:
In[61]:= eql = <<rSol//.{g-» we2 r]/. Rule-» Equal
Out [61]= {i/f"[t] = =
-we2 Sin[i/f[t]] + w2 Cos[i/f[t]]
Instead of solving this second order equation, solve two equivalent first order equations:
In[62]:= eq2 =
Flatten
Out[62]= {di/f'[t] == -we2 Sin[i/f[t]] +
(j2 Cos[i/f[t]] Sin[i/f[t]], i/f'[t] ==di/f[t]}
Start the motion at the bottom of the well with 0[O]==1.318. For one example pick
the initial value for d^ [ 0 ] so that the motion is bounded by the well and another example
where the energy carries the bead around the loop. In particular, let dft [0] =1 and 2.5.
Applying NDSolve to eq2, you get
In[63]:= ndsoll=
NDSolve[{eq2//.values2, *[0] == 1.1318,
d*[0] ==#}//Flatten, {*[t]
{t, 0,10}] [[1]]& /& { 1,2.5}
Out[63]= {{i/f[t] ^
InterpolatingFunction[{{0.,10.}},
t] , di^[t] -» InterpolatingFunction [
{{0.,10.}},<>] [t]},
-> InterpolatingFunction [
{{0.,10.}},<>] [t],
InterpolatingFunction [
The top two solutions correspond to bound motion and the bottom two correspond to
unbound motion. If we define the functions,
ln[64]:= *[1] [t_] = *[t]/.ndsoll [ [1, 1] ] j
d#[l][t_] = d*[t] /.ndsoll [ [1, 2]] ;
*[2][t.]= *[t]/.ndsoll [ [2, 1]];
d*[2][t_] = d*[t] /.ndsoll [[2,2]] i
then the plots for 6x// and ft are
6.2 Lagrangian Problems without Lagrange Multipliers 315
In[65]: = pt2 =
Plot [ {d*[#] [t], *[#] [t] } //Evaluate,
{t, 0, 10},
PlotStylo-* {Dashing [{0.04} ],
AbsoluteThicfcness[2]},
Ticks -» { Automatic,
7T/2 Range [1, 12, 3] },
Display-Function -» Identity ] & /&
Range[ 2] ;
Displaying the results, it follows
In[66]:= Show[GraphicsArray[pt2]];
\ 9
2 4 6 8 10
The dark line is a plot of i/f and the dashed line is a plot of i/f'. The plot on the left is for
a small push and the one on the right is for a larger push. The particle with the small push
just oscillates around the bottom of the potential well while the energetic particle continues
to go over the top of the loop.
The phase trajectory for the motion follows from
In [67]:= pt3 =
ParametricPlot[
{ *[#] [t] , d*[#] [t] } //Evaluate,
{t, 0, 10},
Plotstyle -» AbsoluteThickness [2] ,
DisplayFunction -» Identity ] & /8
{1.2} ;
Combining the two phase trajectories with the phase portrait, we get
In[68]:= Show[ ptl [ [1] ] , pt3,
DisplayFunction -» $DisplayFunction];
316
Chapter 6 Lagrangians and Hamiltonians
-4 7T -2 7T n 2 7T 47T
-4 7T -2 7T 0 27T 4 7T
e. To animate the solution, construct the Graphics for the bead on the hoop at an
instant of time t:
In[69]:= bead[t_] : =
Graphics[{PointSizo[0.03],
[t]], Cos[#[l] [t]]}]}];
Generate a set of graphics with a Do loop. This can be animated to see the motion (all
but one frame is suppressed):
In[70] := frames = 1;
DO[
Show[
{bead[t],
Graphics[{Hue[0.1], Circle[{0,0}, 1]},
PlotRange-» {{-2, 2}, {-2, 2}},
AspectRatio -»1
{t, 0, 10, 10/(frames - 1) }]
The value of frames determines the nuift>er of frames displayed.
6.2 Lagrangian Problems without Lagrange Multipliers
317
PROBLEM 4 Springs Mounted on Top of a Carriage. A massless carriage runs along
rails pointed in the x-direction. The carriage is attached to one end of a spring with equi-
equilibrium length rO and force constant K. The other end is attached to a fixed point denoted
by A. Riding on top of the carriage is a beam pointing in the y-direction. Another spring is
attached to the top of the carriage and runs along the beam with its other end attached to
a particle of mass m. The whole system is forced to rotate with constant angular speed o>
around the point A in the {x, y) plane.
a. Express the Lagrangian in terms of coordinates fixed to the beam. Call these coordi-
coordinates {xb, yb}. The coordinate xb runs in the direction of the rails and yb is along
the beam. Find the equations of motion.
b. Let k=l, K=l, m=l, and rO=l and solve the equations of motion for an arbitrary
0). Plot the motion of the mass in the reference frames of the beam and in an inertial
reference frame for different values of o>.
c. Draw the phase trajectory {y, y'} in the body and inertial frames.
Solution
In[71] .- = Clear ["Global» * "]
a. Let the particle's position be {xi,yi}, where the Cartesian coordinates are denned
relative to an inertial reference frame with origin at A. The kinetic energy is
ln[72] := T = | m (xi' [t]2 + yi' [t]2) ;
Let {xb, yb} be coordinates fixed to the beam, where xb is in the direction of the rails
and yb is along the beam. The potential energy is
318 Chapter 6 Lagrangians and Hamiltonians
In[73] : = V = - K (-rO +xb[t]J + - kyb[t]2;
where rO is the length of the unstretched spring. Since the system is rotating around A the
two coordinate systems are related by a rotation matrix:
In[74]: = change = {
Cos[w#] -yb[#]
(((xb[#]) Sin[u#] +yb[#] Cos [a #])&)};
If we express all the quantities in terms of {xb,yb} then the Lagrangian becomes
In[75]:= L = T - V/.change//FullSimplify
Out[75]= - (-KrO2 + (-K + mW2) xb[t]2-
kyb[t]2 + 2 xb[t] (K rO + mwyb'[t] ) +
m ( (-w yb[t] +xb'[t] J +yb'[t]2) )
The equations of motion follow from
In[76]:= oqmotion =
EulerEquations [L, {xb [t] , yb [t] }, t]//
Solve[#, {xb"[t],yb"[t]}]&
Out[76]= |[xb"[t] -»
-KrO- (-K + mw2) xb[t] -2muyb'[t]
b,
m
2) yb[t] + 2mwxb'[t]
m J J
b. The two equations of motion have an analytic solution. To simplify the results set
In[77] := values = {K-» 1, k-» 1 ,m-» 1, rO -» 1}i
The equations of motion become
ln[78]:= {eql,eq2} =
(oqmotion [ [1] ] /.values/.Rules -» Equal)
Out[78]= {xb"[t] -> 1 + (-1 +u2) xb[t] +2 wyb'[t] ,
yb"[t] ^ (-1 +w2) yb[t] - 2 wxb'[t] }
These equations can be reduced to a single complex equation. Multiply the second equa-
equation by I and add it to the first equation
In[79]:= eq3 =xb"[t] +Iyb"[t] ==
(xb"[t] +Iyb"[t]/.eql/.eq2)
Out[79]= xb"[t] +iyb"[t] -= 1 + (-1 + u2) xb[t] +
i ( (-1 +w2) yb[t] - 2 wxb'[t] ) + 2 wyb'[t]
6.2 Lagrangian Problems without Lagrange Multipliers 319
Nowletxb+I yb-»u,
In[80]:= eq4=eq3/.xb-> ((u[#] -I yb [#])&)//
Simplify
Out [80]= u"[t] ==1+ (-1 + <j2) u[t] - 2 iwu'[t]
For aparticular set of initial conditions, xb[O]=l,xb' [O]=O,yb[O]=O, andyb' [0]=,
the solution is
:= uSol =u[t]/.
DSolve[{eq4, u[0] == 1, u'[0] == 0 } ,
u[t], t] [[!]]// ExpToTrig//
Simplify//Expand
(J2 Cos[t] Cos[t(J]
++
Out [81]=
j + 5 +
i (J3 Cos[t w] Sin[t]
-1 +u>2
i (j2 Cos[t] Sin[tw] w3 Sin[t] Sin[tw]
+
The real part of the solution is x:
In[82]:= xSol=
uSol/. Complex [a., b-] -» Complex [a, 0] //
Simplify
-1 + w2 Cos[t] Cos[tw] +w3 Sin[t] Sin[tw]
Out [82] = =
-1 + <iT
and the complex part is y:
In[83] := ySol = (uSol -xSol //Together) /.I -»1//
Simplify
r , , (J2 (w Cos [t w] Sin [t] - Cos [t] Sin [t w] )
Out[83]= =
-1 + <iT
Let us graph the motion for the following values of co,
In[84] := wvalues = {0.2, 0.4, 0.6, 0.8};
The motion relative to the beam's frame is
In[85] := listb =
ParametricPlot[
{xSol, ySol}/.&> -» # //Evaluate,
{t, 0, 100}, PlotPoints -» 100,
AspectRatio -»1,
AxesLabel -» {"xb", "yb"}.
Ticks -» False,
DisplayFunction -» Identity] & /<?
wvalues;
320
Chapter 6 Lagrangians and Hamiltonians
Displaying the results, it follows
In[86]: = Show[GraphicsArray[Partition[listb , 2] ] ];
xb
The motion in the inertial frame follows from
In[87]: = change
Out[87]= {xi^ (xb[#l] Cos[w#l] -yb[#l] Sin[w#l]&),
yi^ (xb[#l] Sin[w#l] +yb[#l] Cos [w #1]&) }
so the inertial coordinates {xi [t] ,yi [t]} are
In[88]:= eq2 =
{xi[t],yi[t]}/.change/.xb[t] -»xSol/.
yb[t] ->ysol //Simplify
f(J2 Cos[t] -Cos[t(j] (J3 Sin[t] -Si
UU11 aoj —
-1+u2
The graphics for the inertial motions are
In[89]:= listi =
ParametricPlot [eq2/.&> -»#//Evaluato,
{t, 0, 100},
AxesLabel -» {"xi", "yi"},
AspectRatio -»1,
Ticks -»False,
DisplayFunction -» Identity] &/0
wvalues ;
Displaying the results, we get
6.2 Lagrangian Problems without Lagrange Multipliers
In[90]:= Show[GraphicsArray[Partition[listi ,2]]];
321
c. Let us draw the phase trajectories {y, y'} in the body and inertial frames. The phase
trajectory in the body frame is
In[91]:= listpb =
ParametricPlot[
{ySol, D[ySol, t]} /.w-»#//Evaluate,
{t, 0,100},
AspectRatio ->1,
AxesLabel -> {"yb", - yb'"}.
Ticks -» False,
Display-Function -» Identity] & /8
wvalues;
In[92]:= Show[6raphicsArray[Partition[listpb , 2] ] ] ;
yb' yb'
yb
322
Chapter 6 Lagrangians and Hamiltonians
In the inertial frame, we get
In[93]:= listpi =
ParametricPlot[
{eq2[[2]],D[eq2[[2]],t]} /.(»-»#//
Evaluate, {t, 0, 100},
AspectRatio -»1,
AxesLabel-> {"yb", -yb'"}.
Ticks -»False,
DisplayFunction -» Identity] & /&
wvalues;
In[94]: = Show[GraphicsArray[Partition[listpi , 2] ] ];
yb' yb'
Yb
PROBLEM 5 Mass Falling through a Hole in a Table. Two mass points ml and m2 are
connected by a string of length 1 en passing through a hole in a smooth table. The mass ml
rests on the table's surface, and m2 hangs suspended and moves only along a vertical line.
Place the origin of the coordinate system at the hole and use polar coordinates {r, <p} to
describe the motion of mass ml. The distance from the hole to ml is r, and <p is its angular
position around the hole. Describe the hanging particle by the vertical distance from the
hole, z=len-r. The direction of the coordinate z is along the direction of the gravitational
force.
6.2 Lagrangian Problems without Lagrange Multipliers
323
ml
a. Show that the equations of motion for r[t] and0[t] can be expressed as
h ml .,„_ h
r"[t] = _
ml + ml (ml + m2)r[tf
b. Find the effective potential and analyze the motion.
c Numerically solve for the motion of the particle on the table and plot the results.
Solution
In[95]:= Clear["Global* *"]
a. Let us proceed by finding the Lagrangian. The kinetic and potential energies for the
particle on the table are
In[96]:= Tl = - ml (r'[t]2 + r [t]2 <t>' [t]2) ;
2
VI = 0;
The hanging particle is described by the coordinate z [t] =len-r [t]:
In[97] := zRulo = {z -> ((len - r [#])&)};
and its kinetic and potential energies are
In[98]:= T2 = - m2 z'[t]2/.zRule;
V2 = -m2gz[t]/.zRule;
The Lagrangian for the system is
In[99]:= L= (T1 + T2) - (V1+V2)
Out[99]= gm2 (len-r[t]) +-m2r'[t]2 +
iml (r'[t]2+r[t]20'[t]2)
324 Chapter 6 Lagrangians and Hamiltonians
and the equations of motion follow from EulerEquations:
In[100] := eql = EulerEquations [L, {r[t] , *[t] }, t]
Out[100]= {-gm2 + ml r[t] 0' [t]2 - (ml +m2) r" [t] == 0,
-mlr[t] Br'[t] 0'[t] +r[t] 0" [t] ) == 0}
Simplifying by solving for {<p'' [t] ,r" [t]}, it follows
In[101]:= eq2 = Solve [eql, {*" [t] , r" [t] }]//
Flatten;
eq2 //ColumnForm
g m2 - ml r [ t ] 0' [ t ] 2
Out[101]= r" [t]
-ml - m2
2r'[t] 0'[t]
r[t]
The first equation can be integrated once to give
In[102]:= Firstlntegrals[L, {r[t] , *[t] }, t]//
ColumnForm
FirstIntegral[0] -» -ml r [t] 2 0' [t]
Out[102]= Firstlntegral[t] ->
- (-2glenm2 + 2gm2 r[t] + (ml +m2) r'[t] 2 + ml r [t] 2 0'[t] 2)
The first term is the conservation of angular momentum and the second term is just the
conserved energy. The angular momentum First Integral gives the following rules
In[103] := eq* = IV [
, 0[t] > !:? }>
The constant h is a consequence of the conservation of angular momentum.
We can use eqc/> to eliminate the angular dependence from the radial equation
In[104]:= eqR = eq2 [ [1] ] /.eq*//Simplify //EatpandAll
Out[104]= r"[t] -»
h2ml gm2r[t]3
mlr[t]3 +m2 r[t]3 ml r [t] 3 + m2 r [t] 3
The equations of motion are
In[105]:= eqMotion= {eq*[ [1] ], eqR}/.Rule-»Equal//
Flatten;
eqHotion //ColumnForm
t2 h2ml gm2r[t]3
ml r[t]3 +m2r[t]3 ml r [t] 3+m2 r [t] 3
6.2 Lagrangian Problems without Lagrange Multipliers
b. To find the effective potential we define the total energy
In[106] : = energy = Tl + T2 + VI + V2/.eq0//Sinq?lify//
ExpandAll
h2ml
325
Out[106]= -glenm2
2r[t]'
gm2 r[t] + - ml r' [t]2 + - m2 r' [t]2
The effective potential is obtained by setting r' [t] to zero
In[107]:= Effpot =
(+g len m2 + energy) /.
{r'[t] -> 0,r[t] ->r}//Apart
h2 ml
Out [107]= j-+gm2r
where, without loss of generality, we have added a constant term. The potential has a
minimum at
In[108] := min = D [Effpot, r] == 0//Solve [#, r ]
Out[108] = {r^gl/3m2l/3j
To plot the potential consider the parameters
In[109] := values = {h-» 1, ml -» 1, m2 -» 1, g-» 1 };
The potential plot follows from
In[110] := Plot [Effpot/. values//Evaluate,
{r,0.2,3}];
5
4.5
4
3.5
3
2.5
2.5
1.5
The radial motion is bounded from above and below for h not zero.
Another way of visualizing the motion follows from plotting the energy contours:
326
Chapter 6 Lagrangians and Hamiltonians
Infill] .- = ContourPlot[ energy/.values/.len-> 10 //
Evaluate,
{r[t],0.2,6}, {r'[t],-l, 1},
ContourSbading -»True,
ColorFunction -» Hue ];
Again, it is obvious that the r-motion is bounded from above and below for h not zero,
c. Let us numerically solve for r and 0 with the parameters
In[112] := values » {h-» l#ml-» l#m3 -» 1, g-» 1}>
The numerical solution is
In[113]:= ndsol =
NDSolvo[
{ oqMotion/.values , 0[O] == 0,
r[0] == 2,r'[0] == 0}//Flatten,
{«[t],r[t]}# {t, 0, 70}][[l]] i
If we define the functions,
.ndsol;
rl[t_] = r[t]/.ndsol;
then the plot of the trajectory for the particle on the table follows from {r Cos [0],
i}
In[115]:= ParametricPlot[
rl[t] {Cos [4,1 [t]]# Sin [ 01 [t]]} //
Evaluate, {t, 0, 70},
AspectRatio -»Automatic,
Epilog -» {AbsoluteThickness [3] ,
Circle[{0,0},2],Circle[{0, 0},0.55]}
6.2 Lagrangian Problems without Lagrange Multipliers
327
The two dark circles show the upper and lower bounds for r. The particle rotates around
the table top confined within these two circles.
PROBLEM 6 Spring Pendulum. A spring pendulum has a mass m suspended by an elas-
elastic spring of stiffness k and force-free length LO. Assume the motion is confined to a plane.
a. Write the Lagrangian in polar coordinates {x,9} and show that the equations of
motion are
r"[t\ =
m
328 Chapter 6 Lagrangians and Hamiltonians
gsin[0[t]]
e"[t] = -c-
r[t] r[t]
b. Solve the equations when there is no angular motion and show the equilibrium length
of the spring is ID + sj-.
c. Find a numerical solution with initial conditions so the mass does not loop over the
top. Plot the coordinates {r, 9}, the position of the bob, and the phase trajectory.
d. Find a second numerical solution where the pendulum is given sufficient initial an-
angular motion to rotate over the top. Plot the coordinates, position of the bob, and
phase trajectory.
e. Animate one of the numerical solutions.
Solution
In[116]:= Clear["Global'*"]
a. Consider a bob of mass m attached to a spring with spring constant k. Assume the
motion is in a plane. Let {x,y} be the coordinates of the bob, where the origin is at
the support of the pendulum. Let the x coordinate point downward in the direction of
the gravity and y point to the right of x. The length of the pendulum is
:= lsrule = lst-> I -^x[#l]2 +y [#1]2&] ;
The kinetic and potential energies, expressed in Cartesian coordinates, are
In[118]:=T= ^ m (x' [t]2 +y' [t]2) ;
Vsp= |k(-L0
Vgr = -mgx[t];
where LO is the length of the spring with no load.
Express the elastic pendulum in polar coordinates {r,0}. The relations between the
Cartesian and polar coordinates are
In[119] := polarrule = {x-> ((r[#] Cos[6[#] ] )&) ,
Y-» ((r[#] Sin[6[#]])&) };
The Lagrangian is
In[120] .= L = T-Vsp-Vgr/.lsrule/.polarrule//
Simplify//PowerExpand
Out[120]= - Bgm Cos[9[t] ] r[t] +kL0 (-L0 + 2 r [t] ) +
mr'[t]2 + r[t]2 (-k + me'[t] 2 ) )
and the equations of motion follow from
6.2 Lagrangian Problems without Lagrange Multipliers 329
In[121]:= oqMotion=
(( EulerEquations [L, {r [t] , e [t] } , t]
//
(Solve[#, {r"[t],e
)/.Rulo -> Equal
//ExpandAll
oqMotion //ColumnForm
Out[121]= r"[t] == ^^ +g Cos[S[t] ] - kr[t] +r[t] e'[t]
m m
gSin[S[t]] 2r'[t]S'[t]
a [tj ==
2
r[t] r[t]
b. A special solution is vertical motion with no angular motion. The condition for no
angular motion is
In[122] := vertical = {6-» @&) };
The equations for this case are
In[123] .= vertMotion = eqMotion/.Rule -> Equal/,
vertical
Out[123]= (r" [t] ==g
The angular equation is automatically satisfied and the solution for the radial equation
becomes
In [124] := vertSol =
DSolve [vertMotion [[1]] , r[t],t]//
Flatten//ExpandAll
Out[124]= (^l
The bob oscillates with frequency J ^ around the length of the spring under the load:
In[125]:= vertSol/. C[l] -»0/.C[2] -> 0//Flatten//
ExpandAll
Out[125]= {^|
c. Let us find the numerical solution for the motion with the parameters
In[126] .= valuesc = {LO-» 40/9, n-» l#k-» 4, g-» 1,
m-» 1};
and the initial conditions
330
Chapter 6 Lagrangians and Hamiltonians
In[127]:= initialc =
{r[0] == (L0+ gm/k) +l,r'[0] == 0.1,
6[0] ==1/2 7T,e'[0] == 0.}/.valuesc;
The initial conditions have been chosen so the solution does not loop over the top.
The equations of motion and initial conditions become
In[128] := neqc =
{oqMotion, initialc}/.Rule -> Equal /.
valuesc//Flatten ;
and its numerical solution follows from
In[129]:= nSolc =
NDSolve[neqc, {r[t],e[t]}, {t, 0, 110},
HaxSteps -> 2000 ] //Flatten;
If we define the interpolating functions
In[130]:= rc[t_] =r[t]/.nSolc;
6c[t.] =6[t]/.nSolc;
then the plots for r [ t ] and 6 [ t ] follow from
:= Plot[{rc[t],6c[t] }//Evaluate,
{t, 0,110},
PlotStyle-* {Hue[0.7], Hue[0.9]} ,
Ticks -» {Automatic, n Range [-1, 2, 1 ] } ,
Epilog -»
Map [Line, {{0, #tt}, {125, #tt} }& /Q
Range [-1,2]]
2tt
The top curve is the variation of the radial coordinate and the bottom is the angular coor-
coordinate.
The graphics for the motion of the bob follow from
6.2 Lagrangian Problems without Lagrange Multipliers
In[132]:= ParametricPlot[
rc[t]{Sin[ec[t]], -Cos[6c[t]]}//
Evaluate, {t, 0, 110},
Plotstylo ->Hue [0.9],
AspectRatio -»1,
PlotRange-* {Automatic, {-8, 8}},
Epilog-> {Circle[{0, 0},#]&/8{6, 4,2} }
331
The phase trajectories, {r[t],r' [t]} and {0[t] ,6' [t]}, follow from
In[133]:= ptl=
ParametricPlot [ { # [ t ] , #' [ t ] } // Evaluate ,
{t, 0,110},
PlotStyle-» {Hue [0.7], Hue [0.9]},
Ticks -»False,
Display-Function -» Identity
]&/» {re, 6c};
Show[GraphicsArray[ptl]];
The graph on the left is for {r, r'} and the one on the right is {6, ff).
d. Let us find the numerical solution of the equations of motion for the parameters
In [13 4] := valuesd = {L0 -»5,n-»l,k-»2, g-»l,m-»l};
332 Chapter 6 Lagrangians and Hamiltonians
and the initial conditions
In[135]:= initiald =
{r[0] == (LO + gm/k + 0.01) , r' [0] == 0,
6[0] ==tt -0.07,e'[0] == 0}/.valuesd ;
The initial conditions have been chosen so the solution loops over the top.
The equations of motion and initial conditions become
In[136] := neqd =
{eqMotion, initiald}/.Rule -> Equal /.
valuesd//Flatten;
and the numerical solution is
In[137] := nSold =
NDSolve[neqd, {r[t],e[t]}, {t, 0, 110},
Haxsteps -> 2000]//Flatten;
We define the interpolating functions for r and 6:
In[138]:= rd[t_] = r[t] /.nSold;
0d[t_] =6[t]/.nSold;
The plots for the r[t] and0[t] follow from
In[139]:= Plot [ {rd[t] , ed[t] }//Evaluate,
{t, 0, 110},
PlotStyle-* {Hue[0.7],Hue[0.9]} ,
Ticks -> {Automatic, 7r Range [-5, 2, 1 ] } ,
Epilog -»
Map [Lino, {{0, #7r}, {125, #n} }& /&
Range[-5,2]]
v20 40 60 80 100
-7T
-2 7T
-37T
-4tt
-5tt
6.2 Lagrangian Problems without Lagrange Multipliers
333
The top curve is the variation of the radial coordinate and the bottom is the angular
coordinate. The level parts of the angular graph correspond to the times when the bob
loops over the top.
The graphics for the motion of the bob follow from
In[140]:= ParametricPlot[
rd[t]{Sin[ed[t]], -Cos[6d[t]]}//
Evaluate, {t, 0, 110},
PlotStylo -> Hue [0.9],
PlotRange ->All,
AspectRatio -»Automatic,
Epilog-> {Circle[{0,0},#]&/9{8, 6, 4}}
and the phase trajectories are
:= ptl =
ParametricPlot [ {# [t], #' [t] }//Evaluate,
{t, 0, 110},
PlotStylo-* {Hue[0.7],Hue[0.9]} ,
Ticks -»False,
DisplayFunction -»Identity
Show[GraphicsArray[ptl]];
334 Chapter 6 Lagrangians and Hamiltonians
e. To animate the motion define
In[142]:= line[t_] : =
Show[
Graphics[
{{Line[{{0, 0},
re[t]{Sin[ec[t]], - Cos[6c[t]]}}],
{PointSize[0.1],
Point[
rd[t]{Sin[ec[t]],
-Cos[ec[t]]}]}}},
PlotRange-> {{-10, 10}, {-13, 13}}
The motion follows from (all but two frames are suppressed)
In[143]:= frames = 2;
movie = line[#]&/» Range[0, 30, 30/( frames- 1)];
6.3 Lagrangian Problems with Lagrange Multipliers 335
6.3 ¦ LAGRANGIAN PROBLEMS WITH LAGRANGE MULTIPLIERS
6.3.1 ¦ Overview of Nonholonomic Constraints and Lagrange Multipliers
For nonholonomic systems, the coordinates qi are not independent of each other and it
is impossible to reduce them by means of constraint equations. However, if there are k
constraints of the form 'Zl^iAjkSqk = 0, where j = {1,..., k}, then Lagrange multipliers
can be used to describe the constraints. The equations of motion that follow from these
constraints are
dt[dq>) [dq.
where Q- = E*=1 ^Au- The ^ parameters Ax are called Lagrange multipliers. Lagrangian
equations give a coupled set of second order differential equations.
Throughout this chapter, you will need to compute Lagrange's equations of motion
with constraints. The user-defined function Lag[qi,L,Qi,t:t] will compute this in
one step in the case of one or more variables. Before starting these problems load the
user-defined function Lag [qi,L,Qi,t:t]:
In[144]:= Lag[qi_, L_, Qi_, t_ : t] : =
D[D[L, (D[qi[t],t])],t] -D[L,
Lag[qi_List, L , Qi List, t_ : t] :
(D[D[L, (D[qi[[#]][t],t])],t
)& /» Ranged, Length [qi]],•
==Qi;
==Qi[[#]]
This command computes Lagrange's equations of motion given the canonical coordi-
coordinate qi, the Lagrangian L, and the generalized force Qi. The generalized coordinate qi can
be entered as a list or as a single coordinate. Finally we apply Protect to the user-defined
procedure to kept it from being deleted with Clear [ "Globall * " ]:
In[145] := Protect [Lag] ;
xl
ml
x2
PROBLEM 1 Atwood Machine. An Atwood machine consists of two weights with
masses ml and m2 connected by a light, inextensible cord of length Len. The cord passes
over a frictionless pulley. Let xl be the coordinate of mass ml and let x2 be the coordinate
of mass m2. The coordinates xl and x2 are the vertical distances from the pulley to the
masses. Assume the masses move only in a vertical direction. Express the Lagrangian in
terms of xl and x2. Find the Lagrange multipliers from the constraint that the cord does
not stretch. Find the equations of motion for xl and x2 using Lagrange multipliers. Solve
for the motion.
Remarks and Outline The variables xl and x2 can be treated as independent and the
constraint Len=xl+x2 can be used to get a Lagrange multiplier. The user-defined func-
function Lag gives two equations. A third equation follows from Len=xl+x2.
336 Chapter 6 Lagrangians and Hamiltonians
Solution
In[146] : = Clear ["Global* * "]
Let us solve the Atwood problem using two independent variables and a Lagrange multi-
multiplier. The potential and kinetic energies are
In[147] := T= - Sum [m[i] x[i]'[t]2, {i, 1, 2}];
V= (-g) Su»[m[i]x[i][t], {i, 1, 2}];
The Lagrangian in terms ofx[l] andx[2] is
In[148]:= L = T-V
Out[148]= g (m[l] x[l] [t] +m[2] x[2] [t]) +
- (m[l]x[l]'[t]2+m[2]x[2]'[t]2)
where x [ 2 ] is treated as an independent variable. The constraint equation follows from
the fixed length of the string and is given by f [ 1]:
In[149]:= f [1] =x[l] [t] +x[2] [t] - Len;
The differential form of f [ 1] gives the constraint forces {Q[l],Q[2]}as expressed
in terms of the Lagrange multiplier A [ 1 ]:
In[150]:= Qeq = D[f[l],x[#][t]] A[l]&/9{1, 2}
Out[150]=
Two equations of motion follow from the user-defined command Lag:
In[151] := eq2 = Lag[{x[l] , x[2] }, L, Qeq]
Out[151]= {-gm[l] +m[l] x[l]"[t] == X[l],
-gm[2] +m[2] x[2]"[t] ==
where eq2 gives two equations for the three unknowns x[l], x[2], and A[l]. The
third equation follows from the f [1] ==0 constraint:
In[152] := f [1] == 0
Out[152]= -Len + x[l] [t] +x[2] [t] == 0
You get an equation more relevant to the calculation by taking the second derivative of
length,
In[153]:= eq3 = D[f [1] == 0, {t, 2}]
Out [153]= x[l]"[t] +x[2]"[t] ==0
6.3 Lagrangian Problems with Lagrange Multipliers 337
You get three equations by applying Solve to eq2 and eq3:
In [154] := eq4 =
((Solve[{eq2, eq3}//Flatten ,
t] //Simplify
//Flatten
)/. {Rule -> Equal}
);
eq4 //ColumnForm
2gm[l]m[2]
L J "
' L-J mrii+mr2i
r[t]==SM»y-»W)
These three equations are uncoupled and it is a trivial task to solve them.
Assuming the initial conditions
In[155] := initial = {x[l] [0] == xO, (x[l])'[0] ==v0};
the solution for x [ 1 ] follows from part three of eq4:
ln[156] := soil =
DSolve[{eq4[ [{3}] ], initial} //Flatten,
{ (x[l]) [t] }, t] //FullSimplify //
Flatten
Out[156]= [x[l] [t]
The solution for x [ 2 ] follows from the length constraint:
In[157] := sol2 = {x[2] [t] ->Len-x[l]
Out[157]= (x[2] [t] ->Len- tvO - xO - ¦
PROBLEM 2 Hoop Rolling on an Incline. Consider a hoop of radius r rolling down
a fixed incline without slipping. Let <p be the inclination angle of the incline. Specify the
position of the hoop by the distance x traveled by the center of mass along the incline and
let 8 be the rotation angle of the hoop. Let x=0 at the top of the incline and x=Len at the
bottom of the incline.
a. Express the Lagrangian in terms of x and 6. Write the slippage constraint and use
Lagrange multipliers to obtain the equations of motion for the variables x and 6.
b. Solve for x[t] and 0[t] and plot the motion of a fixed point on the hoop as the
hoop rolls down the incline.
Chapter 6 Lagrangians and Hamiltonians
x=Qr
Remarks and Outline The problem simplifies if the generalized coordinates are chosen
to be the center of mass along the incline x[t], and the motion about the center of mass
as described by the angular variable 6 [ t ]. The Lagrange multiplier follows from the con-
condition that there is no slippage, r &B- dx=O. The equations of motion follow from Lag
and they are solved with DSolve.
Solution
In[158]:= Clear ["Global'*"]
a. The kinetic energy can be resolved into the kinetic energy of the center of mass,
plus the rotational energy about the center of mass. Let x [t] be the position vector of the
center of mass and 0[t] be the angular variable around the center of mass. The kinetic
and potential energies and Lagrangian are
In[159] := T= -m(x'[t]2
V= mg (Len-x[t])
L = T-V
Out[159]= -gmSin[0] (Len-x[t]) +
im(x'[t]2+r2e'[t]2)
where Len is the length of the incline and 0 is the angle of slant. The no slippage constraint
is
In[160] := eql = r6[t] -x[t] == 0;
The derivatives of eql gives the constraint forces {Q[1],Q[2]} as expressed in terms
of the Lagrange multiplier A [ 1 ]:
In[161]:= constraintForce =
Q[2] -»
Out[161]= {Q[l] -» -A, Q[2] ->r A}
The constraintForce gives the expression for the generalized slippage force
{Q [ 1 ] / Q [ 2 ]}. The equations of motion follow from applying Lag to L
6.3 Lagrangian Problems with Lagrange Multipliers 339
ln[162] := {eqX, eqe} = Lag[{x, 6}, L, {Q[l] , Q[2] }] //.
constra intForce;
{eqX, eqd}//ColumnFonn
-gm Sin[0] +mx"[t] == -A
You now have two equations of motion and one constraint equation. These three equa-
equations can be solved for the three unknowns x, 9, and A.
b. Solve the equations of motion given the following initial conditions:
In[163]:= initial = {x[0] ==xO,x'[O] == vO,
6[0] ==xO/r, e'EO] ==vO/r};
Next, use DSolve to solve for x [ t ] and 8 [ t ]:
In [164]:= xtSol =
DSolve[{eqX,eq0,initial}//Flatten,
r 2mtvO + 2mxO - t2 A+ gmt2 Sin[0]
Out[164]= x[t] -» L J
e[t]
2m
2mtvO + 2mxO + t2 A-
2 mr
The expression for A follows from the slippage constraint in eql. Use xtSol to elim-
eliminate x[t] and#[t] in eql:
In[165]:= ASol = Solve[eql/.xtSol, A]
Out[165]" [[a^ igm Sin[0]}}
If we use ASol to eliminate A in xtSol then the expressions for x[t] and 0[t]
become
In[166]:= xtSol2 =xtSol/.ASol//ExpandAll//Flatten
r 1 ->
Out[166]= |x[t] -» tvO +xO + -gr Sin[0] ,
tvO xO g t2 Sin[0] i
r r 4r J
c. Let us plot the motion of a point on the hoop as the hoop rolls down the incline.
Consider the values:
In[167] := values = {xO -> 0, vO -» 0, g -» -0.1, 0-»7r/4,
r -> 2 .} ;
The x and y coordinates for a fixed point on the hoop are
In[168]:= posx= (x[t]Sin[0] + rSin[e[t] ]) ;
posy= (x[t]Cos[*] +rcos[6[t]]);
340
Chapter 6 Lagrangians and Hamiltonians
The point on the hoop is given by
In[169] := point = posx, posy/.xtSol2//.values;
This is easily displayed with ParaxnetricPlot:
In[l 70] : = ParametricPlot [point //Evaluate,
{t, 0, 70}, AspoctRatio -> 1 ] ;
-60 -50 -40 -30 -20 -10
-10
-20
-30
-40
-50
-60
PROBLEM 3 Sphere Rolling on a Fixed Sphere. A sphere of radius a and mass m rests
on top of a fixed sphere of radius b. The first sphere is slightly displaced so that it rolls
(without slipping) down the second sphere. Let the {z, x} plane be chosen to pass through
the centers of the two spheres and assume the motion is in the {z,x} plane. Choose a
spherical coordinate system at the center of the fixed sphere. Let r [t] be the radial vari-
variable as measured from the origin of the coordinates to the center of the moving sphere. Let
6X be the angular variable measured from the origin of the fixed sphere. The motion of the
r=a+b
6.3 Lagrangian Problems with Lagrange Multipliers 341
moving sphere's center of mass can be described by the variables {r [t] ,81 [t]}. The
motion of the moving sphere about its center mass can be described by the variables 6X [ t ]
and 02 [t] where 62 [t] is the angular measure relative to spherical coordinates centered
at the moving sphere's center of mass. Note 62 is measured from the contact point of the
two spheres.
a. Assume the generalized coordinates are {r[t] ,6X [t] ,82 [t]} and construct the
Lagrangian. Write the constraints that there is no slippage and that the spheres are in
contact. Use Lagrange multipliers to obtain the equations of motion.
b. Show that the equation 6X can be reduced to a first integral.
c. Find the angle at which the sphere falls off.
Remarks and Outline The total kinetic energy is the kinetic energy of the center of mass
plus the kinetic energy of the motion about the center of mass. There are two constraints:
a. the constraint of contact, r [t] =a+b, and
b. the constraint of no slippage, b01[t]-a02[t]=O.
These two constraints give the expression for the generalized constraint forces. The
equations of motion follow from Lag. The point at which the sphere falls off follows from
setting to zero the Lagrange multiplier associated with the contact constraint.
Solution
In[171]:= Clear["Global'*"]
a. The kinetic energy of the rolling sphere is the energy associated with the motion of
its center of mass plus the rotational energy about its center of mass. The kinetic energy of
the center of mass of the moving sphere is
ln[172]:= Tcm = ^ m (r'[t]2 + r [t]2 61'[t]2);
The rotational energy associated with the motion about the sphere's center of mass is
In[173] := Trot = - II F1' [t] + 62'[t]J;
where II is the moment of inertia of the sphere. The rotational energy is a function of the
sum @l[t~\ + 62[t~\), since the first variable is the contribution from the curved surface of the
fixed sphere and the second term is from the motion about the center of the moving sphere.
The total kinetic energy is
In [174] := T = Tcm + Trot ;
The potential energy (up to a constant) is
In[175]:= V=m g r[t]Cos[61 [t] ] ;
The Lagrangian is
342 Chapter 6 Lagrangians and Hamiltonians
In[176] := L = T-V
Out[176]= -gm Cos[91 [t] ] r[t] +
im(r'[t]2+r[t]2ei'[t]2)
in <ei'[t] +e2'[t]J
The two constraint equations are
In[177] .- = constraints = {b ei[t] -a 62 [t] == 0, r[t] -a-b== 0}
Out[177]= {b91[t] -a92[t] == 0, -a - b + r [t] ==0}
The first equation is the condition that there is no slippage. The second equation is the
contact condition and states that the distance between the centers of the two spheres is the
sum of their radii. The algebra simplifies if you express these equations in terms of pure
rules (we use DSolve to obtain this form):
In[178]:= constraintRule =
DSolve [constraints , {62, r}, t]
Out[178]= [J92 -+Function [{t},
r -» Function[ {t}, a + b] 11
The expressions for Q [i] follow from taking the differential of the constraints. First,
obtain a list of the coordinates as a function of t:
In[179] : = vars = {r[t],61[t], 62 [t]};
Then define Q [i] via X%i ^- -ri> where /. is the jth constraint equation:
In [180]:= Qeq =
Sum[A[j] *D[constraints[[j, 1]],
vars[[#]]], {j,l, 2}]&/9{l, 2,3}
Out[180]= {A[2] , bA[l] , -aA[l] }
The equations of motion are
In[181]:= eqjlotion= Lag[{r, 61, 62}, L, Qeq] ;
oqMotion //ColumnForm
gm Cos [91 [t] ] -mr[t] 91'[t]2 +mr"[t] == A [2]
Out [181]= -gmr[t] Sin [91 [t] ] + 2 mr [t] r'[t] 91'[t] + mr [t] 2 91" [t]
+11 (91" [t] +92"[t] ) == bA[l]Il (91" [t] +92"[t] ) == -aA[l]
These three equations plus the two constraint equations give five equations for the five
unknowns: 01, 62, r, A [1], and A [2].
b. Use constraintRule to eliminate 82 and r in eqMotion and solve the three
equations for 81, A [ 1], and A [ 2 ].
6.3 Lagrangian Problems with Lagrange Multipliers 343
In[182] := {A2Sol, 6Sol, AlSol} = (Solve[eqHotion//.constraintRule//Flatten,
/.Rule -»Equal
//Flatten
{A2Sol,eSol, AlSol}//ColumnForm
A [2] == gm Cos [91 [t] ] - (a + b) m91'[t] 2
__ a2 gm Sin[91[t] ]
Out[182]= el I1] == (a + b) (Il + a2m)
glim Sin [91 [t] ]
The equation 0Sol is the equation for the variable 81 [t]. This equation gives a first
integral if we multiply by 81' [ t ] and integrate both sides of the equation. Move all terms
to the left side of the equal sign
In[183] := eqe = FSol[[l]] -6Sol[[2]])
= 2 r.
(a + b) (II + a2m)
Multiply by 81' [t] and integrate,
In [184] := inte =
Integrate [eqe 61'[t], {t, 0,t}] //.
Apart
__ a2gm(-l + Cos[91[t]])+l
(a + b) A1 +a2 m) 2 L J
(Note that initial conditions are assumed for 81). Next, solve for 81' [ t ]:
In[185] := sole = Solve[inte == 0, {61'[t]}] [[1]] /.
V-l + Cos [x_] -> i Vl - Cos [x]
Out[185]= Ww^
c. The sphere loses contact when A [2] goes to zero. Setting the expression for A [2]
equal to zero, it follows
In[186]:= eql = A2Sol/.A[2] ->0//.soie
Out [186]= 0 = =
2 a2 gm2 A -Cos [91 [t] ]
II + a2 m
Solving for Cos [81 [t] ], you get
gm Cos[91 [t] ;
In[187]:= sol2 = Solve [eql, Cos[61 [t] ]]//Flatten
2 a2 a m2
2
r
Out[187]= Cos[ei[t]
1
¦a^m) -gm- 2 a %m
\ s Il+a2m ,
344 Chapter 6 Lagrangians and Hamiltonians
The sphere falls off when 01 has the value
In[188]:= sol3 =
Solve[sol2//. {Rule-» Equal}, 61 [t],
InverseFunctions -»True] //Flatten
Out[188]=
¦ II + 3 i
,.2.
Finally, substitute the moment of inertia for a sphere and convert the angle from radians to
degrees:
In[189]: = F1 [t]/")//.
2 a2
{.1H
Out[189]= 53.9681
6.4 ¦ HAMILTONIAN PROBLEMS
6.4.1 ¦ Overview of Hamilton's Equations
Consider those systems described by n generalized coordinates qi and the Lagrangian
L[q', q, t~\. The Hamiltonian is defined in terms of the Lagrangian L[q', q, t~\ by
The pi are the generalized momentum and are related to the generalized coordinates by
/>['•] _ dLW-yA gy soivmg these n equations for the q\ in terms of the p and q, you can
write q\ as a function of q and p, q' = q'[p, q\. Eliminate the q\ variables in H and express
H in terms of the canonical coordinates. The equations of motion follow from
, dH[q,p,t] dH[q,p,t]
Pi dqt ' q> dPi
These first-order differential equations are called Hamilton's canonical equations.
You will need to compute Hamilton's equations of motion. It is not necessary to under-
understand the details of the user-defined procedures until you have done all the problems; then
you can go back and examine the procedure. The user-defined function Hamilton will
compute this in one step for the case of one or multiple variables:
6.4 Hamiltonian Problems 345
In[190] : = Hamilton [L_, xList List, pList List,
t_:t] :=
Module [ {xx, w, pp, sol, ham, eqp, eqx,
eqs},
xx = Through[xList[t]];
w = D[xx, t];
pp = Through[pList[t]];
sol = Solve [ (D[L, #]&/9w) == pp, w] //
Flatten;
ham = pp .w - L//.sol//Sijis>lify //
Expand;
eqp = D[pp, t] == - Map [D [ham, #]&, xx]//
Thread;
eqx = D[xx, t] == + Map[D[ham, #]&,pp]//
Thread;
egs = Join [eqp, eqx];
Return[ {sol, ham, eqs} ]
Hamilton returns the expression for the canonical momentum, the Hamiltonian, and
Hamilton's equation of motion. For example, consider the simple one-dimensional La-
grangian,
In[191]:= Clear[L, x, V]
ln[192]:= L = -V[x[t] ] + | mx' [t]2;
You can easily compute Hamilton's equations of motion:
In[193]:= {pRule, hamiltonian,oqMotion} =
Hamilton [L, {x}, {px}];
pRule
hamiltonian
oqMotion
Px[t]
Out[193]= {X'[t].?^i}
Out [193]= PX[t] + V[x[t]
2 m
px[t]
Out [193]= (px'[t] == -V'[x[t]],x'[t] == —
Note how the three separate expressions returned by Hamilton are extracted. The
first equation is the relation between the generalized coordinate x[t] and the canoni-
canonical momentum, px[t]. The second expression is the Hamiltonian expressed in terms of
canonical variables {x [t], px [t] }. The equations of motion follow from the third list.
Next, consider a two-dimensional Lagrangian:
346 Chapter 6 Lagrangians and Hamiltonians
ln[194]:= L = -V[x[t] , y[t] ] + | m (x' [t]2 ty' [t]2) ;
Hamilton[L, {x, y}, {px, py}]
Out [194]=
{px'[t] ==-V<1'0) [x[t]
py-[t] ==-V@'1) [x[t
Finally we apply Protect to the user-defined procedure to keep it from being deleted
with Clear [ "Globall *" ]:
In[195]:= Protect[Hamilton];
PROBLEM 1 Harmonic Oscillator. Consider a particle of mass m moving in a har-
harmonic potential, V = ^-. Find the canonical momentum, Hamiltonian, and Hamilton's
equations. Verify that the equations also follow from the user-defined function Hamil-
Hamilton. Solve Hamilton's equations.
Remarks and Outline Express the Lagrangian in terms of {x [ t ], x' [ t ]}. The canon-
canonical momentum p follows from taking the derivative of the Lagrangian relative to the vari-
variable x' [t]. The Hamiltonian is H=p x'-L[x#x']. The equations of motion follow
from Hamilton's equations.
Solution
In[196] := Clear ["Global' * "]
The kinetic and potential energies are
In[197] := T= -mx'[t]2j
V=ikx[t]2;
and the Lagrangian follows from
In[198] := L = T-V
Out [198]= -ikx[t]2 + imx'[t]2
The momentum conjugate to x [ t ] is
ln[199]:= eql=p[t] ==D[L,
Out[199]= p[t] ==mx'[t]
6.4 Hamiltonian Problems
Solving eql for x' [t], you get
In[200] : = xpRule = Solve [eql, x' [t] ] [ [1] ]
P[t] I
347
Out [200]= [x'[t]
Expressing the Hamiltonian in terms of the canonical variables {x,p}, it follows
ln[201]:= H= (p[t]x'[t] -L)//.xpRule
Out [201]=
-kx[t]
2
+
2 m 2
Hamilton's equations of motion are
In[202]:= eq2 =
Out[202]=
P'[t] ==-D[H,
x'[t] = =+D[H,p[t]]}
[t] = =-kx[t],x'[t] ==
The user-defined function Hamilton automatically returns eql, H, and eq2:
In[203] : = Hamilton [L, {x}, {p}] //ColumnForm
r ,,^ p[t] l
Out[203]=
2m 2
p'[t] ==-kx[t]/X'[t] = =
P[t]
If we assume the initial conditions are
In[204]:= initial = {p[0] ==pO,x[O] ==xO};
then the solution follows from applying DSolve to eq2:
In[205]:= dsol=
DSolve[eq2~Join~initial, {p[t], x[t]},
t]//Flatten //FullSimplify
Out[205]= (p(t) ->pO Cos
x(t) -» xO Cos
Vkt
y/m
Vkt
Vm
- Vk V^xO
pO Sin
Vk\
Sin
Vkt
V^s
m
Vkt
Vm
1
J
348 Chapter 6 Lagrangians and Hamiltonians
PROBLEM 2 Nonlinear Oscillator. Consider the nonlinear oscillator described by
V = \h? - ±ec4;
a. Find the Lagrangian and apply the user-defined function Hamilton to get the
Hamiltonian and Hamilton's equations.
b. Draw the potential and phase diagrams for k-»l and e-»l/2.
c. Use the user-defined procedure firstDiff Series to find the power-series so-
solution. Find the first-order perturbation solution in the parameter e using the user-
defined procedure f irstOrderPert. The user-defined command is listed in the
next paragraph under Remarks and Outline. Let k-»l and e-»l/2 and compare the
previous results with the numerical solution.
In[206]:= Clear["Global'*"]
Remarks and Outline The user-defined function firstDiff Series returns the ex-
expansion for the solution of two first order equations in powers of t.
In[207] := firstDiff Series [eqin., {z_, p.},
initRule-List, order., t_ :t] : =
Module [ {eq, zSer, pSer, eSer, vars,
sol/ zpsol},
eq = Table[eqin[[i, 1]] -eqin[[i, 2]] = = 0,
{i,2}];
zSer = Series[z[t], {t, 0,order}];
pSer = Series[p[t], {t, 0, order}] ;
eSer = eq//.({z[t] ->zSer,p[t] ->pSer})//
ExpandAll;
vars =
(Table[{D[z[t], {t, j}],D[p[t], {t, j}]},
{j, 1, order + l}]/.t-»0)//
Flatten;
sol = Solve [eSer, vars] //Flatten;
zpSol = {zSer, pSer}//.sol//.initRule;
Return[zpSol]
For example, consider the harmonic oscillator described by the two coupled, first-order
equations:
In[208] := eql = j^xtt] +p'[t] == 0,p[t] ==x'[t]J;
firstDiffSeries[eql,{x, p},
{x[0] -»x0,p[0] ->p0}, 4, t]//ColunmForm
6.4 Hamiltonian Problems 349
xO + pO t- - (w2 xO) t2 - - (pOw2) t3 + —w4x0 t4 +O[t]5
Out[208]= 2 1 6 1 2?
pO -w2 xO t- - (pOw2) t2 + - w4x0 t3 + — pOw4 t4 +O[t]5
The command f irstDif f Series returned a time series expansion for x and p.
The user-defined command f irstOrderPert returns the first-order perturbative cor-
correction to the term with coefficient eps
In[209]:= f irstOrderPert [eql., x., {xO., vO.},
eps-:eps, t. :t] : =
Module [{xRule, eq2, eqEps, initConO,
initConl, dsoll, dsol2},
xRule = {x-> (x[0] [#] + epsx[l] [#]&)};
eq2 =eql[[l]] - eql [ [2] ] /.xRule;
eqEps = Coef ficientList [eq2, eps] = = 0//
Thread;
initConO = {x[0] [0] ==x0,
(x[0])'[0] == vO};
initConl = {x[l] [0] = = 0, (x[l])' [0] = = 0};
dsoll =
(DSolvo[join[{eqEps[[1]]},initConO],
{x[0] [t] }, t] //Flatten) ;
dsol2 =
(DSolve[Join[{eqEps[[2]]}, initConl]//.
dsoll, {x[l] [t]}, t]//Flatten);
Return[x[t]/.xRule//.
Join[dsoll,dso!2]]
For example, applying f irstOrderPert to eql,
In[210]:= eql=x"[t] ==-k2x[t] +epsx[t]2;
we get
In[211] := f irstOrderPert [eql, x, {xO, 0}, eps, t] //
Simplify//Collect [#, ops] ft
Out[211]= xO Cos[kt]-
epsxO Bx0 Cos[kt] + xO (-3 +Cos[2kt] )
Solution
a. As a second example of Hamilton's equation, consider a nonlinear oscillator. The
kinetic and potential energies are
350
Chapter 6 Lagrangians and Hamiltonians
ln[212]:= T= ~ mx'[t]2;
The Lagrangian follows from
In[213] := L = T-V;
The canonical momentum, Hamiltonian, and Hamilton's equations follow from the user-
defined function Hamilton:
In[214]:= {xpmle, hamiltonian, eqMotion} =
Hamilton[L, {x}, {p}];
{xprule,hamiltonian, oqMotion}//
ColumnForm
Out [214]=
+ kx[t]
2 4
==-kx[t] +6x[t]3,x'[t] ==
b. Consider the values
In[215]:= values = {k -» 1, e-»1/2, m-» 1};
The potential graphics and phase diagram follow from
In[216]:= ptl = Plot [V/.values//Evaluate,
{x[t],-2,2},
Display-Function -» Identity];
In[217]:= pt2 = ContourPlot[
hamiltonian /.valuos//Evaluato,
ColorFunction -» Huo,
Contours -» 15/
Display-Function -» Identity] ;
Displaying the results, we get
In[218]:= Show[6raphicsArray [{pt2, ptl}] ];
-0.
-2-10 1 2
6.4 Hamiltonian Problems 351
The phase portrait is on the left and the potential graph is on the right. Particles near the
origin with sufficiently small energy are bounded.
c. Use the user-defined command f irstDif f Series. Return a time series solution
for the equations of motion:
ln[219]:= solt =
firstDiffSeries[eqMotion,{x, p},
{x[0] ->xO,p[O] ->0}, 6]//Normal //
Simplify
Out[219]= l^b
(xO G20 m3 -360 m2 t2 (k - xO2 s) + 30 m t4
(k2 -4kx026 + 3x04s2) - t6 (k3-
25k2x026 + 51kx04s2 -27x06s3))),
A20m2-20mt2 (k-3x02e) +
t4 (k2-24kx02s+ 27x04s2)))}
where we have calculated x [ t ] and p [ t] to order t6.
The perturbative solution follows from the user-defined function f irstOrderPert.
To apply f irstOrderPert we express the equations of motion as a second-order dif-
differential equation:
In[220]:= eql = (eqMotion//First) /.
Out[220]= mx"[t] ==-kx[t] +ex[t]3
Apply f irstOrderPert to eql:
in[221]:= sole =
firstOrderPert[eql, x, {xO,0}, e] //
Collect [#, {xO, e, Cos[x.] } ]& //
Short [#,!]&
352
Chapter 6 Lagrangians and Hamiltonians
Viet
Out[221]= e
5 Cos
32 k
3 t Tan
«5» + Cos
Viet
32
16 k
Sin
Sec
128k
xO + Cos
Vkt
xO
The time series and perturbation solution should agree if we keep only the first order
terms in e and 6th order in t. Keeping first order in e terms in the time series solution, we
get
In[222]: = testl=
solt [ [1] ] /.e~n./; n > 1 -> O//Apart //
Collect [#,t]&
Out [222]= xO + t6
k3 xO 5 k2 xO3 6
720 m3 144 m3
k2x0 kx036
24 m2 6 m2
kxO x036
2m
2m
This is to be compared with the time series expansion of the perturbation solution:
In[223]:= test2 = Series [sole, {t, 0, 6} ]//Normal
Out [223]= xO + t
4-4
U
6
k3x0 5
720 m3
k2 xO kxO3 6
24 m2 6 m2
k2x03
6
144 m3
4. 1
+ u
As to be expected, they are in agreement.
In [224]:= test]
Out[224]= True
L =
=test2
+
kxO xO3 6
2m 2m
To compare with the numerical evaluation of the equation of motion we let
In[225] := values = {xO -> 1.2 , pO -» 0, k -» 1, m-» 1,
6.4 Hamiltonian Problems
The numerical solution is
353
In [22 6] : = nsol =
NDSolve[{e<iMotion/.values, p[0] == 0,
x[0] ==1.2 }, {p[t],x[t]},
{t, 0, 30 }]//Flatten;
Comparing the series expansion, perturbative solution, and numerical solution, it fol-
follows
In[227] := Plot[
{ sole , solt[ [1] ] ,x[t] }/.nsol/.
values //Evaluate, {t, 0/30}/
Plotstylo -> {Dashing [ {0.01} ] ,
Dashing[{0.05}], Thickness[0.005]},
GridLinos ->Automatic ] ;
1&
\o
/ 2 0
-1&
The solid curve is the numerical solution, the large dashing curve is the time series
expansion, and the short dashing curve is the perturbative solution. The perturbative and
time series solution only agree with the numerical solution for small t.
PROBLEM 3 Cylindrical Coordinates. Consider the orbit of a particle with mass m
moving in a time-independent potential V[r,0,z], where {x,6,z} are cylindrical coor-
coordinates.
a. Find the expressions for the canonical momentum, the Hamiltonian, and Hamilton's
equations.
b. Consider the potential Va- .-* - and restrict the orbit to the z=0 plane. Find the
first order differential equations for {r,pr}, where pr is the canonical momentum.
c. Derive the time series solution for the equations in Part b.
In[228]:= Clear["Global * *" ]
354 Chapter 6 Lagrangians and Hamiltonians
Remarks and Outline Express the position vector and the kinetic and potential ener-
energies in terms of cylindrical coordinates. The momentum relations, the Hamiltonian, and
Hamilton's equation follow from the user-defined function Hamilton. The power-series
solution of Hamilton's equations follows from the user-defined function firstDiff-
Series.
In[229]:= f irstDif f Series [eqin., {z_, p.},
initRulo_List, order., t_ :t] : =
Module [ {eg, zSor, pSor, oSor, vars,
sol/zpsol}/
eq = Table [eqin[[i, 1]] -eqin[[i, 2]] = = 0,
{i,2}];
zSer = Series [z [t] , {t, 0, order} ];
pSer=Series[p[t], {t, 0, order}];
eSer = eq//. ({z[t] ->zSer, p[t] ->pSer})//
ExpandAll;
vars =
(Table[{D[z[t], {t, j>],D[p[t], {t,
{j, 1, order + 1}] At-> 0)//
Flatten;
sol = Solve [oSor, vars] //Flatten;
zpSol= {zSer,pSer}//.sol//.initRule;
Return[zpSol]
Required Packages
In[230] := Needs["Calculus'VectorAnalysis'11]
Solution
a. The position vector in cylindrical coordinates is described by the rule
In[231]:= rRulo=
rVector -»
(Evaluate[CoordinatesToCartesian[
{r[#], e[#], z[#] }, Cylindrical] ]&)
Out[231]= rVector^ ({Cos[9[#l]] r[#l],
r[#l] Sin[9[#l] ] , z[#l]}&)
The kinetic and potential energies are
In[232]:= T= I - mrVector'[t] .rVector'[t] J//.
rRulo//Simplify
L = T-V[r[t],6[t], z[t]]//Siji5?lify
Out[232]= im (r'[t]2 + z'[t]2 +r[t]2 e'[t]2)
6.4 Hamiltonian Problems 355
Out[232]= -V[r[t] , e[t], z[t] ] +
|m(r'[t]2+z'[t]2+r[t]2e'[t]2)
The Hamiltonian and Hamilton's equations follow from
In[233] := {pRulo, hamiltonian, oqMotion} =
Hamilton[L, {r, 6, z}, {pr, pd/pz}];
In[234]: = pRulo
In[235]:= hamiltonian
The first part of the list is the expression for the canonical momentum; the second is the
Hamiltonian; the last are the six Hamilton first-order equations. The equations of motion
read
In [23 6] : = oqMotion // ColumnForm
pr'(t) == ||^pf-VA'°'o) (r(t),e(t)/Z(t))
pe'(t) == -v^'1-0* (r(t), e<t), z(t))
pz'(t) == -v10'0'1* (r(t), e(t), z(t))
Out [236]= r' ,t\
mr(tJ
5^
The first part of the list is the expression for the canonical momentum; the second is the
Hamiltonian; the last are the six Hamilton first-order equations. The equations of motion
read
In [23 7] : = oqMotion // ColumnForm
Pr'[t] == ^i^ _v<i'°'°> [r[t] , 9[t] , z[t]
ir t]J
pe'[t] ^^-V*15'1'0) [rltj^lt], z[t]]
pz'[t] ==-V<0'0'1) [rltj^lt], z[t]]
Out [237]= r,[t] ==
b. Let us express the gravitational potential in pure form with the rule
356 Chapter 6 Lagrangians and Hamiltonians
In[238]:= vRulo=
1 [ V#l2+#32 JJ
Out[238]= -
V[r[t],6[t], z[t]]//.vRule
k
/r[t]2+z[t]2
and restrict the orbit to the z=0 plane
In[239]:= zRulo = {z-» @&) , pz-» @&)};
Applying vRule and zRule to Hamilton's equations of motion, you get
In[240] := eql = oqMotion//.vRulo/.zRulo//
PowerExpand;
eql //ColumnForm
pr[t]^
mr[t]3 r[t]2
pS'[t] ==0
True
Out[240]= t __ Pr[t]
mr[t]2
True
The z equations are automatically satisfied. Note that p#[t] must be a constant. Setting
p6 [t ] =m h, Hamilton's equations reduce to
ln[241]:= eq2 =eql//.p©-» (mha)
Out[241]= {pr'[t] == -^yj - -AT# True, True,
The equations of motion for {r,pr} are
ln[242]:= rEq = eq2 [ [{1, 4}] ];
rEq // ColumnForm
Out [2421= pr|tj
c. The user-defined function f irstDif f Series returns a power-series solution for
two first-order equations. Apply f irstDif f Series to the r equations of motion rEq
with the initial conditions:
In[243] := initial = {r[0] -»r0,pr[0] -»0};
6.4 Hamiltonian Problems
The results are
357
In[244]:= pert =
firstDiff Series [rEq, {r, pr}, initial,
4, t]//Simplify
Out [244]= rO +
(h2 m-krO) t2
2mrO3
C h4 m2 - 5 h2 km rO + 2 k2 rO2 ) t4
24 (m2 rO7)
Q[t]5>
Ch4m2 - 5h2 kmrO + 2 k2 rO2) t3
6 (mrO7)
PROBLEM 4 Swinging Atwood Machine. Consider the Atwood machine, which con-
consists of two weights of mass m and M connected by a light, inextensible cord of length LO.
The cord passes over a frictionless pulley. The mass M is constrained to move in a vertical
direction but the mass m can swing in a plane. Let {xl,yl} be the coordinate of mass m
and x2 be the coordinate of mass M. The length of the cord is related to the positions of m
and M by
LO =
x2
M
a. Find the Hamiltonian and Hamilton's equations of motion. Express the results in
terms of the coordinates {x,6} and their canonical momentum, where xl= r
Cos[0],yl= r Sin [0]. The angle 0 is measured from the downward vertical.
b. Numerically solve for the motion and graph the results.
Solution
In[245]:= Clear["Global»*"]
358 Chapter 6 Lagrangians and Hamiltonians
a. The potential and kinetic energies are
ln[246]:= T = |{xl'[t] , yl'[t] } . {xl' [t] , yl' [t] } +
V= -gmxl[t] -g M x2[t];
The polar coordinates for m are
In[247] := change =
{xl-> (r[#] Cos[e[#]]&),
yl-» (r[#] Sin[6[#]]&)};
The length of the cord is related to x2 and r by
In[248] := LORule = x2 -» (LO - r[#]&) ;
If we eliminate the x2 coordinate, then the Lagrangian is
In[249]:= L = T - V/.LORule/.change//Simplify
Out[249]= - BgL0M-2g (M-m Cos[9[t] ] ) r[t] +
(m + M) r'[t]2 +mr[t]2 e'[t]2)
The canonical variables, Hamiltonian, and equations of motion follow from the user-
defined function Hamilton:
In[250] : = {xpRule, ham, eqMotion} =
Hamilton[L, {6, r}, {pe, pr}]//Simplify;
In[251]:= xpRule
Out [251]= (e'(t)
In[252]:= ham
Out[252]= ( (m + M) p9(tJ+mr(tJ (pr(tJ-
2g (m + M) (L0M+ (m CosF(t) ) - M) r(t)) ) ) /
2m (m + M) r(tJ)
ln[253]:= eqMotion//ColumnForm
pe'(t) ==-gmr(t) Sin(S(t))
gM + pr'(t) == 3 +gm Cos(9(t) )
mr<t)
Out[253}=
m + M
The first part is the canonical variables (xpRule), the second is the Hamiltonian (ham),
and the equations of motion are given by part three (eqMotion). The equations of motion
reduce to the "normal" Atwood problem if p#[t]-»O, 0[t]-»O, andr-»xl:
6.4 Hamiltonian Problems 359
In[254]: = eqMotion/.{pe[t] -> 0, e[t] ->0}/.
r ->
Out[254] = [pe'[t] == 0, gM + pr'[t] = =gm,
pr[t] -,
S'[t] ==0,xl'[t] = =
m + M
Or, in terms of the familiar second order equation, it follows
m+M
b. Let us find the numerical solution for the motion with the parameters
ln[255] := values = {m-» l,H-» 1.05, g-» 1};
and let the initial conditions be
ln[256]:= initial = {r[0] ==10,pr[0] == 0, 6[0] == 7T/12,
P«[0] ==0};
The equations of motion and initial conditions are
Itx[257]:= eql = {eqMotion, initial}/.values//
Flatten;
The numerical solution follows from
In[258]:= nSol=
NDSolvo [eql, {r , pr, 6 , p6} ,
{t, 0, 250 } ] //Flatten ;
Define the functions
in [259] : = {rl [t.] , 61 [t.] , prl [t.] , p©l [t.] } =
{r[t],6[t],pr[t], pe[t]}/.nSol;
The plots for r and 6 are
In[260]-.= Plot[{rl[t], el [t] }//Evaluate,
{t,0,250},
PlotStylo -» {Dashing[ {0.01}] ,
Thickness[0.008]} ];
360
Chapter 6 Lagrangians and Hamiltonians
10
8
6
4
2
The solid curve is 0 and the top curve is r. Notice that as the cord shortens the frequency
of oscillation increases. The rapid oscillation eventually stops the decreasing length and the
cord starts to increase. The pattern repeats in a periodic fashion.
The graphics for the motion of m follow from
In[261]:= ParametricPlot[
{rl[t] Sin[61[t]],-
Evaluate, {t, 0, 80}] ;
Cos[61 [t] ] }//
Finally, the phase trajectories {6, p#} and {r, pr} are
In[262] .-= ptl =
ParametricPlot [#//Evaluate, {t, 0, 250},
Ticks -»False,
Display-Function -» Identity
rl[t] , prl[t] },
p61[t] }};
Jn[263]:= Show[GraphicsArray[ptl]];
The graph on the left is {rl[t] ,prl[t] } and the right is {6»l[t] ,p01[t] }
6.4 Hamiltonian Problems 361
PROBLEM 5 Spherical Pendulum. Consider a pendulum of mass m suspended by a
rigid, weightless rod. The motion is not restricted to a plane. Use the spherical angular
coordinates {6,0}and their conjugate variables {p6, p<p} to describe the motion.
a. Use the user-defined function Hamiltonian and find the canonical momentum,
Hamiltonian, and Hamilton's equations of motion. Eliminate the 0 variable and re-
reduce Hamilton's equations to a nonlinear equation for 8. Restrict the pendulum mo-
motion to a plane and show that the solution reduces to the standard pendulum equation.
b. Assume g=l, m=l, LO=1, and find a typical numerical solution.
Required Packages
In[264] .= Needs["Graphics'Shapes]
Solution
In[265]: = Clear["Global'*"]
a. The kinetic and potential energies for a spherical pendulum are
ln[266]:= T= |l(X'[t]!ty'[t]2*z'[t]!);
V = mgz[t] ;
The Cartesian coordinates are related to spherical coordinates by
In[267] := change =
{x -> (LO Cos[*[#]] Sin[e[#]]&),
y -» (LO Sin[0[#]] Sin[e[#]]&),
z -> (LO Cos[e[#]]&)};
Instead of 6 we can express the equations in terms of an angle defined relative to the
downward vertical ft:
In[268] := ^Rule = 0 -> GT-*[#]&);
The Lagrangian is
In[269] := L = T - V/.change/.^Rule//Sinq?lify
Out[269]= - LOm Bg Cos[i/f[t] ] +
L0Sin[i/f[t] ]2 <t>' [t]2 +L0i/f' [t]2)
Applying the user-defined function Hamilton to L, you get
In[270]:= eql = {prulo, ham, oqMotion} =
Hamllton[L, {«r, <f>}, {p#, p*}, t] ;
362 Chapter 6 Lagrangians and Hamiltonians
In[271] : = prule
In [2 72] : = ham
Csc2 (rir(t) ) pd> (tJ p*(tJ
Out[272]= Kvy iiyv\ ) +w\> -gLOmCos(i/f(t))
2 LO^ m 2 L(T m
In[273] : = eqMotion//ColumnForm
Csc2 (i^(t) ) p0 (t) 2
= g LO m Sin (if/ (t))
LO m
P0'(t) ==0
Out [273]= Pilr(t)
i/r (t) == j—
__ Csc2 (i/f(t) ) P0(t)
LO2 m
The first part of eql (prule) are the canonical momenta, the second part (ham) is the
Hamiltonian, and the equations of motion follow from the third part (eqMotion).
Consider the equations of motion
In [2 74] := eqMotion//ColumnForm
P<t>' [t] == 0
Out [274]= ^[t] ==PiA[t]
' L J "" L02m
and notice that the solution for p0 is a constant:
In[275] := p^Rule = {p0 -» (mh&) };
Eliminating p0 [t] from the equations, it follows
In[276]:= eqMotion/.p^Rule//ColumnForm
h2mCot[i/f[t] ] Csc[i/f[t] ]2 .
pi/f'[t] == 2 gLOm Sm[i/f[t]
LO
True
Out [276]= == pi/f[t]
LO2 m
The equations of motion have been reduced to three first order differential equations for
the variables p^[t], 0[t], and^# [t].
In the absence of <p motion (h=0) the equations of motion reduce to the following first
order equations:
In[277] := eqMotion /. p*Rule/.h-» 0//ExpandAll //
Flatten
6.4 Hamiltonian Problems 363
Out[277]= jpi/r' [t] == -gLOm Sin[i/r[t] ] ,
True, 4i' [t] == s— , d>' [t] == ol
LO^ m J
The equivalent second order equation is
In[278]:= Solve[{eqMotion[[1]],
D[eqMotion[[3]],t]},r'[t]] /.
Rule -»Equal/. ptf>Rule/.h-> 0//
ExpandAll//Flatten
Out[278]= U"W==-gSin[*[t]]\
L LO J
This is the well-known planar pendulum equation.
b. Let us consider the numerical solutions of Hamilton's equations
In[279]:= eqMotion
Cot[i/f[t]] Csc[i/f[t]]2p0[t]2
Out [279]= {pi/r'[t] = =
LO2 m
gLOm Sin[i/f[t] ] , p0'[t] ==0,
Choose the parameters
In[280] := values = {LO -> 1, g-» 1, m-» 1};
and let the initial conditions be
In[281]:= initial = {^[0] ==0,p*[0] ==0.1,
=0};
The numerical solution is
In [282] .¦= nSol =
NDSolve[ {oqMotion,initial}/.values//
Flatten, {*, *, p*, p*}, {t, 0, 25}] //
Flatten;
Define the functions
ln[283]:= {*1 [t.] , 4>1 [t.] } = {*[t], 0[t] }/.nSol;
The graphics for the motion follow from
364
Chapter 6 Lagrangians and Hamiltonians
In[284]: = ptl=
ParametricPlot3D[
{x[t] , y [t] , z [t] , Thickness[0.01] } /.
change/.i^Rule/.values/.i/r-> i/rl/.
<t>-><t>l //Evaluate,
{t,0,25},
DisplayFunction -» identity
To this motion we add the surface of a sphere found in the add-on package
ln[285] .-= Needs["Graphics'Shapes'"]
The graphics for a sphere are
In[286]:= sphere= Graphics3D[Sphere[0.96]] ;
Displaying the results, it follows
In[287] .- = ptl = Show[ sphere, ptl, Boxed -» False ,
Shading -> False, Viewpoint -> {1, 1, 0} ];
ill
Vr-J\—
A
\i
A'
I
/
u
ijj
We can also display the results against a transparent sphere:
In[288]:= Show[
ptl/. Polygon[x-] -» {Hue[0.8], Line[x] },
Viewpoint -» {1, 0, 1/2}] ;
6.5 Hamilton-Jacobi Problems 365
6.5 ¦ HAMILTON-JACOBI PROBLEMS
6.5.1 ¦ Overview
The Hamilton-Jacobi technique seeks a transformation to a new set of canonical variables
{Q> P}, where the new Hamiltonian is zero. These new canonical variables {Q, P} will be
constants, and the problem is reduced to solving algebraic equations. If {q, p] are the old
canonical coordinates and {Q, P} are the new coordinates, the transformation between the
coordinates is given by Q = Q[q, p, t] and P = P[q, p, t\. The transformation is said to
be canonical if there exists a new Hamiltonian K[P, Q\, where the new coordinates obey
Hamilton's equations:
dP dQ
Canonical transformations can be obtained from generating functions. In particular, gen-
generating functions of the form S[q, P, t] are considered for the Hamilton-Jacobi technique.
The transformation between the variables {q, p\ and {Q, P} follows from derivatives of the
generating function:
dS[q,P,n n dS[q,P,t]
Solve the first set of equations to get P[q, p, t]. The remaining equations give the expres-
expression for Q[q, p, t\. Next, search for a canonical transformation whereby the new Hamilto-
Hamiltonian K is zero; this will render the equations of motion for {P, Q] trivial.
The new and old Hamiltonians are related by
If K is zero, then it follows from Hamilton's equations,
dp u dQ
that the new variables Q and P are constants. The constraint K = 0 implies the generating
function S satisfies
Replacing p in this equation with a5[|'F'f] you get the Hamilton-Jacobi equation
The generating function for the Hamilton-Jacobi variables is called Hamilton's principal
function.
366 Chapter 6 Lagrangians and Hamiltonians
The Hamilton-Jacobi equation is a partial differential equation for the generating func-
function S[q, P, t]. It contains n+1 variables, one time variable and nqi variables. A complete so-
solution of the partial differential equation involves n+1 independent constants of integration.
One of the n +1 constants is just a trivial additive constant and can be set equal to zero. The
remaining n constants of integration {av ..., an) are taken to be the new canonical momen-
momentum P. The problem of finding Hamilton's principal function, S[q, P, t], is simplified if the
Hamilton-Jacobi equation is separable. That is, S[q, P, t] = Wx [qx] + W2[q2] ¦ ¦ .+Wn[qn]-at.
The W's are called Hamilton's characteristic functions. The Hamilton-Jacobi equation is
reduced to a set of ordinary differential equations, one for each W. The solution for W can
then be integrated. In the separable case, the problem is reduced to a set of integrals. The
transformations between the old coordinates {q, p] and the new ones {Q, P] follow from
dS[q,P,n n dS[q,P,t]
P= Q=
The coordinate q is solved by inverting the second equation to give q = q[Q, a, t\.
You will need to compute the Hamilton-Jacobi equations of motion. Define the Hamil
tonJacobi function to compute this systematically:
In [289]:= Clear["Global•*"]
In[290] := Hamiltonjacobi [L_, xListJList, pList—List,
wList-List, a., t. :t] : =
Module [ {xx, w, pp, sol, ham, ww,
hamPrincFunc, pNewRulo, HJeq},
xx = Hap [# [t ] &, xList] ;
w « Map [#' [t]&, xList];
pp = Map [#[t]&, pList];
sol = Solve [(D[L, #] &/9W) ==pp, w]//
Flatten;
ham= (pp.w-L)//.sol//Sinq?lify//
Expand;
ww = Map[#[t]&,wList, {2}];
hamPrincFunc = (Plus@@w) -at;
pNewRulo=
{pp-» (D[hamPrincFunc, #]&/9xx)//
Thread}//Flatten;
HJeq = (ham//.pNewRulo) - a == 0;
Return[ {sol, hamPrincFunc, HJeq} ]
Hamiltonjacobi returns the expression for the canonical momentum, Hamilton's
Principal Function, and the Hamilton-Jacobi equation. The procedure assumes that Hamil-
Hamilton's Principal Function can be expressed in the form W[q] -a t. For example, consider
a system described by the Lagrangian:
6.5 Hamilton-Jacobi Problems 367
In[291]:= L =+-mx'[t]2 - V[x[t] ];
{pRule, hamPrincFunc, oqHamJac} =
HamiltonJacobi [L, {x}, {p}, {W[x]},a];
In[292]:= pRulo
Out [292]= (x'(t)
m J
In[293]:= hamPrincFunc
Out[293]= W(x(t)) -at
In[294]:= oqHamJac //ColumnForm
Note how the separate parts returned by HamiltonJacobi are extracted. Finally,
consider the second example,
ln[295]:= L =+i m (x'[t]2 ty'[t]2) - V[x[t] , y [t] ] ;
HamiltonJacobi[L, {x, y}, {px, py},
{Wl[x],W2[y]},a]
Out [295]=
-at + Wl[x[t]] +W2[y[t]],
-a+V[x[t],y[t]] +
Wl'[x[t]]2 +W2'[y[t]]2
2 m 2m
= =0
We apply Protect to the user-defined procedure to keep it from being deleted with
Clear["Global1*"]:
In[296]:= Protect[HamiltonJacobi];
PROBLEM 1 Harmonic Oscillator. Consider a one-dimensional harmonic oscillator.
a. Express the Hamiltonian in canonical variables and derive the Hamilton-Jacobi equa-
equation for W using the user-defined function Hamilton.
b. Solve the Hamilton-Jacobi equation for W to obtain the oscillator solution for {x, p}.
Solution
In [297] := Clear ["Global» * "]
a. The kinetic and potential energies for a harmonic oscillator are
368 Chapter 6 Lagrangians and Hamiltonians
In[298]:= T=-mx'[t]2;
V= -
L = T-V
1 ,1 ,
Out[298]= —kxm't-mx'It]2
2 2
The Hamiltonian follows from
In [299]:= {xpRule, ham, eqMotion} =
Hamilton[L, {x}, {p}]//. {x.[t] ->x};
In[300] := xpRulo
Out[300]= (x' -> -|
I- mJ
In[301] : =
In [3 02]:= eqflotion
Out [302]= fp'==-kx,x'==-|
where {x,p} are the canonical coordinates. The momentum p and Hamilton's principal
function S[x,t] are related by P=dS[x^''] ¦
In[303] := pRulo = {p -> D[S[x, t] , x] };
The Hamilton-Jacobi equation follows:
In[304]:= oqHJ = (ham +D[S [x, t] , t]) == 0//.pRulo
kx2 cfl-O) rx tl2
Out[304]= ^-+S<°'V [x, t] +^ 21^' J == 0
Assume the solution for S is of the form
In[305] := sRulo = {S-> (W[#l] -P#2&)};
where the new canonical momentum P is a constant. Substitute S into eqHJ to get an
equation for W [x]:
In [306]:= eqW = eqHJ//. sRule
2 2 m
b. Solving eqW for W [x], you get
6.5 Hamilton-Jacobi Problems 369
In[307] := dWRule = Solve[eqW, W [x] ] [ [2] ]
Out[307]= [W[x] V"^
where we have chosen the positive root here.
Integrate dWRule to get an expression forW[x]:
In[308] := wRule =
W[x] -> V2mP Integrate [ Vl - x2 A, x] /.
A.A
2P
Out[308]= W[x] ->
In general, we are interested in the derivative of W with respect to P. The new canonical
position coordinate Q (constant) follows from taking the derivative of S with respect to P,
n- dS[x,p,t].
u~ dP ¦
In[309] := eql = Q == D[S[x, t] /.sRulo/.wRulo, P]//Simplify
Out [309]= Q + t ==
You can solve eql for x:
In [310] := xSol = Solve [eql, x] //Simplify//PoworExpand//Simplify//Flatton
Sin [ ^'°+t'1 ,
The expression for the canonical momentum p follows from xpRule:
In[311]:= eq2 =
xpRulo/.Rulo -» Equal//Solve [#, p]& //
Flatten
Out [311]= {p->mx'}
and xSol
In[312]:= eq2/.x'-» D[x/.xSol, t]
Oat 13121= {p
370 Chapter 6 Lagrangians and Hamiltonians
PROBLEM 2 Particle in a Constant Gravity Field. Consider the motion of a projectile
in a constant gravitational field. Assume the motion is in the {x, z} plane.
a. Express the Hamiltonian in canonical variables and derive the Hamilton-Jacobi equa-
equation for W using the user-defined function Hamilton.
b. Solve for W to obtain the solution {x, p}.
Solution
In[313]:= Clear["Global1*"]
a. The kinetic and potential energies and Lagrangian for a particle in the field are
ln[314]:= T= i m (x' [t]2 + z' [t]2);
V=gmz[t];
L = T-V
1 -> •>
Out [314]= -gmz[t] + - m (x' [t] 2 + z' [t] * )
The Hamilton-Jacobi equations follow from the user-defined function HamiltonJa-
cobi
ln[315]:= {prule, S, Chareq} =
Hamiltonjacobi[L, {x, z}, {px, pz},
{Wx[x] ,Wz[z]},P]//ExpandAll
pz[t] -i
Out[315]= |(x' [t] -» PX[t] , z'[t]
m m
-Pt + Wx[x[t]] +Wz[z[t]],
.gm2[t]+WX'[X[t]]2+WZ'[Z[t]]2=-0)
2m 2m J
where P is a constant and is identified with one of the new momentum variables. The last
equation in the list is the equation for the characteristic function. This equation can be
separated into an equation for x [ 1 ] and x [ 2 ]
In[316] := eqla = Chareq[ [1, {1,2,4}]] == A/.z[t] -> z
eqlb = Chareq[[1, 3]] == -A /.x[t]-»x
Out [316]= -P + gmz +WZJZ] == A
2 m
Out [316]= WX'[X]2==-A
2 m
where A is the separation constant and can be identified with the other constant momentum
variables.
6.5 Hamilton-Jacobi Problems 371
b. The solutions for Wx and Wz are
In[317] := Wxsol = DSolvo [eqla, Wz [z] , z] [[2]]
Wzsol = DSolvo [eqlb, Wx [x] , x] [ [2 ] ]
2 (A + P) 2 z
Out[317]= {wz[z]^V2 l-Z-^±El + 2-^
L \ 3 am 3
yjA m + mP-gm2 z + C [ 1 ] J
Out [317]= [wx[x] -» i V^VAVmx + C[l]}
Without loss of generality we can take the positive solutions for Wx and Wz. The ex-
expression for S becomes
In[318]:= Ssol =-P t + Wx[x] + Wz [z] /. Wxsol/.Wzsol
Out [318]= -Pt+
2 (A + P) 2z
+
2z\ IV
+ — VAm + mP-gm2 z + 2 C[l]
3
\ 3gm
The expressions for the two new coordinates Q [i] follow from taking the derivatives of
Ssol relative to P and A,
In[319]: =
Out [319] =
Qeq =
{Q*
{qx +
Qz
c, Qz} = =
(D[Ssol,#]&/»{A, P}//Flatten)//
Thread //Sinq?lify
inr^x 2-
^ a/2 Vm 1
Vm (A+P-gmz)
g o
;A + P -gmz) -)
gm J
The Qx and Qz are constants. We get the solution for the motion if we solve Qeq for
In [320] := Sol =
Solve [Qeq, {x, z}] /.{x-»x[t] , z -» z[t] }/.
Rule -»Equal//Flatten
Out[320]= (z[t] == i I— + — -gQz2 -2gQzt-gt2 ,
i- 2^gmgm j
x[t] ==
The expression can be simplified if we replace {Qx, Qz, A, P} with the initial condi-
conditions {x[0],z[0],xf [0],zf [0]}. Expressing {x, z} in terms of these initial condi-
conditions, we get the familiar expression
372 Chapter 6 Lagrangians and Hamiltonians
In [3 21]:= Solve [
{Sol, (Sol/.t->0),
(D[Sol, t]/.t ->0)}//Flatten,
{x[t], z[t]}, {A, p,Qx,Qz}]//Flatten//
ExpandAll
Out[321]= |x[t] -»x[0] +tx'[0],
z[t] ->-?^- + z[0] +tz'[0]}
PROBLEM 3 Kepler's Problem and Hamilton-Jacobi Equations. Consider a bound
particle moving in a Keplerian potential. Use cylindrical coordinates {r, 9, z} and restrict
the motion to the z=0 plane. Denote the momentum variables conjugate to {x,6} with
{pr,p#}, respectively. Let S[t,r,0] be Hamilton's principal function, and Wr[r] and
W0[0] be the Hamilton characteristic functions.
a. Derive expressions for Hamilton's characteristic functions, Wr [r] and W0 [0].
b. Solve for the elliptical orbits using Hamilton's principal function S [ t, r, 0]. Show
that the expression for r can be written as r = ^'^'j.
Remarks and Outline Express the position vector in cylindrical coordinates using the
command CoordinatesToCartesian found in the package CalculuslVector-
Analysis V Find the expression for the kinetic and potential energies. The Hamilton-
Jacobi equation follows from the user-defined function HamlltonJacobi. Due to the
lack of 9 dependence in the Hamilton-Jacobi equation, it follows that W9"[ff] can be set
equal to a constant.
Required Package
ln[322]:= Needs["Calculus'VectorAnalysis1"]
Solution
In[323]:= Clear["Global* *"]
a. Use cylindrical coordinates and restrict the motion to the z=0 plane. You need to
load the package:
In[324] := Needs["Calculus''VectorAnalysis]
The position vector in cylindrical coordinates, called rvector, is
In[325] := rRulo =
rvector -»
(Evaluate[CoordinatesToCartesian[
{r[#],6[#], z[#]}. Cylindrical] ]&)
6.5 Hamilton-Jacobi Problems 373
Out[325]= rvector^ ({Cos[S[#l] ] r[#l] ,
r[#l] Sin[S[#l] ] , z[#l] }&)
The kinetic and potential energies for the particle moving in the z=0 plane are
In[326]:= T= - rvector'[t] .rvector'[t]//.rRule//.
{z' [t] -> 0} //Simplify;
V.--*-,
r[t]'
The Lagrangian is
In[327]:= L = T-V
Out [327]' k 1 ' '¦ n5 '¦
~m. r ^ i s\ \LJ LJ LJ/
The Hamilton-Jacobi equation follows from the user-defined function Hand It on Ja-
cobi.
In [328] := {moinRule, hamPF, eqMotion} =
HamiltonJacobi [L, {r, 0}, {pr, pe},
{Wr[r],W6[e]},En];
{momRulo, hamPF, oqMotion}//ColumnForm
I L J m mr[t]2J
Out[328]= -Ent + Wr[r[t] ] +WS[e[t]]
k Wr'[r[t]]2 W9'[9[t]]2
-En - + + ^— == 0
r[t] 2m 2mr[t]2
The first row are the relations between the conjugate momentum variables {pr, p#} and
{r' ,0'}. The second row is S[t,r,0], Hamilton's principal function, andWr[r], and
W0 [6] are the Hamilton characteristic functions. The last equation is the Hamilton-Jacobi
equation.
Due to the lack of 8 dependence in the Hamilton-Jacobi equation, it follows that W [81
can be set equal to a constant. Set W [0] =el and solve for W0 [0]:
In [3 29] := w@mle =
DSoive[{we'[e] == +ei,we[0] == o}, {we},e]
Out[329]= {We -> Function! {9}, el 9] }
The equation for Wr' [r] becomes
Jn[330] := eql =
(e<jMotion//.wemle//
Solve [#,Wr'[r[t]]][[l]]&)/.
r[t] -> r//PowerExpand
374 Chapter 6 Lagrangians and Hamiltonians
r V-el2 +2kmr + 2Enmr2-i
Out[330]= [wr'[r] -» j
The expression for the Q coordinate follows from taking the derivative of S relative to el:
dS[r, el, t] dWr[r, el, t]
Q~ del ~9+ del
where Wr[r,el,t] follows from integrating eql. However, it is more convenient to
take the derivative first and then integrate. It follows that 8Wr'gg'lel''\
ln[331]:= eq2 = D[eql [ [1, 2] ] , el]
Out [331]= — el =
rV-el2 +2kmr+2Enmr2
Integrating eq2 we get the desired relation
In[332] : = eq3 = Integrate f r 1 /.
1 rV-1 + ar + br2 J
Out [332]= ArcTan [-
_o , 2 kmr
2 kmr . 2 Enir'
"S^+ el2
The equation for Q is
In[333] := Qeq = Q == e + eq3
r
Out [333]= Q==9+ArcTan
2 kmr
el2
2kmr 2Enmr2
el2 eP
b. To get an expression for r we must invert Qeq. However, it is more convenient to
work with the variable u=l/r,
In[334] := ueq = Qeq/.r -» -
r -2
Out [334]= Q==G+ ArcTan
. ty /_-i 2 Enm 2 km J
Inverting this equation for u, we find
In [335]:= usol =
u/. Solve [ueq,u] [[2]] /.{Q->tt/2 }//
Simplify// PowerExpand // Simplify
km + Vrn V2 el2 En + k2 m Cos [9]
el2
The solution for u can be expressed in the canonical form
6.6 Exercises 375
u =
a(l-e2)
Equate u to its canonical form:
ln[336] := eq4 = usol == * I'^J?
Out [336]=
km+JmV2 el2 En + k2 m Cos[e]
- 2
1 + e Cos [8]
a A-e2)
You can obtain two independent equations from eq4 by choosing two values for
Cos[0[t]]:
In[337] := eq5 = eq4/.{6-» {0, 7r/2 }} //Thread
Out [337]-
rkm +
L
km
el2
The values for
In[338] : =
Out [338] =
^V2 el2 En + k2 m
el2
1 1
a A-e2) J
e and a follow from
Solve[eq5, a, e]
{{e.
V2 el2 En + k2 m
kVS
1 + e
a A-e2)
— 11
2EnJJ
6.6 ¦ EXERCISES
The solutions to many of these exercises can be found on our web sites.
6.1 Atwood Machine
In the problem section the Atwood machine was solved using Lagrange Multipliers. Solve this
same problem using independent coordinates. The Atwood machine consists of two weights with
masses ml and m2 connected by a light, inextensible cord of length Len. The cord passes over a
frictionless pulley. Let xl be the coordinate of mass ml and let x2 be the coordinate of mass m2.
The coordinates xl and x2 are the vertical distances from the pulley to the masses. Assume the
masses move only in a vertical direction. Express the Lagrangian in terms of only xl. Find the
equations of motion and solve.
6.2 Double Atwood machine
A string of length Lx passes over a fixed light pulley supporting a mass m1 on one end and a pulley
of mass m2 on the other. Over this second pulley passes a string of length L2 that supports a mass
m3 on one end and m4 on the other,
(a) Write the Lagrangian and derive the equations of motion.
376 Chapter 6 Lagrangians and Hamiltonians
(b) Solve for the motion.
(c) Animate the solution.
6.3 Spherical Pendulum
Consider a pendulum of mass m suspended by a rigid, weightless rod. The motion is not restricted
to a plane. Use the spherical angular coordinates {0, <f>] to describe the motion.
(a) Write the Lagrangian and find the equations of motion.
(b) Find a numerical solution and plot the results.
6.4 Double Pendulum
Consider a double pendulum consisting of a massless rigid rod. The first segment of the rod has
one end fixed and the other supporting a particle of mass ml. The length of this segment is Ll.
Attached to ml is another segment of length L2. At the other end of the second segment is a
another particle of mass m2. Do not assume the motion is confined to a plane.
(a) Write the Lagrangian and find the equations of motion.
(b) Find a numerical solution and plot the results.
6.5 Spring Pendulum
A spring pendulum has a mass m suspended by an elastic spring of stiffness k and force-free
length ID. Do not confine the motion to a plane.
(a) Write the Lagrangian and find the equations of motion.
(b) Find a numerical solution with initial conditions so the mass does not loop over the top. Plot
the solution.
(c) Find a second numerical solution where the pendulum is given sufficient initial angular mo-
motion to rotate over the top. Plot the solution.
6.6 Hamilton-Jacobi in Parabolic Coordinates
A particle of mass m is moving in a force whose potential is v=A/r-B z. This produces a force
that is a combination of a uniform force in the z-direction and an inverse square central force.
(a) Derive the Hamilton-Jacobi equation in parabolic coordinates.
(b) Solve the equations and discuss the solution.
6.7 How Hamilton Works
Explain the details in the steps found in the user-defined function Hamilton.
6.8 How Hamiltonjacobi Works
Explain the details in the steps found in the user-defined function HamiltonJacobi.
6.9 How flrstDiffSeries Works
Explain the details in the steps found in the user-defined function firstDiff Series.
6.10 How flrstOrderPert Works
Explain the details in the steps found in the user-defined function f irstOrderPert.
CHAPTER
7
Orbiting Bodies
7.1 ¦ INTRODUCTION
Two bodies interacting by their mutually attractive force is a classical problem that dates
back to Isaac Newton in 1687. Newton solved the problem for two spherical objects moving
under their mutual gravitational attraction. In 1710 Johann Bernoulli proved that the motion
of one particle with respect to the other is described by a conic section: ellipse, parabola, or
hyperbola. Euler in 1744 elaborated on the details of the two-body problem. The two-body
problem can be reduced to a one-body potential problem.
An obvious extension of two bodies is the three-body problem. The motion of three
bodies due to their mutual gravitational attraction was first studied by Euler in 1776 and
shortly after by Lagrange in 1788. The problem can be simply stated: Consider three par-
particles that move under their mutual gravitational attraction, then, given their initial condi-
conditions, determine their subsequent motion. The three-body problem is often referred to as
the most celebrated of all dynamical problems. One of the reasons that it is so appealing
is because of its deceiving simplicity. However, the system of differential equations cannot
be reduced to quadratures, and hence the problem is not solvable. Numerical solutions are
not sufficient to determine the long-time behavior of the motion.
The three-body problem simplifies if the lightest of the bodies is assumed to have no
effect on the motion of the other two bodies (called primaries). The (circular) restricted
three-body problem treats the motion of an infinitesimal particle due to the gravitational
attraction of two massive primaries moving in circular orbits about one another. The re-
restricted three-body equations take on a very simple form in a frame centered on the center
of mass but rotating at rate o>.
Applications of the restricted three-body problem include the motion of a spacecraft in
the Earth-Moon system, an asteroid motion governed by the gravitational attraction of the
Sun and Jupiter, and the motion of the Earth in the field of the Sun and Jupiter. Another
important application is the motion of small bodies about binary stars. At least half of all
stars in the sky are multiple systems, consisting of two or more stars in orbit about their
common center of mass.
This chapter is divided into two problem sections: 7.2 the Two-Body Problem, and 7.3
the Restricted Three-Body Problem. Exercises are included in section 7.4.
Before starting the problems you might find it convenient to turn off the spell checker:
In[l]:= Off[General :: "spell"];
Off[General :: "spelll"];
377
378 Chapter 7 Orbiting Bodies
7.2 ¦ THE TWO-BODY PROBLEM
7.2.1 ¦ Overview
The two-body problem can be simplified if the center of mass position and relative coordi-
coordinates are chosen to describe the motion. If r x and r 2 are the position vectors to particle
one and particle two then the center of mass vector R and the relative vector r are
-± ~rlml + ~r1m2 - - -
K = r = fi — r 2-
The motion of the center of mass point R moves as a force-free point and can be neglected.
The solution for the relative vector r reduces to a one-body potential problem.
PROBLEM 1 Equivalent One-Body Problem. Consider two mass points mx and m2,
where the interaction is given by a central force expressible by a potential V. V is only a
function of the relative separation r = r x - r 2, where r x and r 2 are the position vectors
to particle one and particle two. Define the center of mass vector R and the relative vector
r by
r - r \~ r 1-
r\
a. Express the relative position vector r in terms of spherical coordinates {rO, 6, <p] and
derive the equations of motion.
b. Place the orbit in the 6=n/2 plane and derive expressions for the conservation of
angular momentum and energy.
c. Letu=i and show the equation for u[0] is
7.2 The Two-Body Problem 379
where h is the conserved angular momentum and V [r] =-f [r].
Remarks and Outline Write the Lagrangian in terms of { r, R} and then express the vec-
vector r in terms of spherical coordinates. The equations of motion follow from applying the
command EulerEquations to the Lagrangian, which is found in the add-on package
Calculus lVariationalMethods V In the 6 = | plane, the equations simplify and
the c/>'' [ t ] equation can be integrated to get the conserved angular momentum. Like-
Likewise, the r'' [t] equation can be integrated to get the energy expression. The conserved
quantities also follow from the add-on command Firstlntegrals. We also require a
relation between Cartesian coordinates and spherical coordinates that is found in the add-
addon package, CalculuslVectorAnalysis *.
Solution
In[2]:= Clear["Global1*"]
a. It is convenient to express the equations in terms of the total mass M0= (m^+n^) and
the reduced mass fi= ™x^? :
{mlm2 i
M0==ml+m2,^== f;
HO J
An expression for mx and m2 in terms of MO and fi follows from eql:
ln[4]:= mSol = Solve[eql, {ml, m2}][[1]]
Out[4]= [ml -» - (mO - VMOVMO - 4/j) ,
The next step is to express the position vectors, ~r1 and r2, in terms of the relative
position vector r and center of mass position vector R. The center of mass and relative
vectors are denned by
ln[5] .-= eq2 = {n[t]
ml rl[t] +m2 r2 [t]
MO
I;
r[t] ==rl[t] -r2[t]};
where R, rl, r2, and r are vectors. The inverse relations follow from
In[6]:= soil=
((Solve [eq2, {rl [t], r2 [t] }] [ [1] ] //.
Rule -» Equal//. {MO -»ml+m2})//
MapAll[Apart,#]&)
380 Chapter 7 Orbiting Bodies
ml
It is more convenient to express these equations as rules and in their pure form:
<¦ \ ml +m2 j
The kinetic energy is
In[8] := T= imlrl'[t]2 + -m2 r2'[t]2;
where rl and r2 are the position vectors for the two particles. The Lagrangian follows
from
In[9]:= La = T - V[rO [t] ] /.rSol/.mSol//Sinplify
Out[9]= - (-2V[rO [t] ] +fjr'[t]2 +M0R'[t]2)
where rSol and mSol have been used to express the results in terms of vectors r and R
and masses MO, and fi.
The transformation of the position vector r from Cartesian coordinates to spherical co-
coordinates follows from the command CoordinatesToCartesian found in the pack-
package
In[10]:= Needs["Calculus'VectorAnalysis•"]
Express the relative position vector r={rO[t] ,0[t] ,0[t]} in terms of spherical
coordinates with rRule:
In[ll]:= rRule =
r -»
((CoordinatesToCartesian[
{rO [#] , 6[#] ,*[#]}, Spherical] //
Evaluate)&)
Out[11]= r^ ({Cos[0[#l]] r0[#l] Sin[S[#l]],
rO[#l] Sin[S[#l]] Sin[0[#l]],
Cos[S[#l] ] rO[#l] }&)
Use Cartesian coordinates to express R in terms of its components {Rx, Ry, Rz}:
ln[12]:= RRule ={R-> ({Rx[#] , Ry [#] , Rz[#] }&) };
7.2 The Two-Body Problem 381
Identify r and R as vectors:
In[13] : = r/ : VectorQ[r] = True; R/ : VectorQ[R] = True;
and replace the notation for the square of a vector with the dot product. A rule to transform
the square of a vector to its vector product is
In[14]:= voctorRulo=
{x_[t_]~2»x[ t].x[ t]/;VectorQ[x],
x_' [t_] ~2 » x' [t] .x' [t] /; VoctorQ [x] } ;
where VectorQ ensures that vectorRule is applied only to vector objects. Illustrate
vectorRule by transforming the Lagrangian:
In[15]:= La//.vectorRule
Out[15]= -(fjr'[t] .r'[t] +M0R'[t] .R'[t] -2V[rO[t] ])
The Lagrangian in terms of its components is
In[16] -.= Lb = La//.vectorRule//.rRule//.RRule//Sinplify
Out[16]= j(-4V[rO[t] ] +2fjrO'[t]2 +
2M0Rx'[t]2 + 2M0Ry'[t]2 +2M0Rz'[t]2 +
2fjrO[t]2e'[t]2 +fJrO[t]20'[t]2-
MCos[2S[t]] rO[t]V[t]2)
The equations for vector R are trivial. Apply EulerEquations found in the add-on
package CalculuslVariationalMethodsl:
:= Noods[-CalculusxVariationalMothodsxn]
to obtain the equations of motion for the center of mass:
In[18]:= EulerEquations [Lb, {Rx[t] , Ry [t] , Rz[t] }, t]
Out [18]= {-M0Rx"[t] ==0,
-MORy" [t] ==0, -MORz" [t] ==0}
These equations of motion are those of a free particle. Without loss of generality, set R =0.
In [19]:= L = Lb/.{Rx-» @&),Ry-» @&) , Rz
Simplify
Out[19]= - (-2V[rO[t] ] +fJ(rO'[t]2
Sir![e[t]]20'[t]2)))
382 Chapter 7 Orbiting Bodies
Note how the components of R were replaced so that R and its derivatives vanish. The
three equations of motion for the relative vector components r={rO [t] ,0[t] ,
follow from EulerEquations:
In [20] : = eqMotion =
(EulerEquations [Lb, {rO[t] , e[t] ,
t]//
Solve[#, {rO" [t] , 6" [t] ,
<t>" [ t ]}]&// Flatten //
Simplify) /.Rule ->Equal;
oqMotion //ColumnForm
v r r o r 111 -> -> ->
rO"[t] == LJ_L+r0[t] (e'[t]2 + Sir![e[t]]20'[t]2)
Out[20]= S"[t] ==-2r0r[0tr]t^ [t] +Cos[9[t]] Sin[e[t]]0'[t]2
r
_r 2(rO'[t] +Cot[S[t]] rO[t] S'[t]H'[t]
0 [t]== ^^
b. The orbit can be oriented in the 6=n/2 plane without loss of generality. Define a rule
to reduce the equations of motion to the plane:
In [21] := eRule = 6 -» GT/2&) ;
Eliminating the 0 variable in the equations of motion, you get
In[22] : = eqjlotion = eqMotion//.eRule;
oqMotion //ColumnForm
Out [22]= True
2rO'[t]0-[t]
L J rO[t]
The 0 equation is automatically satisfied, as verified by True in the second part of eqMo-
tion. The first and third equations in eqMotion can be reduced to first integrals.
The conservation of angular momentum follows from the third equation. Applying
DSolve to the variable rO, you get
In[23]:= dSol=
DSolve[{oqMotion[[3]],
r0[0] ==Sqrt[el/(n0'[O])]},
{rO[t] }, t]//PoworExpand //Flatten
Out[23]= |rO[t]
where the conserved angular momentum el is a constant. We used the initial condition,
el=H r[O]20'[O], to eliminate the integration constant in DSolve. A rule to eliminate
0'[t] from the radial equations follows from solving dSol for 0'[t]:
7.2 The Two-Body Problem 383
In[24]:= tfRule=Solve[dSol/.{Rule- > Equal}, <t>' [t] ] [ [1] ]
Substituting this relation into the first equation of motion given by eqMotion, you get
In[25] : = rEq = eqMotion[ [1] ] /.0Rule//Ej?pandAll
Notice that the r and <f> dependence in the equations of motion has been successfully un-
uncoupled.
The conserved energy is obtained by taking all terms in rEq to the left-hand side, mul-
multiplying by rO' [t], and integrating:
In[26]:= energy = Integrate! (rEq [ [1] ] - rEq[ [2] ] )rO' [t] , t]
el2 V[rO[t] ] 1.
2fj2r0[t]2 n +2
Out[26]- ^ .^[t]] ,1^^
This is the expression for the conservation of energy. Notice that the conserved angular
momentum and energy also follow directly from the command Firstlntegrals:
In[27] := eq3 =
Firstlntegrals[L/.eRule,{rO[t],
t] /. {Firstlntegral [0] -> -el,
Firstlntegral [t] -» En
Rule -»Equal//ExpandAll;
eq3 //ColumnForm
-el==-fjrO[t]V[t]
Out [27]= 1 , 1
Enjj == V[rO[t] ] + - fj rO'[t] 2 + -
or solving for {(/>' [t], En},
ln[28]:= Solve [eq3 , {*'[t], En}]//Flatten//
ExpandAll//ColumnForm
Out[28]= 2^ rOe[t] M 2
c. An equation for u= p is obtained with the rule
Rules to eliminate <j>' and 0" follow from
384 Chapter 7 Orbiting Bodies
In[30] := ^Rulel = {^Rule, D[*Rule, t] } //.uRule //
Flatten
2elu[0[t]]u'[0[t]] 0'
0_[t]_J
Applying uRule and 0Rulel to rEq, you get an equation for u
: = eq3 =
(Solve[rEq//.uRule//.*Rulel,
u"[«[t]]] [[1]]) /.Rule-> Equal/.
*//Simplify
Out[31]. {u[0]+u"[0]==
Finally, replace V [r] with the central force V [r] =-f [r]:
In[32]:= eq4 = eq3//.{V [x_] ->-f[x]}
PROBLEM 2 Kepler Orbits. The orbit equation for a particle moving in a central po-
potential can be expressed as
el u[(f>]
where u = -r. The orbit is assumed to be in the equatorial plane Q=\ and u is considered
a function of the angular variable <p.
a. Solve for u [<p] when the gravitational potential is V=- *. Assume the initial condi-
tionu' [0]=0.
b. Plot the elliptical and hyperbolic orbits.
c. Use the user-defined function dif f SeriesOne, denned next, to get a power series
solution for the u [0] equation. Sum the series to get the exact solution.
Remarks and Outline To solve the problem you must find the expression for the force
from the potential and substitute it into the w-equation. The solution follows from DSolve.
The command PolarPlot is used to graph the solutions. A previously denned series
expansion solution is
7.2 The Two-Body Problem 385
In[33]:= Clear[diffSeriesOne];
diffSeriesOne [eqin., z_, t., order.,
initList.JList] : =
Module [ {eq, zSer, eSer, eqs, vars, sol,
zSol},
eq = eqin[ [1] ] - eqin[ [2] ] = = 0;
zSer = Series [z [t] , {t, 0, order}];
eSer = eq/. (z[t] -> zSer) //ExpandAll;
eqs =
Thread[CoefficientList[eSer[[1]], t] = =
0];
vars =
(Table[D[z[t],{t,j}],
{j, 2,order + 2}]/.t->0);
sol = Solve [eqs, vars] [ [1] ];
zSol = zSer/.sol/.initList;
Return[zSol]
Protect [diffSeriesOne];
Solution
In [34]:= Clear ["Global'*"]
a. Consider the orbit equation
m
In[35]:= eql = u" [<t>] ==--
The force is related to the potential byf[r]=-V [r]. Construct a rule that expresses
f in terms of u for the gravitational potential V=- \:
In[36] :- forceRule = \V -> - —& , f
Substituting the gravitational potential into eql, you get
In[37]:= eq2 = eql//.forceRule
k m
Out [37]= u @) == —- - u @)
Note that to complete the substitution, you must use " / /." and not just " /. ¦. Without
loss of generality, choose the initial condition u' [0] =0. Applying DSolve to eq2, it
follows that
386 Chapter 7 Orbiting Bodies
In [38]:= eq3 =
DSolve[{eq2,u'[0] ==0}, {u[*]},*][ [1] ]//
ExpandAll//Simplify
Out[38]= ju@)-> —j + ciCos(<t>)\
The general form for the orbit can be written u [0] =u0 A+e Cos [0]) if you replace
C[l] withe^:
In[39]:= eq4 = eq3/.C[l] -> ^~^//Simplify
Out[39]= (u@) -» —
It is common to introduce the parameter a denned by fj^ = a{\ -e2) so that the canonical
formofu[0] becomes
In[40] : = eq5 = eq4//. [el -> -\/a(l -e2) k m]
The value of e determines the three kinds of conic sections: A) e>l, hyperbolic; B)
e<l, elliptic; and C) e=l, parabolic.
b. To graph the orbits we use the command PolarPlot found in the add-on package
Graphics * Graphics *:
In[41]:= Needs[-Graphics'Graphics'-]
The definition of the command PolarPlot is
In[42]:= ?PolarPlot
PolarPlot[r, {t, tmin, tmax}] generates a polar plot of r as a function of
t. PolarPlot[{rl, r2, ...}, {t, tmin, tmax}] plots each of the ri as a func-
function of t on the same graph. More...
Define a general graphic function for the orbit:
In[43] : = plotOrbit [a_, e_, opts...] : =
PolarPlot[a(l -e~2)/(l + eCos[<*>]),
{<t>, 0, 2 7r},opts,
DisplayFunction -> Identity];
Consider the list of elliptical orbits for e between 0.1 and 0.9:
In[44]:= list = Table[plotOrbit[1, eln,
PlotStyle-* {Thickness [0.008],
Hue[eln]}], {eln, 0.1, 0.9,0.2} ];
7.2 The Two-Body Problem
Displaying the results, it follows
In[45] := Show[list , Display-Function->
$DisplayFunction];
387
To plot a hyperbolic path, you use the same command but with e>l (e=l. 3):
In[46] := plotOrbit[l, 1.3, DisplayFunction- > $DisplayPunction] ;
c. Use the user-defined function dif f SeriesOne, defined at the beginning of this
problem under Remarks and Outline, to derive a power series solution for eq2:
In [47]:= eq2
k m
Out [47]= u"@) == -p--u@)
To agree with the initial conditions in part a let
In[48] := initial = (u'[0] -> 0,u[0] -> -—-—-=—-]•;
I el2 J
Applying dif f SeriesOne to eq2, you get
In[49]:= seriesSol=
dif f SeriesOne [eq2, u, <t>, 6, initial] //
Nonnal//ExpandAll
Out[49]= -
ek m06 ek
+
720 el'' 24 el''
ek mf ekm km
el2 + el2
388 Chapter 7 Orbiting Bodies
Notice that the general expression for terms with e in front follow from
In[50]:= cterm[n_] = -= ;
el2 B n) !
Verify this general expansion for the first five terms:
In[51]:= seriesSol= = I ^-f + Sum[cterm[i] , {i, 0, 3}] J
Out[51]= True
Summing the series solution, you get the exact answer:
- 00
In[52] : = answer = —? + } cterm[n] //Power Expand//
©I • Z I
n=0
Simplify
outf52;= km(eCosW+l)
This result agrees with the answer given in part a.
In[53] := (u[0]/.eq4) == answer
Out [53]= True
PROBLEM 3 Precessing Ellipse. The orbit equation for a particle moving in a central
potential can be written as
L' J j? r til LTJ
elzu[4>Y
where « = 7 and el is the conserved angular momentum. The orbit is assumed to be in the
equatorial plane 8' = |, and u is considered a function of the angular variable c/>.
a. Solve for u [0] when the potential is V = -^ - *. Express the solution in the form
of a precessing ellipse
a(l - e1)
b. Graph the results.
c. Use the user-defined function f irstOrderPert to find the first-order perturbative
solution in the parameter b. Show that the result agrees with the expansion of the
solution derived in part a. The user-defined function f irstOrderPert is denned
below.
Remarks and Outline Find the expression for the force in terms of u. Substituting the
force relation into the equations of motion, DSolve yields the solution. The command
7.2 The Two-Body Problem 389
ParametricPlot is used to graph the solutions. The perturbative solution follows from
firstOrderPert:
In[54]:= firstOrderPert [eql_, x_, {xO_, vO_}, eps_ :eps, t_ it] : =
Module [{xRule, eq2, eqEps, initConO,
initConl, dsoll, dsol2},
XRule = {x-> (x[0] [#] +epsx[l] [#]&)};
eq2 =eql[[l]] - eql[[2]]/.xRule;
eqEps = CoefficientList[eq2, eps] == 0//Thread;
initConO = {x[0] [0] = =x0, (x[0])'[0] == vO};
initConl = {x[l] [0] == 0, (x[l])'[0] == 0};
dsoll= (DSolve[Join[{eqEps[[1]]},initConO],
{x[0] [t]},t]//Flatten);
dsol2 = (DSolve[Join[{eqEps[ [2] ] }, initConl] //.
dsoll, {x[l] [t]},t]//Flatten);
Return [x [ t ]/. xRule//.
Join [dsoll, dsol2] ]
];
Protect[firstOrderPert];
The command firstOrderPert returns the first order correction to the term with co-
coefficient eps.
Solution
In[55]:= Clear["Global'*"]
a. Consider the orbit equation
In[56] := eql = u" [<t>] == —;
©,
The force is related to the potential by f [r] =-V [r]. The rule that finds f from the
potential is
In[57] := forceRule = {v-> I - —
{v-> I -
Substituting the forceRule into eql, you get
In[58]:= eq2 = eql//.forceRule//ExpandAll
Applying DSolve to eq2, it follows
In [59] .-= eq3 =
(DSolve[{eq2,u'[0] == 0} ,u[«],«]) //
Simplify //Flatten
390 Chapter 7 Orbiting Bodies
k m+ (el2 - 2bm] c1 Cos
Out[59]=
-2bm
This expression can be written in the form uO A+e Cos [ A-AH]). Without loss of
generality you can choose C [ 1 ] to be
In[60]: = CRule=
;
el^ - 2bm
uSol = eq3/.CRule//Simplify
k m
Out [60]= u@)
eCos
el* -2bm
The expression for A follows from the argument in Cos or A-A) = e/2tm¦ If we
define the rule
r Vel2 - 2bm
[
then it follows
In[62] := eq3/.CRule/.shif tRule//PullSinplify
„,.„, r ... k m(eCos@-A0) + 1) I
Out [62]= u 0) -» -=
L el^ - 2bm J
You can also introduce the parameter a, denned by the rule
In[63]:= olRulo=
Solve [( 2km = * ), ell [ [
Llel2-2bm a(l-e2)J J
2]] //Simplify
Out[63]= {el^ M2b-a (e2-l) k) m}
The final form of the orbit is
In[64]:= eq3/.CRule/.shiftRule/.elRule//
Simplify
r eCos ld> - Ad>) + 1 ~\
Out[64]= u@) -» ~ ^
a(e2-l)
b. A user-defined function to plot the orbit r = 1+e^Z{_L^ is
7.2 The Two-Body Problem
391
In[65] := plotorbit [start., finish., {a_, e_, A.},
opts—] :=
ParametricPlot
r a(l-e2)Cos[»]
ll + eCos[(l -A) <t>] '
-'i'Si°M )//Evaluate,
l + eCos[(l-A) <t>] J
{<t>, start, finish}, opts ]
If you let the values {a,e,A}be
In[66] := values = { 1, 0.5, 0.1 };
then the plot of the orbit is
In[67]: = plotorbit [0, 67r, values,
PlotStyle-* {Thickness[0.008], Hue[0.8]}] ;
The resulting curve is a precessing ellipse.
c. Use the user-defined function f irstOrderPert to solve eq2
In[68]:= eq2
Out[68]= u"(
km 2 bu ld>) m
+^P
to first order in the parameter b. Applying f irstOrderPert to eq2 with the initial
conditions u [ 0 ] = ^rff^ and u' [ 0 ] = 0, it follows
In[69]:= eq4 =
firstOrderPert
[eq2,u,
A + e) k m
,0},
el2 -2bm
To,4>] +O[b]2//Normal//Simplify//
Out[69]=
Expand
2bkm2 2bekCos@)m2
el4 el4
bek0Sin@)m2 km ekCos@)m
el4
el2
el
2
392 Chapter 7 Orbiting Bodies
where we have kept terms to first order in b. This is to be compared with the exact solution
In[70]:=
k m
Out [70] =
eCos
el1* -2bm
expanded to first order in b,
= eq5 =
(u[*]/.uSol) +O[b]2//Normal//
ExpandAll// PowerExpand
el el
bek$Sin@)m2 k m ekCos@)m
el3 +~^}+ el=
which is in agreement with the perturbative solution given by eq4:
In[72] := eq4 == eq5//Sinq?lify
Out[72]= True
PROBLEM 4 Numerical Solution. Consider the numerical solution of the orbit equa-
equation
hzu[c/>Y
a. Assume the Keplerian potential V = -* and numerically solve the equation with
initial conditions that correspond to an ellipse and to a hyperbola. Plot both solutions.
b. Make a user-defined function that automatically solves and plots the orbit equation.
Apply the plot procedure to the Kepler potential and to the two classes of potentials
denned below:
(a) V = —^ and V = --?,,
(b) V = -\ - ± and V = -\ + ?.
Remarks and Outline The numerical solution follows from NDSolve. The choice of
the initial conditions determines whether the orbit is an ellipse or hyperbola. Use the com-
command PolarPlot, found in the add-on package GraphicslGraphicsl, to graph the
results.
Solution
In[73] := Clear["Global• *"]
7.2 The Two-Body Problem 393
a. Consider the orbit equation
In[74]:= eql =u"[<fr] == / 2
el2u[*]2
and find the numerical solution of eql for the Kepler potential V = -*. The force f
expressed in terms of u follows from the rule
|V -> I - ?-s] , f f-^
<¦ \ #1 / Lu[0]
ln[75]:= forceRule = |V -> I - ?-s] , f f-^-1 -> -V [r] ,
< \ #1 / Lu[0] J
Substituting the f orceRule in eql, you get
In[76]:= eq2=eql//.forceRule
Out[76]= u"[0] == —f -u[0]
Choose the parameters.
ln[77] := values = {k-» 1, el-» 1, m-» 1};
You obtain an ellipse if the initial conditions are chosen to be
In [78]:= initiall = u[0] ==1.6,u'[0] == 0;
The numerical solution of eq2 is
In[79]:= ndsoll=
NDSolve[{eq2Avalues, initiall}//
Flatten, u [<t>], {*, 0, 2 7r} ] //Flatten;
For convenience, define the function ul [0] to be the solution for the ellipse case
In[80]:= ul[*_] =u[*]/.ndsoll; ul[l.l]
Out[80]= 1.27216
where ul was evaluated at a sample point to verify that the solution was properly obtained.
The plot of r as a function of 0 follows from applying PolarPlot to ^. The command
PolarPlot is found in the add-on package
In[81]:= Needs["Graphics'Graphics-"]
The plot of the orbit follows
In[82] := PolarPlot f —-//Evaluate, {<t>, 0, 27r}l ;
Lul[<f>] J
394
Chapter 7 Orbiting Bodies
Hyperbolic orbits follow from the initial conditions:
In[83]:= initial2 = {u[0] ==3,u'[0] ==0};
Again applying NDSolve to eq2, you get
In[84]:= ndsol2 =
NDSolve[{eq2/.values, initial2}//
Flatten, u[*], {*, 0, 2 7r}]//Flatten;
Define the function u2 [0] to be the solution for the hyperbolic case:
In[85]:= U2 [*.] = u[*]//.ndsol2; u2[1.1]
Out[85]= 1.90719
The plot of r is
In[86] := PolarPlot f -—//Evaluate, {*, 0, 2 7r}l ;
L u2 [0] J
7.2 The Two-Body Problem 395
b. The routine for plotting the numerical solution can be summarized in four steps:
1. Find the force from the potential and express it in terms of u.
2. Make a list of the orbit equations and initial conditions.
3. Numerically solve the orbit equation.
4. Use PolarPlot to generate the graphics.
These four steps are combined in the user-defined command numOrbit:
In[87]:= numOrbit [V., r_, {rO. :l,drO_ :0,el_ :l,m_ : 1}, angle., opts ] : =
Module[{u, <f>, uforce, eql, initial, eqs, ndsol},
uforce = -D[V, r]/.r-» l/u[*];
eql = (u"[*] ==-u[*] -muforce/(elu[*])//
ExpandAll);
initial = {u[0] == l/rO,u'[O] == -drO/rO~2};
eqs = Join[{eql},initial];
ndsol = NDSolve [eqs, u[0], {<t>, 0, angle}] //Flatten;
PolarPlot [l/u[>] /.ndsol//Evaluate,
{<t>, 0, angle}, opts,
Display-Function -» Identity]
where uforce represents the force as a function of V [1/u]; eql is the equation of
motion for u; initial contains the initial conditions; eqs is the collection of equations for
NDSolve whose solution is ndsol. The command PolarPlot graphs r=l/u. Note
that default values for rO, drO, el, m, and angle are incorporated. It is assumed that the
add-on package GraphicslGraphicsl has been activated.
Applying numOrbit to the Kepler potential, you get
In[88] := numOrbit [ - -, r, {0.6, 0, 1, 1}, 27T,
PlotStyle-* {Thickness[0.008], Hue [0.6]},
DisplayFunction -» $DisplayFunctionl ;
396
Chapter 7 Orbiting Bodies
Compare the orbits for V=- -^ and V=- -J^:
In[89]:= lista =
numOrbit[#, r, {0.6, 0, 1, 1}, 67T,
PlotStylo-> {Thickness[0.008]
Hue[0.6] {^^
In[90]:= Show[GraphicsArray[lista]];
The curve on the left precesses in a counterclockwise direction and the one on the right
precesses in a clockwise direction.
Similarly, the orbits for V=- ^ - ^ and V=- \ + ^ with b=0.02 are
In[91]:= listb =
numOrbit[#, r, {0.6, 0, 1, 1}, 67T,
PlotStylo -» {Thicknoss[0.008],
Huo[0.6]} ]&/»
r 0.02 1 0.02 l-i
In[92]:= Show[6raphicsArray[listb]];
7.3 ¦ RESTRICTED THREE-BODY PROBLEM
7.3.1 ¦ Overview of the Three-Body Problem and Initialization of PMotion and Mgraph
The equations of motion for three bodies moving under their mutual gravitational attraction
are
7.3 Restricted Three-Body Problem 397
d2 r, m*,G^ m^G-
r
13'
M2 M3
~7pT ~ ~T~ r2i + ~T~ r23
d2r3 mxG^
~HT = ~3~~ r3i + —3- r32
"' M3 *23
where the relative vectors are rn = r2- r x, r13 = r3- rl5 r23 = r3- r2, r(-y- = -ry7
and G is the gravitational constant. The increase in complexity when the third body is
introduced can be explained by the increase in the number of variables. The total number
of equations is nine. This number is reduced if the position vectors are measured relative
to the center of mass, located at ml r x + m2 r 2 + m3 r 3 =0. This constraint gives three
equations and reduces the number of equations to six. Further simplicity is obtained for
the special case of orbits lying in a fixed plane—the order is reduced to only 6-2 = 4
equations. Even for this special case the three-body problem is a complicated nonlinear
problem. The system of differential equations cannot be reduced to quadratures, and hence
the problem is not solvable.
The three-body problem simplifies if the lightest of the bodies is assumed to have no
affect on the motion of the other two bodies (called primaries). The (circular) restricted
three-body problem treats the motion of an infinitesimal particle due to the gravitational
attraction of two massive primaries moving on circular orbits about one another. We take
m2> to be the infinitesimal mass so it does not influence the motion of ml and ml, but is
affected by them in the usual way:
d
2
d
2
~HT = ~J~ r3i + —3- r32
at rn 723
The description for the motion of the primaries follows from the two-body problem. We
assume that ml and ml undergo circular motion with a constant angular velocity o>. The
primaries rotate about their center of mass with an angular frequency to2 = ™, where L is
the separation between the two massive bodies and M = ml + ml. We restrict the motion,
without loss of generality, by requiring the motion of ml and ml to be in the {x, y] plane.
The restricted three-body equations take on a very simple form in a frame centered on
the center of mass but rotating at rate o>. If {X, Y} are coordinates in the nonrotating frame
and {x, y] are coordinates in the rotating frame, then the coordinate systems are related by
X=x Cos[iot]-y
Y=x Sin[a)t]+y
398 Chapter 7 Orbiting Bodies
The primaries will be at rest in the rotating frame with their mutual gravitational attrac-
attraction balanced by the outward "push" of centrifugal force.
We place the primaries on the x-axis. Let ml be located at {xl, 0} and m2 at {x2,0} and
restrict the motion of m3 to be in the {x, y} plane. The equations of motion for the infinites-
infinitesimal particle in the rotating frame centered on the center of mass of the two primaries
are
x»W - WW -aAtf] = S^-*]) + Gm2(x2-xW
y w+w w - ^i = Gml(ylryM) + Gm2(y2ryM)
where rl = yj(x-x\f +y2 and r2 = yj(x-x2J +y2.
Without loss of generality we can pick units so that ml + m2 = \,L= 1 (separation of
the massive particles) and G = 1. With this choice of units the angular frequency of the
primaries becomes to = 1. We also call the smaller primary mass m2 = fi so the larger
primary mass becomes ml = 1 - fi, where fi < \. In these dimensionless units the mass
ml is located at {-fi, 0} and m2 at {1 - fi, 0}. The equations of motion become
y"M + 2 Jt'W-yM = -A ^
rl3 r23
where rl = ^(x[t] + nJ + y[tf and r2 = j(x[t] - 1 + fiJ + y[tf.
The equations of motion admit a first integral known as the Jacobian integral, which is
analogous to the conservation of energy. This first integral is
C = -(x'[t]2+y'[t]2) + 2U
where U = \(x[t~\2 + y[t~\2) + ? + ^. The constant C is the Jacobian constant of inte-
integration, which is constant throughout the motion. The effective potential U includes the
gravitational potential ^ + 7^ and a term representing the position-dependent centrifugal
force j(x[?]2 + y|/]2). The equations of motion, expressed in terms of the potential, are
x"[t]-2y'[t]=dxU
y"[t]+2x'[t]=dyU
The equilibrium positions follow from the solution of the two equations dxU = 0 and
dyU = 0. These stationary points are called Lagrangian points. If the infinitesimal parti-
particle is placed at one of these Lagrangian points with zero velocity, it will remain at rest
in the rotating coordinates—the stationary points co-rotate with the primaries. There are
five Lagrangian positions {LI, 12,13, L4, L5}: three Lagrangian points (LI, L2, L3) are
collinear with the primary masses and the other two points, L4 and L5, form equilateral
triangles with the primary masses.
7.3 Restricted Three-Body Problem 399
In this section we consider several numerical examples of the restricted three-body prob-
problem. There is no difficulty in numerically integrating the equations to find the trajectories
for finite time durations. There are problems, however, when the details of the trajectories
are needed for long time intervals. Computers cannot offer solutions for arbitrarily long
times of the gravitational three-body problem.
It is useful to create user-defined procedures for the calculations that are used in more
than one problem in this section. There are two user-defined procedures that are used re-
repeatedly for the restricted three-body problem. The user-defined procedures are PMotion
and Mgraph. The procedure PMotion returns an interpolating function for the solution
of the restricted three-body problem:
In[93]:= PMotion [ill., {xO_, yO., vxO., vyO_}, trnax., step. : 1000] : =
Module [{mile, Urule, eqMotion, rl, r2, p., U},
rrule = {rl -> yj (n + x[t]J +y[t]2,
r2->-\/(-l + fi + x[t]J + y[t]2};
Urule = {u^ ^ + ? + | (x[t]2 +y[t]2)};
eqMotion = {x" [t] -2y'[t] == D[U/.Urule/.rrule, x[t] ],
y"[t] +2x'[t] = =D[U/.Urule/.rrule,y[t]]};
NDSolvo [ {oqMotion/.^i -» \i\, x[0] ==x0,
y[0] ==y0,x'[0] ==vx0,y'[0] ==vy0}//
Flatten, {x, y}, {t, 0, tmax},
MaxSteps -> step] //Flatten j
The procedure Mgraph graphs the point {fx [t], fy [t]}:
In[94]:= Mgraph[fx., fy_, t_, tfinal_, Qpts—] : =
ParametricPlot[{fx[t], fy[t] }//Evaluate,
{t, 0, tfinal},
Qpts,
AspectRatio -»Automatic,
Display-Function -» Identity];
Finally, we apply Protect to the user-defined procedures to keep them from being
deleted with Clear [ "Globall * " ]:
In [95] : = Protect [PMotion, Mgraph] ;
7.3.2 ¦ Problems on the Equal Mass Primaries (// = 1/2)
PROBLEM 1 Lagrangian Points for Equal Mass Binaries (// = 1/2). Consider the
restricted three-body problem when the binary system has equal masses (jj. =1/2). The
motion with fi = 1/ 2 is generally known as the Copenhagen problem. The Jacobian integral
is C= -{x'[tf + y'[tf )+2\J where U= \{x[tf + y[tf) + ? + ^. The Lagrangian points
follow from the solution of the two equations dxU =0 and dyU =0.
400 Chapter 7 Orbiting Bodies
a. Numerically solve for the five Lagrangian points when fi =1/2. Observe that three
Lagrangian points are collinear and two are triangular. Show that the triangular points
and primaries form an equilateral triangle. Plot the Lagrangian positions.
b. For an arbitrary fi, show the exact solutions for the two triangular positions, L [4]
and L[5], are x=+l/2 A-/O and y= ±^. To simplify the calculation use the
observation from part a that the triangular points and primaries form an equilateral
triangle.
c. Make a contour plot in the {x,y} plane for the Jacobian first integral where the
velocity has been set equal to zero. Include the Lagrangian points with the zero-
velocity contours.
Solution
In[96]:= Clear["Global* *"]
a. Let us solve for the five Lagrangian points when fi = 1 / 2. Since x and y are constant,
the positions are determined by the two equations dxU=0 and dyU=0, where U is given by
ln[97]:= Urule = U-> ^p + i^ + | (x[t]2+y[t]2);
and rl and r2 are
In[98] := rrule = [rl -> yj (n + x[t]) 2 +y[t]2.
r2 -» V(-l + K
Taking the x and y partial derivatives of U, it follows
In[99]:= (eql = D[U/.Urule/.rrule, x[t] ] == 0)//TraditionalForm
(eq2 = D[U/.Urule/.rrule, y[t] ] == 0) //TraditionalForm
Out[99]= x(t) -
(<
((fJ + X(t)
^x(t)J
fjy(t
x(t) -IJ
(i-M)
+ x(t)
-iJ
+ x(t)
+ y(t)
)
+ y(t)
y(t)
-i)
+ y(tJ)
)
2j3/2
2\3/2
rr-rr +\
3/2
n
((fj + x(t)J+y(tJ)
Setting fi =\ and using NSolve to obtain a numerical solution, you get five positions
7.3 Restricted Three-Body Problem 401
In[100]:= {L[2],L[3],L[4],L[5],L[1]} =
{eql, eq2}/.fi->^//
NSolve[#, {x[t],y[t]}]fc;
ColumnForm
{y[t] -+0., x[t] -» 1.19841}
{y[t] -»0., x[t] -»-1.19841}
Out[100]= {y[t] -+-0.866025, x[t] -» 0.}
{y[t] -» 0.866025, x[t] -» 0.}
{y[t] ->0.,x[t] ->0.}
The individual positions are labeled L [i]. The set of coordinates is called CLpt:
In[101]:= CLpt = L[#]&/9 Range[5] ;
These points correspond to the positions where the attractive gravitational force from the
primaries just balance the centrifugal force.
The three Lagrangian points on the x-axis (y[t]=0), {L[1], L[2], L3}, called
the collinear positions, are located at:
In[102]:=
TabloForm[#, TableHeadings
{x[t],y[t]}}]&
x[t] y[t]
L[3] -1.19841 0.
The two points L [ 2 ] and L [ 3 ] lie on the x-axis and are outside the two masses and the
inner Lagrangian point, L [ 1], lies between the two masses. Each of the points, L [ 1],
L [ 2 ], and L [ 3 ], is an unstable equilibrium point. For example, if a particle is displaced
from L[2] (or L[3]) further from the primary, then the inward gravitational attraction
is reduced and centrifugal term is increased; consequently, the test particle will accelerate
outward. Moving a test particle from L [ 2 ] (or L [ 3 ]) toward the primary will increase the
attractive force and reduce the centrifugal force and the test particle will accelerate toward
the primary. A similar discussion holds for L [ 1].
The remaining two Lagrangian points are off the x-axis. In this particular example they
are on the y-axis.
In[103]:= {L[4],L[5]}//ColumnForm
-0-866025,x[t]^0.}
Out [103]=
{y[t] ^0.866025, x[t] ^0.}
Notice the distance from the primaries to L [ 4 ] or L [ 5 ] are equal and of unit length
402 Chapter 7 Orbiting Bodies
In[104] := rl == x2 == l/.rrule/.L[4] /./i -> 1/2
Out [104]= True
The Lagrangian points L[4] and L[5] form equilateral triangles with the primaries.
These two Lagrangian positions are known as the triangular points.
The graphics for all five Lagrangian points follow from
In [105]:= Lgrapfa =
Graphics[
{{PointSize[0.02], Hue[0.9],
Map[Point, {x[t] , y [t] }/.CLpt ] } ,
Text[L# , {x[t] +0.1,y[t]}/.
CLpt[[#]] ]&/9Range[5]}];
Combine these graphic points with the graphics for an equilateral triangle and the posi-
positions of the primaries:
In[106]:= equilateral=
Graphics[
{{PointSize[0.02], Point[{-1/2, 0} ],
Point[{l/2, 0} ]},
{Thickness[0.002], Hue[0.4],
Line[ {{-1/2, 0} , {x[t],y[t]}/.L[4],
{1/2,0},{-1/2,0},
{x[t],y[t]}/.L[5] ,{1/2,0}}] },
Text[L# , {x[t] +0.1,y[t]}/.
CLpt[[#]] ]&/9Range[5]}];
Combining the graphics and displaying the results, it follows that
In [101]:= Show [Lgraph, equilateral,
AspectRatio -»Automatic ];
•L3
b. Consider an arbitrary fi and solve for the triangular positions L[4] and L[5]. To
simplify the derivation, take the suggestion from part a and assume rl and r2 are equal
7.3 Restricted Three-Body Problem 403
and of unit length:
In [108]:= eq3 =rl == r2 == 1/.rrule
Out [108]= ^(fj + x[t]J +y[t]2 ==
Solving eq3 for x [ t ] and y [ t ], you find
In[109] := eq4 =Solve[eq3, {x[t],y[t]} ,
InverseFunctions -»True]
Out[109]= {{ ^ }
{y[t] ->^,x[t] ^i(i-2fJ)}}
To verify that these are indeed Lagrangian points, substitute them into eql and eq2,
:= {eql, eq2}/.eq4//Sijis>lify
Out[110]= {{True, True}, {True, True}}
c. The equations for the restricted three-body problem admit the following first integral
In [111] := jacobi = C == -(x' [t]2 +yr [t]2j + 2 U/.
Urulo
Out[111]= C==2
This relation is known as the Jacobian integral and the constant C is called the Jacobian
constant.
Let us graph the zero-velocity contours. The zero velocity curves follow from setting
x' [t] and y' [t] to zero in the Jacobian integral. The plot of the zero velocity contour
lines for/i =1/2 is
In[112]:= j acGC = ContourPlot[
2 U /.Urule/.rrule/.n -»1/2//
Evaluate,
{x[t],-2, 2}, {y[t],-2,2},
ContourShading -» False,
Contours -» Range [3, 4.5,0.1],
PlotPoints -» 66,
DisplayFunction -» Identity ] ;
If we combine these zero velocity contours with the graphic for the Lagrangian points
and equilateral triangle, then it follows that
404
Chapter 7 Orbiting Bodies
In[113] := Show[jacGC, Lgraph, equilateral,
DisplayFunction -» $DisplayFnnction ] ;
-1.5 -1 -0.5 0 0.5 1 1.5
The motion for an infinitesimal particle can only exist in those regions of the {x, y}
plane for which C-2 U<0 orx'[tf+y'[tf> 0. George W. Hill A878) introduced the idea
of zero velocity curves and established the possible and forbidden regions of motion. Such
a qualitative result is important because its validity is independent of the time duration.
The two triangular points are located in the oval-shaped areas near the top and bottom
of the figure. The figure-eight areas around the primaries represent equipotential surfaces
for the binary stars. In a binary system, as one of the stars evolves, it will expand to fill
successively larger equipotential surfaces. The appearance of a binary star system depends
on which equipotential surfaces are filled by the stars. If one star expands enough to fill
the figure-eight contour out to the inner Lagrangian point, then its atmospheric gases can
escape through the point and be drawn toward its companion. The boundary of the figure-
eight region is called the Roche lobe.
PROBLEM 2 Looping Motion in an Equal Mass Binary System (// = 1/2). Assume
equal mass primaries and explore the different kinds of "looping" orbits around one of the
primaries.
a. Let the starting conditions be x[0]=0.3, x' [0]=0, andy[0]=0. Adjust y' [0]
until you get a retrograde elliptical orbit (Hint: Try y' [ 0 ] = 1 • 7 81). Plot the results
in rotating and nonrotating coordinates.
b. Start the motion atx[0]=1.35, x' [0]=0, y[0]=0 and adjusty' [0] until you
achieve a double loop (Hint: Try y' [ 0] =-1.568). Plot the results in rotating and
nonrotating coordinates.
c. Consider the multi-loop path that follows fromx [ 0] =-0.0114, y [ 0 ] =0, x' [ 0] =0,
y' [0]=+1.537. Plot the results in rotating coordinates.
7.3 Restricted Three-Body Problem
Solution
405
In[114]:= Clear["Global«*n]
a. After several trial and error attempts you find that the initial conditions for an ellip-
elliptical orbit are x[0] =0.3, x' [0]=0, andy[0]=0, andy' [0] =1.781. The numerical
solution for the path follows from the user-defined function PMotion given at the start of
the chapter, where fi is the mass, {x0,y0,vx0,vy0} are the initial conditions, tmax is
the time interval, and step is the number of steps in the differential equation. It follows
from the user-defined function PMotion that the path is
In[115]:= sol=PMotion[1/2, {0.3, 0, 0, 1.781 }, 67T, 1000] ;
where sol contains the interpolating functions for {x,y}. The time duration of t.=6n
corresponds to 3 orbits of the primary stars. The coordinates for the test body are
:= fx[t.]
fy[t_]
x[t]/.sol;
y[t]/.sol;
The graphic for the path in the rotating frame follows from the user-defined function
Mgraph, given at the start of the chapter.
ln[117] := ptl = Mgraph[fx, fy, t, 67T ,
PlotPoints-» 100,
PlotStylo -» Hue [0.9],
AspectRatio -»Automatic,
Epilog -» {AbsolutePointSize [7],
Point[{1/2,0}]},
DisplayFunction -» $DisplayFunction];
0.2
0.1
-0.1
-0.2
406
Chapter 7 Orbiting Bodies
The particle is trapped in the potential well about one of the primaries. It makes a com-
complete orbit in a time of t«0.7, which corresponds to 1/9 of the primary's period or tas^1.
The orbit is an elliptical-like path but there is structure in the band as seen from magnifying
a portion of the orbit
:= Show[ptl,
PlotRango -> {{0.692, 0.709},
{-0.01, 0.01}}, Ticks -> False];
What does the orbit look like in the nonrotating coordinates{x, Y}? The nonrotating
and rotating coordinates are related by
X[t] = x[t] Cos[t]-y[t] Sin
Y[t]=x[t]Sin[t]+y[t]Cos[t]
Let us plot the path in the inertial frame over a time duration of one binary orbit, t=27r:
In[119]:= ParametricPlot[
|{|cos[t], | Sin[t] J,
2 2
{fx[t]Cos[t] -fy[t] Sin[t],
fx[t] Sin[t] + fy[t] Cos[t]}]//Evaluate,
{t, 0, 27T},
PlotStylo-* {GrayLovol[0.3], Huo[0.6] } ,
AspoctRatio -»Automatic I;
7.3 Restricted Three-Body Problem
407
The path forms a retrograde epicycle around the primary and makes nine loops for every
one orbit of the primary. The circle is the path of the primaries rotating around the center
of mass located at the origin.
b. After several trials it follows that the initial conditions for a double loop are
x[0]=1.35, y[0]=0, x' [0]=0, and y' [0]=-1.568. The user-defined function
PMotion returns the interpolating functions for the path,
In[120]: = sol = PMotion[1/2, {1.35,0,0,-1.568},
10 7T, 1000]
Out [120]= {x -» InterpolatingFunction [
{{0., 31.4159}}, <>] ,
y -»InterpolatingFunction [
{{0.,31.4159}}, <>]}
where the time duration of t=10 n corresponds to five orbits of the primary stars. The
coordinates for the test body are
:= fx[t_] : = x[t]/.sol;
fy[t_] : = y[t]/.sol;
The graphics for the path in the rotating frame follow from Mgraph:
In [122] := Mgraph[fx, fy, t, 10 7T,
PlotPoints-* 100,
Plotstylo ->Hue [0.8],
PlotRange-> {{-0.5,1.5}, {-1,1}},
Epilog -> {AbsolutePointSize [7] ,
Point[{l/2,0}] },
DisplayFunction -» $DisplayFunction];
408
Chapter 7 Orbiting Bodies
0.25 0?5 0.75 1 1.21 1.5
The particle forms a retrograde double loop that takes about ta2n to make one complete
double loop.
What does the orbit look like in inertial coordinates {x, Y}? The path in nonrotating
coordinates for one and five rotations of the binaries follow from
In[123] := ptl =
ParametricPlot[
, - Sin[t] },
1.35{Cos[t], Sin[t] },
l.l{Cos[t], Sin[t] },
{fx[t]Cos[t] -fy[t] Sin[t],
fx[t] Sin[t] +fy[t] Cos[t]}J//
Evaluate,
{t, O,#tt},
PlotStylo -> {GrayLovol [0.3],
Hue[0.6],Hue[0.9]},
AspectRatio -»Automatic,
DisplayFunction -»Identity
Displaying the results, it follows
In[124]:= Show[GraphicsArray[ptl]];
7.3 Restricted Three-Body Problem
409
These graphs show the double looping path in the inertial frame. The path on the left
is for one binary rotation and the one on the right is for five rotations. The inner circle
corresponds to the orbits of the primary rotating around the center of mass. The outer two
circles are the envelopes for the small and large loops.
c. Let the initial conditions be x[0]=-0.01112, y[0]=0, x' [0]=0, andy' [0] =
-1.538 and use the user-defined function PMotion to solve for the path's interpolating
functions
In[125]:= sol = PMotion [1/2,
{-0.01112 , 0, 0, +1.538}, 107T, 1000]
Out [125]= {x -» InterpolatingFunction [
{{0.,31.4159}}, <>],
y -»InterpolatingFunction [
{{0., 31.4159}}, <>]}
where the time duration of t=107r corresponds to five orbits of the primary stars. The
coordinates for the test body are
In[126]:= fx[t_] :=x[t]/.sol;
fy[t_] :=y[t]/.sol;
and the path in the rotating coordinates is
In[127]:= Mgraph[fx, fy, t, 10 7r,
PlotPoints-* 100,
PlotStylo-»Huo[0.6] ,
Epilog -> {AbsolutoPointSizo [7] ,
Point[{1/2, 0}]},
DisplayFunction -» $DisplayFunction] ;
0.4
0.2
-0.2
-0.4
The path takes about t« 2n to make one complete cycle.
410 Chapter 7 Orbiting Bodies
PROBLEM 3 Symmetric Orbits about the y-Axis for fi = 1/2. Assume fi =1/2
and consider an orbit that is symmetric about the y-axis. Start the trajectory at x @) =0,
y[0]=0.12067, x' [0]=-l. 0600745428 andy' [0]=0. Plot the results in the ro-
rotating frame.
Solution
In[128]:= Clear["Global'*"]
Consider the path
In[129]:= sol = PMotion[l/2,
{ 0, 0.12067 , -1.06007 , 0 }, 67T,
1000] ;
where the duration is for three orbits of the primaries. The coordinates for the test body are
In[130]:= fx[t_] :=x[t]/.sol;
fy[t_] :=y[t]/.solf
Recall from a previous problem that the Lagrange points were at
In[131]: = CLpt =
{y[t] -> 0.,x[t] -> -1.1984},
{y[t] -»0.,x[t] -> 1.1984},
{y[t] ->0.866,x[t] ->0.},
{y[t] ->-0.866,x[t] ->0.}};
so the path follows from
In[132] := Hgrapfa[fx, fy, t, 6n,
PlotPoints -» 100,
PlotStylo -» Hue [0.8],
Epilog -» {AbsolutoPointSizo [7] ,
Point [{1/2,0} ], Point [{-1/2, 0} ],
Point[{x[t],y[t]}/.CLpt[[#]] ]&/9
Range [4] },
DisplayFunction -» $DisplayFunction];
7.3 Restricted Three-Body Problem
411
Notice that more fine-tuning needs to be done on the initial conditions to make them
perfectly symmetric. The orbit is outside both of the primaries but encloses the Lagrangian
points L [ 2 ], L [ 3 ], and L [ 4 ]. If you integrate the path for long enough times the numer-
numerical errors will accumulate and the particle will escape.
PROBLEM 4 Mass Exchange between Equal Mass Binaries. Consider two equal
mass binary stars where the secondary binary has expanded and fills its Roche lobe. Its
atmospheric gases can escape through the inner Lagrangian point and "fall" toward its
companion.
a. Solve for the path of a particular trajectory that starts from rest just to the right of the
inner Lagrangian point and plot its orbit. Determine the Jacobian constant and plot
the path along with its zero-velocity contour.
b. Increase the initial speed x' [0] until the orbit is exchanged from one primary to
the other. Plot the orbit.
Solution
In[133]:= Clear["Global'*"]
a. Let the initial conditions be x[0] =0.044, y[0]=0, x'[0]=0, y'[0]=0
and use the user-defined function PMotion to solve for the path:
In[134] .- = sol = PMotion[l/2, {0.044 ,0,0,0},
8, 1000] i
The coordinates for the test body are
In[135]:= fx[t_] : = x[t]/.sol;
fy[t-] :=y[t]/.sol;
and the graphics for the path in the rotating frame follow from Mgraph
412
Chapter 7 Orbiting Bodies
In[136] := ptl = Mgraph[fx, fy, t, 8 ,
PlotPoints-* 100,
Plotstylo -> Hue [0.8] ,
Epilog -> {AbsolutoPointSizo [7] ,
Point[{0, 0}] ,Point[{l/2, 0}]},
DisplayFunction -» $DisplayFunction] ;
where the dot at the origin is the inner Lagrangian point and the other dot is the primary.
The "falling" test particle approaches the primary from behind and then orbits the primary
in a co-rotating path.
The value of the Jacobian constant follows from
In[137]:= jacobi = C == - (x'[t]2 + y'[t]2) +2 U;
where U, rl, and r2 are given by
In[138]:= Umle = U-> ^^ + — + | (x[t]2 +y[t]2);
In[139]:= rmle = {rl -> ^ (n + x[t] J +y [t]2.
r2
Evaluating the parameters, it follows that
In[140]:= I jacobi/.Urule/.rrule/.\i- >-/.
y[t] ->0/.x'[t] ->0/.x[
Oat[140]= 4.03315
0.044/.y'[t] -> 0 J [[2]]
The plot of several zero-velocity contours near this value and the path for the test particle
follow from
7.3 Restricted Three-Body Problem
413
In[141] := pt2 = ContourPlot [ 2 U /.Urule/.rrule/.fi -> 1/2//
Evaluate,
ContourShading -» False,
AspectRatio -»Automatic,
Contours -> { 4.033, 3.9 , 3.5 },
PlotPoints -> 66,
The inner contour is for C=4 • 033.
The matter spills through the inner Lagrangian point and spirals around the primary
star if the star is sufficiently small so the orbit misses striking the primary's surface. The
streaming mass forms an accretion disk of hot gas in the orbital plane. However, around a
"real" binary system the viscosity causes the orbiting gases to lose energy and slowly spiral
toward the primary. The gas is heated throughout its descent as the lost orbital energy
is converted into thermal energy. Finally, the plunging gas ends its journey at the star's
surface.
b. If the initial kinetic energy is sufficiently large the particle can escape from the pri-
primary. If you set x[0] =0.044 andy' [0]=0.6, then the path follows from
In[142]:= sol = PMotion[l/2, {0.044,0,0.6,0 },
35,4000] ;
The coordinates for the test body are
In[143]:= fx[t_] : = x[t]/.sol;
fy[t-] : = y[t]/.sol;
The graphics for the path in the rotating frame follow from Mgraph,
In[144] .- = ptl = Mgraph[fx, fy, t, 35 ,
PlotPoints -> 100, PlotStyle -> Hue [0.8] ];
The plot of the orbit, along with the enveloping zero-velocity contours, is
414
Chapter 7 Orbiting Bodies
In[145]: = pt2 = ContourPlot[
2 u /. Urule/.rrule/.f* ->1/2//
Evaluate,
{x[t],-l.l, 1.1}, {y[t],-0.6,0.6}.
Contour Shading -» False,
AspectRatio -»Automatic,
Contours -> {4, 3.6105, 3.5, 3.4,3.3},
PlotPoints -> 66,
The initial kinetic energy is sufficiently large so that the particle jumps in a "chaotic"
fashion between the Roche lobes surrounding the two primaries.
7.3.2.7 ¦ Problems on the Sun-Jupiter System (fi = .000954)
¦
PROBLEM 5 Lagrangian Points for the Sun-Jupiter System. We seek the Lagrangian
points and zero-velocity surface for the Sun-Jupiter System (ji =0.000954).
a. Make a contour plot of the zero velocity surface.
b. The Lagrangian points follow from the solution of the two equations dxU=0 and
dyU=0. Find the Lagrangian points and plot the results with the zero velocity surface.
Solution
In[146] : = Clear [ "Global» * "]
a. The potential and Jacobian integral are
In[147] := Urule = U->
^^ + — + -(x[t]2 +y[t]2);
2
jacobi = C== -(x'[t]2 +y'[t]2) +2 U /.Urule;
The zero velocity curves follow from setting x' [t] andy' [t] to zero. Plotting the zero
velocity contour lines for fi =0.000954, you get
In[148]:= rrule =
r2 -
[t] J + y[t] 2,
n + x[t]J+y[t]2} ;
7.3 Restricted Three-Body Problem
In [149] : = jacGJ = ContourPlot [
2 U /.Urule/.rrule/.fi-» 0.000954//
Evaluate,
{x[t], -1.2,1.2}, {y[t]#-1.2,1.2}.
Contourshading -»False ,
Contours -» Range[3, 3.05 , 0.01],
PlotPoints -> 150 ] i
415
0.5
-0.5
-1 -0.5 0 0.5 1
The large white area represents the gravitational well around the Sun and the smaller
circular area represents the gravitational well around Jupiter.
b. The triangular Lagrangian points follow from the exact analytic expressions
In[150]:= {L[5],L[4]} =
{x[t] -»i(l-2/i
{11-* 0.000954}
Out[150]= {{x[t] -» 0.499046, y[t]
(x[t] -» 0.499046, y[t]
L [ 4 ] and L [ 5 ] are located 60 degrees ahead of and behind Jupiter.
The collinear points, on the other hand, follow from setting y=0 in the two equations
416 Chapter 7 Orbiting Bodies
In[151] : = eql =
D[U /.Urule/.rrule, x[t]] ==0/.
H-> 0.000954/.y[t] -> 0
eq2 =
D[U /.Urule/.rrule, y[t] ] == 0 /.
fi-»0.000954/.y[t] -> 0
Out[151]= °-000954(-°-999046+x[t]) ,
( (-0.999046 +x[t]JK/2
0.999046@.000954 +x[t] )
( @.000954 +x[t] J)
0ut[151]= True
The only relevant equation is eql. Solving for x, it follows
In [152] : = eq3 =
FindRoot [eql [ [1] ] /. n -» 0 .000954/.
y[t] ->0, {x[t], #}]&/8{l, 0.9,-1}
Out[152]= {{x[t] -» 1.06883},
{x[t] ^0.932363}, {x[t] -»-1.0004}}
The coordinates for L [ 1], L[2],andL[3] are
In[153]:= {L[3] , L[l] , L[2] } =
Outer [List, eq3, {y[t] ->0}]//
Flatten//Partition[#, 2]&
Out[153]= {{x[t] -> 1.06883, y[t] -> 0},
{x[t] -> 0.932363, y[t] -> 0},
{x[t] ->-1.0004, y[t] ->0}}
The coordinates for the complete set of Lagrangian points are
In[154] := JLpt = L[#]& /» Range [5] ;
JLpt //ColumnForm
{x[t] -» 0.932363, y[t] -> 0}
{x[t] -» -1.0004, y[t] -» 0}
{x[t] -» 1.06883, y[t] ^0}
Out [154]= , ^31
|x[t] -» 0.499046, y[t] -» ^-[
[x[t] -» 0.499046, y[t] -»- —}
The graphics for these points and the positions of the primary bodies follow from
7.3 Restricted Three-Body Problem 417
In [155] := Lgrapfa =
Graphics[
{PointSize[0.02],
{Point [{ii, 0}], Point [{1-fi, 0}]},
{PointSize[0.02], Hue[0.9],
Map[Point, {x[t] , y[t] }/.JLpt ] },
Text[L# , {x[t] ,y[t] +0.1}/.
JLpt [[#]]]&/» Range [5]
}
]/.fi-» 0.000954 i
Combining the Lagrangian points, primary positions, and zero velocity contours, you
get
In [156] : = Show [ j acGJ, Lgraph ] ;
0.5
-0.5
-1
-0.5
0.5
The Trojan asteroids occupy the L[4] and L[5] equilibrium points. They are on the
same orbit as Jupiter and either lead or trail the planet by 60 degrees. These asteroids are
located in the potential wells that are established by the combined influence of the Sun and
Jupiter.
PROBLEM 6 Numerical Solution for the Trojan Asteroids. In the Sun-Jupiter system
the Lagrangian points L [ 4 ] and L [ 5 ] are called Trojan points because the Trojan asteroid
group are near these points. Consider those orbits that revolve around L [ 4 ]. Start the orbits
with zero velocity and pick the initial {x,y} positions along the arc x=R Cos [0] and
y=R Sin[0] where R= ±-^3 + (l -2fif.
a. Pick 6 so the orbit encloses just L [ 4 ]. Plot the tadpole-shaped orbit and superimpose
the zero-velocity contours on the graph.
418 Chapter 7 Orbiting Bodies
b. Pick 8 so that the orbit encloses L[4], L[2], and L[5]. Plot the horseshoe-
shaped orbit.
Solution
In[157]:= Clear["Global'*"]
a. Consider the bound motion near L[4]. Start the orbits with zero velocity and
pick the initial {x,y} positions along the arc x=R Cos [0] and y=R Sin [0], where
R=5-y3 + A -2fiJ and8 is arbitrary. The initial conditions {x[0], y[0], x'[0],
y'[O]}are:
In[158]:= initial=
{RCos[6], R Sin[6], 0, 0}/.
R- > -"^3+ (l-2fO2/.fi- > 0.000954
2
Out[158]= {0.999523Cos[9] , 0.999523 Sin[S] , 0, 0}
If you let 8 be 35 degrees, then the orbit follows from
In[159]:= sol = PMotion[0.000953875 ,
initial/.e->35° //Flatten,
200, 1000];
Define the coordinates for the test body
In[160]:= fx[t-] := x[t]/.sol ;
fy[t-] :=y[t]/.sol;
so the path about L [4 ] follows from
In[161] := ptl = Mgraph[fx, fy, t, 200 ,
PlotPoints -» 100, PlotStylo -» Hue[0.8] ];
Let us combine the graphics for the orbit with the zero velocity contours and Lagrangian
points. The rule for the potential and primary positions are
In[162] := Urule = U -> ^^ + — + - (x[t]2 +y[t]2);
rl r2 2 \ /
In [163]:= rrule = {rl -> -^(fi+x[t]J +y[t]2.
r2
and the graphics for the zero velocity contours follow from
7.3 Restricted Three-Body Problem 419
In[164]:= j acGJ = ContourPlot[
2 U /.Urule/.rrule/.f* -> 0.000954//
Evaluate,
{x[t], -1.2, 1.2} , {y[t], -1.2 , 1.2 } ,
ContourShading -» False ,
Contours -» Range[3, 3.05, 0.01],
PlotPoints -> 150 ,
DisplayFunction ->Identity];
The Lagrangian points are at
In [165] := Jlipt =
{{x[t] ->0.9324,y[t] ->0},
{x[t] ->-1.0004, y[t] ->0},
{x[t] ->1.0688,y[t] ->0},
{x[t] -»0.499,y[t] -»^}.
{x[t] ->0.499,y[t] -»-^}};
so the graphics and text for these points become
In [166] : = Lgraph =
Graphics[
{PointSize[0.02],
{Point [{n, 0}], Point [{l-/i, 0}]},
{PointSize [0.02] , Hue [0 .9] ,
Map [Point, {x[t],y[t]}/.JLpt]},
Text[L, , {x[t] ,y[t] +0.1}/.
JLpt[[#]] ]&/8Rango[5]
}
] /.^-> 0.000954;
Combining all the graphics and displaying the results, we get
In[167]:= Show [ j acGJ, ptl, Lgraph,
PlotRange -» {{-0.3, 1.2}, {0, 1.2}} ,
DisplayFunction -» $DisplayFunction];
420
Chapter 7 Orbiting Bodies
0.2
-0.2 0 0.2 0.4 0.6 0.8 1
A close look at the tadpole path shows that it has short and long period terms.
ln[168]:= Show[ptl,
PlotRange- > {{0.5,0.85}, {0.55,0.9}},
Ticks ->False,
Display-Function -» $DisplayFunction];
b. Consider orbits that enclose L [ 5 ], L [ 2 ], and L [ 4 ] by decreasing the value of 0.
If you let 0 be 20 degrees then the orbit is
In[169] := sol = PMotion[ 0.000953875 ,
initial/.e-» 20° //Flatten,
200, 1000] i
where the coordinates follow from
7.3 Restricted Three-Body Problem
421
In[170]:= fx[t_] :=x[t]/.sol;
fy[t_] :=y[t]/.sol;
Combining the graphics for the path with the Lagrangian points, it follows from the
user-defined function Mgraph that
In[171] := Mgraph[fx, fy, t, 160 ,
PlotPoints -> 100,
PlotStyle -> Hue [0.8] ,
Epilog -» Lgraph [ [ 1] ] ,
Display-Function -» $DisplayFunction ] ;
By changing the initial displacement, the path in the co-rotating frame goes from a
tadpole-shaped curve to a horseshoe-shaped path.
PROBLEM 7 Perturbative Solution for the Trojan Asteroids. Consider a small dis-
displacement Y->Y0+ijy[t] and x-+x0+r]x[t~\, where {x0#y0} is the position of L[4] and
ijy[t] and r\x\t\ are assumed to be small displacements.
a. Show the restricted three-body equations reduce to the linear equations
3
r,x"W = -
rjy[t]
3a/3
b. Solve the linearized equations and show for the Sun-Jupiter system that the L [ 4 ]
point is stable.
422 Chapter 7 Orbiting Bodies
c. Show the Trojan orbits consist of two harmonics, one with a long period and the
other with a short period.
d. Consider a small displacement and plot the perturbative orbit. Compare the pertur-
bative orbit with an equivalent numerical calculation.
Solution
In [172] :
a. The
ln[173]:
= Clear[
distances
= rrule =
"Global»*"]
from the primaries
= (rl -»-y A1 + x[t])
to the test body are
2+y[t]2,
If you define the restricted three-body potential
In[174] := Urule = D -» —^ + — + - (x[t]2 +
then the equations of motion become
In[175]:= oqMotion=
{x"[t]-2y-[t] ==
D[U/.Urule/.rrule , x[t] ] ,
y"[t] +2x'[t] ==
D[U/. Urule/.rrule , y[t] ] };
oqMotion // ColumnForm//TraditionalForm
\l (n +x(t) - 1)
x"(t) -2^A) ==x(t) -
-1) +y(t) |
) (
Out [175]= ((^;x(t)J+y(tJK/2
-D2+y(tJ) '
1-H) y t)
Ta +y(t)
Consider a small displacement about the L [4 ] point. Let
In [17 6] := pert =
{y-> (yO + Tyy[#]&),
x -» (xO + 77X [#]&)} ;
where rjx[t~\ and 7/y^] are assumed to be small displacements. The values of {x0#y0} are
the coordinates for L [4 ] and are given by
In[177] := zeropt = (xO -> - A - 2 n) , yO -» — J;
Expressing the equations of motion in terms of r\x\t\ and ijy[t], you find
7.3 Restricted Three-Body Problem 423
In[178]:= eql = eqMotion/.pert;
If you expand eql around r\x\t\ and rjy[t\ and keep only first order terms, you get
In [179] := eqPer =
((MapAt[ Series [# , {77x[t] , 0, 1},
{77Y[t] , 0, 1}]&,
eql [ [#] ] /.zeropt , 2] //Normal //
ExpandAll) /.77x[t] ?7y[t] -> 0
)&/» {1,2};
eqPer //ColumnForm
-2rjy'[t] + rjx"[t] == ^^t^WW -|V3fjr7y[t]
Out [179] = 3 J A3 n 9rjy[t]
4 2 4
These are the linearized equations for small displacements about the L [4 ] point.
b. These linearized equations can be solved exactly. To simplify the results, assume
initial conditions with zero initial velocity. The solution is
In[180] := perSol =
{rp?[t],77y[t]}/.
DSolvo[
{eqPer, 77X[O] == xi, 77y[O] == yi,
rjx' [0] == 0, rtf [0] == 0}//Flatten,
{77x[t] , 77y[t] }, t]//Flatten ;
The output has been suppressed because it is too long.
Inspecting the previous output, it is clear that the linearized equations contain two ex-
exponential terms of the form Exp [Cll t ] and Exp [H2 t ], where ill and ?12 are given
by
~ ~ \ V1 "
:= {?21, ?22} = [J~ ~ \ V1 " 27" + 21 ^
2 2 y
For oscillatory or stable motion ?11 and ?12 must be purely imaginary. This is the case
for Jupiter.
In[182]:= {?21, ?22}/. \i -> 0.000954
Out [182]= {0.996757 1,0.0804692 1}
In fact, the motion is stable for fi < 0.03852.
c. The Trojan orbits are certainly stable and consist of a long and short period. The two
frequencies are
424 Chapter 7 Orbiting Bodies
In[183]:= Abs[{?21, ?22}/.fi -> 0.000954]
Out[183]= {0.996757,0.0804692}
If Jupiter's period is taken to be 11.86 years then these frequencies correspond to a short
and long period.
ln[184]:= 11M{-±-.
Out[184]= {11.8957yrs/147.329yrs}
The oscillation with the long period is called a libration.
d. Consider a small displacement about L [4], y-^y0+rfy[t] and x->x0+T]x[t], where
the value of {x0#y0} is
In[185]:= zeropt/.fJ -» 0.000954
Out[185]= [xO -> 0.499046, yO -» —}
Assume the initial conditions for jtx[O], J/x'tO], 7jry[0], rjy' [0] are 0 . 0 0 01, 0, 0.0001,
0, respectively. It follows that the perturbative solution x [ t ] , y 11 ] is
In [186] : = trojanpert =
{o.499 +perSol[[l]],
{xi-» 0.0001, yi-» 0.0001}/.
\i -> 0.000954 //ExpandAll //
ExpToTrig // chop ;
troj anport//Short[#,6]&
Out[186]= [o.499 + 0.000307997 Cos[0.0804692 t]-
0.000207997 Cos[0.996757 t] +
0.00893036 Sin[0.0804692t]-
0.000720956 Sin[0.996757t],
V3
+ «5» + 0.000416031 Sin [0.996757 t]}
where we displayed only a few of the terms. The plot of the path is
In [187] .= ptl = ParametricPlot [
trojanport //Evaluate, {t, 0, 80} ] ;
7.3 Restricted Three-Body Problem
425
0.872
This agrees fairly well with the numerical calculation. The equivalent numerical solu-
solution follows from
In[188] := nSol = PMotion f 0.000954, [0.499 + 0.0001, ^— + 0.0001, 0,0 }//
Flatten, 80, lOOol ;
The coordinates for the test body are
In[189]:= fx[t_] := x[t]/.nSol;
fy[t-] :=y[t]/.nSol;
and the path about L [4 ] is
In[190] ;= Mgraph[fx, fy, t, 80 ,
PlotPoints -> 100,
PlotStyle -» {Hue [0.8], Thickness [0.01],
.03}]},
DisplayFunction -» $DisplayFunction ];
where the dashed curve is the numerical solution and the continuous curve is the perturba-
perturbation solution.
426 Chapter 7 Orbiting Bodies
7.3.3 ¦ Problems on the Earth-Moon System D1 = .01215)
PROBLEM 8 Lagrangian Points for the Earth-Moon System. Consider the La-
Lagrangian positions for the Earth-Moon system (jj. =0.01215). The Lagrangian points,
{L[l], L[2], L[3]# L[4]# L [5]} follow from the solution of the two equations
dxU=0 and dyU=0.
a. Make a plot of the zero velocity surface.
b. Use NDSolve to solve for the five Lagrangian positions: three collinear and two
triangular. Superimpose the points on the zero velocity surface and plot the results.
Solution
In[191]:- Clear["Global'*"]
a. The zero velocity surface follows from the Jacobian integral
In[192]:= Urule = U-> ^^ + -^ + ^ (x[t]2 +y[t]2);
In[193]:= jacobi = C== - (x'[t]2 + y'[t]2) +2 U/.Urule
0ut[193]= C== 2
rl r2 2
x'[t]2-y'[t]2
where C is the Jacobian constant. The values for rl and r2 are given by the rule rrule,
In [194] .= rrule = {rl -> -^(ji + xtt]J + y[t]2,
r2 -»A/(-l + Ji + x[t]J2}
The zero velocity curves follow from setting x' [t] and y' [t] to zero in jacobi. The
plot of the zero velocity contour lines with n =0.01215 is
In[195]:= jacGE = ContourPlot[
2u /.Urule/.rrule/.(/-» 0.01215//
Evaluate,
{x[t], -1.2, 1.2} , {y[t], -1.2, 1.2 },
ContourShading -> False,
Contours -» Range[3, 3.55, 0.05],
PlotPoints -» 150 ];
7.3 Restricted Three-Body Problem
427
0.5
-0.5
-1 -0.5 0 0.5 1
The large white area represents the gravitational well around the Earth and the smaller
oval-shaped area represents the gravitational well around the Moon.
b. Let us solve for the five Lagrangian points with ju = 0.01215. The positions follow
from solving the two equations dxU=0 aaddyU=0 forx[t] andy[t]:
In[196]:= eql = D[U/.anile/.rrule, x[t] ] ==0
eq2 = D[U/.Urule/.rrule, y [t] ] ==0
Out[196]= x[t] -
(-l+^+x[t]J+y[t]^)
1 -n) (n + x[t] )
,x[t]J+y[t]2K/2
2K/2
= = 0
Out[196]- y[t] -
-l + ^+x[t]J+y[t]2K/2
(l-fi)y[t] _ __
m — — U
y[t]
2\3/2
The collinear Lagrangian points, {L[1],L[2],L[3]}, follow from setting y=0 in
eql and eq2. The only relevant equation is eql. Setting y=0 in eql and using Find-
Root to get a solution for x, you get
In [197]:= eq3 =
FindRoot [eql [ [1] ] /.u -> 0 .01215 /.
y[t] ^0, {x[t], #}]& /0{1, 0.9,-1}
Out[197]= {{x[t] -»1.15568},
{x[t] ^0.836918}, {x[t] -»-l.00506}}
If you include the y=0 values for these three x values, the coordinates for L[l],
L[2],andL[3] are
428 Chapter 7 Orbiting Bodies
In [198]: =
Outer [List, eq3, {y[t] ->0}]//
Flatten//Partition[#, 2]6
Out[198]= {{x[t] -»1.15568,y[t] ^0},
{x[t] -> 0.836918, y[t] ->0},
{x[t] -> -1.00506, y[t] ->0}}
The triangular Lagrangian points, L [4 ] and L [5 ], were solved for the general case in
a previous problem and are
In [199] := eq4 =
{x[t] ->f
Evaluating L [4] andL [5] for ju =0.01215, you get
In[200] := {L[4], L[5]} = eq4/.fi-> 0.01215
r r V3 i
Out[200]= {{x[t] -> 0.48785, y[t] ->- — \,
[x[t] -> 0.48785, y[t] -> -5-}}
L [4] and L [5] are stable points. An object placed at these points, 60 degrees ahead
of and behind the moon at the radius of its orbit, will remain at the same point with respect
to the moon. The complete set of Lagrangian points are summarized with LptE:
ln[201]:= LptE = L[#]&/0Ranse[5] ;
Let us graph the Lagrangian points. The graphics follow from
In [202]:= Lgraph =
Graphics[
{PointSize[0.02],
{Point [{fi, 0}], Point [{1-ji, 0}] },
{PointSize[0.02], Hue[0.9],
Hap[Point, {x[t],y[t]}/.LptE]}
] /.(/-> 0.01215;
Combining the Lagrangian points with the Jacobian contours and displaying the results,
you get
In[203]:= Show[ jacGE, Lsraph ];
7.3 Restricted Three-Body Problem
429
0.5
-0.5
-1 -0.5 0 0.5 1
PROBLEM 9 Motion about L[4] in the Earth-Moon System. Consider a small dis-
displacement about the L [4] point, y -> yO+ijy[t] and x -> xO+ T]x[t], where {x0#y0}
is the position of L [4 ] and rjy[t] and rjx[t] are assumed to be small. The linear three-body
equations are
-2rjy'[t]
rjy[t]
The L[4] point is at xO=0.48785 and y0=^. Consider an initial displacement
?7y[0]=0.0001 and 7;jc[0]=0 .0001 and plot the motion. Compare the perturbative orbit
with the equivalent numerical calculation.
Solution
In[204]; = Clear["Global'* "]
The linear equations of motion expressed in terms of rjx[t] and rjy[t] follow from
In [205]:= eqPer =
{-2OY'[t]
The solution of the linearized equations can be solved exactly (this takes a few minutes):
430
Chapter 7 Orbiting Bodies
In[206]:= perSol =
, Oy[t] }/.
DSolve[{eqPer, ?7x[0] ==0.0001,
i7y[0] == 0.0001, rjx' [0] == 0,
rjy'IO] == 0}//Platten,
{»7«[t],rjy[t]}#t
]/.*/-> 0.01215//Flatten//
Expan<SAll//ExpToTris //Simplify //
Chop;
We've suppressed the output as it is rather lengthy.
The L [4] position {x0#y0} follows from
In[207] := zeropt = (x0-> - (l-
—
U-> 0.01215
Out[207]= {xO^ 0.48785, yO ^ —^}
so the perturbative solution is
In[208] :- positions {x0,y0} + perSol/. zeropt;
We've suppressed the output as it is rather lengthy.
The perturbative solution consists of a long and short period. The plot of the solution
follows from
In[209] :- ptl = ParametricPlot [position//Evaluate,
0. 4840. 489D.486D. 487). 4880. 489
Let us compare the perturbative solution with the equivalent numerical solution. The
numerical solution follows from
In[210]:= nSol = PMotion [ 0.01215,
{o.48785 + 0.0001, — + 0.0001, 0, o}//
Flatten, 80, lOOol
7.3 Restricted Three-Body Problem
Out [210]= {x-> InterpolatingFunction[{{0., 80.}}, <>] , y ->
InterpolatingFunction[{{0., 80.}}, <>] }
The coordinates for the test body are
:= fx[t_] :=x[t]/.nSol ;
fy[t_] :=y[t]/.nSol;
so the path about L [4] is
ln[212]:= Msraph[fx, fy, t, 80 ,
PlotPoints -> 100,
PlotStyle -> {Thickness[0.008],
Dashing[{0.05}],Hue[0.8] },
Display-Function -» $DisplayFunction,
E4»iloB->ptl[[l]] ];
431
0. 4840. 483). 4860. 487). 4880. 489
The heavy dashed curve is the numerical calculation and the continuous curve is the
perturbative solution. The two solutions are in good agreement.
PROBLEM 10 Orbit around the Earth and Moon. Consider a periodic orbit that ro-
rotates around both the Earth and the Moon. Choose the initial conditions to be x0=0.8,
vx0#=0# y0=0# andvy0=-1.14. Plot the orbit in the rotating and nonrotating frames.
Solution
In[213]:= Clear["Global'*"]
The Earth-Moon orbit with initial conditions x0=0.8, vx0#=0# y0=0# andvy0=
-1.14 is
In[214]:= sol = PMotion[0.01215, {1.2,0 , 0, -1.5 },
2tt,3000] ;
and the coordinates for the test body are
432
Chapter 7 Orbiting Bodies
In[215]:= fx[t_] :=x[t]/.sol;
fy[t.] : = y[t]/.sol;
The orbit for the test particle in the rotating frame is
In [216] := ptl = Mgraph[fx, fy, t, 2n,
PlotPoints -> 100,
PlotStyle -> Hue [0.8] ,
DisplayFunction -» $DisplayPunction ];
and the curve in the inertial frame is
In[217]:= ParametricPlot[
{{Cos[t], Sin[t] },
{fx[t]cos[t] -fy[t] Sin[t],
fx[t]Sin[t] +fy[t]cos[t]}}//
Evaluate,
{t, 0, 2n},
PlotStyle -» {GrayLevel [0.3], Hue [0.6],
Hue[0.9]},
AspectRatio -»Automatic];
7.4 Exercises 433
7.4 ¦ EXERCISES
The solutions to many of these exercises can be found at our web sites.
7.1 Central Force Problems
A particle is acted on by a central force with a potential v=-^r-, where a and b are positive
constants.
(a) Use potential and phase diagrams to discuss the nature of the motion.
(b) Find the solution for circular orbits.
(c) Find the period for small radial oscillations about the circular motion.
7.2 Central Force Procedure
Consider a particle acted on by a central force with potential V [r]. Write a procedure that:
(a) Plots the potential.
(b) Finds the extremum points.
(c) Returns the solution for the circular orbits.
(d) Finds the perturbative orbit for a small displacement around the circular motion.
7.3 Central Forces and Elliptical Solutions
A particle is acted on by a central force where the potential is of the form V=ar1+" and n= {+5,
+3, 0# -4# -5# -7}.
(a) Plot the effective potential and discuss the motion.
(b) Show that the solutions can be reduced to elliptical functions.
(c) Expand the solution in a power series and compare the results with the power series that
follows from the elliptical solutions.
7.4 Attractive Inverse Fifth Power Force
Consider the motion of a particle described by a circular orbit under the influence of an attractive
central force directed toward a point on the circle.
(a) Show that the force varies as the inverse fifth power of the distance.
(b) Show that for the orbit described the total energy of the particle is zero.
(c) Find the period of the motion.
(d) Find xf and / as a function of angle around the circle and show that the quantities are infinite
as the particle goes through the center of force.
7.5 Eccentric Anomaly
Consider the expression for elliptical orbit r = ^^Ja that follows from a radial force
f [r] =--p. The eccentric anomaly if/ is defined by r=a(l- e Cos[tA]).
(a) If (x> =+[-K then show a) t=d/- e Sin [d/l.
y ma
(b) Show that tan [f ] =-^f tan [f]
(c) Expand iff in a series about e.
(d) Show that i/f = u> t +ZZi 2J»lne]nsinl""], where /„ is a Bessel function of order n.
7.6 Eccentric Anomaly
Show that for elliptical motion in a gravitational field the radial speed can be written as
r ' = —-Ja2e2 - (r - aJ
434 Chapter 7 Orbiting Bodies
Introduce the eccentric anomaly variable iff and show that the resulting differential equation in i//
can be integrated immediately to give Kepler's equation.
7.7 Kepler Problem with Drag
A uniform distribution of dust in the solar system adds to the Sun's gravitational attraction on a
planet an additional radial force of the form - m C r, where m is the mass of the planet, C is
a constant, and r is the radius vector from the sun to the planet. This additional force is small
compared to the direct Sun-planet gravitational force.
(a) Calculate the period for a circular orbit of radius rO for a planet in this combined field.
(b) Calculate the period of radial oscillations for slight disturbances from a circular orbit.
(c) Show that nearly circular orbits can be approximated by precessing ellipses and find the
precessional frequency.
7.8 Lagrange Points
Show the points L [4] and L [5] are stable equilibrium points if// < 0.03852.
7.9 Orbit around the Sun and Jupiter
Consider a periodic orbit that rotates around both Jupiter and the Sun. Set the initial conditions
xO=l. 22, vxO'=0 ,y0=0, and vyO=-l. 012 and plot the orbit in rotating and nonrotating
frames.
7.10 Exact Solution for the Three-Body Problem
An example of a known exact three-body solution is that of three equal-mass objects orbiting in
an equilateral triangular configuration with sides L under the attraction of their mutual gravita-
gravitational field. Show that it is a solution if the rate of rotation is a>2= ^r2.
CHAPTER
8
Electrostatics
8.1 ¦ INTRODUCTION
Electrostatics is the basis of electrodynamics and is the study of time-independent distri-
distributions of charges and fields. Chapter 8 is divided into three problem sections: 8.2, Point
Charges, Multipoles, and Image Charges, 8.3, Laplace's Equation in Cartesian and Cylin-
Cylindrical Coordinates, and 8.4, Laplace's Equation in Spherical Coordinates. At the beginning
of each section is an overview of the physics and a list of user-defined Mathematica proce-
procedures that are used in the section. Before you start the problems, the user-defined function
found at the beginning of this chapter under Mathematica Commands for All Sections, and
user-defined procedures listed at beginning of the individual sections, should be activated.
Exercises are included in section 8.5. The problems in this chapter were chosen to illus-
illustrate Mathematica's analytic and graphic abilities when applied to vector and scalar field
problems. The level of the problems is appropriate for the typical advanced undergraduate
or beginning graduate student. The methods used to solve these problems are not unique.
You are encouraged to find procedures that will illuminate the physics or to find other
commands that speed up the calculations.
When an infinitesimal electric charge experiences a force, we say an electric field exists.
The electric field is a vector equal to the force per unit charge acting on a positive charge
placed auhat point. If an arbitrary charge q is placed in an electric field E, it will experience
a force F given by F = qE. The electric field is described by an irrotational vector field,
V x E = 0. A fundamental property of the electric field is described by Gauss's equation.
If the charges lie interior to a closed surface S, then the total charge Q enclosed by S is
related to the electric field by J E ¦ dS = AnQ. The differential form of Gauss's law is
V • E = Anp, where p is the charge density. The electric field can also be expressed as an
integral over the charge density:
¦/
It is often simpler to deal with scalar fields than with vector fields. The vector electric field
is related to a scalar potential by the equation E = -VU, where V is the gradient operator.
In terms of a charge density, the scalar potential is At/ = -Anp. This equation is known
as Poisson's equation. It follows that At/ = 0 in a region in which the charge density
is zero. This equation is called Laplace's equation. The problem of finding the potential
435
436 Chapter 8 Electrostatics
corresponds to that of finding the solution to either Laplace's or Poisson's equation that
satisfy the boundary conditions for the problem.
You may wish to turn off the spell checker before starting this chapter:
In[l]:= Off[General :: spell]; Off[General :: spelll];
8.1.0.1 ¦ Mathematics Commands for All Sections
VEPlot It is useful to create a user-defined procedure for those calculations that are used
repeatedly in all three sections. You will find it useful to view the equipotential lines (V)
and the electric field lines (E) on the same plot. This procedure uses the command Plot-
GradientField found in the package Graphics * PlotGradientField V Load
the package
In[2] := NeedsfGraphics^PlotField1"]
and define the procedure VEPlot:
In[3]:= VEPlot [potential,, xlim_, ylim_, opts ] : =
Module[{plotl,plot2},
plotl=PlotGradientField[-potential,
xlim, ylim, scaleFunction -» A6),
Display-Function -» Identity];
plot2 = Contourplot [potential, xlim,
ylim, contourShading -» False,
ContourSmoothinjj -» True,
DisplayFunction -> Identity,
PlotPoints -> 50];
Show[ {plotl, plot2}, opts,
DisplayFunction -> $DisplayFunction ] ];
VEPlot [potential., opts ] : =
VEPlot [potential, {x, -1.1, 1.1},
{y, -1.1, 1.1}, opts]
VEPlot graphs the electric field and equipotential surfaces. The range follows from
xlim={x,a,b} and ylim={y#a#b}. The default for the range is {x# -1.1,1.1}
and {y, -1.1,1.1}. Note that we plot the negative of the potential in PlotGradi-
PlotGradientField so that the vector lines point in the direction that a positive test charge would
move. VEPlot simply combines the plot of the equipotential lines obtained from Con-
tourPlot with the electric field obtained from PlotGradientField. It is not nec-
necessary to understand the details of this user-defined procedure until you have done all the
problems; then you can go back and examine the procedure. To understand it in detail, go
through the steps one at a time. Try to make the procedure more time-efficient, add default
conditions, and add options to the procedure.
Finally we apply Protect to the user-defined procedure to keep it from being deleted
with Clear [ "Globall * " ]:
In[4]:= Protect[VEPlot];
8.2 Point Charges, Multipoles, and Image Charges
437
EXAMPLE 1 Equipotential Surface and Electric Field of Two-Point Charges. Con-
Consider the equipotential surfaces and electric field of a dipole:
In[5]:- dipole =
In [61:= VEPlot[dipole,
E4>ilos->{{Hue[0.3], Disk[{0, 1/2}, 0.1]},
{Hue[0.95], Disk[{0, -1/2}, 0.1]}}];
The top disk is the negative charge and the bottom disk is the positive charge.
8.2 ¦ POINT CHARGES, MULTIPOLES, AND IMAGE CHARGES
8.2.1 ¦ Overview
The specific formula for the potential created by a point charge is
V =
where xo(i) are the Cartesian coordinates for the location of the charge and x(i) are the
Cartesian coordinates for the field position. Arbitrary charge distributions can always be
represented by a sum of point charges. This superposition principle is used repeatedly in
this section.
A common method used to solve boundary value problems is to find an equivalent set of
image charges. The method of images removes the boundaries and finds the positions and
magnitudes of image charges that will match the value of the potential on the boundaries.
438 Chapter 8 Electrostatics
The solution for the potential is then the superposition of the potentials from the charges
and image charges.
A common problem in electrostatics is to determine the electric field due to a given
surface distribution of charges. If a surface S has a surface-charge density of cr then ac-
according to Gauss's law, the normal component of the electric field is discontinuous. The
discontinuity is related to the surface charge by the relation (E2 — Ej)- n = 4ncr, where n
is a unit normal n and where E1 and E2 are the electric fields on either side of the surface.
8.2.1.1 ¦ Mathematica Commands for Section 8.1
It is useful to create user-defined procedures for those calculations that are used repeat-
repeatedly in this section. This section makes use of three user-defined functions: Monopole,
TrigToY and TrigToP.
Monopole A function to compute the potential of a charge is called Monopole:
In[7] := Monopole[q_ : 1, rO_ : {0, 0, 0}, r_ : {x, y, z}] : =
q/Sqrt[Sum[(rO[[i]] -r[[i]])^2, {i, 1, Lenarth[rO]
Monopole computes the potential at the field point {x#y# z} due to a point charge q
located at position {x0,y0, z0}. This procedure works in two or three dimensions. The
charge is defaulted at 1, the default position for the particle is at the origin, and the default
position for the field point is {x#y# z}.
EXAMPLE 2 Consider a simple two-dimensional example with specified coordinates:
In[8]:= Monopole[q, {xO, yO},{x,y}]
Out[8]= Q
VfxO-xJ* (yO-yJ
This is the potential at {x, y] due to a charge q located at {;c0, yO}. We can repeat this ex-
example, taking advantage of the default coordinates {x, y}\
ln[9]:= Monopole[q, {x0,y0}]
Out[9]= q
^/(xO-xJ + (yO-yJ
A dipole is easily formed from two monopoles:
In[10]:= dipole = (Monopole[ + 1, {0, 0,-a/2}] + Monopole[-1, {0,0,+a/2}])
Out [10]=
which is the superposition of the potentials from two point charges, one positive and one
negative.
8.2 Point Charges, Multipoles, and Image Charges 439
TrigToY In some cases it is instructive to represent a function f [8, <p] as an expansion in
spherical harmonics. The following user-defined procedure TrigToY will expand f [8, <p]
to order n in spherical harmonics:
In[11]:= TrigToY[expression., terms. : 2] : =
Module [{el, m, result},
result = Sum[Integrate[(-1)"(m)
* SphericalHarmonicY[el, -m, 0, 0]
* expression Sin[e], {6, 0, tt}, {0, 0, 27T}] * Y[el, m, 0, 0]
, {el, 0, terms}, {m, -el, el}];
Return[result]
The user-defined operator TrigToY expands an expression of 8 and <p to order n in
spherical harmonics. Note that the orthogonality relation has been used:
f d<p f d?>sin[8]Y*[f,m', 6, <p]Y[(,m,6, <p] = 6tt,6mm,
Jo Jo
and the conjugate of the spherical harmonic is explicitly replaced using
r [/, m, e, <t>] = (-i)mY[f, -m, e, <t>]
The default for the number of terms is set equal to 2. Specifically,
where
X2n r*n
d<p I d6sin[8](-l)mY[{, -m, 8, <p]f[8, <p].
Jo
EXAMPLE 3 Convert a simple trigonometric function cos[#]2 to spherical harmonics:
In [12]:- eql = Cos[e]~2//TrigToY
0ut[12]= - V^Y@, 0, 9, 0) + - /-YB, 0,9,0)
where Y denotes the spherical harmonic. You can verify that this conversion is correct by
reproducing the original expression:
In[13] := eql//.Y-» SphericalHarmonicY//Simplify
Out[13]= Cos2 (9)
TrigToP It is often instructive to represent a function f{8) as an expansion in Legendre
polynomials. The following user-defined procedure TrigToP expands f{8) to order n in
Legendre polynomials:
440 Chapter 8 Electrostatics
In[14] :- TrigToP[expression., terms- : 2] : =
Module [{el, result},
result s Sum[Integrate[LegendreP[el, Cos[e] ]
* expression Sin[e] , {6, 0, tt}]
* Bel + l)/2 P[el, Cos[e]], {el, 0, terms}];
Return[result]
The user-defined operator TrigToP expands an expression of 6 to order n in Legendre
functions. The default value of the number of terms is 2. P denotes the Legendre polyno-
polynomials. Specifically,
where
'+d r
2 Jo
EXAMPLE 4 Convert the simple trigonometric function sin[#]2 to Legendre polynomials:
In[15] : = eql = Sin[e]2//TrigToP
Out[15]= - P@, Cos (9) ) - - PB, Cos (9) )
Converting back to trigonometric functions, you get
In [16] : = eql //. P -> LegendreP // Simpli f y
Out[16]= Sin2 (9)
Finally we apply Protect to the user-defined procedures to keep them from being
deleted with Clear [ "Global» * " ]:
In[17] : = Protect [Monopole, TrigToY, TrigToP] ;
PROBLEM 1 Superposition of Point Charges. Consider the following charge distribu-
distributions:
Linear Square Triangle
Quadrapole Quadrapole
+dl2 # -q
+dl2
)+2q
-d!2
8.2 Point Charges, Multipoles, and Image Charges 441
1. A linear quadrupole: three charges on the z-axis with charge -q at z = +d/2, charge
-q at z = -d/2, and charge 2q at z = 0.
2. A square quadrupole: two particles with charge -q at {d/2,0, -d/2} and {-d/2,0, d/2}
and two particles with charge q at {d/2,0, d/2} and {-d/2,0, -d/2}.
3. Charges located on the corners of a triangle: charge -q at {+d/2, -0, -d/2}, charge
-q at {-d/2,0, -d/2}, and charge 2q at {0,0,0}.
a. Compute the potentials for these charge distributions. Plot the square quadrupole
potential in the y = 0 plane.
b. Graph the linear quadrupole equipotential lines and electric field lines in two di-
dimensions. Use ContourPlot to graph the equipotential lines and PlotGradi-
entField for the electric field. Verify the graph by using the user-defined function
VEPlot. Use VEPlot to graph the remaining two charge distributions.
c. Convert the potential from Cartesian to spherical coordinates and expand the poten-
potential in powers \. Express the results in terms of Legendre polynomials or spheri-
spherical harmonics using the user-defined rules TrigToP and TrigToY defined in the
Overview of this section.
d. As a final part of this problem, use Plot6radientField3D to make a three-
dimensional vector plot of the linear quadrupole electric field.
Remarks and Outline This problem introduces you to Mathematica's various graph-
graphics tools for visualizing electric and magnetic fields. The packages used in this prob-
problem are: GraphicsAPlotField\ CalculusAVectorAnalysis\ and Graph-
Graphics 'PlotFieldSDV Try using different functions for the ScaleFunction in the
PlotField command. Experiment with different charge distributions and compare their
potentials. Which ones falls off faster with increasing distance?
Required Packages
In [18]:= Needs["Calculus »VectorAnalysis»"]
Needs["Graphics'PlotField1"]
Needs["Graphics *plotField3D*"]
Solution
In[19]:= Clear["Global'*"] ;
a. Consider the potential of a linear quadrupole due to the superposition of three-point
charges located on a line. Assume that one particle has charge -q and is located at z=d/2
and the second particle has charge -q and is located at z=-d/2. The third particle is
located at the origin and has charge 2q. The potential at r from a single charge located at
rO is given by Monopole so the potential from the linear quadrupole is the superposition
of three monopoles:
442
Chapter 8 Electrostatics
In [20] := quad =
(Monopole[2q, {0, 0, 0}] +
Monopole[-q, {0, 0, d/2}] +
Monopole[-q, {0, 0, -d/2}])
Out [20]= --
2q
-y2
-y2
y2 + z2
Consider the potential due to the superposition of three-point charges located on the ver-
vertices of a triangle. Assume that one particle has charge -q located at {d/2, 0, -d/2}
and the second particle has charge-q and is located at {-d/2, 0, -d/2}. The third
particle is located at the origin and has charge 2q. The potential from the superposition of
the three monopoles is
In[21]:= triangle = (Monopole[+2q, {0, 0,0}] +
Monopole[-q, {+d/2, 0, -d/2}]+
Monopole[-q, {-d/2, 0, -d/2}]) ;
Consider the potential due to the superposition of four-point charges located on the
vertices of a square. Assume two particles each have charge -q and are located at {d/2,
0, -d/2} and {-d/2, 0, d/2}. Assume the final two particles each have charge q
and are located at {d/2, 0, d/2} and {-d/2, 0, -d/2}. The potential from the
superposition of the four monopoles is
In[22] :- square = (Monopole[+q, {+d/2, 0, d/2}] +
Monopole[-q, {+d/2, 0, -d/2}] +
Monopole[+q, {-d/2, 0, -d/2}] +
Monopole [ -q, { -d/2 , 0 , d/2 } ]) ;
You can get a visual sense of these distributions by plotting the potential. Consider the
square distribution and plot the potential in the y=0 plane.
In [23] : = Plot3D [square /.{y->0,q-tl,d-tl}
, {x,-1, 1}, {z,-1, 1}
, AxesLabel -> {"ac", "z", ""}];
?'" "'-OS^ s v¦'.,¦''/?~/~/~~-.'
-Q.S"
J.5
8.2 Point Charges, Multipoles, and Image Charges 443
b. Consider the linear quadrupole potential and plot the electric field and the equipo-
tential lines. The electric field is obtained from PlotGradientField, found in the
package Graphics * PlotField * already loaded at the beginning of the problem. Plot
-quad in the {x, z} plane. Define the location of the charges
In[24]:= charges =
{{Hue[0.3], Disk[{0, 1/2},0.1]},
{Hue[0.95],Disk[{0, 0}, 0.2]},
{Hue[0.3], Disk[{0, -1/2},0.1]}};
and combine them with the plot of the electric field
In [25]:= pi = PlotGradientField[
-quad//. {q-» 1, d-» l,y-» 0}
, {x, -1.1, 1.1}, {z, -1.1, 1.1}
, ScaleFunction -> A6) , Epilog -> charges] ;
There is a charge -q at z=l/2, another charge -q at z=-l/2, and a third charge 2q
located at the origin. Note that we plot the negative of the potential so that the electric
vector points away from the positive change.
The equipotential lines (V) follow from ContourPlot,
In [26] := p2 = ContourPlot [
quad//.{q-»l,d-» l,y-»0},
{x, -1.1, 1.1}, {z, -1.1, 1.1},
ContourShading -»False,
PlotPoints -> 50,
Display-Function -» Identity
We now overlay PlotGradientField and ContourPlot:
444
Chapter 8 Electrostatics
In[27]:= Show [pi, p2 ];
VEPlot simply does this same procedure in a single step:
In [28] := VEPlot [quad//. {q-> 1, d-»l#y-»0},
{x, -1.1, 1.1}, {z, -1.1, 1.1},
Epilog -» charges];
For the triangle, you get:
In[29]:= charges =
{{Hue[0.3], Disk[{-l/2, -1/2}, 0.1]},
{Hue[0.95], Disk[{0, 0}, 0.2] },
{Hue[0.3],
Disk[{l/2,-1/2},0.1]}};
8.2 Point Charges, Multipoles, and Image Charges
In[30}:= VEPlot [triangle/. {q->l,d->l, y-> 0},
{x, -1.1, 1.1}, {z, -1.1, 1.1},
Epilojj -» charges] ;
445
Finally, the square quadrupole is
In[31]:= charges =
{{Hue[0.95], Disk[{-l/2,
{Hue[0.95],
Disk[{l/2, 1/2}, 0.1]},
{Hue[0.3],
Disk[{-l/2, 1/2},0.1]},
{Hue[0.3],
Disk[{ 1/2, - 1/2}, 0.1]} };
In[32] := VEPlot [square/, {q-> 1, d-> 1, y-» 0},
{x, -1.1, 1.1}, {z, -1.1, 1.1},
Epilog -» charges] ;
/ M \ \ V
446 Chapter 8 Electrostatics
c. Expand the potentials in the limit of large r. First, we define the rule for converting
Cartesian coordinates to spherical coordinates. The relation between Cartesian and spher-
spherical coordinates is given by the command CoordinatesToCartesian found in the
add-on package already loaded at the beginning of the problem. The rule for converting
Cartesian coordinates to spherical coordinates is
In [33]: = x2rRule =
Thread[
{x, y, z} -» CoordinatesToCartesian [
{r, e, «}, Spherical]]
Out [33]= {x->rCos@) Sin (9) , y -> r Sin (9) Sin@) , z -> r Cos (9) }
Now we apply this rule to quad, and expand for large r to second order:
In[34]: = seriesQuad =
Series [quad //.x2rRule , {r, co, 2}] //
Simplify//Normal
Out[34]= _d^CCosB 9)+l)
Alternatively, you can rewrite this as a Legendre polynomial using the user-defined
function Tr igToP defined in the Mathematica Commands at the beginning of this section:
In[35]:= seriesQuad//TrigToP//Simplify
d2 qPB, Cos (9))
2rJ
Likewise for the square configuration:
In[36]:= seriesSquare =
Series [square //.x2rRule , {r, oo, 2}] //
Simplify //Normal
3d2qCos(9) Cos@) Sin (9)
Out[Jo J = 3
In[37]:= seriesSquare//TrigToY//Simplify
d2 \/^? <3 (YB, -1, 9, 0) - YB, 1, 9, 0))
Out [37]= ^-5 3
Finally, for the triangle configuration you get:
In[38]:= seriesTriangle =
Series [triangle //.x2rRule , {r, co, 2}] //
FullSimplify//Normal
d a Cos (9) d2 q F Cos B 0) Sin2 (9) + 3 Cos B 9) + l)
Out [38]= — r-L- i '
16 rJ
8.2 Point Charges, Multipoles, and Image Charges
In[39].= seriesTriansle//TrigToY//Simplify
447
Out [39]= -
60 r3
3 V5d (V6 YB, -2, 9, <t>) +2 YB, 0, 9, <t>) +
V6 YB, 2, 9, 0) ) - 40 V3 rY(l, 0, 6, <t>)
Note the triangle begins at order ^ because, unlike the two quadrupoles, it contains a
dipole component.
d. As a final example, use PlotGradientField3D to show the three-dimensional
vector plot of the linear quadrupole electric field. This command is found in the add-on
package Graphics APlotField3D'1, already loaded at the beginning of the problem.
To learn about the properties of PlotGradientField3D enter ?PlotGradient-
Pield3D. The graph is
In[40]: = pi=PlotGradientField3D[
quad//.{q-tl,d-»l}, {x, -1, 1},
{y,-1, 1}, {z,-1, 1},
ScaleFunction -» A6),
VectorHeads -»True,
PlotPoints -» 6,
BoxRatios -» {1, 1, 2},
Viewpoint -» {1.3, -2.4, 1}];
PROBLEM 2 Point Charges and Grounded Plane. Consider a point charge q at a dis-
distance d from an infinite conducting plane that is grounded. The potential on the grounded
conductor is zero.
448 Chapter 8 Electrostatics
a. Use the method of images to find the potential. The method of images removes the
conductor and finds the position and magnitude of an image charge that makes the
potential zero on the plane of the conductor. The potential is just the superposition
of the potentials from the charge and image charge.
b. Expand the potential in powers of A and find the leading-order term. Express the
results in terms of Legendre polynomials using the user-defined rule TrigToP de-
defined in the Overview. Find the electric field that follows from applying Grad to the
potential.
c. Find the induced charge density on the plane and verify that the total induced charge
is -q. Make use of the fact that the induced charge is proportional to the normal
derivative of the potential on the surface of the conductor. Plot the induced charge
using ContourPlot.
Remarks and Outline This is a basic boundary-value problem. It serves as a warm-up
for the following problems that have more complex boundary conditions. Mathematical
ability to handle three-vectors as well as to compute gradients in different coordinate sys-
systems enables you to solve this problem in a trivial manner. Using the symbolic integration,
you can integrate the answer for the charge density to verify the total charge. Plot the
charge density on the plane using ContourPlot. Viewing this plot, you can see that you
obtained an answer that makes physical sense. This is always a powerful check of any cal-
calculation. Plot the potential field arising from the point charge and its image charge. Do the
boundary conditions appear to be satisfied in the region of the conducting plane? Try the
same problem for multiple charges. Apply ContourPlot to the charge density to see if
the answer is plausible.
Required Packages
In[41]: = Needs["Calculus'VectorAnalysis1"]
Needs[-Graphics'PlotPield'"]
Solution
In[42]:= Clear[-Global * *¦ ] ;
a. The potential on the grounded conductor is zero. Using the method of images, remove
the plane conductor and find the position and magnitude of an image charge that makes the
8.2 Point Charges, Multipoles, and Image Charges 449
potential zero at the conductor's position. On the basis of the problem's symmetry, the
image charge must have magnitude -q and must be located at a distance d behind the
plane. The total potential for the charge and image charge is the superposition of their
individual potentials:
In[43] := dipole = (Monopole[ +q, {0, 0, +d}] + Monopole[-q, {0, 0, -d}])
Out[43]= g
The z=0 plane has zero potential, since every point on the plane is equidistant from q
and -q. To verify this conclusion, evaluate the potential at z=0:
ln[44]:= dipole/.z- > 0
Out[44]= 0
b. Change from Cartesian to spherical coordinates and expand the potential in the limit
of large r. The relation between the coordinates is given by the command Coordi-
natesToCartesian found in the add-on package CalculusAVectorAnalysisA
and already loaded at the beginning of the problem. The rule for converting from Cartesian
to spherical coordinates is
In[45]:= x2rRule =
Thread[
{x, y, z} -> CoordinatesToCartesian [
{r, e, 0}, Spherical]]
Out[45]= {x->rCos@) Sin @) , y -> r Sin @) Sin (9) , z -> r Cos (9) }
Now apply this rule to dipole and expand for large r to second order:
In[46] : = dipoleR =
Series [dipole//.x2rRule , {r, oo, 2}] //
Normal//Simplify
2dqCos(9)
Out[46]= 2
TrigToP is used to express the answer in Legendre polynomials:
In[47]:= dipoleR//TrigToP
Out[47]= 2dqP(l^Cos(e))
The electric field follows from applying Grad to dipoleR.
In[48] := efieldR = -Grad[dipoleR, Spherical [r, 0, 0] ]
r4dqCos(9) 2dqSin(9) ]
Out[48]= , \ , , 0
450
Chapter 8 Electrostatics
c. The induced charge density on the conductor is -1 / Dn) times the normal derivative
of the potential evaluated on the z=0 plane:
In[49]:= charge = -1/D 7r) D[dipole, z]//.z-> 0
Out[49]= --
dq
277(d2+x2+y2)
It follows from Gauss's theorem that the total induced charge on the conductor must be
-q. Integrating the charge density over the plane, you can verify this result:
In [50] := Integrate [charge, {y, -oo, +oo}, {x, -oo, +00} ] //PowerExpand
Out[50]= -q
A ContourPlot of the induced charge on the conductor is
In[51] := ContourPlot [charge/, {d -»1, q -»1},
{y, -1, 1}, {x, -1, 1}];
0.5
-0.5
-1 -0.5 0 0.5 1
PROBLEM 3 Point Charges and Grounded Sphere. Consider a point charge q located
a distance d from the center of a grounded conducting sphere of radius a.
8.2 Point Charges, Multipoles, and Image Charges 451
a. Find the potential outside the sphere by removing the conductor and finding the
position and magnitude of an image charge that makes the potential zero on the
spherical surface.
b. Expand the potential in a -r series and find the electric field to this same order. Use
the user-defined function VEPlot to graph the electric field and equipotential lines
in the y=0 plane.
c. Note that the induced charge is proportional to the normal derivative of the poten-
potential on the surface of the conductor, so derive an expression for the induced charge
density. Integrate the induced charge density over the surface of the sphere and show
that the total induced charge is equal to the image charge.
d. Plot the induced charge on a sphere's surface.
Remarks and Outline This problem introduces the next level of complication for bound-
boundary value problems. However, the solution is again simple. By symmetry, the image charge
must lie on a line connecting q and the center of the sphere. To get two equations for the
unknowns, consider one point to be on the equator of the sphere nearest the charge and the
second point on the equator farthest from the charge. The potential must be zero at these
two points. You can use ParametricPlot3D to show the charge density induced on the
sphere. From this, you can see that you obtained an answer that makes physical sense—a
powerful check of the calculation.
Required Packages
In[52]:= Needs["Calculus'VectorAnalysis»"]
Needs["Graphics'PlotField'"]
Solution
In[53].- = Clear["Global' *"] ;
a. To solve the problem using the method of images, remove the conductor and find
the position dl and charge ql of an image that makes the potential zero on a sphere of
radius a. You will need two equations to solve for {ql,dl}. The two equations follow
from picking two points on the sphere: the point nearest the particle and the point farthest
from the particle. Requiring the potential to be zero at these two points, you get
ln[54] := eql = {-^- + -^— == 0,
I a + d a + dl
== o ti
J
+
-a + d a - dl
Solving these two equations for ql and dl, it follows that
In[55] := imageRule = Solve [eql, {dl, ql}]//Expandfcll//Flatten
Out [55]= {dl^5-,ql^-^}
I. a a J
452 Chapter 8 Electrostatics
The image charge has a value of (-f2) and is located at a distance ^ from the origin.
The potential is the superposition of the potentials from the charge and image charge.
The potential for a single charge is given by Monopole, so the superposition of the two
charges is
In[56]:= potential=
(Monopole [q, {0, 0, d}] +
Monopole [ql, {0, 0, dl}])//.imajjeRule
q aq
Out [56] =
(d-zJ I ' 2
d lx2+y2+ ?-
¦ z
b. To expand the potential in powers of ? you must first convert to spherical coordinates.
You can relate Cartesian and spherical coordinates by using the command CoordinatesTo-
Cartesian found in the add-on package Calculus ^VectorAnalysis V The rule for
changing to spherical coordinates is
In[57] := x2rRule = Thread[{x, y, z}- >
CoordinatesToCartesian[{r, 0, 0}, Spherical]]
0ut[57]= {x->rCos@) Sin (9) , y -> r Sin (9) Sin(</>) , z -> r Cos (9) }
The potential in spherical coordinates is
In[58]:= potentialR = potential//.x2rRule//Simplify//Expand
Out [58]= *
yd2 - 2r COS (9) d+r2 ^ /a4 2rCos(e) a2 | r2
Note that the potential on the sphere (r=a) is zero, as it should be:
In[59] -.= potentialR//. r-> a//Simplify//
PowerExpand
Out[59]= 0
You can expand the potential in powers of -r by using the command Series:
In[60]:= Series [potentialR, {r, oo, 2}] //Normal //
Collect [#, { Cos [6] , r, a } ] 6
Cos (9)
Out[60]=
The plot of the electric field and equipotential lines in the y=0 plane follow from VEPlot:
8.2 Point Charges, Multipoles, and Image Charges
In[61]:= VEPlot[
potential/. {a-»0.2,d-»0.4,q-»l, y-»0},
{x, -1, 1}, {z, -1, 1},
Epilog -»
{ {Hue[0.3], Disk[{0,0.1}, 0.05]},
{Thickness[0.01],
Circle[{0,0},0.2]} ,
{Hue[0.95],
453
The top disk is the positive charge and the bottom disk is the image charge. A circle has
been placed at the position of the sphere.
c. The induced charge density is -1/ D;r) times the radial derivative of the potential
evaluated at r=a. Taking the radial derivative of the potential, i.e., the electric field normal
to the surface of the sphere, you get
In[62]:= chargedensity=
1
4 7T
D[potentialR, r]/.{r-»a}//
Simplify//PowerExpand//Simplify I
Out [62] =
4a7r a2 -2d Cos (9) a + d2
To get the total induced charge, integrate the charge density over the surface of the sphere.
In[63]:= totalcharge =
Integrate [chargedensity 2 7r a~2 Sin[6],
{6, 0,tt}] //Simplify
454 Chapter 8 Electrostatics
Caution: Using PowerExpand will give incorrect results because of the sign of the
square roots. Note that d>a, so
In[64]:= rule = [
and the total induced charge is
In[65] := totalcharge//.rule//PowerExpand //
Simplify
Out [65]= - —
a
d. To plot the induced charge on a sphere, normalize the charge density so that it ranges
from {0,1} as 6 ranges over {0, 2tt}. Call this function gray and define it by
In[66]:= 6Hin =
+(FindHinimum[+chargedensity/.
{a->l,q->l, d->2}, {6, 1}]//
First);
SHax =
-(FindHinimum[-chargedensity/.
{a-tl,qtl,d-.2}/ {6,1}]//
First);
gray [6-] =
((chargedensity - 6Hin) /(SHax - SHin) /.
{6Hin, SHax}
Out[66]= {-0.238732,-0.00884194}
Note how FindMinimum is used to determine the limits of the function so that you
can map it onto the interval {0# l}. Indicating the induced charge by the gray scale, the
graph of the induced charge plotted on a spherical surface is
In [67] := radius = 1;
ParametricPlot3D[
{radius Sin[6]Cos[0]
, radius Sin[6]Sin[0]
, radius Cos[6] , GrayLevel[gray[6]]}
, {6, 0,tt}, {0,0, 2tt}
, Lighting-> False
, Axes-> False
, Boxed-> False];
8.2 Point Charges, Multipoles, and Image Charges
455
PROBLEM 4 Line Charge and Grounded Plane. Consider a line with charge q per
unit length located along the z-axis, in front of an infinite plane conductor that is located in
the {x# z} plane and kept at zero potential. The potential from a single charged line parallel
to the z-axis and located at x=x0 and y=y0 is V [x#y] = -q Log [(x - x0J + (y- y0J ],
where q is the charge per unit length.
a. Use the method of images to find the potential and plot the equipotential surfaces in
the plane of symmetry. Show that the Laplacian of the potential is zero.
b. Find the induced charge. Plot the induced charge density on the plane. Show that
integrating over the charge density gives a charge per unit length that equals the
image charge per unit length.
c. Find the electric field and use PlotVectorField to plot the electric field lines.
Remarks and Outline Use the method of images to find the image line charge and reduce
the problem to a superposition of two line charges. By symmetry, the image line is located
behind the plane and has a charge per unit length that is the negative of the line charge.
The equipotential surfaces follow from the user-defined function VEPlot. The plot of the
induced charge follows from ContourPlot. The induced charge is proportional to the
normal derivative of the potential evaluated on the conductor's surface. The electric field
follows from the gradient of the potential.
456 Chapter 8 Electrostatics
Required Packages
In [68] .- = Needs [ "Calculus 'VectorAnalysis»" ]
Needs["Graphics »PlotPield»"]
Solution
In [69]:= clear ["Global* *"];
a. The solution for the line charge and plane is equal to the superposition of a line charge
at {x=0#y=y0} and a negative image line charge at {x=0#y=-y0}. The sum of the two
line potentials is
In [70] := potential = -q Lob [x2 + (y -yOJ] +
q Lob [x2 + (y+ yOJ] ;
The potential is zero on the plane (y=0), as it should be:
In [71] .-= potential//.y- > 0
Out[71]= 0
Use VEPlot to graph the equipotential surfaces and the electric field lines in the plane
of symmetry:
In[72] .- = VEPlot [potential//, {q -> 1, yO -> 1},
{x,-1.1, 1.1}, {y, -2,2},
Bpilos -*
{{Thickness[0.03],
Line[{{-l.l, 0}, {1.1,0}}] },
{Hue[0.35],Disk[{0, -l},0.1]},
{Hue[0.95],Disk[{0, l},
8.2 Point Charges, Multipoles, and Image Charges
457
The dark line is the infinite plane conductor. The disk at the top is the positively
charged line and the image line is the bottom disk. The physical region is to the top of
the plane conductor.Show that the Laplacian, found in the add-on package Calcu-
Calculus *VectorAnalysis *, of the potential is zero.
In [73] : = Laplacian [potential, cartesian [x, y, z] ] //Together
Out [73]= 0
b. The induced charge is proportional to the normal derivative at z = 0:
In [74]:= charge = D[potential, y] /. {y-> 0}
4 7T
Out [74]= --
qyO
t\ (x2 +yO2
Plotting the induced charge on the plane, you get
In [75] := ContourPlot [charge/. {q-> 1, yO -> 1},
{x, -2,2}, {y,-2,2}];
-1
-2
-2
-1
The charge density is greatest just below the charged line. Integrate charge along the
jc-direction to get the induced charge per unit length:
In [76] := Integrate [charge, {x, -oo, +00} ] //PowerExpand
Out [76]= -q
c. Take the gradient of the potential to find the electric field, E = -VV:
In [77] := eField = -Grad[potential, Cartesian [x, y, z] ]//Simplify
458 Chapter 8 Electrostatics
8 qxyyO
Out [77] =
(x2 + (y-yOJ) (x2 + (y + yOJ)
2 q (y-yO) 2 q (y + yO)
x2 + (y-yOJ x2 + (y + yOJ ' >
The Grad operator is found in the add-on package Calculus lVectorAnalysisV
The electric field lines in the z=O plane are
In[781:= PlotVectorField[
ePield[[{l, 2}]] //.{q-> 1, yO -> 1},
{x,-5, 5}, {y, 0, 3},
PlotPoints -> 10,
ScaleFunction -» (Is) ,
AspectRatio -> 8/10 ,
Prolog ->
{{Thickness[0.03],
Line[{{-5, 0}, {5,0}}] },
{Hue[0.95],Disk[{0, !},<
\ \
/ \ \ \ \
I I ! i I Mill
iTtT
PROBLEM 5 Multipole Expansion of a Charge Distribution. Consider the charge
densities
a
for r < a and pt = 0 for r > a.
Pa = qoi-^:fi-Sm2@)SinB<p)
a
8.2 Point Charges, Multipoles, and Image Charges 459
a. Use ContourPlot to make a two-dimensional plot of the charge densities.
b. Find the multipole expansion for the potentials. The first two charge densities can be
expanded in terms of Legendre polynomials, and the third in terms of spherical har-
harmonics. To make the expansions, use the user-defined procedures MultipoleSH
and MultipoleP given below in Remarks and Outline.
c. Find the electric fields for the multipole expansions of the potentials.
d. Plot potential contours and electric field lines of the multipole expansions using VE-
Plot.
In[79]:= Clear ["Global* * "];
Remarks and Outline This problem introduces the multipole expansion. Again, because
it is simple for Mathematica to expand complex charge distributions into multipoles, you
can experiment with more complex and realistic charge distributions than you could analyt-
analytically. Experiment with different charge distributions. Take a complex charge distribution
of net charge +1 and compare it with a point charge of +1 as you increase the scale of the
plot. Are the potential fields comparable in the limit r -» oo? Repeat the exercise using a
single dipole and then a collection of dipoles with random orientation. Compare the poten-
potential field between a monopole, a dipole, and a quadrupole. Which one falls off faster with
increasing radius? Is this consistent with the expansion in powers of r? Further, the ability
to plot the vector field associated with the charge distribution will enable you to explicitly
see why the leading terms in the multipole expansion yield the dominant characteristics
of the charge distribution. Try using different functions for the ScaleFunction in the
PlotField command, including the default function. Given a continuous charge distri-
distribution, you will find it useful to expand this in spherical harmonics. The two additional
user-defined procedures needed for this problem are MultipoleSH and MultipoleP.
(Note, these functions share similar elements with TrigToY and TrigToP).
MultipoleSH The multipole expansion of a potential is
(=0 m=-(
where
Xruw,it r" r2
?dr d0sw{0] d(f>(-l)mY[f,-m,e,(f>]q[r,e,(f>]
Jo Jo
The procedure MultipoleSH takes a charge distribution and returns a potential ex-
expanded to n terms in spherical harmonics denoted by Y [ 1, m# 6, <p]
460 Chapter 8 Electrostatics
In[80]:= MultipoleSH [distribution., rlimit., n_] : =
Module [{q, V},
q : = Integrate
I Integrate[distribution r2 ,
{r, 0, rlimit}])*
(-i)msin(e) y;?F, «), {e, o, *},
{0, 0,2*}];
47rq (?i^it\el
[L i
v=Sum
{el, 0,n}, {m, -el, el}];
Return[V] ] ;
The radial extension of the charge density is given by rlimit. To covert to trigono-
trigonometric functions let Y->SphericalHarmonicY. The number of terms in the Multi-
MultipoleSH increases dramatically with larger values of /-terms, so the calculation time be-
becomes prohibitively large.
To see how it works consider the charge distribution
In[81]: = density = 0 (r - a) Sin2 F) Sin2 @) ;
a*
for r<a and zero for r>a. With the number of terms equal to 2, the potential expanded in
spherical harmonics is
In [82] := MultipoleSH [density, a, 2] //Simplify//Apart
Out[82]= ^-"(a27r3/2Q (V6YB, -2, 9, <t>) + 2 YB, 0, 9, <t>) +
45 V5r > >
V6YB, 2, 9, </>)))-
27r3/2 QY@, 0, 9,
9r
This procedure is slow because of the number of integration variables and the number of
terms in the sum.
MultipoleP If the charge distribution is axially symmetric, then you can expand the po-
potential over Legendre polynomials. The specific formula is
where
q(f) = 2n [ lmtt ?dr f Msm[6]Y[(, -m, 6, <p]q[r, 6].
Jo Jo
8.2 Point Charges, Multipoles, and Image Charges 461
The procedure multipoleP takes a charge distribution that is expressed in spherical
coordinates {r, 6,0} (symmetric in <p) and returns a potential. The result is expanded to n
terms in Legendre polynomials denoted by P [el,Cos [#] ].
In [83] : = MultipoleP [distribution., rlimit., n_] : =
Module [{q, pot},
q : = Integrate
2 7T* (Integrate [distribution r~2,
2el+1
P(el, Cos F)) , {el, 0, n}];
Return[pot]I;
The radial extension of the charge density is given by rldmlt. To convert to trigono-
trigonometric functions let P->LegendreP.
To see how it works, consider the charge distribution given by
ln[841:= density = 0 <*'g"<»»
for r<a and zero for r>a. The potential expanded in Legendre polynomials is
In[85]:= eql = MultipoleP[density, a, 2]
57rQP@, Cos(9) ) 8a27rQPB, Cos (9) )
Out[85]=
9r 45 r3
The same calculation using MultipoleSH takes longer:
In[86]:= eq2 = MultipoleSH[density, a, 2]
10 7r3/2 QY@, 0, 9, <t>) 16a27T3/2 QYB, 0, 9, 0)
Out[86] =
9r 45 V5
r
They both agree with each other, as can be verified by reducing the expressions to trigono-
trigonometric functions.
In[87] := eql == eq2//. {P -» LegendreP,
Y -> SphericalHarmonicY}// Simplify
Out [87]= True
462 Chapter 8 Electrostatics
Required Packages
In[88]:= Needs["Calculus *VectorAnalysis*"]
Needs["Graphics'PlotField'-]
Solution
a. The three charge distributions are
qO (a-r) (sin(e) - f)
In [89] : = chargeDensityl = 5-j
e^ qO (a-r) CosF)
chargeDensity2 = ^** i
charseDensity3 =
ji
qO (a - rJ Sin2 F) Sin B 0)
To change from spherical coordinates to Cartesian coordinates (so you can use Contour-
Plot), define
In [90] := r2xRule = Thread [{r, e, 0}- >
CoordinatesFromCartesian[{x, y, z}. Spherical]]
Out[90]= jr -> a/x2 +y2 + z2,
, 0 -» Tan 1 (x, y) t
9 ->Cos
Choose the values
In[91] := values = {qO -» 1, a -> 1};
and plot chargeDensityl in the y^O plane:
In[92]:= ContourPlot[
chargeDensityl/.r2xRule//.values/.
{y->0}, {x, -i, l}, {z, -i, l},
PlotPoints -> 40];
8.2 Point Charges, Multipoles, and Image Charges
463
0.5
-0.5
-1 -0.5 0 0.5
Likewise for chargeDensity2, choose the y-»0 plane:
In [93]:= ContourPlot[
char sjeDensity2/.r2xRule//. values/.
{Y-> 0}, {x, -1, 1}, {z, -1, 1},
PlotPoints -> 40] ;
0.5
-0.5
-1
-1 -0.5
0.5
For chargeDensity3, choose the z->0 plane:
In [94]:= ContourPlot[
charsjeDensity3 /. r2xRule// .values/.
{z -> 0}, {x, -1, 1}, {y, -1, 1},
PlotPoints -> 40];
464
Chapter 8 Electrostatics
0.5
-0.5
b. Applying MultipoleP to chargeDensityl, you get the leading-order term of
the multipole expansion:
ln[95].- = multil= HultipoleP[chargeDensityl, a, 2]
a2 7T2 qO PB, Cos (9) )
Out[95]= --
96 r3
Applying MultipoleP to chargeDensity2, you get
ln[96] .- = multi2 = MultipoleP[chargeDensity2, a, 2] //Simplify
4 a (-11 + 4e) 7rqOP(l, Cos (9) )
Out[96]= --
3r2
For chargeDensity3, you must use MultipoleSH, since this charge density is
not symmetric in <f>.
ln[97] : = multi3 = MultipoleSH[charseDensity3, a, 2] //Simplify
qO (YB, -2, 9, <j>) - YB, 2, 9, <t>) )
Out [97] =
75 rJ
c. The electric fields follow from E - -VV. In spherical coordinates,
ln[98] := eFieldl = - Grad[multil. Spherical [r, e, 0] ]
a2 7T2 qOPB, Cos (9) )
Out [98]= -
32 r4
a2 7T2 qO Sin(9) P'0-1' B, Cos (9) )
96 r4 ' -
Or, evaluating the Legendre polynomials explicitly,
8.2 Point Charges, Multipoles, and Image Charges 465
In[99] := eFieldl//.P -> LesendreP//Sinplify
, f a27r2qO C Cos B 9) +1) a2 tt2 qO Sin B 9) -,
1 128 r4 ' 64 r4 ' J
Similarly, you compute the electric field for the second distribution as follows:
In [100] .-= eField2 =
- Grad[multi2, Spherical [r, e, 0] ] //.
P -> Legendrop//Simplify
8 a (-11 + 4 c) 7rqO Cos (9)
Out [100]= -
4a (-11 + 4e) 7rqO Sin (9)
and for the third distribution:
In[101]:= ePield3 =
- Grad[multi3. Spherical [r, e, tf ] ] ;
ePield3/.{Y-» SphericalHarmonicY}//
ExpToTris// Siifplif Y
Out[10l]=
25 r4
8a27rq0 Cos (9) Cos @) Sin (9) Sin@)
75 r4 '
4 a2 7:qO Cos B 0) Sin (9) -i
75? I
d. Next, use VEPlot to display the potential contours and electric field lines of the
multipole expansions. For the first potential, convert to Cartesian coordinates, make Leg-
endreP and SphericalHarmonicY explicit, and substitute the values. Finally, set
y->0 to project to the plane and replace z by y, since VEPlot uses the variables {x# y}.
In[102]:= potl =
multil/.r2xRule/.
{P -» LegendreP,
Y -» SphericalHarmonicY}/.values/.
{y->0} //Simplify
7T2 (x2-2z2)
Out [102]= i -4-*
The plot of the potential contours and electric field lines is
In[103] := VEPlot [potl, {x, -1.1,1.1}, {z, -1.1, 1.1}];
466
Chapter 8 Electrostatics
Likewise for the second distribution.
In[104]:= pot2 =
multi2/.r2xRule/.
{P -» LegendreP,
Y -»SphericalHarmonicY}/.values/.
Out [104]= -
4 (-11 + 4e) nz
3 x2 + z2
I 3/2
In[105]:= VEPlot[pot2, {x,-1.1, 1.1}, {z,-1.1, 1.1}]i
For the third distribution, we plot in the {x, y} plane.
8.3 Laplace's Equation in Cartesian and Cylindrical Coordinates
In [10 6] := pot3 =
multi3/.r2xRule//.
{P -»LegendreP,
Y -» SphericalHarmonicY}//.values/,
{z -> 0} //PullSimplify
467
Oat [106] =
4 7rxy
1 5/2
75 (x^y2)'
In[107] := VEPlot [pot3];
8.3 ¦ LAPLACE'S EQUATION IN CARTESIAN AND CYLINDRICAL COORDINATES
8.3.1 ¦ Overview of Cartesian and Cylindrical Coordinates
Many electrostatic problems involve boundary surfaces on which either the potential or
a surface-charge density is specified. These problems reduce to a solution of Laplace's
equation. In many coordinate systems the solution of Laplace's equation can be expressed
as a product of three terms, each of which is a function of only one coordinate. The solution
becomes a superposition of these products. The coefficients in the expansion follow from
the boundary conditions and the orthogonality properties of the separation functions. In
this section we consider Laplace's equation in Cartesian and cylindrical coordinates.
The solution of Laplace's equation in Cartesian coordinates can be represented as a
product of three functions: X[x], Y[y], and Z[z]. The functions are of the form
X[x] = {Sin[ax], Costa*]}
Y\y] =
Z[Z] =
468 Chapter 8 Electrostatics
where a2+p2 = y2. Note that these equations only appear to be nonsymmetric. Substituting
y -» iy makes the equation for Z[z] a trigonometric equation. Likewise, substituting a -»
ia makes the equation for X[x] an exponential equation. In cylindrical coordinates, the
solution of Laplace's equation can be expressed as a product of R[r], <t>[0], and Z[z]. These
functions are of the form:
_ ( ae+kz + i
~\ a + bz
. ^ ,¦ be~kz for k * 0
UJ ~ i - - »•¦. for Jk = 0
( anj[n, kr] + bnN[n, kr] for k * 0
~ I («„'* + &„»-») + (a0 log[r] + &0) for t = 0
= (cn cos[n 0] + rfn sin[n <p]) + (co<p + d0)
PROBLEM 1 Separation of Variables in Cartesian and Cylindrical Coordinates.
Consider the separation of variables for Laplace's equation in Cartesian and cylindrical
coordinates.
a. Assume the potential in Cartesian coordinates can be expressed in the form Vx [x]
V [y] Vz [z]. Apply the Laplacian to this product and set it to zero to get Laplace's
equation. Separate the functions by grouping terms with the same variable. Set these
terms equal to separation constants and get ordinary differential equations. Solve the
equations for each separation function.
b. In cylindrical coordinates, assume the solution of Laplace's equation can be ex-
expressed in the form R[r] P [0] Z [z]. Apply the Laplacian to this product and
set it to zero. Separate the variables and solve the ordinary differential equation for
each function.
Required Packages
In[108]:= Needs["Calculus'VectorAnalysis*"]
Solution
In[109]:= Clear["Global* *"];
a. Assume the potential is of the form Vx [x] Vy [y] Vz [ z ],
In[110]:= potential = VK[x]vy [y]Vz [z] ;
Setthe coordinates to Cartesian (found in the package Calculus' VectorAnalysisl),
In[111]:= Setcoordinates[cartesian[x, y, z] ];
and apply the Laplacian to this product
8.3 Laplace's Equation in Cartesian and Cylindrical Coordinates 469
In[112]:= lapEq = Laplacian[potential]
0ut[112]= Vy(y) Vz(z)Vx"(x) +
Vx(x) Vz(z)Vy"(y) +Vx(x) Vy(y)Vz"(z)
The equation for the potential follows from setting the Laplacian of the potential
(lapEq) equal to zero. Note that we do not actually set the Laplacian equal to zero at
this point as it is simpler to deal with the expression without putting them into equation
form. If you divide lapEq by Vx [x] vy[y] Vz [z], then you get
Out[113]=
Vx(x) Vy(y) Vz(z)
The Laplacian separated into terms that depended on only one variable. The terms are
In[114] := eq2 = eql/.Plus -> List
Out[114]- ( Vx(x) / Vy(y) ' vz(z) I
You get three differential equations by equating each group of terms with the same
variable equal to a separation constant,
In[115] := fieldEq = eq2 = = { - Cx2, -Cy2, Cz2}//Thread
Out[115] = I == -Cx2 , == -Cy2, == Cz2l
I Vx(x) Vy(y) Vz(z) J
To satisfy Laplace's equation, the constants must add to zero, i.e., Cz2 = Cx2 + Cy2. The
solutions are of the form
In [116]:= HapThread[DSolve,
{fieldEq, {Vx[x],Vy[y],Vz[z]},
{x,y, z}}, 1]//Flatten//ColumnForm
Out[116]= Vx(x) -> cx Cos (Cxx) + c2 Sin(Cxx)
Vy(y) ^cx Cos(Cyy) + c2 Sin(Cyy)
Vz(z) ^ eCz z cx + e"Cz z c2
Laplace's equation is a superposition of products of these terms. The unknown constants
follow from the boundary conditions.
b. Consider the solution of Laplace's equation in cylindrical coordinates. Assume the
potential is of the form R[r] P[0] Z[z],
In[117] := potential = R[r]P[0]Z [z];
Set the coordinates
In[118]:= Setcoordinates[Cylindrical[r, 0, z] ];
470 Chapter 8 Electrostatics
and apply the Laplacian to this product,
In[119]:= lapEq = Laplacian[potential]//Expand
Z(z) R'(r) R(r) Z(z) P" @)
0ut[119] =
r r^
Z(z) R"(r) +P@) R(r) Z"(z)
The equation for the potential follows from setting the Laplacian of the potential
(lapEq) equal to zero, which we do at a later time. The z-variable separates if you divide
lapEqbyR[r] p[0] Z[z]:
I&dEci
In[120]: = ^
Collect[#, r]&
Out [120] =^L
rR(r) r2P@) R(r) Z(z)
An equation for Z [z] follows from selecting terms that are not Free of z and setting
them equal to a separation constant Cz2'-
In[121]:= zEq = Select[eql, (!FreeQ[#,z])S] ==+Cz~2
0ut[121]= Z B) ==Cz2
Z(z)
For Cz2 ?0 the solution is of the form
in [122] := DSolve [ zEq, Z [ z ], z ]// Flatten
0ut[122]= (z(z) -> eCzz cx + e"Cz z c2]
and for Cz2=0 it is
In[123] := DSolve [ zEq/. Cz -tO,Z [z], z] //Flatten
0ut[123]= |z(z) ^cx + z c2}
You now must separate the <p and r variables. You first reduce the Laplacian to only two
variables {<p, r} by replacing the z-terms in eql with the separation constant Cz2:
ln[124]:= eq2 = eql/. {zEq/.Equal -> Rule}
rR(r) r2P@) R(r)
The separation of the <p variable follows from multiplying eq2 with r2:
In[125] := eq3 = r2 eq2//Expand
0ut[125]= CS r2 + R"(r)r2 + 5^1^ + ?1M.
R(r) R(r) P@)
Set the 0-terms equal to another separation constant -C<p2:
8.3 Laplace's Equation in Cartesian and Cylindrical Coordinates 471
In[126]:= tfEq=Select[eq3, (! FreeQ[#, 0] N] = =-Ctf2
p"(*) ^2
For C<fP-^O the solution for P [0] is of the form,
In[127]-.= DSolve[0Eq, P[0] , 0] //Flatten
Out[127]= (p@) -»cx Cos(C0 0) + c2
andforC02=O, it is
In[128] := DSolve [tfEq/.Ctf2 -» 0, P[0] , *] //Flatten
Out[128]= | }
Finally, replace the 0-term in eq3 with the separation constant C<p2 and reduce the
Laplacian to only one variable
In [129] := eq4 = eq3/. ( tfEq/. Equal -> Rule)
R(r) + R(r)
We are now ready to set the Laplacian to zero to get Laplace's equation. Setting eq4 to
zero and solving for R [r], it follows for Cz2±0 that,
In[130] := DSolve[eq4 == 0,R[r], r]//Flatten
Out[130]= |R(r) ^Jc0(Czr) cx + Yc0 (Cz r) c2}
and for Cz2=0 the solution is,
ln[131]:= (DSolve[eq4 == O/.Cz -> 0, R[r], r]//
Flatten)/.c[l] -»A + B/.
C[2] -»I(A-B) //FullSimplify
Out[131]=
PROBLEM 2 Potential in a Rectangular Groove. Consider a rectangular groove that
runs from z = ~oo to +oo and is open in the positive y-direction. The groove is bounded
by two parallel walls at x = 0, x = a, and at the y = 0 end. The walls at x = 0 and x = a
are at zero potential and the end is at a specified potential V[x] that is independent of the z-
coordinate. The boundary conditions suggest that the potential is independent of z. Express
the potential as a superposition of products X[jc]F[y], whereX[x] = {Sin[Q-Jc], Costa*]} and
Y\y] = {e+yy, e~yy}. The relation between the separation constants is a2 = y2.
a. Express the expansion coefficients as integrals over the potential X[x] given on the
y = 0 end.
472
Chapter 8 Electrostatics
V@,y,z)=0
V(a,y,z)=0
V(x,Q,z)=V(x)
b. Let X[x] = Sin[x] and write the first few terms of the potential. Plot the potential
using the command Plot3D. Use the user-defined command VEPlot to plot the
equipotential and electric field lines.
c. Let X[x] = VO and sum the series to get an exact solution. Plot the potential using
Plot3D.
Solution
In [132]:= Clear ["Global* *"];
a. The potential can be expressed as a product of two functions X [x] and Y [y] where
X [x] ={Sin lax], Cos lax] } and Y [y] ^{e^y, e™} and a2 = y2. In order for the
potential to vanish on the parallel sides at x= 0 and x=a the X [x] term must be of the form
X [x] =Sin In m x/a], where m takes on integer values {1,2,...}. The Y [y] term
must vanish as y->oo so Y [y] = e~"my/a. The potential is a superposition of these terms.
2
A[m]sm\—]e-mny/a
L a J
The coefficients A [m] are determined from the potential V [x] on the y= 0 end. At y= 0
the potential reduces to
V[x] =VA[m] sin
ti
a -I
This is just a Fourier sine series and the orthogonality properties of Sin allows you to
invert this equation and get an expression for A [m].
8.3 Laplace's Equation in Cartesian and Cylindrical Coordinates
- fvMs
a Jo
473
The coefficients A [V,m] follow from
In [133]:= A[V_, m_] := B/a) Integrate [V sin[7r m x/a] , {x, 0, a}];
where V is the potential on the y=0 end. It follows that the user-defined function for the
potential is
In [134] : = pot [V., n_] : =
[Bury /m7rx\ 1
A[V, m] e" « sin I -^— I , {m, 1, n} ;
The function pot [V, n] ensures that the potential vanishes at x={0, a} and reduces
to V on the y=0 end. The operator pot works only for those cases when the integral for A
can be done analytically; otherwise, Integrate must be replaced by NXntegrate.
b. Consider the case where the potential on the end of the groove is V [x] =Sin [x].
Substitute Sin [x] into Pot [V, n]. The first few terms of the potential (n=3) are
In [135]:= pot [Sin [x] , 3]
2c"'
Out [135] =
a Sin(a) a Sin(a)
2 GT-a) 2 (a+7T)
Sin Ua
a Sin(a) a Sin(
2 B 7T-a) 2 (a+2 7T)
Sin
2 e"
a Sin(a) a Sin(
2 C7T-a) T 2 (a+37T)
Sin
To see this visually, let a=l and n=30. If you apply Plot3D to pot then the potential
graph in the {x, y} plane is
In [136] := Plot3D[pot [Sin[x] , 30]/.a-> 1//Evaluate,
{x, 0, 1}, {y, 0, 0.5},
AxesLabel -» { x , y , V } ];
474
Chapter 8 Electrostatics
.'0.5
The potential vanishes at x={0, a} and on the y=0 end the value of the potential rises as
Sin[x].
Next, to save time set n=15 and graph the equipotential lines and electric field lines
using VEPlot.
In[137] := potl5 = pot [Sin [x], 15]/.a->l;
In[138] := VEPlot [potl5, {x, 0, 1}, {y, 0, 0.5} ];
The solution at y=0 and near x=l comes closer to the prescribed boundary condition
as you increase the number of terms in the series.
c. The example in which V [x] =V0 can be summed exactly. Set V=V0 and let the num-
number of terms be <x>,
In [139] := eql = pot [V0, oo]
Out[139]= —
iVO
Log
Log
1 -e"
1 -
- Log
- Log
This potential can be reduced to a simpler form:
8.3 Laplace's Equation in Cartesian and Cylindrical Coordinates 475
In[140] := potVO =
eql/A
|losA -a.) -»Log I -I
FullSimplify
i VO Log
Out[140] =
Tanh
7T (y-JL X)
2 a
- Log
Tanh
7T A X+y
2 a
To visualize the result, use Plot3D to plot the potential in the {x, y} plane:
In[141] := Plot3D[potV0/.a-> 1/.V0 -> 1 ,
{x, 0.0001, 0.9999}, {y, 0, 0.5},
AxesLabel -> { x , y , V } ] ;
0.E
The potential vanishes at x={0, a}, as it should. The value of the potential is one on
the end. The limits for the x-variable have been kept away from x=0 and x=l to avoid the
discontinuity at y=0.
PROBLEM 3 Rectangular Conduit. Consider a rectangular conduit that is bounded by
walls on four sides located at x=0, x=a, y=0, and y=b. The conduit has infinite length
along the z-axis. The potential is zero on the sides y=0 and y=b. On the side x=a, the
potential is V[a, y] = V0 and on the side x=0, the potential satisfies the equation V [x] =0.
a. Express the potential as an expansion in Cartesian coordinates. Determine the ex-
expansion coefficients.
b. Plot the potential on the wall x=a and compare the results with the boundary condi-
condition potential. Experiment by keeping more terms in the expression for the potential.
Make a three-dimensional plot of the potential.
c. Plot the equipotential lines and electric field in the {x, y} plane.
476
Chapter 8 Electrostatics
V@,y,z)=0
V(x,b,y,z)=0
V(x,0,z)=0
*• a
V(a,y,z)=V0
Remarks and Outline The symmetry in z implies that the solution is independent of the
z-variable. Use Cartesian coordinates and express the answer as a product X [x] Y [y].
The boundary conditions on the walls require the product to be of the form Cosh [m
n x/b] Sin [m n y/b], wherem={l,2,3, ...}. The orthogonality of Sin [m n
y/b] enables you to express the expansion coefficients as integrals over the boundary at
x=a.
Required Packages
In[142]:= Needs["calculus'VectorAnalysis'"]
Needs["Graphics'PlotField1"]
Solution
In [143]:= Clear ["Global1 *"];
a. Start by denning the potential (pot) as a sum over the orthogonal functions:
In[144] := term[m_] =A(m) Cosh
\ b
)-(=?)•
pot [n_] = Sum[term[m] //Evaluate, {m, 1, n}] ;
pot [n]
Out[144]= VA(«) Coshf^^) Sinf^)
Verify the boundary condition V [x] =0 at x=0:
8.3 Laplace's Equation in Cartesian and Cylindrical Coordinates 477
In [145]:= check = D[pot[n] , x] //
MapAll[Evaluate, #] 6
n iwA(m) Sin
Sinh
Out[145]= >
m=l
In[146]:= check/. {x-> 0}
Out [146]= 0
At the boundary x=a, the form of the potential is
In[147]:= pot [n]/. {x-> a}
vn /mTra \ Imnv\
Out[147]= ) A(m) Cosh Sin -
*—} \ b / \ b /
m=l > ' » '
You can determine the coefficients A [m] using the orthogonality properties of the sine
function. At the x=a boundary, the potential will be given by a sum of terms of the form
In[148]:= eql = VO == texm[m]/.{x-> a}
Out[148]= VO ==A(m) Cosh (^) Sin
\ b /
\ b /
(Note: there is an implied sum on the right-hand side (rhs), that is, Vo = 2mAm Cosh (m n
a/b) Sin (m n y/b) •) You can determine A [m] by multiplying both sides of eql by
Sin [n n y/b] and then integrating. Do this first to the rhs. Because the sine functions
are orthogonal, the only surviving term will be when n=m, so you can spare Mathematica
the effort of integrating all terms except this one. (That is, Jsin (n n y/b) Sin (m n
y/b) =0 except for n=m.) The rhs is then
in [149] := rhs =
((Intesrate[eql[[2]] Sin[m n y/b],
{y, 0, b}] //Simplify) //.
{Sin[2m7r] -» 0})
Oat[149]= -bA(m) Cosh
Likewise, for the left-hand side (lhs), you have
In [150] := lhs =
((Integrate [ eql [ [ 1 ] ] Sin [m tt y/b],
{y, 0,b}])//.{Cos[m7r] -> (
( - 1 + (-l)m) bVO
Out [150]= '
478
Chapter 8 Electrostatics
Setting the lhs equal to the rhs, you find A [m]
In[151] := aSol = Solve[rhs == lhs,A[m]] [ [1]] //Simplify;
A[m_] =A[m]/.aSol
2 - 1 + (-l)m VO sech
Out[151]= --
and thus, the potential.
In[152]:= pot[n]
n / \
Out[152]= VA(m) Cosh ^^ I
m=1 » /
b. You can see the effect of using different numbers of terms in the expansion of the
potential. Here, make a table of potentials with {2,4,6,8} terms at the boundary x=a and
plot the results:
In[153]:= Plot[
Table [pot [n], {n, 2, 8, 2}]//.
{b-> 1,VO -> 1, a-> 1, x-» a}//Evaluate,
{y, 0, 1},
PlotRanjje -» {0, 2}] ;
0.2 0.4
0.6
The curves with more inflection points contain more terms in the expansion and more
closely represent the correct potential at the boundary. Taking n=4, the potential in the
{x,y} plane is
In [154] := Plot3D[pot [4] //. {b -> 1, V0 -> 1, a -> 1},
{y, o, i}, {x, o, i}.
Viewpoint -> {2, 2, 1}] ;
8.3 Laplace's Equation in Cartesian and Cylindrical Coordinates
479
It is clear from this plot that the boundary conditions are satisfied except at the x=a
boundary.
c. You can plot the electric field and the equipotential lines with VEPlot:
In[155] : = VEPlot [pot [4] //. {b -> 1, VO -> 1, a -> 1},
{x, 0, 1}, {y, 0, 1}];
I t t I
PROBLEM 4 Potential Inside a Rectangular Box with Five Sides at Zero Potential.
Consider a rectangular enclosure with sides at x={0,a}, y={0,b}, and z={O,c}.
The side at z=c has a specified potential VO; the other five sides have zero potential.
The solution is a function of all three variables, {x,y, z}. In Cartesian coordinates, the
solution can be represented by a product of three functions X[x], Y[y], and Z [z].
These functions are of the form
X[x] ={Sin[Q' x], Cos [a x] },
Y[y] ={Sin[y3 y], Cos[y3 y]},
480
Chapter 8 Electrostatics
and
where a1 +/?2 = y2.
Z[z] ={Cosh[y z], Sinh[y z]}
V(x,;y,0)=V0
0 -*
x
a. Express the potential in a series and find the expansion coefficients.
b. Let x=l/2 and use Plot3D to graph the potential in the {y, z} plane. Plot the
equipotential lines and the electric field using VEPlot.
Solution
In[156]:= Clear ["Global' *"];
a. In Cartesian coordinates, the solution can be represented by a product of three func-
functions X[x], Y[y], and Z[z]. The vanishing of the potential at x={0,a} requires
X [x] =Sin [mx n x/a], where mx={l, 2,3,...}. Likewise, the vanishing of the po-
tentialaty={0,b} requires Y[y]= Sin [my n y/b], wheremy={l,2,3, • • .}.For
the potential to vanish on the wall at z=0, the function Z[z] must be Sinh [mz n z/c],
where xaz - c-J ^ + ^-. The potential reduces to
nx ny
A[mx, my] sir
mx=\ my=\
At the z=c boundary, the potential reduces to VO so
inhf^^l
8.3 Laplace's Equation in Cartesian and Cylindrical Coordinates
481
V0 =
mx=\ my=\
r n • \nmxx] \nmyy] . , r
A[mx, my] sin sin smhlnmz]
This is just a two-dimensional Fourier sine series. The orthogonality properties of Sin
allows you to invert this equation and get an expression for A[mx, my] sinh[7i7nz]:
4 ra Cb rn . \nmxx] \nmyy] , ,
A[mx, my] sinnbrmzj = — | I V0 sin sin —-— dydx
«ftJo Jo l a ] L ft J
It follows that the expansion coefficients are
In [157] := mzRule
In [158] := A[mx.,
= j mz -» o -i /
ny-] = (
mx2 my21
4 VO csch (mz tt)
ab
[/mx7r
Sin
\ a
Sin
\
Out [158] =
{x, 0, a}, {y, 0,b}] //
Simplify [#, Element [{my, mx}.
Integers]]& I /.mzRule
4 -1+ (-1I
-1+ (-l)mY VO csch
my2
The user-defined function for the potential becomes
In [159]:= pot [nx_, ny_] =
Sum IA [not, my] Sin
Sinn I mZ7rZ I
Sin
a / \ b /
, {mx, 1, nx}.
Out[159]=
{my, 1, ny} J /.mzRule
/exttx
, my)
zz
mx= 1 my-1
Sin
sin
\
\ a
sinh
n z. .
482
Chapter 8 Electrostatics
Thus, the first term of the potential is
In[160] := pot[l, 1]
Out [160]= --
7X
16V0 csch
1 1
b2 a2
Sin
\ a
Sin | — Sinh
b /
1 1
b. To graph the potential, let
In [161] .-= values = {a -> 1, b-» 1, c -> 1, VO -» 1, x-> 1/2};
and use Plot3D to view the potential in the {y#z} plane at x=l/2. Set nx=20 and
ny=20 and apply Plot3D. It follows that
In [162] := Plot3D[pot [20, 20] //.values/VEvaluate,
{Y, 0,1}, {z, 0, 1}];
You also can view the equipotential lines and the electric field. To save time set nx=10
and ny=10 and apply VEPlot:
In [163]:= VEPlot [
pot [10, 10] //.values//. {x-> 1/2} //
Evaluate, {y, 0, 1}, {z, 0, 1}];
8.3 Laplace's Equation in Cartesian and Cylindrical Coordinates
483
PROBLEM 5 Conducting Cylinder with a Potential on the Surface. Consider a long
cylinder of radius a that is separated by a small lengthwise gap on each side. Use cylindri-
cylindrical coordinates {r,<p, z} and let the length of the cylinder be along the z-axis. One half
of the cylinder @< <p < n) is kept at a potential VO; the other half has a potential -V0.
The symmetry of the problem suggests you should use cylindrical coordinates and that the
solution is independent of z. The solution of Laplace's equation can be represented by a
product of two functions R [r] $[0], where R [r] and <b[<p] are of the form,
and
R[r] =
Cos[n
b[n]r~n
D[n] Sin[n 0].
-Vn
a. Express the potential inside and outside the sphere as a power series in r and 1/r,
respectively. Sum the series to get an exact result.
b. Plot the value of the potential using Plot3D and CylindericalPlot3D.
484 Chapter 8 Electrostatics
Required Packages
In[164]: = Needs["Graphics'ParametricPlot3D'"]
Solution
In [165]:= Clear ["Global' *"];
a. First, construct the potential inside the cylinder. The symmetry of the problem sug-
suggests you should use cylindrical coordinates and that the solution is independent of z. The
solution of Laplace's equation can be represented by a product of two functions R [r] $[0].
Inside the cylinder the potential must be finite at r=0 so that R [r ] is of the form rm. Since
the symmetry of the problem is an odd function in the variable <p, the potential is a super-
superposition of Sin terms
n=l
The solution for <f> has 2n periodicity so the values of n are {1,2,3,...}. You can
determine the coefficients A[n] using the orthogonality properties of the sine function.
On the r=a boundary, the potential is a sum of terms of the form
n=l
This is just a Fourier sine series and the orthogonality properties of Sin allows you to
invert this equation. The expression for A [m] is
i r2"
A[n]an = - Vsin[n<p]d<p
x Jo
The coefficients A [n] are
In [166]:= A[n_] =
a~n
(Intesrate [VO Sin[n0], {<f>, 0, 7r}] -
7T
Integrate [VO Sin [n 0] , {0, n, 2 n } ] ) //
Simplify [#, Element [n. Integers] ] 6
2 ( -1+ (-l)n) a~nV0
Out[166]= ! '
Note that we used the fact that the potential was VO for 0 < <p < n and -VO for n <
<p <2n. The user-defined function for the potential is
In[167]:= potln[nf_] :=Sum[A[n] Sin[n0] r"#
{n, l,
8.3 Laplace's Equation in Cartesian and Cylindrical Coordinates
The first few terms of the potential are
In[168] : = potln[6]
,. , 4VOSinE0)r5 4VOSinC0)r3 4VOSin@)r
Out [168]= e + 5 +
5 ab n 3aJi a n
You get the exact solution for the potential by summing to infinity
485
In [169]:= eql = potln[oo]
Out [169]= — iVO Log
Log
1 -
1- ¦
- Log
- Log
+ 1 -
This can be simplified to give
In [170] : = Vin = eql//. {LosA - aa.) ->
Lob I ^^ I + LOB (aa + 1) ) //FullSimplif y
\aa + 1/ J
i VO Log
Out [170]= --
1 -
e1 a+r
- Log
- 1
Finding the potential outside is similar to finding the potential inside. For the potential
to vanish at infinity the expansion must be expressed in powers of ?:
nf
n=l
On the boundary r=a, you get
nf
n=l
If you invert this equation then you get an expression for B [n],
i r
B[n]cTn = - IV sin[n <f>]d<f>
x Jo
The coefficients for B [n] follow from
:= B[n_] =
an
— (Inteflrate [VO Sin[n0], {0,0, 7r}]
7T
- Intesrate [VO Sin [n 0] , {0, 7r, 2 7r } ] ) //
Simplify [#, Element [n. Integers] ]6
486 Chapter 8 Electrostatics
4 (-a)nV0Sin2 I ^
0ut[171] =
The user-defined function for the potential is
In[172]:= potOut [nf-] :=Sum[B[n] Sin[n0] r'n, {n, 1, nf}];
The first few terms are
In[173]:= potOut[3]
Out[173] = 4VO Sin C 0) a3 | 4V0 Sin@) a
3 n r3 nr
You get the exact solution for the potential by summing to infinity,
In [174] := Vout =
(potOut [oo] //Simplify) //.
[ Los A - »»-) -» Log I —— I + Los (aa +1)}// Simplify
i VO
Out [174] =
Log
- Log
b. Let us plot the potential using Plot3D. Turn off the warning messages
In [175] := Off [Plot3D :: pine, Plot3D : : gval]
and set a=l and VO=1. The graphic for the plot inside the cylinder is
In [176]:= ptl = Plot3D[ Vin/.a-» 1/.V0-» 1 //Evaluate,
{0,0, 2tt}, {r, 0,1 },
PlotPoints -> 40,
DisplayFunction -* Identity];
and the graphic outside follows from
In [177] := pt2 = Plot3D[ Vout/.a-» 1/.V0 -> 1 //Evaluate,
{0, 0,27r},{r, 1,2},
PlotPoints -»40,
DisplayFunction -» Identity];
Joining the two graphs, it follows that
In[178]:= Off[Graphics3D : : nlist3]
In [179]:= Show [{ptl, pt2},
DisplayFunction -» $DisplayFunction];
8.3 Laplace's Equation in Cartesian and Cylindrical Coordinates
487
You can view the potential more directly using CylindricalPlot3D and graphing
just the region from 0 to n. If you restrict the <p to the {0, n] interval, then the graphics for
the inside and outside potentials are
In[180]:= Off[ParametricPlot3D : : pplr]
In[181] := pt3 = CylindricalPlot3D[Vin/.a -> 1/.V0 -> 1,
{r, 0,1}, {0,0.01, 0.99tt} ,
PlotPoints -> 20,
Display-Function -» Identity];
In[182]:= pt4=CylindricalPlot3D[
Vout/.a -> 1/.V0 -> 1, {r, 1, 1.75},
{0,0.01, 0.99 7T},
PlotPoints ->20,
DisplayFunction -» Identity];
Displaying the results, it follows that
In[183]:= Show[{pt3 ,pt4},
DisplayFunction -» $DisplayFunction ];
The range cf> from n to 2n is just the negative of this picture.
488 Chapter 8 Electrostatics
8.4 ¦ LAPLACE'S EQUATION IN SPHERICAL COORDINATES
8.4.1 ¦ Overview of Spherical Coordinates
The solution of Laplace's equation in spherical coordinates can be expressed as products
of /?[r]©[#]<l>[0]. Laplace's equation is satisfied if the functions are of the form
(am sin[w 0] + K cost™ <P] + (ao<P + bQ)
®[ff\ = cn P[n, m, cos@)] + dn Q[n, m, cos@)].
The coefficients follow from boundary conditions.
PROBLEM 1 A Charged Ring. Consider a uniformly charged ring with radius a and
total charge q.
a. Find the potential along the z-axis. Make use of the simplification that all points on
the ring are equidistant from the z-axis. Expand the potential in the limits of r-»0
and r -> oo.
b. Because the solution is axially symmetric, the general potential can be represented
by a product of two functions R [r] ©[#], where
and
R[r] =B[n]r"+A[n]r-(n+1)
= C[n]P[n#Cos[0]] + D[n] Q[n#Cos[0] ].
Find the potential for r<a and for r>a. Determine the expansion coefficients by
evaluating the general potential at 6 = 0 and comparing it with the exact solution
8.4 Laplace's Equation in Spherical Coordinates 489
evaluated on the axis of symmetry in part a. Find the electric field by taking the
gradient of the potential.
c Use Plot3D and ContourPlot to graph the potential in the plane of the ring and
normal to the ring plane. Also plot the equipotential lines and the electric field lines
using VEP lot.
Required Packages
In[184]: = Needs["Calculus'VectorAnalysis'"]
Solution
In[185]:= Clear["Global'*"];
a. Choose the origin of the coordinates at the center of the ring and let the z-axis be
normal to the ring. The distance to the z-axis from the ring is Va2 + z2. In spherical coordi-
coordinates, where z is along the 6=0 direction, the distance from the ring to the axis is Va2 + r2
with 6=0. The potential along the z-axis as expressed in spherical coordinates is given by
In [186] : = potZ :
where q is the charge on the ring and a is its radius. To expand the potential in a power
series you must separately consider the cases r>a and r<a. For r>a you expand about r
= oo and for r<a you expand about r=0. The interior and exterior potentials are
In[187]:= potzin[n_] : =
Series [potZ, {r, 0, n} ] //PowerExpand //
Normal;
potZout[n_] : =
Series [potZ, {r, oo, n}] //PowerExpand//
Normal ;
PowerExpand was used to clean up the results. The first nine terms for the potential
for r<a and r>a are
In [188] : =
Out [188] =
In [189] : =
Out [189] =
potzin[9]
35qr8 5qr6
128 a9 16 a7
potZout[9]
35 q a8 5qa6
128 r9 16 r7
3qr4
' 8 a5
3qa4
' 8r5
qr2
2 a3
qa2
Jr3
q
a
q
r
b. The symmetry of the ring suggests that the general potential depends only on r and 6
and not cf>. The axially symmetric solution of Laplace's equation in {r, 6} coordinates can
be expressed in the form,
490 Chapter 8 Electrostatics
{B[n] [$ + A[n] 0) (C[n]P[n>cos[e]] + DW
n=0
Since the potential is finite at 6=0 you must set the D [n] coefficients to zero. The form
of the potential reduces to
2 Un] (A" + A[n] (;
n=0
The user-defined function for the potential is
In [190] := pot[s_] : =
|j + l^j A(n)
LegendreP[n, Cos [6] ] , {n, 0, s}l
To continue further we must separately consider the series expression for r>a and r<a.
For r>a, the potential must vanish at infinity so B [n] =0 and you are left with
n=0
The user-defined-function for the potential is
In[191] := Vout[s_] =
Sum [I-I A(n) LegendreP[n, Cos [6]],
{n, 0,s}];
The coefficients in the expansion are determined by comparing Vout evaluated on the
axis of symmetry F=0) to the exactly solvable example given by potZout. Subtract
potZout from Vout and set the difference to zero. Use Coef f icientList to extract
powers of j and solve for A [n]. These steps are automatically performed by the function
coeffOut.
In[192]: = coeffOut [s_] : =
Solve[
0 == Coef f icientList [
(Vout [s] - potZout [s]) /.e -> 0, 1/r] ,
A /<? Range [0, s] ] //Flatten
The user-defined function coeffOut solves for A[i] when r>a, e.g.,
In[193]:= coeffOut[3]
Out [193]= (a@) ->-,A(l) ->0,AB) -*—^~,
8.4 Laplace's Equation in Spherical Coordinates 491
You get the potential for r>a to order s by substituting these coefficients into Vout:
In [194]:= potOut[s_] : = Vout [s] /.coeff Out [s]
The first three terms of the potential for r>a are
In [195]:= potOut[6]
3q
Out [195] =
8r5
q L_c2pe1 _iJ
-1 3 I +g
2r3 r
Consider the second case where r<a. For r<a, the potential must be finite at the origin
so A [n] =0 and the potential reduces to
B[n](-T P[n, cosffl]
n=0 W
The potential follows as above with a few obvious changes:
in [196]:= Vin[s_] : =
Sum [I-I B(n) LesendreP [n, Cos [6]],
{n,0,s}]
In [197]:= coeffln[s-] : =
Solve[
0 == CoefficientList [
(Vin[s] -potZin[s])/.e-> 0, r] ,
B/SRange [0, s] ] //Flatten
and
In [198]:= potln[s-] : = Vin[s]/. coeff In [s]
The first four terms of the potential for r<a follow from
in [199]:= potln[6]
492
Chapter 8 Electrostatics
Out [199]= --
3q
231 Cos6 (9) _ 315 Cos4 F) 105 Cos2 (9) _ _5_ 6
16 16 + 16 16 |
35 Cos4 (9) 15CosJ F) 3
8 a5
I I -A
2aJ
The electric fields for r>a and r<a follow from E = -W. Set the coordinates to
Spherical
In [200] : = SetCoordinates [Spherical [r, 0, <p] ];
and then the series expansions for the electric field with r>a and r<a follow from
in[201]:= electout[s-] :=-Grad[potOut[s] ];
In[202]:= electin[s-] : =-Grad[potln[s] ];
For example, the first few terms are
In[203]:= electout[3]
3 a2 q
Out[203]= {^|-
2r4
3 a2 q Cos(9) Sin(9)
2~?
In[204]:= electin[3]
qr
Out [204] =
3qr Cos (9) Sin (9)
c. To plot the potential you switch to Cartesian coordinates and use Plot3D and Con-
tourPlot. Define r2xRule to convert from spherical to Cartesian coordinates:
In [205]:= r2xRule =
{r, 0, 0} -»CoordinatesFromCartesian [
{x, y, z}. Spherical] //Thread
Out [205]= {r -> a/x2 + y2 + z2 ,
9-> Cos
> Tan" (x, y)
Choose the specific values
8.4 Laplace's Equation in Spherical Coordinates
In [206] : = values = {a -» 1, q -» 1};
493
and evaluate the potential inside and outside the ring coordinates. Setting s=12, it follows
that
In [207] : = potOutXYZ [x_, y_, z_ ] = potOut [12] //.r2xRule//.values ;
potlnXYZ [x_, y_, z_ ] = potln[12]/V.r2xRule//.values ;
With the help of an If statement, define a function f f that yields the potential at all
values of {x, y, z}. If the radius, given by yjx2 + y2 + z2, is greater than or equal to a=l,
then use the result of potOutXYZ; otherwise, use potlnXYZ:
In [208]:= f f [x_, y_, z_] : =
If [ N \-\Jx2 + y2 + z21 il, potOutXYZ [x, y, z] ,
potlnXYZ [x, y, z] ]
Plot the potential in the [x, z} plane using both Plot3D and Contour Plot. The
graphics for the plots are
In[209] := ptl = Plot3D[ff [x, 0, z], {x, -2, 2},
{z, -2, 2}, PlotPoints -> 30 ,
DisplayFunction -» Identity];
and
In [210] := pt2 = ContourPlot [f f [x, 0, z], {x, -2, 2},
{z, -2, 2}, PlotPoints -> 30,
ContourSmoothing -»True,
DisplayFunction -> Identity];
Displaying the graphics side-by-side, it follows that
In[211]:= Show[GraphicsArray[{ptl, pt2 } ] ] ;
1.2
The irregularities can be smoothed by taking more terms in the potential expansion.
The corresponding VEPlot for the equipotential lines and the electric field in the {x, z]
plane is
494
Chapter 8 Electrostatics
In[212] := VEPlot[ff [x, 0, z]//Evaluate,
{x, -2.1, 2.1}, {z, -1.6, 1.6},
Epilog-> {{Hue[0.3], Disk[{l, 0}, 0.2]},
{Hue[0.3],
X \
Next, consider the potential in a space slice containing the plane of the ring, {x, y}. The
Plot3D and ContourPlot graphics are
In[213J:= pt3 = Plot3D[f f [x, y, 0] , {x,-2, 2},
{y, -2, 2}, PlotPoints -> 30,
DisplayFunction -» Identity];
and
In[214] .-= pt4 = ContourPlot [f f [x, y, 0],
{x,-2, 2}, {y,-2, 2},
PlotPoints -> 30,
ContourSmoothing -»True,
Bpilog-» {Hue [0.07], Thickness [0.03],
Circle[{0, 0},l]},
DisplayFunction -» Identity];
Displaying the graphs side-by-side, it follows that
In[215].= Show[GraphicsArray[{pt3, pt4}] ] ;
-2
-1
-2-10 1 2
8.4 Laplace's Equation in Spherical Coordinates
495
where a ring image has been inserted into the graph on the right. The correspond-
ingVEPlot for the equipotential lines and the electric field in the ring's plane is
In[216]:= VEPlot [f f [x, y, 0] ,
{x, -2.1, 2.1}, {y, -2.1, 2.1},
Epilosj-> {Hue[0.05], Thickness [0.008],
Circle[{0, 0}, 1]}];
The roughness of the potential at the position of the ring is due to the small number of
terms that were kept in the potential expansion.
PROBLEM 2 Grounded Sphere in an Electric Field. A conducting sphere of radius
a, which is held at zero potential, is placed in a uniform electric field E0. Use spherical
coordinates and choose the z-axis along the direction of the applied field E0. The solution
is symmetric about the z-axis so the potential can be written as an expansion in Legendre
" '•¦.¦¦:
496 Chapter 8 Electrostatics
polynomials:
W @ + B[i] (")'+1)p[i,
i=0
a. Solve for the expansion coefficients by requiring the potential to vanish on the sur-
surface of the sphere. Also use the condition that as r goes to infinity the potential
must reduce to the potential due to the applied electric field. Take the gradient of the
potential to find the electric field.
b. Use the user-defined function VEPlot to graph the equipotential lines and electric
field.
Required Packages
In[217] := Needs ["Calculus'VectorAnalysis]
Needs["Graphics * PlotField*"]
Solution
In[218]:= Clear["Global'*"];
a. Use spherical coordinates and choose the z-axis along the direction of the applied
field E0. The solution is symmetric about the z-axis so the potential can be written as an
expansion in Legendre polynomials. The coefficients {A [ i ], B [ i ]} follow from bound-
boundary conditions. Consider the boundary condition as r -> oo. The potential must go as -E0
r Cos [0], so this requires that all A[i] vanish except for A[l]=-E0 a. This asymp-
asymptotic boundary condition is described by Asol:
In[219]:= Asol = { A[l] -> -E0 a, A[i_] -» 0} ;
The user-defined function for the potential becomes
In[220]:= pot[s_] : =
LesendreP[i, Cos [6]], {i, 0, s}]/.Asol
The values of B[i] follow from the vanishing of the potential on the sphere. First,
evaluate the potential at r=a and set the potential to zero. Second, the command Logic-
Expand can be used to extract equations obtained by setting the coefficients of the powers
of Cos [0] to zero. This is done by tracking the order of the expansion with 0[cos[0]]s+1
and applying LogicalExpand to the potential equation,
In[221]:= Beq[s_] := LogicalExpand[
(pot[s]/.r->a) -= 0 + O[Cos[6]]s+1]
8.4 Laplace's Equation in Spherical Coordinates 497
For example, if s=4 then you get five equations,
In[222]:= Beq[4]
Out [222]= -5BC) ==0AaE0-B(l) + 3BC) == 0A
A 2.
BB) 3BD)
-B@) +~Y~ g^==0A
35BD) __o a 15BD) 3BB) = =
8 4 2
You now have sufficient information to solve for B [i].
In[223]:= Bsol[s_] := Solve [Beq[s] ]//Flatten ;
Let s=6 and apply Solve to the set of equations
In[224]: = Off[Solve :: svars]
In[225]:= Solve[Beq[6] ]//Flatten
Out[225]= {B(l) ->aE0, B@) -> 0, BC) -> 0,
BB) ^ 0, BE) ^0,BD) ^0, BF) ^ 0}
where we turned off the warning message. You can convince yourself by increasing s that
all the B [i] are zero if ±>1, so the solutions for B [i] become
In[226]:= Bsol = {B[l] ->aE0,B[i_] -> 0};
The complete solution for the potential follows from substituting the values of B [i]
into pot [ s ] or equivalently
In [227]:= potential =
LegendreP [i, cos [e] ],
As ol/.Bsol
Out [227] =
a3E0
- E0 r
Cos(9)
Observe that the total potential is a superposition of the applied potential (second term)
and an induced dipole potential (first term).
The electric field follows from E = -VV,
In [228]:= eField =
- Grad[potential, spherical [r, e, «] ] //
r2E0Cos(9)a3 a3E0Sin(9) i
Out [228]= [ 3-^-¦ +E0 Cos (9) , 5—^—- - E0 Sin (9), 0|
498
Chapter 8 Electrostatics
b. To view the equipotential lines and the electric field, first convert to Cartesian coor-
coordinates and then use VEPlot. The transformation from spherical to Cartesian coordinates
is accomplished with the rule
In [229]:= r2xRule =
{r, e, 0} -» CoordinatesFromCartesian [
{x, y, z}. Spherical] //Thread;
Choose specific values for the parameters,
In[230] := values = {EO -> 1, a -> 1};
and use the user-defined function VEPlot to graph the equipotential lines and the electric
field.
In [231]:= pi =
VEPlot[potential//.r2xRule//.values//.
{Y->0},
{x, -2.1, 2.1}, {z, -2.1, 2.1},
Display-Function -» Identity] ;
Since the potential is only defined outside the sphere, we make a disk to mask the
potential inside the sphere.
In[232].- = disk = Graphics[Disk[{0,0}, 1] ] ;
Combining the disk and pi, you get
In[233]:= Show[pl,disk,
Display-Function -» $DisplayFunction ];
8.4 Laplace's Equation in Spherical Coordinates 499
PROBLEM 3 Sphere with an Axially Symmetric Charge Distribution. Consider a
sphere of radius a and assume the sphere has a surface-charge density that can be expressed
in powers of cos"[0]. Use spherical coordinates and expand the potential in Legendre poly-
polynomials:
[ @ 0)i'cos[6]]
IfEn is the normal component of the electric field evaluated on the surface of the sphere,
then the charge density on the sphere is equal to 4n(E°utside -E™side). The normal electric
field En is proportional to the radial derivative of the potential, V# [r].
oF)
a. Solve for the expansion coefficients {A[i] ,B [i]} in terms of a given surface-
charge distribution.
b. Consider a sphere with a surface-charge density given by %Cos(#) + (±)Cos2@)).
Find the potential using the results derived in part a. Use CylindricalPlot3D to
graph the potential. Graph the equipotential lines and electric field in the x=0 plane
withVEPlot.
Required Packages
In[234]:= Needs["Calculus*VectorAnalysis*"]
Needs["Graphics *ParametricPlot3D*"]
Solution
In [235]:= Clear ["Global* *"];
a. The potential can be written as an expansion in Legendre polynomials
y \A[i] (-1 + B[i] (-) P[i, cos[6»]]
1=0 V v ' /
Inside the sphere the potential must be finite at the origin, so all the B[i] terms must
vanish, and the potential becomes
500 Chapter 8 Electrostatics
In[236]:= potInA[s_] : =
Sum[(-| A(i) LegendreP[i, Cos[6]],
{i, 0, s}]
Outside the sphere the potential must vanish as r -> oo, so the A [i] coefficients must
vanish, and the potential follows from
In[237]:= potOutA[s.] t =
±¦1
Sum|A[i] | = | LegendreP[i, Cos[e]],
(j)
{i, 0, s}]
We have replaced B [ i ] with A [ i ] given in pot InA since the coefficients in both ex-
expressions must be the same to make the potential continuous across the sphere.The charge
density on the sphere is equal to ^{E°uts%de - E™Side), where En is the normal component
of the electric field evaluated on the surface and is proportional to the radial derivative of
the potential, V# [r]. The expression for the charge density is,
In [238] : = chargeDensity [ s_] : =
— (D[potInA[s],r] -D[potOutA[s], r])//.
4 7T
For example, the first three terms of the charge density are
In [239] : = chargeDensity [2] //Apart
Out[239]= 15A<2) Cos2 (9) + 3AA) Cos(9) + 2A@) -5AB)
8a7r ian 8 an
To find the coefficients A[i], first equate chargeDensity to the given surface
charge Qdensity. Expand this equation to order s+1 in powers of Cos [6]. Use Log-
icalExpand to obtain a set of equations that follow from equating the coefficients in
front of equal powers of Cos [#] to zero. These steps are all performed by the function
aEquation:
In[240]:= aEquation[s_, Qdensity-] : =
LogicalExpand\
chargeDensity[s] ==
Qdensity + O [Cos [6] ]s+1]
Qdensity is the charge density to be specified (hence the use of the delayed equals,
: =). Solve the aEquation equations to obtain rules for the A [i] coefficients:
8.4 Laplace's Equation in Spherical Coordinates 501
In[241]:= aRule [s_, Qdensity_] : =
Solve[aEquation[s, Qdensity],
Array [A, s + 1, 0] ] //Flatten
For a surface-charge density of Q/a cos[#]2, the first four A [i] coefficients for this
charge density are
r 4 7T 0
0ut[242]= A@) -> ——-, A(l) -> 0,
AB) ->i^°,AC) ->0,AD)
In this simple example, all A [i] for i>2 are equal to zero. You can verify this by taking
larger values of s. The potential for r<a and r>a follows from
In[243] := potInA[4]A aRule I 4,
87:Q
2 2
Out [243]=
15 a3 3 a
q cos2 (e)
In[244] := potOutA[4] /. aRule 4,
L
Out[244]=
r+
15 r3 3 r
b. Consider the surface-charge density
In [245] := surfaceQ = —* = L// Expand
a2
. _„,«., QCos2(9) QCos(9)
Out [245]= 5 + 5
2 aJ ar
The user-defined procedures derived in part a can be used to evaluate this potential. The
potential follows from potlnA and potOutA with values of the expansion coefficients
given by aRule. If we set s=8, then the potential outside the sphere is
In[246] := potOutQ = potOutA[8]//.aRule[8, surfaceQ]
47rQ Cos (9) a 2 7rQ
Out [246] =
s2'
2
15 r3 " iT5 + 17
502 Chapter 8 Electrostatics
Terms that fall off faster than 4- are zero. The potential inside the sphere is
In[247] := potlnQ = potInA[8] //.aRule[8, surfaceQ]
15 a3 3 a2 3 a
Graph the potential in the {r, 8} plane by joining the graphs for the potential inside and
outside the sphere. Use the values
In [248] : = values = {Q -> 1, a -> 1} ;
then the graphic for the potential inside the sphere is,
In[249]:= pi = CylindricalPlot3D[potInQ//.values,
{r, 0,1}, {6, 0, 2tt},
DisplayFunction -» Identity] ;
and outside the sphere, it follows that
In[250]:= p2 = CylindricalPlot3D[potOutQ//.values,
{r, 1, 3}, {6,0,2*},
DisplayFunction -» Identity] ;
The complete graph for the potential for all values of r follows from combining pi and
P2,
In[251]:= Show[pi, p2 ,
AxesLabel -» {a, b, c}.
Viewpoint -> {-1.5, -2, 2},
BoxRatios -> {1, 1, 1},
DisplayFunction -> $DisplayFunction];
8.4 Laplace's Equation in Spherical Coordinates 503
Consider the plot for the electric field and equipotential curves in the x=0 plane and use
VEPlot to graph the electric field and equipotential lines. You must express the potential
in Cartesian coordinates. The transformation from spherical to Cartesian coordinates fol-
follows from the rule
In[252]: = r2xRule =
{r, e, <t>} -» CoordinatesFromCartesian [
{x, y, z}. Spherical] //Thread;
The potentials inside and outside the sphere as expressed in Cartesian coordinates and
restricted to the x=0 plane are given by eql and eq2, respectively:
In [253]:= (*forO<r<l*)
potInQ/.r2xRule/.{Q->l, a-> 1, x->0}//
Simplify;
In[254]:= (*forl <r*)
eq2 [y-, z.] =
potOutQ/.r2xRule/.{Q-> 1, a-> 1, x-> 0} //
Simplify;
Use the command If to combine eql and eq2 into one function that is valid for all
coordinate values. The condition y2 + z2<l is True if you are inside the sphere so the
potential is
in [255]:= pot[y., z.] : =
If [y2 + z2 < 1, eql [y, z], eq2 [y, z] ]
Draw a circle to overlay on the plot
In [256] := circle =
{Thickness [0.02], Circle [{0,0}, 1]} //
Graphics;
The graphics for the equipotential lines and electric field follow from
In [257]:= Show[
{VEPlot [pot [y, z], {y, -2,2}, {z, -2,2},
Display-Function -» Identity],
circle},
Display-Function -» $DisplayFunction] ;
504
Chapter 8 Electrostatics
PROBLEM 4 Sphere with a Given Axially Symmetric Potential. Consider a sphere
of radius rO whose surface is held at a fixed potential V [#]. Use spherical coordinates and
expand the potential in Legendre polynomials:
1=0
VF)
a. Show the coefficients in the expansion can be expressed in terms of an integral over
the surface potential and derive the expression for the potential inside and outside
the sphere for an arbitrary surface potential V [#].
b. Illustrate the procedure by considering the example V[6] = V0CosFJ. Plot the po-
potential as a function of {r, 6} using CylindricalPlot3D.
c. Find the potential when the surface potential is l [™^L and the radius of the sphere
is rO=l Plot the potential as a function of {r, 6} using CylindricalPlot3D.
8.4 Laplace's Equation in Spherical Coordinates 505
Required Packages
In[258]:= Needs["Calculus *VectorAnalysis»"]
Needs["Graphics *ParametricPlot3D*"]
Solution
In[259].- = Clear["Global1* "];
a. The symmetry of the problem suggests you should use spherical coordinates {r,
6, <p} and assume the solution is independent of <f>. Expand the potential inside the sphere
in Legendre polynomials keeping only positive powers of r so that the potential is finite at
r=0:
In [260]:= potIn[V_, s_] : =
Sum
\ 1 x \n 1
I —I B(V,n) P[n,Cos[6]], {n, 0, s} I
where rO is the radius of the sphere and P are Legendre polynomials. Outside the sphere,
keep only negative powers of r so that the potential vanishes at r= oo, the potential be-
becomes
In [261] : = potOut [V_, s_] : =
Sun
r i _ » n+1 "I
I^-J B(V, n) P[n, Cos[6]], {n, 0, s} I
Continuity of the potential on the sphere required the coefficients to be the same in
potOut andpotln so we set A[i] =B[i] inpotOut.
On the surface of the sphere the potential must be V [0]. We can expand V [#] in Leg-
Legendre polynomials. Specifically, V[ff\ = ? B[V, n]P[n, 0] where
B[V,n]= Bw+1) f d0sm[O]P[n,cos[O]]V[0i
2 Jo
The user-defined function for B [V# n] is
In [262] := B[V_, n.] : =
Integrate [V LegendreP [n, Cos [e] ] Sin [e],
b. To illustrate the procedure, consider an example where the potential on the sphere is
V0 Cos(#J. For s=4, the potential outside is
In[263] .= pOut = potOut [v0Cos[6]2, 4]
Out[263]= 2v0pB'Cos(9)) r°3 , V0P@,Cos(9)) rO
3 r3 + 3 r
506
Chapter 8 Electrostatics
and the potential inside follows from
In[264] := pln = potln [vo Cos [e]2, 4]
Out [264]= 2VOPB,Cos(9))r^lvo
3 rCr 3
To plot the potential, choose the substitutions
In [265] : = values = {rO -> 1, VO -> 1, P -> LegendreP};
First, plot the potential inside the sphere
In [266]:= pi = CylindricalPlot3D[pin/.values,
{r, 0, 1}, {6, 0, 2n},
DisplayFunction -» Identity] ;
and then plot the potential outside the sphere
In[267] := p2 = CylindricalPlot3D[pOut/.values,
{r, 1, 3}, {6, 0, 2tt},
DisplayFunction -> Identity] ;
Combining the graphics, it follows that
In [26 8] .= Show [pi, p2,BoxRatios -> {1, 1, 1},
Viewpoint -> {-1.5, -2, 2},
DisplayFunction -» $DisplayFunction] ;
.25
-2
c. Consider the case where the radius of the sphere is rO=l and the surface potential is
given by
8.4 Laplace's Equation in Spherical Coordinates
in[269] .= surfacePot =
507
The first four terms of the potential inside and outside the sphere are
In[270]:= {pln2, pOut2} =
({pot In [ surfacePot , 3 ],
potOut[surfacePot,3]} /.
P->LegendreP//.{rO ->1}//Simplify) ;
First, plot the potential inside the sphere,
In[271] := pi = CylindricalPlot3D[pIn2, {r, 0, 1},
{6, 0, 2n}, PlotRange -> All,
DisplayFunction -> Identity] ;
and then the potential outside the sphere
In[272]:= p2 = CylindricalPlot3D[pOut2, {r, 1, 3},
{e, 0, 27T}, PlotRange -> All,
DisplayFunction -» Identity];
Combining plots, you have the potential for all regions of space:
In[273]:= Show [pi, p2,
BoxRatios -» {1, 1, 1},
Viewpoint -> {-1.5, -2, 2},
DisplayFunction -> $DisplayFunction];
508 Chapter 8 Electrostatics
PROBLEM 5 Sphere with Upper Hemisphere VO and Lower Hemisphere -VO.
Consider a sphere of radius rO with a surface potential that is described by a discontinu-
discontinuous function. The top hemisphere has a potential +V0, and the bottom hemisphere has a
potential -VO. In spherical coordinates the potential in Legendre polynomials is
[*,cos[0]]
a. Evaluate the expansion coefficients and find the potential inside and outside the
sphere. Evaluate the series for the first few terms.
b. Use ContourPlot to graph the equipotential curves in the x=0 plane.
Required Packages
In[274]:= Needs["Calculus *VectorAnalysis»"]
Needs["Graphics *ParametricPlot3D*"]
Solution
In[275] .-= Clear ["Global» * "];
a. The symmetry of the problem suggests you should use spherical coordinates [r, 6, <p}
and assume the solution is independent of <p. Therefore, expand the potential inside the
sphere in Legendre polynomials with positive powers of r so that the potential is finite at
r=0
In[276]:= potln[s.] :=Sumf[ — I B (n) P[n, Cos [6] ] ,
l\rO/
{n, 0, s}]
where rO is the radius of the sphere and P are Legendre polynomials. Outside the sphere,
expand the potential in Legendre polynomials with negative powers of r so that the poten-
potential vanishes at r = oo:
8.4 Laplace's Equation in Spherical Coordinates 509
In[277]:= potOut[s.] : =
SumM^J B(n) P[n, Cos[e]], {n, 0, s}]
Continuity of the potential on the sphere requires the coefficients B [i] to be the same
in potOut and pot In.
As was the case in the previous problem, it follows from the orthogonality of the Leg-
endre polynomials that the coefficients B [ i ] are
In[278] : = B[n_] : =
(+ Integrate [V0 LegendreP [n, Cos [e] ]
Sin[e], {6, 0,7r/2}] +
Integrate [-V0 LegendreP [n, Cos [e] ]
Sin[6], {0,7r/2,7r}])t
Note that we used the information that V=V0 for 0 < 8 < n/2 and V=-V0 for n/2
< 6 <n. The first few terms for the potential outside and inside the sphere are, respectively,
In[279]:= potOut[5]
11VOPE, Cos (9) ) rO6
Out [279] =
16 r6
7V0PC, Cos (9)) rO4 3 V0 P(l, Cos (9) ) rO2
8 r4 2 r2
b. To view the potential, consider the values of the parameters
In [280] := values = {rO -> 1, V0 -> 1, x- > 0} ;
and then express the potential in Cartesian coordinates. The transformation from spherical
to Cartesian coordinates follows from the rule
In[281];= r2xRule=
{r, 0, 0} -» CoordinatesFromCartesian [
{x, y, z}. Spherical] //Thread;
The conversion rules are
In[282]:= allRules=
{P -» LegendreP , r2xRule, values}//
Flatten ;
Applying r2xRule to potln[s] andpotln[s] for s=ll, you get
In[283]:= eql= potln[ll]//.allSules;
In[284].= eq2 = potOut[11]//.allRules;
510
Chapter 8 Electrostatics
Defining one function for the potential inside and outside the sphere, it follows that
In [285] := potTot = If [y2 + z2 S 1, eql, eq2] ;
Next, draw a circle to overlay on the plot.
ln[286] := circle = Graphics [{Thickness [0 .02] , Circle[{0, 0}, 1]}];
Applying ContourPlot to potTot, you can see the equipotential lines for this po-
potential
In[287] := Show[{
ContourPlot [potTot //Evaluate,
{y, -2, 2}, {i,-2,2},
PlotPoints -> 20,
Display-Function -» Identity],
circle},
Display-Function -» $DisplayFunction] ;
-2
The islands on the top and bottom boundaries of the spherical surface result from the finite
number of terms in the potential expansion.
8.5 Exercises 511
8.5 ¦ EXERCISES
The solutions to many of these exercises can be found on our web sites.
8.1 Parallel Plates and Strips
Consider parallel plates located in the {x, z} plane. One plate is located at y=0 and the other at
y=L. The plate at y=L is at zero potential except for a strip along the jc-axis from x = {+d, -d).
The strip is at potential Vo.
(a) Find the potential and graph the equipotential surfaces and electric field.
(b) Generalize the problem to allow for n parallel strips that have the same width, potential, and
separation.
8.2 Parallel Plates and a Point Charge
Two infinite, grounded conducting planes are at x= 0 and x=L. A point charge q is placed between
the planes.
(a) Find the charge induced on the planes and graph the results.
(b) Generalize part a to include n charges between the plates. Graph the results for three charges.
8.3 Cylinder Divided into Segments
Consider an infinite, hollow conducting cylinder of radius b. Divide the cylinder into two equal
segments that run parallel to the axis of the cylinder. The top segment has constant potential +V,
and the bottom has potential -V.
(a) Expand the potential in cylindrical coordinates. Can you sum the series and get an exact
expression for the potential?
(b) Graph the equipotential surfaces and electric field for the potential.
(c) Generalize the problem for a cylinder divided into 2n equal segments that have potentials
that alternate in sign.
8.4 Elliptical Cylinder in a Uniform Electric Field
An infinitely long, conducting elliptical cylinder bearing no net charge is placed in an initially
uniform electric field Eo. The cylinder is grounded. The direction of Eo is perpendicular to the
cylinder's axis.
(a) Find the potential and its electric field.
(b) Plot the equipotential surfaces and electric field.
8.5 Cylindrical Box and n Charges
Consider a conducting cylindrical box with one end at z=0 and the other at Z=L. The radius
of the cylinder is r0. The walls are kept at zero potential. A positive charge is placed inside the
cylindrical box.
(a) Find the potential inside the cylindrical box. Plot the equipotential surfaces and electric field.
(b) Find the charge induced on the conducting walls and plot the results.
(c) Generalize the results to include n charges inside the box.
8.6 Distorted Sphere with a Potential
Consider a distorted sphere whose surface is held at a fixed potential V[#]. The shape of the
surface is described by the radial coordinate r = ro(l + cP[l, Cos#]). The parameter c and the
Legendre polynomial P describe the distortion,
(a) Derive an expression for the potential inside and outside the sphere.
512 Chapter 8 Electrostatics
(b) Find the potential when the surface potential is V [6] = Cos [0]. Plot the potential as a func-
function of {r,6}.
(c) Plot the potential found in part b in the two planes denned by x=0 and z=0.
8.7 Concentric Spheres with Different Potentials on the Two Hemispheres
Two concentric spheres have radii a, b (fc»a) and are each divided into two hemispheres by the
same horizontal plane. The upper hemisphere of the inner sphere and the lower hemisphere of the
outer sphere are maintained at potential V. The other hemispheres are at zero potential.
(a) Determine the potential.
(b) Graph the electric field and equipotential surfaces.
8.8 Ring Charge
Consider a total charge q distributed around a circular ring of radius r0. The axis of the ring is
along the z-axis, and the center of the ring is located at z=b. The charge per unit length is a
function of <f>.
(a) Find the potential everywhere.
(b) For the charge density, ^{Cos@) - SinB$)}, find the asymptotic expression for the potential
and electric field.
(c) Plot the results.
8.9 Laplace's Equations in Other Coordinates
Consider the coordinate systems EllipticCylindrical, Bispherical, and Toroidal.
For each of these systems solve the following problems.
(a) Express Laplace's equation as a product of three functions and derive an ordinary differential
equation for each function.
(b) Find the solutions for the functions and write the general expression for the potential.
(c) Write a procedure that will return the separated Laplace equations when you input a given
coordinate system.
CHAPTER
9
Quantum Mechanics
9.1 ¦ INTRODUCTION
This chapter contains problems on nonrelativistic quantum mechanics found in standard
texts for upper division physics students. We cover the essential points of Schrodinger the-
theory for both one-dimensional problems and three-dimensional problems. Many kinds of
graphics are used to display the results, and the reader is encouraged to modify the po-
potentials, boundary conditions, and graphics to better understand the solutions. The purpose
of this chapter is to develop an understanding of the Schrodinger equation by means of
problem solving. We start this chapter with a brief introduction to Quantum Mechanics.
In 1913, Danish physicist Niels Bohr made one of the first attempts to formulate a
quantum theory of the atom. He realized that the electrons in hydrogen could possess only
discrete sets of energy values. Bohr proposed three postulates concerning the structure of
an atom:
1. Atomic electrons move in orbits restricted by the requirement that the angular mo-
momentum I be an integral multiple n of fi = 1~. Furthermore, the electrons in these
orbits do not radiate. For an electron of mass m and velocity v moving in a circular
orbit of radius r, the angular momentum quantization restricts the electron's velocity
according to the relation I = mvr, where the angular momentum I = nh.
2. Transitions from one state to another are accompanied by a gain or loss of energy
equal to the energy difference between the two states. The energy loss can appear as
electromagnetic radiation.
3. If an electron falls from orbit nt to nf with a change in energy of Ei - Ef, the energy
difference can appear as radiation with angular frequency Et - Ef = fi oj, where
at = 2nf, and / is the frequency.
The success of Bohr's provisional theory with hydrogen-like atoms gave impetus for
additional research on this quantum approach. The modern theory of quantum mechanics
was ushered in with the works of Heisenberg, Born, Jordan, Schrodinger, and Dirac in the
1920s. Modern quantum mechanics uses wave functions to describe the probability that a
particle will be found at a space-time point.
In 1925, Erwin Schrodinger and Werner Heisenberg independently developed the new
quantum theory. Schrodinger's method involves partial differential equations, whereas
Heisenberg's method employs matrices. These two methods are mathematically equiva-
equivalent. Most textbooks begin with Schrodinger's equation. The time-dependent Schrodinger
513
514 Chapter 9 Quantum Mechanics
equation is a partial differential equation in space and time:
where V represents the potential energy of the system. The operator V2 is the Laplacian
and in Cartesian coordinates it is
, d2 d2 31
V2 = i i
dx2 dy2 dz2
Schrodinger's equation is of fundamental importance in a wide range of physical phe-
phenomena where quantum mechanics is important. The concepts of energy eigenstates,
quantum mechanical tunneling, and scattering are evident in solutions of the Schrodinger
equation.
The state of a quantum mechanical system is completely specified by the function
\j/[x, t], which depends on the coordinates of the particle and on time. This wave func-
function has the important property that it determines the probability that a particle is located
at x at time t. The wave function must satisfy certain mathematical conditions because of
this probabilistic interpretation. For the case of a single particle, the probability of finding
it somewhere is 1, so that you have the normalization condition
Mx.tTifix.fldxS = 1
The wave function \j/ describes the physical problem. The probability current or flux is
given by the vector equation:
The Schrodinger equation plays the role of Newton's laws in classical mechanics, i.e., it
predicts the future behavior of a dynamic system. A wave equation that determines a wave
function, predicts the probability of events.
For time-independent potentials it is possible to express the wave function as a product
e~'~ri/f[x,y,z]. The time coordinate gives the parameter En, which is the energy of the
quantum state. The time-independent wave function for a single particle of energy En in a
potential V obeys the time-independent Schrodinger equation:
^V4r + V En4r
Zm
The solution of Schrodinger's equation gives the wave function for a particle in a poten-
potential V.
The solutions of Schrodinger's equation simplify for systems that can be described with
one variable. For example, Schrodinger's equation for systems that are only a function of
the x-coordinate reduces to
~ifr"[x] + V[x]4r[x]=EJ[x]
Zm
9.2 One-Dimensional Schrodinger's Equation
515
Further simplifications occur if the potential is a constant. The constant potential is the
simplest one-dimensional boundary problem.
This chapter is divided into two problem sections: 9.2 One-Dimensional Schrodinger's
Equation, and 9.3 Three-Dimensional Schrodinger's Equation. In section 9.2 we illustrate
the affects of wells and barriers. Potential barriers in the form of a well allow you to inves-
investigate quantized energy levels and their associated wave functions. Step potentials allow
you to investigate phenomena associated with quantum tunneling and scattering. With a
step barrier, some of the wave will be reflected, some will be transmitted, and some of
the wave will penetrate into the barrier. These concepts are then applied to more complex
problems for three dimensions in section 9.3. Exercises are included in section 9.4.
Before starting the problems you might find it convenient to turn off the spell checker:
In[l]:= Off[General :: "spell"];
Off[General :: "spelll"];
9.2 ¦ ONE-DIMENSIONAL SCHRODINGER'S EQUATION
PROBLEM 1 Particle Bound in an Infinite Potential Well. Suppose a particle is
bound by the infinite potential well defined byV = 0if0<;t<a and V = <x> otherwise.
Schrodinger's one-dimensional time-independent equation is
Zm
where V is the potential that describes the system. This simple one-dimensional boundary
problem illustrates the methods used to evaluate quantized energy levels and their associ-
associated wave functions.
a. Show that the general solution of Schrodinger's equation inside the well can be writ-
written in the form
Cos[fcc] + C[2] Sin[fcc]]
where En= ^.
Am
V(x)
516 Chapter 9 Quantum Mechanics
b. The boundary condition requires the wave function to vanish at x = 0 and a. Use this
condition to show that the allowable energy states are En = n2n2fi2/2a2m, where n =
1,2, 3.... Show the corresponding normalized wave functions are sf2 sin[^]/-y/a.
c. Explicitly verify that the first four wave functions are orthonormal and plot the wave
functions.
Required Packages
In[2]:= Needs["Graphics* Legend *"]
Solution
In[3]:= Clear["Global1*"] ;
a. The one-dimensional wave equation is
En)#[x] a' *"[x] ¦
ln[4]:= eql= 0 ==
En)#[x]
2m
Consider the region 0<x<a, where the potential is zero. Schrodinger's equation reduces to
In [5] : = eq2 = eql/.V -> 0
0ut[5]= 0 == -^ (X) h -Eni)f(x)
2m
If you simplify the notation by expressing the energy En in terms of the wave-number k,
»2k2
In [6] := krule = En -» ;
2m
then Schrodinger's equation becomes
In[7]:= schrod = Solve [eq2Akrule, *" [x] ][ [1, 1] ]/.Rule-» Equal
0ut[7]= tji" (x) == -k2 i/f(x)
The general solution for this simple one-dimensional problem follows immediately
from DSolve:
In [8] : = dsol = DSolve [schrod, ¦, x] [ [1, 1] ]
Out [8]= ijt -> Function {x} , cx Cos (kx) + c2 Sin (kx) I
The constants {C[l]# C [2]}, as well as the allowable values of the energy En, are
determined by the boundary conditions and by normalizing the wave function. The solution
is returned in pure form so Reduce, applied in the next section, returns all the solutions
for the boundary values.
9.2 One-Dimensional Schrodinger's Equation 517
b. The boundary condition requires the wave function to vanish at x=0 and a. Set \j/ to
zero at x=0 and x=a and then use Reduce to find all possible solutions,
In[9].-= soil = Reduce [{#[0] ==0,*[a] == 0}/.dsol]
Out[9]= C-L == 0 Ac2 == 0 Vct == 0 A Sin (a k) == 0
The only nontrivial solution is C [1] =0 and Sin [a k] =0, which is equivalent to set-
setting k= ™ where n is an integer. The allowable energy states follow from En= ^:
Out [10]= En ==
2m
Note that the energy levels differ by a factor of n2.
The solution for the wave function becomes
/.dsol/. {c[l] -> 0, k -> —
Out[11]= c2 Si
The constant C [ 2 ] follows from normalizing the wave function according to the criteria,
1= f 4f[x]*4r[x]dx:
In[12].-= normEq = 1 == Integrate f*[x, n]2, {x, 0, a}| //
Simplify [#, Element [n. Integers] ]&//
Solve[#,c[2]][[2,1]]6
V2
Oat [12]= C2^^=
Va
where only the positive root was kept. The complete normalized wave function is
In[13]:= #[x_,n_] = #[x, n] /.normEq/YSimplify
V2 Sin I sax
Out[13]=
c. You can integrate over the product of the wave functions to verify that they are or-
thonormal. Form a table of integrations over the products of the first four wave functions,
ln[14]:= table = Table[Intearate[*[x,i]*[x,j], {x,0,a}], {i,4}, {j,4}];
Displaying the results with TableFoxm, it follows that
In[15]:= TablePorm[table,
TableHeadings ->
518
Chapter 9 Quantum Mechanics
Out [151 =
ill {2) ill C) i/fD)
0 0 0
10 0
0 10
0 0 1
To graph the wave functions make a table of the wave functions for the first four energies
and apply Plot. It follows that
In[16] := Plot [ Table [#[n, «]# {"*' 4}]/.{a-> 1}//Evaluate,
{x, 0,1},
PlotStyle ->{{}, Dashing[{0.05}],
Dashing[{0.03}] , Dashing[{0.01}] },
PlotLabel -> StyleForm[i/f, Fontsize -> 14,
FontWeight ->Bold],
PlotLegend-> {"n = 1", "n = 2", "n = 3", "n = 4" },
LegendPosition -> {1, -1/2}] ;
-0.5
\ v / \ ' \ /'
This plot made use of PlotLegend and LegendPosition found in the add-on
package Graphics * Legend * that was loaded at the beginning of this problem. Notice
the wave functions with odd n={l,3#...} are symmetric about x=l/2, and the wave
functions with even n={2,4, ...} are asymmetric.
PROBLEM 2 Particle Bound in a Finite Potential Well. Consider a potential well
given by V[x]= -V0<0 if-a<x<a, and V[x]= 0 otherwise. This problem is the finite
generalization of the infinite well solved in the previous problem. Suppose a particle with
V(x) = -V
+a
9.2 One-Dimensional Schrodinger's Equation 519
negative energy En=-Wh<0 is bound in the finite well, The wave function follows from
the solution of Schrodinger equation but the solution must be treated separately in the three
regions: x<-a, -a<x<a, and a<x. The boundary condition requires the wave function
to vanish as x->+oo and as x->-oo. In addition, the wave function and its derivative must
be continuous across the boundaries of the well.
a. Show that the wave functions in the well, to the right of the well, and to the left of
the well, can be written as
ifrW = cSym Cos[kWx] + cAsym Sva[kWx\ -a<x<a
4fR = cRe~qLRx x>a
fL = cLeqLRx x<-a
where
and qLR =
Notice the parameter kW and qLR are real since V0>Wh>0. Also observe that in the
well there are symmetric (cAsym=O) and asymmetric (cSym=O) oscillating solu-
solutions.
b. Use the boundary condition that the wave function and its derivative are continuous
across the well's boundaries. Consider separately the boundary conditions that fol-
follow for the symmetric (cAsym=O) and asymmetric (cSym=O) in-well waves. Apply
Reduce to get all possible solutions for the boundary conditions and determine the
constants {cL#cR}. Also show for the symmetric wave that the energy eigenval-
eigenvalues follow from the equation Tan [a kW] = ^ and for the asymmetric wave the
energy eigenvalues are determined by Tan [a kW] = -¦% •
c Consider the four potential well depths, V0={100# 200, 500, oo} and set
{a->l, m->l, #->l}. Use graphic procedures to solve for the energy eigenvalues.
Express the energy eigenvalues in a form similar to the infinite well by measuring
the energy levels from the bottom of the well and parameterizing the energy values
with n where Wn= V0 ~"^^2. Verify that the value of n approaches an integer in
the limit that V0-> oo.
d. Repeat the energy eigenvalue determination using the command FindRoot with
the parameters found in part c.
e. Let V0=100 and plot the symmetric and asymmetric wave functions that correspond
to the energy eigenvalues found in part d.
Solution
In [17] : = clear [ "Global' * " ] ;
a. This one-dimensional boundary problem illustrates a simple nontrivial solution of
Schrodinger's equation where the wave can penetrate into the walls of the well. Begin with
520 Chapter 9 Quantum Mechanics
the one-dimensional Schrodinger equation,
In[18] := sohrodeq = 0 == (V-En) #[x] - h * [X] ;
2m
First consider the solution in the well (-a<x<a) where V<En<0. If you express the energy
En in terms of the wave-number kW,
r KW2 h2 i
In[19]:= EWl jEk
jEn>+vk
I 2m J
then the solution of Schrodinger's equation can be expressed as
In[20]:= tfr[x]/.DSolve[schrodeq, #[x],x] [ [1, 1]]/.
EWrule//ExpToTrig //Simplify //PowerExpand
Out[20]= Ic1 + c2\ Cos(kWx) +i (c^-Oj) Sin(kWx)
The wave-number kW is related to the energy via the relation kW = ^2m(^""y). If you
rewrite this expression in terms of V0 and Wn then
~Jl Vm (En - V)
In[21]:= KWrule= KW -> -—*— -/.V -> -VO/.En -» -Wn
h
where V0>Wn>0. The value of kW is real and the solution is oscillatory. It is instructive to
separate even and odd solutions. Thus, you define the constants so the wave function in the
is
In [22] := t(W[x.] = oSym Cos [KWx] + oAsym Sin[KWx] ;
Now consider the solutions to the left of the well where x<-a and to the right of the
well where a<x. The potential is zero in both regions. If we express the energy En in terms
of the wave-number kLR,
In[23] := ELRrule = (En-» ]•;
I 2m J
and then solve Schrodinger's equation with V=0, it follows
In[24] := *[x]/. DSolve[sohrodeq, *[x] , x] [ [1, 1]]/.
V-» 0/.ELRrule //Simplify //PowerExpand
Out [24]= elkLRxc1 + e-
The value of kLR is
Out [25]= kLR
9.2 One-Dimensional Schrodinger's Equation 521
It is convenient to define kLR=I qLR so that qLR is real:
V2 V"»to
In [26] : = qLRrule = qLR -> — ;
h
The solution becomes
In[27] := #[x] /. DSolve[schrodeq, #[x] , x] [[1,1]]/.
V->O/.ELRrule/.fcLR-> I qLR//
Simplify// PowerExpand
The wave function has both exponentially decreasing and increasing terms. If you
choose the values of C [1] and C [2] so the wave vanishes to the right of the well as x
goes to +00 then it follows that
In[28]:= *R[x_] = cRe""" ; (*x>a*)
To the left of the well the wave function must vanish as x goes to -00 so
In[29]:= *L[x_] = cLe**""; (*x <-a*)
b. The boundary condition requires the wave function and its derivative to be continuous
at the boundaries. Four equations follow from applying these continuity conditions at x=a
andx=-a,
In [30]:= eql = {
==0)/.{x- >-a},
==0)/.{x->+a},
L' [x] - W [x] == 0) /. {x- > -a},
[x] - m' [x] == 0) /. {x- > +a} }
Out[30]= (e'aqLR cL-cSym Cos (akW) + cAsym Sin (a kW) ==0,
-e'aqLRcR+ cSym Cos (akW) + cAsym Sin (a kW) ==0,
cL e'aqLR qLR - cAsym kW Cos (a kW) -
cSymkW Sin(akW) = = 0, cR e'a qLR qLR+
cAsymkW Cos (akW) - cSymkW Sin (akW) == 0}
To find the wave function constants {cSym, cAsym} and the energy eigenvalue equa-
equation you consider separately the symmetric (cAsym=0) and asymmetric (cSym=0) solu-
solutions.
First proceed with the symmetric solutions. If you set the constant cAsym to zero in
eql then the boundary condition reduces to
In [31 ] : = (eq2 = eql/.cAsym -> 0 ) //ColumnFoxm
522 Chapter 9 Quantum Mechanics
Out[31]= cLe'aqLR- cSym Cos(akW) ==0
cSym Cos(akW) -cRe'aqLR==0
cL e~aqLR qLR - cSymkW Sin (a kW) == 0
cR e'aqLR qLR - cSymkW Sin (a kW) ==0
You get all boundary value solutions by applying Reduce to eq2. Include a few ex-
extra constraints {cL^O, cR^O, cSym^O, kW^O, kLR^O}, so you are not burdened
with trivial solutions, and apply Reduce
In [32] := eq3 =
Reduce[
{ eq2 , OL ji 0, OR ji 0, KW ji 0, qLR * 0,
cSyiM 0, Cos[ aKW] * 0 }//Flatten ,
{OL, OR} ] ;
eq3 //ColumnFoxm
Out[32]= cL == cSymeaqLR Cos(akW)
cR == cSym ea qLR Cos (a kW)
qLR == kW Tan(akW)
cSym t 0
kW + 0
Cos (akW) + 0
Sin(akW) * 0
The first two equations give the wave function amplitudes {cL# cR} and the third part
gives the energy eigenvalue equation. Apply Solve to eq3 to separate out the amplitudes.
In[33]:= symSol =
Solve[eq3 , {cL, cR} ] //Simplify//Flatten
Out[33]= [cL-> cSymeaqLR Cos(akW) ,
cR -> cSym ea qLR Cos (a kW) }
The third equation in eq3 gives the energy eigenvalue equation, which can be written
as
In[34]:= symEn = Tan[aKW] == qLR/KH;
Let us now turn to the case of the asymmetric wave function. The solution is completely
analogous to the symmetric case. The primary difference is that you let cSym->0 and set
cAsym^O. The boundary conditions reduce to
In [35] := eq4 =
Reduce[
{ eql/.cSym-» 0 , oL * 0, OR * 0, KW 4 0,
qLRji CcAsym* 0,Cos[aKW] * 0 }//
Flatten , {cL,cR} ] ;
eq4 //ColumnFoxm
9.2 One-Dimensional Schrodinger's Equation 523
cAsym eaqLR kW Cos (a kW)
Out [35]= cL == -
cAsym eaqES kW Cos (a kW)
cR — — —
qLR
kWCos(akW)
Sin akW) ==
qLR
cAsym f 0
kW* 0
qLR t 0
Cos(akW) t 0
The first two equations give the amplitudes {cL# cR} and the third part gives the energy
eigenvalue equation. Apply Solve to eq4 to get the wave amplitudes,
In[36]:= asymSol=
Solve [eq4 , {cL, cR} ] //Simplify//Flatten
cAsym eaqLR kW Cos (a kW)
Out [36]= [cL-
cR-> -
qLR
cAsym eaqLR kW Cos (a kW)
qLR J
The energy eigenvalue equation for the asymmetric case is
In [3 7J:= asymEn = Tan [ a KW] ==-KW/qLR;
c. The transcendental equation for the symmetric energy eigenvalues follows from
symEn and asymEn gives the asymmetric energies. Although you cannot analytically
solve these energy eigenvalue equations, you can graphically solve them. Choose {a->l,
m->l, #->l} and consider the four potentials V0={l00,200,500,oo}:
In[38] := values = {a -> 1, m-> 1, h -> 1, VO -> { 100, 200, 500, oo}} ;
Before you proceed, re-parameterize the energy in terms of the expression Wn=V0 - "^ :
In [39] : = nRule = Wn -> V0 =— ;
8a2m
This energy form is chosen so that in the infinite well limit (V0-> oo) the value of n
approaches an integer. You can monitor the progression of the solutions toward, or away,
from the case of the infinite well by comparing the values of n with integers.
Define the rules
In[40]:= KRules¦
and consider the energy values for the symmetric solutions. The eigenvalue equation for n
follows from symEn
eq5=symEn/.KRules/.nRule//PowerExpand
524
Chapter 9 Quantum Mechanics
Out[41]= Tan
nji
where nRule was used to express the solutions in terms of n.
The allowed values for n follow from plotting the left and right sides of eq5 as a
function of n, and observing where the curves intersect. Instead of plotting the left and
right sides of eq5 you can equivalently plot the ArcTan of the two sides:
In [42] .-= ptl =
Plot[
{AroTan[eq5 [ [1] ] ] , AroTan[eq5 [ [2] ] ] }/.
values // Evaluate ,
{n, 0,9},
Frame-* True,
FrameTicks -»
{{{1, "n = l"}, {3,"n = 3"}, {5,"n=5"},
{7, "n = 7"}, {9, »n = 9"}},
{0, 0.5, 1,1.5}},
PlotRanse -> {0.4, 1.6},
DisplayFunction -» Identity];
Attach the following text to enhance the readability of the graph.
In[43] := text = {
Text[ "VO-oo", {6, 1.5}],
Text [ "V0 = 500", {6,1.3}],
Text [ "V0 = 200", {6,1.1}],
Text [ "V0 = 100", {6,0.8}]};
Combining the text and graph along with grid lines, it follows
In[44]:= Show[ptl, Graphics[text] ,
GridLines -» Automatic,
DisplayFunction -> $DisplayFunction] ;
n=l n=3 n=5 n=7 n=9
1.5
1
0.5
/
4
t
/
-1
t
1 v0
4-
f
ve=
50Gf|
^op
f
/
n=l
n=3
n=5
n=7
1.5
0.5
n=9
9.2 One-Dimensional Schrodinger's Equation 525
The four sloping horizontal curves come from the four choices of VO substituted into the
right-hand side of eq5. The slanted vertical lines come from the arctan[tan[y]] function
on the left-hand side of eq5; the intersections of these curves with the sloping horizontal
lines give the values of n corresponding to the energy eigenfunctions. The straight vertical
lines are an artifact of the Tan [ x ] function, which is singular at x=hjt/ 2 for odd n; these
lines and their intersections should be ignored. The curves intersect just below the odd-
integer values. Notice that in the case of an infinite potential (V0=oo), the eigenvalues are
precisely the integers n={l# 3# 5#7# 9,...} as expected. As VO decreases, the values
of n deviate more and more from integers.
The asymmetric solutions follow from the equation asymEn,
In[45]:= eq6=asymEn/.kRules/.nRule//PowerExpand
Out [45]= Tan
Take the ArcTan of both sides of eq6 and plot the two curves. Define the text
In[46]:= text = {
Text[ "VO-oo", {7, 0}],
Text [ "VO = 500", {7,-0.4}],
Text[ "VO = 200", {7,-0.7}],
Text[ "V0 = 100", {7,-0.9}]};
and display the results
In [47]:= Plot[
{ArcTan[eq6 [ [1] ] ] , ArcTan[ eq6 [ [2] ] ] } /.
values // Evaluate ,
{n, 0. ,9},
Frame -»True,
FrameTicks ->
{{{2, "n = 2"}, {4, "n = 4"}, {6, "n = 6"},
{8, "n=8"}},
{-1.5, -1, 0, 0.5,1, 1.5}},
PlotRanjje-> {-1 , 0.1},
GridLines -» Automatic,
EpilojJ -> text ] ;
526
Chapter 9 Quantum Mechanics
n=2
n=4
n=2
n=4
n=6
n=8
/
1
4
f
\
l T7A
>
vo=
\
T
n=6
n=8
-1
The intersections of the sloping horizontal curves with the sloping vertical curves are
just below even-integer values. At V0=oo the values of n are even integers.
d. Let us now solve for the symmetric and asymmetric n values by using the command
FindRoot. The n values follow from the function
In [48] : = nValues [eq., potential., guess.] : =
(n/.
FindRoot[
eq/.{m-» l,a-»l,fi-»l,
VO ->potential}//Evaluate,
{n,guess}][[1]])
The term eq stands for eq5 in the symmetric case and for eq6 in the case of the
asymmetric solutions. An initial guess must be given to find the roots. For the symmetric
solutions, consider three different values for the potential, VO={100# 200, 500} and
solve for the first five eigenvalues. Let us make an initial guess for the five values of n that
are just below odd integers:
In[49] := symGuess = {0.9, 2 .9, 4 .9, 6.9, 8 .9};
The values of n are
In[50]:= symValues=
{nValues[eq5,100, #]
, nValues[eq5, 200, #]
, nValues [eq5, 500, #] }& /<? symGuess;
The list for the asymmetric solution follows in a similar manner. Let the guess be just
below the even integers,
In[51] := asymGuess = {1.9 , 3.9 , 5.9, 7.9 };
and then it follows that
In[52]:= asymValues=
{nValues [eq6, 100, #]
, nValues [eq6, 200, #]
, nValues [eq6, 500, #] }& /<? asymGuess;
9.2 One-Dimensional Schrodinger's Equation
527
Combining the two classes of solutions and displaying the results in table form, you find
In [53]:= Partition[
Sort [ { symValues , asymValues } // Flatten] ,
3]//
TableFoxm[#,
TableSpacing -> {0,2},
TableHeadings -»
{{"n = 1", "n = 2", "n = 3", "n = 4",
"n = 5", "n = 6", "n = 7", "n = 8",
"n = 9"}, {"V0 = 100", "V0 = 200",
"V0 = 500"}}
]&
Out [53] =
n= 1
n = 2
n = 3
n = 4
n= 5
n = 6
n = 7
n = 8
n = 9
V0 = 100
0.933848
1.86702
2.79876
3.72819
4.65414
5.5749
6.48773
7.38736
8.26041
V0 = 200
0.952339
1.90442
2.85598
3.80671
4.75628
5.70426
6.65015
7.59322
8.53247
V0 = 500
0.969335
1.9386
2.90773
3.87664
4.84526
5.8135
6.78128
7.74848
8.71498
These are the first nine energy values for the potentials V0=100# 200 and 500.
e. Let us graph the first nine symmetric and asymmetric wave functions for the potential
V0=100. First consider the symmetric waves. Define the parameters and rules for the
symmetric case:
In[54]:= symRules=
{kRules, nRule, symSol, a -» 1, h -» 1,
m-» 1, V0 -» 100, cSym-> 100, cAsym-> 0}//
Flatten
Out[54]= [
kW-
V2 Vm (V0 - Wn7
, qLR-
h " h
Wn -> VO - -—j—' cL -> cSym ea qLR Cos (a kW) ,
8 a. m
cR-> cSymeaqLR Cos(akW) , a-» 1, fi-» 1,
m^ 1, VO -> 100, cSym^ 100, cAsym ^ o}
Also define a wave function valid for all values of x. The complete symmetric wave func-
function to the left, inside, and right of the well is,
In[55]:= Clear[s*,
(¦Symmetric*)
x<-l, n0.] := (*L[x] //.synlRules//. {n- >n0}) ;
-1 <=x <l,n0.] := (t(W[x]//.syjBRules//.{n->n0})
.syjBRules//. {n- >n0}) ;
528 Chapter 9 Quantum Mechanics
The values nO are the eigenvalues for the wave function.
The five symmetric energy eigenvalues of Wh for V0=100 are given by
In[56] := symEnergy = nValues [eq5, 100, #]&/@symGuess;
The graphics for the corresponding wave functions are
In [57]:= plotsym =
x, #]//.symRules//Evaluate
, {x,-2, 2}
, PlotLabel- > Number Form [#, 2]
, Axes-> None
, DisplayFunction- >Identity
] 6 /<? symEnergy;
Displaying the results with GraphicsArray, you obtain
In[58]:= Show[GraphiosArray[plotsym[[1, 2, 3] ] , plotsym[ [4, 5]]]];
0.93 2.8 4.7
6.5 8.3
Now consider the plot for the four asymmetric wave functions. Define the parameters
and rules for the asymmetric wave:
In[59]:= asymRules=
{kRules, nRule, asymSol, a -»1, h -»1,
m-> 1, V0 -> 100, cAsym-* 100, cSym-» 0}//
Flatten
r ^Jm (V0 - Wn)
Out [59]= kW^^i
h
qLR -> -— , Wn -> V0 -
cL-
h 8 af- m
cAsym eaqLR kW Cos (a kW)
qLR '
cAsym eaqLR kW Cos (a kW)
cR —> / 3. —> 1 /
qLR
fi->l,m->l,V0->100, cAsym-> 100, cSym -> o|
The complete asymmetric wave function to the left, inside, and right of the well is,
9.2 One-Dimensional Schrodinger's Equation 529
In[60]:= (*Asymmetric*)
a#[x./;x <-l, nO.] := (tfrL[x] //.asymRules//. {n- >nO}) ;
a#[x./; -1 <=x <l,nO.] := (t(W[x] //.asyjBRules//. {n- >nO});
a#[x./;x>= l,nO_] := (*R[x] //.asyiBRules//. {n- > nO}) ;
The five asymmetric energy eigenvalues Wh for V0=100 are given by
In[61] := asymEnergy = nValues [eq6, 100, #]&/@asym<3uess ;
The graphics follow from
In[62]:= plotasym =
Plot[ai/f[x, #]//.asymRules//Evaluate
,{x,-2,2}
, Plot Label- >NumberFoxm[#, 2]
, Axes- > None
, DisplayFunction- >Identity
] 6 /SasymEnergy;
Displaying the asymmetric results, it follows that
ln[63] := Show[GraphicsArray [plotasym[ [1, 2] ] , plotasym[ [3, 4] ] ] ] ;
1.9 3.7
7.4
PROBLEM 3 Particle Hitting a Finite Step Potential. Consider a particle of energy
En approaching a potential barrier defined by V [x] = 0ifx<0;andV[x] =VO if x>0.
The general solution of Schrodinger's equation with constant potential is given by c\eikx +
c2e~lkx, where the wave vector is ~ = En- V0. The constant En represents the energy
and the constant potential is V0. The wave to the left of the barrier ^L [x] has an incident
wave and a reflected wave so it can be written as \j/L[x\ = eikLx + e~MjcR where kL =
/ imEn an(j ^ js ^ reflection amplitude. The wave to the right of the barrier ^R [x] has
only a transmitted wave so it is of the form fR[x] = eikRxT, where kR = ^WEn-vo) and T
is the transmission amplitude.
a. Use the boundary condition at the barrier to evaluate the amplitudes for the reflected
and transmitted waves and show: R = ^|| and T= ^
530 Chapter 9 Quantum Mechanics
x = 0
b. The flux follows from ^ (i/f*Vi/f-Vi/f*i//) and the current densities follow from apply-
applying the flux expression to the appropriate parts of the wave function. The coefficient
of transmission TT is defined as the ratio of the transmitted current density to the
incident current density. Likewise the coefficient of reflection RR is the ratio of the
reflected current density to the incident current density. Show that TT and RR can be
expressed as RR= ^'fjl and TT= ,^TkL^2 ¦ Plot RR, TT and their sum RR+TT as a
r (kL+kRy (kL+kR)
function of En.
c. Plot the real and imaginary parts of the wave function for energies above and below
the barrier.
d. Use Plot3D to graph the wave function as a function of the two parameters {x#
En}.
e. An animation is generated by forming a table of wave plots evaluated at different
times. Animate the real parts of the incident, reflected, and transmitted waves for
energies above and below the barrier.
Required Packages
In[64]:= Needs["Graphics'Legend'"]
Solution
In[65]:= Clear["Global»*" ] ;
a. The general form of the wave is cletkx + c2e~tkx, where the wave vector is ^ =
En - VO. A particle that approaches from the left (x<0) is reflected by the barrier at x=0
so it has an incoming and reflected part:
In[66]:= *L[x.] = eikLX+ e"ikLXR;
The term e+lkx represents the incident wave; without loss of generality you can set its
coefficient to one. The term e~lkLx represents the reflected wave with amplitude R. To the
left of the barrier the potential is V0=0 so the wave number kL is given by
In [67]:= kLRule = kL ->
9.2 One-Dimensional Schrodinger's Equation 531
The wave to the right of the barrier (x>0) has only a transmitted component traveling
to the right, so it is of the form
In[68] : = tfiR[x_] =eikEXT;
where the wave vector kR is
_i (En - VO)
In [69] : = kRRule = kR -> V2 , / —- j ;
The boundary condition requires the wave function and its derivative to be continuous
at x=0. The two boundary equations are
In[70]:= boundary = {tfrL[x] = = tffR [x] , #L'[x] == #R' [x] }//.x -¦ 0
Out[70]= {R + 1 == T, ikL- ikLR — ikRT}
Solving for the T and R amplitudes, you obtain
In[71]:= RTrule = Solve [boundary, {R, T}]//Flatten//
Simplify
kL - kR 2kL 1
T
0at[71] =
kL + kR ' kL + kR J
b. The current densities follow from finding the flux due to the appropriate parts of the
wave function. To find the transmission and reflection coefficients you must define the flux
operator ^{f^f - V^*^). To construct the flux operator you first define the complex
conjugate symbol (see Chapter 1),
In[72]:= exp.* := exp/.{Complex [a., b.] » Complex [a,-b] }
The "Superstar" notation exp.* is done by enclosing the expression with () and
making a superscripted *. It is just the complex conjugate operator. For example,
ln[73]:= (a-ib + e9)"
a + ele + ib
Contrast this with the built-in function Conjugate:
In[74] := Conjusate [a - ib + e e 1
Out [74]= Conjugate (a-ib) + e1 conjugate(e)
The Conjugate function is more cautious as it does not assume {a#b##} are real. You
next define the V operator,
ln[75]:= Vf.: = D[f, #]& /0 {x,y, z}
which takes the gradient of a scalar, e.g.,
532 Chapter 9 Quantum Mechanics
ln[76]:= V#[x ]
Out[76]= W (x.) , 0, 0}
The flux operator is
In[77]:= flux[>_] := (#* v#- V** #) //Simplify
If you apply flux to \j/L [x]
In[78]:= *L[x] //flux//Simplify
, kL(R2-l)fi
Out[78]=
then this expression has both the incident and reflected flux. You can obtain just the incident
flux by setting R-»0,
In[79]: = inePlux = flux[*L[x] ] /.{R-»0}
Out[79]= (-^— , 0, o]
The reflected flux is simply the difference of the incident flux and the total flux on the
left-hand side,
In [80]:= Rflux= (inePlux - flux [*L[x] ]) //Simplify
Out[80]= ( ,O,o|
I m J
Finally, the transmitted flux follows from applying flux to \j/R [x],
In [81]:= Tflux = flux[tfR[x]]
Out[81]= ( ,O,o]
I m J
The vector currents are in the x direction so you can drop the vector notation and con-
consider only the first component of the vectors. The transmitted and reflected coefficients
follow from dividing the reflection and transmitted currents by the incident current:
In[82]:= RR, TT = Rflux[[1]]/incPlux[[1] ] , Tf lux[[1]]/incPlux[[1]]
Out[82]= (r2, )
I- kL J
If you substitute the solutions for R and T into this expression, it follows that
In [83] := RR, TT = RR, TT/. RTrule
(kL-kRJ 4kLkR i
r
Out [83 =
(kL + kRJ (kL + kRJ
As a cross check, you can verify that the sum of the transmitted and reflected coefficients
equals unity, thereby demonstrating current conservation:
9.2 One-Dimensional Schrodinger's Equation
533
In[84]:= RR + TT//Simplify
Out[84]= 1
Let us plot as a function of En the transmitted and reflected coefficients as well as their
sum. Choose the following specific numerical values
In [85]:= values = {m-> 1, »-> 1, VO-> 1} ;
Applying Plot to RR, TT and TT+RR, it follows
In[86]:= Plot[
{RR, TT, TT + RR}/.RTrule/.kLRule/.
kRRule/. values // Evaluate,
{En, 1,2},
AxesLabel -> {"E", "Coefficient"},
PlotStyle-* {Dashing[{0.06, 0.02}],
DashinB[{0.02}], {}},
PlotLes«nd -> { "RR" , "TT" , "TT + RR" } ,
LegendPosition -> {1, -1/2},
PlotRanjje -> {0, 1}] ;
Coefficient
1,
0.8
0.6
0.4
0.2
1.21.41.61.8 2
?=% E
RR
TT
TT+RR
c. Consider the plots for the real and imaginary parts of the wave function when the
incoming energy is greater than the barrier (En>V0), and for the case when the energy is
below the barrier (En<V0). Let us first evaluate all the parameters in ifrli [x] and if/R [x].
Define the general rule
In[87].= kRule = {fcLRule,kRRule};
and then the evaluation of {^L [x], \j/R [x]} is given by wave [x. En]:
In [88] := wave [x_. En.] =
{*L[x], *R[x]}/.RTrule/.kRule/.
values //Simplify ;
The function wave is a list of both the wave to the left and right of the barrier with all
substitutions. Use Which to construct a wave \f/ [x. En] that takes the appropriate solution
for x to the left and to the right of the barrier:
In[89]:= *[x.,En_] : = Which[ x i. 0, wave[x. En] [ [1] ] ,
x > 0, wave [x. En] [[2]]]
534
Chapter 9 Quantum Mechanics
Now define the function waveplot2D to plot the Re and Im parts of the wave.
In [90] : - waveplot2D [Energy.] : =
Plot [{#[x. Energy] //Re,
*[x. Energy]//Im},
{x,-10,10},
PlotStyle-> {{}, Dashinsj[{0.02}] },
AxesLabel -> {"x", "y"}];
Consider the case where the incoming particle has energy above the barrier En=l. 1
(i.e., 110% of V0). The plot of the real and imaginary parts of the wave are
In [91]:= waveplot2D[l.l];
The real part of the wave function is denoted by a solid curve and the imaginary part by
a dashed line. Notice, the wave is oscillatory but the frequency decreases on the right of
the barrier.
Consider the case where the incoming particle has energy below the barrier En=0.9
(i.e., 90% of V0):
:= waveplot2D[0.9]
Notice that the transmitted wave is exponentially damped as the wave tunnels into the
classically forbidden region.
d. Let us illustrate how the wave function behaves as a function of both the energy and x
by using Plot3D Plot the Re and Im parts of the wave function for values of En between
9.2 One-Dimensional Schrodinger's Equation
0.5 and 1.5. First, you have for the real component,
In[93] .-= Plot3D[#[x, Energy]//Re, {x, -10, 10},
{Energy, 0.5, 1.5}, PlotPoints -> 50,
AxesLabel-> {"x", "Energy", "#"}];
535
-5
10
Then, for the imaginary component, you have
In[94] := Plot3D[#[x, Energy] //Im, {x, -10, 10},
{Energy, 0.5, 1.5}, PlotPoints -> 50,
AxesLabel -> {"x", "Energy", "*"}];
Energy
-10
-5
Energy
Observing the two graphs it follows that for Energy<1 and x>0 the wave damps as it
tunnels into the classically forbidden region. For Energy>1 the wave energy is above the
barrier height and the wave continues to oscillate for x>0.
e. Let us animate the real part of the incident, reflected, and transmitted waves. Multiply
by the factor e~l ~~*~, where fi is set equal to one, to get the time dependence for the wave
function. The graphics for the time dependent wave function is generated by the function
timePlot.
536
Chapter 9 Quantum Mechanics
In [95]:= timePlot [time., En_] : =
Plot [ {Exp [-I En time]#[x. En] //Re,
Exp[-IEntime]#[x, En]//Im},
{x,-10,10},
PlotStyle-* {{}, {Thickness [0.008]}},
PlotRanjje -> {-2, 2}] ;
Here is a sample of timePlot for En<V0,
In[96]:= timePlot[1.,0.9];
The thin line is the real part, and the thick line is the imaginary part. To animate the
wave you embed timePlot inside a Do loop, and plot this for a series of time steps. We
choose timestep so that for a given number of frames, the animation moves through
a complete cycle. Here is a sample with En<VO
In[97]:= frames = 1;
Energy = 0.9;
timestep =
(frames)Energy'
Do [timePlot [n timestep , Energy] ; , {n, 1, frames}]
10
where we have set frames=1 To generate more frames increase this number. Likewise,
here is a sample with En>V0.
9.2 One-Dimensional Schrodinger's Equation
537
In[98]:= frames = 1;
Energy = 1.1;
timestep
(frames)Energy'
Do[timePlot [ntimestep , Energy] ; , {n, 1, frames}]
PROBLEM 4 Particle Propagating Toward a Rectangular Potential. Consider a par-
particle with energy En>0 propagating from the left (x<-a) toward a rectangular well or bar-
barrier. The potential is described by: V(x) =V0 if -a<x<a and V(x) =0 otherwise, where
V0 is a constant. If V0>0, then the potential describes a barrier and for V0<0 the potential
describes a well. The general solution of Schrodinger's equation with a constant potential
is given by cxeikx + c2e~llcx- The wave solutions to the left, right, and in the center of the
potential must be treated separately. The wave to the left of the potential, called tfrli, has
an incoming and reflected component. You can set the amplitude of the incoming wave to
one and let R be the amplitude of the reflected wave. The wave to the right of the potential,
called tf/R, has only a transmitted wave; let its amplitude be T. The wave in the potential
region (-a<x<a) can be described by two amplitudes, call them A and B. The boundary
conditions determine the amplitudes {A, B# R#T}.
V(jc) =
Particle
V(x) = 0
+a
a. Write the general form of the wave function to the left, center, and right of the
well/barrier.
b. Use the boundary condition to evaluate the wave amplitudes and show
538 Chapter 9 Quantum Mechanics
p-2iakLR f_i , pAiakW\ (Uj n _ VO/\(hT J? 4. i-UA
R -
A = -
B =
e4iakw(kLR - kWf - (kLR + kWJ
2e~ia(-kLR-m)kLR(kLR + kW)
e4iakw(kLR - kWf - (kLR + kWJ
2e-ia(.kLR-3kW)kLR(kLR-kW)
e4iakW(kLR-kWf -(kLR+kwf
4e-2ia(kLR-kW)kLRkW
T =
e4iakW(kLR-kWf-(kLR+kWf
c. The coefficient of transmission (TT) is denned as the ratio of the transmitted current
to the incident current. Likewise, the reflection coefficient (RR) is denned as the
ratio of the reflected current to the incident current. Show the x-component of the
reflection coefficient is
(kLR2 - kW2J sin[2akW]2
RR =
4kLR2kW2 cos[2akW]2 + (kLR2 + kW2J sin[2akW]2
and the x-component of the transmission coefficient is
4kLR2kW2
TT =
4kLR2kW2 cos[2akW]2 + (kLR2 + kW2J sin[2akW]
Verify that TT+RR=1.
d. As a function of En, plot the coefficients of transmission (TT) and reflection (RR)
for a potential well (V0<0) and for a potential barrier (V0>0).
e. As a function of the energy and potential, use Plot3D to plot the reflection and
transmission curves.
f. Plot the real part of the wave for the complete range of x.
g. Animate the time dependence of the real part of the wave as it propagates through a
barrier (V0>0# 0<En<V0).
Solution
In [99]:= clear ["Global'* *"];
a. The general solution of Schrodinger's equation with a constant potential is given by
cxeikx + c2e~ikx. The general form of the wave number is k = V2m(f"y). For x < -a
there is an incident wave traveling to the right, and a reflected wave traveling to the left.
The amplitude for the incident wave is set equal to one without loss of generality, and the
amplitude for the reflected wave is called R. The form of the wave is
In[1001:=
There is only a transmitted wave with amplitude T for x > +a, so the wave becomes
eikLRxT;
9.2 One-Dimensional Schrodinger's Equation 539
The wave function in the central region (-a<x<a) is
In[102]:= tfW[x_] =Be"lk*Itleik"Ii
Given the form of the potential function the expressions for kLR and kW are
In [103]:= kRules = J "»-*'•> ' iEa~v0)
b. The boundary condition requires the wave function and its derivative to be continuous
across the boundaries. Applying these conditions at x=a and x=-a gives four equations:
In [104] : = eql =
[x] -HflH[x] = =0)/.{x->-a},
==0)/.{x->+a}.
Simplify ;
If you apply Solve to these equations then the amplitudes {A, B# R# T} follow,
In [105]:= ABRTrule =
Solve [eql, {A, B, R, T} ] //FullSimplify //
Flatten;
ABRTrule //ColumnForm
e-2iakLR / x+ e4iakw| (kLR-kW) (kLR + kW)
Out[105]= R^ ^^ '-
9 -la (kLR-k'w)
, __._,2 - (kLR + kWJ
2 e-i a (kLR-3 kW) kLR (kLR _ kw)
_4iakW (kLR-kWJ
4 e-2ia (kLR-kW)
T^ "e4lakw (kLR-kWJ- (kLR + kWJ
c. The transmission and reflection coefficients are defined as the ratio of the transmitted
and reflected currents relative to the incident current. To construct the flux or current oper-
operator ^(^"V^ - V^*^) you first define the notation for taking the complex conjugate (see
Chapter 1),
In [106]:= exp_* : =
exp /.{Complex [a_, b_] :-> Complex [a,-b] }
For more details of this operator see the previous problem. Beware, the constants in the
expression are assumed to be real. If you define the gradient operator
In[107] := Vf- := D[f, # ]6/0 {x, y, z}
540 Chapter 9 Quantum Mechanics
then the flux operator follows from
In [108]:= flux [#_] : = -^- (tfr* v* - v#* *) // Simplify
Applying flux to \j/L gives both the incident and reflected flux to the left of the potential.
The incident flux follows from setting R=0.
In[109] : = incFlux = f lux[*L[x] /.R -> O/.ABRTmle ]
Out[109] = {^,O,o}
The reflected flux is simply the difference of the incident flux and the total flux on the
left-hand side.
In[110]:= Rflux= (incPlux - f lux[#L[x] /.ABRTrule]) //ExpToTrig//Simplify
Out[110]= j(kLR (kLR2 -kW2) h Sin2 B a kW)) /
(m D kLR2 kW2 Cos2 B a kW) +
(kLR2+kW2) Sin2 B akW) j j , 0, 0}
The flux on the right-hand side follows from applying flux to ^^R. This flux contains
only the transmitted flux so
In[lll]:= Tflux =
flux[tfR[x]/.ABRTrule]//ExpToTrig //
Simplify
Out[111]= {DkLR3kW2fi)//(m D kLR2 kW2 Cos2 BakW) +
(kLR2+kW2) Sin2 BakW))) , 0, 0}
The vector currents are in the x direction so you only need to consider the first com-
component of the vectors. The transmitted and reflected coefficients follow from dividing the
reflection and transmitted currents by the incident current,
In [112] := {RR, TT} = {Rf lux[ [1] ]/incFlux[ [1] ] ,
Tf lux [ [1] ] / incFlux [ [1] ] };
{RR, TT}//ColumnForm
(kLR2 - kW2) Sin2 B a kW)
Out [112]= 4kLR2 kW2 Cos2 B akW) + (kLR2+kW2) Sin2BakW)
4 kLR2 kW2
4 kLR2 kW2 Cos2 B a kW) + (kLR2 + kW2 J Sin2 B a kW)
Notice, the current is conserved.
In[113]:= TT + RR==1 //Simplify
Out[113]= True
9.2 One-Dimensional Schrodinger's Equation
541
d. Consider a potential well with V0=-100. To plot RR and TT as a function of the
energy, make the following choice for the parameters.
In [114] := values = {fi-»l,m-»l,a-»l};
The graph of these coefficients for energies between 1 and 200 follows from
In [115]:= Plot[
{RR, TT}/.kRules/.{V0 -> -100}/.values//
Evaluate, {En, 1,200},
AxesLabel -> {"En", "RR, TT"},
PlotStyle-> {{},Dashing[{0.02, 0.02}]}];
M
RR, TT
1
0.8
0.6
0.4
0.2
50
100
150
200
En
The dashed curve is TT and the solid curve is RR. Notice the decrease in the reflection
coefficient with increasing energy.
For the next example consider a potential barrier with V=+l and let the values of En
range from 0 to 5:
In [116] := Plot[
{RR, TT}/.kRules/.{VO -> +1}/.values//
Evaluate, {En, 0, 5},
AxesLabel -> {"En", "RR, TT"},
PlotStyle-* {{}, Dashing[{0.02, 0.02}]},
PlotPoints -> 50
RR, TT
0.8
0.6
0.4
0.2
En
542
Chapter 9 Quantum Mechanics
Again, the dashed curve is TT and the solid curve is RR. Note, for En above about 2V0 the
reflection coefficient of the barrier is essentially zero.
e. You can use Plot3D to illustrate the reflection and transmission curves for a range
of potential and energy values. Consider wells whose potentials range from V0=0 to -20.
For the transmission coefficient, you obtain
In[117] := Plot3D[TT/.kRules /.values/.a-> 1//
Evaluate, {En, 0, 10}, {V0, -20, 0},
PlotPoints ->40,
Ticks-* {Range [0, 10, 5], Range [-20, 0, 10],
{0,1/2,1} },
AxesLabel -> {"Energy", "Potential", "TT"}];
Energy
¦ r itential
-2 0
Similarly for the reflection coefficient:
Plot3D[
RR/.kRules/.ABRTrule/.values/.a ->1//
Evaluate, {En, 0, 10}, {V0, -20, 0},
PlotPoints -> 40,
Ticks -> {Range [0, 10, 5] , Range [-20, 0, 10],
{0,1/2,1}},
AxesLabel -> {"Energy", "Potential", "RR"}];
tential
9.2 One-Dimensional Schrodinger's Equation
543
f. Consider the plot of the wave function for the complete range of x. Let {#->l, m->l}
and make all substitutions into the waves to the left of the potential, in the potential, and to
the right of the potential:
, aa_], (f* [x_, aa_],tfR[x., aa_] } =
x] , (dW[x] , *R[x] } /.ABRTrule/.
kRules//.{»-> 1, m-» 1, a-> aa} //
Simplify;
Now define the function \j/ [x, a ], which extracts the appropriate solution in each region
of the potential,
In[120]:=
_, a_] : = Which[x s -a, tfrL[x, a],
-a<xs a, t/rW [x, a], a < x, 0t[x, a]]
The function iff defines the wave everywhere.
Set the boundary of the potential at a=2, the energy at En=l and let the potential well
be V0-»-12. The graph of the real part of the wave function is
Plot[ #[x, 2] /.{En-> 1, VO -> -
{X,-15, 15},
Epilog-> {Thickness [0.02] ,
Line[{{-2,0}, {2,0}}]}];
-15
0
.6
1 0.4
t
-0
.4
.6
•
I
The dark line is the region of the well.
Likewise, you can graph the absolute value of the wave function, \\j/[x, a]\2:
In[122]:= Plot [ tfr[x, 2]*[x, 2] * //.
{En-> 1, V0-> -12} , {x, -15, 15},
Epilog-> {Thickness [0.02],
544
Chapter 9 Quantum Mechanics
. . .3.5
3
E.5
2
1.5
1
q.5
\ . Jyyj
-15 -10
10
g. Let us animate the real and imaginary parts of the wave as it propagates through the
barrier @<En<V0). To get the time dependence for the wave, you multiply the wave by
e-iEj/h w-m ^=1 Tjje jjjjjg dependence of a wave is described by the function timePlot.
In[123]:= timePlot [t_, En_, V0_] : =
Plot[
[e~iEat/b 4f[x, 2] //Re,
Evaluate,
{X,-15, 15},
PlotStyle ->
{{}, {Dashing[{0.02}],
Thickness[0.008]}},
PlotRange -» {-2, 2},
Epilog-> {Thickness [0.02],
Line[{{-2,0},{2,0}}]}];
You then embed this into a Do loop to generate the sequence of frames for animation.
Let us display the case where V0=l. 1, and En=l,
In[124] := frames = 1;
V0 = 1.1;
En = 1;
tlmestep = 27r/(framesEn);
Do[timePlot [ntlmestep. En, V0] , {n, 1, frames}]
9.2 One-Dimensional Schrodinger's Equation 545
The real part is the solid line, and the imaginary part is the thick dashed line. The number
of animation frames is determined by frames.
PROBLEM 5 The One-Dimensional Harmonic Oscillator. Consider a particle bound
by a force proportional to its displacement, F = -k x. The potential of the restoring
force is the harmonic potential V[x] = \k x2. The harmonic oscillator potential is one
of the basic problems in quantum mechanics. It can be applied to the explanation of the
vibration spectra of diatomic molecules, the motion of atoms in a solid lattice, or the theory
of heat capacity.
a. Solve the Schrodinger equation,
[^-+V[x\f[x\=Enij/[x\
Zm
and express the results in terms of k = co2m, En = {n+ \)ti o», and a2 = ~. By
considering the physical characteristics of the wave function, namely, that it vanish
at infinity, show that the unrenormalized solution is e ^Hn[^], where n is an integer
and Hn[^] are Hermite polynomials. Write the energy levels for the first few states.
b. Show that the normalized wave function can be written as
and display the solutions for n=0,... .4. Plot the normalized wave function and
the square of the normalized wave function.
Solution
In[125]:= Clear["Globall*"] ;
a. The one-dimensional Schrodinger equation with a harmonic oscillator potential is
In[126] := eql = 0 == (V-En) #(x) y /.V->
2m 2
Out [126]= 0 ==
¦ - En
V (x)
2m
Apply DSolve to get the solution of this differential equation,
In[127] := eq2 =
DSolve [eql, *[x] , x] [ [1] ] //PowerExpand //
Simplify
546
Chapter 9 Quantum Mechanics
Out [127]= |i/f(x) ->e ra~ c, HEn
If you define the notation
In[128] := notations [k -> <u2m. En -» I - +nj ha.
1 En^/m 1
4 2 Vkfi' 2 ' fi
then the solution simplifies and you get
In[129]:= dsol =eq2[[l]] //.notation//PowerExpaad//Simplify
Out[129]= i/r(x) ->e in2
n 1 x
2 ; 2 ; ^
In the above notation a> is the frequency defined by a> = -J ^ and o- is a convenient
grouping, a = -J ~, that determines the scale of the x-variable. The solution is a linear
combination of HermiteH and HypergeametriclFl functions. The Hypergeo-
metriclFl can be eliminated because it does not have the correct boundary condition at
infinity, or it can be expressed as a linear combination of HermiteH functions. In order
for the wave to vanish at infinity, you must set n equal to an integer or zero in Her-
HermiteH [n,x]. Hence, if you dispense with the HypergeametriclFl function and
express the solution in terms of only HermiteH polynomials where n=0,l,2,3, it fol-
follows that
In[130] :=
Out[130]= e 2«2 h -
n\a
x]/.dsol/. C[2]
The wave function contains a Gaussian form multiplied by a polynomial of order n
called a Hermite polynomial.
The harmonic oscillator solution leads to a sequence of evenly spaced energy levels
characterized by a quantum number n:
In[131]:= energylevels=En/.notation/.\a
/ k / 1
0ut[131]= J - n+ - | h
ml 2 ,
For example, the energy levels for n=0,1,2,3 are
In[132] := energylevels/.n-»Ranse[O, 3, 1]
9.2 One-Dimensional Schrodinger's Equation 547
m 2 A/ m 2 A/ m 2
In real systems the energy spacings are equal only for the lowest levels where the po-
potential is a good approximation to the "mass on a spring" type harmonic potential. The
most surprising difference between the classical simple harmonic oscillator and the quan-
quantum case is the so-called zero-point vibration of the n=0 ground state. This implies that
molecules are not completely at rest, even at absolute zero temperature.
b. To normalize the wave function you define the norm
In [133]:= norm[n_] : =
Intesrate [#0 [x , n] #0 [x , n] , {x, -co, oo} ,
Assumptions -»
{a > 0 , Element [n. Integers] } ] //Sqrt
It can be shown that the norm is equivalent to -J2" n\a*\fn. Verifying this relation for the
first 6 values of n, it follows that
ln[134]:= Table[norm[n] = =
Sqrt[ 2~n n! a Sqrt [tt] ] , {n, 0, 5}]
Out [134]= {True, True, True, True, True, True}
The normalized wave function becomes
In[135]:=<Hx-,n.l= *° ["' n]
Out [135] =
As the final cross check, you can verify that these first four wave functions are properly
normalized by integrating over the square of the wave function:
In[136] := Table f Intesrate [#[x, n]2 , {x, -oo, oo}.
Assumptions -> { a > 0}l , {n, 0,3}l //PowerExpand
Out[136]= {1, 1, 1, 1}
The first four wave functions are
In[137]:= table = *[x, #]6 /0 Ranse[0,3] //Simplify;
In[138]:= TableForm [table,
TableHeadings ->
0] ", "#[x, 1] ". "*[x, 2] -, »#[x, 3] - }}]
548
Chapter 9 Quantum Mechanics
Out[138]=
0]
(a2 - 2x2
2] --
3]
e 2 ^ x 2 xJ - 3 or
Next, plot the first eight wave functions. The wave function plot follows from
in[139]:= Plot[
Table[#[x, n]/2 + n,{n,0,7}] /. {a-» 1}//Evaluate ,
{x, -6, 6} ,
EpilojJ-> Plot [0.6 z, {z, -6, 6},
PlotStyle -> Thickness [0.01],
Display-Function -» Identity
-6
-4
The functions have been vertically offset so that the vertical axis roughly corresponds to
the eigenstate. Also the amplitude of the waves was multiplied by 1/2. The curve for the
harmonic potential was added with the command Epilog.
Similarly, the plot of the square of the wave function is
In [140] := Plotf
Table [#[x, n]2 + n, {n, 0,7}] /.{a->l} //Evaluate, {x, -5,5},
Epilog-» Plot [0.6 z~2, {z, -6, 6},
PlotStyle -» Thickness [0.01] ,
DisplayFunction -> Identity
9.3 Three-Dimensional Schrodinger's Equation
549
-2
9.3 ¦ THREE-DIMENSIONAL SCHRODINGER'S EQUATION
PROBLEM 1 Three-Dimensional Harmonic Oscillator in Cartesian Coordinates.
Consider the three-dimensional Schrodinger equation,
2m
y, z] + (V[x, y, z] - En) f[x, y,z] =
(9.1)
where the potential is of the form V [x# y, z ] =Vx [x] +Vy [y ] +Vz [ z ].
a. Assume the wave function is separable and can be written in the form X [x] Y [y]
Z [z]. Reduce the three-dimensional problem to three separate one-dimensional dif-
differential equations for X [x], Y [y ], and Z [z] and show
n2x"[x]
O=-Ex+Vx[x] - l J,
2mX[x]
O=-Ex+Vy[y] - ?*
2mY[y]
O=-Ex+Vz[z] -
H2Z"[z]
2mZ[z]
where En=Ex+Ey+Ez.
b. Consider the harmonic oscillator potential Vx [x] = jkx x2, Vy [y] = ^ky y2, and
Vz [z] = jkz z2- Make use of the one-dimensional harmonic oscillator solution
found in a previous problem and find the general solution for Schrodinger's equation.
If the normalization criteria is J^ X[x, nx]2dx=l, then show the normalized solution
is
550 Chapter 9 Quantum Mechanics
Likewise, for Y [y, ny ] and Z [ z, nz ] show that
Y[y,ny]= ^M and Z[z,nz] =
where {nx,ny,nz} are integers and Hn[n, z] are Hermite Polynomials.
c. Plot the two-dimensional wave function X [x] Y [y ].
Required Packages
In[141]:= Needs["Calculus'VectorAnalysis*"]
Solution
In[142].= Clear["Global' *"] ;
a. You begin by setting the coordinates to Cartesian [x#y# z] using the command
SetCoordinates found in the package Calculus'VectorAnalysisv,
In[143]:= SetCoordinates[Cartesian[x, y, z] ] ;
Assume the wave function is separable and let
ln[144]:= #[x_,y_, z_] = X[x]Y[y]Z[z] ;
The form of Schrodinger's equation is
In[145] := eql = —— Laplacian[i/f [x, y, z] ] +
2m
(Vx[x] +Vy[y] +Vz[z] -En)*[x,y, z]
Out [145]= (-En + Vx(x) +Vy(y) + Vz (z)) X(x) Y (y) Z (z) -
— lh2 (Y(y) Z(z) X"(x) +
2 m i
X(x) Z(z) Y"(y) +X(x) Y(y) Z"(z)))
where the potential V[x#y# z] has been replaced with Vx[x] +Vy [y] +Vz [z]. Schro-
Schrodinger's equation follows from setting eql to zero. Delay doing this until a later time
because it is more convenient to work with the nonequation form. The terms with the same
variable separate if you divide eql by \f/ [x,y, z]:
ln[146] := eq2 = eql/#[x, y, z]//ExpandMl
X" (x) h2 Y" (y) h2
Out[X46]= -
2mX(x) 2mY(y)
Z"(z)fi2
2mZ(z)
-En + Vx(x) +Vy(y) +Vz(z)
9.3 Three-Dimensional Schrodinger's Equation 551
Three ordinary differential equations can be extracted from eq2 by grouping terms with
the same variable. Let En=Ex+Ey+Ez,
In[147]:= Enrule = {En-> Ex + Ey + Ez} ;
and define a selection operator to select terms with the same variables and with the relevant
separation constant Ex, Ey, or Ez:
ln[148]:= select [eq_, Ei_, var_] := Select [eq, (!FreeQ[#, var] | | !FreeQ[#, Ei] )s]
If you apply select to the three variables and set the results to zero, then you get three
equations:
In[149]:= fieldEq =
0 == { select [eq2/.Enrule, Ex, x] ,
select[eq2/.Enrule, Ey, y],
select [eq2/.Enrule, Ez, z] }//Thread;
fieldEq //ColumnForm
X" (x) h2
Out[149]= 0 == — Ex + Vx(x)
2 mX (x)
Y" (y) h2
0 == — Ey + Vy(y)
2mY(y) ^ '
0 == — Ez +Vz (z)
2mZ(z)
b. For the harmonic oscillator potential,
In[150] .-= potential = [vx(x)
the one-dimensional field equations become
ln[151] .= {xEq, yEq, zEq} = fieldEq/.potential;
{xEq, yEq, zEq} // ColumnForm
kxx2 h2 X" (x)
Out [151]= 0 == -— Ex-
2mX(x)
oEy
2 2mY(y)
kz z2 fi2Z"(z)
0 == — Ez -
2mZ(z)
The solutions for {xEq,yEq, zEq} are the one-dimensional harmonic oscillator so-
solutions that were solved in a previous problem. You only need to consider the solution
for X [x], since the solutions for Y [y] and Z [z] are similar. As was done for the one-
dimensional harmonic oscillator, if you define the notation kx = at^m, Ex = {\ + nx)fi atx,
In[152] := notation = J kx -» m aix2 , Ex -» nx+ - (i)xi,ux-t
I- 12/
=\;
m ooc2 J
552
Chapter 9 Quantum Mechanics
then the solution for xEq follows.
In [153] .- = xSol =
DSolve[xEq//.notation, X[x] , x] [ [1] ] //Simplify
r -
Out[153]= |x(x) ->e
nx 1 x2
' T '' 2 '' S?
As in the one-dimensional case, you obtain a linear combination of HermiteH and
HypergeametriclFl functions. Note, HypergeametriclFl is either divergent in
the limit of large x, or proportion to the HermiteH polynomials; therefore, you do not
need them for the solution of the harmonic oscillator. Only for nx equal to an integer or
zero will the HermiteH functions have the correct behavior as x-»oo. The normalized
solution is
In[154] := X[x_,nx_] =
X[x] /.xSol//.|c2
e 2 c«2 h I —
"nx ax
0ut[154] =
Let us double check the normalization by integrating over the product X[x, nx]2 for
n=O,l.. .5:
In[155] := Table f Integrate [x[x, nx]2 , {x, -oo, oo},
GenerateConditions -» False] , {nx, 0, 5}1 //PowerExpand
0ut[155]= {1, 1, 1, 1, 1, 1}
Setting GenerateConditions-*False suppresses printing out special cases in ad-
addition to speeding up the evaluation of the integral. You can trivially write the solutions for
Y [y,n] since this problem is symmetric in all the variables.
In[156]:=
y.] =X[y,ny] /.{ooc-»oty}
Out [156]= ¦¦¦
•yvr v2nY ay ny!
as well as for Z [z,n],
In[157]:= Z[z_,nz_] = X[z, nz]/. {ooc-> az}
e 2 cot2 jj I _Z_
"nz az
0ut[157] =
9.3 Three-Dimensional Schrodinger's Equation 553
The complete normalized wave function is given by the product X [x# nx] Y [y, ny ]
Z [z,nz], where nx, ny, and nz are integers.
c. Let us plot a typical two-dimensional wave function that is of the form X [x] Y [y ].
Set orx=ay=l for simplicity,
In[158]:= aRule = {ax->l, ay-»l};
and consider the graphics for the wave with {nx=3, ny=2}:
In[159]:= wavePlot = Plot3D[X[x,3]Y[y, 2]/.aRule,
{x/-4/4}/ {y, -4,4},
PlotPoints -> 35/
Display-Function -» Identity];
Add to this graphic the harmonic potential described by x1 + y2:
In[160]:= vPlot = Plot3D fo.15 (x2+y2)-2/
{x,-4, 4}, {y,-4,4},
PlotPoints -> 35,
Display-Function -»Identity];
The normalization and displacement of the potential are chosen for aesthetics. Finally,
if you combine these graphics in a single plot it follows that
In[161]:= Show[{vPlot,wavePlot},
DisplayFunction -» $DisplayFunction ];
PROBLEM 2 Schrodinger's Equation for Spherically Symmetric Potentials. Having
solved the Schrodinger equation in Cartesian coordinates, let us turn to the next logical
set of coordinates—spherical coordinates {r, 6, (/>}. Consider Schrodinger's equation with
a spherically symmetric potential V=V[r] and assume the wave function is of the form
iflr,0,<pi= R[r] ©[0]
554 Chapter 9 Quantum Mechanics
a. Express Schrodinger's equation in spherical coordinates and derive an equation for
the angular function $[0]. Solve for $[0] and show that $[0] = e±m*^, where m^ is
an integer or zero.
b. Eliminate the cf> variable in Schrodinger's equation using the results in part a. Derive
for ®[6] and R[r] the remaining two equations and show:
= -1A + l)®[0] + mcf>2 csc[0]2®[6\ - cot[0\&[8]
]R'[]
^ J R[r]
r j2 ft
Caution, be aware of the difference between I ("el") and 1 ("one") here.
c. Let z=Cos [#] and show that the ®[6] equation in part b can be expressed in the
canonical form of Legendre's equation,
f®(z) + f2®(z) + z^j ~ 2z®'fe) + A - ?)®"(z) = 0.
Solve Legendre's equation and show the physical solution is an associated Legen-
dre polynomial, LegendreP[l,m0,Cos[0] ], where I = 0,1,2,... and m^ =
-l,...,0,...,l.
d. The product of the angular functions ©[#]<I>[0] is proportional to
e+im^LegendreP[l# mtp, Cos[0]].
Show the product
Y[(, m, 6, <p] = C[f, m<f,]P[f, m? +i^
agrees with Mathematical spherical harmonic if
2f+l(f-m)\
Required Packages
In[162]:= Needs["Calculus'VectorAnalysis«"]
Solution
In[163]:= Clear["Global* * " ] ;
a. You start by setting the coordinate system found in the add-on package Calcu-
Calculus vVectorAnalysis» to spherical coordinates {r, 6, <p]:
In[164] : = SetCoordinates [Spherical [r, e, <t>] ];
Assume the wave function is of the form
In [165]:= #[r, e, «] = R[r]e[e]*[«];
9.3 Three-Dimensional Schrodinger's Equation 555
The form of Schrodinger's equation is
h2
In[166]:= eql = -— Laplacian[#[r, e, *] ] + (V - En)#[r, e, tf]
2m
Out[166]= (V-En) R(r) 9(9) ?(</>) ^
r2
h2 Csc(9) { Sin(9) 9(9) S(</>) R"(r) r2
lh2 Csc(9) { Sin(9) 9(9) S(</>) R"(r) r
2 Sin (9) 9(9) S(</>) R'(r) r + Cos(9) R(r) S@) 9'(9)
R(r) Sin (9) S(</>) 9" (9) +Csc(9) R(r) 9(9) S" (</>)
where Schrodinger's equation follows from setting eql to zero. Delay setting this equation
to zero, since it is easier to work with this nonequation form. First separate the cf> variable
followed by separating the 8 and r variables.
To separate the <p variable you multiply eql by r,[sr'°^1,
r2 Sin2 (e)
in [167] := eq2 = eql ^-i//ExpandAll
#[r, e, <p]
n *nc*,i r Sin2 (9) R'(r) fi2 Cos (9) Sin (9) 9' (9) f?
Out Ilo/j — - -
mR(r) 2m9(9)
r2 Sin2 (9) R" (r) f? Sin2 (9) 9" (9) h2
2mR(r) 2m9(9)
— Enr2 Sin2 (9) + r2 VSin2 (9)
2 mS @)
Notice the term with the cf> variable is isolated so it can be set equal to a constant. Define
the operator,
ln[168]:= select[eq_,var_] := Select[eq, (!PreeQ[#, var] )&]
to select those parts of an equation with a certain variable. Apply select to eq2 and
separate out the cf> variable. If you then set the results equal to the separation constant
r-mdJ it follows that
In[169] := eq3 = select [eq2
0ut[169]= -
2m
f? s" @) m02 f?
2mS@) 2m
The form of the separation constant j^mcp1 is defined in anticipation that mp is an integer
or zero. Rearranging terms, you find
In [170] := «Eq = Solve [eq3, *"[«]] [ [1, 1] ]/.Rule- > Equal
Out[170]= S" @) == -m02
Solving $[0] for <p, it follows that
ln[171]:= eq4 = DSolve [«Eq, ¦[*],*][[ 1] ]
0ut[171]= (s@) -+C-L Cos(m00) + c2 Sin(m00)]
556 Chapter 9 Quantum Mechanics
Equivalently, you can convert the trigonometric functions to exponential functions with
a proper choice of constants.
ln[172]:= eq4/.{c[l] -» 1, C[2] ¦* {1,-1}}//
MapAll[TrigToExp, #]&//
Map [Thread, #, 2]6 //Flatten
Out[172]= {$(</>) ^
To summarize, the solution for $[0] follows from the rule
In[173] := tfRule = *[«] -> e1™**;
For the wave function to be periodic the value of m/> must be either zero, a positive integer,
or a negative integer.
b. Equations for ®[6] and R [r] follow from eq2 if you eliminate the <p variable using
0Eq derived in part a. Eliminate the <p variable and then dividing by sin2[0], it follows that
In[174] := eq5 =
(eq2/. (*Eq/. Equal -> Rule )) /Sin [e]2 //Expand
, fi2 R" (r) r2 fi2 R' (r) r
2
Out [174]= -Enr2 +Vr2+
2mR(r) mR(r)
m02 h2 Csc2 (9) h2 Cot (9) 9' (9) h2 9" (9)
2m 2m9(9) 2m9(9)
The variables in eq5 can be grouped with terms that contain either 6 or r variables but
not products of the variables. You can now set these two groups equal to another separation
constant.
Apply the operator select to eq6 and separate out the r variables. The radial equa-
equation follows if you then set the results equal to a separation constant - ltfJr^t '¦
In[175] := eq6 = select [eq5, r] == ——
2m
, , fi2R"(r)r2 fi2R'(r)r
Out [175 = -Enr2 +Vr2 — —— ==
2mR() mR()
==
2mR(r) mR(r) 2m
The form of the separation constant - ^m* was cnosen m anticipation that the allowed
values of I are{0#l#2#3# ...}. You can simplify eq 6 by solving for R#' [r],
ln[176] .= rEq = Solve[eq6, R" [r] ] [ [1, 1] ] /.Rule- >Equal//ExpandAll
Out[176]= R" (r) = =
R(r) t2 R(r) / 2EnmR(r) 2mVR(r) 2R'(r)
r2 r2 T? h2 r
The © equation follows in a similar manner:
ln[177] := eq7 = select [eq5, e] == ' *
2 m
9.3 Three-Dimensional Schrodinger's Equation 557
m02 Csc2 (9) h2 Cot (9) 9' (9) h2 9" (9) h2
11111 j t ^» i ¦ i i—j ill \ i i i i i—j i v"j I I—j I it v"j I I—j I [^
0ut[177] = 2m 2m9(9) 2m9(9)
/(/ + !) h2
2m
Simplify eq7 by solving for ©"[#],
In[178]: = 6Eq =
Solve [eq7,e"[6]][[l, 1] ] /.
Rule -> Equal//ExpandAll
Out[178]= 9" (9) == -9(9) t2 -9(9) / + m02 Csc2 (9) 9(9) - Cot (9) 9'(9)
Equation 0Eq is Legendre's equation.
c. The canonical form of Legendre's equation is usually written in terms of the variable
z=Cos [0]. The following procedure called vChange implements a change of variables
in a differential equation:
In [179] := vChanse [ Eq_, i/r., x_, z_, f.] : =
Eq/.
Nest[(
When this operator is applied to a differential equation Eq of function \j/ [x], it changes
the variables from x to z where x=f [ z ]. The Nest command just applies the chain rule
over and over until all the higher derivatives have been changed to the z variable. If you
apply vChange to 0Eq with the change of variables #=ArcCos [ z ], it follows that
In [180]:= eq8 =
vChange [6Eq, 6, 6, z, ArcCos [z] ] //
ExpandAll// Simplify
(m02+ (z2-l)/ (/ + 1)) 9(z)
Out[180]= - j - == 2 z9' (z) + z2 - 1 9" (z)
z - 1 \ '
You can solve for © [z] in eq8 by applying DSolve:
In[181] := eq9 = DSolve[eq8 , e[z] , z]//Platten
Out [181] =
The solution is a linear combination of LegendreP and LegendreQ functions. The
LegendreQ[l,m, z] has a log [|^] singularity at z={-l,+l}, e.g.,
In[182]:=
Out [182] =
LegendreQ[2,
4T^F C z2 -
z2 - 1
1,
2)
z]
-H
1 - z2 Log
(z +
U-
1
z
558 Chapter 9 Quantum Mechanics
so they cannot represent physical solutions. Thus, you are left with the LegendreP [ 1, m, z ],
In[183] := 6Rule = eq9/.{C[l] -> 1, C[2] ¦* 0} //
Simplify
Out[183]= |e(z) -»P?*(z)}
The desired solutions given by dRule are associated Legendre polynomials where
l={O#l#2#3#...}andm0={-l#...# 1}.
d. You can replace the product of ©[Cos[0]] and $[0] with a spherical harmonic. Mul-
Multiply the product of ©[Cos[0]] and $[0] with a normalizing constant norm [ 1, m].
ln[184]:= norm[/,m] e[z]
z -»cos [e] /.mfi -> m
Out[184]= elm*P?(Cos(e)) nonn(/,m)
To make the product agree with Mathematical spherical harmonic, set the normalization
constant to
The product becomes
In[186]:= Y[/_, m_, e
noxm[/,m] e[z]
z -» Cos [6] /.m0 -» m
^
To verify that the expressions Y[l#m,#, 0] match Mathematicals spherical harmonic
functions called SphericalHarmonicY[l,m#d,0], form the following table
In[187]:= Taile[ SphericalBarmonicY[/, m, 0, 0] = =
Y[/, m, e, «] , {/, 0, 4}, {m, -/, /}] //
Simplify//PowerExpand
Out[187]= {{True}, {True, True, True}, {True, True, True, True, True},
{True, True, True, True, True, True, True},
{True, True, True, True, True, True, True, True, True}}
At least for 1=0 to 4 the functions Y[l,m,0,(p] match SphericalHarmonicY [ 1, m,
6, <p]. It is also true for all other values of I and m.
PROBLEM 3 Particle in an Infinite, Spherical Well. Consider a three-dimensional
well with infinite depth and radius a defined by V[r] = 0 if r<a; V[r] =oo if a<r.
Assume the wave function separates and is of the form R [r] © [61 $ [0]. This is the
9.3 Three-Dimensional Schrodinger's Equation
559
simplest spherically symmetric problem and is a close analogy to the one-dimensional infi-
infinite square well. The angular functions are spherical harmonics so the problem is reduced
to solving the radial wave equation:
0== -1A+1) R[r] +-^(En-V[r])r2R[r]+2 r R' [r]+r2R" [r]
V(r)
a. Solve the radial equation for R[r]. Require the solutions to be finite at r=0 and
show that the physical solutions are esseh+: ri jf me constant is C[l] =
V1 +1(, then show that the solution is normalized according to the criteria,
J^°°R[r]2dr = 1. Display the explicit wave functions for 1= 0,1,2,3. (Note,
we use an unconventional normalization here.)
b. Use the boundary condition at the wall to derive an expression for the energy lev-
levels. Consider the states S(l= 0),P(l= 1), D(l= 2), FA= 3), 6 A=
4) and find the first five energy levels for each state. Make use of the command
BesselJZeros found in the package NumericalMath*BesselZeros *. Dis-
Display the results in table and graphic forms.
c. PlotR[r] for the first few states and energy values.
Required Packages
In[188]: = Needs["NumericalMath'BesselZeros*"]
Needs["Graphics *Legend1"]
Solution
In[189]:= Clear ["Global' *"];
a. Enter the radial wave equation
2mR(r) (En-V(r))r2
In [190] := rEq= 0 = =
+ R"(r) r2
2R'(r) r-/ (/ + 1) R(r)
|v(r) 40,1
2m J
560 Chapter 9 Quantum Mechanics
Out[1901= 0 == k2 R(r) r2 + R" (r) r2 + 2 R' (r) r - / (/ + 1) R(r)
where V [r] =0 and En = ^. Applying DSolve to rEq, it follows that
In[191]:= dsol = DSolve [rEq , R[r], r] //Flatten //Simplify
Y,i (kr) c2 ,
r J,+ i (kr) cx +Y
Out[191]= R(r) -> ^ ,_
The solutions are Bessel functions of type Bessel J and BesselY. Further investiga-
investigation shows that BesselY [^ + /, r] is divergent as r->0. Therefore, these are not physically
valid as wave functions. The radial wave function becomes
In[192]:= R[r_,/., k. :1] =
R[r] /.dsol/.{c[l] ->Vl+2/, C[2] ->o}
V2 / + 1 J,ti (kr)
Out [192]= 1=2
v
Let us check the normalization criteria, J^°° R[r, f, k]2dr = 1:
In[193] := Intesrate [ R[r, /, k] ~2 . {r, 0, oo} ,
Assumptions -> { k > 0, / > -1/2}]
Out[193]= 1
A table of the explicit wave functions for 1= 0,1,2,3 follows.
In[194] := TableForm[ R[r, #, k]&/0Ranse[O, 3],
TableEeadings -»
{ { "/ = 0", "/ = 1", "/ = 2", "/ = 3" }} ] //
Simplify//PowerExpand
Vkr
^/|"(Sin(kr) -kr Cos(kr))
Out[194]= ,— k3/2 r2
JiS 3kr Cos(kr) + k2 r2 - 3 Sin(kr)
k5/2 r3
if (kr (k2 r2 -15) Cos (kr) + 3 E - 2 k2 r2 ) Sin(kr)
\ \ / \ /
?7^
b. The boundary condition requires the wave to vanish at the boundary r=a. This condi-
condition is equivalent to finding the values of ka, where BesselJ [1+1/2, k a] vanishes.
Since En= ^ it follows that these discrete values of ka determine the quantized energy
levels. We limit the evaluations to the first five energy levels in this section.
The zeros of BesselJ[l+l/2, k a] follow from the command
9.3 Three-Dimensional Schrodinger's Equation
561
ln[195]:= ?BesselJZeros
BesselJZeros[nu, n] gives a list of the first n zeros of the order nu BesselJ
function. BesselJZeros[nu, {m, n}] gives a list of the mth through the nth
zeros. More...
found in the add-on package NumericalMath'BesselZeros *. Consider, in turn, the
states SA=O)# P(l=l)# D(l=2), F(l=3)# 6A=4) and find the first five en-
energy levels for each state. The list of zeros for 1=0,1,2,3,4 is
In[196] := zeros = BesselJZeros [1/2+ #, 5] &/<? Range [0,4]
Out [196] =
3.14159
4.49341
5.76346
6.98793
8.18256
6.
7.
9.
10
11
28319
72525
09501
.4171
.7049
9.42478
10
12
13
15
9041
3229
.698
0397
12
14
15
16
18
.5664
.0662
.5146
.9236
.3013
15
17.
18
20.
21.
.708
2208
.689
1218
5254
The first list are the five values of ka, where BesselY [| + 0, r]=0, i.e., the energy levels
for the S states. The remaining lists contain the five values of ka for the states P, D, F,
and 6. To display the results in a table you apply TableForm to zeros:
In[197] := TableFoxm[zeros, TableSpacing -» 1,
TableHeadings -»
{ { "S - Wave" , "P - Wave" , "D - wave" ,
"P - Wave" , "G - Wave" } ,
{"First", "Second", "Third", "Fourth",
"Fifth"}}]
First
Second Third
Out [197] =
S - Wave
P - Wave
D - Wave
F - Wave
G - Wave
3.14159
4.49341
5.76346
6.98793
8.18256
6.
7.
9.
10
11
28319
72525
09501
.4171
.7049
9.42478
10.9041
12.3229
13.698
15.0397
Fourth Fifth
12.5664 15.708
14.0662 17.2208
15.5146 18.689
16.9236 20.1218
18.3013 21.5254
These are the values for ka, or equivalently the energy levels for the S, P, D, F, 6
states.
The results can also be displayed in the form of an energy level graph. If you define the
levels
In[198]:= levels = Table[
{{i-0.4, zeros [[i, j]]},
{i+ 0.4, zeros[[i, j]]}},
{i, 1, Lensth[zeros]},
{j,l,Length[zeros[[l]]]}] ;
and graph them along with the appropriate text, you get
562
Chapter 9 Quantum Mechanics
In[1991:= Show[
{Graphics[{Thickness[0.01],
Map[Line,levels,{2}]}],
Graphics [Text ["S", {1,1}]],
Graphics[Text["P",{2,1}]],
Graphics[Text[ "D" , { 3 , 1} ] ] ,
Graphics [Text ["P", {4,1}]],
Graphics [Text ["G", {5, 1}]]
}.
Frame -»True,
PlotRange-> {{0, 5.9}, {-1,25}}];
c. Consider the states S# P# D# F and 6 and plot the wave functions that correspond
to the first five energy eigenvalues. Let us first consider the wave function plot for the
S A=0) state. If you set a=l, then the plot for the 1=0 wave function corresponding to
the five lowest eigenvalues, kl# k2, k3, k4, and k5, is
In[200]:= Plot [R[r, 0, k]/. {k-> (zeros [ [0 + 1] ]) }//Evaluate,
{r, 0,1},
PlotStyle -> {{}, Dashing[{0.01}],
Dashing[{0.02}],Dashing[{0.03}],
Dashing[{0.05}]},
PlotLabel -> StyleForm["i/f", FontSize -»14],
PlotLegend-» {kl, k2, k3, k4, k5} ,
LegendPosition -» {1, -1/2},
Epilog -?
Text [StyleForm["S(/ = 0) - State",
FontSize -> 14] , {0.6,2}]
9.3 Three-Dimensional Schrodinger's Equation
563
-\ S(/=0) -State
0 .' 2\
'I
You can repeat this command for the P( 1=1), D(l=2), F(l=3) and 6A=4)
states with the obvious changes. Instead of doing the individual states, let us do all the
states using a GraphicsArray. The corresponding plots for S# P# D# F, and 6 states
follow from
In[201]:= rPlots=
Table[
Plot [ R[r, /, zeros [ [+1 + /, n] ] ] //
Evaluate, {r, 0.01, 1}, Ticks -» None,
plotRanjje->A11,
PlotLabel -> {n, /},
DisplayFunction ->Identity
], {n, 1,5}, {/, 0,4}];
In[202]:= rPlots//GraphicsArray //Show;
{1/ 0} {1, 1} {1, 2} {1, 3} {1, 4}
[X l?\ \Z\ IZX L^
{2, 0} {2, 1} {2, 2} {2, 3} {2, 4}
I \_^ r—V I Vy r~\7 I V/
{3, 0} {3, 1} {3, 2} {3, 3} {3, 4}
{4, 0} {4, 1} {4, 2} {4, 3} {4, 4}
{5, 0} {5, 1} {5, 2} {5, 3} {5, 4}
\ r \ /\ „
The values of n denotes the first, second, ...energy levels and the value of I gives the
state. Notice that all the radial wave functions vanish at the boundary r=a=l.
PROBLEM 4 Particle in a Finite, Spherical Well. Consider a three-dimensional finite
well of radius a defined by V[r] =-V0 if r<a; V[r] =0 if a<r. This is the finite gen-
generalization of the infinite well in the previous problem. Unlike the infinite well the wave
function can tunnel into the boundaries. Assume the wave function is of the form R[r]
© [#] $ [0]. The angular functions are spherical harmonics so the problem is reduced to
564
Chapter 9 Quantum Mechanics
solving the radial wave equation with a constant potential,
0== -1A+1) R[r] +&VR[r]+2 r R' [r]+r2R" [r]
where k2 = ^5 (En-V). The regions 0<r<a and a<r must be treated separately.
V(r)=-V0
a. Use the condition that the wave function must be finite at the origin and vanish as
r->oo and solve for the general form of the wave inside and outside the well.
b. To match the interior and exterior solutions you must join them with boundary con-
conditions. The boundary conditions require the wave function and its derivative to be
continuous at r=a. Fix the parameters, ti->l, a->l# m->l# V->-110, and use
the boundary condition at the wall to derive the first four energy values for the
S(l=0), PA=1) and D( 1=2) states. Display the results in table form.
c. Plot the radial solution for the S# P, and D wave functions that correspond to their
first four energy states.
Required Packages
In[203]: = Needs["Graphics^Legend*"]
Solution
In[204]:= Clear ["Global* *"]j
a. Enter the radial wave equation,
In [205] := rEq = 0 == k2 R(r) r2 + R" (r) r2 + 2 R' (r) r-
/ (/ + 1) R(r) /.En-> -WH/.V-> -V0
Out[205]= 0 == k2 R(r) r2 + R" (r) r2 + 2 R' (r) r - / (/ + 1) R(r)
9.3 Three-Dimensional Schrodinger's Equation 565
where Jc1 = ^ (En-V) and V is a constant. Applying DSolve to rEq, it follows that
In [206]:= rRule = DSolve [rEq , R[r] , r] //Flatten//ExpandAll
r J/+i (kr) c± Y,+ i (kr) c2 ,
Out[206] = R(r) -> ^—= + 1—r
The values of k inside and outside the well are, respectively,
In[207]: = kRule = (kin ¦,
kOut -> —^—i—^ L-
fi J
where V=-VO, En= -Win and 0<Wn<V0. Notice the value of kin is real and the value of
kout is complex. Define kOut=I qOut so that qout is real.
Let us consider the region inside the well. To examine the behavior near the origin
consider the series expansion of R [r ] around the origin for l->0,1,2,3:
In[208] := Series [ R[r] /.rRule/./ -> # ,
{r, 0, 1}]6 /<? Ransje[0, 3]//ColumnForm
Out [208]= -^
Vk
k
3 { PI r. \ /v3/2
1 k3/2 [2 r + o/r3/2\
3 V ^ '
(k3/2 V2^) r2
The rows are the expansions for 1=0,1,2, and 3. The constant in front of BesselY [/ +
\, r] must be set equal to zero to prevent the BesselY from diverging as r->0. The un-
renormalized wave function for r<a is
In [209]:= waveln[kln_,/., r_] =
R[r]/.rRule/. {c[l] -> cln, c[2] -.0,
k -» kin}//Simplify //PowerExpand
cln J,+ i (klnr)
Out [209]= ^
The explicit wave functions for 1=0,1,2, and 3 are:
In[210]:= TableForm[waveln[kin, #, r] 6/0
RanBe[0,3],
TableHeadings -»
{ { -/ = 0", "/ = 1", V = 2", "/ = 3" }} ] //
Simplify//PowerExpand
566 Chapter 9 Quantum Mechanics
cln J- Sin (klnr)
Out[210]= t = 0
Vklnr
cln -^1" (kin r Cos (kin r) - Sin (kin r) )
kln3/2 r2
clnJ% C klnr Cos (klnr) + (kin2 r2 - 3 Sin (klnr)
" kln5/2 r3
cln Jl (klnr (kin2 r2 - 15) Cos (kin r) + 3 E - 2 kin2 r2 ) Sin (klnr))
kln7/2 r4
The general form of the wave function outside the well with V0=0 becomes,
In[211]:= eql = R[r] /.rRule/.k -> I qOut//Power Expand
J,+ i (iqOut r) ct Y,+ i (i qOut r) c2
Out [211]= j= + j=
The boundary value problem reduces to finding C[l] andC[2] sothatR[r] vanishes
as r->oo. By themselves BesselJ and BesselY don't vanish at 00. To see what the
constants must be, let us evaluate eql for 1=0:
In[212] := eql/./ -> 0//TrigToExp //Simplify //
PowerExpand//Collect [#, { Exp [a.] } ] 6
(_lK/4 e-q0utr ( _ i Ci _ C, ) (-1K'4 e1" r (ic, - C, )
Out[212]= r=
<iOut r
There are both exponentially increasing and decreasing terms. To eliminate the expo-
exponentially increasing terms you want to pick C [ 2 ] =1 C [ 1 ]:
In[213]:= eq2 = eql/. C[2] ->
J,i (iqOut r) c± Y,+ i (i qOut r) ct
Out [213]= 1 = + 1 j=
Vr Vr
This combination of Bessel functions vanishes as r-»oo. This exponential decay is valid
for all values of I. The exterior wave function is
In[214]:= waveOut [qOut.,/., r_] = eql/.rRule/.{c[l] ->cOut,C[2] -> +1 oOut}
cOut J. 1 (i qOut r) i cOut Y. 1 (i qOut r)
Out[214]= ^-= + ^=
The explicit wave functions for 1=0,1,2, and 3 are:
In[215]:= TablePormt
(waveOut [qOut , #, r ] //TrigToExp //
Simplify//PowerExpand )&/&
Range[0,3],
TableHeadings -»
{ { "/ = 0", "/ = 1", "/ = 2", "/ = 3" }} ]
9.3 Three-Dimensional Schrodinger's Equation 567
Out[215]= f - 0
y7: yqOut r
(-lK/4c0ute-<'0utr.N/f (qoutr + l)
/ = 1 qOut3/2 r2
-y^l V2 cOut e"*^ r (qOut2 r2 + 3 qOut r + 3)
/ = 2
(-1K/4 cOut e-qOutr Jf qOut3 r3 + 6 qOut2 r2 + 15 qOut r + 15
/ _ 3 v ' L
qOut7/2 r4
They all vanish as r->oo, as expected.
b. The boundary condition requires the wave function and its derivative to be continuous
at r=a. The continuity of the wave at the boundary is described by bcl:
In[216] := bcl = (waveln[kin, /, r] == waveOut [qOut, /, r]) //. {r -> a}
clnJ/+i (akin)
Oat [216]=
cOut J/+ i (i a qOut) i cOut Y/+ i (i a qOut)
I + ?
The constant Cln is an arbitrary normalization constant and can be set equal to one.
Solving bcl for cOut, you get
In [217] : = oOutRule =
Solve [bcl, cOut] /.cln -> 1 //Flatten //Simplify
Out [217]= [cOut
J/+i (akin)
J/+1 (i a qOut) + i Y/+ i (i a qOut) >
The derivative condition is given by bc2,
In[218]:= bc2 = (D[waveln[kin, /, r] , r] == D[waveOut [qOut, /, r] , r]) //.
{r->a}//Simplify;
The energy eigenstates follow from fixing land solving bc2.
Let us consider the energy eigenvalues and graphs of the corresponding wave functions
for different values of I. Fix the numerical choices for various parameters and collect all
the relevant rules into allRules:
In [219] : = allRules =
(VO - Wn)
{
i— mWn
qOut -» V2 «/ —j-, cOutRule, h -> 1,
V "
a -> 1, m -» 1, VO -> 110, cln -» l}//Flatten ;
568
Chapter 9 Quantum Mechanics
If you substitute the numerical parameters into bc2, then the boundary condition be-
becomes
In[220]:= bo2Sol[/_] = bo2//.oOutRule/.oIn -> l//.allRules //.
allRules //Simplify;
The energy levels follow from finding Wn that satisfy the boundary conditions in bc2Sol.
Consider the first four energy levels for 1=0 (S-state). The boundary value equation
becomes
In[221]:= eq3 = bo2Sol[0]//Simplify
Out[221]=
Sin (V220 -2Wn) -
4 (Wn- 110) Cos (V220 - 2Wn) )
7: D40 -4WnK/4) = = 0
Notice that the resulting S-Wave expression depends purely on Wn. This equation can
be solved by applying FindRoot. However, to use this command you need to estimate
the Wn values. An estimate follows from graphing the left-hand side of eq3:
In[222]:= Plot [eq3 [ [1] ] //Evaluate, {Wn, 0, 110}];
The eigenvalues occur where the curves intersect the x-axis. The values of ka for the
first four approximate values are {10,40,70,90}. The numerical values for the eigen-
states follow (more accurately) from FindRoot.
In[223] := sValues = FindRoot [ eq3 , {Wn, #}]& /<? {10, 40, 70, 90}
Out[223]= {{Wn^ 6.55387}, {Wn -» 42 . 0025},
{Wn-> 71.3 642}, {Wn -> 92 .7371}}
The energy values for the P and D states follow in a similar fashion. The boundary
condition equations for the P and D states follow from eq4 and eq5, respectively,
In[224];= eq4=bo2Sol[l] //Simplify ;
9.3 Three-Dimensional Schrodinger's Equation 569
and (this may take a minute or so),
In[225]:= eq5 = bo2Sol[2] //Simplify;
The guesses for the P and D eigenvalues follow from plotting the right sides of eq4 and
eq5:
In [226] : = Plot [ {eq4 [ [1] ] , eq5 [ [1] ] }//Evaluate,
{¦Via., 0, 110},
PlotStyle-> {{},Dashins[{0.01}]} ];
The first four energy values for the P states follow from applying FindRoot to eq4,
In [227] ¦. = pValues = FindRoot [ eq4 , {Wn, #}]6 /0
{20,60, 80, 100}
Out[227]= {{Wn-> 25.4847}, {Wn -> 58 .4703},
{Wn-> 83.9514}, {Wn -> 101.154}}
Similarly, the first three energy values for the D states are
In[228] := dvalues = FindRoot [ eq5, {Wn, #}]& /0
{10, 40,70, 90}
Out[228]= {{Wn^8.49601}, {Wn -» 44.4765},
{Wn-> 73.9698}, {Wn^95.458}}
To display the results in a table you apply TableForm to the energy levels.
In [229] : = TableForm [ { sValues , pValues , dvalues } ,
TableSpacing -» 1 ,
TableHeadings ->
{ { "S - Wave" , "P - Wave" , "D - Wave" } ,
{"First", "Second", "Third", "Fourth" }}]
Out[229]= First
S-Wave Wn-> 6.55387
P-Wave Wn-> 25.4847
D-Wave Wn ^ 8.49601
Second Third Fourth
Wn-> 42.0025 Wn-> 71.3642 Wn-> 92.7371
Wn^58.4703 Wn->83.9514 Wn^lOl.154
Wn-> 44.4765 Wn ^ 73.9698 Wn ^ 95.458
570
Chapter 9 Quantum Mechanics
c. Now that the energy eigenvalues have been found, you can smoothly join the wave
function in the well to the wave function outside the well. The wave function inside and
outside the well are
In [230] .- = {in [r_, /_, Wn_] , out [r_, /., Wn_] } =
{waveln [kin, /, r] , waveOut [qOut, /, r] }//.
allRules;
The complete wave function is
In [231] : = wave [r_, /_, Wn_] =
Which[r si, in[r, /, Wn] , r > 1 ,
out [r, /, Wn] ] ;
For the S-wave eigenfunctions, the plot of the first four energy eigenvalues are
In[232]:= Plot [ wave [r, 0, Wn] /. sValues//Re//Evaluate ,
{r, 0,1.3},
PlotStyle-* {{}, Dashinsj[{0.01}],
Dashing[{0.02}],Dashing[{0.03}]},
PlotLegend ->
Evaluate [ Wn/. sValues [ [#]]6/0Range[4] ] ,
LegendPosition -> {1, -1/2},
Epilog-> Line [{{1,-3}, {1,3}}]] ;
1.5
1
0.5
0.5
\ '¦ * ^ /~^
o^y^.
=-*T? 2
6.553
42.00
- — 71.36
---92.73
The legend displays the value of the energy level. The command Re was wrapped
around the wave to eliminate the small complex numerical errors.
For the P-wave eigenfunctions, you have
In[233]:= Plot [ wave [r, 1, Wn] /.pValues//Re//Evaluate ,
{r, 0,1.3},
PlotStyle-* {{},Dashing[{0.01}],
Dashing[{0.02}],Dashing[{0.03}]},
PlotLegend -»
Evaluate [ Wn/. pValues [ [#] ]6/0Range [4]] ,
LegendPosition -» {1, -1/2},
Line[{{1,-3}, {1,3}}]
9.3 Three-Dimensional Schrodinger's Equation
571
Finally, for the D-States:
In[234] : = Plot [ wave [r, 2, WH] /.(lvalues//Re //Evaluate
{r,0,1.3},
PlotStyle-* {{}, Dashinsj[{0.01}],
Dashing[{0.02}],Dashing[{0.03}]},
Plot Legend -»
Evaluate [ Wn/. dvalues [ [ # ] ] s/0 Range [ 3 ] ] ,
LegendPosition -> {1, -1/2},
Epilos->Line[{{l, -3}, {1,3}}]
Note that all the above waves are smooth at the boundary r=a=l. This is a consequence
of the fact that the Wh are the eigenvalues that follow from the boundary conditions.
PROBLEM 5 The Hydrogen Atom in Spherical Coordinates. Consider Schrodinger's
equation in spherical coordinates {r,6,<p},
~ V24r[r, 6,
2m
(V[r] - En) >{r[r, 6,cf>] =
(9.2)
with the Coulomb potential V [ r ] = ^ ?. The wave function can be written as a product
^[r###0] = R[r] ©[#]<1>[0]. The angular dependence is given by spherical harmonics
and the radial function R [r] satisfies the equation:
R"[r] +-
r
R[r]
a. Require the radial solution to vanish at the origin and infinity and show the solution
reduces to
572 Chapter 9 Quantum Mechanics
R [r] -> tT=fc/C[2] LaguerreL \-l+n-(,l+2f, —1
L aOnJ
where aO= ^^ is the Bohr radius.
If
C[2] =
aOn
then show that R [r] is normalized according to the criteria J^°° R^rfr^dr = 1.
b. Write the explicit wave function for {n=l# 1=0}, {n=2, l={0#l}} and{n=3#
1={O#1#2}}. Graph the radial probability density p[r] = r2/?!/]2 for the states
n={l,2,3}.
c. The angular dependence is given by Y[l#m,#, <p]. Plot the absolute value of the
wave function for I = 0,1, and 2 for all the allowable values of m and for fixed r.
Required Packages
In[235]:= Needs["Graphics * ParametricPlot3D*"]
Solution
In[236]:= clear[-Global* *"] ;
a. Enter the radial equation
2m
Out[237]= 0 ==
h2
R" (r) r2 + 2R'(r) r-/ (/ + 1) R(r)
where the potential was replaced with the Coulomb expression and the negative energy
bound states were replaced by a positive expression Wn=-En. The solution for R follows
from applying DSolve to eql,
ln[238]:= eq2 = DSolve [eql, R[r] , r] [ [1] ]
9.3 Three-Dimensional Schrodinger's Equation
573
{>h Log(r)-V2 ymr VWn
R(r) -> e r-* Cl U
2 V2" Viii
h -
2/+1
^ V2 Vme
2 \/2 \/mr Vwn
You can define some substitutions to simplify the notation. Given that aO= 4ht^ is the
Bohr radius, you can define the rule m -> 4^ff to insert this combination of factors. For
the energy En, you parameterize this as a function of n2 via the relation Wn = 32ft4veo1 •
If you define the substitutions
In[239]:= substitutions=
then the radial solution becomes
In[240]:= eq3 = eq2//. substitutions //Power Expand//Sin^ili fy
Out[240]= |^'
This solution is a linear combination of LaguerreL and HypergeametricU func-
functions. The HypergeametricU function is either divergent or for integer values of n
and I is proportional to the LaguerreL functions. Further inspection shows that valid
candidates are n={l, 2,3, • •.}, l={0# 1,2,... #n-l}. The physical wave function
is
ln[241]:= eq4 = eq3/. {C[l] -> 0 }
0ut[241]= {R(r) -> e-ift; r' c2 L^ ^
For the radial equation to be normalized f™ Rtrf^dr = 1 the value of C [ 2 ] must be
multiplied by
574 Chapter 9 Quantum Mechanics
In [242] : = rNorm = 2'*1
a03n* (n +
The normalized radial solution is
In[243]:= rwave[n_, /., r.] =
R[r]/.eq4[[l]]/.c[2]
PowerExpand//Simplify
2'+1aO"'-t e-i*Hn-'-2r'
Out[243]=
2r
aO n
The principle quantum number is n={l, 2,3,...} and the angular momentum quan-
quantum number is 1={0,1,... ,n-l}. To verify the normalization J^°° Rlrf^dr = 1, con-
consider the first few values of n:
In [244] := Integrate [r2 {rwave [1, 0, r ] , rwave [2, 0, r ] , rwave [2, 1, r]}2,
{r, 0, oo}. Assumptions -» {Re[aO] >0}l
Out[244]= {1, 1, 1}
b. The explicit wave function for {n=l, 1=0}, {n=2,l={0,l}} and {n=3.
In [245] := eq5 =
Table [rwave [n,/, r] , {n, 1, 3},
TableFoxm[#, TableHeadings ->
{{"n= 1", "n = 2", "n = 3"},
{»/ = 0", "/ = 1", "/ = :
Out[245]= t = 0 / = 1
2 e&
11=1 Itf^
A <2-a%)
n - 2
n= 3
n = 1
n = 2
2V2aO3/2
2e"^in |27 aO2 - 18 r aO + 2 r2 ) J^e~^rD-
81 V3aO7/2 27aO5/2
/ = 2
81 aO7/2
Analysis of the radial wave functions can be performed by plotting these functions along
the radial coordinate, thus giving insight into the electronic structure of the atom. Define
the plot operator for the probability densities r2/?!/]2,
9.3 Three-Dimensional Schrodinger's Equation 575
In[246]:= plot [n_,/_, rmax_] : =
Plot [r2 rwave[n, /, r]2/.a0 ->1//
Evaluate,
{r, 0.01, max}.
Ticks ^{{1, 4, 8,14,20},
{0.1,0.3,0.5}},
DisplayFunction -> Identity];
whereaO=l.Theplotsoftheprobabilitydensitiesfor{n=l# l=0}# {n=2, l={0#l}}
and {n=3# l={0#l#2}}are,respectively,
In [247] : = Show [GraphiosArray [Table [plot [n, /, n* 7] , {n, 1, 3}, {/, 0, n- 1}]]];
14 8 14 2 0 14 8 14 2 0 14 8 14 2 0
c. The complete wave function is a product of the radial wave function and spherical
harmonics. To plot the angular part of the wave function for fixed r you only need to
consider the plot of the spherical harmonics. Consider the plots for the absolute value of
the spherical harmonics. Define the plot operator
In [248]:= plot [/_, m_] : =
SphericalPlot3D[
SphericalHarmonicY[/,m, e, 0] //Abs//Evaluate,
{6, 0, 7r}, {<t>, 0, 2 7T},
Boxed -> False,
Axes -> False,
DisplayFunction -» Identity];
The graphs for 1=0,1, and 2 with the allowable values of m={-l# 1}, follow from
In[249] := ptl = Table [plot [/, m] , {/, 0,2}, {m, -/,/}];
Show[GraphicsArray[ptl]];
576 Chapter 9 Quantum Mechanics
• tit*
9.4 ¦ EXERCISES
The solutions to many of these exercises can be found at our web sites.
9.1 Infinite Potential Well with Rectangular Perturbation
Consider the symmetric double potential barrier:
V(jc) = oo if *<0;
V(x) = 0 ifO KxKa^,
V(x) = V1 if^KxKa^,
V(x) = oo if a2 < x < a3.
(a) Solve the one-dimensional Schrodinger's equation for the wave function.
(b) Make a table of eigenvalues. Graph the eigenvalues as a function of Vj.
(c) Graph the first few wave functions for some fixed value of Vj. Use Plot3D to compare how
the wave functions change with V1.
(d) Develop a perturbation procedure that solves this problem.
9.2 Tilted Square Well
Consider the tilted potential well:
V(jc) = V! if*<0;
V(x) = V1+V2(x/a) = 0 ifO<x<a;
V(x) = V1+V2 ifa<x;
(a) Consider a particle bound in the well. Solve Schrodinger's one-dimensional equation for the
eigenfunctions.
(b) Make a table of the eigenvalues and graph the first four wave functions.
(c) Find the transmission and reflection coefficients for a particle with energy greater than Vj.
Graph the coefficients, and show how the results depend on V2.
9.3 The Wentzel-Kramers-Brillouin Approximation
Consider the one-dimensional Schrodinger equation with a potential V [x]. Assume the wave
function is of the form u=R [x] Exp [i S [x] IK\.
9.4 Exercises 577
(a) If R [x] is a slowly varying function, derive an equation for S [x] in terms of the potential
V[x].
(b) Derive a procedure that returns the probability of tunneling through a potential barrier.
9.4 Plot of the Electron Probability Density
Derive two operators using ScatterPlot that plots the probability density of a wave function.
Make the density of dots proportional to the probability density given by the wave function.
Construct a density operator that plots the results in two dimensions, and a second operator that
plots the results in three dimensions. Apply the two operators to the hydrogen wave functions.
9.5 Perturbed Harmonic Oscillator
Consider a particle that is bound by a potential V = \k? + px4. Treat the last term px4 as a
perturbation.
(a) Find the perturbed solutions for the eigenvalues and eigenfunctions.
(b) Compare the perturbed and unperturbed solutions by graphing the results as a function of p.
(c) Construct a perturbative function using Module for the one-dimensional Schrodinger equa-
equation with an arbitrary potential.
9.6 Perturbation Theory
Paraboloidal coordinates {? tj, <p], where x=t/ ? Coa[<p],y =r\ ? Sin [0], and z=l/2 (?2-
rf), is another coordinate system where the Schrodinger equation can be separated if the poten-
potential is of the form
Examples of such systems are the hydrogen atom and the hydrogen atom in a constant electric
field. Let the potential be of the form
and assume the wave function can be expressed as the product of three functions f [?] g [7/]
(a) Separate the variables and find the ordinary differential equations for f [?], g [7;], and
(b) Consider the hydrogen atom in an electric field. The potential for the system is, V{r) =
^— eEoz. Find the differential equations.
9.7 Separation of Variables in Cylindrical Coordinates
Consider the following problems in cylindrical coordinates,
(a) Express Schrodinger's equation
— VVIP, 0, z] + (V[p, 0, z] - En) ift[p, 6,z] = 0 (9.3)
Zm
in cylindrical coordinates [p, 6,z], where x = pCos[ff], y = pSin[0], and z = Z- Let the
potential be of the form V = Vp[p] + Vz[z] and assume the wave function can be expressed as
the product of three functions R\p]@[0\h[z]- Derive ordinary differential equations for R\p],
©[«], and h[z\.
CHAPTER
10
Relativity and Cosmology
10.1 ¦ INTRODUCTION
In this last chapter we solve problems taken from special relativity, general relativity, and
cosmology. Einstein recognized that the classical ideas of space and time were suspect.
He rejected the idea that space and time were independent of each other and developed,
with simple postulates, a relationship between space and time. In Newtonian mechanics
the transformation between inertial (nonaccelerating) frames is simple due to the absolute
nature of time. Inertial frames can differ by a rotation of the coordinates, a translation of
the space origin, a translation of the time origin, and by a difference in constant velocity.
These general transformations form a 10 parameter group of transformations called the
Galilean transformations. If we find one inertial frame, then we have found all of them by
the Galilean transformations. For a time it appeared that ether could single out an absolute
frame. In 1878 Maxwell proposed the existence of ether as the universal substance that
acted as a medium for the transmission of electromagnetic waves. It seemed reasonable to
assume that the frame of "still ether" coincided with the frame of the fixed stars and could
be identified with absolute space. Experiments tried without success to detect our motion
through the ether. Ether had no measurable properties and the speed of light in free space
was the same everywhere, regardless of the motion of the source or observer.
In 1889 the Irish physicist George FitzGerald pointed out that the results could be
explained if the length of material bodies changed as they move through ether. In 1892
Lorentz, unaware of FitzGerald's paper, proposed an almost identical contraction. They
postulated that the movement through ether produced a "real" contraction of length. A
more natural explanation had to wait until 1905 when Einstein proposed the special theory
of relativity. The special theory of relativity postulated that the laws of physics held in all
inertial frames moving with respect to one another at a constant velocity. Gone was the
notion of an absolute frame of reference and there was no need for ether.
The next step in understanding spacetime was Einstein's theory of general relativity,
proposed in 1915. General relativity merged Newtonian gravity with ideas that stemmed
from special relativity. The basis of general relativity was the postulate that an observer
cannot distinguish between the local effects produced by a gravitational field and those
produced by an acceleration. This postulate, known as the principle of equivalence, fol-
follows from the experimental observation that the inertial mass of a body is exactly equal
to its gravitational mass. Consequently, Einstein postulated that the laws of physics must
be expressed by equations having the same form in all frames of reference, regardless of
their motion. Thus, the general theory covered acceleration as well as uniform motion and
was able to describe gravity. General relativity called for a new geometry—a geometry of
578
10.2 Special Relativity 579
curved four-dimensional spacetime. General relativity abandons the notion of a gravita-
gravitational force and instead thinks of moving masses as responding to the curvature of space-
time. The presence of mass curves spacetime and the curvature acts back on the motion of
the mass. In general relativity spacetime is described with Riemannian geometry and the
geometry is determined by the energy and momentum density in space.
This final chapter is divided into three sections: Special Relativity, General Relativity,
and Cosmology. At the beginning of each section we include an overview of the subject
followed by problems. The methods used to solve these problems are not unique; you are
encouraged to find procedures that will illuminate the physics and to find other approaches
that make the calculations faster.
You may wish to turn off the spell checker before starting this chapter:
In[l]: = Off[General : : spell];Off[General : : spelll];
10.2 ¦ SPECIAL RELATIVITY
10.2.1 ¦ Overview
In 1905 Einstein proposed two postulates that formed the foundations of special relativity.
One postulate relates to the constancy of the speed of light and the other to the formal
invariance of physical laws in different inertial reference frames.
1. Principle of the Constancy of the Speed of Light: The velocity of light as measured
in a vacuum is the same in all inertial systems and is independent of the motion of
the observer or source.
2. Principle of Relativity: Physical laws and principles have the same form in all iner-
inertial systems so there does not exist any preferred inertial system.
The first postulate is the prescription used to find the space and time transformations be-
between inertial frames. The relation between inertial frames in classical mechanics is simple
due to the absolute nature of time. To illustrate a classical transformation, consider two in-
inertial frames ? and ?'. Let the coordinates of a certain event in frame X be {t,x,y,z} and in
2', the coordinates of the same event are {V, x', y', z'}. The absolute nature of time means
t = t'. Let the coordinate systems be coincident at t = 0 and assume the relative motion of
the two frames is along the x-direction. If the velocity of ?' relative to ? is V, then the clas-
classical transformation between the inertial frames is x' = x - Vt, y' = y, z' = z, t' = t. This
classical transformation is called a Galilean transformation. Galilean transformations do
not satisfy the first postulate of special relativity because they do not preserve the velocity
of light.
The transformations between inertial frames that keep the velocity of light constant
are known as Lorentz transformations. A Lorentz transformation relates the coordinates
{t, x, y, z} of an event in X to the coordinates {V, x', y', z'} of the same event in another
inertial system X'. To construct the Lorentz transformation, let {dt, dx, dy, dz} be the
infinitesimal distance between two nearby points in an inertial frame X. The space and
time coordinates of a light ray between these nearby points satisfy the equation 0 = dt2 -
580
Chapter 10 Relativity and Cosmology
dx2 - dy2 — dz2. (We choose natural units and set the speed of light equal to one (c = 1) in
this chapter.) The equation for light suggests we define a function ds2 by the relation ds2 =
dt2 — dx2 — dy2 — dz2. We call ds2 the line element. The propagation of light is described
by ds2 = 0. Similarly in X' the line element is ds'2 = dt'2 - dx!2 - dy2 - dz'2 and light
is described by ds'2 = 0. The first postulate of relativity is satisfied if the transformation
between the frames leaves the line element invariant, ds2 = ds'2.
The line element allows us to introduce the concept of a metric since ds2 can be written
as ds2 = r\ dxfdx*', where the coordinate differentials are {dt, dx, dy,dz} and the metric
is
10 0 0
0-100
0 0-10
V o o o-i
We assume the Einstein convention and sum over repeated indices. The pseudo-
Euclidean matrix 77 is the metric for the spacetime. In X' the line element is ds'2 =
jj^y dx1^ dxrv. To find the transformation between the two inertial frames, we assume a
linear transformation x!^ = ajixv. The conditions for a/ needed to preserve the speed of
light are 77^ = 2 2 77^ of.
Consider the values of a/ that connect one inertial frame X with another inertial frame
X' moving with relative speed v along the ^-axis. The Lorentz transformation that relates
coordinate frames with different velocities and no rotations of the coordinates is called a
boost. The Lorentz boost between these two inertial frames is z' = y(z - vt), f = y(t - vz),
y =y,x! =x, where 7 = ,* ,. (Recall, c = 1.) The expression for aaM is
7 0 0 -vy
0 10 0
0 0 10
V -vy 0 0 7
The second postulate of relativity requires the equations of physics to have the same
form in all inertial coordinate systems. An equation written in a form-independent manner
is said to be covariant. The construction of covariant equations leads to the study of tensors;
tensors are those objects that are invariant under coordinate transformations. The simplest
of all tensors is a scalar. If 0 is a scalar in coordinates x, then in the coordinates x' the scalar
is <p', where <p' = <p. For example, the line element ds2 is a scalar since ds'2 = ds2. A scalar
is called a tensor of rank zero. The next most elementary tensor is of rank one, or a vector. In
four-dimensional spacetime, a vector has four components and can be either contravariant
or covariant. If the components v** (jm. = 1,2,3,4) transform like the coordinate differentials
drf1, the vector is contravariant, V^ = fprV*. The components of contravariant vectors are
denoted with superscripts. If the components of a vector, va (a = 1,2, 3,4), transform
like Va = J^ Vg, the vector is covariant. We can generalize these transformations to define
tensors of arbitrary rank. An arbitrary tensor can be covariant, contravariant, or mixed.
The metric can be used to convert contravariant indices to covariant indices. For ex-
example, consider the contravariant vector Av and lower its index with the metric 77^, AM =
10.2 Special Relativity 581
r\'yAv. Indices ate raised with the inverse metric tensor rf". If A are the components of a
covariant vector, then the contravariant vector is A^ = ifvAY. The scalar product of two
four-vectors is denned as T]fiyAftBy. The product is a scalar. If we define AM = {A0, A]
and W = {B°, ?}, then the scalar product gives ^A^B" = A°B° - A • B. A special
case of this relation _is the square of the length of a four-vector Vy that is defined to be
Tj^Vf Vv = V° V° - V ¦ V. Due to the presence of the minus sign in the metric, we can dis-
distinguish three types of four-vectors: timelike if 77 V Vv > 0, spacelike if 77^ V Vy < 0,
and null if 77^ V 1^ = 0.
An event is represented by a single point in spacetime {to,xQ,yQ,zo}. The path of a
particle, called its world line, is described by the four parameterized coordinates x^[s] =
{t[s], x[s], y[s], z[s]}. The tangent to the world line is a four-velocity vector.
dx? (dt dx dy dz\
ds \ds' ds' ds' ds)
The tangent is a contravariant vector and is the generalization of the three-velocity in
Newtonian mechanics. For a world line the magnitude of the vector is unity, 77 V Vy = 1.
The four-velocity of a photon is a null vector, 77 V Vv = 0. The notation simplifies if
we write Vv = {y, y v}, where y = % and the three-velocity is v = C7. ^» 37}• Since the
magnitude of the four-vector for a particle is one, 77 VV = y2{\ - v • v) = 1, it follows
thaty = A -7-7).
The four-momentum is closely related to the four-velocity. The four-momentum is de-
defined by F*1 = m0VM, where V is the four-velocity and m0 is the rest mass or proper
mass of the particle^This vector can be written in terms of three-vector notatjon, f =
{moy, mQyv] = {E, P], where E = moy is the total energy of the particle and P = moyv
is the relativistic three-momentum. The magnitude of the momentum vector is just the rest
mass of the particle, r\iiYPlxPv = mfc. A relation between energy, momentum, and mass
follows from this observation, 77 P'PV = E2 - P ¦ P = mfc. An important four-vector is
the four-momentum of a photon. The photon's four-momentum vector can be written as
ky = hvo{l, n}, where v0 is the frequency measured by an observer at rest relative to the
source, h is Planck's constant, and n is the normalized three-vector, n.n = 1. The three-
vector n points in the direction the photon is propagating. The four-momentum vector is
obviously null since T]^]? = /*2VqA - n ¦ n) = 0.
PROBLEM 1 Decay of a Particle. Consider a stationary particle with rest mass ml that
decays into two particles, one of mass m2 and the other of mass m3. Let the four-momenta
LI LI LI LI LI
for the particles be pi, pi, and P3. The conservation of energy and momentum is P3 = pi-
pi. It is often the case that the algebra for calculations in special relativity simplifies if the
problem can be expressed in terms of scalars. Evaluate the scalar equation m2 = T]pP
and get an expression for y2 = J__. Show that the kinetic energy of the particle with
mass m2 is (ml~f^~m31. 2
582 Chapter 10 Relativity and Cosmology
Before After
ml
l /
m
ml
mi
Remarks and Outline The conservation of energy and momentum pi = pi - pi gives
two nontrivial equations between the initial and final momentum. These equations are so
simple that the solution for the kinetic energy is straightforward. Try it. It is not necessary
to use the scalar equation m\ = ri^pipi to simplify the algebra for this simple case, but
this is an excellent example to illustrate the use of scalars.
Solution
In [2]:= Clear["Global * *"] ;
In the rest frame of particle one, the four-momenta vectors are defined by the rules,
In[3]:- momRule =
{pi -nnl{l, 0, 0, 0},
p2 -nn2y2{l, 0, 0, -v2},
p3 -nn3 y3{l, 0, 0,v3}};
where yi = -f== (recall, c=l). The fact has been used that in the rest frame of particle
VI-vr
one the speeds v2 and v3 must have opposite signs to be consistent with the zero initial
three-momentum. You can align these particles along the z-axis without loss of generality.
The conservation of four-momentum gives a relation between these three momenta,
In[4] := conRule = {p3 -» pi -p2};
If we define the metric
ln[5] := 77 = DiasonalMatrix[{l, -1, -1, -1}] ;
it then follows from the scalar invariant m\ = rj pipvi and conRule that
In [6] := eql =
m32 == p3.77. p3/. conRule/. momRule/.
(v2 -> . /1 - -^} //ExpandAll
I- y y22 J
ml2 - 2 m2 y2 ml +m22
where v2= Jl - -^ was used to eliminate the speed v2. Solving for y2, you get
y2
Out [6]= m32 ==ml2 - 2 m2 y2 ml +m22
10.2 Special Relativity 583
In[7]: = sol= Solve [eql,y2 ]//Simplify//Flatten
r ml2 +m22 - m32 t
Out [7]= |Y2^ —— }
L 2 ml m2 >
The kinetic energy of m2 is the total energy m2 y2 minus the rest mass m2:
: = PullSimplify[m2 y2 -m2/.sol]
(ml-m2J-m32
2 ml
PROBLEM 2 Two-Particle Collision. A particle of rest mass m1 collides with a station-
stationary particle of mass m2. The collision produces two particles with masses m3 and m4. The
threshold kinetic energy in the laboratory is defined to be the kinetic energy just sufficient
to make the center of mass energy equal to the sum of the rest masses in the final state.
Before After
P\ P2
ml ml
<a
a. Write the initial four-momenta for the two particles in the laboratory frame and find
the total initial four-momentum, Plt ¦ Do the same for the total four-momentum as
measured in the center-of-mass frame, Pcmt-
b. Consider the scalar invariant T] pflpv, where pi1 is the total momentum. Evaluate the
invariant in the laboratory and center-of-mass frames. Equate the expressions and
solve for the threshold energy. Express the results in terms of the kinetic energy of
the particle with mass mx. Use the definition of threshold energy and show that the
initial kinetic energy of the particle with mass m1 is (m3+m4^2ml+"'2>2.
Solution
In[9]:= Clear["Global'*"] ;
a. Let the initial four-momentum of the particle with mass ml be Pl\ and the four-
momentum of the stationary particle be /&. The initial four-momenta of the two particles
in the laboratory frame are
In[10]:= pLl = {El, pi, 0, 0};
pL2= {m2,0, 0, 0};
584 Chapter 10 Relativity and Cosmology
and the total initial four-momentum is
In[ll]:= pLT = pLl + pL2
Out[11]= {El+m2,pl, 0, 0}
Next, write the initial four-momenta in the center-of-mass frame:
In[12] : = pCMl = {ECM1, kCMl, 0,0};
pCM2 = {ECM2, -kCMl, 0, 0};
Note, we have used the fact that the sum of the three momenta is zero. The total four-
momentum is
In[13] : = pCMT = pCMl + pCM2
Out[13]= {ECM1+ECM2, 0, 0, 0}
b. Consider the scalar invariant r]^ p" py, where //* is the total momentum. Evaluate the
scalar invariant in both frames. Since it is a scalar it must be true in all reference frames. If
you equate the two expressions, you get
In[14] := 77 = DiasonalMatrix[{l, -1, -1, -1}];
In[15] := eql = pLT.77.pI1T == pCHT.77.pCHT
Out[15]= (El+m2J -pi2 == (ECM1 + ECM2J
The threshold energy is obtained when
In[16]:= eq2 = ECM1 + ECM2 ==m3+m4;
where m3 and m4 are the rest masses of the final particles. To find the threshold energy in
terms of the kinetic energy of particle one, you must express the energy E{ and the three-
momentum pi in terms of kinetic energy. The kinetic energy T{ is related to El and pi by
the equations
ln[17] := {eq3,eq4} = [eI == Tl+ml, pl== VeI2 -ml2}
Out[17]= [eI ==ml + Tl,pl == VeI2 -ml2}
Using eql, eq2, eq3, and eq4 to express T{ in terms of the rest masses, you get
In [18] := sol =
Solve [{eql, eq2, eq3, eq4}, {Tl},
{El, pi, ECM1}]//Flatten//Simplify
r ml2 + 2 m2 ml + m22 - (m3 + m4) 2 t
Out [18]= Tl-» — [
L 2 m2 >
10.2 Special Relativity 585
PROBLEM 3 Compton Scattering. A photon with wavelength A0 collides with an elec-
electron of mass m at rest and scatters with a new wavelength Al. Let the incident photon move
along the z-axis and let the scattered photon be in the x-z plane, making an angle 6{ with the
z-axis. The scattered electron moves along a direction making an angle 62 with the z-axis.
Let p\ and pi be the initial four-momenta of the photon and electron, respectively. The
final four-momenta of the photon and electron are pj, and pn, respectively.
Before After
ei
62
\
pA
a. Write the initial and final four-momenta. Consider the scalar invariant m2 = Tj^p^p^
and show the change in wavelength as a function of the photons scattering angle 8{
is
h{\ - cos[01])
Al - A0 =
m
b. Write the four equations that follow from the conservation of four-momentum p\ +
pi = p*3 + p*4. Show the kinetic energy of the recoil electron m(yf - 1) is
h{\ - cos[01])
where yf = . ' and vf is the recoil velocity of the electron.
c Show that
mXO cot
Solution
In[19] := Clear ["Global* * "] ;
a. The initial photon and electron four-momenta are
In[20J:= pl= -^ {1,0,0,1};
p2 = m{l, 0, 0, 0};
586 Chapter 10 Relativity and Cosmology
where AO is the initial photon wavelength, h is Planck's constant, and the photon is moving
along the z-axis. The final four-momentum vectors are
In [21]:= p3= ^- {1, Sin [el] , 0, Cos [61] };
p4 = myf{l, -vf Sin[62], 0, vf Cos[62]};
where Al is the scattered wavelength of the photon, yf = J-—-, and vf is the recoil
velocity of the electron. The photon and electron are moving in the x-z plane and the angles
are measured relative to the z-axis.
Consider the scalar invariant m1 = T] p^p*. It follows from the conservation of energy-
LI U LI LI
momentum that p4 = p\ + pi - P3- Expressing the scalar invariant in terms of px, p2, and
p3, it follows that
In[22] := r) = DiasonalMatrix[{l, -1, -1, -1}];
In[23]:= eql=
(m2 == (pl + p2-p3) .77.(pl+p2-p3)//
Sinqplify//ExpandAll j
2 Cos (91) h2 2h2 2mh 2mh
Out[23]= aoai -i5n + -ir--7r^°
Solve eql for Al,
in [24] : = lamRule = Solve [ eql , Al ] [ [1, 1] ] //
ExpandAll
m m
The shift A1-A0 is:
In[25] := Al - AO/.lamRule//Collect [#, {m,h}]6
0ut[25]= hA-C°S(91))
m
b. The four equations that follow from the conservation of four-momentum are
In[26] : = (eq2 = pi + p2 == p3 + p4//Thread) //
ColumnFoxm
Out [26]= — +m== — +myf
True
h h Cos (91)
tt: == 7Z +mvfyf Cos (92)
AV Al
The expression for the electron's kinetic energy is m (yf-1) and the value of yf
follows from the first equation,
10.2 Special Relativity 587
In[27]:= eq3 = Solve [{eq2 [ [1] ]}, yf ]//Flatten//
Simplify
r h (Al - A0)
Out [27]= {Yf
mAO Al
+ 1
Using lamRule to eliminate Al, the kinetic energy for the recoil electron becomes
In[28]:= (( m(yf - 1) /.lamRule/.eq3//Factor) /.
lamRule /.A0 -» h/mtemp //Factor) /.
temp -> A0 m/h
h(Cos(91)-1)
A0 Uf^ -Cos (91) + 1
c. The second and fourth equations in eq2 give two relations between the angles 6X
and#2,
ln[29]:= eq4 = eq2 [ [{2, 4}] ]
Out[29]= (o == h Sln(91) -mvf yf Sin(92),
h h Cos @1) -i
— == -i -tmvfyf Cos (92)
A0 Al J
Eliminating yf, it follows that
In[30] := eq5 = Eliminate [eq2[[{2, 4}]], yf ]//
Simplify
hAl Sin (92)
Out [30]- A0*0AAl*0A — == h Sin (91 +92)
A0
You can use lamRule to eliminate Al
In[31]:= eq6= eq5/.lamRule//
ExpandAll [#, Trig -» True] 6
Out [31]= A0*0A — — + -+A0^0A
m m
_ Cos F1) Sin F2I.2 + sln(e2)h2 +^Q gin(e2) h
A0 ==
h Cos (92) Sin (91) +hCos(91) Sin (92)
and use Solve to reduce this expression to the desired form.
In[32]:= Solve[eq6/. { Sin[e2] ->Tan[62] Cos[62]},
Tan[62]] [[1, 1]] /.tan ->Tan/.
Rule -» Equal //Simplify
mAO Cot
Out[32]= Tan(92) ==
h + mAO
588
Chapter 10 Relativity and Cosmology
PROBLEM 4 Moving Mirror and Generalized Snell's Law. Consider a mirror at rest
in the reference frame X'. As observed in X', the mirror's rest frame, an incident beam
of light makes an angle 8m relative to the normal and, according to Snell's law, reflects
at the same angle. The photon's four-momentum vector can be written as kv = h v0 {1,
n }, where v0 is the frequency measured by an observer at rest relative to the source, h is
Planck's constant, and n is the normalized three-vector, n. n =1. The frequency of light
in X' is vm and is the same for the reflected and incident beam. The laboratory frame X
is moving with velocity v along the normal. In the laboratory frame, the incident light has
frequency v; and makes an angle 6i with the normal to the mirror. The reflected beam in X
has frequency vr and makes an angle 6r relative to the normal.
vr
a. Write the four-momentum vectors for the incident and reflected momenta in the lab-
laboratory and mirror reference frames. Relate these vectors by a Lorentz boost. Show
that the generalized Doppler formula is
1-v2
v, = v_
+V2 + 2vcos[0i]'
b. Show that the generalized Snell's law is
m [6M i_v
cot M tan M = .
2j 2j 1+v
Solution
In[33]:= Clear["Global* *"];
a. The photon's four-momentum vector can be written as ky = h v0 {1, n}, where
v0 is the frequency measured by an observer at rest relative to the source, h is Planck's
constant, and n is the normalized three-vector, n.n =1. The three-vector n points in the
direction the photon is propagating.The momentum four-vectors in the laboratory frame
for the incident and reflected waves are
In[34] := Ki = vi{l, Cos [ei] , Sin[ei] , 0};
Kr = vr{l,-Cos[6r], Sin[er], 0};
10.2 Special Relativity 589
where {#,, 6r} are the incident and reflected angles of the beam and {v;, vr} are the incident
and reflected frequencies as measured in the laboratory frame. Without loss of generality
the value of h has been set equal to one.
In the mirror's frame, the reflected and incident frequencies vm are equal and by Snell's
law the angle of incident and reflection 6m are the same. The momentum vectors in the
mirror's frame are
In [3 5] := Kmi = vm{l, Cos [6m] , Sin [em] , 0};
Kmr = vm{l, -Cos [em]. Sin [em], 0};
The four-momenta in the laboratory and mirror frames are related by Lorentz transfor-
transformations. The boost between two coordinate systems moving with relative speed v along
the x-axis is
In[36] := boostx =
y -vy 0 0
-vy y 0 0
0 0 10
0 0 0 1
where the symbol y = -j== and the speed of light, c=l. The incident four-momenta in
the two frames are related by a Lorentz boost,
In[37]:= (eql = (Ki == boostx.Rni)//Thread)//
ColumnFoxm
Out[37]= vi == y vm- vy vm Cos (©m)
vi Cos (9i) == y vm Cos (©m) - vy vm
vi Sin (9i) == vm Sin (©m)
True
Another four equations follow from relating the reflected four-momenta:
In[38] :- (eq2 = (Kr == boostx.Kmr) //Thread) //
ColumnForm
Out[38]= vr == y vm +vy Cos (Sm) vm
-vr Cos @r) == -vy vm - y Cos Fm) vm
vr Sin(9r) == vm Sin(Sm)
True
Eliminate the variables cos[#r], sin[#r], cos[#;-m], sin[#;m] and vm in eql and eq2 and
solve for vi,
In [39]:= soil =
Solve [{eql, eq2}//Flatten, vi ,
{Cos [er], Sin [er], Cos [em] , Sin [em] ,
vm} ] // Flatten
(v2-l)vr
vr
= -
2 + 2 Cos(9i) v+ lJ
vi
L v2 + 2 Cos(9i)
This is the generalized Doppler shift.
590 Chapter 10 Relativity and Cosmology
b. To get a generalized Snell's law we first eliminate vi from eql and eq2 using soil.
Then use Eliminate to eliminate Cos [dm], Sin [ftn] and y:
In [40]:= eq3 =
Eliminate[
{eql, eq2 , vr * 0, vi * 0 , v * 0,
vjt -1 ,vjt 1}/.soil//Flatten,
{Cos [em] , Sin [6m] , y } ] //
Hap [Simplify,*] 6 ;
eq3 //ColumnFoxm
2 B v+ (v2 + l) Cos(ei))
Out[40]= 2 Cos(9r) = =
Sin(9r) == —
v2 + 2 Cos(ei) v+ 1
(v2 -l) Sin(ei)
v2 + 2 Cos(ei) v+ 1
v t 0
v+ 1 * 0
vm * 0
vr f 0
v Cos (9i) +1^0
v2 + 2 Cos(ei) v+ 1 * 0
Use the second equation to get an expression for v,
In[41]:= eq4 =
Solve [ eq3 [ [2] ] , v ] //Simplify //
PowerExpand //Simplify
Sin(9i + 9r) i r Sin(ei-er)
Oat[41]= v-> -
Sin(ei) + Sin(9r) >' I Sin(9i) + Sin(9r)
Only the second solution has the correct nonrelativistic Umit. This second equation can be
written in the form
ln[42]:= ^^ == [ ^^/. eq4 [ [2] ] I//Simplify
(vTl/.eq4[[2]]).
PROBLEM 5 One-Dimensional Motion of a Relativistic Particle with Constant Ac-
Acceleration. Consider a relativistic particle accelerated by a constant force directed along
the x-axis. Let the particle move along the x-axis and solve for its distance as a function
of coordinate time t. The motion is assumed to be described by the relativistic equation
tyft-'-TC = g, where v[t] =x# [t], t is the coordinate time, and g is the acceleration con-
constant due to the force. Assume the initial velocity is v[0] =v0, and the initial position is
x[0]=x0.
10.2 Special Relativity 591
a. Solve for x [t] and show the solution has the expected nonrelativistic limit.
b. Plotx[t] for the relativistic and nonrelativistic solutions.
Solution
In [43]:= Clear ["Global' *"];
a. The relativistic equation of motion for constant acceleration is
In[44]:= eqMotion = n [ . t-.l == g
L Vl - x.' (t) 2 J
O»t[44]= fV*^-*M=«,
(l-x'(tJ) ^l-x'(tJ
where t is the coordinate time. The algebra simplifies if we solve eqMotion with ar-
arbitrary boundary conditions and then fix their values at the end of the calculation. You
must be careful in using Power Expand because the operation will not always choose the
correct sign of the roots. Solving eqMotion for x[t], you get
In [45]:= eql =
DSolve[{eqMotion }//Flatten, x[t] , t]//
Simplify//PowerExpand//Simplify //
Flatten
Out[45]= (x(t) -»i
- 2 gc-L t + c2 + 1
g
- 2 gCl t + c2 + 1
Only the first solution satisfies eqMotion. To verify this result substitute the two so-
solutions given by eql into eqMotion. You get
In[46] := eqMotion/. D[eql [[#]], t]/.
D[eql [[#]], {t, 2}]&/0{l, 2} //
Simplify//PowerExpand //Simplify
Out[46]= {True, 2 g == 0}
Solution one is the correct answer:
ln[47]:= eq2 = x[t] /. eql [ [1] ]
Jg2 t2 - 2 gCl t + c^ + 1
Out[47]= c2 +-^
9
The initial conditions are related to C [ 1] and C [2] by the two equations
In[48]:= initialConditions=
{(eq2) ==x0, (D[eq2, t]) == vO}/.t -> 0//
PowerExpand
592 Chapter 10 Relativity and Cosmology
f a/C-i + 1 C -,
Out[48]= \c7 + -* == ynr -— 1 == vni
1 g V^
Using the rule
In[49] := gamRule = (l - vO2 -> —^, vO2 - 1-> -—?]•;
to simplify the expressions for C [ 1 ] and C [ 2 ], you get
In[50]:= eq3 =
((Solve[initialConditions,
{C[1],C[2]}] //Simplify)//
PowerExpand) /.gamRule //PowerExpand
Out [50]= ((c, ^xO , c, -> -vOyl, (c, -» xO , c, -^ vOy}}
II g JL g JJ
You can easily check that only the first expression for these constants reproduces the
correct initial condition. The rule for the constants and initial condition is
In[51] := crule = eq3 [ [1] ]
Out[51]= [c2 ->xO - -, C-L -> -vO y|
Eliminating C[l] andC[2] in eq2, the result for x[t] follows
In[52]:= xsol= eq2/.crule//Simplify
gxO - y + Jg t2 + 2 gvO y t + vO2 y2 + 1
Out[52]= i
g
The nonrelativistic Umit is recovered for small vO and g:
In[53]:= nonRelResult =
Series \ xsol/.y-» - ,
4 Vl - vO2 )
{a, 0, 1}, {vO, 0,1}] //Normal
gt2
Out [53]= -—+v0t + x0
b. Set the values of the parameters to
In[54] := values = jxO -> 0, v0-» 1/2, g-» -0.1,
Vl - vO2 J
and plot the relativistic and nonrelativistic motions. If you define the text for the graphic,
10.2 Special Relativity
In[55]:= text =
{Text[ StyleFoxm["Relativistic",
FontFamily- > "Times - Bold",
FontSize -> 10 ] , {10, 1.2}],
Text[ StyleForm["non- relaltivistic ",
FontFamily- > "Times - Bold",
FontSize -> 10 ], {8, 0.2}] };
and combine it with the plot of x [t ], it follows that
In[56] := Plot[{xsol, nonRelResult}//.values//
Evaluate,
{t, 0, 12},
GridLines -»Automatic,
AxesLabel -> {"t", "x"},
PlotStyle-* {{Thickness [0.01]},
{Dashing[{0.06, 0.1}],
Thickness[0.001]}},
Epilog -» text ];
593
1.5
0.!
-0.5
-t
/
u
on-rel
\
\
iltivisti
) 1
vistic
\
D \2
\
The solid curve is the relativistic result and the dashed curve is the nonrelativistic motion.
PROBLEM 6 Two-Dimensional Motion of a Relativistic Particle in a Uniform Elec-
Electric Field. A particle with mass m and charge e moves in a uniform static electric field
Eo. The electric field is assumed to be along the y-axis. The four-momentum for the par-
particle is /** = {moy, moyv} ={E, p], where E = moy is the total energy of the particle
and p = moyv = {px,py,pz} is the relativistic three-momentum. The equation for the
three-momentum is
dt
The relativistic equation of motion reduces to p'x [t]=0,p'y [t] =eEo, p'z[t] =0.
594 Chapter 10 Relativity and Cosmology
a. Assume the initial momentum is perpendicular to the electric field so
Pxl0] = pxo, pyl0]=0, and pzl0]=0.
Show that px [t ]^=pxO, _py[t]=e EO t, and pz [t]=0. Use the relations E2-
p ¦ p = Wq and p = moy v to show that
my = y m2 + pxO2 + e2E02t2.
b. Solve for the particle's path and compare the nonrelativistic limit and the relativistic
solution.
Solution
In [57]:= Clear ["Global* *"];
a. It you define the relativistic three-momentum vector
ln[58]:= pVec[t_] = {px[t] , py [t] , pz [t] };
then the equations of motion for the particle's relativistic three-momentum are
In[59]:= eqMotion = pVec' [t] =={0, eEO,0}//Thread
Out[59]= {px' (t) == 0, p^ (t) == eE0,pz' (t) == 0}
The initial conditions are assumed to be
In[60]:= initial = {px[0] ==px0,py[0] ==0,pz[0] ==0};
The equations of motion and initial conditions can be integrated to give expressions for the
relativistic momentum components:
In[61]:= momRule =
DSolve[eqMotion"Join"initial,
{px[t] , py [t] , pz [t] }, t] [ [1] ]
Out[61]= {px(t) ->pxO, py(t) -> eEO t, pz (t) -> 0}
An expression for y follows from the energy and momentum relation (myJ = p.p +m2,
where p = pVec. It follows that
In[62]:= yRule =
my= = Sqrt fpVec[t] .pVec[t] +m2/.
momRule]//Solve[#,y]&//Flatten
r Jm2 + pxO2 + e2 EO2 t2 ^
Out[62]= y^^
10.2 Special Relativity 595
b. The relativistic momentum and three-velocity are related by p = mQy v. If we let
~v = {j±, ^, ft} and P =Pvec, then it follows that
In[63]:= eql =
pvec[t] ==my{x'[t],y'[t],z'[t]}/.
momRule/ .yRule//Thread
Out[63]= [pxO == ym2 +pxO2 + e2 EO2 t2 x' (t),
eEO t == ym2 +pxO2 + e2 EO2 t2 y' (t) ,
0 == ym2 + pxO2 + e2 EO2 t2 z' (t) }
If the particle starts from the origin,
In[64] := initial = {x[0] == 0,y[0] == 0, z[0] == 0};
then the subsequent path follows from
In[65]:= path =
DSolve[{eql, initial}//Flatten,
{x[t] , y [t] , z [t] }, t] //Flatten;
path // ColumnFoxm
pxO Log 2 e EO t + 2 ^m2 + pxO2 + e2 EO2 t2 j - pxO Log | 2 -Jm2 + pxO2
Out[65]= x(t) -» i
eEO
Jm2 + pxO2 + e2 EO2 t2 - Jm2 + pxO2
y(t) ^ V _ V
z(t) -» 0
To plot the motion assume the values
In [66] .= values = {m-> 1, e-> 1, EO -> 0.1, pxO -» 0.1};
The plots for x[t] andy[t] are
ln[67] := Plot [{x[t], y[t] }/.path//.values//
Evaluate,
{t, 0, 5},
SridLines -»Automatic,
Plotstyle -» { Thickness [0.01] ,
Dashing[{0.06,0.1}] },
AxesLabel -» {"t", "yorx"} ];
596
Chapter 10 Relativity and Cosmology
y or x
1.2
0.8-
O.fr
0.4-
0.2-
/
2 3 '
/
^^
1 5
where the solid curve is the x-coordinate and the y-coordinate is the dashed curve.
The nonrelativistic hrnit follows from expanding x[t] andy[t] in a time series, keep-
keeping the leading-order term, and then assuming m2 > p2xo. It follows from path that the
relativistic and nonrelativistic equations for {x,y} are
ln[68]:= relXY = {x[t] , y[t] }/.path;
In[69]:= nonrelXY=
(Map [Series [#, {t, 0, 2}]s, relXY]/.
{pxO -» 0}//PowerExpand//
Sinq?lify//Normal)
Out[69]
The motion in the x-direction moves with uniform speed and the motion in the y-
direction moves with constant acceleration or as t2. To compare the relativistic and non-
nonrelativistic motions let us plot the relativistic and nonrelativistic coordinates on the same
graph. The plot for the jc-coordinate is
In[70]:= Plot[
{relXY[[1]], nonrelXY[[1]]}/.values//
Evaluate,
{t,0,30},
GridLines -»Automatic,
Plotstyle -» { Thickness [0.01] ,
Dashing[{0.06,0.1}] },
AxesLabel -> {"t", "x"} ] ;
2.!
1.!
0.!
i
^—
-
10
15
20
25
30
10.3 General Relativity
597
where the dashed curve is the nonrelativistic x-coordinate and the solid curve is the rela-
tivistic path. There is no force in the x-direction so the nonrelativistic motion is straight,
but the y factor causes the relativistic path to curve down.
The y component is being accelerated by an electric field along the y-direction. The
graph for the y-coordinate is
In [71]:= Plot[
{relXY[[2]], noarelXY[[2]]}/.values//
Evaluate,
{t, 0, 30},
GridLines -> Automatic,
PlotStyle -> { Thickness[0.01] ,
Dashing[{0.06,0.1} ] },
AxesLabel -> {"t", "y"} ];
40-
3&
2fr
10-
10 15 20 25 30
The dashed curve is for the nonrelativistic motion and the solid curve describes the rela-
relativistic motion. The y factor causes the relativistic and nonrelativistic paths to differ.
10.3 ¦ GENERAL RELATIVITY
10.3.1 ¦ Overview
The theory of general relativity was formulated by Einstein in 1916 and is based on the
principle that the local gravitational force can be replaced by an accelerating reference
frame. The local indistinguishability between gravity and acceleration is a consequence
of the equivalence of inertial and gravitational masses. The equivalence principle is the
basis of general relativity. In contrast to special relativity, general relativity abandons the
pseudo-Euclidean metric and replaces it by a general four-dimensional metric g where
g is a function of the coordinates tf1. Einstein's field equations are then used to relate the
metric g to the matter-energy density in space. In general relativity gravity is no longer
considered to be a physical force transmitted through space and time but is a manifestation
of the curvature of spacetime. The curvature of spacetime is defined by
pa par par
par
l 6fi
pa
l Sv
598 Chapter 10 Relativity and Cosmology
where T% is the Christoffel symbol; this symbol is related to the metric and its derivative
by
The Riemann curvature tensor Rp^v measures the change in a four-vector as it is par-
parallel transported around a closed path. It follows that if space is flat then RjL, = 0 and a
parallel transported vector will return to its original value. The metric for a flat spacetime
corresponds to geometry described by special relativity and does not contain the effects of
a gravitational field.
Several important tensors can be formed from the Riemann tensor. We can lower the
index of the mixed curvature tensor Rpyg to get the covariant tensor R^g = gajiRpy6- The
Ricci tensor R^Y, a second rank tensor, follows from summing over two curvature indices,
RMy = ^r/y-We also have me mixed Ricci tensor Wv = gflaRaY and the Ricci scalar R = Rp.
Following Einstein, a possible choice for the empty space field equations is
An equivalent form of the vacuum equations is
Gap = Kp ~ iSapR = 0
where G^g is called the Einstein tensor. The generalized field equations that include matter
are
r t
*-> ~ ? V
where G is the Einstein tensor and T is the stress energy density.
Geodesies play the same role in curved spacetime as straight lines do in flat spacetime.
A geodesic path satisfies the equations
d d
ds2 * ds ds
where Tpy is the Christoffel symbol. An alternate form of the geodesic equation is
d_( djfi\_U
ds[8^ds) 2
djfi _
d
dx? ds ds
The path is timelike if the four-velocity tangent to the geodesic v" = ^?- satisfies va\P =
+ 1 and null if the four-velocity satisfies vaV = 0. Null geodesies represent the motion of
light and world lines of particles follow timelike paths.
Spacetimes often possess special symmetries. Such symmetries are useful in picking the
"best" coordinate systems and for finding conserved constants associated with the geodesic
equations. For example, if a metric g^ is spherically symmetric, then it is formally in-
invariant under rotations. This means that rotational coordinate transformations leave the
10.3 General Relativity 599
metric form-invariant, g'ap[x'] = g^x'], where x' are the rotated coordinates and g'ap[x']
is the transformed metric expressed in terms of the rotated coordinates. If the metric is
rotationally invariant, then the transformed metric g'ag[x'] is the same function of its argu-
arguments as the original metric gap[x'] is of its argument x'. A transformation leaving g~g[x]
form-invariant is called an isometry. We restrict our attention to symmetries that can be
constructed from infinitesimal transformations. The finite transformation follows from an
infinite sequence of infinitesimal transformations.
Consider the infinitesimal transformation x'f = x? + s?M[x] where s is small. Let us
find the requirements for ^[x] to generate an isometry. The metric and transformed metric
are related by the tensor transformation equations, ?aJx] = |jj? ^g'[x']. If the metric is
form invariant, then gap[x] = |jj? |^r? v[x']. Considering the infinitesimal transformation
given above and evaluating this equation to lowest-order in e, you find that
0 =
W] + g [,] + g [,]
dx? ? dx°~ P* dxf ^
These equations are called the Killing equations and any solution ^[x] is called a Killing
vector. If a metric admits a Killing solution ^[x], then the metric has an infinitesimal
isometry. With some algebra, these equations can be written in the form
where ?.v is the covariant derivative of ? defined by ?.v = -^ - T" %a. When a spacetime
has a symmetry it can be used to simplify the geodesic equation. If V is the tangent to
a geodesic and l& is a Killing vector, then the scalar product gtiYV>i^' gives a constant of
motion. The symmetries of the geometry guarantee a conservation law or first integral for
the geodesic.
Obviously, a tremendous amount of algebra is involved in doing calculations in general
relativity. It is almost a requirement that some computer algebra program be used to do the
calculations. In this section of problems we have constructed several user-defined proce-
procedures for doing common repetitious calculations. They are usually listed in the Remarks
and Overview included at the beginning of the problems.
PROBLEM 1 Killing Vectors and Spherical Symmetry.
In[72]:= Clear["Global* *"];
Consider the following metric
In [ 73 ] : = gj/v = DiagonalHatrix [
{ gOO (r) , gll (r) , -r2, -r2 Sin2 F) }] ;
gf/v //HatrixFoxm
Out[73]=
gOO(r)
0
0
0
0
gll(r)
0
0
0
0
-r2
0
0
0
0
-r2 Sin2
600 Chapter 10 Relativity and Cosmology
This metric has a symmetry if there is a vector ?„ that is a solution of the Killing equa-
equations ?,a.g + ?g.a = 0, where the semicolon ; means covariant derivative. To find all the
Killing vectors for the metric is in general a hard task. However, we can simplify the
calculation by stating the Killing vectors and then showing that they satisfy the Killing
equations.
a. This metric has four Killing vectors: three vectors are associated with rotational
symmetry and a fourth Killing vector is associated with the invariance under time
translations. Consider the following four contravariant vectors W:
&" = {1,0,0,0}
kxf = {0,0, -Sin[0], -Cos[0]Cot[0]}
kf = {0,0, Cos[0], Sin[0]Cot[0]}
fa" = {0,0,0,-1}
and verify that these four vectors satisfy the Killing equations for the metric g/j.v.
Use the user-define procedure listed below under Remarks and Outline that returns
the nontrivial Killing equations.
b. If V = {f [s], r' [s], & [s], <f>' [s]} is the four-vector tangent to a geodesic,
then a constant of motion follows from g^V^k*, where kv is a Killing vector and g
is the metric. Find the constants of motion using the four Killing vectors. Express
t' [s], ff [s], and0' [s] in terms of the four constants of motion.
Remarks and Outline You need two procedures to do this problem, one to calculate the
killing vectors and another to calculate the Christoffel symbol. The user-defined function
that returns the nontrivial Killing equations ?a.^ + ^.a = 0 is
In[74] := killingEq[ContraV_, g_, r_,
x_ :{t, r, 0, 0}] : =
Module [{tempi, temp2, temp3, temp4},
tempi=g.ContraV;
temp2 = Outer[D, tempi, x] - tempi.r,-
temp3 = temp2 + Transpose[temp2];
temp4 = (temp3 //Flatten) == 0//Thread //
Simplify;
Complement[
Select [temp4, FreeQ [#, Trues ] ] ]
The Killing equations are computed when the contravariant vector (ContraV), metric (g),
Christoffel symbol (F), and variables (x) are entered into the procedure call killingEq
If no equations are returned, then the vector is a Killing vector.
The procedure was written in a manner that required the calculation of the Christoffel
symbol
10.3 General Relativity 601
The user-defined function for the Christoffel symbol is
In [75] : = Christ [met., var. : {t, r, 6, 0} ] : =
Module[{ tempi, imet, result},
tempi = Outer [D, met, var] ;
imet = Inverse [met] //Simplify;
result =
1/2 (Transpose [imet.tempi, {1,3,2}] +
Transpose [Imet.tempi, {1, 2, 3}] -
imet. Transpose [tempi, {3, 2, 1}] ) ;
Return[result]]i
If you input the metric and variables, then Christ returns a list of all 4 X 4 X 4 = 64
components for the symbol. The individual components follow from Tpy = T[[a,fi, y]],
where the variables are labeled by t-»l, r-»2, 8 -»3, and cf> -»4. To understand these
procedures, you should execute the steps one at a time until you understand each.
Solution
a. Define the four contravariant vectors W:
ln[76]:= kt = {1,0,0,0};
kz = {0,0,0,-1};
kx= {0, 0, -Sin[0], -Cos[0] Cot [6]};
ky= {0, 0, Cos [0],-Sin [0] Cot [6]};
The Christoffel symbol for the metric g/j.v is
In[77] := T = Christ [gj/v] ;
Applying the user-defined function killingEq to all four contravariant vectors at
once, you get
In[78] := (killingEq[#, gj/v, r]6/0{kt, kz, kx, ky} //Simplify)
Out[78]= {{}, {}, {}, {}}
There are no nontrivial equations, so the four contravariant vectors kt, kz, kx, and
ky are all Killing vectors.
b. The constants of motion follow from the scalar product g VMky, where ky is the
Killing vector, g is the metric, and the tangent four-velocity V is
ln[79]:= velocity = {f [s] , r'[s] , e'[s] , 0'[s] };
Form the scalar product gJV^ for each of the Killing vectors and equate them to the
constants, {en, jx, jy, j z}:
602 Chapter 10 Relativity and Cosmology
In [80] .-= kconst = {
en == gj/v. velocity, kt,
jx== gj/v. velocity, kx,
jy == gj/v. velocity, ky,
jz == g^v.velocity.kz};
kconst //ColumnFoxm
Out[80]= en==gOO(r) t'(s)
jx == Sin @) 9' (s) r2 + Cos (9) Cos @) Sin (9) 0' (s) r2
jy == r2 Cos (9) Sin (9) Sin @) 0' (s) - r2 Cos @) 9' (s)
jz == r2 Sin2 (9) 0' (s)
The first constant corresponds to the conservation of energy and the next three constants
correspond to the three components of the conserved angular momentum.
We can solve these equations for t' [s], <p' [s] and ff [s]. The expressions for
t' [ s ] and </>' I s ] follow from the first and fourth equations
ln[81]:= Solve[kconst[[{l, 4}]], {t' [s], <t>' [s] }] //
Flatten//ColumnFoxm
Out[81]= t' (s)
g00(r)
jzCsc2(9)
0 (s) -> =
The equation for ff [ s ] is
ln[82]:= Solve [kconst [ [{ 2, 3}] ] , 6' [s] , 0' [s] ]//
Flatten//Simplify
Out[82]
PROBLEM 2 Schwarzschild Solution.
In[83]:= Clear["Global* *"] ;
Just months after Einstein published his theory of gravity, Karl Schwarzschild A916) found
an exact solution that corresponded to the gravity field outside a nonrotating spherical mass
source. It is by far the most important vacuum solution in general relativity. The derivation
simplifies if you make use of the static and spherical nature of the source. We first introduce
coordinates that are appropriate to the problem, i.e., spherical coordinates {t, r,8, cf>}. We
also assume the metric is rotationally invariant and independent of time. It follows from
problem one that the metric that satisfies these constraints is
In [84] := gj/v = DiagonalHatrix [
{ gOO (r), gll (r) , -r2, -r2 Sin2 F)}] ;
The problem is to find the values for gOO and gll that correspond to a spherical star
of mass M.
10.3 General Relativity 603
a. Set the components of Einstein's tensor to zero, G = 0, and solve for the metric
components. Assume the boundary condition that follows from the weak field limit.
The weak field limit relates Newtonian gravity to the metric component g00->
1+^J, where $ is the Newtonian gravitational potential. Use the user-defined proce-
procedures defined in the Remarks and Outline below to compute the Einstein tensor.
b. The critical radius at r = 2S^ is called the Schwarzschild radius and is a measure of
c
the importance of the effects of general relativity. Evaluate the ratio for the radius of
the Moon, Earth, Sun, white dwarf and neutron star with the Schwarzschild radius.
Remarks and Outline To calculate the Einstein tensor we need the expression for the
Christoffel symbol and curvature tensor. The Christoffel symbol was defined in the previ-
previous problem:
In[85}:= christ [met., var. : {t, r, e, 0}] : =
Module [{ tempi, imet},
tempi = Outer[D, met, var] ;
Imet = Inverse [met] //Simplify;
1/2
(Transpose[imet.tempi, {1, 3, 2}] +
Transpose [imet.tempi, {1, 2, 3}] -
imet. Transpose [tempi, {3, 2, 1}] )
If we know the Christoffel symbol then the curvature tensor
follows from
In[86] := curvR [Christ., var. : {t, r, 0, 0}] : =
Module[{tempi},
tempi = Outer [D, Christ, var];
(Transpose[Outer[D,Christ, var],
{1,2,4,3}]-
Transpose [Outer [D, Christ, var] ,
{1, 2,3,4}] +
Transpose [Inner [Times, Christ,
Christ, Plus, 2] , {1, 3,4,2}]-
Transpose[Inner[Times,Christ,
Christ, Plus, 2] , {1,4,3,2}])
If the Christoffel symbol and coordinates are entered into curvR, then a list of
4x4x4x4 = 256 components are returned. The individual components follow from
CurvR [•••] [[1,2,3,4]], where the variables are labeled by t-»l, r-»2, 8 -»3,
and (f> ->4. Not all these components are independent due to the algebraic symmetries of
the curvature tensor.
604 Chapter 10 Relativity and Cosmology
Finally, the Einstein tensor Ga~ = Ra~ - jg^R follows from the user-defined procedure
In[87] : = einstein[curv_, met.] : =
Module [{dam, tempi, temp2, i, j, s},
dem = Length[met];
tempi=
Simplify[
Expand&ll[
Table[Sum[curv[ [s, i, s, j] ] ,
{s, dem}], {i, dem}, {j, dem}]]];
temp2=
Simplify[
ExpandAll[
Sum [Inverse[met][[j, i]]
ourv[[s, i, s, j]], {s, dem},
{i, dem}, {j,dem}]]];
Simplify[
ExpandAll[
Table [tempi [[i, j]]-
A/2) met [[i, j]]temp2, {i, dem},
{3, dem}]]]]
The Einstein tensor is calculated when the curvature Rpyg and the metric are entered into
einstein. The Einstein tensor Gap is a symmetric tensor.
Solution
a. The metric components gOO [r] and gll [r] follow from solving the vacuum equa-
equations G = 0. To find the Einstein tensor you first compute the Christoffel symbol T%y for
the metric
In[88]:= r = Christ [gj/v, {t, r, e, *}];
where the spherical coordinates are {t, r,6, <p}. To view the individual components, enter
F [ [a,b, c] ] where a, b, and c take on the values {1,2,3,4}. You now compute the
curvature tensor R"pys:
In[89]:= R = ourvR[r, {t, r, 0, «}] //Simplify ;
Given the metric and curvature components you can use the user-defined function ein-
einstein to calculate the Einstein tensor G :
In [90] := Gf/v = einstein [R, gj/v] ;
In general, Gpv has 16 components but with our simplifying assumptions on the form of
the metric only the diagonal components are nonzero.
The vacuum equations follow from setting the components of G Y to zero. The nontrivial
equations that follow from G = 0 are
10.3 General Relativity 605
In[91] : = {eqGtt, eqGrr, eqGee,
MapAt [Flatten, Gj/v ==0,1] //Thread //
Select [#1, FreeQ [#, True] 6] 6 //
Simplify ;
where Select was used to pick out the nontrivial equations. These four equations cor-
correspond to the diagonal components of G and are called {eqGtt, eqGrr, eqGOO,
eqG#}.
Only the first two equations, eqGtt and eqGrr, are needed to determine the two un-
unknown functions gOO and gll. The two relevant vacuum equations are
In [92]:= vacuumeq =
({eqGtt,eqGrr}//
Solve [#, {gll' [r], gOO' [r] } ] &//
Flatten) /. Rule -> Equal;
vacuumeq //ColumnForm
Out [92]= gll'(r) == --
. _ gOO(r)
1 r2 gll(r)
gOO' (r) == r gOO (r) I -
gOO(r)
gll(r) 1
r2 r2
Applying DSolve to vacuumeq, the solutions for gll [r] and gOO [r] follow
In[93]:= sol = DSolve[vaouumeq, {gll[r] , gOO [r] }, r] //Simplify//Flatten
Out[93]= {gll (r) -» e ^ , gOO(r) -» -i —L^-j
The values for C[l] and C[2] follow from the weak field condition gOO [r]
->l-2^r as r goes to infinity. It is obvious that the constants that give this value
are
In[94]:= bdcond = {c[l] -> Log [^-] , C[2] -
Out [94]= ic- -> Loa ^^ .c,^—^\
c2
2GM
where the velocity of light is c, G is the gravitational constant, and M is the mass. The
Schwarzschild metric is
In[95] := (gj/v/.sol/.bdcond/.G-> temp o2 r//
8
Simplify) /.temp -» j
re2
606
Chapter 10 Relativity and Cosmology
Out[95]=
c2r
0
-r2
0
-r2 Sin2 (9)
Far from the origin the gravitational effects vanish and the metric reduces to the familiar
Minkowski metric expressed in spherical coordinates.
b. The critical radius at rs = 2 m =^^ is called the Schwarzschild radius. The value
of the Schwarzschild radius is usually very small compared to the size of a moon, planet, or
star. Let us evaluate the ratio of rs to the radius of the Moon, Earth, Sun, white dwarf star,
and neutron star. The values of the {mass, radius} for the Moon, Earth, Sun, white
dwarf, and neutron star are given by the list of lists,
In [96] := data =
{{7.35 * 1025 g, 1.738 * 108 cm},
{5.977 *1027 g, 6.378 *108 cm},
{mo, 6.9598 *1010 cm},
{mo, 1.738 *1010 cm},
{mo, 106 cm}}/.
Mo-> 1.989 *1033g;
Displaying the data in table form, it follows
In [97] := names = {Moon, Earth, Sun, "white dwarf" ,
neutron star};
TableForm[data,
TableHeadings ->
{names, {Mass, Radius}}]/, cm -> 10 km
Out[97]=
Moon
Earth
Sun
Mass
7.35xl025g
5.977 x 1027 g
Radius
1738. km
6378. km
1.989xl033g 695980. km
white dwarf 1.989 xl033g 173800. km
neutron star 1.989 xl033g 10 km
The relevant constants needed for a numerical evaluation are
In [98] := constants = {c -> 3 . * 1010cm/sec ,
If you define the simple user-defined procedure
In [99] : = Ratio [ {M_, r.} ] : =
2GM
-//.constants
10.3 General Relativity 607
and then apply it to data, it follows that the ratios ™, where rs = 2Gm/c2, are
In[100]:= Transpose [{names. Ratio[#]&/9data }] //
TableFoxm
Out [100]= Moon 6.28006X101
Earth 1.39163 x 1(T9
Sun 4.24389x10
white dwarf 0.0000169946
neutron star 0.295367
The ratios ™ are very small and the effects of general relativity can usually be ignored
except for neutron stars and possibly for white dwarfs.
PROBLEM 3 Geodesies for the Schwarzschild Metric. The paths for geodesies fol-
follow from the equation
A I AtP\ 1 ddi-^ArO AJ3
= 0
2 dxF ds ds
Use the user-defined procedure geodesic given below under Remarks and Outline to
find the four geodesic equations.
a. Restrict the motion to the plane 6 [ s ] = n/2, write the explicit geodesic equations for
the Schwarzschild metric, and show
r[s]= 2-WM
2mr[s] - r[s]2
r"[s]
S
where m = ^f.
b. Integrate the t"
t'[s] :
r"[s] =
( 2m \
2rWM
r[s]
[s] and0"[s]
En
-4h2m2 + 4ti
mr>^ . mfTvl2 Hvl^Tvl2
r. . 2 LJJ r\.s\ <P Is!
I I1 r[s]j )
r[s]2
equations and reduce the equations to the forms
lmr[s] - h2r[s]2 + mr[s]3(En2 - r'is]2
Bm - r[s])r[s]4
608 Chapter 10 Relativity and Cosmology
c. Find the expression for /[s]2 that follows from evaluating the timelike condition 1
= g v^V. Show that r'ls]2 can be written in the form
_ 2 _ 2h2m _ Jf_ 2^
r[s]3 r[s]2 r[s]
In [101] .- = Clear [ "Global» * " ] ;
Remarks and Outline The procedure to calculate
d
2 dxF ds ds
is
In [102] := geodesic [met., var., parameter. : s ] : =
Module [{metl, tempi, veil, varl},
veil = D[Through[var[parameter]],
parameter];
varl = Through[var[parameter]];
metl =
met/.
Thread [var -> Through [var [parameter] ] ] ;
tempi=
(D[metl .veil, parameter]-
A/2 D[metl, #] .vell.vells/evarl) ==
{0, 0, 0,0})//Thread]
If the metric and coordinates are entered into the operator geodesic, then four
geodesic equations are calculated.
Solution
a. The form of the Schwarzschild metric is
In [103] := gf/v = DiagonalMatrix f
{g00(r) , gll(r) , -r2, -r2 Sin2 F) }]
Out [103] =
where the metric components are defined by the rule
l
g00(r)
0
0
0
0
gll(r)
0
0
0
0
-r2
0
0
0
0
-r2 Sin2 (9)
In[104]
r / 2m
:= oomp=|g00-> ll-—
and m=^-. Applying the user-defined operator geodesic to g , you get four equations
for the general metric.
10.3 General Relativity 609
In[105] := eql = geodesic [gjzv , {t, r, 6, «}]//
Simplify ;
The equations simplify if you solve for {t" [s], r" [s], 0"[s], <p"[s]}, evaluate
the metric components, and restrict the motion to the 6 = f plane:
In [106]:= eq2 =
(Solve [eql, {t" [s] , r" [s], e" [s] ,
«" [s] }]//Flatten)/.comp/.
6 -> GT/2&) /.Rule -> Equal //Simplify;
eq2 //ColumnForm
Outflow- t"(s) 2mr'(s)t'(s)
2mr (s) -r
/ 9 \
2r'(s)«'
(sJ
(s)
2r(sK"M
r(sJ
SlJ7 tit'
(sJ
True
r(s)
We restricted the motion to a plane using the rule 6 -> (n/2&). These are the desired
equations listed in part a of the problem.
b. The equations for t" [s] and <p" [s] can be integrated once. It follows from the
following "trick" that t' [s] is
In[107] := eq3= DSolve[eq2 [ [1] ] , r [•],•][ [1, 1] ] /.
Rule -> Equal
2 e2mcimt' (s)
Out [107]= r(s) ==
t'(s) -
Solving this equation for t' [s] and choosing an appropriate expression for the con-
constant, it follows that
In [108] := trule =
Solve[eq3,t'[s]] [[1,1]]/.
C[l] -> Log [En]//Flatten
2m
Out [108]= t'(s) ¦ Enr(s)
r (s) - 2m
This is one of the equations listed in part b of this problem.
We can also apply this same trick to the equation for <p" [s]:
In [10 9] := «rule =
(DSolve[eq2[[4]] ,r[s],s] [[1,1]] /.
Rule -> Equal//
Solve[#, V
610 Chapter 10 Relativity and Cosmology
Out[109]= <j>' (s) -> =¦
which is the second equation in part b.
The equation for r" [s] reduces to the desired form if we eliminate <p' [s] and
t' [s] in the radial geodesic equation given by eq2 [ [2 ] ],
': = eq4 = eq2 [ [2] ] /.trule/.tfrule//Simplify
Out [110]= r"(s) ==
m (En2 -r'(sJ)r(sK-h2r(sJ+4h2rnr(s)-4h2m2
Bm-r(s)) r(sL
c. To get an expression for r'fj]2, evaluate the timelike criteria 1 = g^v^V, where g
is the Schwarzschild metric and vv is the four-velocity vector defined by
Restrict the variables to the 6 = n/2 plane and then change the metric variables to be
functions of the parameter s
In[112]:= met =
[g(iv/.comp/.e-> -/.i
9-.9[s] ;
The timelike condition becomes
In[113]:= eq5 = 1 == vel.met.vel
2m
You can eliminate the derivatives t' [s] and <f>' [s] with the rules derived in part b:
Oat 11131= l==-^-^+ [l-^l t'(sJ-r(sJ0'(sJ
ln[114] := eq6 = eq5/.trule/.0nile //Simplify
(En2 -r'(sJ)r(sK-h2r(s) +2h2m
Out [114]= '-j == 1
r(sJ (r(s) -2m)
Solving for ^[s]2 you get
ln[115]:= r' [s]2/. Solve [eq6,r'[s]] [[1]]//
Simplify
, 2m h2 2h2m
Out[115]= En2 + —— ^ + t - 1
r s) r(sJ r(sK
10.3 General Relativity 611
PROBLEM 4 Time It Takes to Fall into a Black Hole. Radial geodesies are one of the
simpler types of paths to calculate, because their four-velocity has only two nonzero terms
{f [s] ,r' [s],0,0}. Consider the radial timelike geodesies for the Schwarzschild
metric. In Problem 3 it was shown that the geodesic equations satisfy the following two
expressions:
Radial geodesies follow from setting h=0 in the second equation.
a. Assume the initial conditions r' [0] =0 and r [0] =r0 and derive an equation for
r' [s] that corresponds to an Mailing particle. The proper time as a function of
the radial position follows from integrating 1 /r' [ s ] over r. Integrate the equation
to get an expression between s and r. How long does it take to fall from rO to the
origin as measured by the proper time?
b. An expression for the coordinate time follows from forming the ratio r' [t] =
r'[s]/t'[s] and integrating 1 / r' [ t ] over r. Integrate the expression.
c. Plot r as a function of both the proper and coordinate times.
Solution
In[116]:= Clear["Global1*"] ;
a. Consider the equation for the radial variable,
:= eql =
, , 2m h2 2h2m
Set h=0 and solve for r' [s]
in [118]:= eq2 =
Solve [eql, r'[s]] /.h-> 0/.
Rule -> Equal /. ^/xL » Vsimplif y [x] //
Flatten
Out [118]= {r< (s) == -^ ^-U (s) == ^ + -^ - l}
The inward moving path corresponds to the solution with the negative sign in front of
the radical, so define
:= eq3 = eq2[[l]]
612 Chapter 10 Relativity and Cosmology
Out [1191= r'(s) ==-
The constant En can be expressed in terms of the initial velocity r' [0] =0 and initial
position r [0] =r0 if you evaluate eq3 at s=0:
In[120] := eq4 = 0 == eq3 [ [2] ] /.s -> 0/.r[0] -> rO
Out [1201= 0 ==-,/En2 + —-1
Solving eq3 and eq4 for r' [s] and En, you get
In[121]:= rprimerule=
Solve[{eq3,eq4}, {r'[s],En}] [[2]] //
Simplify//ExpandAll
Out 11211= -lr'(s) -»-
r(s) rO'
Only the solution that corresponded to inward motion was kept. The radial equation is
In[122]:= radialeq=
rprimerule [ [ 1] ] /.*JxL » Victor [x] //
Po^erExpand
0ut[122]=
r (s)
An equation for the proper time as a function of the radial position follows from inte-
integrating 1/r' [s] overr.
In [123]:= Stime =
Integrate \ ———/.rprimerule,
{r[s], rO , r },
Assumptions -» { rO >r >0}l//Apart
Notice the time to fall to the origin (r=0) is
GH
In[124]:= Stime/.r-> 0/.m-» -j-//PowerExpand
cj:rO3/2
Out[124]=
b. Let us now parameterize the position of the falling test particle by its coordinate time,
i.e., the time read by a clock a long distance away from the black hole. The expression for
r' [t] follows from the ratio pj^J, where the expression for t' [s] is
10.3 General Relativity 613
in[125]:= trule = t'[s] ->—^;-;
The ratio ^M follows from
In [126]:= eq5 =
/.trule/.rprimerule/.
it'(s)
r[s]
x.n- » Factor [Together [x] ]n //
PowerExpand //Expand //Simplify
Out[1261=
/rO-2mr(t)
3/2
The coordinate time as a function of the radial position follows from integrating 1 /eq5
over r. This integration simplifies if you change variables,
In[127] : = change = [r (t) -> rO Cos2 (x) ,
r' (x) -> -2 rO Cos (x) Sin(x) };
and then integrate over x where the integral becomes jT ^^dx. The integrand is
ln[128]:= eq6 = I r'[x]/.change I//Simplify//
\eq5 /
PowerExpand
V2 rO2 VrO - 2mCos4 (x)
Out [128]= —
Bm-rOCos2 (x) ]
Integrating eq6 from xO =0 to xf = arccos kr^L the expression for the coordinate
time becomes
In[129]:= Ttlme =
Integrate f eq6 , (x, 0, Cos L / ~ \\ ]/.
{2m- rO -» -tempi }//PowerExpand |/.
tempi -> rO - 2 m // Simplify
614
Chapter 10 Relativity and Cosmology
l
Out[129]=
2 V2VS
TcHXri
rO - 2m
V2"
VrVrO-
2 Dm + rO)
rO Sin
2 Cos
2m
Cos
yfr
VrO
m3/2
Vr '
VrO
c. Plot the coordinate and proper times for the values:
In [130] : = value = {m-> 1, rO -> 8};
The graphics for the coordinate and proper time curves are
In[131]:= ptl = Plot [Evaluate [ (Ttime/. value)],
{r, 2, 8}, DisplayFunction -» Identity] ;
pt2 = Plot[Evaluate[Stime/.value],
{r, 0, 8}, DisplayFunction -»Identity] ;
Define the text and markings for the graphics,
In[132]:= text={Line[{{2,0},{2,40}}],
Text [ StyleForm [" Proper Time " ,
FontFamily- >"Times - Bold",
FontSize-»10 ], {1.2, 22}],
Text [ StyleForm[ "Coordinate Time",
FontFamily- > "Times - Bold",
FontSize-* 10 ], {4.5, 30}],
Text[ StyleForm["r = 2m",
FontFamily- > "Times -Bold",
FontSize-»10 ], {2.6, 10}]
}//Graphics;
If you combine the paths and add labels, then the graph for the coordinate and proper
times follow from
In[133]:= Show[{ptl, pt2, text},
AxesLabel -> {"Distance", "Time"},
DisplayFunction -» $DisplayFunction,
PlotRange -> {0, 40}];
10.3 General Relativity
615
irdinate Time
Distance
PROBLEM 5 Circular Geodesies for the Schwarzschild Metric. Consider the time-
like circular geodesies for the Schwarzschild metric. Assume the geodesies are in the plane
#[s] = n/2 and the radius is a constant r [s] =r0. Start from the expressions for the
geodesic given in Problem 3:
t'[s] =
En
— 2m'
cf>'ls] = j,
-4h2m2 + 4h2mr[s] - h2r[s]2 + mr[s]3(En2 -
r"[s] =
Bm - r[s])r[s]4
and
= (En2 - 1) +
2h2m h2
2m
r[s]3 r[s]2 r[s]
You get circular orbits by replacing r [s] with the constant rO. Express the constants
En and h in terms of rO and derive expressions for t [ s ] and <p [ s ]. Find the orbit periods
as expressed in terms of the proper and coordinate times.
Solution
In[134]:= clear ["Global1 *"];
The expressions for t' [ s ] and <p' [ s ] are
In [135]:= teq = t'(s) ==
En
l-
->r0
Out[135]= t' (s) = =
En
In [13 6]-.= 0eq = <t>' (s) == , 2/.r[s] -.rO
r(s)'
Out [136]= 0'(s) == —j
rCr
616
Chapter 10 Relativity and Cosmology
where we set r equal to a constant using the rule r [ s ] ->rO. The expressions for En and
h follow from the equations for r " [ s ],
ln[137]:= ace =
r"[s] ==
(m (En2 -r' (sJ) r(sK -h2 r(sJ +
4h2m(r(s) -m))/
(Bm-r(s)) r(sL)/.r ¦* (rOs)
En2mr03 - h2 rO2 + 4h2m (rO - m)
Out 11371= 0 ==
and for r'ls]2,
ln[138]:= vel =
Bm-rO) rO4
r' (sJ == En2 +
2m
2h2m
r(s) r(sJ r(s)
-1/.
r -> (rO&)
Out[138] = 0 == En2 + - -
rO rO2
- 1
where we set r equal to a constant using the rule r-> (rO&).
You can solve these two equations for En and h:
In[139]:= eq2=
(Solv*[{acc,vel}, {En, h} ]//Simplify //
PowerExpand)/.
i
/3m- rO ~
Out[1391=
There are four solutions. We are interested only in the one where both En and h are posi-
positive.
In [140]:= Enhrule = eq2[[4]]
rO - 2m
Out [140]= JEn-
10.3 General Relativity 617
Apply DSolve to t' [s] and <p' [s] to get expressions for t [s] and <p [s]
In[141] := sol =
DSolve[{ teq, *eq, t[0] == 0, *[0] == 0},
{t[s],« [s]},s]/.Enhrule//
Flatten//simplify
0ut[141] =
/rO -3m rO VrO - 3mJ
The proper period follows from solving <p [s] =2;r for s:
ln[142]:= s/.Solve[(*[s]/.sol) == 2n, s] [ [1, 1]]
27rrO VrO -3m
Out [142]= ._
-\/m
The coordinate period follows from evaluating t [s] when 0 [s] =2;n
In [143]:= Period/.
Solve [ {Period == t[s ], tf [s] == 2 tt}/.sol.
Period, s][ [1,1]]
2 7rrO3/2
Out[143]=
¦\/m
PROBLEM 6 Precession of the Perihelion. One of the most accurate tests of general
relativity is the precession of the perihelion. The precession reflects the fact that bound or-
orbits are precessing ellipses. Consider the timelike geodesies for the Schwarzschild metric.
Assume the orbit is in the 6 = | plane and consider the bound orbits. Make use of the
expressions derived in Problem 3 for the conservation of angular momentum <p'[s] = p,
and the equation that followed from the timelike condition 1 = gfn,vf'vy,
/[s]2 = (En2 - 1) + —5- - —-j + —-
r[sf r[s]2 r[s]
a. Show the orbit equation can be expressed as
"W
where u=j and the parameter s is replaced with <p.
b. Assume a small perturbation about a circular orbit and show that the orbit can be
expressed as a precessing ellipse where the perihelion shift is J??^
c. Make a numerical table of the precession values for Mercury, Venus, and Earth.
Solution
In[144] := Clear ["Global1 * "] ;
a. The timelike condition gives the following expression for
618 Chapter 10 Relativity and Cosmology
In [145] := eql =
, , 2m h2 2h2m
r' (sJ == En2 + j + ? - 1;
r(s) r(sJ r(sK
Change the r parameterization from s to 0 in eql. The change follows from noticing that
dr[s] d<p[s] dr[<p[s]] d<p[s] h
= and = —x.
ds ds dcf>[s] ds r2
This change is implemented with the rule
r h r' (<*) i
In[146]:= change = Jr'(s) -> ^V-,r(s) ->r(tf) \i
I r(«J J
Replacing the parameter s with cf> in eql, you find that
In [147]:= eq2 = eql/. change
h2r'@J__ 2 2m h2 2h2m
r(*L + r@) ~r@J + r@);
Further simplification occurs if the radial coordinate is changed to r= 1 /u.
In[148]:= eq3 = eq2/. {r
Out[148]= h2u' @J == 2h2mu@K -h2u@J + 2mu@) +En2 -1
Take the derivative of eq3 to convert this first-order differential equation to an equation
In[149]:= uEQ=
(D[eq3,«] //solve [#, u" [«] ] [[1, 1]]&)/.
Rule -»Equal//ExpandAll
Out[149]= u" @) == 3mu@J -u@) + -^¦
b. Let us find the first-order perturbative solution of uEq. Assume the solution is of the
form
In [150] : = pertu = {u - > (uO + du [#] 6) } ;
where uO corresponds to the circular orbit and du is a small perturbation about uO. Ex-
Expressing uEq in terms of du, you get
In [151]:= uEq/.pertu// ExpandAll
Out[151]= du"@) ==
3muO2 + 6mdu@) uO-uO + 3mdu@J + — -
10.3 General Relativity 619
Since du is considered to be small we can drop the term du[</>]2:
In[152]:= eq4 = (uEq/.pertu//ExpandMl) /.
du[0]~2->O
Oat[152]= du" @) == 3muO2 + 6m du(</>) uO - uO + -^ -du(</>)
We can eliminate the value of h by using the fact that the condition for the circular orbit
follows from setting du and its derivative to zero:
In[153]:= eq5 = eq4/.du"[tf] ->0/.du[tf] -> 0//
Simplify
Out[153]= -^ +u0 CmuO - 1) == 0
eq5 gives a relation between h and uO. If we use eq5 to eliminate h in eq4, then you get
an equation for du expressed in terms uO. It follows that
In [154].- = eq6 =
Solve [ {eq5, eq4}, du" [*] ] [ [1, 1] ] /.
J6muO- > 1 -y2j/.Rule- >Equal//
ExpandAll//Simplify
Oat[154]= du" @) == -y2 du(</>)
where we simplified the notation by defining y:
In [155]:= yrule = y -> Vl-6muO;
Notice the value of y is less than one. The solution for this "oscillator equation" is
In [15 6] := dusol =
DSolve[{eq6 ,du[0] ==eu0, du'[0] ==0},
du[0],0] [[1,1]]
Out[156]= du@) ^euO Cos(y0)
where du [ 0 ] = e uO and the value of e is an arbitrary small constant. The first-order
solution for the orbit follows from uO+du:
In[157]:= uSol = uO + du[«]/.dusol
Oat[157]= e Cos(y0) uO+u0
To agree with the parameterization of an ellipse, we identify uO with
In [158] := uOrule = uO -» 5—;
a A-e2)
where a denotes the semi-major axis of the orbit and e is the eccentricity of the ellipse.
The equation for the radial variable of the processing ellipse becomes
620 Chapter 10 Relativity and Cosmology
ln[159]:= r == A/uSol )/.u0rule //Simplify
Out[1591= r== a"a^—-
e Cos (y0) + 1
The factor y determines the rate of precession. The orbit does not return to the same
point after cf> goes from 0 to 2 n but the next perihelion occurs at y 0p=2 n. Since y is less
than one it follows that 0p is greater than 2n. The advance of the angle beyond 2n is called
the perihelion shift and is given by
In [160]:= eq7 = 2 tt/y - 2 tt;
Evaluating y and keeping lowest-order terms in m, you get the advance after one orbit
In[161]:= ((eq7/.Ynile/.u0rule) + o[m]~2//
GH
Normal) /.m-> -=¦
c
Out [161]= ^GM7T
ac' A-e2)
We have replaced m with ™. Denote the perihelion advance with A,
6GM7T
In [162]:= A =
ac2(l-e2)
which is in units of radians per orbit.
c. Let us evaluate the shift for the orbit of Mercury. The values of M and 6 are
In[163]:= const = [m -> 1.989 * 1033 gm.
G- > 7.42426 * 10
9
gm
where M is the mass of the Sun, 6 is the gravitational constant, and c is the speed of light.
The orbit parameters for Mercury are
In[164]:= mercury = [ a-» 0.3871 An,
AU- > 1.49599 * 1013 cm,
6- >0.205614 };
where AU is an astronomical unit. We want the answer in arc sec so we define the con-
conversion from radians to arcsec.
In[165]:= radTosec = 360* 60 *60/B 7r) ;
We also want the shift for a time period of 100 Earth years. To make this conversion
you need to know how many orbits Mercury makes in 100 years,
100
In[166]:= Mmimber = —;
0.24085
10.4 Cosmology 621
where Mercury's orbital period is 0.24085 years. The perihelion shift for Mercury is
In[167] : = A (radTosec) (Mnumber) /.const//.mercury//
NumberForm[#,4]6
Out[167]= 42.98
in units of arcsec per 100 years.
What are the perihelion shifts for Venus and Earth? The orbit parameters for Venus are
In [168]:= venus = { a -> 108.2 * 1011 cm, e -> 0.007} ;
and the number of orbits Venus makes in 100 years is
100
In [169]:= Vnumber = —— ;
The advance follows from
In[170] := A (radTosec) (Vnumber)/.const//.venus//
NumberForm[#,2]&
Out [170]= 8.6
For Earth, you find
In [171]:= earth =[ a -> 149.6 * 1011 cm , e -> 0.017} ;
In[172]:= A (radTosec ) A00)/.const//.earth//
NumberForm[#, 2]&
Out [172]= 3.8
The observed values for Venus and Earth are 8.4 ±4.8 and 5.0 ± 1.2, respectively. The
experimental error increases rapidly as the distance from the Sun increases because the
precession per revolution and the revolutions per century both decrease.
10.4 ¦ COSMOLOGY
10.4.1 ¦ Overview of Friedmann, Robertson, and Walker Cosmology
Cosmology is the study of the large-scale structure of the universe—what it is like now,
what it was in the past, and what it will be in the future. Einstein's theory of general relativ-
relativity is the language used by cosmologists to describe the evolving universe. To understand
every facet of the universe is too hard, so assumptions are made so that the finer details do
not overshadow the relevant aspects of the large-scale structure of the universe. In particu-
particular, the standard cosmological models are based on the Cosmological principle. The Cos-
mological principle states that, on the average, the universe looks the same in all directions
and from any point. This leads to the requirement that space is homogeneous and isotropic
about each point. The universe is certainly not homogeneous on small scale where there
622 Chapter 10 Relativity and Cosmology
ate irregularities like stars, galaxies, and clusters of galaxies; however, on scales of a few
hundred million parsecs (Mpc) the homogeneity of space may be a good approximation.
We begin this discussion of cosmology with the assumptions that space is homoge-
homogeneous and isotropic. These assumptions offer a useful simplification and, hopefully, a good
approximation to the real universe. Homogeneous and isotropic models of spacetime fol-
follow from the work of Friedmann, Robertson, and Walker. In 1922, the Russian physicist
and mathematician, Alexander Friedmann A888-1925) constructed three models that were
consistent with general relativity, expanding space, and the Cosmological principle. In the
1930s Robertson and Walker extended Friedmann's work. These models are referred to
as Friedmann-Robertson-Walker (FRW) spacetimes. The line element for such a universe
can be written in the form
ds2 == dt2 - R[t]2
+ r2 sm[0\2dA
where R[t] is a function to be determined by the Einstein equations. This metric is called
the Friedmann-Robertson-Walker metric. The three types of models are distinguished by
their curvature, which is parameterized by k, called the signature. The signature k has
values +1, 0, and -1. These three models are called spherical (closed), Euclidean (flat),
and hyperbolic (open), respectively.
To formulate the geometry we assume that spacetime is filled with a fluid in which the
galaxies are the fundamental points of the fluid. The cosmic fluid is at rest in the comoving
coordinates so its contravariant four-velocity is V = {1,0,0,0}. Assume there is an ob-
observer with an ideal clock on each galaxy that moves with the mean flow of the matter. The
observer's clock measures the coordinate t, which plays the role of a cosmic time. Each
spacelike slice at t = constant is homogeneous. There are no privileged points or directions
about any point in the constant t slice.
The behavior of R[t] follows from solving Einstein's equations
where G is the gravitational constant and A is the cosmological constant. The conservation
of energy-momentum requires V1 = 0, where the symbol ; stands for the covariant
derivative:
We must now model the source term T>iY on the right-hand side of the field equations.
The majority of cosmological models assume that matter can be described as a perfect
fluid. The stress energy tensor for a perfect fluid is characterized by density and pressure,
both of which are only functions of time. The stress energy tensor for a perfect fluid is
10.4 Cosmology 623
where p and p are the mass density and pressure, respectively. The field equations reduce
to
R'[tf = -kc2 + ^KR(t)J + *G7t(R(t)Jp(t)
These are the two starting equations for most cosmological models. To get an explicit
model you need a relation between the pressure and density, i.e., an equation of state.
PROBLEM 1 Field Equations for Friedmann-Robertson-Walker Cosmology. Con-
Consider the Friedmann-Robertson-Walker metric defined by the diagonal metric
1
p.
0
0
0
R[t]
1 — kr2
0
0
0
0
0
0
0
¦ o
-r2/?^]2 sin[0]2
g =
Assume the model is described by the contravariant energy-momentum tensor
+ (p + p)WVy, where Vv = {1,0,0,0}.
a. Use the user-defined procedures given below under Remarks and Outline to calculate
the Christoffel symbol Tjjy, the curvature tensor R%s, and the Einstein tensor G^.
From the Einstein equations with cosmological constant G^v = SnGT^ + Xg^ show
that R [t] obeys the following two equations:
R[t]'2 = ! (-3* + AR[tf + SGnR[t]2p[t])
= -(A - \2GnP[t] - AGnp[t])
b. Assume that pressure and density are related by the equation of state P [ t ] = ap [ t ].
From the conservation of energy-momentum Tf = 0, show that
Ro \
where po and Ro are the current values.
c. Let a =0, which corresponds to a pressureless dust, and show that the equations for
R'[t]2 and R"[t] can be written as
624 Chapter 10 Relativity and Cosmology
Remarks and Outline The user-defined function to calculate the Christoffel symbol Tpr,
is
In [173]:= Christ [guv., var. : {t, r, 6, «}] : =
Module [ { tempi, imet},
tempi = Outer [D, sj/v, var] ;
imet = Inverse[guv]//Simplify;
1/2
(Transpose[imet.temple {1, 3, 2}] +
Transpose[imet.tempi, {1, 2, 3}] -
imet. Transpose [tempi, {3, 2, 1}] )
];
and the user-defined function to calculate the curvature tensor
_ ra -u ra T —
follows from
In[174]:= curvR[r_, var. : {t, r, e, «}] : =
Module [{tempi}/ tempi = Outer [D, r, var];
(Transpose [Outer [D, r, var],
{1,2,4,3}]-
Transpose [Outer [D, r, var] ,
{1,2,3,4}] +
Transpose [Inner [Times, r, r. Plus, 2] ,
{1,3,4,2}]-
Transpose[Inner[Times, r, r. Plus, 2],
{1,4,3,2}])
10.4 Cosmology 625
The Einstein tensor G is given by
In [175] : = einstein [curv_, gf/v_] : =
Module[{dem, tempi, temp2, i, j, s},
dem = Length [gf/v] ;
tempi=
Simplify[
ExpandAll[
Table[Sum[curv[[s, i, a, j]],
{s, dem}], {i,dem}, {j, dem}] ] ] ;
temp2=
Simplify[
ExpandAll[
Sum [ Inverse [ffMv] [[j, i] ]
curv[[s, i, a, j]]# {s, dem},
{i, dem}, {j,dem}]]];
Simplify[
ExpandAll[
Taile[tempi[[i,j]]-
(l/2)gf/v[[i, j]]temp2, {i,dem},
{3, dem}]]]]
Solution
In [176]:= Clear [ "Global * * " ] ;
a. The Friedmann-Robertson-Walker metric is
In [177J : = gj/v = DiagonalHatrix [
To derive Einstein's equations, first calculate the Christoffel symbol 1% and curvature
tensor Rpyg. The Christoffel symbols follow from the user-defined function Christ and
the curvature tensor follows from the user-defined function curvR:
In [178] : = r = Christ [gj/v] ;
In[179] := Ra^yS = curvR[r] //Simplify;
The Einstein tensor G^ follows from the user-defined procedure einstein:
In [180] := Gmv = einstein [Ra/3y5,
The only nonzero elements of the Einstein tensor are the diagonal components.
To get an expression for the stress-energy tensor, first define the contravariant V and
covariant VM four-velocities:
626 Chapter 10 Relativity and Cosmology
In[181] .- = vel = {1, 0, 0, 0}; (*Contravariant four-velocity*)
covel = s(/v.{l, 0, 0, 0}; (*Covariant four - velocity*)
The expression for the covariant stress-energy tensor T^ = -Pg v + (P+ pWMVy is
In[182] := T =
Table[(p[t] +P[t]) covel[[i]] covel[[j]]-
v + (P+ pWMVy
Simplify;
The four nontrivial Einstein equations with a cosmological constant follow from
In[183]:= (eql =
Hap [Flatten, Gj/v = = 8 7rGT + Ajjmv]//
Thread//
Select [#1, FreeQ[#, True]6]6 //
Simplify) //ColumnForm
3 (R'(tJ +k)
Out [183]= —X- j U=At8G^p(t)
-(A-8G;rP(t))R(tJ+2R"(t)R(t)+R'(tJ+k_
kr2 -1 " ""
r2 (A-BG^P(t)) R(tJ ==r2 (r' (t) 2 + k + 2 R(t) r" (t))
r2 Sin2 (9) ( - (A - 8 G7: P(t) ) R(t) 2 + 2 r" (t) R(t) + R' (t) 2 + k) ==0
Solving eql for R'[t]2 and R"[t], you get the desired solutions:
In [184]:= (f ieldeq =
Solve [eql/.R' [t] -> Sqrt [x],
{R" [t] , x}] [ [1] ] /.x -» R' [t] '2/.
Rule -> Equal//ExpandAll) //
ColumnForm
1 4
Out[184]= R (t) ==-AR(t)-4G;rP(t)R(t)--G7:p(t)R(t)
18
R'(tJ==-AR(tJ + -G7:p(t)R(tJ-k
b. Consider the equations that follow from the conservation equation r^ = 0. The
contravariant stress energy tensor is
In [185] : = conT =
Out [185] =
Tablet (p[t] +P[t]) vi
Inverse [jh/v] [ [i.
P(t)
0
0
0
0
(l-kr2) P(t)
R(tJ
0
0
»l[[i]] v.
3]]P[t],
0
0
P(t)
r2 R(tJ
0
»l[[j]]
{i.4}.
Csc2
r2
-
0
0
0
(9) P(t)
R(tJ
10.4 Cosmology 627
Next, create a user-defined function that will return the covariant derivative of a con-
travariant tensor of rank two, T.°f = ^ + I%,Tsfi + liyTaS:
In[1861:= coder [{2, u, U}, conT-, Christ., var_] : =
Outer [D, conT, var] +
Transpose[
Inner [Times, Christ, conT, Plus, 2],
{1,3,2}] +
Transpose[Inner[Times,Christ,
Transpose [conT, {2,1}], Plus, 2],
{2,3,1}]
When coder is applied to a contravariant tensor of rank two given by T^x =conT, it
returns its covariant derivative Tv . The Christoffel symbol is given by Christ and the
coordinates are given by var. Applying coder to conT, you get T\a :
In [187] := eq2 =
coder [{2, U, U}, conT, r, {t, r, 0, «}] //
Simplify ;
Summing over the last two indices, 7$°', it follows that
In [188] := eq3 = Table [Sum [eq2 [ [i, s, s] ] , {s, 1, 4}],
{i. 1. 4}]
Out[188]= {3(P
The conservation equations follow from setting the four equations in eq3 to zero. The
only nontrivial equation follows from the first element in the list:
In[189] := eq4 = eq3 [ [1] ] == 0
Out [1891= 3(P(tW(t))R'(t)+p,(t)==0
Consider the equation of state defined with the rule
In[190]:= eqstate= {P[t] -»otp[t]};
Using eqstate to eliminate the pressure in eq4 and solving for R [t], you can see that
In[191] := eq5 =
DSolve [{eq4/.eqstate, R[to] == Ro},
R[t],t] [[1,1]]/.
{p[to] -»po. Rule-» Equal}//Simplify//
PowerExpand
Out[191]= R(t) ==
628 Chapter 10 Relativity and Cosmology
If you solve eq5 forp [t], you get a rule for the behavior of p [t]:
In [192] := prule =
Solve[eq5,p[t]] [[1, 1] ]//PowerExpand//
Simplify
Out[192]= p{t) ^Ro3 (a+1) poR(t) <a+1)
c. Eliminating the pressure and p in the field equations and setting a to zero, you get
In[193]:= fieldeq/.prule/.eqstate/.a- >0//ExpandAll//ColumnForm
, 8G7:poRo3
R(t) ==-
PROBLEM 2 Zero-Pressure (Dust) Cosmological Models. The equations for zero-
pressure Friedmann-Robertson-Walker models can be written as
or
The parameters that are more directly related to observations are
1. the Hubble expansion rate, Ho = f^;
2. the dimensionless deceleration parameter, qo = -??
3. the dimensionless density parameter, cr = ^^
4. the dimensionless cosmological parameter, F =
where to is the current cosmic time.
a. Show that qo and k satisfy the following equations:
qo = -T + a- and k = -HoRo{\ - T - 2cr).
b. Derive an analytical expression for the cosmological age as a function of qo when
the cosmological parameter is zero. Plot the results.
c Consider models with a nonzero cosmological parameter and make a table of ages
for different values of cr and qo.
10.4 Cosmology 629
Remarks and Outline Relations for {qo# k} follow from evaluating the two field equa-
equations at t=0 and expressing the results in terms of {qo# Ho, cr, F}. The age of the model
follows from integrating ^ from R =0 (beginning) to R=Ro (now). The integration can
be analytically solved for the special case of zero cosmological constant. For the nonzero
cosmological constant, use NIntegrate to evaluate the ages.
Solution
In[194]:= Clear["Global* *"] ;
a. The field equations for zero-pressure and nonzero cosmological models are
In[195]:= eql = r" (t) ==^AR(t) -*°**° f°S
J 3R(t)
-_« _, ,^.2 8G7TPORO3
Define the Hubble constant Ho, deceleration parameter qo, dimensionless cosmological
parameter F, and dimensionless density cr with the rules:
In [196] := parameterrule =
JR(to) -> RO, R' (to) -> HoRO,
r" (to) -> -Ho2 qo Ro, po -> ,
4 G7T
A-»3HO2 r};
Relations for {qo#k} follow from evaluating the field equations at t=to. Evaluate
eql and eq2 at t=to and express the results in terms of {qo#Ho#cr#r}. The relations
for {qo# k} follow from the command Solve:
In[197] := qrule =
Solve [{eql, eq2}/.t -»to/.parameterrule,
{qo, k}] //Flatten//Simplify
Out [197]= (qo -» a- T, k ^ Ho2 Ro2 (r + 2a-l)|
b. The ages follow from eq2. Simplify the notation in eq2 by defining X [t] with the
rule
In[198] := chanse = {R'[t] ->X'[t] Ro, R[t] -»X[t] Ro};
The variable X [t ] is more convenient than R [t] because the present time occurs at X=l.
Expressing eq2 in terms of X, you get
In[199] := (eq2/. parameterrule/. qrule/. change//
Solve [#, X'[t]]s)
630 Chapter 10 Relativity and Cosmology
Out[199]= \\X' (t) -> -JrX(tJ Ho2 -THo2 -2 aHo2 + 2gHo + Ho2]
X(t) J
TX(tJHo2 -THo2 -2 aHo2 + 2aHo +Ho2}}
Pick the positive solution and factor Ho
In[200]:= eq3 =
{X' [t] ¦*
HO (l-r-2a+ Ba)/X[t] trx[t])"
A/2)}
Out[200]= |x'(t) ^Ho /rx(tJ -r-2atlt-^-j
I- \j X (t J J
The ages follow from integrating ^~ from X=0 (beginning) to X=l (now). If you set
Ho=l, then the time is in units of ^ (Hubble time units). The integration can be solved
analytically for the special case of zero cosmological constant. Setting F=0 and Ho=l and
integrating ^Wj from X=0 to X=l, the age in Hubble units follows from eq3:
In[201]:= integrand=
(l/X'[t]/.eq3/.{r-.0,Ho-.l/a-tqo} )
1
Out[201]=
where we used the fact that cr=qo when F=0. It follows from integrating that
In[202] := eq4 = Integrator, integrand, {X[t], 0, 1} ]//
Simplify
r 1 ao
Out [202]= If < 0 V —- >
L 2 - 4 qo 1 - 2 qo
- 4 qo 1 - 2 qo \ 1 - 2 qo J
OVImf q°
2qo-l
f tf=—(K(t)]
Jo J|722.-2qo + l J
The age follows from
In[203] := Clear[ageo]
10.4 Cosmology 631
In [204]:= aseo[ql_] := eq4 [ [2] ] /.qo -> ql//caiop;
ageo[l/2] =2/3; ageo[0.5] =2/3;
ageo[0] =1;
Beo[0.] =1;
The special ages for qo=l/2 and qo=0 are defined separately.
Display the results by plotting the age as a function of qo. The labels for the curves are
given by
In[205]:= label= {PointSize[0.03],
Point[{0.5,ageo[0.5]}].
Text [ StyleForm["k = 0, Flat",
FontFamlly- > "Times - Bold",
FontSize-> 10 ], {0.9, 0.67}],
Text [ StyleFoxm["k = 1, Closed",
FontFamily- > "Times - Bold",
FontSize -> 10 ] , {1.4, 0.58}],
Text[ StyleForm["k = -1, Qpen",
FontFamily- > "Times - Bold",
FontSize -> 10 ], {0.5, 0.82}]};
Define a plot function to graph the age for different values of the Hubble constant:
In [206] : = ageplot [Ho.] : =
Plot[ageo[qo] , {qo,0.00001,2},
Frame -» True, PlotLabel -» "Age for r = 0",
FrameLabel -> {0" - 29 gm/cc", " ",
"eo", ""},
FrameTicks ->
A/10
Round[
10 {{0, {1/2, 0.000196 Ho~2},
{1,2* 0.000196 Ho~2},
{1.5, 3* 0.000196 HO~2}},
{{0.5, 0.5*9.78* A00/Ho)},
{0.6, 0.6*9.78* A00/HO)},
{0.7, 0.7 * 9.78* A00/Ho)},
{0.8, 0.8*9.78* A00/Ho)},
{0.9, 0.9* 9.78* A00/Ho)},
{1,1*9.78* A00/Ho)}}} ]//N),
GridLines -»Automatic, Epilog -»label];
The labels were included with the option Epilog. The input Ho converts the time scale
to units of billions of years. Displaying the results for a particular choice of Ho, you get
In [207] .-= ageplot [70];
632
Chapter 10 Relativity and Cosmology
14.
12.6
11.2
9.8
8.4
7.
Age for T=0
1.9 2.9
w
\
Open
l k=0,Fl
at
^k=l, Cli
sed
"
14.
12.6
11.2
9.8
8.4
7.
1. 1.9 2.9
10A-29 gm/cc
c. Consider the cosmological age for models with nonzero F. The age can no longer
be expressed in terms of elementary functions, so you must numerically evaluate the ages
for different cr and qo. The age follows from integrating ^r^ from X=0 to X=l. Use
NIntegrate to evaluate the results that follow from eq3:
In [208]:= ajjeL [ql_, al_] : =
NIntegrate[
l/X'[t]/.eq3/.Ho-> l/.r-»a
qo->ql/.a->al/.X[t]
> x, {x, 0, 1}]
The age is a function of the deceleration parameter called ql and the dimensionless density
cr called crl.
Instead of just evaluating the age for one set of parameters, form a list of ages for
different decelerations and dimensionless densities. Also, convert the age from Hubble
units to billions of years. The table of age values for different Hubble constants follows
from agetable:
In[209]:= asetable[Ho_] : =
1/100
Round[
100Tablet 9.78* A00/Ho)
ageL[q, a] , {q, 0, 2, 0.5},
{a,0,2.5,0.5}]]//N;
Displaying the result with TableForm and a particular value of Ho, you get
In[210] := TableFoxm[agetable[70] , TableSpacing -» {1},
TableHeadings -*
{{"qo = 0", "qo = .5", "qo = 1", "qo = 1.5",
"qo = 2"}, {"ao = 0", ".5", ", .5",
",.5"}}]
10.4 Cosmology
Out [210] =
qo = 0
qo = .5
qo = 1
qo = 1. 5
qo = 2
¦
ao
13
12
10
10
9.
= 0
.97
.16
.97
.11
44
0.5
10.02
9.31
8.76
8.3
7.92
1
8.9
8.39
7.97
7.62
7.32
1.5
8.22
7.81
7.47
7.17
6.91
2
7.74
7.39
7.09
6.83
6.61
2.5
7.36
7.06
6.8
6.56
6.36
633
PROBLEM 3 The Expansion and Age for the Friedmann-Robertson-Walker Models.
The standard cosmological models are Friedmann-Robertson-Walker models with zero
pressure and zero cosmological parameter. The scale factor obeys the equation
where HoRo = -J _^2 o for k not zero.
a. Find the solution for R [t] and age for the model when k=0. Graph the results.
b. Find the solution for R [t] and age for the model when k=l. Graph the results.
c. Find the solution for R [t] and age for the model when k=-l. Graph the results.
Remarks and Outline The solution for R[t] follows from applying DSolve to the
scale factor equation. For k=l or -1, the solution is long. It is more transparent to change
the variables and define the solution in parametric form. The graphics follow from Plot
for the case k=0 and from ParametricPlot for the cases k=l and -1.
Solution
In[211]:= Clear["Global»*" ] ;
a. The equation for the scale factor R [t] when k=0 is
In [212] : = eql = R' (tJ = =
HO2 RO3
R(t)
A solution for t follows directly from integrating 1/R# [t] over R:
In [213]: = eq2 =
t == Intesrate [Sqrt [1/eql[ [2] ] ], R[t] ] //
PowerExpand
3 Ho Ro3/2
The age for the model follows from setting R [ t ] =R [ 0 ] in eq2:
ln[214]:= eq2 [ [2] ] AR[t] -> Ro
Out[214]= -^-
3 Ho
634
Chapter 10 Relativity and Cosmology
The expression for R [t] follows from solving eq2 for R [t]:
In[215]:= scaleO = Solve[eq2,R[t]][[2, 1]]/.
Rule -> Equal
/3\2/3
Out [215]= R(t) ==2 Ho2/3Rot2/3
Use Plot to graph R [t]:
In [216] := Plot [
Evaluate [scaleO[ [2]]/. {Ho -> 1, Ro-> 1}],
{t, 0, 1}, Frames True,
FrameTicks -»
{{{0,"},{1/3,"l/CHo)"},
{2/3, "Now"}, {1, "I/Ho"}},
{0, {1/2, "Ro/2"}, {1, "Ro"}}},
EpilojJ -»
Graphics[{PointSize[0.03],
Point [{2/3, !}]}][[!]]];
Ro/2
0 l/CHo) Now I/Ho
0
0 l/CHo) Now
Ro/2
I/Ho
b. Consider the closed model with k=l (qo>l/2). The equation for the scale factor
R[t] is
In[217] := eq3 = R'[t]~2 == -1 + 2 qoHo~2 Ro~3/(R[t]) ;
The value of Ro expressed in terms of qo for k=l, is
In [218] : = Rorule = Ro -> I/Ho Sqrt [ 1/B qo - 1) ] ;
Eliminating Ro in eq3, you get
In[219]:= eq4 = eq3/. Rorule//PowerExpand
2 2qo
Out [219]= R'(t)J = =
Ho Bqo-lK/2 R(t)
-1
A solution for t follows directly from eq4 by integrating 1/R# [t] over R [t]. How-
However, do not solve eq4 this way; the solution is simpler if you express R [ t ] in parametric
form. Define R in terms of the parameter x with the rule
10.4 Cosmology
In[220]:= change =
(Bqo/(HoBqo-l)-C/2))
Sin[x[#]]-2)&);
The parametric representation for R[x] is
In[221]:= scalel = R[x]/.change/.x[x] -> x//
PowerExpand
0ut[221]= 2q0Sin2(X3)/2
Ho Bqo-lK/2
An equation for x' [t] follows from using change to eliminate R in eq4:
In [222]:= eq5 =
Solve [eq4/.change, xf [t] ] [ [2] ] //
S implify//PowerExpand
Ho Bqo-lK/2 Csc2 (x(t)) i
635
Out [222]= x'(t)
4qo
The expression t [x] follows from integrating 1/x' [t] over x [t]:
In[223] := timel = Integrate[ A/x' [t]/.eq5),
{x[t],0,x}]
4 qo
Out[223]=
f -i SinBx)
Ho Bqo-l)J
The model starts at x=0 (t=0) and completes the cycle at the Big Crunch when x=tt
(R=0).
To find the age, first find the value of x when scalel=Ro:
In[224]:= xage =
Solve [ Ro = = scalel, x] [ [ 2 ] ] /. Rorule //
ExpandAll//PowerExpand
Out [224]= x->Sin~
V2 Jqo
where the positive solution was kept. When x=xage, you get the current values of R [x]
and t [x].
The age for the model follows from evaluating timel at xage:
In[225] := agel = timel/.xage//ExpandAll //Simplify
qo
Out [225]= --
Sin
2 Sin
- 2 Sin
Ho B qo - 1)J
636
Chapter 10 Relativity and Cosmology
Plot R [ t ] for the particular values of qo and Ho given by
In [226] : = value = {qo -> 1, Ho -> 1} ;
The plot for R follows from applying ParametricPlot to {t [x] ,R[x]}. Add to
these graphics a point for the current value of {t [x] ,R [x]} and a point at maximum
expansion. The graphics for these points along with the text are given by label:
In[227]:= label= {PointSize[0.03],
Text [ StyleFoxm [
1/100
Round[100 (timel/.xasre/.value ) ]//
N , FontFamlly- > "Times - Bold",
FontSize-* 10 ], {2.6, 1}],
Text [ StyleFoxm ["age/Bo = " ,
FontFamlly- > "Times - Bold",
FontSize -> 10 ], {1.4, 1}],
Point [ {timel/.x ->n/2/. value,
scalel/.x -> 7T/2Avalue}] ,
Point[{timel/.xage/.value,
scalel/.xage/.value}]};
Applying ParametricPlot to {timel, scalel}, you get the plot for the closed
model:
In[228]:= ParametricPlot[
Evaluate[{timel,scalel}/.value],
{x, 0, 7r}, Frame -» True,
PlotLabel -» "Closed Model, qo = 1 ",
FrameTicks -»
{{{0, "}, {asel/.value//N, "ajie"},
{3 agel/.value//N, * age"},
{timel/.value/.x-»7r/2, "Max"},
{9 asel/.value//N, "9* age"}},
{0,1/2, {1, "Ro"},1.5,2}},
Bpilog -» label];
2
1.5
Ro
1
2
0
0
/
/
0
age
>
/
/
age
Closed
3* age
/
;e/I
3*
Model,
Max
—• .
age
Max
qo=l
9*
\
\
9*
age
\
\
\
1
age
2
1.5
Ro
1
2
0
10.4 Cosmology 637
The time has been expressed in units of the current age, and the current age is expressed in
units of the Hubble age.
c. Consider the open model with k=-l (qo<l/2). The equation for the scale factor
R[t] is
In[229] := eq6 =R'[t]~2 == 1 + 2qoHo~2Ro~3/(R[t]) ;
For k=-l, the value of Ro expressed in terms of qo and Ho is
In [230] : = Rorule = Ro-> I/Ho Sqrt [1/A - 2 qo) ];
Eliminating R [ 0 ] in eq6, you get
In [231]:= eq7 = eq6/. Rorule//PowerExpand
Out [231]= R'(tJ ==
Ho A-2 qo)JA: R(t)
Solve eq7 in the same way that you solved for R [t] in part b. Express R in terms of
the parameter x:
In[232]:= chanse =
(Bqo/(Ho(l-2qo)-C/2))
Sinh[x[#]]-2)&);
The parametric representation for R[x] is
In[233]:= scale2 = R[x] /.chanse/.x[x] -> x//
PowerExpand
Out[233]= 2q°Sinh2(^
Ho (l-2qoK/2
Next, change variables in eq7 and get an equation for x# [t]:
In[234]:= eq8 =
Solve [eq7/.chanBe, x- [t] ] [ [2] ] //
Simplify//PowerExpand
Out[234]= |x' (t) -> °
4 qo J
The expression for t [x] follows from integrating l/x# [t] over x [t]:
In[235] := time2 = Integrate [ A/x' [t] /.eq8) ,
{x[t],0,x}]
4qo |i SinhBx) -f
Out [235] =
Ho A -2 qo)'
638
Chapter 10 Relativity and Cosmology
The parametric expression for t is given by time2 and the parametric expression for R
follows from scale2. The model starts at x=0 (t=0), evolves to the present R [x] =Ro,
and then keeps expanding.
To find the age, first find the value of x when scale2=Ro
In[236] : = xajje =
Solve [Ro == scale2, x] [ [2] ] /.Rorule//
PowerExpand//Simplify
Out [23 6]=
qo
where the positive solution was kept. The age for the model follows from
In[237] .- = age2 = time2/.xage
4 qo
Out [237] =
7 Sinh
2 Sinh"
Ho A -2qo)J/^
Plot R [ t ] for the particular values of qo and Ho given by
In[238] := value = {qo-> 0.02, Ho -> 1};
The plot for R follows from applying ParametricPlot to {t [x] #R[x]}. Add to
these graphics a point for the current value of {t [x], R [x]}. The graphics for this point
along with the text are given by label:
In[239]:= label= {PointSize[0.03],
Text[ StyleFoxm["age/Ho = " ,
FontFamily- > "Times - Bold",
FontSize -> 10 ] ,
{1.5 time2/.xage/.value,
scale2/.xage/.value}],
Text [ StyleFoxm [
1/100
Round[100(time2/.xasje/.value ) ]//
N , FontFamily- > "Times - Bold",
FontSize -* 10 ] ,
{1.9 time2/.xage/.value,
scale2/.xage/.value}],
Point [ {time2/.xajje/. value,
scale2/.xage/.value}]};
Applying ParametricPlot to {time2,scale2}, you get the plot for the open
model:
10.5 Exercises
639
In[240]:= ParametricPlot[
Evaluate[{time2 , scale2}/.value],
{x, 0, 3}, Frame -> True,
PlotLabel -> "QpenModel, qo = .02",
FrameTicks -»
{{{0, " 0"}, {0.5asel/.value//N,
"ase/2"}, {asel/.value//N, "ase
{2asel/.value//N, n2ase"},
{3/2agel/.value//N, /2 ase"}},
{0,1/2, {1, "Ro"), 1.5,2}},
Bpilog ->label];
2
1.5
Ro
1
2
0
0
Open
age/2
Model, qo=.02
age 3/2 age 2age
jr age/Bo = 0.94
2
1.5
Ro
1_
2
0 age/2 age 3/2 age 2age
The time has been expressed in units of the current age, which is expressed in units of the
Hubble age.
10.5 ¦ EXERCISES
The solutions to many of these exercises can be found on our web sites.
10.1 Lorentz Boosts
(a) Show that two successive Lorentz boosts in the same direction are equivalent to a single
Lorentz boost. Find the formula for the addition of velocities that follows from the product
of two Lorentz boosts.
(b) The electromagnetic three-vector fields E and B are elements of a second-rank contravari-
ant tensor F'K In frame X, the second-rank tensor is defined as
F" =
0 -Ex -I
? 0 -I
0 -fi,
fi 0
In a boosted reference frame, the three-vector fields are E' and B'. Find the relation be-
between the electric and magnetic fields in frames Z and ?'.
640 Chapter 10 Relativity and Cosmology
10.2 Radioactive Decay of Moving Nucleus
Consider a radioactive nucleus moving relative to the laboratory with a constant speed v. The
nucleus decays and emits an electron with a speed v in a direction perpendicular to the motion
as determined by an observer at rest with respect to the nucleus. Find the velocity and the
direction of motion for the electron as measured by an observer in the laboratory frame.
10.3 Schwarzschild Solution
Consider spherical coordinates {t, r,ft (f>) and assume the metric is diagonal with components
given by {g^lr], gu[r], -r2, -r^sinlfP}. Set the components of the Ricci tensor R^ to zero and
solve for the metric components. Assume the boundary condition g^lr]- > 1 - ^f as r goes
to infinity.
10.4 Potential Analysis for Timelike Geodesies
Consider the Schwarzschild metric and illustrate the different kinds of timelike geodesies by
doing a potential analysis. There are sufficient symmetries that you do not have to use the
geodesic equations. Assume the orbits are confined to the plane 6 = n/2.
(a) If the effective potential V is defined by the equation r'ls]2 = (En2 - 1) - V, show that
V = - 2sU^+sL--2s.. The first term is the relativistic correction, the second is the centrifugal
barrier, and the third is the gravity potential.
(b) Show that the potential has two extrema if el2 > Ylm2. Graph the three parts of the effective
potential for el2 > Ylm2. Also graph the effective potential for the three cases, el2 > Ylm2,
el2 = Urn2, and el2 < Ylm2.
10.5 Schwarzschild Solution in Null Coordinates
Consider a spherically symmetric metric expressed in null coordinates {fi, r, 0, <f>}. The metric
is nondiagonal and is of the form
?OOW -10 0
-10 0 0
0 0 -t2 0
0 0 0 -
Find the solution of Einstein's vacuum equations with the boundary conditions that g^ [r]
->1 - 2js as r goes to infinity.
10.6 Null Geodesies for the Schwarzschild Metric
Consider null geodesies for the Schwarzschild metric. Assume the orbit is in the 6 = \ plane.
Find the effective potential and describe the different kinds of paths. Plot the results.
10.7 Mercury's Anomalous Precession and Modification of Newton's Gravity
Consider Newtonian motion and assume a small perturbation about a circular orbit. Calculate
the perihelion shifts for the two potentials V=--^y andv=--^. If the precession of Mercury
is +43 sec of arc/century, which potential is correct and what is the value of 6 needed to ex-
explain Mercury's precession? Using the value of 6 established from Mercury's orbit, what is the
predicted value of the perihelion shift for Venus and Earth? How does this compare with the
observed values for Venus = 8.4 ± 4.8" per century and for Earth = 5.0 ± 1.2" per century?
10.8 Cosmological Force and Mercury
The potential for a Newtonian orbit in a gravitational field with a cosmological force is V =
GM r2*
10.5 Exercises 641
(a) Show that the orbit equation for u=l/r is u + u" = ^ - ^j, where u is a function of
<f> and h is the conserved angular momentum. The orbit was assumed to be in the 6 = \
plane.
(b) Show that the perihelion shift caused by the cosmological term is
(c) What is the value of A needed to produce a precession for Mercury of one second of arc
per century?
Index
:>, 11
?, 15
$DisplayFunction, 49,
56
&, 5
Abs, 6, 295
animate, 34, 106
animation, 34,106,179, 334,
536
Apart, 8
Attributes, 15
BesselJ, 14, 39,559,566
BesselY, 560, 565
boost, 580
boost along the x axis, 589
boostx, 589
canonical momentum, 345, 353,
361
canonical transformations, 365
Cartesian, 107, 468, 550
center-of-mass frame, 378, 584
Christ, 601, 625
Christoffel symbols, 598, 603, 623
CoefficientList,490
Collect, 48
complex conjugate, 10, 589
rule, 10
Conjugate, 6, 581
conjugate, 10
conjugateRule, 10
Context, 25
ContourPlot, 100, 140, 202,
234,312,441,448
Contours,202
Convert, 46
CoordinatesToCartesian,
24,105, 372, 380,446
covariant equations, 580
Curl, 107-109
curvature tensor, 603, 625
curvR, 603, 625
Cylindrical, 110
CylindricalPlot3D, 37, 483,
487, 504
Dashing, 31, 562,593
DensityPlot,296
derivative, 27
differential equation, 29
dif fSeriesOne, 137, 384
dimensionless cosmological
parameter, 628
dimensionless deceleration, 628
dimensionless density, 628
dipole, 102
DisplayFunction49, 196
Do, 106, 171
Doppler shift, 589
dot product, 381
double pendulum, 175
doublePlot, 131, 147,156
DSolve, 29,48,45,134, 145,
151,185, 545, 557
Duffing equation, 232
eigenfrequency, 166,175
Eigensystem, 159, 181
Eigenvalues, 159, 181
eigenvalues, 158
eigenvalues and eigenvectors for
small oscillating systems,
158
eigenvector, 166, 175
Eigenvectors, 159, 181
einstein, 604, 625
Einstein tensor, 598, 604
electric field, 94, 106, 435,
495
electric field lines, 455, 489,
496
electric potential, 94
Eliminate, 12,590
Epilog, 49, 54, 136, 149,189,
548,631
equilibrium, 130
equipotential, 437
equipotential lines, 102, 452, 489,
496
Evaluate, 31,486
Expand, 7
Factor, 6
FilledPlot, 141
FindMinimum, 454
FindRoot, 40,519, 526, 536,
568
firstDiffSeries, 348
f irstOrderPert, 348, 388
Flatten, 29,48, 116,526
flux, 532, 540
flux, 532, 540
Fontform, 57
Foucault pendulum, 85-93
four-vector, 126, 581
Fourier spectrum, 209
of one-dimensional oscillating
system, 185
643
644
Index
Fourier Transform, 185,187
fractals, 259, 291
Frame, 34, 586
FreeQ, 18
FullForm, 10
Function, 30, 50
Galilean transformation, 578-579
Gauss's Law, 94
Gaussianlntegers,7
general relativity, 597
generalized coordinates, 299
generalized Doppler formula, 589
generalized force, 299
generalized momentum, 344
generalized Snell's law, 588
geodesic, 598, 607, 608
geodesic, 607, 608
geodesic equations, 598, 608
Global", 26
Grad, 95,448,458
Graphics, 23, 25, 316
Graphics'PlotField', 35
Graphics'PlotField3Dv
ScaleFunction, 36
Graph icsArray, 76, 528, 563
Gridlines, 118
Hamilton, 344, 367
Hamilton's canonical equations,
344
Hamilton's characteristic
functions, 372
Hamilton's equations, 344, 357,
365
Hamilton's principal function, 365
Hamilton-Jacobi, 365-367
Hamilton-Jacobi equations, 366
hamiltonian, 308, 361
Hamiltonian, 398
HamiltonJacobi, 366, 372
harmonic oscillator, 131,150,191,
346, 367,545
Hermite polynomials, 545
Hermite solution, 546
HermiteH, 39, 546, 552
holonomic, 299
Hubble expansion rate, 628
Hue, 33
HypergeometriclFl, 546,
552
HypergeometricU, 573
Identity, 49
Im, 6
Integrate, 28, 95,473
integrate, 28
InterpolatingFunction,
30, 240
InverseLaplaceTransform,
137
Join, 84
Julia set, 291, 292, 294
Killing equation, 599
killingEq, 600
laboratory frame, 583,588
Lag, 335
Lagrange multipliers, 299, 355
Lagrange's equations, 299, 335
Lagrangian, 298, 323
LaguerreL, 39, 573
Laplace transforms, 135
Laplace's equation, 435, 467, 488
LaplaceTransf orm, 134, 149,
187
Laplacian, 457, 468
Legendre polynomials, 439,488,
499, 508
Legendre solution, 508
LegendreP, 39, 465, 554, 557
Limit, 54, 115
limit, 84
ListPlot, 22, 32, 48, 171, 261
LogicalExpand, 496
LogicExpand, 496
Lorentz transformations, 579, 589
magnetic vector potential, 107
Mandelbrot set, 291, 292
Map, 48, 276,469
metric, 580
Mod, 19
Module, 20, 41, 138,180
Monopole, 438,441,452
monopole, 103
MultipoleP, 459,460
MultipoleSH,459
NDSolve, 30, 87, 211, 241, 314,
400
Needs, 24
Newton's second law, 44, 67, 78,
94
Newtonian motion, 45
non-inertial frame of reference, 77
nonholonomic, 299, 335,355
nonlinear pendulum, 195
normal modes, 157
NSolve, 21
numOrbit,395
Options, 57
oscillations, 130,157,183
oscMovie, 242
Outer, 75,181, 624
Packages, 23
parabolic coordinates, 376
ParametricPlot, 67, 69, 132,
163, 213, 633
ParametricPlot3D, 82, 84,
111,132,451
perturbative solution, 421
phase diagram, 140, 196, 234
phase plane, 140
phase plot, 132
for one-dimensional system,
132
and time evolution for a
one-dimensional system,
132
phase trajectories, 195, 241, 321,
331
phasePlot, 131,132,156
Plot, 32,48, 80, 93,163, 235,
518
Plot3D, 151, 235, 489, 534, 542
PlotGradientField,100
PlotGradientField3D, 101,
436
PlotRange, 155
PlotStyle, 32
PlotVectorf ield, 35,148,
211,217,243
Index
645
PlotVectorField3D, 112
Point, 56, 80,115
PointSize, 22
PolarPlot, 384, 386, 393
potential diagrams, 130,140, 234,
311,348
PowerExpand, 9, 6, 95,454,489
Protect,134
pseudo-Euclidean metric, 580, 597
pure forms, 29
pure functions, 17, 29
Quantum mechanics, 513
Random, 11,41
Re, 6, 570
Reduce, 12,14, 161,196, 516
reflection, 542
Ricci scalar, 598
Ricci tensor, 598
Riemann metrics, 598
Robertson-Walker metric, 621
Roots, 12
rotating coordinate
system, 77
Rule->Equal, 68
scalar potential, 45
ScaleFunction, 36, 104,
459
schrod, 516
Schrodinger's equation, 514
Schwarzschild metric, 602, 607,
615
Select, 18,122, 605
Series, 54, 70,452
series expansion for second-order
equation, 70
series expansion solution for
second-order equation,
137
SetCoordinates, 469,
550
shadowing, 26
ShadowPlot3D, 140
Show, 57, 83
Sign, 64
Simplify, 6
small oscillations, 157
smallOsc, 158,159, 162,166,
172, 179
Snell's law, 175-179, 588
Solve, 12,46, 587
Spherical, 492
spherical harmonics, 439
SphericalHarmonicY, 38,
558
SphericalPlot3D, 38
stress-energy tensor, 622
Sum, 137
superposition of point charges,
440
Table, 41, 70,115, 181, 517, 560
TableForm, 73, 117, 561, 569,
606,632
TableHeadings, 517, 527, 560
TableSpacing, 569, 606, 632
Text, 57, 59, 98, 524, 614
Thickness, 82
Thread, 23, 25, 81, 88,492
three coupled harmonic
oscillators, 165,171
timePhasePlot, 131,151, 156
Timing, 20,131
Together, 6
transmission, 538
Transpose, 603, 624
TrigFactor, 8
TrigToP, 438^40,446
TrigToY,438
two postulates for special
relativity, 578
Union, 262
user-defined metric, boost, and
velocity parameters, 599
van der Pole equation, 255
van der Pole oscillator, 255
vChange, 557
VectorQ, 381
VEPlot, 436,444,451,456,465,
496
ViewPlot, 104