




























































































Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Prepare-se para as provas
Estude fácil! Tem muito documento disponível na Docsity
Prepare-se para as provas com trabalhos de outros alunos como você, aqui na Docsity
Encontra documentos específicos para os exames da tua universidade
Prepare-se com as videoaulas e exercícios resolvidos criados a partir da grade da sua Universidade
Responda perguntas de provas passadas e avalie sua preparação.
Ganhe pontos para baixar
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Aplicações do Mathematica para Engenheiros e Cientistas
Tipologia: Notas de estudo
1 / 647
Esta página não é visível na pré-visualização
Não perca as partes importantes!





























































































Cover Image: Breaking wave, theory and experiment photograph by Rob Keith.
Copyright 2003 by John Wiley & Sons, Inc. All rights reserved.
Published by John Wiley & Sons, Inc., Hoboken, New Jersey. Published simultaneously in Canada.
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, scanning or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400, fax 978-750-4470, or on the web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, Ž^201. 748-6011, fax Ž^201. 748-6008, e-mail: [email protected].
Limit of LiabilityrDisclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.
For general information on our other products and services please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993 or fax 317-572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print, however, may not be available in electronic format.
Library of Congress Cataloging-in-Publication Data is a © ailable.
ISBN 0-471-26610-
Printed in the United States of America
10 9 8 7 6 5 4 3 2 1
CONTENTS ix
6.2 Grid Methods r 464 6.2.1 Time-Dependent Problems r 464 6.2.2 Boundary-Value Problems r 486 Exercises for Sec. 6.2 r 504 6.3 Numerical Eigenmode Methods (^ Electronic Version Only) 6.3.1 Introduction 6.3.2 Grid-Method Eigenmodes 6.3.3 Galerkin-Method Eigenmodes 6.3.4 WKB Eigenmodes Exercises for Sec. 6. References r 510
7 NONLINEAR PARTIAL DIFFERENTIAL EQUATIONS 511
7.1 The Method of Characteristics for First-Order PDEs r 511 7.1.1 Characteristics r 511 7.1.2 Linear Cases r 513 7.1.3 Nonlinear Waves r 529 Exercises for Sec. 7.1 r 534 7.2 The KdV Equation r 536 7.2.1 Shallow-Water Waves with Dispersion r 536 7.2.2 Steady Solutions: Cnoidal Waves and Solitons r 537 7.2.3 Time-Dependent Solutions: The Galerkin Method r 546 7.2.4 Shock Waves: Burgers’ Equation r 554 Exercises for Sec. 7.2 r 560 7.3 The Particle-in-Cell Method (^ Electronic Version Only) 7.3.1 Galactic Dynamics 7.3.2 Strategy of the PIC Method 7.3.3 Leapfrog Method 7.3.4 Force 7.3.5 Examples Exercises for Sec. 7. References r 566
8 INTRODUCTION TO RANDOM PROCESSES 567
8.1 Random Walks r 567 8.1.1 Introduction r 567 8.1.2 The Statistics of Random Walks r 568 Exercises for Sec. 8.1 r 586 8.2 Thermal Equilibrium r 592 8.2.1 Random Walks with Arbitrary Steps r 592
x CONTENTS
8.2.2 Simulations r 598 8.2.3 Thermal Equilibrium r 605 Exercises for Sec. 8.2 r 609 8.3 The Rosenbluth-Teller-Metropolis Monte Carlo Method (Electronic Version Only) 8.3.1 Theory 8.3.2 Simulations Exercises for Sec. 8. References r 615
9 AN INTRODUCTION TO MATHEMATICA (ELECTRONIC VERSION ONLY) 9.1 Starting Mathematica 9.2 Mathematica Calculations 9.2.1 Arithmetic 9.2.2 Exact ® s. Approximate Results 9.2.3 Some Intrinsic Functions 9.2.4 Special Numbers 9.2.5 Complex Arithmetic 9.2.6 The Function N and Arbitrary-Precision Numbers Exercises for Sec. 9. 9.3 The Mathematica Front End and Kernel 9.4 Using Pre ® ious Results 9.4.1 The % Symbol 9.4.2 Variables 9.4.3 Pallets and Keyboard Equi ® alents 9.5 Lists, Vectors, and Matrices 9.5.1 Defining Lists, Vectors, and Matrices 9.5.2 Vectors and Matrix Operations 9.5.3 Creating Lists, Vectors, and Matrices with the Table Command 9.5.4 Operations on Lists Exercises for Sec. 9. 9.6 Plotting Results 9.6.1 The Plot Command 9.6.2 The Show Command 9.6.3 Plotting Se ® eral Cur ® es on the Same Graph 9.6.4 The ListPlot Function 9.6.5 Parametric Plots 9.6.6 3D Plots 9.6.7 Animations
PREFACE
Up to this point in your career you have been asked to use mathematics to solve rather elementary problems in the physical sciences. However, when you graduate and become a working scientist or engineer you will often be confronted with complex real-world problems. Understanding the material in this book is a first step toward developing the mathematical tools that you will need to solve such problems. Much of the work detailed in the following chapters requires standard pencil- and-paper Ž^ i.e., analytical. methods. These methods include solution techniques for the partial differential equations of mathematical physics such as Poisson’s equation, the wave equation, and Schrodinger’s equation,¨ Fourier series and transforms, and elementary probability theory and statistical methods. These methods are taught from the standpoint of a working scientist, not a mathemati- cian. This means that in many cases, important theorems will be stated, not proved Ž (^) although the ideas behind the proofs will usually be discussed. Physical intuition. will be called upon more often than mathematical rigor. Mastery of analytical techniques has always been and probably always will be of fundamental importance to a student’s scientific education. However, of increasing importance in today’s world are numerical methods. The numerical methods taught in this book will allow you to solve problems that cannot be solved analytically, and will also allow you to inspect the solutions to your problems using plots, animations, and even sounds, gaining intuition that is sometimes difficult to extract from dry algebra. In an attempt to present these numerical methods in the most straightforward manner possible, this book employs the software package Mathematica. There are many other computational environments that we could have used insteadfor example, software packages such as Matlab or Maple have similar graphical and numerical capabilities to Mathematica. Once the principles of one such package
xiii
xiv PREFACE
are learned, it is relatively easy to master the other packages. I chose Mathematica for this book because, in my opinion, it is the most flexible and sophisticated of such packages. Another approach to learning numerical methods might be to write your own programs from scratch, using a language such as C or Fortran. This is an excellent way to learn the elements of numerical analysis, and eventually in your scientific careers you will probably be required to program in one or another of these languages. However, Mathematica provides us with a computational environment where it is much easier to quickly learn the ideas behind the various numerical methods, without the additional baggage of learning an operating system, mathe- matical and graphical libraries, or the complexities of the computer language itself. An important feature of Mathematica is its ability to perform analytical calcula- tions, such as the analytical solution of linear and nonlinear equations, integrals and derivatives, and Fourier transforms. You will find that these features can help to free you from the tedium of performing complicated algebra by hand, just as your calculator has freed you from having to do long division. However, as with everything else in life, using Mathematica presents us with certain trade-offs. For instance, in part because it has been developed to provide a straightforward interface to the user, Mathematica is not suited for truly large-scale computations such as large molecular dynamics simulations with 1000 particles or more, or inversions of 100,000-by-100,000 matrices, for example. Such appli- cations require a stripped-down precompiled code, running on a mainframe computer. Nevertheless, for the sort of introductory numerical problems covered in this book, the speed of Mathematica on a PC platform is more than sufficient. Once these numerical techniques have been learned using Mathematica , it should be relatively easy to transfer your new skills to a mainframe computing environment. I should note here that this limitation does not affect the usefulness of Mathematica in the solution of the sort of small to intermediate-scale problems that working scientists often confront from day to day. In my own experience, hardly a day goes by when I do not fire up Mathematica to evaluate an integral or plot a function. For more than a decade now I have found this program to be truly useful, and I hope and expect that you will as well. ŽNo, I am not receiving any kickbacks from Stephen Wolfram!^. There is another limitation to Mathematica. You will find that although Mathe - matica knows a lot of tricks, it is still a dumb program in the sense that it requires precise input from the user. A missing bracket or semicolon often will result in long paroxysms of error statements and less often will result in a dangerous lack of error messages and a subsequent incorrect answer. It is still true for this Žor for any other software^. package that garbage in s garbage out. Science fiction movies involving intelligent computers aside, this aphorism will probably hold for the foreseeable future. This means that, at least at first, you will spend a good fraction of your time cursing the computer screen. My advice is to get used to itthis is a process that you will go through over and over again as you use computers in your career. I guarantee that you will find it very satisfying when, after a long debugging session, you finally get the output you wanted. Eventually, with practice, you will become Mathematica masters.
xvi PREFACE
tion of the notebook under the Format entry of the main menu Žchoose Magnifi - cation^. , or by choosing a magnification setting from the small window at the bottom left side of the notebook. A number of individuals made important contributions to this project: Professor Tom O’Neil, who originally suggested that the electronic version should be written in Mathematica notebook format; Professor C. Fred Driscoll, who invented some of the problems on sound and hearing; Jo Ann Christina, who helped with the proofreading and indexing; and Dr. Jay Albert, who actually waded through the entire manuscript, found many errors and typos, and helped clear up fuzzy thinking in several places. Finally, to the many students who have passed through my computational physics classes here at UCSD: You have been subjected to two experimentsa Mathematica -based course that combines analytical and computa- tional methods; and a book that allows the reader to interactively explore varia- tions in the examples. Although you were beset by many vicissitudes Žcrashing computers, balky code, debugging sessions stretching into the wee hours^. your interest, energy, and good humor were unflagging Ž^ for the most part!. and a constant source of inspiration. Thank you.
DANIEL DUBIN
La Jolla, California March, 2003
CHAPTER 1
ORDINARY DIFFERENTIAL EQUATIONS
IN THE PHYSICAL SCIENCES
1.1.1 Definitions
Differential Equations, Unknown Functions, and Initial Conditions Three centuries ago, the great British mathematician, scientist, and curmudgeon Sir Isaac Newton and the German mathematician Gottfried von Liebniz independently introduced the world to calculus, and in so doing ushered in the modern scientific era. It has since been established in countless experiments that natural phenomena of all kinds can be described, often in exquisite detail, by the solutions to differential equations. Differential equations involve derivatives of an unknown function or functions, whose form we try to determine through solution of the equations. For example, consider the motion Ž^ in one dimension. of a point particle of mass m under the action of a prescribed time-dependent force F t^ Ž.^. The particle’s velocity ®Ž. t satisfies Newton’s second law
d ® m s F (^) Ž. t (^). (^) Ž 1.1.1. dt
This is a differential equation for the unknown function ®^ Ž. t. Equation Ž^ 1.1.1. is probably the simplest differential equation that one can write down. It can be solved by applying the fundamental theorem of calculus : for any function f t^ Ž.^ whose derivative exists and is integrable on the interval w^ a , b x ,
b (^) df H (^) dtdt s^ f^ Ž^ b^.^ y^ f^ Ž^ a^.^.^ Ž^ 1.1.2. a
1
Numerical and Analytical Methods for Scientists and Engineers, Using Mathematica. Daniel Dubin Copyright 2003 John Wiley & Sons, Inc. ISBN: 0-471-26610-
1.1 INTRODUCTION 3
can be determined by two initial conditions, on the initial position and velocity:
x (^) Ž 0. s x (^) 0 , ® (^) Ž 0. s ® 0. (^) Ž 1.1.8.
Since Eq. Ž^ 1.1.7. implies that x Ž. 0 s C (^) 1 and x Ž. 0 s ®Ž. 0 s 0 C (^) 2 , the solution can be written directly in terms of the initial conditions as
x Ž. t s x (^) 0 cosŽ 0 t. q (^) sinŽ 0 t.. Ž 1.1.9. 0
We can easily verify that this solution satisfies the differential equation by substituting it into Eq. Ž^ 1.1.6 :.
Cell 1.
x[t_____] = x0 Cos[ (^) 0 t] + v0/ (^) 0 Sin[ (^) 0 t]; Simplify[x"[t] == - (^) 0 ^^^^^2 x[t]]
True
We can also verify that the solution matches the initial conditions:
Cell 1.
x[0] x
Cell 1.
x'''''[0] v
Order of a Differential Equation The order of a differential equation is the order of the highest derivative of the unknown function that appears in the equation. Since only a first derivative of ®^ Ž. t^ appears in Eq. Ž^ 1.1.1 , the equation is. a first - order differential equation for ®^ Ž. t^. On the other hand, Equation Ž^ 1.1.6. is a second - order differential equation. Note that the general solution Ž^ 1.1.3. of the first-order equation Ž^ 1.1.1. involved one undetermined constant, but for the second-order equation, two undetermined constants were required in Eq. Ž^ 1.1.7. It’s easy to see why this must be so. an N th-order differential equation involves the N th derivative of the unknown function. To determine this function one needs to integrate the equation N times, giving N constants of integration.
The number of undetermined constants that enter the general solution of an ordinary differential equation equals the order of the equation.
4 ORDINARY DIFFERENTIAL EQUATIONS IN THE PHYSICAL SCIENCES
Partial Differential Equations This statement applies only to ordinary differen- tial equations Ž^ ODEs , which are differential equations for which derivatives of the. unknown function are taken with respect to only a single variable. However, this book will also consider partial differential equations Ž^ PDEs , which involve deriva-. tives of the unknown functions with respect to se ® eral variables. One example of a PDE is Poisson’s equation, relating the electrostatic potential Ž^ x , y , z .to the charge density Ž^ x , y , z. of a distribution of charges:
2 ^ Ž^ x ,^ y ,^ z. Ž x , y , z. s y (^) . Ž 1.1.10. 0
Here 0 is a constant Žthe dielectric permittivity of free space, given by 0 s 8.85... 10 y 12 Frm , and.^ 2 is the Laplacian operator ,
s 2 q 2 q 2. Ž 1.1.11. x y z
We will find that ^2 appears frequently in the equations of mathematical physics. Like ODEs, PDEs must be supplemented with extra conditions in order to obtain a specific solution. However, the form of these conditions become more complex than for ODEs. In the case of Poisson’s equation, boundary conditions must be specified over one or more surfaces that bound the volume within which the solution for ^ Ž x , y , z .is determined. A discussion of solutions to Poisson’s equation and other PDEs of mathematical physics can be found in Chapter 3 and later chapters. For now we will confine ourselves to ODEs. Many of the techniques used to solve ODEs can also be applied to PDEs.
An ODE involves derivatives of the unknown function with respect to only a single variable. A PDE involves derivatives of the unknown function with respect to more than one variable.
Initial-Value and Boundary-Value Problems Even if we limit discussion to ODEs, there is still an important distinction to be made, between initial - ® alue problems and boundary - ® alue problems. In initial-value problems, the unknown function is required in some time domain t 0 and all conditions to specify the solution are given at one end of this domain, at t s 0. Equations Ž^ 1.1.3. and Ž^ 1.1.9. are solutions of initial-value problems. However, in boundary-value problems, conditions that specify the solution are given at different times or places. Examples of boundary-value problems in ODEs may be found in Sec. 1.5. ŽProblems involving PDEs are often boundary-value problems; Poisson’s equation Ž^ 1.1.10. is an example. In Chapter 3 we will find that some PDEs involving both time and space derivatives are solved as both boundary- and initial-value problems.^.
6 ORDINARY DIFFERENTIAL EQUATIONS IN THE PHYSICAL SCIENCES
Theorem 1.1 Consider a general initial-value problem involving an N th-order ODE of the form
d N^ x dx d^2 x d N y^1 x
dt dt dt
for some function f. The ODE is supplemented by N initial conditions on x and its derivatives of order N y 1 and lower:
dx d^2 x d N y^1 x (^) Ž 0. s x (^) 0 , s ® 0 , 2 s a (^) 0 ,... , (^) N y 1 s u (^) 0. dt (^) dt dt
Then, if the derivative of f in each of its arguments is continuous over some domain encompassing this initial condition, the solution to this problem exists and is unique for some length of time around the initial time.
Now, we are not going to give the proof to this theorem. ŽSee, for instance, Boyce and Diprima for an accessible discussion of the proof.^. But trying to understand it qualitatively is useful. To do so, let’s consider a simple example of Eq. Ž^ 1.2.1 : the first-order ODE.
d ® s f (^) Ž t , ® (^).. (^) Ž 1.2.2. dt
This equation can be thought of as Newton’s second law for motion in one dimension due to a force that depends on both velocity and time. Let’s consider a graphical depiction of Eq. Ž^ 1.2.2.^ in the Ž^ t , ®. plane. At every point Ž^ t , ®. , the function f t Ž^ , ®. specifies the slope d ®r dt of the solution ®Ž. t. An example of one such solution is given in Fig. 1.1. At each point along the curve, the slope d ®r dt is determined through Eq. Ž^ 1.2.2. by f t Ž^ , ® .. This slope is, geometri- cally speaking, an infinitesimal vector that is tangent to the curve at each of its points. A schematic representation of three of these infinitesimal vectors is shown in the figure. The components of these vectors are
d ®
The vectors dt^ Ž^ 1, f t Ž^ , ®.. form a type of ® ector field Ža set of vectors, each member of which is associated with a separate point in some spatial domain^. called a direction field. This field specifies the direction of the solutions at all points in the
Fig. 1.1 A solution to d ®r dt s f t^ Ž^ , ®..
1.2 GRAPHICAL SOLUTION OF INITIAL-VALUE PROBLEMS 7
Fig. 1.2 Direction field for d ®r dt s t y ®, along with four solutions.
Ž (^) t , ®. plane: every solution to Eq. Ž (^) 1.2.2. for every initial condition must be a curve that runs tangent to the direction field. Individual vectors in the direction field are called tangent ® ectors. By drawing these tangent vectors at a grid of points in the Ž^ t , ®. plane Žnot infinitesimal vectors, of course; we will take dt to be finite so that we can see the vectors , we get an overall qualitative picture of solutions to the ODE. An example^. is shown in Figure 1.2. This direction field is drawn for the particular case of an acceleration given by
f Ž t , ®. s t y ®. Ž 1.2.4.
Along with the direction field, four solutions of Eq. Ž^ 1.2.2. with different initial ®’s are shown. One can see that the direction field is tangent to each solution. Figure 1.2 was created using a graphics function, available in Mathematica ’s graphical add-on packages, that is made for plotting two-dimensional vector fields: PlotVectorField. The syntax for this function is given below:
PlotVectorField[{vx[x,y],vy[x,y]}, {x,xmin,xmax},{y,ymin,ymax}, options ].
The vector field in Fig. 1.2 was drawn with the following Mathematica commands:
Cell 1.
Graphics‘