doing complex analysis with computers
PDF · 721 pages · 4.7 MB
Open PDF file
Course notes for MAE207, Applications of complex analysis, dated 29 May 2008 and dedicated to David Crighton. They take an applied, proof-light approach, using symbolic and numerical software to evaluate and generalize closed-form complex-variable solutions. The introduction lists prerequisites, recommended books, web resources, software libraries, a warning on numerical precision, and a 20-chapter overview. The file is stored in Phil's Ahlfors complex analysis folder.
AI-written summary; may contain errors.
Extracted text (machine-read; may contain errors)
MAE207 Applications of complex analysis
Stefan LLEWELL YN SMITH
In memory of David Crighton.
Introduction (05/29/2008)
Rationale
Many solution techniques in applied mathematics use complex variable techniques,
in many cases leading to closed-form but difficult-to-use solutions. The develop-
ment of computers in the last 50 years has led to brute-force approaches to many
of these problems. However modern computer software for symbolic and technical
computing like Maple and Matlab can also be used to evaluate and generalize the
analytical solutions. In these notes, we will cover some of these approaches using
actual examples and as much of the underlying theory as needed.
Prerequisites
Some prior knowledge of complex numbers, up to integration using residues, and
of linear algebra, including solution of systems of linear equations and eigenvalue
problems, is desirable. These notes have a distinctly applied flavor: very few, if
any, proofs will appear, and methods will be justified by their reasonableness rather
than by theorems and lemmas. Nevertheless, I will attempt not to write down any
outright lies and to ‘give conditions that are mathematically correct.
Some background in numerical analysis would be helpful, but is probably not ab-
solutely necessary. As mentioned above, the goal here is to use existing software
to solve problems using complex analysis, not to derive fundamental results of nu-
merical analysis. Some experience is useful in giving an idea of where the tools
that are being used come from and why they work.
Computer resources
The computer system that I will be using is Matlab1There are three main reasons
for this:
1.I expect most students to have access to Matlab.
2.It can do what I want. If it can’t in its basic form, it probably can using the
Maple extensions built in or the symbolic algebra package. Beyond this is more
difficult. We may occasionally require something more, in which case we will
use Maple. I dislike Mathematica. And if that’s no good, we’ll use FORTRAN.
3.I like Matlab.2
Matlab calls itself “The Language of Technical Computing” and fulfills the role of
an easy-to-use language to do things using mathematical objects. Its syntax is not
perfect, but is straightforward if you have seen C previously. Its graphics capabilities
1In these notes, I will not worry about trademarks and the like. In a real book, there would be R/circlecopyrt,c/circlecopyrtandTM
signs floating around.
2Note for UCSD students: one of the developers of Matlab, Loren Shure, was a graduate student in IGPP
at SIO. Bob Parker, Professor Emeritus of geophysics, had previously written something very similar for his
own use.
are good. Its toolboxes are outstanding. Its extensions like Simulink and the like
are pointless.
However, Matlab is not always fast enough. This is because it is an interpreted
language. One can compile Matlab, but this is a fairly pointless exercise. Note that
linear algebra routines like matrix inversion in Matlab are fast: it is the control struc-
tures and boring day-to-day operations that slow things down. Hence there will be
an occasional need for something faster, in which case FORTRAN is the language
of choice. This may seem slightly perverse, given the venerability of FORTRAN and
its problems, as well as the fact that Matlab is C-based. Nevertheless, FORTRAN
is still the best choice there is to draw upon the existing base of (free) numerical
software.
My programming style is not quite as spare as that of Prof. Ierley. However, I rec-
ommend using command-line summonings of Matlab and Maple. The GUI rarely
adds much value, and Emacs is a better editor than anything else.
Resources
Books
Y ou may find the following useful:
•Ablowitz, M. J. & Fokas, A. S. Complex variables: introduction and applications.
Cambridge University Press, Cambridge, 2003. Probably the best advanced
undergraduate/graduate level applied complex variable book. Good section on
Riemann–Hilbert problems, which is unusual in books at this level.
•Abramowitz. M. & Stegun, I. A., ed. Handbook of mathematical functions with
formulas, graphs, and mathematical tables. Dover, New Y ork, 1965. If you want
to do this stuff, you need to own this. If you want to do this stuff well, you need
to read this for fun. Some people like the hardbound government edition. Dover
edition cheap, of course.
•Bornemann, F ., Laurie, D., Wagon, S. & Waldvogel, J. The SIAM 100-digit chal-
lenge. SIAM, Philadelphia, 2004. In 2002, Nick Trefethen issued a challenge
to readers of SIAM News: solve 10 problems, each to 10 digits. Rather more
people met the challenge than he expected. This book presents a fascinat-
ing discussion of these problems, using them to introduce a variety of topics
in computational mathematics. Highly recommended, and I don’t say that just
because you’ll find my name in it as a prize winner.
•Carrier, G. F , Krook, M. & Pearson, C. E. Functions of a complex variable; theory
and technique. SIAM, Philadelphia. New ed., 2005. A classic which has been
reprinted. A good source to learn about “advanced” applied complex analysis.
•Duffy, D. G. Transform methods for solving partial differential equations. Chap-
man & Hall/CRC, Boca Raton. 2nd ed., 2004. A detailed, not to say over-
detailed exposition of transforms and integrals. Lots of complex analysis of
course. Valuable bibliography.
•Gradshteyn, I. S. & Ryzhik, I. M. Tables of integrals, series and products. Aca-
demic Press, San Diego. 6th ed., 2000. A number of other people have con-
tributed to this. This has most integrals that you’ll need in life. A laudable goal
is to be featured on the online errata page.3There is also a version on CD.
•Henrici, P . Applied and computational complex analysis. Wiley, New Y ork,
1974–1986. Three volumes written by a distinguished numerical analyst who
combines in a very effective manner theory and applications. Probably the
closest book in spirit to these notes.
•Ierley, G. R. I’m sorry, wrong number. Unpublished manuscript, 2007. These
notes by Prof. Ierley are remarkable on extrapolation and worth reading for an
3Guess who is. . .
insight on how to get the most bang in precision for your computing buck.
•Press, W. H., Flannery, B. P ., Teukolsky, S. A. & Vetterling, W. T. Numerical
recipes. . . Cambridge University Press. There are a number of editions and
also a web site (see below). A great resource, and can be read online. Watch
out though, there are mistakes. Often most useful when combined with canned
software to do the boring bits (who wants to type in a Gaussian elimination
subroutine?). I’m used to the FORTRAN 2nd edition.
•Trefethen, L. N. Spectral methods in MATLAB. SIAM, Philadelphia, 2000. Ex-
ceptionally clear introduction to modern spectral methods, using MATLAB pro-
grams brilliantly. I will try not to copy this approach too obviously. Good value
paperback.
•Needham, T. Visual complex analysis. Clarendon Press, Oxford, 1997. An
unusual book which emphasizes the geometrical aspects of complex analysis.
I’m not sure it works for me, but the pictures are interesting.
Web resources
•http://cernlib.web.cern.ch/cernlib/ CERNLIB is a library of numerical
routines developed at CERN. It used to be proprietary but is now freely avail-
able. Good for some of the more abstruse manifestations of special functions,
such as Bessel functions of imaginary order.
•http://www.cpc.cs.qub.ac.uk/ CPC Program Library.
•http://www.mathtable.com/ Daniel Zwillinger’s web site. He is probably the
most active special function and mathematical tables person out there. Useful
errata, e.g. for G&R.
•http://mathworks.com/ Has the Matlab documentation, which is useful if you
don’t like running Matlab in a GUI. Also contains contributed Matlab software
which can be useful. There is also an extensive support site, which can be
useful if you’re having technical difficulties with linking Matlab and FORTRAN
and so on, but not really otherwise.
•http://tonic.physics.sunysb.edu/docs/num meth.html Good links to nu-
merical methods resources on the Internet.
•http://www.gnu.org/software/gsl The GNU Scientific Library.
•http://www.nr.com/ The Numerical Recipes web site.
•http://www.olemiss.edu/sciencenet/benet/ Boundary Element Resources
Network contains lots of useful information about boundary element methods
(BEMs). We will not touch on these much, but they are closely linked to some
of the things we will be discussing.
•http://dlmf.nist.gov/ Digital Library of Mathematical Functions. The suc-
cessor project to A&S. Seems stalled at the moment.
•http://gams.nist.gov/ Excellent search engine and search tree linking to
many different public domain codes.
•http://www.netlib.org/ Most venerable numerical software repository. gams
links to it, and so on.
Software
This can be broken down into two main groups. First, integrated packages/suites/-
technical languages. These break down into computer algebra-type programs,
which range from extremely abstruse and special-purpose (MACAULEY) to what
most people would recognize as symbolic algebra programs (Mathematica, Maple,
Reduce) to more numerically-oriented programs (Matlab, IDL). The distinctions are
blurred however. Mathematica and Maple have extensive numerical capabilities,
and Matlab includes symbolic algebra facilities.
Second, we have the general purpose computer language (FORTRAN, C, C++
and so on) combined with appropriate software. In general, you need to be fairly
eccentric these days to write your own low-level mathematical software (Gaussian
elimination, quadrature, etc. . . ), although I know plenty of people who have done
so. It is a good thing to know how to do so, and in most cases these people have
a very good reason for doing so. As mentioned above, I use FORTRAN. Y ou can
use C or C++; don’t expect me to debug it.
The list of mathematical software libraries and packages is too long to mention,
ranging from specialized and application-oriented (all the way up to very expensive
commercial codes like FLUENT) to general and low-level. We won’t be dealing with
the former. From the latter, you should be aware of libraries like BLAS, LAPACK,
ARPACK, SLATEC, QUADPACK, CERNLIB.
Warning 14
At a fundamental level, computers operate on numbers (integers in fact: you should
be aware that a lot of effort has gone on behind the scenes to deal with real num-
bers in a sensible way). Computers have no concept of infinity or limiting pro-
cesses. Therefore, anything we do will boil down to solving sets of linear equations.
If your computer doesn’t do that fast, you will have trouble as things become more
accurate and more complicated.
Obtaining very high-precision results can be important for certain applications.
Standard IEEE double precisions gives about 16 digits of accuracy. To do better,
one needs multiple or arbitrary precision software. Most symbolic algebra pack-
ages use exact arithmetic, or as much as possible in the case of radicals, and then
have user-configurable precision (50, 100, . . . digits). There are also FORTRAN
multiple-precision package: MP and ARPREC, which are worth playing with. There
4Warning are things we would do well to remember. Forgetting them won’t kill you as you sit in front of your
computer, but the output might be wrong, or might take forever to compute. The former might kill someone
else in the long run if you have a real job; the latter might kill your job in the long run if you’re a scientist.
is also the GNU MP Bignum library, with which I am not familiar.
Overview of the material
The following is a quick overview of the 20 chapters. I have tried to make each
chapter a little lecture, and also to have the chapters follow in a logical order. I
may have failed on both fronts; in particular there may be too much material for 20
lectures.
1.Introduction and review of complex numbers
2.Branch cuts
3.Finding zeros
4.ODEs in the complex plane
5.Integral transforms
6.FFTs
7.Solving ODEs using integral transforms
8.Laplace transforms
9.Multiple transforms: Cagniard-de Hoop method
10.Multiple transforms: absolute and convective instability
11.Wiener–Hopf method
12.Matrix factorizations
13.Integral equations and principal-value integrals
14.WKB and ray theory
15.Laplace’s equation
16.Conformal maps
17.Elliptic functions
18.Special functions
19.Chebyshev expansions
20.Orthogonal polynomials
Sprinkled into the text you will find theorems, quasitheorems, exercises and exam-
ples. Quasitheorems are theorems that I have stated somewhat imprecisely. The
results are not wrong, but often conditions for their validity are lacking. Full versions
can be found in the references above.
Introduction (04/14/2008)
We rapidly review complex numbers and more particularly complex analysis. Our
discussion is brief, and concentrates on building up as quickly as possible the tools
that we will use. In lieu of extended discussions, we try and provide one example
of everything.
Complex numbers
Definition
We start be reviewing complex numbers. We define two operations, “addition” and
“multiplication”, on pairs (x,y)of reals as follows:
(x1,y1) + (x2,y2) = (x1+y1,x2+y2), (1)
(x1,y1)×(x2,y2) = (x1x2−y1y2,x1y2+x2y1). (2)
One can verify that (0,0)is the identity for addition, and every element (x,y)has
the inverse (−x,−y)under addition. Hence subtraction is defined. The element
(1,0) is the identity under multiplication. Every element except for (0,0)has an
inverse as can be seen from
(x,y)×/parenleftbiggx
x2+y2,−y
x2+y2/parenrightbigg
= (1,0). (3)
We see that (C,+,×)form a field, and drop the ×sign from now on. By identifying
R×RwithCunder the map (x,y)→z=x+ iy, we have defined the complex
numbers. We identify elements of the form (x,0)with real numbers. While iin this
approach can initially be viewed as an abstract symbol, considering the element
(0,1)shows that i2=−1shows that iis the complex unit.
The reason iwas introduced is that the set Cis algebraically closed, i.e. every
polynomial has a zero in C. (This is of course not true in R, as shown by the
polynomialx2+ 1.) This is a theorem, given the above definition: the fundamental
theorem of algebra.
Note that Cis also a vector space under multiplication by reals.
Geometry
The identification of a complex number with a pair of real numbers leads immedi-
ately to the Argand diagram, where z=x+ iyis associated with the point in the
plan with coordinates (x,y). Some of the algebraic operations acquire geometric
meanings then: −zis the reflection of zthrough the origin, z1+z2is the vector sum
of the two vectors associated with points (arrowhead at the point, tail at the origin),
and we can now think about distances and angles.
We write the distance from the origin of the point zas|z| ≡√x2+y2; this
is the modulus of z(sometimes written as rwhen polar coordinates are being
used). Defining the complex conjugate of z,¯z, by ¯z=x−iygives|z|2=z¯z.
The angle made by the line (vector, whatever) to zis the argument of z; clearly
(x,y) =|z|(cosθ,sinθ). Then tanθ=y/x in general, but one has to be care-
ful about cases like x= 0and what happens in different quadrants of the complex
plane. These may seem like trivial issues, but can lead to real problem in numerical
implementations.
Warning 2 An equation that is true or “obvious”, as a relation between complex
entities, can fail as part of a numerical implementation.
The argument θis safe whenever it appears inside a sine, cosine, or exponential
function. Recalling the series for these, we see that in polar coordinates
z=rcosθ+ irsinθ=reiθ. (4)
Now we blithely use the results we know about the exponential function, obtaining
some trigonometric identities on the way. This shows that multiplication is a “twist
and scale” operation:
z1z2= (r1cosθ1,r1sinθ1)(r2cosθ2,r2sinθ2) =r1r2ei(θ1+θ2). (5)
The modulus of the product is the produce of the moduli. The argument of the
product is the sum of the arguments (watch out for the modulo 2πaspect).
It is sometimes useful to think of the complex plane as a simply-connected set,
i.e. as a sphere. Then the point at infinity is part of this sphere, which is called the
Riemann sphere. This geometric picture can be very useful when thinking about
multivalued functions.
Exercise 0.1 Write a two-paragraph discussion of the Riemann sphere.
Analyticity
A central notion in this book will be that of analyticity. A number of the techniques
that we consider will explicitly be concerned with constructing analytic functions.
This will usually be the most difficult part of the problem. Once a certain function
has been constructed with the appropriate analyticity properties, one is usually
home and dry.
To begin, we need the notion of a function. A function f(z)is a rule that to the
complex number zassociates another complex number f. We will return to this
issue when talking about multivalued functions (sometimes called multifunctions).
The range of fis the subset of Cof valuesf(z);fis one-to-one if f(z1) =f(z2)⇒
z1=z2.
We will often write f=u+ iv. We will also be alarmingly slapdash about the
arguments. When it suits us, fwill be a function of z, ofxandy, or ofzand ¯z.
Differentiation
The complex function fis differentiable at the point zif the limit
f/prime(z)≡lim
h→0f(z+h)−f(z)
h(6)
exists for all complex hash→0. We have not defined limits and so on: these
notions are taken to be understood, if only informally, for real numbers, and we are
discussing the extension to the complex case.
The fact that ( 6) has to hold for all h, i.e. in all directions about the origin, is fantas-
tically important. It leads to entirely unexpected consequences; to be brief we can
say that complex differentiable functions are nice.
We can use this property to derive in a very simple manner the Cauchy–Riemann
equations. First take hto be real. Then f(z+h) =f(x+h,y)and df/dz=
∂/∂xf (x,y). Similarly is we write h= ik,df/dz=∂/∂(iy)f(x,y). Identifying real
and imaginary parts gives the Cauchy–Riemann equations:
∂u
∂x=∂v
∂y,∂u
∂y=−∂v
∂x. (7)
Theorem 1 Iffis analytic, then ( 7) hold. Conversely, if uandvare continuous and
(7) hold, then fis analytic.
It is sometimes useful to consider zand ¯zas independent variables. We can
change variables for an arbitrary function by our usual abuse of notation, f(z,¯z) =
f(x,y). Then the chain rule gives, at least formally,
∂
∂x=∂
∂z+∂
∂¯z,∂
∂y= i∂
∂z−i∂
∂¯z. (8)
Note that this leads to
∇2=∂2
∂x2+∂2
∂y2= 4∂2
∂z∂¯z. (9)
The term analytic is sometimes used interchangeably with differentiable, and some-
times not. So is the word holomorphic. We will just use analytic from now on. So
the complex function fis analytic in a subset of the complex plane Sis (6) holds
at all points of S.
We can check analyticity by hand to build intuition:
Example 0.1 The function f(z) =zm, withminteger, is differentiable everywhere
inC. We write
(z+h)m−zm
h=mzm−1+m(m−1)
2hzm−2+··· →mzm−1, (10)
which holds for all z.
We can see where it fails in harder situations:
Example 0.2 The function f(z) =|z|2is differentiable only at the origin. We have
(z+h)(¯z+¯h)−z2
h=¯z+¯h
hz. (11)
This does not have a unique limit as h→0(since the second term depends on the
argument of h), except when z= 0.
However, in most cases we use the following shortcut:
Tip 1 The obvious functions that we know and love (polynomials, exponential, sine,
logarithm, etc. . . ) are analytic except at points where there’s an obvious problem.
Taylor and Laurent series
An equivalent definition of analyticity is by use of Taylor series: the function fis
analytic atz0if it has a convergent expansion of the form
f(z0+h) =a0+a1h+1
2a2h2+···, (12)
where we identify a1withf/prime(z0). Given our definition ( 6), this is a theorem. We do
not prove it.
Unlike the real-variable case, we have another, very useful, kind of series: the
Laurent series. If the function fis analytic in the annulus 0<|z−z0|<d, then it
can be written as
f(z0+h) =···+a−1h−1+a0+a1h+1
2a2h2+···, (13)
where the sum can in principle extend infinitely far to the left. In that case the point
z0is called an essential singularity. Otherwise, it is a pole.
This definition excludes points of non-analyticity where are not isolated. These
includes points of accumulation such as 1/(sinz−1)which is non-analytic at z=
(nπ)−1for all integer nand branch points. We will have more to say about the
latter.
An entire function has no singularities in the complex plane (excluding the point at
infinity). This means no poles, no non-isolated singularities, no branch points.
Multivalued functions
Our definition in words of function as a rule implies that to each zwe associate one
f(z). This is the usual procedure, and certainly necessary for computer implemen-
tation. However, there are times when a more general definition is useful.
A multivalued function or multifunction is a rule that to each zassociates one or
moref(z). For example, we can define the multifunction√zto be one of the
complex number that, when squared, give z. The usual real-valued definition of√xpicks the positive root of y2=x. However for complex numbers, we want
square roots of all z.
Dealing with multifunctions leads naturally to the idea of Riemann surfaces: C
is mapped to a more complicated geometric structure, with different copies of C
stitched together.
From a practical perspective, we will not use multifunctions in their raw form (it can
be done), but instead introduce branch cuts to make the functions single-valued.
We pay a price: functions are no longer continuous in places where they were
previously. For now, we defer the discussion to Chapter 16.
Analytic continuation
In|z|<1, we write
1
1−z= 1 +z+z2+z3+···, (14)
and the sum converges. We can think of this another way: reading from left to
right, we see that the sum is the same as the rational function in the unit disk. The
two sides are just different ways of writing the same function. Hence we use the
equality to extend the sum to the entire complex plane, nothing that the point 1has
issues. This is essentially analytic continuation in a nutshell.
Quasitheorem 1 Iff1andf2are defined over subregions D1andD2ofCand
f1(z) =f2(z)inD1∩D2, and this region is enough of the complex plane , namely
a non-trivial curve or set, then f1provides an analytic continuation of f2toD1.
Again, we have been vague. This is only interesting if D1is bigger than D2(it may
containD2.) In the previous example, we had D1=C\ {1}andD2the unit disk.
Example 0.3 Consider the integral
F(z) =/integraldisplay∞
0e−tzdt=1
z(15)
when Rez > 0(otherwise the integral does not converge). The function Fis
analytic in this domain of definition, and the equality holds there. Hence z−1is its
analytic continuation to the C\ {0}. This kind of argument is very common with
Mellin and Laplace transforms.
Liouville’s theorem
Theorem 2 A bounded entire function is constant.
This is amazing. More generally, a function satisfying |f(z)|< c|z|mfor some
integermandzsufficiently large is a polynomial.
Exercise 0.2 Use Liouville’s theorem to prove the fundamental theorem of algebra:
every polynomial has a root in C.
Integration
Cauchy’s theorem
Integrals in the complex plane can be defined using parameterizations. We shall
not worry about distinctions between curves, contours, or smoothness. All the
obvious properties of integration based on linearity work.
Example 0.4 This is a useful integral: Im=/integraltext
Czmdz.whenCis the unit circle.
Parameterize the unit circle by z= eiθ, so that dz= ieiθdθ. Then
Im=/integraldisplay2π
0iei(m+1)θdθ= 0 (m/negationslash=−1) (16)
by the properties of trigonometric functions. Clearly I−1= 2πi.
The fundamental theorem of calculus also works, and if one thinks about applying
it to a closed curve, one would like to argue that the result always vanishes. This is
almost true: the correct version is Cauchy’s theorem.
Quasitheorem 2 If the function fis analytic inside a closed curve C, then/integraldisplay
Cf(z) dz= 0. (17)
This is a quasitheorem because we have not worried about the smoothness of the
curveC. The conditions on fare fine (note that Cauchy’s original proof required f
to be analytic on the curve; Darboux showed this was unnecessary).
We can hence deform contours in regions where the integrand is analytic: adding
connecting lines and checking appropriate cancellations (running along the same
arc in two different directions) shows that deforming a contour makes no difference.
Hence the result above, Im= 2πiδm,−1, is valid for any contour enclosing the origin.
Exercise 0.3 Prove Green’s theorem in the plane from Cauchy’s theorem.
Integration by residues
The fact that we can deform contours except when the integrand has a pole inside
it and the result for I−1above leads to the following result:
Quasitheorem 3 /integraldisplay
Cf(z) dz= 2πi/summationdisplay
nRes(f;zn), (18)
where Res (f;z0)denotes the residue, that is the −1term in the Laurent series, at
the singularity zn.
If the integral exists, one doesn’t have to worry too much about the behavior of f
alongC. I have sidestepped issues with non-isolated singularities, which will not
crop up here.
For a function f(z)/g(z)that has a simple pole at z0, the residue is given by
f(z0)/g/prime(z0)(assuming that common terms have been cancelled out).
We use this to compute real integrals. The name of the game is to find a contour
such that the parameterization of the integral over part of the contour gives what
the desired real integral, while the rest of the integral vanishes or can be dealt with
somehow.
The classic example is the following. Note that versions of this which require deal-
ing with a simple pole at the origin, or that use Cauchy principal values, are missing
the point.
Example 0.5 Compute
I=/integraldisplay∞
0sinx
xdx. (19)
First note that we can extend the range to the whole real line by adding a factor of
1
2. The next step is to come up with a contour integral. The natural candidate is
I1=1
2/integraldisplay
Csinz
zdz. (20)
Unfortunately, the function sinzblows for large positive and negative imaginary val-
ues, so any semicircular contour will have an unbounded integrand. Exponentials
are better behaved, so let’s use the relation sinz= (eiz−e−iz)/(2i).The real prob-
lem is the contour then, since eiz/zblows up at the origin. However, the choice of
contour for the original function is immaterial, so we can deform the contour off the
real axis, either up or down. We take it up to C+. We now work with
I2=/integraldisplay
C+eiz−e−iz
4izdz=/integraldisplay
C+eiz
4izdz−/integraldisplay
C+e−iz
4izdz. (21)
The first integral on the right-hand side can be closed in the upper half-plane and
has no poles inside the contour, hence it vanishes. The second can be closed in
the lower half-plane. There is a simple pole at the origin with residue 1. Hence
I2=π/2. Note the minus sign from the fact that the contour in the lower half-plane
is described in the negative sense. Now I=I2+stuff that goes away, so we have
I=π/2.
As a lesson from that example, we note the following:
Warning 3 Analyticity in Cis very nice. However, functions sometimes have differ-
ent behavior in the complex plane compared to the real line. Sine and cosine are
no longer bounded (this is a classic mistake).
It’s worth practising contour integration. Be efficient:
Tip 2 Don’t worry about detailed proofs that contributions along parts a contour
vanish. Use orders of magnitude. Large circles or semicircles with radius Rbehave
OK provided the integrand is o(R−1). The only case where one has to be careful is
O(R−1)along a semicircle. There one actually has to use Jordan’s lemma, which I
do not include here on principle.
This tip uses order symbols. These are all valid in some limit as ztends to some-
thing, so they hold for zclose enough to that point. Briefly, f=O(g)iff/g is
bounded and f=o(g)iff/g→0.
One can do many more integrals this way. Note the use we made of symmetry in
the integral there. Clearly the integral of xsinx/(1 +x4)would work similarly.
Exercise 0.4 What about the integral of sinx/(1+x3)? This is no longer elementary
and you will need special functions.
Example 0.6 Finally, we look at
L(z) =/integraldisplayz
1du
u, (22)
whenzis imaginary. The path of integration doesn’t matter, provided it doesn’t go
through the origin. Take it to be from 1to|z|and then along an arc from |z|to
z=|z|eiθ. Using the obvious parameterizations, we find
L(z) =/integraldisplay|z|
1dx
x+/integraldisplayθ
0i dθ= log|z|+ iθ. (23)
The logarithm above is the usual real logarithm. The presence of θshould immedi-
ately alert us to the possibility of multivaluedness: we have not specified how many
times around the origin our path goes and there are many possibilities differing by
multiples of 2πi. ClearlyL(z)is the complex logarithm, and we have shown that it
is a multifunction. The principal branch has −π < θ ≤θ. We shall return to this
later. Note that the complex logarithm is the inverse of the complex exponential
function, which is invariant under the addition of 2πi. The integral I−1is an integral
ofL(z)around a closed curve encircling the origin. Then θvaries smoothly and
changes by 2π, giving the required answer.
Cauchy’s integral formula
Theorem 3 Iff(z)is analytic inside and on the contour C, then for any interior
point ofz,
f(z) =1
2πi/integraldisplay
Cf(ζ)
ζ−zddζ. (24)
This formula can be differentiated as often as we wish. Hence an analytic formula
is differentiable infinitely many times, which is definitely not the case for a real
differentiable function (e.g. |x|x).
We will be very interested in integrals of the form
F(z)/integraldisplay
Cϕ(ζ)
ζ−zdζ, (25)
known as Cauchy-type integrals, in what follows.
Cauchy principal value integrals
We have glossed over the definition of improper integrals. Formally we have for a
real integral/integraldisplay∞
−∞f(x) dx= lim
M−→∞,M+→∞/integraldisplayM+
−M−f(x) dx (26)
when the limit exists. The Cauchy principal value corresponds to taking M−=M+
in the limit. It exists when the integral exists, and sometimes when it does not.
Similarly, when f(x)has a simple pole along the contour, say at the origin, we can
do the same thing and write
−/integraldisplayb
af(x) dx=/parenleftbigg/integraldisplay/epsilon1
a+/integraldisplayb
/epsilon1/parenrightbigg
f(x) dx. (27)
Often we will detour around simple poles and the limit becomes a Cauchy principal
value integral. These integrals are not limited to integration along the real axis.
Example 0.7 Iff(z)is analytic at the origin and decays at infinity, then
−/integraldisplay∞
−∞f(z)
zdz=−/integraldisplay∞
−∞f(z)−f(0)
zdz+f(0)−/integraldisplay∞
−∞dz
z=−/integraldisplay∞
−∞f(z)−f(0)
zdz. (28)
The first integral on the right-hand side is a Cauchy principal value integral because
of the behavior at infinity. The second integral is zero:
−/integraldisplay∞
∞dz
z= lim
/epsilon1→0,M→∞/parenleftbigg/integraldisplay−/epsilon1
−M+/integraldisplayM
/epsilon1/parenrightbiggdz
z= log| −/epsilon1|
| −M|+ logM
/epsilon1= 0. (29)
Plemelj formulae
Consider what happens in a Cauchy-type integral F(z)as in ( 25) asztends to the
contour of integration C. WriteF+for the result as zapproaches Cfrom the left
(with respect to the direction of integration) and F−for the result as zapproaches
Cfrom the right.
F±(z) =±1
2ϕ(z) +1
2πi−/integraldisplay
Cϕ(ζ)
ζ−zdz. (30)
These formulae underlie a lot of results on integral equations and Riemann–Hilbert
problems.
The principle of the argument
Consider the integral
J=1
2πi/integraldisplay
Cf/prime(z)
f(z)dz= [arg (f(z))]C. (31)
Iffis well-behaved along the contour, this will be a multiple of 2πi. The result will
depend on the number of singularities of the function inside the contour. When f
has a simple zero at z, we havef(z+h) =hf/prime(z) +···, sof/prime(z)/f(z)∼h−1+···.
Iffhas a zero of order n,f/prime(z)/f(z)∼nh−1+···The same argument with poles
gives minus signs, so equating the two sides, we have
1
2πi/integraldisplay
Cf/prime(z)
f(z)dz=Z−P, (32)
whereZandPare the numbers of zeros and poles, counted with multiplicity.
Exercise 0.5 Discuss the integral/integraldisplay
Czf/prime(z)
f(z)dz. (33)
See Chapter 21
Physical applications
Complex numbers are unjustly tarred with the appellation imaginary, and one could
ascribe their creation to the mathematical aim of solving x2+ 1 = 0 . However,
their origin lies in the very practical goal of solving cubic equations and obtaining
three real solutions, two of which involve complex arithmetic when using Cardan’s
formula. Complex analysis is of enormous help in solving a number of physical
application, which we describe briefly.
Waves
The definition of the complex exponential in terms of trigonometric functions shows
that complex analysis is uniquely suited to describing periodic systems and waves,
which after all are periodic disturbances in a medium.
The use of complex numbers ranges from efficient ways of solving LRC circuits,
where differentiation maps to multiplication by an imaginary number, through Fourier
transforms and FFTs, which underlie modern signal processing, to quantum me-
chanics and nonlinear scattering theory in integrable systems.
Integral transforms
Fourier’s theorem states that any periodic function can be decomposed into a sum
of harmonics. This generalizes to Fourier transforms, which apply to (almost) any
real functions. We write
F(k) =/integraldisplay∞
−∞f(x)e−ikxdx, f (x) =1
2π/integraldisplay∞
−∞F(k)eikxdk. (34)
I will try and stick to this notation ( xandk) for transforms in space, and use tand
ωfor transforms in time. It can be useful to use the opposite convection in the latter
case. Sometimes I may use αas the transform variable.
Many other integral transforms exist. All rely on some version or extension of
Fourier’s inversion theorem to obtain an inverse transform. Examples are Laplace
transforms (one-sided in our case), Mellin transforms, Hankel transforms, Kantorovich–
Lebedev and others.
Laplace’s equation
The other main application of complex analysis comes from ( 9): harmonic func-
tions, i.e. functions that satisfy Laplace’s equation, can be obtained from analytic
functions. Boundary conditions on the harmonic functions become conditions on
the analytic functions at the boundary.
Laplace’s equation occurs in fluid mechanics (potential flow), heat transfer (steady-
state solutions), elasticity, potential theory and many others. The biharmonic equa-
tion,∇4φ= 0, can be attacked using complex methods. It occurs in Stokes flow
and linear elasticity.
These approaches are limited to two dimensions usually.
Branch cuts (04/10/2008)
We have introduced multifunctions previously. We now treat branch cuts.
Branch cuts
First, we call a branch point of fa point in Caround which the function fdoes
not return to its original value as we trace out a closed curve. Typical example: the
origin for√zorlogz. In fact infinity is also a branch point for both these functions,
and for geometrical reasons, there has to be more than one branch point for a
function. This notion of treating infinity on a par with other points has already come
up when the Riemann sphere was mentioned.
Quasitheorem 4 Anything that can be done with a function f(z)at a pointzinC
can be done with the point at infinity by setting t=z−1and proceeding as usual.
Then a branch cut is an arbitrary curve in Cjoining two branch points. We have
enormous freedom in how we pick a cut, so we have replaced a multifunction by
an infinite family of functions with different branch cut structures. In addition to
the curve, we must pick a branch by specifying the value of the function at a point
somewhere. From a computer science perspective, a branch of a function is an
abstract data structure including f, the topology of the cuts and the value chosen
forf(z0). This is more than we want to deal with usually, so we will try to be
efficient.
Note that in physical problems, the complex plane is a place we visit to find a
solution that must be expressed in terms of real numbers.5Hence the answer we
find cannot depend on the particular choice of branch cut topology we use.
Warning 4 If the final, physical, answer you find depends on the branch cuts you
have picked, you have probably made a mistake. This does not mean that different
parts of your solution can depend on the branch cuts cannot individually depend
on the branch cuts (leaky waves and so on). The final answer cannot.
This also does not hold if one is using a complex function to represent a discontin-
uous real function. But there the branch cut was not picked arbitrarily as part of the
method of solution; it came from the physics.
5This is an approximation of course: continuum mechanics does not hold at the molecular scale and be-
low. More abstrusely, it is sometimes suggested that all lengths in the universe or time intervals are discrete
multiples of some fantastically small fundamental units. Who knows?
Matlab implementation
The prototypical multifunctions are the square root and logarithm functions. They
are of course related, since√z= exp (1
2logz). Let’s look at the the imaginary part
of√zin Matlab. The code of program p21.m : calculates√zin a square of the
complex plane and produces a surface plot of the output, as shown in Figure 1.
% p21: square root branch cut; 04/02/2008 SGLS
x = -2:.01:2; y = x;
[x,y] = meshgrid(x,y); z = x + i*y;
f = sqrt(z);
surf(x,y,imag(f)); shading flat
xlabel(’Re z’); ylabel(’Im z’); zlabel(’Im \sqrt {z}’)
We see a discontinuity along the negative real. In fact, Matlab is using the princi-
pal branch of the logarithm, which can’t be seen in Figure 1. To verify this, type
log(-1) in Matlab and obtain 0 + 3.1416i , corresponding to the principal branch
of axis and values between −πandπ.
This is fine, but what if we want a different branch cut? Straight branch cuts are
very easy. The point about the Matlab branch is that the cut is along z=−xfor
Contour plot of the imaginary part of√zusing the native Matlab branch cut.
positive real x. Hence the function g(z) = e−iα/2√
zeiα, which is certainly a solution
ofg(z)2=z, has a branch cut when z=−xe−iα, i.e. along a ray making angle −α
with the real axis. So if we replace sqrt(z) byexp(i*pi/5)*sqrt(z*exp(-2*i*pi/5)) ,
we obtain a branch cut at making an angle of 2π/5.
For curved branch cuts, we are out of luck. One has to write a program that sets
the argument of the logarithm or other multifunction by hand.
More complicated branch cut structures
The more branch points, the more branch cuts and the more ways of joining them
up:
Exercise 0.6 How many ways are there of choosing branch cuts that are topologi-
cally distinct for nbranch points?
Certain functions recur again and again in physical problems, the most common
beingβ(z) =√
z2−1 =√z−1√z+ 1andγ(z) =√
z2+ 1 =√z−i√
z+ i.
Actually these equalities are not necessarily true in Matlab, in the sense that one
can calculate left-hand and right-hand sides and obtain different answers. Let’s
have some new notation.
Warning 5 We will use the symbolC=to denote an equality that is true for complex
numbers or functions, but not necessarily for the results of a Matlab calculation;
e.g.
logxyC= logx+ logy. (35)
Let’s look at β(z) =sqrtz2−1. The way to handle this is to think of a length of
string tied to nails at ±1. Start on the real axis at x> 1. We need to pick a branch
and the sensible one is real and positive. Then we go around the branch cut, as if
we had a pencil keeping the string drawn taut. The complex number z−1can be
thought of as a vector from 1toz, so on the positive real axis it initially has argument
θ1= 0. The complex number z+ 1is a vector from −1toz, once again initially with
argumentθ−1= 0. As the tip of the pencil moves to be just above the branch cut,
the argument of z−1increases to 2π. As it moves further left beyond the branch
cut, the argument of z+ 1now changes to π. The pencil tip now loops around to
be under the branch cut: the argument of z+ 1has increased to 2π. Finally the
pencil tip reappears to the right and the argument of z−1increases to 2π. We use
the resultβ(z) =/radicalbig
|z2−1|ei(θ1+θ−1)/2. Combining the results we get positive real
values on the positive real axis x > 1, negative real values on the negative real
axisx <−1, positive imaginary above the branch cut, negative imaginary below
the real axis. Note that this function depends only on z2, butf(z)/negationslash=f(−z)for real
|z|>1.
Warning 6 Complex functions with branch cuts do not always have the symmetry
properties you might expect.
The Matlab code in p22.m gives the picture in Figure 2. The top row uses the func-
tionsqrt(z.^2-1) which is not the correct branch cut. Solving z2−1 =−x2gives
z=√
1−x2; this is forx > 0, so the branch cut contains parts of the imaginary
axis as well as the real axis. The bottom row uses sqrt(z-1).*sqrt(z+1) . Now
the branch cuts are at z±1 =−x2, and the portion left of −1cancels, leaving
the branch cut between −1and 1as desired. The right-hand column shows the
Contour plot of the real and imaginary part of β(z)using several different branch
cuts.
imaginary part, which vanishes on the real axis outside the branch cuts and does
not show the antisymmetry on the real axis so obviously.
The functions β(z)andγ(z)is commonly encountered in wave propagation prob-
lems for monochromatic waves (Helmholtz-type equations). If the function under
consideration is an inverse transform, the presence of singularities on the inversion
contour, the real axis, is usually a warning of some kind of causality or radiation
condition. It is usually safer to add a small imaginary part to take the singularity off
the real axis.
Example 0.8 The function |z|/epsilon1= lim /epsilon1→0√
z2+/epsilon12is encountered quite often in the
solution of Laplace’s equation. Of course |zis a non-analytic function (check the
Cauchy–Riemann equations or go from the definition). However, one can use it by
thinking of the limit. This function is analytic in the strip −/epsilon1 <Imz < /epsilon1 , and then
arguments of analyticity are OK in that strip.
By analogy with p22.m , a branch of the function γ(z)can be chosen which is
real and positive on the positive real axis and has a branch cut between −iand
i. This uses the code z.*sqrt(1+1./z.^2) . However this is not the appropriate
branch to deal with an inverse transform, since it intersects the inversion contour.
Possible branch cut structures are cuts along the imaginary axis with |Imz|>1,
using sqrt(z.^2+1) , and cuts parallel to the real axis in the left half-plane, using
sqrt(z-i).*sqrt(z+i) . Finally one can construct very strange cuts with code
likesqrt(z+i).*sqrt(z).*sqrt(-i./z+1) : imaginary axis between −1and 1,
negative real axis, horizontal line going left from −1.. These possibilities are shown
inp23.m and in Figure 3.
As seen in p22.m , branch cuts can cancel in a nice way. Typical examples occur in
linear elasticity problems:
Example 0.9 The function f(z) =√
z2+ 1/radicalbig
z2+k2
0, wherek0>1, has a nice
branch cut structure.
Contour plot of the imaginary part of γ(z)using two different branch cuts.
IN CLASS
Exercise 0.7 Work out the branch cut structure of
f(z) =/radicalBig
z+√
z2+ 1. (36)
Be as explicit as possible. Think about how the Riemann sheet structure stitches
together.
Integrals
Keyholes and hamburgers
Branch cuts are critical in calculating certain integrals using residues.6
The following integral can be done without branch cuts,but we’ll use a cut here:
I=/integraldisplay∞
0x2
1 +x5dx. (37)
The integrand has no good symmetry properties on the real axis, although it does
well along the ray making an angle 2π/5from the axis. So one approach is to go
out along the real axis and come back along the arc making angle 2π/5with the
real axis. The result is π/5 sin (2π/5).
Consider
IC=/integraldisplay
Cz2logz
1 +z5dz. (38)
We have introduced a multifunction. Take the branch cut along the positive real
axis, with logzreal along the top of the real axis (and hence with imaginary part
6Richard Feynmann’s proud claim that he could do any integral without using residues always struck me as
depressing: contour integrals are so enjoyable.
2πialong the bottom of the positive real axis. The “keyhole” contour Cgoes along
the top of the positive real axis to R, swings around a large circle, and then back
along the bottom of the positive real axis. Since logzis integrable near the origin,
we need not bother with little circles about the origin in our policy of efficiency. The
integrand is O(R−5)for largeR, which immediately shows that the contribution
from the large circle vanishes. There are simple poles at the five fifth roots of −1:
eπi/5,e3πi/5,e5πi/5e7πi/5and e9πi/5(the choice of arguments is set by the choice of
branch). Hence
IC= 2πi/parenleftbigg
e2πi/5πi/5
5e2πi/5+ e6πi/53πi/5
5e6πi/5+ e10πi/55πi/5
5e10πi/5+ e14πi/57πi/5
5e14πi/5
+e18πi/59πi/5
5e18πi/5/parenrightbigg
= 2πi/parenleftbiggπi
25/parenrightbigg
[20c2+ 10c−5 + 8is(1−c)], (39)
where we have written sandcfor the sine and cosine of 2π/5respectively. Taking
appropriate limits and nothing that logz= log|z|+ 2πialong the underside of the
real axis, we find
IC=/integraldisplayR
0x2logx
1 +x5dx+/integraldisplay0
Rx2(logx+ 2πi)
1 +x5dx+O(R−4) (40)
for largeR. The logarithmic terms cancel and leave us with −2iπIasR→ ∞ .
Equating these results gives
I=−πi
25[20c2+ 10c−5 + 8is(1−c)]. (41)
Now we need to simplify this result. The imaginary part vanishes, so c2=−1
2c+1
4.
Hence
I=8π
25s(1−c) =8π
25s(1−c2)(1−c) =8π
25s(3
4+1
2c)(1−c) =8π
25s(3
4−1
4c−1
2c2) =π
5s(42)
as before.
Now consider
I=/integraldisplay∞
1dx
(x−1
2)/radicalbig
x(x−1). (43)
The singularity at x= 1is integrable. Consider
IC=/integraldisplay
Cdz
(z−1
2)z/radicalbig
z(z−1)dz (44)
with branch cuts from 1to infinity along the positive real axis and from 0to minus
infinity along the negative real axis. We take the branch that is real and positive
on top of the positive real axis. The contour goes out from 1along the top of the
real axis toR, loops around a semicircle to −R, back along the top of the negative
real axis to 0, back out along the bottom of the negative real axis to −R, semicircle
back toRand returns to 1along the bottom of the positive real axis. This is the
“hamburger” contour. We don’t bother with little circles or indentations around 1and
0: the singularity is integrable so there will be on contribution. Similarly, for large R,
the contributions from the large semicircle is O(R−1)and goes away. Paying close
attention to the cuts, we find
Ic= 2/integraldisplay∞
1dx
(x−1
2)/radicalbig
x(x−1)+ 2/integraldisplay∞
0dy
(y+1
2)/radicalbig
y(y+ 1)= 4I (45)
after a simple change of variable. Now there is a simple pole at z=1
2, with residue
2. HenceI=π. Note that if we move that pole, the result cannot be obtained
this way because there is no longer the required symmetry to express Icpurely in
terms ofI.
Branch cuts and integrating around infinity
Consider
I=/integraldisplay1
−11
(1 +x2)√
1−x2dx. (46)
ConsiderIcwith the obvious integrand, branch cut between −1and1with positive
real values along the top of the branch cut. This is non-standard. Take the contour
to go around the branch cut in the positive sense. Again we don’t bother indenting
around the ends of the branch cut since the singularities are integrable. Along the
top of the cut, we obtain iI, and ditto along the bottom. Now think about deforming
the contour. As it grows larger, we have an estimate O(R−2). Hence the integral
around infinity vanishes. However, there are two poles in the complex plane at
z=±ithat are moved through to deform the contour to infinity. Hence
I=1
2Ic=πi/parenleftbigg1
2i√
2+1
(−2i)i(−√
2)/parenrightbigg
=π√
2, (47)
where one has to be careful with the arguments of the square roots. This technique
of deforming the contour to go around infinity also works well for more complicated
integrals.
Finding zeros (04/09/2008)
Finding the zeros of an analytic function is required for many physical problems.
This is particularly the case for problems solved using integral transforms, where
the behavior of complex frequency and wavenumber leads to complex dispersion
relations linking the two.
In many wave propagation problems, for example surface gravity waves, we have
some physical insight into the problem, and can usually identify propagating waves
and exponentially damped waves (a boundary is required for these). The disper-
sion relation takes the form of a transcendental relation and zeros are pure real or
pure imaginary, so that a few judicious substitutions give a real equation to solve.
Intrinsically complex cases are more difficult.
Exercise 0.8 Find the real and imaginary roots of the dispersion relation
ν−ktanhk. (48)
This is a problem that deals with real numbers, not complex numbers.
Multi-dimensional zero finding
In general, this is a difficult and unrewarding task. In one dimension, we have a
good intuitive picture of what is going on: to solve f(x) = 0 , we draw a graph of
y=f(x)and see where it intersects the x-axis. Even better, if our function f(x)is
continuous (and there are cases where it won’t be), the intermediate value theorem
tells us that between points where fhas opposite sign, there must be a zero of f.
There are many algorithms to find zeros, as in secant, Newton–Raphson, more
complicated versions, and so on. There is no shame in using a packaged routine.
The programmer probably had more time and experience than you. Matlab has
fzero which is good. Note that it can be used in two modes: by specifying an
initial guess, and by specifying an interval. In the second case, fzero can tell you
if there is no root (assuming your function is continuous). If there are several roots
in your interval, you might not find the one you expect. No guarantee that there is a
root in the first case, and again the zero you find might not be the one you expect.
In FORTRAN, SLATEC’s dfzero does a good job. For polynomials, you should be
using an algorithm designed for polynomials. Matlab has roots .
Even if you are using a canned package, some care is required. In all cases, you
should look at what is going on graphically. Unless everything is very spiky, the
main point of running the algorithm is often to get good accuracy. Nevertheless,
you should check your results. Acton (1970) has some wise words on this and on
many other thins. To extend on the words of Boyd (2001; Definition 16),
Definition 0.1 An idiot is someone who obtains a numerical result and does not
check it. Graphically, physically, by doubling the resolution, etc. . .
In higher dimensions, things are nastier. Instead of finding the intersection of a
curve and a straight line, we are finding the intersection of hypersurfaces and we
may not be looking at points any longer; for example the zeros of f(x,y) =x2−y2
are no longer points (zero dimensions) but curves (one dimension). If this is really
what you are doing, grit your teeth and use something like fsolve in Matlab or a
FORTRAN routine.
The complex function f(z)have one advantage when it comes to finding zeros:
two unknowns (real and imaginary parts of z) and two equations to satisfy (real
and imaginary parts of f). We have a good graphic pictures of what is going on,
as in Figure 4for an essentially arbitrary function f(z).
% p31: contour plot for zeros; 04/07/2008 SGLS
x = -10:00.1:10; y = x;
[x,y] = meshgrid(x,y); z = x + i*y;
f = z.^2+1 - sin(z).*z;
contour(x,y,real(f),[0 0],’r’);
Re zIm z
−10 −5 0 5 10−10−50510Contour of real (red) and imaginary (blue) part of the function f(z) =z2+1−zsinz.
hold on; contour(x,y,imag(f),[0 0],’b’); hold off
xlabel(’Re z’); ylabel(’Im z’);
Another advantage is that the algebraic (and analytic structure) of complex num-
bers means that we can use algorithms that were developed for the one-dimensional
cases, in particular iterative methods.
Exercise 0.9 Find the zeros of f(z) =z2+ 1−zsinz. Discuss what is meant by
“all zeros”. How many do you think would be useful? Can you find approximate
values for the larger ones?
Iterative methods
Fixed-point iteration
The idea here is to turn our zero-finding problem into an equation of the form f(z) =
zand then solve the iterative process
zn+1=f(zn), (49)
with some initial guess z0.The condition for convergence is simple to obtain. Write
the root off(z) =zasz∗, so thatz∗=f(z∗). Define the error as en=zn−z∗and
subtract:
en+1=f(z∗+en)−f(z∗) =enf/prime(z∗) +O(|en|2). (50)
If we are close enough to the z∗, then this is almost a geometric process and the
convergence will depend on |f/prime(z∗)|.
Quasitheorem 5 The fixed-point iteration zn+1=f(zn)converges near the root z∗
if|f/prime(z∗)|<1.
However, if initial guess is poor, the result may be poor. Worse than that, it may be
unpredictable. This is the cue for lots of lovely pictures of Julia sets and so on, as
in Figure 5.
% p32: iterations and fractals; 04/07/2008 SGLS
x = -1.2:0.005:1.2; y = x;
[x,y] = meshgrid(x,y); z = x + i*y;
c = 0.285 + 0.01*i;
for j = 1:length(x);
for k = 1:length(y);
zn = z(j,k); n = 0;
while (abs(zn)<10 & n<100)
zn = zn.^2 + c; n = n + 1;
end
f(j,k) = n;
end
end
pcolor(x,y,f); shading flat; axis square; colorbar
xlabel(’Re z’); ylabel(’Im z’);
Newton–Raphson
Fixed point iteration is limited by the condition on |f/prime(z∗)|. Worse, it may not be
obvious how to produce an iteration from the original equation except in an artificial
Level sets of the basin attraction of infinity for the map zn+1=z2
n+c, wherec=
0.285 + 0.01i. The color gives the number of the iteration at which |zn|= 10 with a
maximum of 100.
way. Newton–Raphson7iteration converges quadratically and looks particularly
simple for complex functions because the derivative is a complex quantity rather
than a mapping as in the multidimensional case. So no Jacobians.
The iteration is
zn+1=zn−f(zn)
f/prime(zn). (51)
The geometric interpretation in one dimension is that one draws from f(xn)the
tangent to the curve y=f(x)and finds the intersection of the tangent with the
x-axis as the next iterate. In the complex plane, this isn’t so clear. Once again the
choice of starting point can be crucial, and we have Newton fractals, etc. . . Watch
our for multiple roots.
7Question: who was Raphson? Answer: Newton’s programmer. Originally heard from Arieh Iserles. In
reality Raphson was an obscure English mathematician – approximate dates 1648–1715.
Principle of the argument
The methods above are effective and useful. We can use the analytic structure of
complex differentiability to obtain methods that are guaranteed to find zeros in a
domain of the complex plane. The function has to be analytic, and multiple roots
can be confusing, but the method is extremely useful.
We know that /integraldisplay
Cf/prime(z)
f(z)dz=Z−P, (52)
whereZandPare the number of zeros and poles of f(z)in the domain, counted
with multiplicity. So if we have a function of f(z)with no poles inside C, we can
see if it has a zero. Checking to see if a function has poles is usually very easy,
and we can almost always get rid of the poles.
Now we can show similarly that for a function that has no poles inside C,
/integraldisplay
Czf/prime(z)
f(z)dz=/summationdisplay
nzn, (53)
where theznare the zeros we are looking for. If Z= 1, we have found the zero. If
Z= 2, we can use /integraldisplay
Cz2f/prime(z)
f(z)dz=/summationdisplay
nz2
n (54)
to solve forz1andz2. Obviously this can be extended to more and more zeros, but
it is usually easier to change C.
So by computing an integral, we guarantee to find the zero (or zeros) inside C.
This can be very advantageous if one is unsure where the zeros are or if one is
having trouble with starting values for an iterative method. To do this, one needs to
compute complex integrals numerically. How does one do this?
An aside on numerical integration and contour in-
tegrals
Whole books can be written on the topic of numerical integration. Many have,
some more interesting than Piessens et al. (1983) which is a slight elaboration of
the manual for QUADPACK. We will limit ourselves to one quick discussion,
Numerical integration is based on replacing integrals by sums, as in the original
definition of the Riemann integral.
Tip 3 I have never met a physical problem that could not be solved using Riemann
integrals, except for probability integrals where Stieltjes is useful. I have never used
a Lebesgue integral.
The workhorse of most automatic integration is the compound trapezium rule:
/integraldisplay1
0f(z) dz=h/parenleftbig1
2f(0) +f(h) +f(2h) +···+f((n−1)h) +1
2f(h)/parenrightbig
, (55)
wherenh= 1. More general intervals of integration are obvious. Clever ways of
applying this recursively lead to efficient algorithms with potentially high accuracy.
Note that if fisn’t smooth enough, this accuracy will not be reached. This is the
classic trade-off between order and smoothness. Matlab actually uses adaptive
Simpson rule ( quad ) and adaptive Lobatto quadrature ( quadl ), and clearly states
in the help page for the latter: “Function QUAD may be more efficient with low
accuracies or nonsmooth integrands.”
Formally the error for ( 55) isO(h2). Integrating the simple function f(x) =x/(4x2+
1)between 0and 1shows this,as indicated in Figure 6(a). In fact, the compound
trapezium rule does well compared to the Matlab functions, but efficiency has not
been factored into this calculation. The same integrand is integrated around the
unit circle in (b), and the difference is startling. The compound trapezoid rule is
now exponentially accurate. This can be proved for periodic functions, and all the
closed contour integrals we examine will be periodic. Note that for periodic integrals
the rule can be written as
/integraldisplay1
0f(z) dz=hn/summationdisplay
j=1f(jh). (56)
% p33: numerical integration in the complex plane; 04/07/2008 SGLS
f = inline(’x./(4*x.^2+1)’); Iex = log(5)/8;
n = 10.^(1:6); h = 1./n;
for j = 1:length(n)
x = h(j)*(0:n(j));
I1(j) = h(j)*( 0.5*f(x(1)) + sum(f(x(2:end-1))) + 0.5*f(x(end)) );
I2(j) = quad(f,0,1,h(j));
I3(j) = quadl(f,0,1,h(j));
end
subplot(2,2,1)
loglog(h,abs(I1-Iex),’.’,h,h.^2/12,h,abs(I2-Iex),’o’,h,abs(I3-Iex),’s’);
g = inline(’exp(2*pi*i*t)./(4*exp(4*pi*i*t)+1)*2*pi*i.*exp(2*pi*i*t)’);
Ic = 0.5*pi*i;
for j = 1:length(n)
t = 2*pi*h(j)*(1:n(j));
z = exp(i*t); dz = 2*pi*i*z;
I4(j) = h(j)*sum(f(z).*dz);
I5(j) = quad(g,0,1,h(j));
I6(j) = quad(g,0,1,h(j));
end
subplot(2,2,2)
loglog(h,abs(I4-Ic),’.’,h,h.^2/12,h,abs(I5-Ic),’o’,h,abs(I6-Ic),’s’)
To be fair, at least Matlab can integrate complex integrands directly. FORTRAN pro-
grams need separate real and imaginary parts for most canned integration pack-
ages. In addition, infinite integrals do not have this wonderful property, so Matlab
routines are usually faster then.
10−1010−510010−2010−10100
10−1010−510010−2010−10100(a) Absolute errors in the integral of f(x)between 0and1as a function of hfor the
trapezium (dots) and the Matlab routines quad (circles) and quadl (squares). The
solid line shows h2/12. (b) Same for the integral of f(z)around the unit circle.
Some care is required with singular integrands. If the singularity is integrable (frac-
tional powers between −1and 0or logarithms), a change of variable is required
for quadrature rules that use the endpoints to avoid returning NaN’s. From a math-
ematical perspective it’s also a good thing to do, since the quadrature routines
usually require a certain degree of smoothness to achieve optimal convergence.
There are FORTRAN subroutines that take care of singular integrals automatically
(dqagi ,dqawf , etc. . . ). They are mostly changes of variable as discussed, with
two important exceptions. First, infinite integration with an oscillatory integral – this
is specialized, so use the routines. Finally, numerical evaluation of Cauchy principal
value integrals is also specialized so use the routines.
Tip 4 NaN andInf are our friends. They show us we’ve screwed up. We should
be grateful to the IEEE standard. They’re also useful in plotting routines to remove
part of a field that we’re contouring.
An example using Matlab
In a paper dealing with elastic plates, Abrahams et al. (2008) require the complex
zeros of the numerator and denominator, denoted µnandλnrespectively, of the
following function:
D=k4[4 + (3 +ν)(1−ν) sinh2k+ (1−ν)2k2]
sinh2k−k2. (57)
These zeros are related to the Papkovich–Fadle eigenfunctions for a semi-infinite
elastic plate.
By symmetry, we see that if kis a zero (of numerator or denominator), so is −k.
Similarly, ifkis a zero, so is ¯k. Hence we can restrict ourselves to the first quadrant,
and label the desired zeros in an obvious way, moving away from the origin ( µ0=
λ0= 0).
It is a good policy to study the behavior of Din various limits For small |k|,D∼12,
a finite limit. For large |k|with Rek > 0, the hyperbolic sine terms dominate and
D∼(3+ν)(1−ν)k4. Along the imaginary axis, the hyperbolic sine term is bounded
and for large |k|,D∼ − (1−ν)2k4.
We start with the denominator. First, can we find a first approximation to the zeros?
We can see there are no pure real roots and no pure imaginary roots except at the
origin (kdoes not intersect sinkorsinhkexcept at the origin). When |k|is big
and Rek > 0,sinhk∼1
2ek, which grows must faster than k. Hence for the two
to be equal, the imaginary part of kmust be such as to make eksmaller, i.e. near
π/2 +jπwherejis an integer. Substituting into sinhk=±kgives
1
2ex+i(π/2+jπ)+···=1
2(−1)jiex+···=±[x+ i(π/2 + 2jπ) +···]. (58)
Exploiting the ambiguity in sign and solving for the real part gives k∼log (π+ 2jπ)+
i(π/2 +jπ)as a first guess. This is in fact a very good guess, and starting from it,
Matlab has no trouble finding the roots, as shown in Figure 7. Note the use of the
fsolve function and the change from complex to real and back in the implementa-
tion.
function p34
n = 20; k = pd(n); nn = 1:n; kg = log(pi+2*nn*pi) + i*(pi/2+nn*pi);
plot([0 ; k],’r.’); hold on; plot([0 kg],’o’); hold off
xlabel(’Re k’); ylabel(’Im k’)
function k = pd(M)
options = optimset(’Display’,’off’,’TolFun’,eps,’TolX’,eps);
k = zeros(M,1);
for j = 1:M
kg = fsolve(@(k) crel(k),[log(pi+2*j*pi) pi/2+j*pi],options);
k(j) = kg(1) + i*kg(2);
end
function f = crel(k)
k = k(1) + i*k(2);
b = sinh(k)^2-k^2;
f(1) = real(b);
f(2) = imag(b);
The approach to finding the µnis similar, including the initial guess. However,
convergence is more delicate, particularly for ν > 1/4. In that case, the code
starts withν= 1/4and increases νgradually, ensuring convergence. This is an
example of a continuation procedure: start from a case that works and change a
parameter (gently). The iteration can converge to negative real values, and these
are removed.
Note also the special case considered at the beginning. There is one zero, ki, that
does not have the same asymptotic behavior as the others. It is purely imaginary.
It can be seen on the imaginary axis in Figure 8. The different values of νdo not
seem to make much difference to the final plots, but, as mentioned previously, can
0 1 2 3 4 5010203040506070
Re kIm kDots: zeros λnof the denominator of ( 57). unit circle; circles: initial guesses.
cause problems numerically.
Exercise 0.10 Justify the initial guess for kiinp35.m .
function p35
subplot(2,2,1)
k = pn(20,0); plot([0 ; k],’.’)
xlabel(’Re k’); ylabel(’Im k’)
subplot(2,2,2)
k = pn(20,0.25); plot([0 ; k],’.’)
xlabel(’Re k’); ylabel(’Im k’)
subplot(2,2,3)
k = pn(20,0.3); plot([0 ; k],’.’)
xlabel(’Re k’); ylabel(’Im k’)
subplot(2,2,4)
k = pn(20,0.5); plot([0 ; k],’.’)
xlabel(’Re k’); ylabel(’Im k’)
function k = pn(M,nu)
options = optimset(’Display’,’off’,’TolFun’,eps,’TolX’,eps);
k = zeros(M+1,1);
kim = fsolve(@(k) crel(k,nu),[0 2/(1-nu)],options);
for j = 1:M
kg = [log(2*j*pi*sqrt((1-nu)/(3+nu))) j*pi];
if (nu>0.25 & j==1)
for nn = 0.25:0.05:nu
kg = fsolve(@(k) crel(k,nn),kg,options);
end
end
kg = fsolve(@(k) crel(k,nu),kg,options);
k(j+1) = kg(1) + i*kg(2);
end
k = [k(imag(k)<kim(2)) ; i*kim(2) ; k(imag(k)>kim(2))];
k = k(1:M);
function c = crel(k,nu)
k = k(1) + i*k(2);
b = 4 + (3+nu)*(1-nu)*sinh(k)^2 + (1-nu)^2*k^2;
c(1) = real(b);
c(2) = imag(b);
0 2 4 60204060
Re kIm k
0 1 2 3 40204060
Re kIm k
0 1 2 3 40204060
Re kIm k
0 1 2 3 40204060
Re kIm kZerosλnof the numerator of ( 57). (a)ν= 0, (b)ν= 0.3, (c)ν= 0.4, (d)ν= 1/2.
Warning 7 The physically acceptable values for νlie in the range (0,1/2)(materi-
als with −1< ν < 0are thermodynamically possible but do not occur naturally).
The code p35.m has only been tested in that range of νand attempting to use it for
other values of νwill probably result in disaster.
An example using the principle of the argument
In a problem treating with groundwater flow using Laplace transforms, it is neces-
sary to find the zeros of
D=ztanz+K, (59)
whereKis complex. One approach used the principle of the argument.
The code is long and is relegated to the appendix. The critical issue is the presence
of an unexpected zero for complex Kin certain parts of the K-plane. The location
of this zero causes problems with iterative methods or canned packages, because it
is hard to know where it is except in limiting cases, and it leads to poor convergence
for the other roots unless the initial guesses are very good.
Figure 9shows roots for (a) K < 0, (b)Kpure imaginary, (c) K > 0and (d)K
with large positive real part but not pure real. The new root appears in case (d)
andz∼iK. The numerical code uses a series of rectangles in the complex plane,
since something special is obviously happening at Re z=π/2 +jπ. The top
and bottom of the boxes are at ±max (2π,2abs(ReK))respectively: the second
value is dictated by a scaling argument as Im zincreases, while the first is there to
ensure that roots still fit in the box for small |ReK|. The roots are polished after
being found crudely using the contour integral procedure. This polishing is carried
out using a complex version of ( 59) and there are (inconsequential) imaginary parts
in case (a), where the zeros are in fact real. The numerically found zeros in (c) are
real as they should be.
Exercise 0.11 Derive the relation z∼iKfor this new root. When does it exist?
Exercise 0.12 Explain why there are 9points plotted in case (c) of Figure 9.
0 10 20 30−6−4−202x 10−30
Re zIm z
0 10 20 30−1−0.50
Re zIm z
0 10 20 30−1−0.500.51
Re zIm z
0 10 20 300246
Re zIm zThe first 10zeros ranked by (positive) real part of ( 59) in the first quadrant for (a)
K=−3, (b)K= 3i, (c)K= 3(only 9zeros plotted) and (d) K= 5−i.
Other approaches
There are other ways of finding zeros. Sometimes the zeros are related to an
underlying Sturm–Liouville problem. Recalling the Rayleigh–Ritz method, which
gives the eigenvalue as a ratio of integrals, one can use a trial function to obtain a
good first approximation and then iterate. See Porter & Chamberlain (1999).
References
Books:
•Abrahams, I. D., Davis, A. M. J. & Llewellyn Smith, S. G. Matrix Wiener–Hopf
approximation for a partially clamped plate. Q. J. Mech. Appl. Math. , doi:
10.1093/qjmam/hbn004.
•Acton, F . S. Numerical methods that work. Harper & Row, New Y ork, 1970.
•Boyd, J. P . Chebyshev and Fourier spectral methods. Dover, New Y ork, 2nd
ed., 2001.
•Chamberlain, P . G. & Porter, D. On the solution of the dispersion relation for
water waves. Appl. Ocean Res. ,21, 161–166, 1999.
•Piessens, R. et al. Quadpack: a subroutine package for automatic integration.
Springer-Verlag, Berlin. 1983.
Web sites:
•http://en.wikibooks.org/wiki/Fractals/Iterations inthecomplex plane/Julia set
•http://en.wikipedia.org/wiki/Joseph Raphson
•http://en.wikipedia.org/wiki/Newton fractal
ODEs in the complex plane (04/17/08)
Motivation
We start with a problem from fluid mechanics, stability to be precise (see Llewellyn
Smith 1996). The governing equations for inviscid two-dimensional fluid flow can
be written in terms of ψ, the streamfunction such that (u,v) = (ψy,−ψx)– this is
the geophysical convention which is the opposite from the classical convection –
or(ur,uθ) =−r−1(ψθ,ψr)in polar coordinates. The streamfunction satisfies the
vorticity equation
Dq
Dt=∂q
∂t+J(ψ,q) = 0, q =∇2ψ. (60)
Hereqis the scalar vorticity and the Jacobian takes the form J(a,b) =axby−aybx
in Cartesian coordinates and J(a,b) =r−1(arbθ−aθbr)in polar coordinates.
We wish to investigate the stability of unidirectional shear flows, ψ= Ψ(y), and
swirling flows, ψ= Ψ(r). These flows are exact, steady, solutions of ( 60). We
hence write ψ= Ψ +ψ/prime(and hence q=Q+q/prime) and retain only linear terms in the
resulting equation. The result is
∂q/prime
∂t+J(Ψ,q/prime) +J(ψ/prime,Q) = 0, q/prime=∇2ψ/prime. (61)
In the Cartesian case, the coefficients are independent of x, so we may consider
modes of the form eikx. The linearized equation reduces to/parenleftbigg∂
∂t+ ikU/parenrightbigg/bracketleftbigg∂2ψ/prime
∂y2−k2ψ/prime/bracketrightbigg
+ ikQ/primeψ/prime= 0, (62)
whereU= Ψ/prime(y)is the background velocity in the x-direction and Q/primeis the deriva-
tive ofQwith respect to y. In the cylindrical case, the appropriate mode structure
iseinθand the corresponding result is/parenleftbigg∂
∂t+ inΩ/parenrightbigg/bracketleftbigg1
r/parenleftbigg
r∂ψ/prime
∂r/parenrightbigg
−n2
r2ψ/prime/bracketrightbigg
−inQ/prime
r= 0 (63)
with Ω =r−1Ψ/prime(r)the angular velocity. Rayleigh’s equation, properly speaking,
probably refers to the Fourier transform in time of ( 62). Boundary conditions are
ψ/prime= 0 on the boundaries y=±ain the Cartesian case; ψ/prime= 0 atr=aand
finiteness at r= 0 in the polar case. (These are replaced by appropriate decay
conditions if the domain is unbounded.) On physical grounds Q/prime(0) = 0 and Ω =
Ω0+O(r2).
Eigenmodes of the system come from substituting the time dependence eiωt. If
there are solutions for ωwith negative imaginary part for any k, the basic state is
linearly unstable since an arbitrary perturbation will contain some component at the
unstablek, and perturbations grow. If ωis real for all k, the basic state is neutrally
stable: the perturbation neither grows nor decays in time.
This is an eigenvalue problem. Second-order eigenvalue problems are very com-
mon in physical situations, and so we concentrate on second-order equations here.
Matlab has a suite of ODE solvers ( ode45.m , etc. . . ) that solve initial-value prob-
lems for systems of first-order equations. This is not a limitation since such sys-
tems are equivalent to n-order systems. We will limit ourselves to linear ODEs in
this chapter. These are hard enough for the second-order case. For the first-order
case, we can find an explicit solution using integrating factors.
Radial Rayleigh equation
We consider the radial Rayleigh equation written in self-adjoint form:
(−rφ/prime)/prime+/bracketleftbiggn2
r2+nQ/prime
nΩ−ω/bracketrightbigg
φ= 0. (64)
Clearly something strange can happen if the denominator of the second fraction
vanishes, which corresponds to a neutral mode since ωhas to be real. The eigen-
value problem is a boundary value problem, since one has a natural8boundary
condition at the origin and something at large r.
We shall return to ( 64) and its Cartesian counterpart later. Let us consider a more
general problem for now, one in which there is some extra physical effect of small
amplitude that enters the governing vorticity equation (e.g. the beta-effect) and in
which we are solving an initial-value problem based on ( 63). If some different phys-
ical balance holds far from the origin, we need to understand how well-behaved
solutions of the Laplace-transformed version of ( 64) behave for large r. This is a
connection problem (see Olver 1974 for a general presentation).
8Jargon for a condition that is imposed by the equation, so to speak, rather than coming from outside.
Common in discussions of the finite element method.
The problem is hence to solve
(−rφ/prime)/prime+/bracketleftbiggn2
r2+inQ/prime
p+ inΩ/bracketrightbigg
φ= 0 (65)
withφwell-behaved at the origin and obtain the behavior of φfor larger.
Frobenius expansions
First we have to be able to solve near the origin. We recall the classification of the
pointaof the linear second-order ODE
y/prime/prime+p(x)y/prime+q(x)y= 0. (66)
Ordinary point: p(a)andq(a)well behaved. Otherwise: singular point. Regular
singular point: (x−a)p(x)and(x−a)2q(x)bounded as x→a. Irregular singular
point: otherwise.
A series solution of the form/summationtext∞
n=0an(x−a)n+σwith non-vanishing a0always exists
for a regular singular point. Plug into ( 65) nearr=x= 0to obtain
(−σ2+n2)a0rσ−2+O(rσ−1) = 0. (67)
Hence near the origin, φ∼r±n. Obviously only the plus sign is physically accept-
able. The fact that the indices differ by 2n, an integer, means that there may be
complications to do with logarithms. These complications do not affect us here.
What initial condition do we use for our vector (φ(0),φ/prime(0))? Forn> 1, this vector
vanishes and our ODE solver cannot start. This is a typical problem for regular
singular points. There are (at least) three possible solutions in this case:
1.Start integrating at r=δsmall withφ(δ) =δnandφ/prime(δ) =nδn−1. This is
just forcing the solution to be the Frobenius expansion for small r. I dislike
introducing an error into the problem.
2.Work withg=r−nφ. Theng(0) = 1 andg/prime(0) = 0 . The ODE for gis
g/prime/prime+2n+ 1
rg/prime−inQ/prime
r(p+ inΩ)g= 0. (68)
Note that when calculating g/prime/prime(0), which is required numerically, one has to use
l’Hopital’s rule. Since Q/prime(0)∼qr, we find
g/prime/prime(0) + (2n+ 1)g/prime/prime(0) =inq
p+ inΩ0. (69)
3.Work withh=φ1/n. This can be unpleasant in the complex case, because of
branch cuts (especially when 0< n < 1which is not physically possible for
the Rayleigh equation unless one is working only in a sector which makes no
sense for the basic state).
Irregular singular points
Frobenius series only work at regular singular points. At irregular singular points,
there is no nice theory. The best approach is to use the substitution y= eS(x)and
solve as an asymptotic series. For ( 65), this is unnecessary and using Ω =O(r−2)
andQ=O(r−∞)9, we findφ=O(rn)for larger.
Exercise 0.13 Work out the behavior near the irregular singular point at infinity for
f/prime/prime+1
rf/prime+/bracketleftbigg
(1 + e−r2)k2−n2
r2/bracketrightbigg
f= 0. (70)
Connection coefficients
The connection coefficient ∆is the coefficient of the rnterm at large r. It is shown
for the Gaussian vortex, Q(r) = e−r2in Figure 10. The code uses strategy 1.
% p41.m 04/10/08 SGLS
function [nn,res]=p41
global p n
nn=0:0.1:4;
n=2;
9Decays faster than any power of r.
pp=1+i*nn;
r0=1e-4;
rmax=100;
for j=1:size(pp,2)
p=pp(j);
[t,y]=ode45(@f,[0 rmax],[1 0 0 0]);
res(1,j)=y(end,1);
res(2,j)=y(end,3);
end
plot(nn,res)
xlabel(’Im p’); ylabel(’\Delta’)
function f=f(r,y)
global p n
f = zeros(4,1);
f(1) = y(2);
f(3) = y(4);
if (r==0)
temp = i*n*2/(p+i*n*0.5)*(y(1)+i*y(3));
f(2) = real(temp)/(2*n+2);
f(4) = imag(temp)/(2*n+2);
else
temp = i*n*qp(r)/r/(p+i*n*om(r))*(y(1)+i*y(3));
f(2) = -(2*n+1)/r*y(2) + real(temp);
f(4) = -(2*n+1)/r*y(4) + imag(temp);
end
function om=om(t)
om=(1-exp(-t.^2))/2./t.^2;
function qp=qp(t)
qp=-2*t.*exp(-t.^2);
Exercise 0.14 Obtain the expressions for Ω(r)andQ/prime(r)for the Gaussian vortex.
Exercise 0.15 Rewrite p41.m to use both other strategies to deal with the regular
singular point. Which of the three is easiest?
Exercise 0.16 Discuss the connection problem for ( 70).
0 0.5 1 1.5 2 2.5 3 3.5 4−0.4−0.200.20.40.60.81
Im p∆Real (blue) and imaginary (green) parts of the connection coefficient for the Gaus-
sian vortex with n= 2.
Integrating along complex paths
A problem of Boyd
We have looked at eigenvalue problems for complex-value functions, for which
the complex attribute was mostly an algebraic property, and for which the special
properties of complex analyticity were not used. We now consider a situation where
it is very useful to solve an ODE along a path in the complex plane.
The following problem is discussed in Boyd (2001; §7.11). Find the eigenvalues λ
of
fyy+/parenleftbigg1
y−λ/parenrightbigg
= 0 withf(a) =f(b) = 0 ,a< 0andb>0. (71)
Hereyis our real independent variable. The singularity at the origin means that
this is not a regular Sturm–Liouville problem, and the solutions are singular. The
remedy is to use a path in the complex plane. After stretching the interval trivially
onto [−1,1], write
y=x+ i∆(x2−1). (72)
The solutions f(y)has a branch point at the origin in the complex y-plane, and the
choice of whether the path goes above or below the origin is given by the physics
of the problem. Here we must go below the real axis, so ∆>0.
This is now a boundary-value problem. These are more difficult to program. Luckily,
Matlab has one: bvp4c . However functions like bvp4c need an initial guess. One
could divide the complex λ-plane up into little boxes and see what eigenvalue was
returned by the initial guess, but this would be painful. Continuation won’t help
much because there is no parameter to vary.
Exercise 0.17 Try this approach.
Instead we look at methods to return all the eigenvalues. Note also that the path in
the complex plane doesn’t give a very useful estimate for the eigenfunctions, which
are physical for real y.
Pseudospectral methods in one paragraph
One can classify numerical methods to solve differential equations chronologically:
finite differences finite elements, spectral. Spectral methods are particularly good
at obtaining high accuracy in certain problems. One subcategory of spectral meth-
ods, often called pseudospectral, enforces equations at certain points in the do-
main.
A new strand of the literature developed pointing out the intimate connection with
linear algebra. One can represent a function f(x)as a vector fof the values
off(xi)where thexiare discretization points. Then the derivative f/prime(x)can be
represented at those points by a differentiation matrix Dacting on f. There is
hence a very simple representation for differential equations.
Excellent books on this topic are Fornberg (1996), Boyd (2001) and Trefethen
(2000), which is particularly pedagogical and also has Matlab code that can be
downloaded. I tend to use the Matlab toolbox of Weideman & Reddy (2000), be-
cause it is more complete.
Solution to Boyd’s problem
We solve ( 71) using the toolbox of Weideman & Reddy (2000). The x-variable is
discretized at the appropriate Chebyshev points with N= 40 , and the differential
equation is turned into a generalized eigenvalue problem. Accuracy is outstanding:
the first 7eigenvalues
ans =
0.125053784915595 + 0.284985539605466i
-0.296730301617421 + 0.520320308706465i
-0.638802533479911 + 0.000261422784429i
-1.217501201556951 + 0.563348974818304i
-1.601895926942392 + 0.007822859918900i
-2.726011668004498 + 0.489965769815868i
-3.101209886006712 + 0.070299331841965i
are plotted in Figure 11are essentially good to machine accuracy.
% p43.m Solve Boyd problem using pseudospectral method SGLS 04/10/08
N=42;
D=0.5;
a=-6;b=6;
[x,DM]=chebdif(N,2);
s=x+i*D*(x.^2-1);
y=a+(b-a)/2*(s+1);
D2=DM(:,:,2);
D1=DM(:,:,1);
M=4/(b-a)^2*( diag(1./(1+i*2*D*x).^2)*D2 - diag(i*2*D./(1+i*2*D*x).^3)*D1 ) + diag(1./y);
v=eig(M(2:N-1,2:N-1));
[y,k]=sort(-real(v));
v=v(k);
plot(v(1:7),’.’)
Boyd (2001; §7.5) has an excellent discussion of how to determine which zeros
obtained from a pseudospectral approach are accurate, based on their behavior
0.5 1 1.5 2 2.5−2−1.5−1−0.500.511.52First 7eigenvalues of ( 71) solved using a pseudospectral method.
asNis increased.
Orr–Sommerfeld and Rayleigh equations
Both Trefethen (2000) and Weideman & Reddy (2000) provide codes to solve the
Orr–Sommerfeld equation. The Orr–Sommerfeld equation is the viscous counter-
part of the Rayleigh equation, which is strictly speaking only valid for Poiseuille-
Couette basic flow. The Trefethen code p40.m is extremely simple. The corre-
sponding figure are shown in Figure 12. One eigenvalue is just in the right half-
plane.
% p40.m - eigenvalues of Orr-Sommerfeld operator (compare p38.m)
R = 5772; clf, [ay,ax] = meshgrid([.56 .04],[.1 .5]);
for N = 40:20:100
% 2nd- and 4th-order differentiation matrices:
[D,x] = cheb(N); D2 = D^2; D2 = D2(2:N,2:N);
S = diag([0; 1 ./(1-x(2:N).^2); 0]);
D4 = (diag(1-x.^2)*D^4 - 8*diag(x)*D^3 - 12*D^2)*S;
D4 = D4(2:N,2:N);
% Orr-Sommerfeld operators A,B and generalized eigenvalues:
I = eye(N-1);
A = (D4-2*D2+I)/R - 2i*I - 1i*diag(1-x(2:N).^2)*(D2-I);
B = D2-I;
ee = eig(A,B);
i = N/20-1; subplot(’position’,[ax(i) ay(i) .38 .38])
plot(ee,’.’,’markersize’,12)
grid on, axis([-.8 .2 -1 0]), axis square
title([’N = ’ int2str(N) ’ \lambda_{max} = ’ ...
num2str(max(real(ee)),’%16.12f’)]), drawnow
end
Project 1 Examine the irregular neutral modes of the Orr–Sommerfeld equation
using paths in the complex planes. Relevant references: Engevik, Lin.
−0.8 −0.6 −0.4 −0.2 00.2−1−0.50N = 40 λmax = −0.000078179499
−0.8 −0.6 −0.4 −0.2 00.2−1−0.50N = 60 λmax = −0.000078191186
−0.8 −0.6 −0.4 −0.2 00.2−1−0.50N = 80 λmax = −0.000078191704
−0.8 −0.6 −0.4 −0.2 00.2−1−0.50N = 100 λmax = −0.000078192756Eigenvalues of the Orr–Sommerfeld equation for R= 5772 , Outout 40 of Trefethen
(2000).
References
Publications:
•Boyd, J. P . Chebyshev and Fourier spectral methods. Dover, New Y ork, 2nd ed,
2001.
•Fornberg, B. A practical guide to pseudospectral methods. Cambridge Univer-
sity Press, Cambridge, 1998.
•Llewellyn Smith, S. G. Vortices and Rossby-wave radiation on the beta-plane.
Ph.D. thesis, University of Cambridge, 1996.
•Olver, F . W. J. Asymptotics and special functions. A K Peters, Natick, 1997.
•Weideman, J. A. C. & Reddy, S. C. A MATLAB differentiation matrix suite. ACM
Trans. Math. Software ,25, 465–519, 2000.
Integral transforms (04/23/2008)
Fourier series
Definition
Fourier series are the natural language to describe periodic functions. In fact, their
use is more general. If f(x)is a function of the real variable x, we can write
f(x) =1
2a0+∞/summationdisplay
n=1ancosnx+∞/summationdisplay
n=1bnsinnx, (73)
where the coefficients in the series are given by
an=1
π/integraldisplay2π
0f(x) cosnxdx, b n=1
π/integraldisplay2π
0f(x) sinnxdx. (74)
Note that ( 73) must be viewed as holding in the range 0< x < 2π. The equality
holds under certain conditions on f, and investigating this and similar questions
was a major priority of mathematicians in the first half of the 20th century. We will
be as expeditious as usual. Note that if f(x)has a discontinuity at x0, the series
on the right-hand side of( 73) tends to the average of f(x−
0)andf(x+
0).
There is a natural extension of ( 73) from trigonometric to complex exponentials:
f(x) =∞/summationdisplay
n=−∞cneinx. (75)
Iff(x)is real then c−n=¯cn. The coefficients are given by
cn=1
2π/integraldisplay2π
0f(x)e−inxdx. (76)
Exercise 0.18 Work out the relation between anandbnin (73) andcnin (75).
Example 0.10 Let us solve Laplace’s equation ∇2u= 0 in the circle r < a with
boundary condition u=f(θ)onr=a. The coefficients of the Laplacian in polar
coordinates are independent of θ, since
∇2u=1
r∂
∂r/parenleftbigg
r∂u
∂r/parenrightbigg
+1
r2∂2u
∂θ2= 0. (77)
Hence we expand in a Fourier series in θ:
u=∞/summationdisplay
n=−∞un(r)einθ. (78)
Periodicity means this goes through well and we obtain
d2un
dr2+dun
dr−n2
r2un= 0. (79)
We decompose the boundary condition in the same way as f(θ) =/summationtext∞
n=−∞fneinθ.
At the origin, we require unto be finite. Hence solving the ODE ( 79) with the
appropriate boundary conditions gives u=fn(r/a)|n|. Putting this altogether, we
obtain
u(r,θ) =∞/summationdisplay
n=−∞fn/parenleftBigr
a/parenrightBign
einθ=1
2π/integraldisplay2π
0f(φ)∞/summationdisplay
n=−∞ein(θ−φ)/parenleftBigr
a/parenrightBign
dφ
=1
2π/integraldisplay2π
0f(φ)/bracketleftBigg
1 +∞/summationdisplay
n=1ein(θ−φ)(r/a)n+∞/summationdisplay
n=1e−in(θ−φ)(r/a)n/bracketrightBigg
dφ
=r2−a2
2π/integraldisplay2π
0f(φ)
a2−2arcos (φ−θ) +r2dφ. (80)
The geometric series converge for r < a . This is Poisson’s integral formula for
the Dirichlet problem in a circle. Figure 13shows the value of uas a function of φ
inside the circle. We use the trapezium rule since this is a periodic integral.
% p51.m Poisson’s integral formula SGLS 04/14/08
a = 1.5; r = 0.5;
P = inline(’sin(3*phi).*exp(-(phi-1).^2)./(a^2 - 2*a*r*cos(phi-theta)+r^2)’,’phi’,’theta’,’r’,’a’);
n = 100; h = 1./n;
phi = 2*pi*h*(1:n); dphi = 2*pi;
th = (0:0.01:1)*2*pi;
for j = 1:length(th)
theta = th(j);
u(j) = h*sum(P(phi,theta,r,a).*dphi);
end
plot(th,u,th,cos(3*th).*exp(-(th-1).^2))
xlabel(’\theta’); ylabel(’u’)
Exercise 0.19 Work out the solution to the Neumann problem in the disk r < a
with∂u/∂ =g(θ)on the boundary. Write a Matlab program to plot the output.
Warning 8 When writing a function f(x)as a series of expansion functions fn(x),
as for a Fourier series, always multiply the equation by fn(x)and integrate. This
approach can cope when the boundary values of f(x)andfn(x)do not match up.
Example 0.11
Sine and cosine series are just special cases of general Fourier series and are not
pursued here. One can think about how to generalize Fourier series appropriately.
One way is to characterize expansion function by their zeros, another is by the way
0 1 2 3 4 5 6 7−1−0.500.5
θuPlot ofu(φ,0.5)(blue) andu(φ,1.5)(green) where usolves the Laplace equation
in the circle r<1.5and boundary condition u(φ,1.5) = sin 3φe−(φ−1)2.
the Sturm–Liouville problem they solve. A final way is to think about the “continuum
limit”, in which there are more and more modes. We continue along these lines.
Fourier transforms
Fourier series are defined on an internal and have a countably infinite number of
modes (discrete sum over integer). One can think about taking a large and large
interval, and more and more modes. Intuitive reasoning about the Riemann sum
takes us in a cavalier fashion to the Fourier transform and inverse transform
F(k) =/integraldisplay∞
−∞f(x)e−ikxdx, f (x) =1
2π/integraldisplay∞
−∞F(k)eikxdk. (81)
The existence of an inverse transform, which is the manifestation of Fourier’s the-
orem is critical to the use of Fourier transforms. Abstractly, we Fourier transform a
problem, solve for the Fourier transform, and return to the original variable.
One of the most important facts about Fourier transforms for our purposes are their
analyticity properties. The Fourier transform defined in ( 81) is complex because of
the exponential, but the presence of the integral sign in it and in particular in the
inverse transform lead to results that make use of analyticity. Again we do not
worry about the conditions on f(xfor these: provided fis well-enough behaved,
fis analytic for large enough |k|, although there may be branch cuts extending to
infinity.
Most Fourier transforms that one comes across in textbooks can be evaluated by
hand. The inverse transforms are not so easy, but often succumb to contour inte-
gration.
Example 0.12 Calculate the inverse Fourier transform of
F(k) =1
k4+ 1. (82)
We need to compute
I=1
2π/integraldisplay∞
−∞eikx
k4+a4dk. (83)
Forx> 0, we close in the upper half-plane, where the integrand has simple poles
ateiπ/4ande3iπ/4. Hence
I= i/parenleftBigg
eix(1+i) /√
2
4e3iπ/4+eix(−1+i)/√
2
4e9iπ/4/parenrightBigg
=1
2e−x/√
2cos (x+π/4). (84)
For negative x, we can use the symmetry properties of the Fourier transform to
obtain the general result with |x|replacingx.
This is an example which can be carried out by hand. Let’s try something more
esoteric using a little numerical calculation. The following function is certainly not
the result of computing a Fourier transform:
F(k) =e−1/(k2+1)2
k2+ 1. (85)
This has essential singularities at ±i. Note that for large |k|, the exponential term
looks like 1and the denominator ensures convergence for x= 0. Forx> 0we can
compute the inverse transform just by doing the integral around a little circle about
the pole. The results are shown in Figure 14. Note that the imaginary part of f(x)
is zero to machine accuracy.
% p52.m inverse Fourier transform of essential singularity SGLS 04/16/08
a = 1.5; r = 0.5;
F = inline(’exp(i*k*x-1./(k.^2+1).^2)./(k.^2+1)’,’k’,’x’);
n = 100; h = 1./n;
k = i + 0.5*exp(i*2*pi*h*(1:n)); dk = 0.5*2*pi*i*exp(i*2*pi*h*(1:n));
xp = 0:.01:5;
for j = 1:length(xp)
fp(j) = h*sum(F(k,xp(j)).*dk);
end
k = -i + 0.5*exp(i*2*pi*h*(1:n)); dk = 0.5*2*pi*i*exp(i*2*pi*h*(1:n));
xm = -5:.01:0;
for j = 1:length(xm)
fm(j) = -h*sum(F(k,xm(j)).*dk);
end
plot(xp,real(fp),xp,imag(fp),’--’,xm,real(fm),xm,imag(fm),’--’)
xlabel(’k’); ylabel(’f’)
Warning 9 The Riemann–Lebesgue lemma guarantees that the Fourier transform
of a bounded function tends to 0ask→ ∞ (this is immediately obvious along the
imaginary axis). Hence if you are dealing with a function F(k)that does not have
this property, it is probably unphysical or wrong.
Exercise 0.20 Explain when inverse Fourier transforms are discontinuous.
Exercise 0.21 Obtain the inverse transform of F(k)as an infinite sum (maybe even
a doubly infinite sum). Can you sum it numerically in an efficient way?
−5 0 5−0.4−0.3−0.2−0.100.10.20.3
kfSolution to ( 71) computed using Real (solid) and imaginary (dashed) parts of the
inverse transform f(x)of (85).
Using Fourier transforms
The critical property of Fourier transforms from a practical perspective is that they
enable one to replace differentiation, an analytic concept, with multiplication, an
algebraic concept. Fourier transforms are appropriate for equations with constant
coefficients, or with very special and simple coefficients, and with appropriate de-
cay properties.
We have (formally)
f/prime(x)→ikF(k), xf (x)→iF/prime(k). (86)
The proof is simple: integrate by parts and wave your hands.
As an example, we solve the ODE
f/prime/prime+1
xf/prime−a2f= 0 (87)
whereais real and positive. Multiply by xand apply the rules ( 86) to obtain
id
dk[(−a2−k2)F] + ikF= 0. (88)
This has solution F(k) =A(a2+k2)−1/2. We have a formal solution, which contains
a branch cut. Pick A=πso thatF(0) =/integraltext∞
−∞f(x) dx=πa−1. One can show that
this solution is the one usually written K0(ax). Note that we have only found one
solution. This is because all the solutions grow exponentially.
We can’t express f(x)as an integral around a singularity any longer. We need first
to pick a branch. The transform F(k)has branch points at ±cia. We can’t have
branch cuts cross the inversion contour. The natural cuts are from ±ato±∞, with
a2+k2real and positive on the real axis. Consider now x> 0. We can deform the
integration contour up and around the branch cut, so that
f(x) =1
2π/integraldisplay∞
12πe−ux
i(u2−a2)1/2i du=/integraldisplay∞
1e−ux
(u2−a2)1/2du. (89)
Using this cut has led to exponential convergence in the integral. We can see
thatf(x)is singular as x→0. This is rapid enough to ensure that essentially
any change of variable works. To use a general-purpose integration package, it
is advisable to remove the integrable singularity at u= 1 by writingu= 1 +v2.
Figure 15showsf(x)for positive xanda= 1 using the Matlab quad function.
Because of the exponential decay, we truncate the integral at v= 50/x, where the
exponential in the integrand is approximate e−50≈2×10−22, which is comfortably
smaller than the error estimate for quad (10−6by default).
% p53.m inverse Fourier transform for K_0 SGLS 04/14/08
fint = inline(’exp(-(1+v.^2)*x)./sqrt(2+v.^2)*2’,’v’,’x’);
x = 0.01:.01:5;
for j = 1:length(x)
f(j) = quad(@(v) fint(v,x(j)),0,50/sqrt(x(j)));
end
plot(x,f,x,besselk(0,x),’.’);
xlabel(’k’); ylabel(’f(x), K_0(x)’)
Exercise 0.22 From ( 89), discuss the singularity in K0(x)asx→0.
Exercise 0.23 From ( 87) discuss the behavior of the solutions near the irregular
singular point at infinity.
Most wave problems that can be dealt with have constant coefficients, so these
kinds of ODEs in kwill not appear. There can still be branch cuts associated with
the continuous spectrum, which we gloss over for now.
0 1 2 3 4 5012345
kf(x), K0(x)Inverse Fourier transform solution to ( 71) (blue);K0(x)(green).
h-transforms and other transforms
In our inexorable pursuit of generalization, we arrive at the idea of h-transforms
(Bleistein & Handelsman 1986). We will use sandkas the transform variables,
more or less according to tradition. The h-transform of f(x)is given by
F(λ) =/integraldisplay
f(x)h(λx) dx. (90)
The range of integration depends on the function h. Our notation is left deliberately
vague. The inversion integral is not specifically mentioned here. In general, all
inversion integrals come from the Fourier inversion theorem, which is the result
underlying ( 81). This indicates that the majority of these transforms are just the
Fourier transform by another name.
In this way, we have the (one-sided) Laplace transform and inverse
F(s) =/integraldisplay∞
0f(x)e−sxdx, f (x) =1
2πi/integraldisplay
ΓF(s)esxdx. (91)
where Γis the Bromwich contour, a vertical contour parallel to the imaginary axis
and to the right of all singularities of F(s). For large |k|with positive real part, F(s)
is analytic. In fact, the inverse transform returns 0forx < 0, so be careful with
Laplace transforms of functions which are non-zero for x< 0.
We also have the Mellin transform
F(s) =/integraldisplay∞
0f(x)xs−1dx, f (x) =1
2πi/integraldisplayc+i∞
c−i∞F(s)s−xds, (92)
which can be obtained from the Laplace transform by a change of variable. The
Mellin transform is not an h-transform. The domain of analyticity of the Mellin
transform is usually between two vertical lines in the complex s-plane.
Less immediately obvious is the Hankel transform
F(k) =/integraldisplay∞
0f(x)Jν(kx)xdx, f (x) =/integraldisplay∞
0F(k)Jν(kx)kdk, (93)
which can be motivated for n= 0 by the two-dimensional Fourier transform of
a radially symmetric function. We requires ν≥ − 1/2. There are some other
definitions that include square roots.
The generalized Stieltjes transform is
F(s) =sν/integraldisplay∞
0f(x)
(1 +sx)νdx. (94)
Again there are other definitions. I don’t even know the inverse transform.
The Kontorovich–Lebedev transform is
F(s) =/integraldisplay∞
0f(x)Kix(s) dx, f (x) =2
π2x/integraldisplay∞
0F(s)Kis(x) sinh (πs)sdx.(95)
This is unusual because the index of the modified Bessel function (sometimes
called Macdonald function) occurs, rather than its argument.
Sneddon (1972) is a detailed and useful exposition of most of the integral trans-
forms one can think of. An exhaustive list can be found in Zayed (1996), while
Debnath & Bhatta (2006) is slightly less general. Davies (2002) is a clear peda-
gogical work that is good on complex analysis.
We do not give examples of the use of these transforms here, but will do so in
Chapter 53. In most cases, the choice of transform to use is dictated by the geom-
etry of the system (Fourier for straight boundaries, Mellin in wedges for the Laplace
equation in two dimensions, Kontorovich–Lebedev in wedges for the Laplace equa-
tion in three dimensions).
Hilbert transforms
The Hilbert transform has a slightly different origin, and is related very closely to
the notion of analyticity. We start with an example; solve ∇2u= 0in the half-plane
y> 0withu(x,0) =g(x)andu→0asy→ ∞ . Then we can Fourier transform in
xand obtain
d2U
dy2−k2U= 0, (96)
withU(0) =G, the Fourier transform of g(x), andU→0asy→ ∞ . The solution
is clearlyU=Ge−|k|y, where the modulus sign can be viewed as a placeholder for
||/epsilon1(see Chapter 6). Then the inverse Fourier transform of this result gives
f=1
2π/integraldisplay∞
−∞G(k)e−|k|ydk=y
π/integraldisplay∞
−∞g(ξ)
(x−ξ)2+y2. (97)
We have used the convolution theorem, which states that the Fourier transform of
f∗g(x) =/integraldisplay∞
−∞f(ξ)g(x−ξ) dξ (98)
isF(k)G(k).
Exercise 0.24 Prove the convolution theorem.
Exercise 0.25 Show that the inverse Fourier transform of πe−|k|yisy(x2+y2)−1.
Exercise 0.26 Show that as y→0,u(x,y)→g(x). The best approach is to
consider different regions of the integral separately.
UNDER CONSTRUCTION (I.E. WRONG) Since uis a harmonic function, it can be written as the real part of an
analytic function f(z). Taking g(x)to be real, we see immediately see that
f(z) =1
πZ∞
−∞g(ξ)
z−ξdξ, (99)
which is just Cauchy’s integral formula. The imaginary part of this gives a new function
v(x, y) =y
πZ∞
−∞g(ξ)
(x−ξ)2+y2dξ. (100)
With a nod to ( 99) we define the Hilbert transform as
H(k) =1
π−/integraldisplay∞
−∞h(x)
x−kdx. (101)
Note that the Hilbert transform is not an h-transform. The inversion formula is
h(x) =−1
π−/integraldisplay∞
−∞H(k)
k−xdk. (102)
The transform of h(x)can be viewed as the convolution of h(x)with (πx)−1. The
Fourier transform of this function is i sgnk.
Exercise 0.27 Show that the Fourier transform of (πx)−1issgnk.
Exercise 0.28 Show that applying the Hilbert transform twice to f(x)returns −f(x)
(use the convolution theorem).
fromu. Using Fourier transforms, we can show that V= i sgnkU. The Hilbert
transform is used extensively in signal processing.
Project 2 Write a report on the use of Hilbert transforms in signal processing, in-
cluding examples using some of the complex techniques we have been discussing.
References
Publications:
•Bleistein, N. & Handelsman, R. A. Asymptotic expansions of integrals. Dover,
New Y ork, 1986.
•Davies, B. Integral transforms and their applications. Springer, New Y ork, 2002.
•Debnath, L, & Bhatta, D. Integral transforms and their applications. Chapman
& Hall/CRC, Boca Raton, 2007.
•Sneddon, I. N. The use of integral transforms. Mc-Graw Hill, New Y ork, 1972.
•Zayed, A. I. Handbook of function and generalized function transformations.
CRC, Boca Raton, 1996.
The Fast Fourier Transform (04/22/08)
Fourier coefficients
The Fast Fourier Transform (FFT) is a transform by name, but one that takes a finite
set of numbers (e.g. data at points) to a finite set of coefficients. As such it is more
like a Fourier series (function to coefficients) than a Fourier transform (function
to function). The Fast refers to efficiency, not to the definition of the transform,
and one can argue that the FFT is just an implementation of the Discrete Fourier
Transform (DFT), where Discrete refers to its working on values at points.
Hence we start by considering Fourier coefficients in Fourier series: how to com-
pute them and some of their properties. In textbook cases, we can find the coeffi-
cients by hand. (It would be easier to work in the interval (−π,π)for some of the
integrals, but for the DFT the original interval (0,2π)is convenient.)
Example 0.13 Compute the Fourier series of f(x) =−sgn (x−π), i.e. 1for0<
x < π and−1forπ < x < 2πand then repeated periodically. From the definition
ofcn, we have
cn=1
2π/integraldisplay2π
0f(x)e−inxdx=1
2π/integraldisplayπ
0e−inxdx−1
2π/integraldisplay2π
πe−inxdx
=2
nπ(103)
Note then−1decay for large n. The Fourier sum with nranging from −50to50is
shown in Figure 16, along with a filtered version where the amplitude of the higher
modes is reduced.
% p61.m Fourier series for -sgn(x-pi) SGLS 04/16/08
nn = (-50:50)’;
c = 2/pi*(-1).^((nn-1)/2)./nn; c(1:2:end) = 0;
d = c.*exp(-abs(nn).^2/500);
x =(-1:0.01:1)*2*pi;
f = sum(exp(i*nn*x).*(c*ones(size(x))));
g = sum(exp(i*nn*x).*(d*ones(size(x))));
plot(x,f,x,g)
xlabel(’x’); ylabel(’f’)
Note that the discontinuities in f(x)leads to oscillations near the discontinuities.
There is pointwise convergence, but for a finite truncation of the sum, there is
always an overshoot, which moves closer to the point of discontinuity. This is the
Gibbs phenomenon. To use these functions in real applications, one usually needs
to filter, and some care is required to avoid losing too much of the high-wavenumber
energy.
Quasitheorem 6 The Fourier coefficients of a function f(x)with a discontinuity in
f(j)(x)behave like n−j−1for largen.
−8 −6 −4 −2 0 2 4 6 8−1.5−1−0.500.511.5
xfFourier coefficients of a step function with and without filtering.
The Fourier coefficients of δ(x−a)are simplycn= e−ina/(2π), i.e. they do not
decay with n. Progressively spikier generalized functions, δ/prime(x−a), and so on,
have coefficients that go like njwherejis the number of derivatives on δ. All this
can (and should) be done properly; see for example Lighthill (1959) for a brief and
dare I say challenging account.
Now let us try a more complicated function from the previous chapter: f(x) =
x(4x2+ 1)−1. A closed form expression can be found for the coefficients cn, but
we want to compute it numerically. The function f(x)is not periodic, so we do not
quite have the nice properties of the trapezoid rule as applied to periodic functions.
However, the exponential term is pure real at the end points, so the imaginary part
is periodic. We use the periodic version of the the rule, thereby committing a small
error. Our 101-term sum is a good approximation, as shown in Figure 17.
% p62: numerical integration for Fourier coefficients 04/16/2008 SGLS
f = inline(’x./(4*x.^2+1)’);
n = 100; h = 1./n;
c = zeros(101,1);
x = 2*pi*h*(1:n);
for n = -50:50
c(n+51) = h*sum(f(x).*exp(-i*n*x));
end
x =(-1:0.01:1)*2*pi;
−8 −6 −4 −2 0 2 4 6 8−0.4−0.3−0.2−0.100.10.20.3
xfFourier series and exact values of x(4x2+ 1)−1.
fs = sum(exp(i*nn*x).*(c*ones(size(x))));
plot(x,fs,x,f(x))
xlabel(’x’); ylabel(’f’)
Exercise 0.29 Find a closed form for the cnofp62.m . Y ou will end up with special
functions. Write a Matlab program to compare the error in the numerical integration
ofp62.m ; examine how the error depends on the number of terms in the quadrature
rule and in the Fourier sum.
We now argue in the following way. If we knew the function, or data, only at equis-
paced points along the real axis: h, . . . , 2πwith values fm=f(xm),m= 1...M ,
then we could view these data as approximating a period function with f(0) =
f(2π). The trapezoidal rule would then become exponentially accurate. We would
have found the coefficients as a linear combination of the data,
cm=N/summationdisplay
n=1fne−imnh, (104)
and the function can be represented as the series
fn=M/summationdisplay
m=−Mcmeimhn. (105)
The DFT is a formalization of this idea, showing that it all works and tidying up the
notation (we have not used the optimal intervals above).
Trefethen (2000; Chapter 3) has a very clear discussion of the FFT. He uses a
slightly different notation and considers both matrix-based and FFT approaches to
representing functions on periodic grids.
The DFT
One of the major problems with the DFT and the FFT is notation and order of
indexing. Matlab has a self-consistent approach, which is not necessarily intuitive.
We follow Matlab’s definition.
>> help fft
FFT Discrete Fourier transform.
FFT(X) is the discrete Fourier transform (DFT) of vector X. For
matrices, the FFT operation is applied to each column. For N-D
arrays, the FFT operation operates on the first non-singleton
dimension.
FFT(X,N) is the N-point FFT, padded with zeros if X has less
than N points and truncated if it has more.
FFT(X,[],DIM) or FFT(X,N,DIM) applies the FFT operation across the
dimension DIM.
For length N input vector x, the DFT is a length N vector X,
with elements
N
X(k) = sum x(n)*exp(-j*2*pi*(k-1)*(n-1)/N), 1 <= k <= N.
n=1
The inverse DFT (computed by IFFT) is given by
N
x(n) = (1/N) sum X(k)*exp( j*2*pi*(k-1)*(n-1)/N), 1 <= n <= N.
k=1
See also FFT2, FFTN, FFTSHIFT, FFTW, IFFT, IFFT2, IFFTN.
Overloaded functions or methods (ones with the same name in other directories)
help uint8/fft.m
help uint16/fft.m
help gf/fft.m
help iddata/fft.m
Ignore the multi-dimensional and zero-padding aspects. We have a transform that
goes from a vector with entries xnto a vector with entries Xk, according to
Xk=∞/summationdisplay
n=1xne−2πi(k−1)(n−1)/N, 1≤k≤N, (106)
xn=1
N∞/summationdisplay
k=1Xke2πi(k−1)(n−1)/N, 1≤n≤N. (107)
Compare this to ( 104) and ( 105). The notation is designed to deal with Matlab’s
suffix convention that starts at 1.
The first thing to do is check that ( 107) and ( 107) really are self-inverse. Substitute
the first into the second; this gives the double sum
xm?=1
N∞/summationdisplay
k=1/parenleftBigg∞/summationdisplay
n=1xne−2πi(k−1)(n−1)/N/parenrightBigg
e2πi(k−1)(m−1)/N
=1
N∞/summationdisplay
n=1xn/parenleftBiggN−1/summationdisplay
j=0e2πij(m−n)/N/parenrightBigg
. (108)
The final sum is a geometric progression with ratio e2πi(m−n)/N. Ifm/negationslash=n, the sum
yields a fraction with numerator 1−e2πi(m−n)= 0 sincemandnare integers. If
m=n, every element in the sum is 1and there are Nterms in the sum. Hence
xm?=1
N∞/summationdisplay
n=1xnNδmn=xn (109)
and we are done.
WRONG: ISSUES WITH COEFFICIENTS. One of the reasons this is useful is how it relates to derivatives. If we
view Xnas representing a function f(x), with the function being sampled at points x= 2π(n−1)/N.then
f(x) =1
N∞X
k=1Xkei(k−1)x(110)
with the Matlab convention. We can now differentiate:
f/prime(x) =1
N∞X
k=1i(k−1)Xke2πi(k−1)x, (111)
so the coefficients of the derivative f/prime(x)areYk= i(k−1)Xk. This is tremendously useful.
Clearly the FFT of a data vector is related to the Fourier coefficients as the length
of the vector increases. It also has intrinsic interest in signal processing, which we
will not discuss here. Our interest lies in applications so continuum problems.
FFT
The FFT proper refers to a fast way to calculate the DFT of a data vector xnof
sizeN. There are Nterms to calculate, and each is a sum of Nterms, so the
naive estimate is that the process takes N2operations. In fact, the transform can
be done inNlogNoperations, as pointed out by Cooley & Tukey (1965)10. It turns
out that they had been anticipated by Gauss. This is not a course about algorithms,
so we will not explain the algorithm here, but to be brief it relies on a recursive way
of computing the terms in the sum, once it has been written in a clever way. Hence
the logarithmic dependence. This recursion requires a certain amount of overhead,
and it is not useful to continue it down to its final value, which is a sum of 1 term,
since it is straightforward and fast to compute the DFT of a small vector.
The question of what is meant by small is a good one. The answer will depend
on the architecture and memory (cache especially) of the machine being used.
Platform-dependent implementation exist and those are fast. A particularly nice
approach is FFTW, which runs test cases before executing a calculation and deter-
mines the fastest approach. Matlab now uses FFTW.
Exercise 0.30 Write a Matlab program to examine the speed of FFTW in matlab.
10I don’t know if anyone reads this paper any more. I never have.
Investigate the command fftw .
Solving linear PDEs with FFTs
We can use some programs from Trefethen (2000) to illustrate this. The numerical
derivatives of two simple functions is shown in Figure 18.
% p5.m - repetition of p4.m via FFT
% For complex v, delete "real" commands.
% Differentiation of a hat function:
N = 24; h = 2*pi/N; x = h*(1:N)’;
v = max(0,1-abs(x-pi)/2); v_hat = fft(v);
w_hat = 1i*[0:N/2-1 0 -N/2+1:-1]’ .* v_hat;
w = real(ifft(w_hat)); clf
subplot(3,2,1), plot(x,v,’.-’,’markersize’,13)
axis([0 2*pi -.5 1.5]), grid on, title(’function’)
subplot(3,2,2), plot(x,w,’.-’,’markersize’,13)
axis([0 2*pi -1 1]), grid on, title(’spectral derivative’)
% Differentiation of exp(sin(x)):
v = exp(sin(x)); vprime = cos(x).*v;
0 2 4 6−0.500.511.5function
0 2 4 6−101spectral derivative
0 2 4 60123
0 2 4 6−202
max error = 9.5735e−13Spectral differentiation of two functions. Output 4 of Trefethen (2000).
v_hat = fft(v);
w_hat = 1i*[0:N/2-1 0 -N/2+1:-1]’ .* v_hat;
w = real(ifft(w_hat));
subplot(3,2,3), plot(x,v,’.-’,’markersize’,13)
axis([0 2*pi 0 3]), grid on
subplot(3,2,4), plot(x,w,’.-’,’markersize’,13)
axis([0 2*pi -2 2]), grid on
error = norm(w-vprime,inf);
text(2.2,1.4,[’max error = ’ num2str(error)])
Exercise 0.31 Explain the code in p5.m
From this to solving simple linear PDEs is but a small step. Figure 19shows the
solution of the variable coefficient wave equation
ut+/bracketleftbigg1
5+ sin2(x−2)/bracketrightbigg
ux= 0. (112)
The time-integration uses leapfrog. There’s nothing wrong with leapfrog in general,
but careful numerical analysis textbooks (e.g. Iserles 1996) would warn you to be
very careful: there’s no guarantee that coupling some spatial differentiation strategy
with a time-stepping routine will not end in disaster. And these books are right.
However, people tend to be more casual in physics and engineering, and the proof
of the pudding is in the eating: it works here.
% p6.m - variable coefficient wave equation
% Grid, variable coefficient, and initial data:
N = 128; h = 2*pi/N; x = h*(1:N); t = 0; dt = h/4;
c = .2 + sin(x-1).^2;
v = exp(-100*(x-1).^2); vold = exp(-100*(x-.2*dt-1).^2);
% Time-stepping by leap frog formula:
tmax = 8; tplot = .15; clf, drawnow, set(gcf,’renderer’,’zbuffer’)
plotgap = round(tplot/dt); dt = tplot/plotgap;
nplots = round(tmax/tplot);
data = [v; zeros(nplots,N)]; tdata = t;
for i = 1:nplots
for n = 1:plotgap
t = t+dt;
v_hat = fft(v);
w_hat = 1i*[0:N/2-1 0 -N/2+1:-1] .* v_hat;
w = real(ifft(w_hat));
vnew = vold - 2*dt*c.*w; vold = v; v = vnew;
end
data(i+1,:) = v; tdata = [tdata; t];
end
waterfall(x,tdata,data), view(10,70), colormap(1e-6*[1 1 1]);
axis([0 2*pi 0 tmax 0 5]), ylabel t, zlabel u, grid off
Spectral differentiation of two functions. Output 5 of Trefethen (2000).
Interpolation
Balmforth, Llewellyn Smith & Y oung (2001) study critical layers in a two-dimensional
vortex. In the critical layer, the streamfunction takes the form
ψ≡ − (y2/2) +ϕ(θ,t), ϕ (θ,t)≡ˆϕ(t)e2iθ+ ˆϕ∗(t)e−2iθ, (113)
and the vorticity advection equation is
ζt+∂(ψ,ζ +βy)
∂(θ,y)=ζt+yζθ+ϕθζy+βϕθ= 0. (114)
The evolution of ˆϕ(t)is then obtained from
iˆϕt=χ+/angbracketlefte−2iθζ/angbracketright, where /angbracketleft···/angbracketright is/angbracketleftf/angbracketright ≡ −/integraldisplay
dy/contintegraldisplaydθ
2πf(θ,y,t ). (115)
The principal value integral in ( 115) is necessary because ζ∝y−1as|y| → ∞ .
However, henceforth we will omit the dash on the understanding that we take the
principal values of all integrals to assure convergence.
When written in terms of F=ζ+βy, the equation for ζreduces to the advection-
diffusion equation
Ft+yFθ+ϕθFy= 0. (116)
(Fcan be used instead of ζinterchangeably in the /angbracketleft/angbracketrightterm since /angbracketlefty/angbracketright= 0.) Balm-
forth et al. (2001) solved the equations with an operator splitting scheme based
on the algorithm developed by Cheng & Knorr (1976) for the Vlasov equation and
subject to the boundary condition in y:ζ→0asy→ ±∞ . In order to save com-
puting the evolution of unneeded angular harmonics, they considered a periodicity
inθofπrather than 2π.
To avoid dealing with an infinite domain, the range is truncated in yand the vorticity
equation is solved over the region −L < y < L . This requires boundary condi-
tions aty=±L. To increase the accuracy of this truncation of the domain, they
used the asymptotic solution for large y. The slow algebraic decay of the vorticity
complicates the numerical scheme over the original Cheng & Knorr algorithm.
An integration step over the interval [t,t+τ]is divided into three stages:
1.Advect inθfor half a time step. This amounts to solving
Ft+yFθ= 0 (117)
over [t,t+τ/2], leaving ˆϕunchanged. The exact solution is Fα(y,θ) =F(y,θ−
yτ/2,t). This shift in θis computed using Fourier interpolation.
2.Advect inyfor a complete time step. This is done using a spline method and
you are referred to the original paper.
3.Advect inθfor another half time step. This gives F(y,θ,t +τ) =Fβ(y,θ−yτ/2)
as the new vorticity distribution. Except at the first and final time steps, this step
can be combined with the first one and a shift in θis only carried out once per
time step.
The main practical limitation on the time step (other than τ/lessmuch1for the sake of
precision) is that one cannot shift in yover more than one grid point. To avoid this
situation, it is easiest to limit the time step to ensure that shifts over more than one
grid point do not take place.
COEFFICIENT PROBLEMS AGAIN. The step that we focus on is the Fourier interpolation. The y-dependence is
parametric, and what we care about is obtaining f(x−a), knowing the coefficients Xk. Once again, we write f(x−a)in terms of the coefficients:
f(x−a) =1
N∞X
k=1Xkei(k−1)(x−a). (118)
Hence the coefficients of the shifted function are Xke−ai(k−1).
Exercise 0.32 Write a Matlab program to carry out interpolation using the FFT.
Examine the accuracy of this procedure as a function of the number of points by
comparing the numerical answer to the exact shifted function.
References
Publications:
•Balmforth, N. J., Llewellyn Smith, S. G. & Y oung, W. R. Disturbing vortices.
J. Fluid Mech. ,426, 95–133, 2001.
•Cheng, C. Z. & Knorr, G. The integration of the Vlasov equation in configuration
space. J. Comp. Phys. ,22, 330–351, 1976.
•Cooley, J. W & Tukey, J. W. An algorithm for the machine computation of the
complex Fourier series. Math. Comp. ,19, 297–301, 1965.
•Iserles, A. A first course in the numerical analysis of differential equations.
Cambridge University Press, Cambridge, 1996.
•Lighthill, M. J. An introduction to Fourier analysis and generalised functions.
Cambridge University Press, Cambridge, 1958.
Web sites:
•http://www.fftw.org
Solving differential equations using transforms (04/22/08)
General procedure
This is an approach that is discussed in surprisingly few books11. It is equivalent
to a standard transform in many cases, but gives some insight into the analytic
properties of the solution that is obtained. We will also be able to obtain more
than just one solution, which was a problem with the Fourier transform example of
Chapter 34.
For a given differential equation for the function f(z), consider the formal solution
for the function:
f(z) =/integraldisplay
CK(z,t)h(t) dt. (119)
We allowzandtto be complex, and Cis a path in the complex plane to be
discussed later. The function K(z,t)is the kernel. Typical examples are the Fourier
kernel, eizt, the Laplace kernel, ezt, the Euler kernel, (t−z)−ν, the Mellin kernel,
t−z, and so on. The choice is dictated by the problem at hand.
We now substitute ( 119) into the governing equation for f. In general, we haven’t
made any progress, unless we can operate on the integrand using integration by
parts to obtain a simpler equation for g(z). In the Fourier case, we could remove
11I’ve seen it in one or two, but I can’t remember where now.
derivatives and terms of the form tf(t). The result is an integral in closed form,
[g(z,t)]C, that we annihilate by choosing Cappropriately. There are two possi-
bilities:Cis a closed contour containing all the singularities of K(z,t)h(t), orC
is an open contour beginning and ending at zeros of g(z,t). This is most easily
illustrated using an example.
Example 0.1412We look at Hermite’s equation
f/prime/prime−2zf+ 2νf= 0. (120)
Use the Laplace kernel and substitute into the ODE. Integrate by parts to find
/integraldisplay
Cezt[(t2+ 2ν+ 2)h(t) + 2th/prime(t)] dt−2[eztth(t)]C= 0. (121)
This equation can be satisfied by choosing h(t)so that is satisfies the ODE in t
inside the integral. Hence
h(t) =t−ν−1e−t2/4. (122)
Next we pick Cso that [t−νezt−t2/4]C= 0. The position of the zeros of this express
depends on the value of ν. The integrand vanishes at infinity in the sectors |argt|<
π/4and|π−argt|< π/ 4. It also vanishes at the origin if ν < 0. The final
12From my Part II Lecture notes.
expression for f(z)is
f(z) =/integraldisplay
Ct−ν−1ezt−t2/4dt. (123)
Ifνis not an integer, there is a branch cut, that we can take along the negative
real axis with the usual branch. If νis a positive integer or 0, there is a pole at
the origin around which we can integrate to get a non-trivial answer. If νis not a
negative integer or zero, we have one path from left to right, and from left back to
itself looping around the cut. If ν < 0one can also take a contour starting at the
origin. Ifνis a negative integer, one can take paths starting from the origin and
going to left or right. If νis a positive integer, there is only path circling the origin
and one from left to right. When νis an integer, there is no cut.
This example works because the ODE for h(t)is second order. This is usually the
requirement for this technique to be useful. In some cases, one can find more than
two paths. Then only two of them can give linearly independent solutions.
The representation ( 123) gives an explicit way to calculate Hermite functions. Let
us work out the two linearly independent solutions for ν= 1/3(essentially an
arbitrary value). We carry out the integral numerically; the exponential convergence
means we can just truncate. This is true irrespective of the value of z, and this
representation works just fine for complex z. Maple knows about Hermite functions,
so we use the Maple function from within Matlab. The first integral is parallel to the
real axis. The second loops around the branch cut and is proportional to the Maple
Hermite function. In general, it is not terribly clear from Figure 20which solutions
have been computed and how one can distinguish them. A quick analysis of the
irregular singular point at infinity, writing f= eS, shows that
S/prime/prime+S/prime2−2zS/prime+ 2ν= 0. (124)
The dominant balances for large |z|areS∼z2−(ν+ 1) logzandS∼νlogz,
corresponding to
f∼z−ν−1z−ν−1ez2, f ∼zν. (125)
From Figure 20, the function H1looks like it will grow exponentially, while H2will
not.
% 71.m Hermite functions SGLS 04/22/08
f1 = inline(’exp(-(t+1i).^2/4+z*(t+1i)).*(t+1i).^(-nu-1)’,’t’,’nu’,’z’);
f2 = inline(’exp(-(1+1i*y).^2/4+z*(1+1i*y)).*(1+1i*y).^(-nu-1)*1i’,’y’,’nu’,’z’);
nu = 1/3; z = -1.5:.05:1.5;
for j = 1:length(z)
H1(j) = quad(@(t) f1(t,nu,z(j)),-20,20);
H2(j) = quad(@(t) f1(t,nu,z(j)),-20,1);
H2(j) = conj(H2(j)) - H2(j) + quad(@(t) f2(t,nu,z(j)),-1,1);
end
fH = pi*16/9*mfun(’HermiteH’,nu,z);
−1.5 −1 −0.5 0 0.5 1 1.5−15−10−5051015
xf(1/3,x)
Re H1
Im H1
Re H2
Im H2
(16π/9)HHermite functions f(1/3,(x)forxreal. For comparison the function (16π/9)H(x)
from Matlab is plotted.
plot(z,real(H1),z,imag(H1),z,real(H2),z,imag(H2),z,fH,’.’)
legend(’Re H_1’,’Im H_1’,’Re H_2’,’Im H_2’,’(16\pi/9)H’,’Location’,’SouthEast’)
xlabel(’x’); ylabel(’f(1/3,x)’)
Exercise 0.33 Compute the solutions for integer ν.
Exercise 0.34 Try larger values of zand complex z.
The method of steepest descents
We would like to be able to understand the behavior of a function defined by an
integral representation from the integral itself. The ISP analysis does not tell you
which of the possible behaviors your particular integral will have. The results we
find are not convergent series solutions, but asymptotic expansions, which are just
fine for our purposes. Remember that given a series with term anδn(x), where the
δn(x)are gauge functions, that is functions that are getting smaller in an asymptotic
sense, we say that the series converges if the answer gets better, for all x, if we
take more and more terms. For an asymptotic expansion, the answers gets better
ifxgets larger say (or closer to x0); ultimately the answer gets worse if we add
more and more terms. Note that all convergent series are asymptotic.
Tip 5 Some people would say you only ever need the first term in any asymptotic
expansion. Others say calculate as many as you like.
Many of the integral representations use the Laplace kernel, and a lot of machinery
has been developed to analyze such integrals. Good introductions can be found in
Bender & Orszag (1978) and Hinch (1991). A more general approach is given in
Bleistein & Handelsman (1986) using Mellin transforms.
Watson’s lemma
Consider the integral
F(x) =/integraldisplayM
0e−xtf(t),dt, (126)
whereMmay be infinite if the integral exists. Then close to the origin, fhas the
asymptotic behavior f(t)∼ar1ts1+ar2ts2+···, with−1<r 1<r 2<···, then
F(x)∼ar1Γ(s1+ 1)x−s1−1+ar2Γ(s2+ 2)x−s2−1+···, asx→ ∞,(127)
an asymptotic expansion. Hence the behavior of F(x), which looks like a Laplace
transform, for large xdepends only on the behavior of f(t)for smallt. This is
usually the easy way of doing things. The harder way is to find the behavior for
smallx, knowing the behavior for large t.
Exercise 0.35 Prove Watson’s lemma for loop integrals:
F(x) =/integraldisplay0+
−∞extf(t) dt∼/summationdisplay2πiarix−si−1
Γ(−si)(128)
with the same notation as before for f(t); the contour starts from minus infinity
below the real axis, loops anticlockwise around the real axis and returns above
the real axis to minus infinity. Y ou will need to use Hankel’s representation of the
gamma function.
Definition 0.2 The Gamma function is defined for Re z >0by
Γ(z) =/integraldisplay∞
0e−ttz−1dt. (129)
From the recurrence relation Γ(z+ 1) =zΓ(z), one can extend this definition to the
whole complex plane excluding negative integers.
For a lovely little book on the Gamma function, see Artin (1964). The Gamma
function is the natural extension of factorials to non-integer numbers.
Theorem 4 (Bohr–Mellerup) The only continuous log-convex function satisfying
the recurrence relation f(x+ 1) =xf(x)andf(1) = 1 is the Gammma function.
Exercise 0.36 Prove the recurrence relation for the Gamma function. Discuss the
nature of the singularities of the Gamma function: location, nature, residue. . .
Laplace’s method
Laplace’s method, simply stated, is Watson’s lemma associated to a change of
variable. We are looking at integrals of the form
F(x) =/integraldisplayA
0e−h(t)xf(t) dt (130)
(Acan be infinite). For large x, the exponential term wipes everything out, except
whereh/prime(t)vanishes (if that happens). We can try the change of variable u=h(t),
with the chain rule yielding dt= du/h/prime[h−1(u)]. This change of variable will fail
whenh/prime(t) = 0 : these are critical points.
Practically speaking then, we work out where h/primevanishes, and consider these
points and the endpoints. The contribution from t0goes like some power of tmul-
tiplied by e−h(t0)x. so we only need to consider the smallest values of h(t0)(in
magnitude). To obtain more terms, it is best to do the change of variable and use
Watson’s lemma. For the leading term, one can calculate it by hand (usually true
for the first correction term too).
Watson’s lemma provides the formal justification, but one can also treat this method
informally using arguments on what is small and what is big: the crucial issue is
the size of the region that contributes to the dominant behavior. This is especially
useful if the variable xenters the integrand not only in the exponential. Note finally
that the functions f(t)can be slightly badly behaved: discontinuous, not infinitely
differentiable and so on. Provided the integral exists, the method works.
Example 0.15 Find the behavior of the Gamma function for large positive x. This
is a classic. Start by writing
Γ(x) =/integraldisplay∞
0e−t+xlogtt−1dt. (131)
This doesn’t look right, but if we differentiate everything in the exponential, we get
−1+xt−1which vanishes at t=x. Hence the action happens when t=O(x). One
can continue informally, but we might as well make the change of variable t=xu.
Then
Γ(x) =xx−1/integraldisplay∞
0ex(−u+log u)u−1du∼xx−1/integraldisplay∞
0e−x+(u−1)×0−1
2(u−1)2du. (132)
Theu−1has been pulled out and replaced by its value at the critical point, 1. Take
thee−xout, do the Gaussian integral after changing the endpoints (exponential
error) and ignore the dots. The results is
Γ(x)∼√
2πxx−1/2e−x. (133)
This is Stirling’s approximation.
To get the whole series, one needs to carry out the change of variable mentioned,
so that
Γ(x) =xx−1/integraldisplay∞
0e−xvu−1du
dvdv. (134)
There is a good way to do this: use Lagrange’s inversion theorem (Bellman 2003):
Theorem 5 Letf(z)andg(z)be analytic functions of zaround the point z=awith
u=a+/epsilon1g(u). (135)
If|/epsilon1g(z)|<|z−a|, (135) has one root, u=u(a), in the neighborhood of z=a,
and
f(u) =f(a) +∞/summationdisplay
n=1/epsilon1n
n!/parenleftbiggd
da/parenrightbiggn−1
[f/prime(a)g(a)”n]. (136)
Exercise 0.37 Find the first three terms in the asymptotic expansion of the Gamma
function. Use Lagrange’s theorem.
To see how well we are doing, let us compute the Gamma function for large x. The
results show that for x > 1we are doing a very good job both numerically and
using the approximation ( 133).
% p72.m Gamma function asymptotics SGLS 04/21/08
f = inline(’exp(-t).*t.^(x-1)’,’t’,’x’);
x = logspace(0,1,21);
for j = 1:length(x)
g(j) = quad(@(t) f(t,x(j)),0,50);
end
gas = sqrt(2*pi)*x.^(x-0.5).*exp(-x);
loglog(x,g,x,gamma(x),’.’,x,abs((gas-gamma(x))./gas),x,1/12./x,’.’)
xlabel(’x’); ylabel(’\Gamma(x) and approximations’)
10010110−410−2100102104106
xΓ(x) and approximationsEuler’s integral ( 129) (blue) and Matlab Γ(x)(green dots). x−x+1/2exΓ(x)−1(red)
and1/(12x)(blue dots).
The method of stationary phase
A natural question is what happens with the Fourier kernel. A similar approach, due
originally to Kelvin, carries through. It was first derived to obtain the free surface
of surface gravity waves at large distances form the source and is still very useful
for such problems. The method is slightly more delicate than Laplace’s method,
because the amplifying effect of the exponential is not exponential, so to speak,
but depends on rapid cancellation of trigonometric functions. Usually all zeros
have to be taken, and higher-order corrections are hard to obtain, because the
contributions from the end points can be important. Once again, the method works
for fairly general integrals of the form
G(x) =/integraldisplayb
aeixtf(t)ddt. (137)
We won’t go through this technique. It is important however, particularly since it
can be viewed as underpinning ray theory. See Lighthill (1979) for an interesting
account. If you really want to get into ray theory, see Bleistein (1984).
Project 3 Develop an Eulerian ray solver using the ideas of Sethian, Osher and
others that computes amplitudes for situations with background flows where the
energy is no longer conserved. Warning: this is non-trivial.
Steepest descents
The method of steepest descents can be viewed as the generalization of the former
two methods to the case of complex zandh(t). Ironically, however, it requires the
functions to be analytic which is more stringent than the previous conditions. This
is not a problem when using integral transforms, and the method is very powerful.
The method works on integral of the form
H(x) =/integraldisplay
Cezh(t)f(t)ddt, (138)
whereCis some contour in the complex plane.
The basic idea is to deform the contour of integration to one along which we make
the argument of the integral real, giving us the exponential increase and decrease
of Laplace’s method. Obviously one has to be careful about deforming contours
through poles. There are critical points where h/prime(t) = 0 and one then finds a nice
combination of subcontours that go from startpoint to endpoint. Here surface plots
are extremely useful in understanding the topology of the complex plane.
Equations for these subcontours are curves of constant phase, since we want the
real part to change. The correct curves are curves of steepest descent: the real
part rises to a maximum at the critical point. One doesn’t even need to compute
the exact contours, because all that really matters is the topology of the real and
imaginary parts. Near the critical points, all that matters are local approximations.
There will usually be a question of which phase in a fractional power to use: this
corresponds to the correct steepest descent and not ascent curve. The standard
critical points have two curves going through them (saddle); higher order points will
have more (monkey saddle).
Example 0.16 I made up the following:
F(z,a) =/integraldisplay
Cezs−s3/3sads. (139)
Ifais not an integer there is a branch cut along the negative real axis; we take the
principal branch. We could rescale sto isolate the zterm to recover the canonical
form, but we shan’t bother. There are critical points at s=z1/2(two of them) and
the equations for the path of constant phase are ( s=ξ+ iη,z=x+ iy)
Im(zs−s3/3) = Im(2/3)z3/2. (140)
These curves and critical points are shown in Figure 22for different values of z.
Note that there are different curves going through the different critical points, except
whenzis real. The presence of the branch cut does not affect the curves on this
figure, but means that when we deform contours, we may have to veer off the
curves of constant phase to avoid going through a branch cut.
% p73.m Paths of constant phase SGLS 04/22/08
xi = -5:0.1:5; eta = xi; [xi,eta] = meshgrid(xi,eta); s = xi + 1i*eta;
subplot(2,2,1)
z = 1.2; h = z*s - 1/3*s.^3; sc = sqrt(z); ihz = imag(2/3*sc^3);
contour(xi,eta,imag(h),[ihz -ihz])
hold on; plot(real(sc)*[1 -1],imag(sc)*[1 -1],’k*’); hold off
xlabel(’\xi’); ylabel(’\eta’);
subplot(2,2,2)
z = -0.8*i; h = z*s - 1/3*s.^3; sc = sqrt(z); ihz = imag(2/3*sc^3);
contour(xi,eta,imag(h),[ihz -ihz])
hold on; plot(real(sc)*[1 -1],imag(sc)*[1 -1],’k*’); hold off
xlabel(’\xi’); ylabel(’\eta’);
subplot(2,2,3)
z = 2.4-0.3*i; h = z*s - 1/3*s.^3; sc = sqrt(z); ihz = imag(2/3*sc^3);
contour(xi,eta,imag(h),[ihz -ihz])
hold on; plot(real(sc)*[1 -1],imag(sc)*[1 -1],’k*’); hold off
xlabel(’\xi’); ylabel(’\eta’);
subplot(2,2,4)
z = -0.4+2.2*i; h = z*s - 1/3*s.^3; sc = sqrt(z); ihz = imag(2/3*sc^3);
contour(xi,eta,imag(h),[ihz -ihz])
hold on; plot(real(sc)*[1 -1],imag(sc)*[1 -1],’k*’); hold off
xlabel(’\xi’); ylabel(’\eta’);
ξη
−5 0 5−505
ξη
−5 0 5−505
ξη
−5 0 5−505
ξη
−5 0 5−505Curves of constant phase of zs−s3. (a)z= 1.2; (b)z=−0.8i; (c)z= 2.4−0.3i;
(d)z=−0.4 + 2.2i.
Let us now discuss C. From the exponential, we see that Ccan start and end
in|args|< π/ 3and the wedges obtained by rotating this sector by 2π/3. We
can manufacture two linearly independent solutions by specifying the start and end
sectors (if both are the same, the integral is zero by Cauchy’ theorem). Let us
start in third quadrant and finish along the real axis. Then in (a) we can deform
the contour to one that goes through both critical points ±z1/2. In (b) and (c) we
go along the blue curve and only through the critical point in the fourth quadrant.
In (d) we go through the critical point in the third quadrant out to infinity in the
second quadrant, then back along the red curve through the other critical point out
to toward the real axis.
We do case (b) so that zis negative imaginary. The critical point is sc=z1/2=√
0.8e−iπ/4(we are treating the square root here as a function, not as a multifunc-
tion). There are no problems with branch cuts when we deform on the blue contour.
All that matters is the local behavior of the argument of the exponential near z1/2,
which is given by
h(s) =h(sc)+(s−sc)h/prime(sc)+1
2(s−sc)2h/prime/prime(sc)+···= (2/3)z3/2−3z1/2(s−z1/2)2+···,
(141)
where we just keep the quadratic term. Doing the integrals gives
F(z,a)∼/radicalbig
π/3e2/3z3/2za/2−1/2. (142)
Figure 23compares this approximation to the numerically computed integral. No-
tice how the integral has been evaluated using two straight lines avoiding the origin.
% p72.m Steepest descent asymptotics SGLS 04/25/08
f1 = inline(’exp(z*exp(-2*pi*i/3)*u-u.^3/3).*(u*exp(-2*pi*i/3)).^a*exp(-2*pi*i/3)’,’u’,’z’,’a’);
f2 = inline(’exp(z*(u-i)-(u-i).^3/3).*(u-i).^(a-0.5)’,’u’,’z’,’a’);
a = 1.5; z = -i*logspace(0,2,21); zc = sqrt(z);
for j = 1:length(z)
F(j) = quad(@(u) f1(u,z(j),a),10,2/sqrt(3));
F(j) = F(j) + quad(@(u) f2(u,z(j),a),-1/sqrt(3),10);
end
Fas = sqrt(pi/3)*zc.^(a-0.5).*exp(2/3*zc.^1.5);
semilogy(abs(z),abs(F),abs(z),abs(Fas),’.’)
xlabel(’|z|’); ylabel(’F(z,-3/2)’)
Exercise 0.38 Work out the behavior for the other three cases.
Exercise 0.39 Find the ODE satisfied by F(z,a)from ( 139).
Exercise 0.40 Analyze the behavior of the Hankel function defined by
H(1)
ν=1
πi/integraldisplay∞+πi
−∞ezsinht−νtdt (143)
x
0 20 40 60 80 10010−5010−4010−3010−2010−101001010
|z|F(z,−3/2)
INCORRECT GRAPH?
with|argz|<1
2π.
Stokes’ phenomenon
Figure 22shows that the topology of critical points and steepest descent curves
changes as zchanges. Hence the form of the asymptotic expansion can change
in different regions of the z-plane as one crosses lines called Stokes lines. This is
called Stokes’ phenomenon. It is real and important: it means that we do not have
enough flexibility in our expansion functions to represent the asymptotic expansion
of our function in a single formula. For nonlinear problems, one needs a more
general approach.
Warning 10 Watch out for notation. There are two sets of lines: Stokes and anti-
Stokes, and authors use them to mean opposite things.
In fact, the asymptotic expansion does not change discontinuously across as Stokes
line. There is a transition region, first pointed out by Berry (1989). Some authors
have used Stokes lines to understand complex ray theory (Chapman et al. 1999).
References
Publications:
•Artin, E. The gamma function. Holt, Rhinehart and Winston, New Y ork, 1964.
•Bellman, R. Perturbation techniques in mathematics, engineering & physics.
Dover, Mineola, 2003.
•Bender, C. M. & Orszag, S. A. Advanced mathematical methods for scientists
and engineers. McGraw-Hill, ?, 1978.
•Berry, M. V. Uniform asymptotic smoothing of Stokes’ discontinuities. Proc.
R. Soc. Lond. A ,422, 7–21, 1989.
•Bleistein, N. Mathematical methods for wave phenomena. Academic Press,
Orlando, 1984.
•Bleistein, N. & Handelsman, R. A. Asymptotic expansions of integrals. Dover,
New Y ork, 1986.
•Chapman, S. J., Lawry, J. M. H., Ockendon, J. R. & Tew, R. H. On the theory of
complex rays. SIAM Rev. ,41, 417–509, 1999.
•Hinch, E. J. Perturbation methods. Cambridge University Press, Cambridge,
1991.
•Lighthill, M. J. Waves in fluids. Cambridge University Press, Cambridge, 1978.
Laplace transforms (05/12/08)
Definition and inverse
We have already seen the definition of the Laplace transform:
F(p) =/integraldisplay∞
0e−pxf(x) dx. (144)
Iff(x) =O(eax)for largex, the integral converges for Re p > a (and maybe
for Rep=a) and the Laplace transform F(p)is hence defined and analytic for
Rep>a . The function defined by ( 144) can often be continued analytically outside
this region. The function f(x)also has to be civilized near the origin.
Example 0.17 Consider the transform of xν. We have
F(p) =/integraldisplay∞
0e−pxxνdx=p−ν−1/integraldisplay∞
0e−uuνdu= Γ(ν+ 1)p−ν−1(145)
on making the change of variable px=u. From the behavior at the left endpoint,
the transform is defined for ν >−1. The analytic properties in terms of pfrom
the definition show that F(p)is defined for Re p > 0. For Rep= 0, there is
convergence at infinity only if ν <−1which is not allowed. However, the result
Γ(ν+ 1)p−ν−1can be extended over the whole complex plane, taking into account
possible branch cuts and singularities at the origin. The function F(p)of (145)
exists forν <−1, but is not the transfor of a “normal” furction.
The definition ( 144) is formally that of the one-sided Laplace transform, for which
only the behavior of f(x)forx > 0is of interest. This is built explicitly into the
inversion formula
f(x) =1
2πi/integraldisplayc+i∞
c−i∞F(p)epxdp, (146)
wherecis a real number such that all the singularities of F(p)have real part smaller
thanc. Then for x < 0, one can close the contour in the right half-plane and
obtain zero. For poles, the 2πiprefactor cancels nicely with that term in the residue
theorem.
Warning 11 If you are using the one-sided Laplace transform of f(x), don’t try to
use negative values of x. The transform-inverse pair will always return 0, even if
you thought f(x)was non-zero for x< 0.
The main point of the Laplace transform comes from the formula for the transform
of a derivative, which nicely builds in the initial condition. The transform of f/prime(x)is
pF(p)−f(0). Formulas for f/prime/prime(x)and so on can be obtained straightforwardly. Let
us also remind ourselves of the convolution theorem.
Theorem 6 (Convolution theorem). If f(x)andg(x)have Laplace transforms F(p)
andG(p)respectively, then the inverse Laplace transform of F(p)G(p)is the con-
volution (f∗g)(x), where the convolution is defined by
(f∗g)(x) =/integraldisplayx
0f(ξ)g(x−ξ) dx. (147)
We discussed inverting Fourier transforms using the calculus of residues and the
same process works here, although if branch cuts happen, one has to be more
careful. Let us do an example that comes from a PDE to learn something about
Fourier series at the same time. We wish to solve the problem
ct=cxx withcx= 0onx= 0andcx=f(t)onx=a. (148)
This is a one-dimensional diffusion equation with imposed flux boundary condi-
tions.
We start using a Fourier series approach. Write
c(t) =∞/summationdisplay
n=0cn(t) cos (nπx/a ). (149)
How do we know this? Well we don’t really at this point, although clearly we are do-
ing just fine with the left-hand boundary condition. If we keep sines and cosines, we
will have trouble there. However, we definitely have non-zero cxat the right-hand
boundary, which doesn’t seem to mesh with the behavior of the cosine function.
We heed warning 8and multiply ( 148) by cos (mπx/a )and integrate. The rule is
one can substitute the expansion as soon as it is no longer differentiated, and then
use the orthogonality relation/integraltexta
0cos (mπx/a ) cos (nπx/a ) dx=a/epsilon1−1
mδmn, where/epsilon1j
is the Neumann symbol, defined to be 0forj= 0 and 2otherwise. One of the
boundary terms does not cancel and the result is
/integraldisplaya
0cos (mπx/a )∞/summationdisplay
n=0˙cncos (nπx/a ) dx=a/epsilon1−1
m˙cm
= [cos (mπx/a )cx]a
0−/integraldisplaya
0cos (mπx/a )∞/summationdisplay
n=0(−nπ/a )2cos (nπx/a ) dx
= (−1)mf(t) +a/epsilon1−1
m(mπ/a )2cm. (150)
We hence obtain the inhomogeneous equation
˙cm+ (mπ/a )2cm= (−1)m/epsilon1m
af(t). (151)
This can be solved using an integrating factor, yielding
cm= (−1)m/epsilon1m
a/integraldisplayt
0e−(mπ/a )2(t−τ)f(τ) dτ. (152)
Note that this equation is in convolution form and can be viewed as the Green’s
function response convolved with the forcing.
The second approach is the Laplace transform ( 148) in time. Writing the resulting
dependent variable as C(p,x), we have
pC=Cxx withCx= 0onx= 0andCx=F(t)onx=a. (153)
The solution to this equation is
C=cosh√px√psinh√paF(p). (154)
Now let us invert this transform. By the convolution theorem, the answer is g∗f,
wheregis the inverse transform of the fraction in ( 154). This fraction does not
in fact have a branch cut (check by expanding). It does have lots of singularities
where√pa=nπifor integern. These singularities are simple poles and are hence
atp=−(nπ/a )2. This raises the ugly question of which square root to take in the
root, but the answer is that it doesn’t matter; we just taken one. The singularities
withn > 0are clearly simple poles; the singularities at p=−(nπ/a )2can be
shown to be simple poles. We have
g=1
a+∞/summationdisplay
n=1cosh (nπix/a)
1
2acosh (nπi)e−(nπ/a )2t=1
a+∞/summationdisplay
n=1(−1)m2
acos (nπx/a )e−(nπ/a )2t.(155)
which matches with ( 152).
Figure 24showsc(t,x)for different values of tfor the (arbitrary) forcing function
f(t) =E1(t), whereE1(t)is the exponential integral. The solution is computed by
carrying out the convolution integral numerically and summing the Fourier series.
The answer is acceptable, but the program is very slow. The behavior near x= 1
look suspiciously flat too; presumably more modes are needed to synthesize the
non-zero slope there.
% p81: numerical integration for Laplace solution 04/25/2008 SGLS
f = inline(’exp(-(m*pi/a)^2*(t-tau)).*expint(tau)’,’tau’,’t’,’m’,’a’);
a = 1.4; MMAX = 20;
n = 100; h = 1./n;
x = a*h*(0:n); tt = 0.5:0.5:1;
c = zeros(size(x));
clf; hold on
for j = 1:length(tt)
t = tt(j)
for k = 1:length(x)
c(k) = quad(@(tau) f(tau,t,0,a),eps,t)/a;
for m = 1:MMAX
c(k) = c(k) + quad(@(tau) f(tau,t,m,a),eps,t)*cos(m*pi*x(k)/a)*2/a*(-1)^m;
end
end
plot(x,c); drawnow
end
hold off
xlabel(’x’); ylabel(’c’)
Exercise 0.41 Repeat this calculation with boundary condition c= 0atx= 0.
Project 4 Pelloni claims that a recent development by Fokas can deal with more
complicated boundary conditions for linear equations like the one above. Investi-
gate, write up and consider examples with numerical calculations.
0 0.2 0.4 0.6 0.8 1 1.2 1.40.20.30.40.50.60.70.80.91
xcSolutionc(x,t)to (148) fort= 0.5,1. The integral in ( 152) was computed numeri-
cally and terms up to m= 20 were retained in the Fourier series.
Solving integral equation using the Laplace trans-
form
Integral equations take a variety forms. Commonly encountered are (linear) Fred-
holm and Volterra equations of the first and second kind. In general, Volterra are
easier than Fredholm and second kind is easier than first kind. A Fredholm equa-
tions of the second kind is
f(x) =λ/integraldisplay1
0k(x,t)f(t) dt+g(x) (156)
and a Volterra equation of the first kind is
g(x) =λ/integraldisplayx
0k(x,t)f(t) dt, (157)
wheref(t)is an unknown function, to be found, in both cases. F1 and V2 are left
to the reader. The function k(x,t)is called the kernel. There is a close relation
between integral equations and linear algebra (for a good treatment see Pipkin
1991). As a result, their numerical solution can be relatively easy. This is a good
thing, because in most cases that is the only way of solving them. For a clear
introduction to numerical techniques for solving Volterra equations, see Linz (1985).
A special kind of integral equation has a convolution kernel, i.e. one that depends
only on the difference between the two variables so that K(x,t) =K(x−t). For
the Volterra equation above, we see immediately that
G(p) =K(p)F(p), (158)
which can be inverted with derisory ease.
A particularly nice application is the Abel equation:
g(t) =/integraldisplayt
0f(τ)√τ−tdτ. (159)
Note thatg(0) = 0 seems like a good idea, although it isn’t quite obvious in some
limiting cases. We need the Laplace transform of t−1/2, which we found earlier to
beΓ(1
2)p−1/2. HenceF(p) =π−1/2p1/2G(p). We invert this using the convolution
theorem, but we should be careful of the fact that p1/2, which does not decay at
large realp, cannot be the transform of an ordinary function. Hence we write
p1/2G(p) =p(p−1/2G(p))and obtain
f(t) =1
πd
dt/integraldisplayt
0g(τ)√τ−tdτ. (160)
An example is enlightening. First take g(t) = 1 . Then
f(t) =1
πd
dt/integraldisplayt
01√τ−tdτ=2
π√
t. (161)
Note thatf(t)is singular as t→0, which might not have been obvious initially.
Exercise 0.42 Solve the Abel equation for f(t) = logt(by hand) and f(t) =
log(t)/(1 +t2)(numerically).
Numerical inversion
Overview
As seen above, the solution to a fair number of problems can be written down as a
Laplace Transform. Carrying out the transform by hand may be impossible or may
be computationally expensive (e.g. returning an infinite sum). It would be useful
to carry out the inversion numerically. Algorithms to carry out inverse Laplace
transforms have been around for a long time, and are reviewed in a number of
places, including Davies (2002) and Duffy (2004).
The algorithms we consider start from the exact Laplace transform and invert that
expression. The problem of going backward and forward from time variable to
Laplace variable is rather different and difficult. The only real possibility is to adapt
the FFT, but the result looks rather like an FFT with some strong filtering. For some
reason, this algorithm has only been used practically in one or two areas, notably
structural engineering (ref).
We will not review the different possible algorithms but only mention a few before
concentrating on one in particular. One can try and calculate the Bromwich integral
directly; this becomes an exercise in integration of what can be a very oscillator
function (e.g. the Laplace transform of the harmless function H(x)H(1−x)(the
H(x)is automatic really), namely (1−e−p)p−1, oscillates wildly going up toward
±∞). There are expansion approaches using Laguerre polynomials or Chebyshev
polynomials.
The approach we detail goes back to Talbot (1979). In its simplest form, it is very
straightforward. Deform the Bromwich contour to something that essentially looks
like a parabola around the real axis going off into the left half-plane. Crucially, one
needs to do some simple shifting and scaling transformations beforehand. Then
replace the integral by the simplest trapezoid approximation.
The accuracy of this method can be investigated quite carefully. Talbot (1979) knew
this well, but really only offered semi-empirical bounds. More recently, Trefethen,
Weideman & Schmelzer (2006) and Weideman & Trefethen (2007) gave more so-
phisticated analyses relating the algorithm to approximation problems.
The algorithm is very easy to code. The major part of Talbot (1979) lies in a method
to find the smallest number of points that will return a certain accuracy. For many
applications, this is unnecessary because the algorithm is still blindingly fast with
more points than strictly needed. However, even today, there are problems where
it is worth using the smallest number of points that one can get away with. We will
present only the simple version of the algorithm with a fixed number of points. Murli
& Rizzardi (1990) wrote a publicly available version. I have not used it. I have my
own matlab and Fortran version; the Matlab version is included below.
Talbot’s method
We replace the Bromwich contour by an equivalent contour Lgoing to −∞ in the
left half-plan. This replacement is permissible if Lencloses all singularities of F(p)
and|F(p)| → 0uniformly in Re p≤γ0as|p| → ∞ . This second condition may
not hold for the original function, but can generally be made to hold by introducing
a scaling parameter λand shift parameter σand considering F(λp+σ). The
inversion formula becomes
f(x) =λeσx
2πi/integraldisplay
LF(λp+σ)eλσxds (162)
forx> 0.
We define the new contour by a change of variable z=Sν(p). Many functions
work, but Talbot emphasizes
S(z) =z
1−e−z+ν−1
2z, (163)
whereνis a positive parameter. This function maps the interval (−2πi,2πi)on the
imaginary axis to L. In terms of θ, we have
Sν(z) =θcotθ+ iνθ, S/prime
ν(z) =ν
2+i
2[θ+ cotθ(cotθ−1)]. (164)
Then we replace the integral by the trapezoidal rule and obtain
˜f(x) =λeσx
nn−1/summationdisplay
k=−n+1/prime
S/prime
ν(zk)eλSν(zk)F(λSν(zk) +σ). (165)
Iff(x)is real, we can take the real part of the sum evaluated along the portion of
Sin the upper half-plane.
The freedom to choose νis crucial in being able to go around all the singularities if
they are complex. The algorithm is simple to code, once one has worked out λ,σ,
νandn. Doing so forms the bulk of Talbot’s paper.
I have the sneaking suspicion there’s a bug in talbot.m in the sum: have I taken
1/2the last term properly? The arguments of talbot.m areF(p),D, the requested
digits of accuracy, the location of the singularities, and their order (take 0for a
branch cut).
function [f,n] = talbot(fun,tt,D,sj,mult)
% Use the error analysis on page 108b
phat = max(real(sj));
sigma0 = max(0,phat);
spj = sj-sigma0;
if (~isreal(spj))
ss = spj(imag(spj)~=0);
r = imag(ss)./angle(ss);
[rr,k] = find(max(r));
sd = ss(k);
qd = imag(sd);
thetad = angle(sd);
multd = mult(k);
else
qd = 0;
thetad = 0;
multd = 0;
end
% 15 significant digits in Matlab
c = 15;
% test Talbot S.P. value
%c= 20;
% Talbot DP
%c = 27;
warning off
m = length(feval(fun,0));
warning on
f = zeros(length(tt),m);
for j = 1:length(tt)
t = tt(j);
% determine lambda, sigma, nu
v = qd*t;
omega = min(0.4*(c+1)+v/2,2*(c+1)/3);
if (v<=omega*thetad/1.8)
lambda = omega/t;
sigma = sigma0;
nu = 1;
else
kappa = 1.6 + 12/(v+25);
phi = 1.05 + 1050/max(553,800-v);
mu = (omega/t+sigma0-phat)/(kappa/phi-cot(phi));
lambda = kappa*mu/phi;
sigma = phat - mu*cot(phi);
nu = qd/mu;
end
tau = lambda*t;
a = (nu-1)/2;
sigmap = sigma-sigma0;
% determine n
% n0
Dd = D + min(2*multd-2,2) + floor(multd/4);
if (v>omega*thetad/1.8 | multd==0 | isreal(spj))
% Case 2 or Real singularities or not poles
n0 = 0;
else
% Dominant singularity is a pole
sstar = (sd-sigma0)/lambda;
p = real(sstar);
q = imag(sstar);
r = abs(sstar);
theta = angle(sstar);
y = fzero(@(y) utal(y,sstar,q,r,theta),2*pi - 13/(5-2*p-q-0.45*exp(p)));
% iteration blows up with negative im pole, so use bogus positive one
uds = log((y-q)/r/sin(y-theta));
n0 = floor((2.3*Dd+(phat-sigma0)*t)/uds)+1;
end
% n1
e = (2.3*D+omega)/tau;
if (e<=4.4)
rho = (24.8-2.5*e)/(16+4.3*e);
elseif (e<=10)
rho = (129/e-4)/(50+3*e);
else
rho = (256/e+0.4)/(44+19*e);
end
n1 = floor(tau*(a+1/rho))+1;
% n2
gamma = sigmap/lambda;
if (~isreal(spj))
Dp = Dd;
else
Dp = max(D + min(2*mult-2,2) + floor(mult/4));
end
y = v/1000;
eta = (1.09-0.92*y+0.8*y^2)*min(1.78,1.236+0.0064*(1.78)^Dp);
n2 = floor(eta*nu*(2.3*Dp+omega)/(3+4*gamma+exp(-gamma)))+1;
n = max(n0,max(n1,n2));
% [lambda sigma nu n]
% sum over both branches of paraboloid
k=((-n+1):(n-1))’;
% vectorise sum over curve
theta=k*pi/n;
warning off
alpha=theta.*cot(theta);
alpha(n)=1;
snu=alpha+nu*i*theta;
s=lambda*snu+sigma;
beta=theta+alpha.*(alpha-1)./theta;
beta(n)=0;
warning on
% plug in actual function here
ff=feval(fun,s);
% keyboard
temp=diag((nu+i*beta))*diag(exp(snu*tau))*ff;
f(j,:)=f(j,:)+sum(temp);
f(j,:)=f(j,:)*lambda*exp(sigma*t)/n/2;
end
function utal=utal(y,sstar,q,r,theta)
u = log((y-q)/r/sin(y-theta));
z = -u+i*y;
utal = real(sstar*(1-exp(-z))-z);
Numerical solution to model problem
For practical purposes, one needs a function f(t)with a known Laplace transform
if one is to solve ( 148) using a numerical inverse Laplace transform. For ( 148),f(t)
was carefully chosen to give F(p) =p−1log (1 +p). We use ( 154) intalbot.m ;
we don’t bother passing all the singularities to the routine, just the one furthest to
the right at the origin which is a pole of order two (an extra factor of p−1fromF(p)).
The solution obtained using this techniques is plotted in Figure 25. It is much
smoother and better behaved. The program also runs much faster. The behavior
at the right-hand edge of the interval looks right, since
>> expint(tt)
ans =
1.2227 0.7024 0.4544 0.3106 0.2194
which matches with the observed slopes.
% p82: numerical inversion for Laplace solution 04/25/2008 SGLS
F = inline(’1./p.*log(1+p).*cosh(sqrt(p)*x)./sqrt(p)./sinh(sqrt(p)*a)’,’p’,’x’,’a’);
a = 1.4;
n = 100; h = 1./n;
x = a*h*(0:n); tt = 0.1:0.1:1;
c = zeros(length(x),length(tt));
clf; hold on
for k = 1:length(x)
[f,n] = talbot(@(p) F(p,x(k),a),tt,6,0,1);
c(k,:) = f;
end
plot(x,c); drawnow
hold off
xlabel(’x’); ylabel(’c’)
Exercise 0.43 Is the Matlab code actually correct or is there a factor of 1/2miss-
ing? Will this matter much?
0 0.2 0.4 0.6 0.8 1 1.2 1.400.10.20.30.40.50.60.70.80.9
xcSolutionc(x,t)to (148) fort= 0.1:0.1:1using Talbot’s algorithm. Six digits of
accuracy were requested.
Diffusion out of a well
This is a problem I have been looking at for Andrew Kummel in Chemistry and
Biochemistry that is relevant for the design of a new platform called “Single Cell
Hyper Analyzer for Secretants” (SiCHAS).
Formulation
We have a cylindrical well of depth dand radius aconnected to a semi-infinite
space. The well and half-space are filled with fluid in which a protein diffuses. The
concentration of protein obeys the diffusion equation
ct=D∇2c (166)
withDan appropriate diffusion coefficient. All the boundaries are impermeable to
the protein, so cn= 0 on the boundaries. As initial condition, we have a uniform
layer of depth lwith concentration ciat the bottom of the well.
This is an axisymmetric problem. Use cylindrical polar coordinates with z= 0 at
the top of the well and zpointing down. Non-dimensionalize lengths by a, time by
a2/D, and define h=d/a. Then the diffusion equation becomes
ct=∇2c=1
r∂
∂r/parenleftbigg
r∂c
∂r/parenrightbigg
+∂2c
∂z2. (167)
Boundary conditions are cr= 0onr= 1,0< z < h ,cz= 0onr < 1,z=hand
r>1,z= 0, and decay as (r2+z2)1/2→ ∞ ,z <0.
The diffusion equation is linear so the scaling of cis arbitrary. Take the initial
condition
c0(z) =/braceleftBig/epsilon1−1forr<1,h−/epsilon1<z <h ,
0 elsewhere.(168)
This means that l=a/epsilon1and that the initial integrated c, i.e. the mass, is π.
We wish to find ¯c, the mass in the well, as a function of time. The parameters of
the problem are hand/epsilon1. Suggested values in microns of 10fora,100fordand 1
forlgiveh= 10 and/epsilon1= 0.1. IfD= 10−6cm2s−1, then the time scale is 1second.
Solution
This is an extension of Miles (2002). Take the Laplace transform of ( 167):
pC−c0(z) =∇2C. (169)
Define the function F=Czonz= 0; this is the nondimensional flux out of the well.
Expand it in a Fourier–Bessel series as
F(r) =/summationdisplay
nFn
InJ0(knr), withFn=/integraldisplay1
0F(r)J0(knr)rdr. (170)
The numbers knare roots of the equation J/prime
0(kn) =−J1(kn) = 0 . We havek0= 0.
The numbers Inare given by
In=/integraldisplay1
0J2
0(knr)rdr=1
2J2
0(kn). (171)
Note thatI0= 1/2.
Now work inside the well. Separate variables by writing C=/summationtext
nJ0(knr)Zn(z),
multiply ( 169) byrJ0(kmr)and integrate from 0to1. This gives
pImZm−c0(z)/integraldisplay1
0rJ0(kmr) dr=ImZ/prime/prime
m−k2
mImZm. (172)
This equation can be rewritten as
Z/prime/prime
n−(p+k2
n)Zn=−J1(kn)
knInc0(z) =−δn0
/epsilon1H(z+/epsilon1−h) (173)
in0<z <h . Defineµn= (p+k2
n)1/2. We find
Z=/braceleftBigg
Ancoshµn(h−z) +δn0
p/epsilon1cosh√p(h−/epsilon1−z)for0<z <h −/epsilon1,
Ancoshµn(h−z) +δn0
p/epsilon1forh−/epsilon1<z <h .(174)
We can now write the solution for Conz= 0as
C=/summationdisplay
n≥1J0(kn)Ancoshµnh+A0cosh√ph+1
p/epsilon1cosh√p(h−/epsilon1). (175)
In the reservoir, we have
C=/integraldisplay1
0F(η)ηdη/integraldisplay∞
0J0(kr)J0(kη)eµzk
µdk (176)
whereµ= (p+k2)1/2. Atz= 0, this is
C=/integraldisplay1
0F(η)ηdη/integraldisplay∞
0J0(kr)J0(kη)k
µdk=/summationdisplay
nFn
In/integraldisplay∞
0Qn(k)J0(kr)k
µdk,(177)
where
Qn(k) =/integraldisplay1
0J0(knr)J0(kr)rdr=k
k2−k2
nJ0(kn)J1(k). (178)
Match ( 175) atz= 0and ( 177) and use orthogonality:
1
2/bracketleftbigg
A0cosh√ph+1
p/epsilon1cosh√p(h−/epsilon1)/bracketrightbigg
=/summationdisplay
nFn
In/integraldisplay∞
0Qn(k)Q0(k)k
µdk, (179)
AmImcoshµmh=/summationdisplay
nFn
In/integraldisplay∞
0Qn(k)Qm(k)k
µdk(m≥1).(180)
We can relate the coefficients AntoFnusing
A0√psinh√ph+√p
p/epsilon1sinh√p(h−/epsilon1) =−2F0, (181)
AmµmImsinhµmh=−Fm(m≥1). (182)
We have obtained an infinite set of coupled linear equations for the Fn:
F0coth√ph√p+/summationdisplay
nFn
In/integraldisplay∞
0Q0(k)Qn(k)k
µdk=sinh√p/epsilon1)
2p/epsilon1sinh√ph, (183)
Fm
µmcothµmh+/summationdisplay
nFn
In/integraldisplay∞
0Qm(k)Qn(k)k
µdk= 0 (m≥1). (184)
The quantity we seek is ¯c=/integraltext
WcdV, the mass of protein inside the well. At the
initial instant, ¯c=π. We can obtain an equation for ¯cby integrating ( 169) over the
well, giving
p¯C−/integraldisplay
Wc0(z) dV=/integraldisplay
SW∇C·ndS=−2π/integraldisplay1
0Frdr=−2πF0. (185)
Physically this equation just says that the change in mass is due to the flux of
matter out of the top of the well. We can transform this into
¯C=p−1π(1−2F0). (186)
Numerical solution
We compute the inverse Laplace transform of ¯Cusing Talbot’s algorithm. The
functionF0(p)is calculated by truncating the set of linear equations of ( 183–184)
at finite order. The Fortran code is relegated to the Appendix.
Figure 26shows the evolution of ¯c/πas a function of time for different values of h,
while/epsilon1is fixed to be 0.1. We see that the depth of the well affects how fast protein
escapes from it
% p83.m Concentration in well for SiCHAS 04/24/08 SGLS
hh = [0.5 1 2];
e = 0.1;
clf; hold on
for j = 1:length(hh)
[f,c,t] = Kdo(hh(j),e,0,2.5,.05,6);
t = [0 ; t]; c = [pi ; c]; plot(t,c/pi,’b’); drawnow
[f,c,t] = Kdo(hh(j),e,5,2.5,.05,6);
t = [0 ; t]; c = [pi ; c]; plot(t,c/pi,’r’); drawnow
end
hold off
axis([0 2.5 0 1]); legend(’h = 0.5’,’h = 1’,’h = 2’)
xlabel(’t’); ylabel(’c/\pi’)
0 0.5 1 1.5 2 2.500.20.40.60.81
tc/π
h = 0.5
h = 1
h = 2Concentration in well ¯c/π. The blue curves correspond to M= 0, the red toM= 5.
The differences are very small.
References
Publications:
•Davies, B. Integral transforms and their applications. Springer, New Y ork, 2002.
•Duffy, D. G. Transform methods for solving partial differential equations. Chap-
man & Hall/CRC, Boca Raton, 2004.
•Linz, P . Analytical and numerical methods for Volterra equations. SIAM, Philadel-
phia, 1985. SIAM, 1985
•Miles, J. W. 2002. Gravity waves in a circular well. J. Fluid Mech. ,460, 177–
180.
•Murli, M. & Rizzardi, M. Talbot’s method for the Laplace inversion problem.
ACM Trans. Math. Software ,16, 158–168, 1990.
•Pipkin, A. C. A course on integral equations. Springer, New Y ork, 1991.
•Talbot, A. The accurate numerical inversion of Laplace transforms. J. Inst.
Math. Appl. ,23, 97–120, 1979.
•Trefethen, L. N., Weideman, J. A. C. & Schmelzer, T. Talbot quadratures and
rational approximations. BIT Num. Math. ,46, 65-3-670, 2006.
•Weideman, J. A. C. & Trefethen, L. N. Parabolic and hyperbolic contours for
computing the Bromwich integral. Math. Comp. ,76, 1341–1356, 2007.
Multiple transforms: Cagniard–de Hoop method
(04/29/08)
Multiple integrals
Since we have not defined integrals formally, we have no trouble not defining mul-
tiple integrals and just using them. Essentially everything carries through and one
can brazenly change orders of integration and so on in the finite case. However
there are a few little surprises in store with infinite integrals and especially principal
value integrals.
Let us remind ourselves how to change the order of integration and how to change
variables in multiple integrals. Re-expressing the area/volume/hypersurface/hypervolume
in the integral is merely a matter of reparameterizing the governing equations defin-
ing the boundary. To change variables, one uses the formula
dx1dx2...dxn−1dxn=/vextendsingle/vextendsingle/vextendsingle/vextendsingle∂(x1,x2,...,x n−1,xn)
∂(y1,y2,...,y n−1,yn)/vextendsingle/vextendsingle/vextendsingle/vextendsingledy1dy2...dyn−1dyn.(187)
The big fraction is the determinant of the n×nmatrix made up of the partial
derivatives.
Example 0.18 Spherical polar coordinates. We have Cartesian components x,y,
zand spherical polar coordinates r,θ,φ. Note that for the latter coordinates, in
that order, to form a right-handed basis, θmust be co-latitude ( 0at the North pole,
πat the South pole). The relationship between the two coordinate systems is
x=rsinθcosφ, y =rsinθsinφ, z =rcosθ. (188)
Then
/vextendsingle/vextendsingle/vextendsingle/vextendsingle∂(x,y,z )
∂(r,θ,φ )/vextendsingle/vextendsingle/vextendsingle/vextendsingle=/vextendsingle/vextendsingle/vextendsingle/vextendsingle/vextendsingle/vextendsinglesinθcosφ rcosθcosφ−rsinθsinφ
sinθsinφ r cosθsinφ r sinθcosφ
cosθ −rsinθ 0/vextendsingle/vextendsingle/vextendsingle/vextendsingle/vextendsingle/vextendsingle=r2sinθ (189)
as you already know. The area of a sphere is
/integraldisplayπ
0/integraldisplay2π
0r2sinθdθdφ= 2πr2[−cosθ]π
0= 4πr2. (190)
Theorem 7 (Poincar ´e–Bertrand) Let f(x,t)be H ¨older-continuous with respect to
both its variables. Then
−/integraldisplayb
a1
x−y/bracketleftbigg
−/integraldisplayb
af(x,t)
t−xdt/bracketrightbigg
dx=−π2f(y,y) +−/integraldisplayb
a/bracketleftbigg
−/integraldisplayb
af(x,t)
(x−y)(t−x)dx/bracketrightbigg
dt.
(191)
This theorem extends to complex integrals with no trouble.
Exercise 0.44 Track down the original references and construct a clear proof. Dis-
cuss applications. See http://eom.springer.de/p/p072980.htm for references.
Let us test this formula numerically. Calculating principal value integrals is not
entirely straightforward. Quadpack has the routine dqawc . In Matlab, one can
consider either writing a rule from scratch, deforming the contour away from the
pole (which will require inserting the πiresidue contribution by hand), or subtracting
out the singular part, as in
−/integraldisplayb
af(x,t)
t−xdt=−/integraldisplayb
af(x,t)−f(x,x)
t−xdt+f(x,x)−/integraldisplayb
a1
t−x
=−/integraldisplayb
af(x,t)−f(x,x)
t−xdt+f(x,x) log/vextendsingle/vextendsingle/vextendsingle/vextendsingleb−x
a−x/vextendsingle/vextendsingle/vextendsingle/vextendsingle. (192)
This will only work if fis well-behaved near t=x. It is also more involved for the
right-hand side of ( 191). The result is a rather crude program written in Fortran
which could almost certainly be made much more elegant.
c p91.f Poincare-Bertrand 04/29/08 SGLS
c g77 -O -o p91 p91.f -lslatec -Wl,-framework -Wl,vecLib
program p91
implicit double precision (a-h,p-z)
parameter (epsabs=1d-6,epsrel=0d0)
parameter (limit=10000,lenw=limit*4)
dimension iwork(limit),work(lenw)
common a,b,tc,xc,yc
external Flo,Fro
call xsetf(0)
a = 0d0
b = 1d0
pi = 4d0*atan(1d0)
do j = 0,10
yc = j*0.1d0
call dqawc(Flo,a,b,yc,epsabs,epsrel,r1,abserr1,
$ neval1,ier1,limit,lenw,last,iwork,work)
write (6,*) ’lhs’,r1,ier1,neval1,abserr1
call dqawc(Fro,a,b,yc,epsabs,epsrel,r2,abserr2,
$ neval2,ier2,limit,lenw,last,iwork,work)
write (6,*) ’rhs’,r2,ier2,neval2,abserr2
write (6,*) ’PB’,yc,r1,-pi*pi*f(yc,yc)+r2
enddo
end
double precision function f(x,t)
implicit double precision (a-h,p-z)
f = x*x + t*t + log(1d0 + (1d0+x*x)/(1d0+t*t))
end
double precision function fl(t)
implicit double precision (a-h,p-z)
common a,b,tc,xc,yc
fl = f(xc,t)
end
double precision function fr(x)
implicit double precision (a-h,p-z)
common a,b,tc,xc,yc
fr = f(x,tc)
end
double precision function Flo(xin)
implicit double precision (a-h,p-z)
parameter (epsabs=1d-6,epsrel=0d0)
parameter (limit=10000,lenw=limit*4)
dimension iwork(limit),work(lenw)
common a,b,tc,xc,yc
external fl
xc = xin
if (a.eq.xc.or.b.eq.xc) then
Flo = 0d0
return
endif
call dqawc(fl,a,b,xc,epsabs,epsrel,result,abserr,
$ neval,ier,limit,lenw,last,iwork,work)
Flo = result
end
double precision function Fro(tin)
implicit double precision (a-h,p-z)
parameter (epsabs=1d-6,epsrel=0d0)
parameter (limit=10000,lenw=limit*4)
dimension iwork(limit),work(lenw)
common a,b,tc,xc,yc
external fr
tc = tin
if (a.eq.tc.or.b.eq.tc) then
Fro = 0d0
return
endif
call dqawc(fr,a,b,yc,epsabs,epsrel,r1,abserr,
$ neval,ier,limit,lenw,last,iwork,work)
call dqawc(fr,a,b,tc,epsabs,epsrel,r2,abserr,
$ neval,ier,limit,lenw,last,iwork,work)
Fro = r1 - r2
end
> p91
lhs 0. 6 0 0.
rhs 0. 6 0 0.
PB 0. 0. -6.84108846
lhs -1.34216557 0 1425 9.8550233E-07
rhs 5.69631497 0 1425 9.85498413E-07
PB 0.1 -1.34216557 -1.34216558
lhs -2.82517836 0 1385 9.80385068E-07
rhs 4.80547845 0 1385 9.80383278E-07
PB 0.2 -2.82517836 -2.82517837
lhs -3.91783477 0 1345 9.83306328E-07
rhs 4.69978248 0 1345 9.83305798E-07
PB 0.3 -3.91783477 -3.91783477
lhs -5.01960816 0 1335 8.24348636E-07
rhs 4.97975371 0 1335 8.24348424E-07
PB 0.4 -5.01960816 -5.01960816
lhs -6.20534062 0 1335 8.32939443E-07
rhs 5.57055004 0 1335 8.32938877E-07
PB 0.5 -6.20534062 -6.20534062
lhs -7.44370949 0 1365 8.629954E-07
rhs 6.50349414 0 1365 8.62995162E-07
PB 0.6 -7.44370949 -7.4437095
lhs -8.59730377 0 1375 8.19080127E-07
rhs 7.915997 0 1375 8.19078694E-07
PB 0.7 -8.59730377 -8.59730378
lhs -9.28631154 0 1415 8.06449584E-07
rhs 10.1878706 0 1415 8.06445658E-07
PB 0.8 -9.28631154 -9.28631154
lhs -8.11656248 0 1455 8.25652154E-07
rhs 14.7132851 0 1455 8.2564037E-07
PB 0.9 -8.11656248 -8.11656248
lhs 0. 6 0 0.
rhs 0. 6 0 0.
PB 1. 0. -26.5802973
Ioakimidis (1985) considers constructs interesting quadrature rules for double in-
tegrals from the Poincar ´e–Bertrand formula, claiming s they can be used to solve
Cauchy-type singular integral equations but does not consider any applications.
Exercise 0.45 Find an application for Ioakimidis (1985). Maybe more appropriate
for Chapter 82. This is slightly beyond the level of detail we have gone into for
quadrature so far.
Multiple transforms
Since integral transforms are essentially integrals, we can apply transforms re-
peatedly and obtain multiple transforms. Multiple Fourier transforms, one for each
spatial dimension, are common. Throwing in a Laplace transform for the tempo-
ral dependence is also common. For example, studying the linearized stability of
a system using the Laplace-Fourier transform lies behind ideas in convective and
absolute instability, as we shall see later. The Poincar ´e–Bertrand theorem warns
us to be careful, however, with Hilbert transforms.
Example 0.19 The Hankel transform of order 0can be derived from the two-dimensional
Fourier transform. Let the function f(x,y)depend only in fact on r, the polar co-
ordinate. Transform to F(k,l)and back;Fwill be a function only of κ, the polar
coordinate in the (k,l)plane. Then
F(k,l) =/integraldisplay∞
−∞/integraldisplay∞
−∞f(x,y)e−i(kx+ly)dxdy=/integraldisplay∞
0f(r)e−iκrcos (θ−φ)dθrdr=π/integraldisplay∞
0f(r)J0(κr)rdr.
(193)
The angular coordinates are θin the (x,y)plane andφin the (k,l)plane, but
cancel. Doing the same for the inverse transform and tidying up gives the transform
pair
g(κ) =/integraldisplay∞
0f(r)J0(κr)rdr, f (r) =/integraldisplay∞
0g(κ)J0(κr)κdκ. (194)
Numerically the same issues about computing numerical transforms exist: one has
to find a good quadrature rule and so on. There is a serious new problem though:
how to deal with singularities that depend on the previous integral transform. This
will be addressed in Chapter 82. We turn now to a situation where one uses the
double integral to our advantage.
Cagniard–de Hoop method
Basic idea
Cagniard originally studied seismological problems and was the first to consider
initial-value problems. His analysis was later extended by de Hoop. Note that
Cagniard’s original work (Cagniard 1939) mentions the axisymmetric case, not just
the two-dimensional case. We will present the method, then go through two worked
examples.
Consider a Laplace–Fourier transform fLF(p,k). Carry out the inverse Fourier
transform to get
fL=1
2π/integraldisplay∞
−∞fLF(p,k)eikxdk. (195)
The game now is to turn this into something that looks like a Laplace transform.
This is accomplished by deforming the contour in the complex plane to get a curve
parameterized by a new real variable t. Then we’re done and we can read off the
original function.
An impact problem
Adda-Bedia & Llewellyn Smith (2006) consider the LF transform:
ϕLF(k,z,s ) =−uCLF(k,s)
s√
k2+ 1e−sz√
k2+1, (196)
where the function uC(k,s)comes from transforming
uC(x,t) = (t−x2/2)H(t−x2/2), (197)
whereHis the Heaviside step function.
We define branch cuts in the k-plane extending from ±ito±i∞, with√
k2+ 1
positive and real for kon the real axis. Hence the transformed pressure, which is
what is physically interesting, is
pLF(k,z,s ) =−s2ϕLF(k,z,s ) =√
2πs−3/2
√
k2+ 1e−sk2/2−sz√
k2+1. (198)
Exercise 0.46 Show that
uCLF=√
2πs−5/2e−sk2/2. (199)
We now follow the Cagniard–de Hoop procedure. The Laplace transform of the
pressure on the boundary z= 0is given by
pL(x,0,s) =s−1/2
√
2π/integraldisplay∞
−∞e−s(k2/2+ikx)
√
k2+ 1dk. (200)
Note that we have rescaled the integration variable k, assuming that sis positive
and real, or that the integration limits can be moved back to the real axis if sis
complex. This enables us to write
pL(x,0,s) =π−1/2s−1/2gL(x,s), (201)
so as to isolate the x-dependence in the integral into the exponential alone.
We now define a new variable τso that the integral in ( 200) becomes a Laplace
integral. Hence we set
τ=1
2k2+ ikx. (202)
There are two regimes that we label supersonic and subsonic.
Supersonic region When |x|<√
2τ, the relation ( 202) may be inverted to give
k(x,τ) =−ix±√
2τ−x2. (203)
We now move the Fourier contour to Im k=−x, initially with |x|<1so as not to
involve the branch cut. We then change the variable of integration from ktoτ. The
resulting horizontal contour is described as ttakes the values1
2x2to∞(there are
two branches of kcorresponding to the two possible signs of the square root: k+
in the right half-plane and k−in the left half-plane). Hence we may write
gL(x,s) =1√
2/integraldisplayx2/2
∞e−sτ
/radicalbig
k2
−+ 1dk−
dτdτ+1√
2/integraldisplay∞
x2/2e−sτ
/radicalbig
k2
++ 1dk+
dτdτ. (204)
Sincek2
−= (k2
+)∗and
dk+
dτ=−dk−
dτ=1√
2τ−x2, (205)
we obtain
gL(x,s) =/integraldisplay∞
0H(τ−x2/2)1/radicalbig
τ−x2/2Re1√
k2+ 1e−sτdτ. (206)
The choice of the branch of kis now irrelevant. The expression ( 206) has the form
of a Laplace transform, so τis in fact the time variable t. From now on we replace
τbyt, in particular in ( 203). Now ( 206) may readily be inverted to give
g(x,t)≡g1(x,t) =H(t−x2/2)1/radicalbig
t−x2/2Re1/radicalbig
k2(x,t) + 1, (207)
wherek(x,t)is defined by ( 203) withtreplacingτ. Hence in the supersonic
regime, the pressure on the boundary z= 0takes the form
p(x,0,t)≡pS(x,t) =1
πt−1/2∗g1(x,t), (208)
where ∗is the time-convolution operator.
Wave region For|x|>1, there is still the contribution g1(x,t)from the horizontal
contour, but the contour of integration must now also detour around the branch
cut, and so there is an extra contribution, g2(x,t), to add which corresponds to
|x|>√
2t. The appropriate way to write k(x,t)is now
k(x,t) =−ix+ i sgnx√
x2−2t. (209)
The new section of the contour corresponds to values of tin the range (ta,1
2x2),
whereta(x)≡ |x|−1
2is the equation of the ray propagating at the acoustic velocity
that passes through the transonic point. We hence obtain
gL
2(x,s) =1√
2/integraldisplayta
x2/2e−st
(i sgnx)|k2+ 1|1/2dk
dtdt+1√
2/integraldisplayx2/2
tae−st
(−i sgnx)|k2+ 1|1/2dk
dtdt.
(210)
This leads to
g2(x,t) =H(x2−1)H(x2/2−t)H(t−ta(x))|k2+ 1|−1/2
/radicalbig
x2/2−t. (211)
The pressure hence takes the form
pS(x,t) =1
πt−1/2∗[g1(x,t) +g2(x,t)]. (212)
Figure 27showspS(x,t). The curve marked ‘subsonic’ is not the physical pres-
sure, since the correct physical boundary condition ( 197) is not satisfied outside
the contact area. Determining the true pressure in the contact region in the sub-
sonic regime requires substantially more work. Note that the convolution integrals
(208) and ( 212) have integrable singularities at the endpoints t=x2/2correspond-
ing to the contact line.
% p92.m Impact CdH convolution integrals 04/29/08 SGLS
function p92
xx = 0:0.001:2; tt = [0.1 0.5 1];
[f,f2,f3] = psup(xx,tt,2);
plot(xx,-f);
xlabel(’x’); ylabel(’p’); legend(’t = 0.1’,’t = 0.5’,’t = 1’)
function [f,f2,f3]=psup(xx,tt,n)
f2=zeros(length(tt),length(xx));
f3=zeros(length(tt),length(xx));
for j=1:length(tt)
t=tt(j);
for k=1:length(xx)
x=xx(k);
if (t>x^2/2)
f2(j,k)=quad(@phi2int,0,pi/2,[],[],x,t,n);
end
ta=x-0.5;
if (t>ta & x>1)
f3(j,k)=quad(@phi3int,0,pi/2,[],[],x,t,n);
end
end
end
f=f2+f3;
function f=phi2int(theta,x,t,n)
tp=x^2/2+(t-x^2/2)*sin(theta).^4;
k=-i*x+sqrt(2*tp-x^2);
r=sqrt(k.^2+1);
snz=find(theta~=0);
tnz=theta(snz);
f=zeros(size(theta));
f(snz)=-4*sin(tnz)./sqrt(1+sin(tnz).^2).*real(1./r(snz))/pi;
if (x==1 & 2*t~=x^2)
sz=find(theta==0);
f(sz)=-4*(2*t-x^2)^(-0.25)/2/sqrt(x)/pi;
end
if (n==1)
f=2*(t-tp).*f;
elseif (n==0)
f=4/3*(t-tp).^2.*f;
end
function f=phi3int(theta,x,t,n)
ta=x-0.5;
f=zeros(size(theta));
snz=find(theta~=0);
tnz=theta(snz);
sz=find(theta==0);
if (ta<t & t<x^2/2 & x>1)
tp=ta+(t-ta)*sin(theta).^2;
k=-i*(x-sqrt(x^2-2*tp(snz)));
f(snz)=-2*sin(tnz)*sqrt(t-ta)./sqrt(x^2/2-tp(snz)).*abs(1./sqrt(k.^2+1))/pi;
f(sz)=-2/sqrt(x^2/2-ta)*sqrt(x-1)*sqrt(0.5)/pi;
elseif (ta<x^2/2 & t>x^2/2 & x>1)
tp=ta+(x^2/2-ta)*sin(theta).^2;
k=-i*(x-sqrt(x^2-2*tp(snz)));
f(snz)=-2*sin(tnz)*sqrt(x^2/2-ta)./sqrt(t-tp(snz)).*abs(1./sqrt(k.^2+1))/pi;
f(sz)=-2*sqrt(x^2/2-ta)/sqrt(t-ta)/sqrt(x-1)/pi;
else
return
end
if (n==1)
f=2*(t-tp).*f;
elseif (n==0)
f=4/3*(t-tp).^2.*f;
0 0.5 1 1.5 200.511.522.533.54
xp
t = 0.1
t = 0.5
t = 1“Pressure”pS(x,t)at timest= 0.1(supersonic), t=1
2(transonic) and t= 1
(subsonic).
end
Project 5 Carry out this calculation for an elastic solid with shear waves.
Wavefronts using Cagniard–de Hoop
Craster (1996) obtains the Laplace transform for the pressure in a fluid overlying
an elastic half-space in the form
σyy(x,y,p ) =k4k/prime]/epsilon1F(p)
2π/integraldisplay∞
−∞pγ/prime(ζ)
cdγ/prime
0(ζ)
×exp{(p/c)d}
(2ζ2+k2)2−4ζ2γ/prime
d(ζ)γ/prime
s(ζ) +/epsilon1k4k/primeγ/prime
d(ζ)/γ/prime
0(ζ)dζ(213)
(ζis the Fourier transform variable). From now, we limit ourselves to F(p) =p−1
and decorate σyywithH. More complicated forcings can be considered, for which
the final solution is constructed using the convolution theorem.
The functions γ/prime
q(ζ)are defined by γ/prime
q(ζ) = (ζ2+k2
q)1/2, where the waveumber
corresponding to the dilational wave is kd= 1, the wavenumber corresponding
to the shear wave is ks=k=cd/csand the wavenumber corresponding to the
acoustic wave in the fluid is k0=k/prime=cd/c0.
The denominator in the integrand is the elastic Rayleigh function
R(ζ) = (2ζ2+k2)2−4ζ2γ/prime
d(ζ)γ/prime
s(ζ). (214)
The Rayleigh function has simple zeros at ±ikrwherekr=cd/cr, withcrthe
Rayleigh wave speed. The Sch ¨olte function is
S(ζ) =R(ζ) +/epsilon1k4k/primeγ/prime
d(ζ)/γ/prime
0(ζ). (215)
This function has two roots at ±iks. It is quite different from the Rayleigh wave
speed.
Now we consider the region x > 0and adopt polar coordinates with y=−rcosθ
andx=rsinθ. Then we can solve cdt=γ/prime
0(ζ)rcosθ+ iζrsinθto give
ζ(t) =−icdt
rsinθ±k/prime/parenleftbiggc2
0t2
r2−1/parenrightbigg1/2
cosθ forr/c 0≤t. (216)
This path cuts the imaginary axis at −ik/primesinθ. If0≤θ≤θdcr, this is below the
branch cuts of the function. Otherwise, the path must also include a section around
the branch cuts with
ζh(t) =−icdt
rsinθ±ik/prime/parenleftbigg
1−c2
0t2
r2/parenrightbigg1/2
cosθ fort≤r/c 0. (217)
We find
σH
yy(x,y,p ) =/epsilon1k/primek4
πcdRe/integraldisplay∞
r/c0γ/prime
d(ζ(t))
γ/prime
0(ζ(t))S(ζ(t))dζ(t)
dte−ptdt forθdcr≤θ≤1
2π.
(218)
Now the inverse Laplace transform is obvious. The general answer is
σH
yy(x,y,t ) =/epsilon1k/primek4
πcd/braceleftbigg
H(t−r/c 0)Re/parenleftbiggγ/prime
d(ζ(t))
γ/prime
0(ζ(t))S(ζ(t))/parenrightbigg
+[H(t−td)−H(t−r/c 0)]Re/parenleftbiggγ/prime
d(ζh(t))
γ/prime
0(ζh(t))S(ζh(t))/parenrightbigg/bracerightbigg
.(219)
One can now find the wavefronts in the fluid explicitly. The hardest part in this
process is finding the zeros of the Rayleigh and Sch ¨olte functions, and keeping
track of real and imaginary parts.
Exercise 0.47 For realistic parameter values (see Craster 1996), find the zeros of
theR(ζ)andS(ζ). Be careful if you square equations that your roots actually work.
Project 6 Meteotsunamis are small tidal waves that are not generated by displace-
ments of the seafloor caused by earthquakes, as is the case for normal tsunamis
(for a review, see Monserrat et al. 2006). Instead a propagating storm generates
waves on the ocean surface that are amplified when their phase speed is approx-
imately equal to the speed of motion of the forcing. Vennell (2007) examined a
one-dimensional model. Investigate the two-dimensional case (Mercer et al. 2002)
using Cagniard–de Hoop (the topography will still be one-dimensional).
References
Publications:
•Adda-Bedia, M. & Llewellyn Smith, S. G. Supersonic and subsonic states of
dynamic contact between elastic bodies. Proc.. R. Soc. Lond. A,463, 759–
786, 2006.
•Cagniard, L. R´eflexion et r ´efraction des ondes s ´eismiques progressives. Gauthier-
Villars, Paris, 1939. (A 1962 English translation exists.)
•Craster, R. V. Wavefront expansions for pulse scattering by a surface inhomo-
geneity. Q. J. Mech. Appl. Math. ,49, 657–674.
•Ioakimidis, N. I. Application of quadrature rules for Cauchy-type integrals to the
generalized Poincar ´e–Bertrand formula. Mathematics of Computing ,44, 199–
206, 1985.
•Mercer, D., Sheng, J., Greatbatch, R. J. & Bobanovi ˇc, J. Barotropic waves gen-
erated by storms moving rapidly over shallow water. J. Geophys. Res. ,107,
3152, 2002.
•Monserrat, S. Vilibi ´c, I. & Rabinovich, A. B. Meteotsunamis: atmospherically
induced destructive ocean waves in the tsunami frequency band. Nat. Hazards
Earth Syst. Sci. ,6, 1035–1051, 2006.
•Venell, R. Long barotropic waves generated by a storm crossing topography.
J. Phys. Oceanogr. ,37, 2809–2823, 2007.
Multiple integrals: absolute and convective insta-
bility (05/06/08)
Case’s analysis
We have mentioned Rayleigh’s equation previously. As pointed out in Case (1960),
previous analyses of Couette flow had omitted some modes and were unclear
about the completeness and time dependence of the solutions. Completeness
here refers to being able to represent any disturbance as a sum of normal modes.
The set of all trigonometric functions is complete on the interval (0,2π), but if one
remove one of them, this is no longer true. We will go through Case’s analysis and
plot some actual results. In the next section, we will consider the more general
problem.
We consider a homogeneous, incompressible, inviscid fluid flowing between in-
finite parallel plates at y= 0 and 1. We limit ourselves to the two-dimensional
problem. Linearizing about the background flow u=yand writing the time- and
x-dependence as ei(kx+σt), we can reduce the problem to a single equation for the
vertical perturbation velocity v1in the form
(σ+ky)/bracketleftbiggd2v1
dy2−k2v1/bracketrightbigg
= 0, (220)
withv1= 0aty= 0and1. This equation has no solution, so we are stuck.
Let us now try an initial-value approach. Define Fourier and Laplace transforms by
vL=/integraldisplay∞
0e−ptvdt, vF=/integraldisplay∞
−∞e−ikxvdx (221)
respectively. We find
/bracketleftbiggd2
dy2−k2/bracketrightbigg
vLF=1
p+ iky/bracketleftbiggd2
dy2−k2/bracketrightbigg
viF(y), (222)
wherev0F(y)is the Fourier transform of the initial value of v1(x,y). We can invert
the Laplace transform to obtain
/bracketleftbiggd2
dy2−k2/bracketrightbigg
vF= e−ikyt/bracketleftbiggd2
dy2−k2/bracketrightbigg
viF(y). (223)
This equation can be interpreted using the vorticity ζF, which is proportional to
d2vF/dy2−k2vF, so that
ζF= e−ikytζF(y,0). (224)
The Fourier transform of the vorticity merely evolves by a phase factor. This is
sometimes called the Orr mechanism.
We can solve( 223) using a Green’s function. The solution is
vF(y,t) =/integraldisplay1
0G(y,y 0)e−iky0t[/bracketleftbiggd2
dy2−k2/bracketrightbigg
viF(y0) dy0, (225)
where the Green’s function is given explicitly as
G(y,y 0) =−1
ksinhksinhky<sinhk(1−y>), (226)
wherey<andy>are the lesser and greater of yandy0respectively.
Case then carries out a long-time analysis based on an expansion of v0(y)as a
Fourier series. The result, that the perturbation vertical velocity goes to 0liket−1
seems incorrect. To see this, we compute the solution numerically for a simple
initial condition in the channel, v0=y(1−y). This discrepancy in decay rate is not
mentioned in Drazin & Reid (1981).
% p101.m Case solution SGLS 04/30/08
k = 1;
f = inline([’-1/k/sinh(k)*sinh(min(y,y0)).*sinh(k*(1-max(y,y0))).*’ ...
’exp(-i*k*y0*t).*(-2-k^2*y0.*(1-y0))’],’y’,’k’,’t’,’y0’);
tt = [0 logspace(0,2,21)];
yy = 0:0.01:1;
clf; figure(1); hold on
for l = 1:length(tt)
t = tt(l)
for j = 1:length(yy)
v(j) = quad(@(y0) f(yy(j),k,t,y0),0,1);
end
vm(l) = max(abs(v));
plot(real(v),yy,imag(v),yy); drawnow
end
hold off
xlabel(’v’); ylabel(’y’)
figure(2)
loglog(tt,vm,’.’,tt,1./tt); xlabel(’t’); ylabel(’max(v^F)’)
As Case points out, there are two classes of solutions. There are discrete solutions
that satisfy
d2vF
dy2−k2vF= 0 (227)
and the boundary conditions (an empty set for Couette flow). Then there are those
that satisfy
d2vF
dy2−k2vF=δ(σ/k +y), (228)
which are in fact G(y,−σ/k). These latter solutions form the continuous spectrum.
Case then treats more general background flows u0(y). The analysis is the same,
but one has to construct a Green’s function and invert a Laplace transform nu-
merically. We now turn to the general problem of the long-time behavior of similar
10010110210−410−310−210−1100
tmax(vF)Maximum of |vF|(dots);t−2(green line).
systems, not just the Rayleigh equation.
Convective and absolute instability
We follow the pedagogical treatment of Drazin (2002), which is very similar to the
review article of Huerre & Monkewitz (1990). We are dealing with linearized sta-
bility. A background flow is said to be absolutely unstable if there exists an initial
perturbation whose subsequent evolution satisfies
|u/prime(x,t)| → ∞ ast→ ∞ (229)
for all fixed x. The flow is convectively unstable if the perturbation does not grow
above some limit at any fixed point of the flow but does grow at a moving point.
Then
|u/prime(x,t)| → 0 ast→ ∞, (230)
but there exists Vsuch that
|u/prime(x+Vt,t)| → ∞ ast→ ∞. (231)
Otherwise the flow is stable. These definitions are illustrated in Figure 29. These
ideas are only interesting if the flow is open, so that fluid particles enter and leave
through the boundaries of the domain.
LOCAL AND GLOBAL INSTABILITIES 479
is added, this simple model is known to arise in many marginal-stability
analyses of fluid-dynamical systems close to onset (Newell & Whitehead
1969, Stewartson & Stuart 1971). In such a context, the field ¢(x, t)
interpreted as a complex amplitude function characterizing the spafio-
temporal modulations of the marginal wave ~b(x, t)ei(kcx-~oo’) at R = Re. The
Ginzburg-Landau equation has been extensively studied by Deissler (1985,
1987a,c, 1989) to identify possible transition mechanisms in open-flow
systems (see Section 7). Throughout the present review, we use Equation
(8) and its spectral counterpart as a simple example of instability-wave
evolution. It is argued in the next section that the spatio-temporal dynamics
of global modes is indeed governed, in the WKB approximation, by such
an amplitude equation, but with varying coefficients.
Examples of possible linear impulse responses arising from Equation
(8) are displayed in Figure 1 for different ranges of the control parameter
R (see also Chomaz et al. 1987). Disturbances. grow exponentially along
all rays contained within the indicated wedges. The flow is stable in Figures
la,d,f, convectively unstable in Figures lb, g, and absolutely unstable in
R <Rc0 xRc <R <Rt~(c) ~~~_~
0 x 0 xR >Rt
R <Rcit (e)
~
0 x 0 xR>Rc=Rt
0 x 0 x 0 xR <RcRc <R <RtR >Rt
Figure 1 Sketches of typical impulse responses. Single traveling wave: (a) stable, (b)
convectively unstable, (c) absolutely unstable. Stationary mode: (d) stable, (e) absolutely
unstable. Counterpropagating traveling waves: (f) stable, (9) convectively unstable,
absolutely unstable.www.annualreviews.org/aronlineAnnual ReviewsAnnu. Rev. Fluid Mech. 1990.22:473-537. Downloaded from arjournals.annualreviews.org
by University of California - San Diego on 04/30/08. For personal use only.From Huerre & Monkewitz (1990).
This is not the same as non-normal stability (Schmid 2007) or nonlinear instability
(Chomaz 2005), although there are links. Chomaz (2005) also details more recent
thinking about global modes. Figure 30shows a prettier color version of Figure 29.
We can turn the above limits into complex analysis by considering the Green’s func-
tion associated with the dispersion relation D(k,ω;R) = 0 , whereRis some con-
trol parameter. We are limiting ourselves to a one-dimensional view with u/prime(x,t) =
Re[Aei(kx−ωt)], so the dispersion relation can be identified with the differential op-
erator in the form D(−i∂x,i∂t;R) = 0 .
First we review temporal and spatial instability. In temporal stability, we consider k
real and solve D(k,ω;R) = 0 forω. If, for some k,ωhas positive imaginary part,
the system is unstable. In spatial stability, we consider ωreal (e.g. we are exciting
a fixed-frequency disturbance somewhere in the flow) and solve D(k,ω;R) = 0 for
k. Ifkhas negative imaginary part, the disturbance grows downstream.
Example 0.20 This is a toy example from Drazin (2002):
u/prime
t+Wu/prime
x=u/prime
xx+ (R−Rc)u/prime. (232)
The dispersion relation is D=−iω+ iWk+k2−(R−Rc). IfR<R c, the system
is temporally stable. If R > R candW/negationslash= 0, disturbances grow and propagate, so
we have convective instability. If R >R candW= 0, we have absolute instability.
Note that the group velocity is given by cg=∂kω=W−2ik. See the plots in
Figure 31. Note the use of matrix exponentials in p102.m .
10 Nov 2004 13:27 AR AR235-FL37-14.tex AR235-FL37-14.sgm LaTeX2e(2002/01/18) P1: IBD
362 CHOMAZ
Figure 2 Classical linear stability theory for stable (S), convectively unstable (CU)
and absolutely unstable (AU) flow. The first row of sketches illustrates the temporal
stability theory with kreal (temporal growth rate ωiversus real wavenumber k). The
second row illustrates the spatial stability theory with ωreal (locus of the complex
wavenumber kfor varying real frequency ω)that describes the response to a harmonic
forcing localized at x=0. For a stable flow, the response to forcing, schematically
shown in the last row, is damped and the k-branches that lie above the real k-axis
propagate to the right of the forcing station. They are therefore labeled with a +sign,
whereas k-branches that lie below the real k-axis propagate to the left and are labeled
with a −sign. When a k+-branch crosses the real k-axis the flow becomes unstable to
aparticular range of forcing frequencies. For a frequency in this unstable range, the
spatial response to forcing is amplified downstream of the forcing station because, by
asimple continuation argument, the k+-branch keeps propagating downstream. When
ak+-branch pinches with a k−-branch, such an identification by continuity of the
direction of propagation is no longer possible, the flow becomes absolutely unstable,
and the response to a localized forcing cannot be defined. Any initial transient will then
be amplified in situ because the wave with zero group velocity is temporally growing
and overwhelms any other signal.
the stable region. As a result, globally stable open flows exhibit large transient
growth associated with instability wave propagation downstream, but for a long
time and in the absence of external forcing or feedback, they relax to the basic
state. They also exhibit large amplification if harmonic forcing at the frequency
ωfis locally applied at the station x=0. The downstream response Af(x,y,t)
is asymptotic for x>0 toAnnu. Rev. Fluid Mech. 2005.37:357-392. Downloaded from arjournals.annualreviews.orgby University of California - San Diego on 04/30/08. For personal use only.
From Chomaz (2005).
% p 102.m Model instability problem. See p6.m SGLS 05/06/08
N = 128; h = 2*pi/N; x = h*(1:N); t = 0;
dR = [-1 0 4 4]; W = [4 4 4 0];
tmax = 1; tplot = .1; clf, drawnow, %set(gcf,’renderer’,’zbuffer’)
nplots = round(tmax/tplot);
dk = 1i*[0:N/2-1 0 -N/2+1:-1];
v0 = exp(-100*(x-2).^2);
v_hat = fft(v0);
for j = 1:4
subplot(2,2,j)
t = 0;
data = [v0; zeros(nplots,N)]; tdata = t;
for i = 1:nplots
v = real(ifft(exp((-dk*W(j)+.01*dk.^2+dR(j))*t).*v_hat));
data(i+1,:) = v; tdata = [tdata; t];
t = t + tplot
end
waterfall(x,tdata,data), view(10,70), colormap(1e-6*[1 1 1]);
axis([0 2*pi 0 tmax 0 5]), ylabel t, zlabel u, grid off; drawnow
024600.51
05
tu
024600.51
05
tu
024600.51
05
tu
024600.51
05
tuEvolution of u.W= 2for (a–c),W= 0for (d). (R−Rc) =−1,0,4,4respectively.
We have stability, stability, convective instability and absolute instability.
end
The procedure is to look at the behavior of the Green’s function defined by
D(−i∂x,i∂t;R) =δ(x)δ(t) (233)
ast→ ∞ for fixedV=x/t. Then stability corresponds to G→0for allVand
instability to G→ ∞ for at least one V. For convective instability, G→0forV= 0;
for absolute instability G→ ∞ forV= 0. These ideas were developed earlier in
the field of plasma (Briggs 1964) and then moved into fluids later.
The standard thinking is as follows. Fourier and Laplace transforming ( 233) gives
G(x,t) =1
(2π)2/integraldisplay
F/integraldisplay
Lei(kx−ωt)
D(k,ω;R)dωdk. (234)
(Note that this is not quite a standard Laplace transform: we have ω= ip.) The
contourLin the complex frequency plane is a straight horizontal line located above
all the singularities of the integral to satisfy causality. The path Fin the complex
wavenumber plane is initially taken along the real axis. These paths are shown in
Figure 32.
If the dispersion relation has a single discrete mode, one can carry out a residue
calculation in the ω-plane atω=ω(k). This leads to
G(x,t) =−i
(2π)2H(t)/integraldisplay∞
−∞ei(kx−ω(k)t)
∂ωD(k,ω(k);R)dk. (235)
Now we can use steepest descents on the Fourier integral at large tand fixedx/t.
Critical points occur at ∂kω=x/t, and problems must be studied on a case-by-
case basis. If there is a single critical point k∗and the contour of integral can be
LOCAL AND GLOBAL INSTABILITIES 481
~oi
~ t < O L ¯
~ ~t>O
(a)ki
~~’~’~x>O
F" [~ " jkr~x<O
09r(b)ki
~+(~o)
kl
kr
Figure 2 Loci of spatial branches k+(o~) and k-(o~) as L-contour is displaced downward
in the complex ~o-plane. (a), (b), and (c) refer to different stages of the pinching process.
namely G(x, t) = 0 for all x when t < 0. The path F in the complex wave-
number plane is initially taken along the real axis. A sketch of the paths
of integration is shown in Figure 2a. If one assumes for simplicity that
Equation (1) admits a single discrete temporal mode c0(k), then the Green’s
function G(x, t) is formally obtained from a residue calculation in the co-
plane at 09 = og(k). One finds that
i ~+~ ei[kx-~°(k)t]
G(x, t) = - ~H(t) J_~ dk, (10)
~ [k, co(k);
where H(t) is the Heaviside unit-step function. This Fourier integral over
all wave numbers k can be evaluated for large time t (x/t fixed) by applying
the method of steepest descent. Details of the calculation very much depend
on the particular form of co(k). It is assumed here that the mode og(k) gives
rise to a single stationary point k, for the phase in the integrand such that
~-~ (k,) = 7"(11)www.annualreviews.org/aronlineAnnual ReviewsAnnu. Rev. Fluid Mech. 1990.22:473-537. Downloaded from arjournals.annualreviews.org
by University of California - San Diego on 04/30/08. For personal use only.From Huerre & Monkewitz (1990).
deformed onto a steepest descent path, we have
G(x,t)∼ − (2π)1/2eiπ/4 ei(k∗x−ω(k∗)t)
∂ωD(k∗,ω(k∗);R)[d2ω(k∗)/dk2t]1/2. (236)
The temporal growth rate is ω(k∗)−(x/t)k∗.
INCOMPLETE. Then things become rather complicated. As the path Lin the com-
plexω−plane s moved up, the roots k(ω)of the dispersion relation move in the
complexk-plane. AsLapproaches a root ω(k), one of the branches approaches
the real axis. According to B/B, it cannot cross the axis.
It would be nice to have some simple numerical calculations of G(x,t)to see how
this works.
Exercise 0.48 Solve the toy example numerically using the variables xandt.
Exercise 0.49 Solve the toy example numerically using inverse Fourier and Laplace
transforms.
A dissenting view
Cumberbatch argues that the method of analysis that has been described, which
he calls B/B, for Briggs and Bers, gives contradictory results for a water wave prob-
lem.
Example 0.21 This is due to Briggs, and is based on the dispersion relation
D= (ω−k)2−1 + 4iω. (237)
The associated PDE is
(∂t+∂x)2u+u−4ut=δ(x)δ(t). (238)
The solution to this problem is
u=−t[π(t−x)3]1/2e(t−3x)(t+x)/4(t−x)H(t)H(t−x). (239)
This grows exponentially between the rays t= 3xandt=−x, corresponding to
absolute instability. This contradicts B/B.
Exercise 0.50 Derive ( 239). (This is not that easy.)
Figure 33displays a contour plot of the solution ( 239), and absolute instability is
clear.
% p103.m Briggs counter-example SGLS 05/01/08
x = -2:0.001:2; t = 0:0.001:1; [xx,tt] = meshgrid(x,t);
u = real(-tt.*(pi*(tt-xx)).^0.5.*exp((tt-3*xx).*(tt+xx)*0.25./(tt-xx)).* ...
(tt>0).*(tt>xx));
pcolor(x,t,u); shading flat; colorbar
hold on; plot(x(x>0),3*x(x>0),’k’,x(x<0),-x(x<0),’k’,[0 0],[0 1],’w--’); hold off
xlabel(’x’); ylabel(’t’)
Crighton & Oswell (1991) consider a problem which has similar issues to do with
instability.
Solution to Briggs’ counter-example from ( 239).
References
Publications:
•Briggs, R. J. Electron-stream interactions in plasmas. MIT Press, Boston, 1964.
•Case, K. M. Stability of inviscid plane Couette flow. Phys. Fluids ,3, 143–148,
1960.
•Chomaz, J.-M. Global instabilities in spatially developing flows: Non-normality
and nonlinearity. Ann. Rev. Fluid Mech. ,37, 357–392, 2005.
•Crighton, D. G. & Oswell, J. E. Fluid loading with mean flow. I. Response of
an elastic plate to localized excitation. Proc. R. Soc. Lond. A,335, 557–592,
1991.
•Cumberbatch, E. Wave patterns via multiple Fourier transforms. Unpublished
manuscript.
•Huerre, P . & Monkewitz, P . A. Local and global instabilities in spatially develop-
ing flows. Ann. Rev. Fluid Mech. ,22, 473–537, 1990.
•Drazin, P . G. Introduction to hydrodynamic stability. Cambridge University Press ,
Cambridge, 2002.
•Drazin, P . G. & Reid, W. H. Hydrodynamic stability. Cambridge University Press ,
Cambridge, 1981.
•Schmid, P . J. Nonmodal stability theory. Ann. Rev. Fluid Mech. ,39, 129–162,
2007.
The Wiener–Hopf method
The semi-infinite screen
The easy bit
The semi-infinite screen is always the example used to present the Wiener–Hopf
method and we shall follow tradition. The classic reference is Noble (1988). Con-
sider a rigid semi-infinite plate occupying x< 0,y= 0immersed in a compressible
fluid. A plane wave with velocity potential
φi= exp [ −ik0(xcos Θ +ysin Θ) −iωt] (240)
with 0<Θ< π is incident upon this plate. The frequency ωand wavenumber k0
are related by the dispersion relation ω=k0c. The total velocity potential can be
decomposed into φt=φ+φs, whereφsatisfies the Helmholtz equation
∂2φ
∂x2+∂2φ
∂y2+k2
0φ= 0, (241)
The wavenumber will be taken to have a small imaginary part when necessary to
ensure causality. We now suppress the time-dependence.
We have the following boundary conditions on the screen:
∂φt
∂y= 0,∂φ
∂y= ik0sin Θ exp ( −ik0xcos Θ) ony= 0,x≤0, (242)
while we require φtand henceφto be continuous on y= 0,0<x. Finally∂φt/∂y
and hence ∂φ/∂y are continuous on y= 0. We also need some assumptions
concerning the behavior of φat infinity and near the edge of the screen at the
origin.
Physically we know that there are three regions in this problem. In region (1), φ
consists of a diffracted wave and a reflected wave. In region (2), φconsists of a
diffracted wave minus the incident wave. In region (3), φconsists of a diffracted
wave only. The reflected wave is exp [−ik0(xcos Θ−ysin Θ)] . The diffracted wave
behaves like H(1)
0(kr)∼r−1/2eik0rby causality. Hence for any fixed y,
|φ|=O(exp [ Imk0(xcos Θ− |y|sin Θ)]) forx<−|y|cot Θ. (243)
This says that in regions where φcontains a diffracted or reflected wave, it is of
that order. In the region with only a diffracted wave,
|φ|=O(exp [−Imk0r]) for−|y|cot Θ<x. (244)
Near the edge of the screen, we assume that the velocity potential is bounded
asx→0, while∂φt/∂y is allowed to have an inverse square root singularity as
x→+0ony= 0.
There are a number of ways of solving this problem. The original Wiener–Hopf
technique was devised to solve coupled integral equations in radiation transport
theory. The version we use is due to Jones, and presented in Noble (1988) very
clearly.
We introduce a new object: the half-range Fourier transform. This is defined by
Φ+(k,y) =/integraldisplay∞
0φeikxdx, Φ−(k,y) =/integraldisplay0
−∞φeikxdx. (245)
(Note the sign convention.) The usual Fourier transform is given by the sum of
the two: Φ = Φ ++ Φ 0. One can show that Φ+is analytic for Im k >−Imk0
and Φ−is analytic for Im k < Imk0cos Θ . As a result Φis analytic in the strip
−Imk0<Imk< Imk0cos Θ .
We Fourier transform the governing equation ( 241) and obtain
dΦ
dy2−(k2−k2
0)Φ = 0. (246)
Writeγ= (k2−k2
0). Then the solution is
Φ =A1(k)e−γy+B1(k)e−γy(y≥0), (247)
=A2(k)e−γy+B2(k)e−γy(y≤0). (248)
since Φis discontinuous across y= 0. Using the fact that Φdecays for large |y|
and the usual definition of the branch cut leads to B1=A2= 0. Since∂φ/∂y is
continuous across y= 0, we have
Φ = sgnyA−(k)e−γ|y|. (249)
Now write Φ(0) forΦon thex-axis and so on. The continuity conditions and rela-
tions above lead to
Φ+(0) + Φ (+ 0) =A(k), (250)
Φ+(0) + Φ (−0) = −A(k), (251)
Φ/prime
+(0) + Φ/prime
(0) = −γA(k). (252)
Note that
Φ/prime
−(0) =/integraldisplay0
−∞(ik0sin Θe−ik0xcos Θ)e−ikxdx=k0sin Θ
k−k0cos Θ. (253)
Some algebra now leads to
Φ+(0) = −S−, (254)
Φ/prime
+(0) +k0sin Θ
k−k0cos Θ=−γD−. (255)
The functions S−andD−are unknown sum and difference functions, analytic in
Imk < Imk0cos Θ . We have two equations in four unknowns, which looks to be a
problem.
Splits
Both ( 254) and ( 255) are in the form
R(k)Φ+(k) +S(k)Ψ−(k) +T(k) = 0, (256)
whereR,SandTare given, and +and−functions are analytic in upper and lower
half-planes with a non-trivial intersection.
The critical step in the Wiener–Hopf procedure (remember we are solving one
equation with two unknown functions) is to find K+(k)andK−(k)analytic and non-
zero in upper and lower half-planes such that
R(k)
S(k)=K+ (k)
K−(k). (257)
This is a multiplicative decomposition. Then we can rewrite ( 256) as
K+(k)Φ+(k) +K−(k)Ψ−(k) +K−(k)T(k)
S(k)= 0. (258)
Now we carry out an additive split:
K−(k)T(k)
S(k)=T+ (k) +T−(k). (259)
We can now rewrite the equation with −functions on one side and +functions on
the other side:
J(k) =K+(k)Φ+(k) +C+(k) =K−(k)Φ−(k) +C−(k). (260)
We have two expressions that are analytic in upper and lower half-planes respec-
tively, and that overlap over a non-trivial strip. Hence they are the same function,
J(k), which is entire. If we can bound the second and third terms appropriately, the
extended form of Liouville’s theorem tells us that J(k)is a polynomial. There are
a finite number of unknowns in the polynomial that come from physical conditions
(holding near the edge).
Sometimes both of the splits can be done by hand. It’s always a good idea to try
and factorize expressions and cancel out singularities. If not, there is a formal way
of obtaining any multiplicative or additive split:
Theorem 8 Letf(k)be an analytic function of k=σ+ iτ, analytic in the strip
τ−< τ < τ +, such that |f(k)|< C|σ|−p,p > 0, for|σ| → ∞ , the inequality
holding uniformly for all τin the strip τ−+/epsilon1 <≤τ≤τ++/epsilon1,/epsilon1 > 0. Then for
τ−<c<τ <d<τ +,
f(k) =f+(k) +f−(k), (261)
f+(k) =1
2πi/integraldisplay∞+ic
−∞+icf(ζ)
ζ−kdζ, f −(k) =−1
2πi/integraldisplay∞+id
−∞+idf(ζ)
ζ−kdζ. (262)
Theorem 9 IflogK(k)satisfies the conditions of the previous theorem, which im-
plies in particular that K(k)is analytic and non-zero in a strip τ−< τ < τ +and
K(k)→1asσ→ ±∞ in the strip, then we can write K(k) =K+(k)K−(k)where
K+(k),K−(k)are analytic, bounded and non-zero in τ <τ −,τ <τ +respectively.
Solution
We can carry out the multiplicative split in ( 255) by hand:
Φ/prime
+(0)
(k+k0)1/2+k0sin Θ
(k+k0)1/2(k−k0cos Θ)=−(k−k0)1/2D−. (263)
The second term is not regular in either half-plane. We deal with it in a very stan-
dard way, giving
k0sin Θ
(k+k0)1/2(k−k0cos Θ)
=k0sin Θ
(k−k0cos Θ)/bracketleftbigg1
(k+k0)1/2−1
(k0+k0cos Θ)1/2/bracketrightbigg
+k0sin Θ
(k0+k0cos Θ)1/2(k−k0cos Θ)(264)
=H+(k) +H−(k). (265)
Rearrange to obtain
J(k) = (k+k0)1/2Φ/prime
+(0) +H+(k) =−(k−k0)1/2D−−H−(k). (266)
Some analysis of the edge conditions shows that J(k)tends to zero for large k.
This is a relief, since we had no other conditions left to fix terms in the polynomial.
So by Liouville’s theorem, we obtain
Φ/prime
+(0) = −(k+k0)1/2H+(k), (267)
D−= =−(k−k0)1/2H−(k). (268)
Putting this together leads to
φ=∓1
2π(k0−k0cos Θ)1/2/integraldisplay∞+ia
−∞+iae−ikx∓γy
(k−k0)1/2(k−k0cos Θ)dk, (269)
where −Imk0< a < Imk0cos Θ and with the upper and lower signs referring to
y≥0andy≤0respectively. We can do the same thing with ( 254) but we don’t
need to.
Exercise 0.51 Work out the large- rbehavior of ( 269) using the method of steepest
descents.
The form ( 269) is special, because it can be turned into a Fresnel integral. It turns
out that for −π≤θ≤π, withθgiving the angle with respect to the x-axis,
φt=π−1/2e−iπ/4[e−ik0rcos (θ−Θ)F{(−2k0r)1/2cos1
2(θ−Θ)}
+e−ik0rcos (θ+Θ)F{(2k0r)1/2cos1
2(θ+−Θ)}]. (270)
The resulting field is shown in Figure 34.
% p111.m Fresnel solution for semi-infinity screen SGLS 05/05/08
k = 1.2; kF = k*sqrt(2/pi);
T = 0.45;
x = -10:0.25:10; y = x; [xx,yy] = meshgrid(x,y);
r = sqrt(xx.^2+yy.^2); t = atan2(yy,xx);
Fmr = 0.5 - mfun(’FresnelC’,-(2*kF*r).^0.5.*cos(0.5*(t-T)));
Fmi = 0.5 - mfun(’FresnelS’,-(2*kF*r).^0.5.*cos(0.5*(t-T)));
Fm = sqrt(pi/2)*(Fmr + i*Fmi);
Fpr = 0.5 - mfun(’FresnelC’,(2*kF*r).^0.5.*cos(0.5*(t+T)));
Fpi = 0.5 - mfun(’FresnelS’,(2*kF*r).^0.5.*cos(0.5*(t+T)));
Fp = sqrt(pi/2)*(Fpr + i*Fpi);
phi = pi^(-0.5)*exp(-i*pi/4)*(exp(-i*k*r.*cos(t-T)).*Fm + exp(-i*k*r.*cos(t+T)).*Fp);
subplot(2,2,1)
contour(x,y,real(phi)); colorbar; hold on; plot([-5 0],[0 0],’k’); hold off
xlabel(’x’); ylabel(’y’)
subplot(2,2,2)
contour(x,y,imag(phi)); colorbar; hold on; plot([-5 0],[0 0],’k’); hold off
xlabel(’x’); ylabel(’y’)
subplot(2,2,3)
contour(x,y,abs(phi)); colorbar; hold on; plot([-5 0],[0 0],’k’); hold off
xlabel(’x’); ylabel(’y’)
subplot(2,2,4)
contour(x,y,angle(phi)); colorbar; hold on; plot([-5 0],[0 0],’k’); hold off
xlabel(’x’); ylabel(’y’)
Exercise 0.52 Derive ( 270). Work out the large- rbehavior of ( 270) using the
method of steepest descents.
xy
−10−50510−10−50510
xy
−10−50510−10−50510
xy
−10−50510−10−50510
xy
−10−50510−10−50510−2−1.5−1−0.500.511.5
−2−1012
0.511.52
−3−2−10123Total fieldφtcalculated from ( 270) fork= 1.2andΘ = 0.45(meaningless values).
Contour plots of (a) real part; (b) imaginary part; (c) absolute value; (d) argument.
Numerical splits
The split that we used in the semi-infinite screen case was easy: γcould essentially
be factorized by hand by looking at its poles and branch points. The additive split
was just a case of removing a pole. In many cases, this is not possible. The
Rayleigh and Sch ¨olte functions of Chapter 59are cases where this is not possible.
We must then resort to carrying out the split numerically. This is possible from
Theorems ( 8) and ( 9). The resulting numerically evaluated functions are then put
back into the Fourier inversion algorithms or used as needed.
In Abrahams et al. (2008), a paper mentioned previously, one can find the following
equation
r+(k)r−(k) cosh[∆(k)(θ+(k) +θ−(k))] = (1 +2
3k2)g−∆/radicalbig
f2+e2, (271)
r+(k)r−(k) sinh[∆(k)(θ+(k) +θ−(k))] = (1 +2
3k2)/radicalbig
f2+e2−∆g, (272)
where
e(k) =k/parenleftbigg
1 +ν+2k2
sinh2k−k2/parenrightbigg
, (273)
f(k) =2k2
sinh2k−k2, (274)
g(k) =ksinh 2k
sinh2k−k2, (275)
∆(k) = (1 +k2)1/2. (276)
We can separate the two equations to give
[r+(k)r−(k)]2=1
3k2(1 +4
3k2)(g2−f2−e2), (277)
tanh[∆(k)(θ+(k) +θ−(k))] =(1 +2
3k2)√f2+e2−∆g
(1 +2
3k2)g−∆√f2+e2. (278)
Then from Theorem 9,
θ+(k) =1
2πi/integraldisplay∞
−∞1
∆(ζ)tanh−1/braceleftBigg
(1 +2
3ζ2)/radicalbig
f2(ζ) +e2(ζ)−∆(ζ)g(ζ)
(1 +2
3ζ2)g(ζ)−∆(ζ)/radicalbig
f2(ζ) +e2(ζ)/bracerightBigg
dζ
ζ−k
=k
πi/integraldisplay∞
01
∆(ζ)tanh−1/braceleftBigg
(1 +2
3ζ2)/radicalbig
f2(ζ) +e2(ζ)−∆(ζ)g(ζ)
(1 +2
3ζ2)g(ζ)−∆(ζ)/radicalbig
f2(ζ) +e2(ζ)/bracerightBigg
dζ
ζ2−k2,(279)
valid for Im (k)>0. The last result is true because the integrand is even in ζ, which
further implies that
θ−(k) =θ+(−k) forkin the lower half-plane. (280)
Actually, any path parallel to the real axis suffices for the full range integral and so if
θ+(k)is required for real kthen the first integral must be indented below the chosen
k. The existence of the integral representations in ( 279) is confirmed by noting that
the right-hand side of ( 278) isO(k2)ask→0,∼1
2(1 +ν)as|k| → ∞ and is
bounded in the lower half-plane. Hence this representation is ideal for computing
θ±(k)and can be directly coded for numerical evaluation.
This procedure has to be modified for [r+(k)r−(k)]2in (277) whose right-hand side
tends to 4ask→0and∼(3 +ν)(1−ν)4k6/9as|k| → ∞ in the lower half-plane.
The latter behaviour is not suitable for direct application of the product decomposi-
tion formula,which requires a function that tends to the value unity at infinity. This is
simply circumvented by applying a suitable divisor to ( 277), employing the standard
factorization formula, and then decomposing the divisor into upper and lower half
functions by inspection. From
1
3k2(g2−f2−e2) =/bracketleftbiggk2sinh2k
3(sinh2k−k2)/bracketrightbigg/braceleftbiggk2
sinh2k[4 + (1 −ν)2k2] + (3 +ν)(1−ν)k2/bracerightbigg
,
we find
r+(k) = (1 −2ik/√
3)1/2(1−ik/√
3)1/2[2−ik(3 +ν)1/2(1−ν)1/2]1/2×
exp/braceleftbigg1
4πi/integraldisplay∞
−∞log/bracketleftbigg[g2(ζ)−f2(ζ)−e2(ζ)]ζ2
(ζ2+ 3)[4 + (3 + ν)(1−ν)ζ2]/bracketrightbiggdζ
ζ−k/bracerightbigg
(281)
for Im (k)>0and indentation of the contour below kis taken ifkis real. Note that
the exponential function in this expression may be re-expressed as
exp/braceleftbiggk
2πi/integraldisplay∞
0log/bracketleftbigg[g2(ζ)−f2(ζ)−e2(ζ)]ζ2
(ζ2+ 3)[4 + (3 + ν)(1−ν)ζ2]/bracketrightbiggdζ
ζ2−k2/bracerightbigg
,
where convergence of this and the above integral are now ensured. The func-
tionr−(k), analytic in the lower half plane, is again, due to the symmetry, simply
obtained from
r−(−k) =r+(k) forkin the lower half-plane. (282)
The numerical program p112.m is long. Figure 35shows computed minus and plus
functions, as well as their product and sums compared to the original functions.
One can’t tell from this diagram that the functions are analytic, although this can be
seen by taking values of Im kthat go through singularities of θ(k)andr(k).
% p112.m Numerical split SGLS 05/0608
function p112
global nu
nu = 0.3; ai = 0.2;;
aa = (-1:.025:1) - ai*i;
aa = (-10:.5:10) - ai*i;
aa = (-10:.5:10) - ai*i;
ax = real(aa);
t = tex(aa);
r = rex(aa);
r = (1+4*aa.^2/3).^0.5.*(1+aa.^2/3).^0.5.*(4+(3+nu)*(1-nu)*aa.^2).^0.5.*exp(r);
[tm,tp,rm,rp] = trdo(aa);
subplot(2,2,1)
plot(ax,real(tm),ax,imag(tm),’--’,ax,real(tp),ax,imag(tp),’--’)
subplot(2,2,2)
plot(ax,real(t),ax,imag(t),’--’,ax,real(tm+tp),ax,imag(tm+tp),’--’)
subplot(2,2,3)
plot(ax,real(rm),ax,imag(rm),’--’,ax,real(rp),ax,imag(rp),’--’)
subplot(2,2,4)
plot(ax,real(r),ax,imag(r),’--’,ax,real(rm.*rp),ax,imag(rm.*rp),’--’)
function [tm,tp,rm,rp] = trdo(aa)
global nu
tm = zeros(size(aa));
rm = zeros(size(aa));
tp = zeros(size(aa));
rp = zeros(size(aa));
for j = 1:length(aa)
al = aa(j);
i1 = quadl(@(z) tcv(z,al),-1,1);
i2 = quadl(@(zeta) ti(zeta,al),-1,1);
tm(j) = i1 + i2;
if (imag(al)>=0)
tm(j) = tm(j) - 2*pi*i*tex(al);
end
tp(j) = i1 + i2;
if (imag(al)<0)
tp(j) = tp(j) + 2*pi*i*tex(al);
end
i1 = quadl(@(z) rcv(z,al),-1,1);
i2 = quadl(@(zeta) ri(zeta,al),-1,1);
rm(j) = i1 + i2;
if (imag(al)>=0)
rm(j) = rm(j) - 2*pi*i*rex(al);
end
rp(j) = i1 + i2;
if (imag(al)<0)
rp(j) = rp(j) + 2*pi*i*rex(al);
end
end
tm = -tm/(2*pi*i);
tp = tp/(2*pi*i);
rm = -rm/(2*pi*i);
rp = rp/(2*pi*i);
rm = (1+i*2*aa/sqrt(3)).^0.5.*(1+i*aa/sqrt(3)).^0.5.*(2+i*sqrt((3+nu)*(1-nu))*aa).^0.5.*exp(rm);
rp = (1-i*2*aa/sqrt(3)).^0.5.*(1-i*aa/sqrt(3)).^0.5.*(2-i*sqrt((3+nu)*(1-nu))*aa).^0.5.*exp(rp);
function tt = tex(al)
n = (1+2/3*al.^2).*sqrt(f2(al).^2+e2(al).^2)-Del(al).*g(al).*al.^2;
d = (1+2/3*al.^2).*g(al).*al.^2 - Del(al).*sqrt(f2(al).^2+e2(al).^2);
tt = atanh(n./d)./Del(al);
tt(al==0) = 0;
function rr = rex(al)
global nu
warning off
n = (g(al).^2-f(al).^2-e(al).^2).*al.^2;
d = (3+al.^2).*(4 + (3+nu)*(1-nu)*al.^2);
rr = 0.5*log(n./d);
rr(al==0) = 0;
warning on
function e = e(al)
global nu
e = al.*(1 + nu + f(al));
function e = e2(al)
global nu
e = al.^3.*(1 + nu) + al.*f2(al);
function f = f(al)
%f = 2*al.^2./(sinh(al).^2 - al.^2);
warning off
im = real(al)<0;
al(im) = -al(im);
f = zeros(size(al));
ib = real(al)>1; ab = al(ib);
f(ib) = ab.^2*8.*exp(-2*ab)./((1-exp(-2*ab)).^2-4*ab.^2.*exp(-2*ab));
is = real(al)<=1; as = al(is);
f(is) = 2./((sinh(as)./as).^2-1);
warning on
function f = f2(al)
%f = 2*al.^2./(sinh(al).^2 - al.^2);
warning off
im = real(al)<0;
al(im) = -al(im);
f = zeros(size(al));
ib = real(al)>1; ab = al(ib);
f(ib) = ab.^2*8.*exp(-2*ab)./((1-exp(-2*ab)).^2-4*ab.^2.*exp(-2*ab));
is = real(al)<=1; as = al(is);
f(is) = 2./((sinh(as)./as).^2-1);
f = f.*al.^2;
f(al==0) = 6;
warning on
function g = g(al)
%g = al.*sinh(2*a)./(sinh(al).^2 - al.^2);
warning off
im = real(al)<0;
al(im) = -al(im);
g = zeros(size(al));
ib = real(al)>1; ab = al(ib);
g(ib) = ab*2.*(1-exp(-4*ab))./((1-exp(-2*ab)).^2-4*ab.^2.*exp(-2*ab));
is = real(al)<=1; as = al(is);
g(is) = (sinh(2*as)./as)./((sinh(as)./as).^2-1);
warning on
function tt = ti(x,al)
ya = imag(al);
ym = 0.5;
if (abs(ya)>ym)
y = 0;
elseif (ya>=0)
y = ya-ym;
else
y = ya+ym;
end
zeta = x + i*y;
tt = tex(zeta)./(zeta-al);
function tt = tcv(t,al)
inz = find(t~=0);
tnz = t(inz);
tt = zeros(size(t));
tt(inz) = ti(1./tnz,al)./tnz.^2;
function rr = ri(x,al)
ya = imag(al);
ym = 0.5;
if (abs(ya)>ym)
y = 0;
elseif (ya>=0)
y = ya-ym;
else
y = ya+ym;
end
zeta = x + i*y;
rr = rex(zeta)./(zeta-al);
function rr = rcv(t,al)
inz = find(t~=0);
tnz = t(inz);
rr = zeros(size(t));
rr(inz) = ri(1./tnz,al)./tnz.^2;
−10 −5 0 5 10−0.06−0.04−0.0200.020.040.06
−10 −5 0 5 10−0.0500.050.10.15
−10 −5 0 5 10−30−20−100102030
−10 −5 0 5 10−200020040060080010001200Numerical splits for Im k=−0.2. (a)θ−(k)andθ+(k)(imaginary parts dashed);
(b) their sum and θ(k); (c) (a)r−(k)andr+ (k)(imaginary parts dashed); (b) their
product and r(k).
Mixed boundary-value problems
The Wiener–Hopf method is useful for solving a certain class of mixed boundary-
value problems, in which φis given over part of the boundary and ∂φ/∂ nis given
over the rest of the boundary (or some other combination of boundary conditions).
Such problems are usually harder to solve than Dirichlet or Neumann problems.
Sneddon (1966) is a clear and useful reference. Many techniques use coupled in-
tegral equations. In some cases these can be solved by hand. In other cases, par-
ticularly when there are more than two boundary conditions, numerical approaches
are necessary. Often the solution is expressed along different parts of the contours
using different expansion functions, for example Chebyshev polynomials, and one
obtains an infinite set of linear equations that are then truncated and solved nu-
merically. This approach is sometimes combined with the Wiener–Hopf technique.
There have been developments since 1966, and a particularly interesting approach
is outlined in Fabrikant (1991). Very elegant formulas can be obtained directly for
some problems.
References
Publications:
•Abrahams, I. D., Davis, A. M. J. & Llewellyn Smith, S. G. Matrix Wiener–Hopf
approximation for a partially clamped plate. Q. J. Mech. Appl. Math. , doi:
10.1093/qjmam/hbn004.
•Fabrikant, V. I. Mixed boundary value problems of potential theory and their
applications in engineering , Kluwer, Dordrecht, 1991.
•Noble, B. Methods based on the Wiener–Hopf technique , Chelsea, New Y ork,
1988.
•Sneddon, I. M. Mixed boundary value problems in potential theory , North-
Holland, Amsterdam, 1966.
Matrix factorizations
Introduction
The transverse oscillations of a thin elastic plate, which may be statically or dy-
namically loaded, are governed by a differential equation, fourth order in space
and second order in time, that is a standard example in texts devoted to separa-
tion of variables and Fourier transform techniques. A classic unsolved problem in
bending plate theory is the displacement of a uniformly loaded infinite strip having
one edge clamped and the other clamped or free on two semi-infinite intervals.
The parallel lines’ geometry suggests the use of the Wiener–Hopf technique but
the advantage of the parallel edges in creating constant bending profiles far away
in either direction is offset by the appearance of a matrix Wiener–Hopf system.
The Wiener–Hopf technique has, since its invention in 1931, proved immensely
valuable in determining exact solutions to a huge variety of problems arising in
physics, engineering, and applied mathematics. Whilst the method is straightfor-
ward to apply for scalar equations, a key step fails in general for matrix systems;
see a detailed discussion on this point below. Here this classic problem is tackled
using a matrix Wiener–Hopf formulation. The solution is achieved by an approxi-
mate rather than exact procedure via application of Pad ´e approximants.
The Wiener–Hopf Problem
In terms of Cartesian coordinates (x,y), the static displacement w(x,y)of a plate,
situated at −∞<x< ∞,0≤y≤1, is governed by the fourth order equation
∇4w=q
D, (283)
whereqis a uniform load applied normal to the plane of the plate and Dis the
constant flexural rigidity. Physical choices of boundary conditions at a plate edge,
include a clamped edge:
w= 0 =∂w
∂y(284)
and a free edge:
ν∂2w
∂x2+∂2w
∂y2= 0, (2−ν)∂3w
∂x2∂y+∂3w
∂y3= 0, (285)
in whichνis Poisson’s ratio ( 0≤ν≤1/2). Thus, for a plate clamped at y= 0,1,
w=q
24Dy2(1−y)2(286)
while, for a plate clamped at y= 0but free aty= 1,
w=q
24Dy2(6−4y+y2). (287)
Consider a plate clamped at y= 0, allx, andy= 1,x< 0but free aty= 1,x> 0.
Then, in terms of two sets of Papkovitch–Fadle eigenfunctions whose details are
not needed here, ( 286,287) yield
w=q
24Dy2(1−y)2+/summationdisplay
n/negationslash=0Aneλnxφn(y) (x< 0),
w=q
24Dy2(6−4y+y2) +/summationdisplay
n/negationslash=0Bne−µnxψn(y) (x> 0). (288)
Now, in view of ( 286), it is advantageous to write the total displacement as
wtot=q
24Dy2(1−y)2+q
DW, (289)
whereWsatisfies ( 284) aty= 0andy= 1,x < 0and, from ( 283) and ( 285),W
is biharmonic and
ν∂2W
∂x2+∂2W
∂y2=−1
12e−/epsilon1x,(2−ν)∂3W
∂x2∂y+∂3W
∂y3=−1
2e−/epsilon1x(y= 1,x> 0).
(290)
Here the exponential factors have been introduced for mathematical convenience,
with/epsilon1a small positive number that will revert to zero after application of the Wiener–
Hopf technique.
In terms of the Fourier transform
Φ(k,y) =/integraldisplay∞
−∞W(x,y)eikxdx, (291)
the boundary conditions ( 284), (290) yield
Φ(k,0) = 0 = Φ y(k,0), (292)
/integraldisplay0
−∞W(x,1)eikxdx= Φ−(k,1) = 0 = Φ−
y(k,1) =/integraldisplay0
−∞Wy(x,1)eikxdx, (293)
/integraldisplay∞
0[Wyy−νk2W]eikxdx= Φ+
yy(k,1)−νk2Φ+(k,1) =−i
12(k+i/epsilon1), (294)
/integraldisplay∞
0[Wyyy−(2−ν)k2Wy]eikxdx= Φ+
yyy(k,1)−(2−ν)k2Φ+
y(k,1) =−i
2(k+i/epsilon1).(295)
Convergence of the above Fourier full and half-range transforms is ensured if klies
in an infinite strip containing the real line, here and henceforth referred to as D, with
its width limited from below by the singularity at k=−i/epsilon1. Evidently the unknown
pairs of (half-range transform) functions Φ+(k,1),Φ+
y(k,1)and Φ−
yy(k,1),Φ−
yyy(k,1)
are regular in the region above and including D, denoted D+, and the region below
and including D, denoted D−, respectively. Thus, D+∩ D−≡ D.
The displacement Wis bounded at x=±∞, so the biharmonic equation can be
Fourier transformed ( 291) to give
/parenleftbiggd2
dy2−k2/parenrightbigg2
Φ = 0 (296)
and hence a general solution which satisfies ( 292) is
Φ(k,y) =A(k)kysinhky+B(k)(kycoshky−sinhky). (297)
Application of the conditions ( 293) now yields:
/parenleftbigg
A(k)
B(k)/parenrightbigg
=1
sinh2k−k2×
/parenleftbigg
ksinhk −(kcoshk−sinhk)
−(kcoshk+ sinhk)ksinhk/parenrightbigg/parenleftbigg
Φ+(k,1)
k−1Φ+
y(k,1)/parenrightbigg
.(298)
Then the use of the conditions ( 294,295) facilitates the deduction of the following
matrix Wiener-Hopf equation
/parenleftbigg−Φ−
yyy(k,1)
Φ−
yy(k,1)/parenrightbigg
−i
2(k+i/epsilon1)/parenleftbigg
−1
1/6/parenrightbigg
=K(k)/parenleftbigg
Φ+(k,1)
Φ+
y(k,1)/parenrightbigg
, (299)
where
K(k) =/parenleftbigg
k2[g(k) +f(k)]−ke(k)
−ke(k)g(k)−f(k)/parenrightbigg
, (300)
e(k) =k/parenleftbigg
1 +ν+2k2
sinh2k−k2/parenrightbigg
, (301)
f(k) =2k2
sinh2k−k2, (302)
g(k) =ksinh 2k
sinh2k−k2. (303)
The determinant of the kernel is
|K(k)|=k4[4 + (3 +ν)(1−ν) sinh2k+ (1−ν)2k2]
sinh2k−k2, (304)
and the complex numbers {µn,λn;n≥1}appearing in ( 288) are the zeros in the
first quadrant of the numerator and denominator respectively. Negative values of n
denote complex conjugates.
It remains to consider the neighbourhood of (0,1), where the edge condition changes.
In terms of the polar coordinate representation x=−rcosθ,y= 1−rsinθ, a bi-
harmonic function w=rq+1F(θ) (0<θ <π )is required such that w= 0 =wyat
θ= 0andνwxx+wyy= 0 = (2 −ν)wxxy+wyyyatθ=π. Thus
F=A[cos(q+ 1)θ−cos(q−1)θ] +B/bracketleftbiggsin(q+ 1)θ
q+ 1−sin(q−1)θ
q−1/bracketrightbigg
,
where
2Acosqπ+ (1 +ν)Bsinqπ
q−1= 0, (1 +ν)(q−1)Asinqπ−2Bcosqπ= 0.
Hence the eigenvalue equation is
4 cos2qπ+ (1 +ν)2sin2qπ= 0,
whose solutions are
q=/parenleftbigg
n−1
2/parenrightbigg
±iK, tanhKπ=1 +ν
2,
for any integer n. But, for the displacement gradient to remain finite, Re (q)≥0
and so the lowest admissible value of nis 1. Therefore, wis of order r3/2as
r= [x2+ (1−y)2]1/2→0.
Factorization of the kernel
Introduction and overview of the factorization procedure
In the previous section the matrix Wiener–Hopf equation was derived, in which the
kernel, K(k), is written in ( 300). The aim of this section is to factorize K(k)into a
product of two matrices
K(k) =K−(k)K+(k), (305)
one containing those singularities of K(k)lying in the lower half-plane, referred
to asK+(k), andK−(k)which is analytic in the lower half-plane, D−, and hence
contains the singularities of K(k)lying above the strip D. Note that [K+(k)]−1
and[K−(k)]−1are also analytic in the regions D+andD−, respectively. Further, it
is necessary for successful completion of the Wiener–Hopf procedure that K±(k)
are at worst of algebraic growth. Unfortunately, although matrix kernel factoriza-
tion with the requisite growth behaviour has been proven to be possible for a wide
class of kernels, to which the kernel ( 300) belongs, no constructive method has yet
been found to complete this in general. There are classes of matrices for which
product factorization can be achieved explicitly, the most important of which are
those amenable to Hurd’s method and Khrapkov-Daniele commutative matrices
The present problem yields a kernel which falls outside of the classes permit-
ting an exact factorization and so an approximate decomposition will be performed
here. Essentially, the procedure is to rearrange the kernel into an appropriate form,
namely to resemble a Khrapkov (commutative) matrix, and then to replace a scalar
component of it by a function which approximates it accurately in the strip of analyt-
icityD. The new approximate kernel is able to be factorized exactly (into an explicit
non-commutative decomposition) and, in the previous cases cited above, strong
numerical evidence was offered for convergence of the resulting approximate fac-
tors to the exact ones as the scalar approximant is increased in accuracy.
Conditioning of the matrix kernel
The matrix K(k)is characterized by its elements e(k),f(k),g(k), given in ( 301)–
(275), and in particular by their behavior for large and small k. Evidently,
e(k)∼k(1 +ν), f (k)∼0, g (k)∼2|k|as|k| → ∞,k∈ D (306)
and
f(k)∼6
k2, g (k)−f(k)∼2
3k2f(k), e (k)∼kf(k)ask→0. (307)
It is appropriate to arrange the kernel ( 300) so that the diagonal elements are equal
to the same even function, and the off-diagonal terms are odd as k→ ∞ . This is
achieved by the rearrangement
K(k) =1
2/parenleftbigg
0−k
1 0/parenrightbigg/parenleftbigg
1−1
i i/parenrightbigg
L(k)/parenleftbigg
i1
i−1/parenrightbigg/parenleftbigg
k0
0 1/parenrightbigg
, (308)
whereL(k)takes the form
L(k) =g(k)I+/parenleftbigg
0f(k) +ie(k)
f(k)−ie(k) 0/parenrightbigg
, (309)
withIthe identity. The definition of K(k)in (300) easily establishes the subse-
quently useful properties
K(−k) =K(k) = [K(k)]T, (310)
whereTdenotes the transpose.
NowL(k)is arranged in Khrapkov form, having the square of the second matrix
term in ( 309) equal to a scalar polynomial in ktimes the identity. This is achieved
by removing the factor/radicalbig
f2(k) +e2(k)from this matrix in ( 309). However, as
f(k)±ie(k)∼(1±ik)f(k), k →0, (311)
it is more effective to write L(k)as
L(k) =g(k)I+/radicalbigg
f2(k) +e2(k)
1 +k2J(k), (312)
J(k) =/parenleftbigg
0d(k)(1 +ik)
d−1(k)(1−ik) 0/parenrightbigg
, (313)
in which
d(k) =/radicalBigg/parenleftbiggf(k) +ie(k)
f(k)−ie(k)/parenrightbigg/parenleftbigg1−ik
1 +ik/parenrightbigg
. (314)
Evidently, a branch of d(k)can be chosen to be regular in D, equal to unity at
k= 0 and, because of ( 306), tend to unity at infinity in the strip. Thus the factor
(1−ik)/(1 +ik)ind(k)not only ensures an order k2deviation from unity but also
causes arg[d(k)]to tend to zero as k→0andk→ ±∞ . Note that the function
d(k)has an infinite sequence of finite branch-cuts at symmetric locations in the
upper and lower half-planes. The matrix L(k)now appears to be in Khrapkov form,
because
J2(k) = ∆2(k)I, ∆2(k) = 1 +k2(315)
butJ(k)fails to be entire, having the infinite sequences of finite branch-cuts as-
sociated with d(k). These will have to be considered once the partial Khrapkov
decomposition is complete, but for the present will be ignored.
Partial decomposition of K(k)
Before performing the Khrapkov factorization on L(k), it is necessary to note, from
(307), (309), that ask→0,
|L(k)|=g2−f2−e2∼12
k2+O(1), (316)
which is singular at the origin, contrary to the original assumption of regularity in D.
This removable singularity, due to the use of L(k)instead of K(k), is conveniently
handled by introducing the resolvent matrix, R(k), defined by
R−1(k) = (1 +2
3k2)I−J(k), (317)
which commutes with L(k). The combined matrix
T(k) =R−1(k)L(k) (318)
has determinant value 4 at k= 0 which allows T(k)to be factorized instead of
L(k). The subsequent factoring of R(k)will not pose any difficulty.
Since any matrices of the form αI+βJ(k), likeR−1(k)andT(k), will commute,
the product factors of T(k)may be posed in the form
T±(k) =r±(k)/parenleftbigg
cosh[∆(k)θ±(k)]I+1
∆(k)sinh[∆(k)θ±(k)]J(k)/parenrightbigg
, (319)
wherer±(k),θ±(k)are scalar functions of kwith the analyticity property indicated
by their superscript. The function ∆(k), given by ( 315), generates no branch-cuts
because ( 319) contains only even powers of ∆(k). The scalar factors r±(k),θ±(k)
are deduced by equating
T(k) =T+(k)T−(k), (320)
which yields the decomposition discussed in Chapter 70. Hence T±(k)have been
determined ( 319,279,281) in a form which can be evaluated directly and these
are analytic in their indicated half-planes, D±, except for the singularities occurring
inK(k)(due tod(k)) which have yet to be resolved.
The inverse of R(k), introduced above in order to improve the convergence of L(k),
was chosen in a form that now allows R(k)to be easily constructed and directly
factorized. First, R−1(k)may, by inspection, be written in the form
1
2[(1 +ik/√
3)I−J(k)][(1−ik/√
3)I−J(k)], (321)
where both matrices are entire save for the finite cuts in the scalar function d(k)
contained within J(k). It is then readily apparent that the partial decomposition of
the resolvent matrix is
R(k) = 2R+(k)R−(k), (322)
where
R±(k) =3
4k(k±i√
3/2)/bracketleftBig
(1∓ik/√
3)I+J(k)/bracketrightBig
, (323)
i.e. each matrix is analytic in its indicated half-plane except for poles at k= 0and
the finite branch-cuts in d(k). Note that R±(k)commute with each other and with
T±(k). Hence this completes the partial product factorization of K(k), namely,
from ( 308,318,320,322),
K(k) =Q−(k)Q+(k), (324)
where
Q−(k) =/parenleftbigg
−ik−ik
1−1/parenrightbigg
R−(k)T−(k), (325)
Q+(k) =T+(k)R+(k)/parenleftbigg
ik 1
ik−1/parenrightbigg
. (326)
Note that Q±(k)are without a pole singularity at k= 0even though R±(k)contain
this singularity (verified later in section 3.4). All that remains is to (approximately)
remove the residual singularities appearing in J(k).
Approximate factorization
There is no exact procedure known for eliminating the finite branch-cuts in d(k)
from the upper (lower) half-planes of the matrix factor Q+(k)(Q−(k)). To obtain
an approximate factorization the original matrix K(k)is replaced by a new one,
KN(k), where
KN(k) =1
2/parenleftbigg
0−k
1 0/parenrightbigg/parenleftbigg
1−1
i i/parenrightbigg
LN(k)/parenleftbigg
i1
i−1/parenrightbigg/parenleftbigg
k0
0 1/parenrightbigg
, (327)
LN(k) =g(k)I+/radicalbigg
f2(k) +e2(k)
1 +k2JN(k) (328)
andJN(k)is as given in ( 313) but with a modified scalar d(k)→dN(k), i.e.
JN(k) =/parenleftbigg
0dN(k)(1 +ik)
d−1
N(k)(1−ik) 0/parenrightbigg
. (329)
The scalardN(k)is any function which approximates d(k)accurately in the strip
D, and for efficacy of the following method it is most convenient to use a rational
function approximation
dN(k) =PN(k)
QN(k), (330)
wherePN(k),QN(k)are polynomial functions of order N. Note that the order of
each polynomial is the same as it is required that dN(k)→1as|k| → ∞ . There
is a variety of ways of generating the coefficients of these polynomials, and the
simplest and perhaps most justifiable (in terms of its analyticity properties) is to
use Pad ´e approximant. Care is required to ensure that dN(k)does not introduce
spurious singularities into the strip of analyticity Dand consequently produce an in-
accurate factorization. One-point Pad ´e approximants, if they exist, are determined
uniquely from the Taylor series expansion of the original function at any point of
regularity and accurately serve our current purposes because of the rapid decay at
large realkthat is present in the Fourier transforms ( 380) and ( 381). The polynomi-
alsPN(k)andQN(k)are determined uniquely from/summationtext∞
n=0fnkn−PN(k)/QN(k) =
O(k2N+1)wherefnare the coefficients of the Maclaurin series expansion of dN(k).
The definition ( 314) displays the symmetry, d(−k) = 1/d(k), which must be re-
flected in the similar approximant behaviour:
dN(−k) = 1/dN(k). (331)
HenceQN(k) =PN(−k)in (330), since the approximant is assumed to be in its
lowest form. Then Nmust be even (N= 2M)for the limit value unity to be attained
at the origin and at infinity in D. Thus, for example,
d4(k) =1 +13
15k2+1+ν
6k3(i
2+k)−197
1575k4
1 +13
15k2+1+ν
6k3(−i
2+k)−197
1575k4, (332)
with errors O(k9)ask→0andO(k−1)as|k| → ∞ inD. After writing [(f+
ie)/(1 +ik)]1/2as a power series in ik, suitably truncated, an equivalent procedure
that exploits the numerator/denominator symmetry in d(k)is cross-multiplication.
Then, for ( 332), only the terms in ik,ik3,ik5,ik7need be considered and suffice to
determine the four coefficients in d4(k).
Note that the approximation of just d(k)does not change the form of the scalar
Khrapkov factors ( 279), (281), and so a partial decomposition of KN(k)is simply
KN(k) =Q−
N(k)Q+
N(k) (333)
in which Q±
N(k)are given by ( 325), (326), with R±(k),T±(k)replaced respec-
tively by R±
N(k)andT±
N(k), for which the subscript Ndenotes that JN(k), given
by (329), everywhere replaces J(k). Thus, the factorization of KN(k)has been
accomplished apart from sequences of poles, arising from the zeros and poles of
dN(k)occurring in both half-planes exterior to D. The removal of these singular-
ities will then achieve an explicit exact factorization of KN(k)which approximates
the actual factors K±(k)in their regions of analyticity.
The exact factorization of KN(k), given by ( 327), may be written as
KN(k) =K−
N(k)K+
N(k), (334)
K−
N(k) =Q−
N(k)M(k),K+
N(k) =M−1(k)Q+
N(k) (335)
in which M(k)must be a meromorphic matrix chosen to eliminate the poles of
Q−
N(k)in the lower half-plane and the poles of Q+
N(k)inD+. A (non-unique) ansatz
forM(k)can be posed after noting certain symmetry properties of Q±
N(k). From
(331),
JN(−k) = [JN(k)]T, (336)
where the superscript denotes the transpose, and so by inspection of ( 323),
R+
N(−k) = [R−
N(k)]T. (337)
Similarly, from ( 280), (282) and the obvious evenness of ∆(k)in (315), changing k
to−kin (319) reveals
T+
N(−k) = [T−
N(k)]T. (338)
Hence it is found (see ( 326)) that
Q+
N(−k) = [T−
N(k)]T[R−
N(k)]T/parenleftbigg
−ik−ik
1−1/parenrightbiggT
= [Q−
N(k)]T(339)
and thus the second equation in ( 335) gives:
K+
N(−k) =M−1(−k)[Q−
N(k)]T. (340)
Symmetry properties dictate, by comparison with the first equation in ( 335), that a
suitably scaled M(k)can be constructed so that M−1(−k) = [M(k)]T. After this is
achieved, it suffices to eliminate poles of K−
N(k)in the lower half plane.
Evidently,d2M(k)is a ratio of polynomials in (ik)with real coefficients so the zeros
ofP2M(k)are pure imaginary and/or pairs of the form ±k1+ik2. Moreover, the
vanishing of the kterm inP2M(k)implies that the sum of the inverses of the zeros
is zero. Hence at least one zero lies in each (upper/lower) half-plane. Suppose
now thatd2M(k)hasNp(0< N p<2M)poles in the upper half-plane at k=ipn,
n= 1,2,...,N p(ipn/negationslash∈ D−) andNq(= 2M−Np)poles in the region below the strip
atk=−iqn,n= 1,2,...,N q. These are the zeros of P2M(−k), that is,P2M(k)has
2M(=N)simple zeros at
k=−ipn, n = 1,2...,N p;k=iqn, n = 1,2...,N q (341)
in lower and upper regions respectively. Thus, dN(k)and its inverse may be ex-
pressed as Mittag-Leffler expansions:
d2M(k) = 1 +Np/summationdisplay
n=1αn
pn+ik+Nq/summationdisplay
n=1βn
qn−ik, (342)
1
d2M(k)= 1 +Np/summationdisplay
n=1αn
pn−ik+Nq/summationdisplay
n=1βn
qn+ik. (343)
The coefficients αn,βnare easily determined from the coefficients of the polynomial
P2M(k). By inspection of the location of dN(k)inQ−
N(k), the ansatz for M(k)is now
posed
M11(k) =1√
2+Np/summationdisplay
n=1An
pn+ik+Nq/summationdisplay
n=1Bn
qn−ik,
M21(k) =1√
2+Np/summationdisplay
n=1Cn
pn−ik+Nq/summationdisplay
n=1Dn
qn+ik, (344)
and
M22(k) =1√
2+Np/summationdisplay
n=1En
pn−ik+Nq/summationdisplay
n=1Fn
qn+ik,
−M12(k) =1√
2+Np/summationdisplay
n=1Gn
pn+ik+Nq/summationdisplay
n=1Hn
qn−ik, (345)
whereAn,Bn,Cn,Dn,En,Fn,Gn,Hnare as yet undetermined constants. The
construction of M−1(k)involves
|M(k)|=M11(k)M22(k)−M12(k)M21(k), (346)
whose poles are eliminated by satisfying
AmM22(ipm)+GmM21(ipm) = 0, M 11(−ipm)Em−M12(−ipm)Cm= 0 (1 ≤m≤Np),
BmM22(−iqm)+HmM21(−iqm) = 0, M 11(iqm)Fm−M12(iqm)Dm= 0 (1 ≤m≤Nq).
Comparison of ( 344) and ( 345) shows that this is achieved by setting
M22(k) =M11(−k),−M12(k) =M21(−k), (347)
i.e.,En=An,Gn=Cn(1≤n≤Np),Fn=Bn,Hn=Dn(1≤n≤Nq), and
requiring that
AmM11(−ipm) +CmM21(ipm) = 0 (1 ≤m≤Np), (348)
BmM11(iqm) +DmM21(−iqm) = 0 (1 ≤m≤Nq). (349)
By pre-multiplying M(k)byR−
N(k)T−
N(k), and eliminating poles in the lower half-
plane, conditions relating the coefficients An,Bn,Cn,Dncan be found. From ( 319)
and ( 323), it is known that
/bracketleftBig
(1 +ik/√
3)I+JN(k)/bracketrightBig/bracketleftbigg
cosh[∆(k)θ−(k)]I+1
∆(k)sinh[∆(k)θ−(k)]JN(k)/bracketrightbigg
M(k)
must be analytic in D−and so, according to ( 329), poles in the lower half-plane are
to be removed from
W(k) =/parenleftbigg
a−(k)b−(k)(1 +ik)dN(k)
b−(k)(1−ik)/dN(k)a−(k)/parenrightbigg
M(k), (350)
where
a±(k) = (1 ∓ik/√
3) cosh[∆(k)θ±(k)] + ∆(k) sinh[∆(k)θ±(k)], (351)
b±(k) = cosh[∆( k)θ±(k)] +1∓ik/√
3
∆(k)sinh[∆(k)θ±(k)] (352)
are scalar functions analytic in the indicated regions and such that
a−(k) =a+(−k), b−(k) =b+(−k). (353)
From ( 350),
W11(k) =a−(k)M11(k) +b−(k)(1 +ik)d2M(k)M21(k), (354)
which contains simple poles in the lower half-plane only at k=−iqn,n= 1,2,...,N q
because, by comparison of ( 343) and ( 344),d2M(k)M21(k)is regular at the poles
ofM21(k). The matrix element in ( 354) is forced to remain finite at k=−iqnby
setting
a−(−iqm)Bm+b−(−iqm)βm(1 +qm)M21(−iqm) = 0, m = 1,...,N q.(355)
Similarly, in ( 350),W21(k)contains no poles in the lower half-plane if and only if
a−(−ipm)Cm+b−(−ipm)αm(1−pm)M11(−ipm) = 0, m = 1,...,N p.(356)
The second column of ( 350) yields similar equations when suppressing the remain-
ing poles in the lower half-plane. Thus, after use of ( 347),
a−(−ipm)Am−b−(−ipm)αm(1−pm)M21(ipm) = 0, m = 1,...,N p, (357)
−a−(−iqm)Dm+b−(−iqm)βm(1 +qm)M11(iqm) = 0, m = 1,...,N q.(358)
By inspection, ( 356), (357) imply ( 348) and ( 355), (358) imply ( 349). Then |M(k)|
is entire and, since it takes the value unity at infinity, must by Liouville’s theorem be
given by
|M(k)|= 1. (359)
Moreover, this ensures that M−1(−k) = [M(k)]T, as anticipated above, and that
the inverses of K±
N(k)are also free of singularities in D±respectively. Confirmation
that these equations suffice to eliminate poles of K+(k)in the upper-half plane is
obtained by showing that M−1(k)T+(k)R+(k) = [W(−k)]T. The sets of equations
(355)–(358) constitute a linear system of 2Mequations for the 2MunknownsAm,
Bm,Cm,Dmand are easily solved to determine their values. Note that it may
transpire that 1 +qmor1−pmis zero for particular choices of m,Netc. in which
caseBm,DmorAm,Cmwould vanish.
The explicit approximate factorization of K(k)is complete, having obtained an ex-
act noncommutative matrix product decomposition of KN(k). The factors K±
N(k)
are constructed from ( 335), with Q±
N(k)given from ( 329), (325), (326), (323) and
(319). The meromorphic matrix takes the explicit form ( 344) in which the coef-
ficients satisfy algebraic equations ( 355)–(358). AsN= 2Mincreases it is ex-
pected that K±
N(k)will converge rapidly to the exact factors K±(k)and this will be
borne out by numerical results given in section 5. All that remains here is to verify
that the apparent pole at k= 0inR±(k)is removed and to give the behaviours of
K±
N(k)for large |k|inD±.
Ask→0,dN(k)→1by virtue of the function d(k)in (314), and hence R±
N(k)
behaves as, from ( 313) and ( 323),
R±
N(k) =∓i√
3
2k/parenleftbigg
1 1
1 1/parenrightbigg
+O(1). (360)
Therefore/parenleftbigg
−ik−ik
1−1/parenrightbigg
R−
N(k)∼√
3/parenleftbigg
1 1
0 0/parenrightbigg
+O(1), k→0. (361)
Now,T±
N(k), from their definitions, are bounded at the origin and, by inspection, so
also is M(k)in (344). Hence, from ( 335) and ( 361) it may be deduced that
K−
N(k) =O(1), k →0. (362)
Similarly, from above,
R+
N(k)/parenleftbigg
ik 1
ik−1/parenrightbigg
=O(1), k→0 (363)
and so K+
N(0)is bounded too.
As|k|tends to infinity it is a straightforward matter to deduce the asymptotic be-
haviour of the product factors. First, by inspection of ( 323),
R±
N(k)∼3i
4k/parenleftbigg
∓1/√
3 1
−1∓1/√
3/parenrightbigg
(364)
in view of the fact that dN(k)isdefined inJN(k)to behave as
dN(k)→1,|k| → ∞. (365)
Second, the asymptotic form of the Krapkhov decomposition elements r±(k)can
be deduced from its integral definition written in ( 281), whose exponent has an
integral that is O(k−1)for large |k|. Hence, by inspection,
r±(k) = [(3 +ν)(1−ν)4/9]1/4e∓3iπ/4k3/2+O(k1/2),|k| → ∞,k∈ D±.(366)
Third, the asymptotic form of the Krapkhov decomposition elements θ±(k)cannot,
due to L(k)not being diagonally dominant as |k| → ∞ inD, be similarly deduced
from their integral definition written in ( 279) because the right-hand side of ( 278) is
O(1)for large |k|. Hence it is necessary to first subtract tanh−1[(1 +ν)/2]before
using the sum-split formula and then employ the standard decomposition
1
∆(k)=2
π(1+k2)−1/2arctan/parenleftbiggi−k
i+k/parenrightbigg1/2
+2
π(1+k2)−1/2arctan/parenleftbiggi+k
i−k/parenrightbigg1/2
,(367)
in which
2 arctan/parenleftbiggi−k
i+k/parenrightbigg1/2
=π
2+iln[√
1 +k2+k],
to show that
θ±(k)∼ ±/bracketleftbigg
ln/parenleftbigg3 +ν
1−ν/parenrightbiggiln|k|
2πk+χ
k/bracketrightbigg
,|k| → ∞,k∈ D±, (368)
where
χ=i
π/integraldisplay∞
0/bracketleftBigg
tanh−1/braceleftBigg
(1 +2
3ζ2)/radicalbig
f2(ζ) +e2(ζ)−∆(ζ)g(ζ)
(1 +2
3ζ2)g(ζ)−∆(ζ)/radicalbig
f2(ζ) +e2(ζ)/bracerightBigg
−tanh−11 +ν
2/bracketrightBigg
dζ
∆(ζ).
(369)
Thus, from ( 319),T±
N(k) =O(k3/2). Last, the meromorphic matrix ( 344) has the
large|k|form
M(k) =1√
2/parenleftbigg
1−1
1 1/parenrightbigg
, (370)
and therefore Q±
N(k)in (325), (326) can be estimated. Finally, the asymptotic
growth of K±
N(k)in (335) is found to be:
K−
N(k)∼k1/2/parenleftbigg
−ik−ik
1−1/parenrightbigg/parenleftbigg
O(1)O(1)
O(1)O(1)/parenrightbigg
,
K+
N(k)∼/parenleftbigg
O(1)O(1)
O(1)O(1)/parenrightbigg
k1/2/parenleftbigg
ik 1
ik−1/parenrightbigg
. (371)
Hence
[K−
N(k)]−1∼/parenleftbigg
O(1)O(1)
O(1)O(1)/parenrightbigg
k−1/2/parenleftbigg
ik−11
ik−1−1/parenrightbigg
(372)
and the kernel decomposition is now complete.
Solution of the Wiener–Hopf equation
Having obtained an approximate factorization of K(k)it is now a straightforward
matter to complete the solution of the Wiener–Hopf equation ( 299). Dropping the
subscriptNin the factorization ( 334) for brevity, the Wiener–Hopf equation can be
recast into the form
[K−(k)]−1/parenleftbigg−Φ−
yyy(k,1)
Φ−
yy(k,1)/parenrightbigg
−i
2(k+i/epsilon1)/braceleftbig
[K−(k)]−1−[K−(−i/epsilon1)]−1/bracerightbig/parenleftbigg
−1
1/6/parenrightbigg
=
E(k) =K+(k)/parenleftbigg
Φ+(k,1)
Φ+
y(k,1)/parenrightbigg
+i
2(k+i/epsilon1)[K−(−i/epsilon1)]−1/parenleftbigg
−1
1/6/parenrightbigg
, (373)
wherek∈ D . The left-hand side is analytic in D−, whereas the right-hand side
is regular in D+. Thus, the equation has been arranged so that the two sides
offer analytic continuation into the whole complex k-plane which must therefore be
equal to an entire function, say E(k), that is determined by examining the growth
at infinity of both sides of ( 373) in their respective half-planes of analyticity. This
requires the large kbehaviour of Φ+(k,1),Φ+
y(k,1),Φ−
yy(k,1),Φ−
yyy(k,1), which
relate directly to the values of the untransformed physical variables near to (0,1),
where the edge condition changes. For example, a function which behaves like xn,
x→0+, has a half-range ( 0to∞) Fourier transform which decays like O(k−n−1),
k→ ∞ in the upper half plane. Hence w=O(r3/2)asr= [x2+ (1−y)2]1/2→0
implies that
Φ+(k,1) =O(k−5/2),Φ+
y(k,1) =O(k−3/2) (374)
as|k| → ∞ ,k∈ D+and
Φ−
yy(k,1) =O(k−1/2),Φ−
yyy(k,1) =O(k1/2),|k| → ∞,k∈ D−. (375)
These are used, together with the asymptotic forms ( 371), (372) to reveal that both
elements of the left-hand side of ( 373) decay as O(k−1)in the lower half plane
and similarly the right-hand side has the form o(1)as|k| → ∞ in the upper half
plane. Hence, E(k)is an entire function which decays to zero at infinity, and so, by
Liouville’s theorem,
E(k)≡0. (376)
Thus, the solution of the Wiener–Hopf equation is
/parenleftbigg−Φ−
yyy(k,1)
Φ−
yy(k,1)/parenrightbigg
=i
2(k+i/epsilon1)/braceleftbig
I−K−(k)[K−(−i/epsilon1)]−1/bracerightbig/parenleftbigg
−1
1/6/parenrightbigg
(377)
or, equivalently,
/parenleftbigg
Φ+(k,1)
Φ+
y(k,1)/parenrightbigg
=−i
2(k+i/epsilon1)[K+(k)]−1[K−(−i/epsilon1)]−1/parenleftbigg
−1
1/6/parenrightbigg
. (378)
From this, the coefficients A(k),B(k)are readily deduced from ( 298) and hence
Φ(k,y)is established for all y,0< y < 1, from ( 297). Finally, on setting the
convergence factor /epsilon1equal to zero in ( 377), the additional displacement due to the
semi-infinite free edge is
q
DW=q
2πD/integraldisplay∞
−∞Φ(k,y)e−ikxdk, (379)
where the integral path runs along the real line indented above the origin, and
Φ(k,y) =−i
2(sinh2k−k2)/parenleftbigg
ysinhky
ycoshky−k−1sinhky/parenrightbiggT
×
/parenleftbigg
ksinhk −(coshk−k−1sinhk)
−(kcoshk+ sinhk) sinh k/parenrightbigg
[K+(k)]−1[K−(0)]−1/parenleftbigg
−1
1/6/parenrightbigg
.
(380)
It is a straightforward matter to verify that, when this solution is substituted into
(289), the total displacement satisfies the fourth-order equation ( 283) and the bound-
ary conditions ( 284), (285). Moreover, Wevidently has the structure predicted by
(288) forx< 0, in which case the contour in ( 379) is completed in D+and residues
at the zeros of sinh2k−k2are obtained. An alternative form for ( 380) is obtained by
replacing [K+(k)]−1by[K(k)]−1K−(k), according to ( 305), and substituting ( 300)
and ( 304), whence
Φ(k,y) =−i
2k2[4 + (3 +ν)(1−ν) sinh2k+ (1−ν)2k2]/parenleftbigg
ysinhky
ycoshky−k−1sinhky/parenrightbiggT
×/parenleftbigg
[(1−ν) coshk+ (1 +ν)k−1sinhk]−[(1−ν)ksinhk−2 coshk]
−[(1−ν) sinhk+ 2k−1coshk] [(1 −ν)kcoshk−(1 +ν) sinhk]/parenrightbigg
×K−(k)[K−(0)]−1/parenleftbigg
−1
1/6/parenrightbigg
. (381)
Then, forx > 0, completion in D−of the contour in ( 379) yieldsqy2(5−2y)/24D
from the pole at the origin and residues at the zeros of [4 + (3 +ν)(1−ν) sinh2k+
(1−ν)2k2], which include a pair on the imaginary axis determined by k=iκ,4−
(1−ν)2κ2= (3 +ν)(1−ν) sin2κ. Thus the structure of Wpredicted by ( 288) for
x< 0is demonstrated.
Numerical computations
The calculations are carried out with MATLAB, except for the evaluation of the
Pad´e approximants d2M, which are obtained using Maple. The resulting fractions
are then converted to floating points (16 digit accuracy) and returned to MATLAB.
Accuracy is low unless N= 2MwithMeven, to take account of symmetries
about both axes. Maximum accuracy occurs at about N= 2M= 16 . This could
be increased by using variable precision arithmetic. The poles ipm,−iqmand coef-
ficientsαm,βmin (342) are then readily determined, followed by JN(k)andR+
N(k).
Evaluation of r+
N(k),θ+
N(k)yieldsT+
N(k)and hence Q+
N(k), given by ( 326). The
scalar Wiener–Hopf decomposition of randθis accomplished using standard
MATLAB numerical integration. The default relative accuracy of 10−6was amply
sufficient, since as in many contour integrals of analytic functions, higher accuracy
was actually obtained. Finally K+
N(k)is constructed. The displacement, W(x,y),
is evaluated as a sum of the residues of ( 380) over the first 50poles in the upper
half-plane for x < 0. Note that once the residues are known, the inverse Fourier
transform ( 379) can be computed for different xfor essentially no further cost. The
companion matrix function K−
N(k), needed in ( 381) forx > 0, is constructed sim-
ilarly. The oscillatory case is algebraically more complicated but structurally the
same.
The numerical evaluation of the approximation [K+
N(k)]−1to[K+(k)]−1in (380) de-
pends on the accurate determination of the coefficients a+(ipm),... in the sets of
equations ( 355)–(358). These are given by ( 351), (352), in which ∆(k)appears
analytically but branch 5Bcuts may arise from the presence of θ±(k)in the sinh
functions. By factoring ∆(ζ)from the numerator of the fraction in ( 279), it is evident
that the branch cuts created by the approximate factorization arise solely from the
square root in the definition ( 312) ofL(k).
Very high accuracy would require variable precision arithmetic and a large number
of terms in the residue sum, especially when computing the deflection near the
transition between the free and clamped edges.
Values ofνfor naturally occurring materials are constrained thermodynamically to
lie between 0and 1/2. Examples are cork ( ν= 0), concrete ( ν= 0.2), stainless
steel (ν= 0.3) and rubber ( ν= 0.5). A typical example of a Pad ´e approximant
for the steady ν= 1/2case is shown in Figure 36for real values of k. The be-
haviour near the origin of the error is of the appropriate power and the error de-
creases for large k. Note that the relative error decreases slowly for large k, but
this is unimportant. The sum over the residues at the zeroes and poles of |K|re-
quires evaluating the Pad ´e approximant off the real axis. The curves analogous to
those of Figure 36become very confusing close to branch cuts, where the smooth,
single-valued Pad ´e approximant lacks the significant jumps in dnear its artificially
created cuts. Nevertheless, the computed residues approach the exact ones. The
behaviour for other values of νand in the oscillatory case is qualitatively the same.
Figure 37shows the plate displacement for the steady cases with ν= 0.3for
N= 16 . The difference between these results and those for νin the range (0,1/2)
are small and so other results are not shown. The relative difference in Wbetween
ν= 0 andν= 1/2, except on the boundaries, are 15% or smaller and decay
very rapidly for x < 0. The surface has an imperceptible defect at x= 0: the
values ofW(0,y)computed using ( 380) and ( 381) are not exactly the same in the
Pad´e approximant technique, but would be the same for the exact matrix K. This
discrepancy provides an estimate of the error, which is found to decrease with N
until at least N= 16 . The plate is deformed substantially in the region 0< x < 1
and then attains its asymptotic value smoothly.
0 5 10 150.80.850.90.951
krRe d; Re d2N
0 5 10 1500.20.40.60.81
krIm d; Im d2N
0 5 10 1510−1510−1010−5100
kr100|(d−d2N)/d|
10−210010210410−1510−1010−5100
kr|d−d2N|Pad´e approximant to d(k)(314) in the steady case with ν= 1/2forN= 4,8,12,
16. Curves with larger Ncluster together. (a) Real and (b) imaginary parts. (c)
Percentage relative error in modulus on a logarithmic scale. (d) Absolute error.
−505
00.20.40.60.81−0.0200.020.040.060.080.10.120.14
xyhDisplacement W(x,y)forν= 0.3withN= 16 .
Conclusion
The Pad ´e approximant technique for matrix Wiener–Hopf equations yields accu-
rate numerical results for a classic plate deflection problem, whether the forcing be
static or dynamic. The theory is complicated by the need for successive modifi-
cations L,Tof the kernel and M,M−1of the matrix factors Q−,Q+in order to
achieve the required analyticity of K−andK+. The numerical implementation is
conceptually straightforward, but, like many problems in numerical complex anal-
ysis, requires careful attention to the analyticity properties of the functions being
used. The technique provides a constructive scheme to obtain the physical solu-
tion without the difficulties involved in matching the biorthogonal Papkovich–Fadle
eigenfunctions.
Physically, the reason that the displacement is insensitive to the value of νappears
to be that the imposed load and the clamped boundary condition do not give much
of a role toν, which relates compression in one direction to expansion/compression
in the other, at least in the steady case. Of course the actual dependence on νof
the displacement can only be determined by carrying out the calculation. Unfortu-
nately, there doesn’t appear to be a special value of νfor which everything can be
solved by hand. This suggests that for similar problems, a single value of νcan be
used to obtain typical results.
Integral equations (05/13/08)
Types of equations
We have already met linear integral equations, Fredholm
f(x) =λ/integraldisplay1
0k(x,t)f(t) dt+g(x) (382)
and Volterra
g(x) =λ/integraldisplayx
0k(x,t)f(t) dt, (383)
wheref(t)is an unknown function, to be found, in both cases. The above are
equations of the second and first kind (F2 and V1 respectively).
The Wiener–Hopf technique of the previous two chapters can also be phrased in
terms of coupled integral equations on semi-infinite intervals. Now seems like a
good time to return to integral equations. Let’s solve some that are not in convolu-
tion form, and then turn to integrals with singular kernels, i.e. in which the integral is
a principal value integral. These provide beautiful applications of complex variable
ideas.
Solving integral equations numerically is treated quite well in Numerical Recipes ,
both for Volterra and Fredholm equations. Be careful though: the midpoint? method
suggested for V2 is said to work fine for V1, but a look at Linz (1985) will show that
this is incorrect.
Non-singular equations
We can show very simply how V2 reduces to a system of linear equations. Re-
member that V2 is
f(x) =λ/integraldisplayx
0k(x,t)f(t) dt+g(x). (384)
Discretize the interval into segments with endpoints 0,h,2h, . . .x, withx=Nh.
This implies it’s easiest to increase xin units ofhto avoid fractional segments.
Now evaluate ( 384) at the point (m+1
2)h, discretizing the integral by the midpoint
rule:
fm=λm/summationdisplay
n=01
2kmnfn+gm, (385)
wherefm=f((m+1
2)h),kmn=k(((m+1
2)h,(n+1
2)h)andgm=g((m+1
2)h).
This is now a lower-diagonal set of linear equations that can be solved by back-
substitution.
One can use the trapezium rule instead. The result is almost as simple, but one
has to be slightly more careful. The same method clearly makes sense for V1
and Fredholm equations. For the latter case, the linear system is no longer lower-
diagonal, but this is no impediment. For the former, there is a technical problem.
More sophisticated methods exist, including means for dealing with integrable sin-
gularities in the kernel. These include integrating out the singularity or using more
sophisticated quadrature rules. This leads onto the topic of Gaussian integra-
tion, which we may see again briefly when talking about orthogonal polynomials
in Chapter 128.
Another improvement for V1 is the algorithm described by Linz (1985) which lends
itself well to Richardson extrapolation (known as the deferred approach to the limit
in the old days). It is just based on the ... quadrature rule, which has known
errorh2/12(remember this always includes an unknown prefactor depending on
the exact function being integrated, but independent of h). Figure 38shows the
results of this method applied to the following test problems in Linz (1985):
/integraldisplayt
0cos (t−s)f(s) ds= 1−cost, (386)
/integraldisplayt
0[1 + 2(t−s)]f(s) ds=t, (387)
/integraldisplayt
0
cos (t−s) 0 0
0 1 + 2( t−s) 0
1 e−(t−s)1
f(s) ds=
1−cost
t
1
2t2
. (388)
Note that the third equation is a matrix V1 equation with the first two lines repro-
ducing the first two problems.
The routine p131.m includes specific provision for convolution kernels, which should
lead to a slight gain in efficiency, as well as for Richardson extrapolation. The plots
of Figure 38clearly show the O(h2)convergence for the bare algorithm, compared
toO(h4)convergence for the algorithm with extrapolation.
Tip 6 Richardson extrapolation. The idea is that you have a numerical approxima-
tion whose error you know. Say it goes like h2/12. Computef1, the approximation
with step size h. Then if you carry out the procedure again with a step size of h/2,
the error for f1/2ish2/48. Now compute f1−4f2: theh2/12term in the error can-
cels and you are left with something smaller. The result: the order of the error has
gone down without having to come up with a new method and with only one extra
calculation. This is gold. Use it when you can.
% p131.m Linz algorithm SGLS 05/12/08
function p131
hh = 10.^(0:-0.5:-2);
e = zeros(length(hh),4);
subplot(2,2,1)
for j=1:length(hh)
hh(j)
[t,y] = volt1m(@k91,@g91,10,hh(j),0,0);
e(j,1:2) = [norm(y-t) norm(y-t,inf)];
[t,y] = volt1m(@k91,@g91,10,hh(j),1,0);
e(j,3:4) = [norm(y-t) norm(y-t,inf)];
end
loglog(hh,e,’.’,hh,hh.^2,hh,hh.^4/24)
xlabel(’h’); ylabel(’e’)
subplot(2,2,2)
for j=1:length(hh)
hh(j)
[t,y] = volt1m(@k91c,@g91,10,hh(j),0,1);
e(j,1:2) = [norm(y-t) norm(y-t,inf)];
[t,y] = volt1m(@k91c,@g91,10,hh(j),1,1);
e(j,3:4) = [norm(y-t) norm(y-t,inf)];
end
loglog(hh,e,’.’,hh,hh.^2,hh,hh.^4/24)
xlabel(’h’); ylabel(’e’)
subplot(2,2,3)
for j=1:length(hh)
hh(j)
[t,y] = volt1m(@k932,@g932,10,hh(j),0,0);
e(j,1:2) = [norm(y-exp(-2*t)) norm(y-exp(-2*t),inf)];
[t,y] = volt1m(@k932,@g932,10,hh(j),1,0);
e(j,3:4) = [norm(y-exp(-2*t)) norm(y-exp(-2*t),inf)];
end
loglog(hh,e,’.’,hh,hh.^2,hh,hh.^4/24)
xlabel(’h’); ylabel(’e’)
subplot(2,2,4)
for j=1:length(hh)
hh(j)
[t,y] = volt1m(@ktest,@gtest,10,hh(j),0,0);
y = y(:,3); yex = exp(-t)-2*exp(-2*t);
e(j,1:2) = [norm(y-yex) norm(y-yex,inf)];
[t,y] = volt1m(@ktest,@gtest,10,hh(j),1,0);
y = y(:,3); yex = exp(-t)-2*exp(-2*t);
e(j,3:4) = [norm(y-yex) norm(y-yex,inf)];
end
loglog(hh,e,’.’,hh,hh.^2,hh,hh.^4/24)
xlabel(’h’); ylabel(’e’)
function [t,y] = volt1m(k,g,tmax,h,Ri,Co)
if (Ri==0)
t = h:h:tmax+0.5*h;
N = length(t);
for n = 1:N
r = g(t(n))/h;
if (n==1)
m = length(r);
y = zeros(m,N);
if (Co==1)
K = zeros(m,m,N);
end
end
if (Co==1)
K(:,:,n) = k((n-0.5)*h);
for j = 1:n-1
r = r - K(:,:,n-j+1)*y(:,j);
end
y(:,n) = K(:,:,1)\r;
else
for j = 1:n-1
K = k(t(n),t(j)-0.5*h);
r = r - K*y(:,j);
end
K = k(t(n),t(n)-0.5*h);
y(:,n) = K\r;
end
end
t = (t-0.5*h)’;
y = y.’;
else
[t,y1] = volt1m(k,g,tmax,h,0,Co);
[t2,y2] = volt1m(k,g,tmax,h/3,0,Co);
y = y2(2:3:end,:) + 1/8*(y2(2:3:end,:)-y1);
end
function k = k91(t,s)
k = cos(t-s);
function k = k91c(t)
k = cos(t);
function g = g91(t)
g = 1 - cos(t);
function k = k932(t,s)
k = 1 + 2*(t-s);
function g = g932(t)
g = t;
function k = ktest(t,s)
k = [cos(t-s) 0 0 ; 0 1+2*(t-s) 0 ; 1 exp(-(t-s)) 1];
function g = gtest(t)
10−210−110010−2010−10100
he
10−210−110010−2010−10100
he
10−210−110010−1010−5100
he
10−210−110010−1010−5100
heLinz algorithm applied to test cases.
g = [1-cos(t) ; t ; 0.5*t^2];
Exercise 0.53 Solve ( 386) and ( 387) using Laplace transforms and Talbot’s algo-
rithm from ( 53).
Singular integral equations: Tuck’s method
There is a crucial difference between equations of the first and second kind. The
first tend to be ill-posed.
Definition 0.3 A problem is well-posed if its solution is uniquely determined and
not arbitrarily sensitive to small changes in e.g. boundary conditions.
There is a physical reason why equations of the first kind tend to be ill-posed:
integration is a smoothing operation. So in ( 383) we could add to f(x)some wildly
oscillating function and the oscillations would be wiped out by the integral. Hence
there may be other solutions to the equation very close to the correct solution. In
equations of the first kind, the presence of the unknown function f(x)outside an
integral removes this problem.
Returning to the linear algebra perspective, the ill-posedness is reflected by an
increasingly worse condition number of the resulting matrix. The condition number
measures the spread in eigenvalues. If it is infinite, there is a zero eigenvalue and
the matrix is no longer invertible.
However, as the kernel inside the integral becomes more singular, it smooths less
and less, so this problem goes away. The most extreme limit corresponds to
k(s,t) =δ(s−t); then the integral just becomes f(x)and the answer is trivial.
We also saw that the Abel integral equation of Chapter 53had a unique solution,
when it existed. As a result, singular integral equations are more likely to have
unique solutions than integral equations with smooth kernels.However, we have to
be careful when discretizing them so as to deal with the singularities appropriately.
One important class of singular integral equations corresponds to kernels with
(s−t)−1singularities. Then the integral itself must be viewed as a principal value
integral. Such integral equations arise very naturally in the solution of Laplace’s
equation, and this leads to the field of Boundary Integral Methods (for a review of
numerical methods see e.g. Pozrikidis 2002). We will limit ourselves to a simple
discussion based on Tuck (1980).
We can base pretty much everything on what is known as the airfoil equation13
1
π−/integraldisplay1
−1f(t)
t−xdt=g(x) (389)
(notice the change in notation). This equation has the critical property that its
solution is not unique. We can see this by computing
−/integraldisplay1
−1(1−t2)−1/2
t−xdt= 0. (390)
13Richard Courant is said to have called this the most important piece of mathematics of the 20th century, in
the sense that it was an application of pure mathematics to a very concrete problem. I may be misquoting.
Physically this corresponds to needing to fix the circulation about a contour to de-
fine the irrotational flow about the contour uniquely. We hence have to supplement
(389) with some extra condition, usually/integraltext1
−1f(t) dt= 0or a requirement of finite-
ness at one of the endpoints.
Warning 12 Integral equations may have unique solutions, or at least, a finite num-
ber of arbitrary constants (one for the airfoil equations). However, the solutions of-
ten have square root singularities at the endpoints. These integrable singularities
are usually physically meaningful but require care in the mathematical procedure.
Exercise 0.54 Prove ( 390).
Tuck (1908) suggests integrating the airfoil equation to obtain an integral equation
with a logarithmic kernel:
1
π/integraldisplay1
−1log|t−x|f(t) dt=h(x). (391)
One can show that this equation has a unique solution. Of course, h(x)is no
longer unique and fixing it corresponds to removing the non-uniqueness as men-
tioned previously. Figure 39shows the solution to ( 389) with zero right-hand side.
This is hence the homogeneous solution, so an extra condition has to be applied.
The right-hand side of h(x)is taken to be 1, which leads to the exact solution
log 2/π√
1−x2. The numerical procedure performs very well, even though the
solution is singular at both endpoints.
The details of the procedure, briefly, are as follows. The unknown function f(x)is
pulled out of the integral and evaluated at the midpoints of the intervals. The re-
sulting logarithmic integral is computed explicitly. Hence this is a modified midpoint
technique. For increase accuracy near the endpoints, a stretched (Chebyshev)
mesh is taken. The extension to different g(x)is trivial, although some thought is
required with respect to the constant of integration in h(x). More complicated ker-
nels are possible, but they need to be integrable. Subtracting out the logarithmic
singularity is the way to go. For an example, see Llewellyn Smith & Y oung (2003).
% p132.m Fredholm singular integral equation SGLS 05/12/08
l=4; M=40;
xi=-l*cos(pi*(0:M)/M);
x=(xi(1:end-1)+xi(2:end))/2;
x=x’;
hp=ones(M,1)*xi(2:end)-x*ones(1,M);
hm=ones(M,1)*xi(1:end-1)-x*ones(1,M);
K=hp.*(log(abs(hp))-1)-hm.*(log(abs(hm))-1);
dxi=ones(M,1)*(xi(2:end)-xi(1:end-1));
g=ones(M,1);
−4 −3 −2 −1 0 1 2 3 400.511.522.53
xγTuck’s method applied to the airfoil equation ( 389) withg= 0.
gamma=K\g;
plot(x,gamma,x,1/pi/log(l/2)./sqrt(l^2-x.^2),’.’,[-l l],[1 1])
xlabel(’x’); ylabel(’\gamma’)
Exercise 0.55 What condition was used to make the solution plotted in Figure 39
unique?
Exercise 0.56 Solve ( 389) with the right-hand sides cosxand(1−x2)−1/2.
Singular integral equations: complex variable ap-
proaches
Remarkably, some singular integral equations can be solved exactly. The exact
details are too long to enter into here, but an excellent discussion can be found in
Pipkin (1991). A by-product of this method is being able to compute a number of
complex integrals almost trivially.
Exercise 0.57 Show that the solution to the coupled integral equations (P ´etr´elis,
Llewellyn Smith & Y oung 2006)
8π
3=−/integraldisplay1
−1S±(t)
t−xdt∓πS±(x)√
3(392)
is
S±(x) =4(x∓1/3)√
3(1−x2)1/3(1∓x)1/3. (393)
(If you can do this, you are ready to teach this class.)
References
Publications:
•Linz, P . Analytical and numerical methods for Volterra equations. SIAM, Philadel-
phia, 1985. SIAM, 1985
•Llewellyn Smith, S. G. & Y oung, W. R. Tidal conversion at a very steep ridge.
J. Fluid Mech. ,495, 175–191, 2003.
•Pipkin, A. C. A course on integral equations. Springer, New Y ork, 1991.
•P´etr´elis, F ., Llewellyn Smith, S. G. & Y oung, W. R. Tidal conversion at a subma-
rine ridge. J. Phys. Oceanogr. ,32, 1053–1071, 2006.
•Pozrikidis, C. A practical guide to boundary element methods with the software
library BEMLIB , Chapman & Hall/CRC, Boca Raton, 2002.
•Tuck. E. O. Applications and solutions of Cauchy-singular integral equations. In
The application and numerical solution of integral equations , (eg. R. S. Ander-
ssen, F . R.de Hoog & M. A. Lukas), pp. 21–50, Sitjoff and Noordhoff, Alphen
aan den Rijn, 1980.
WKB and ray theory (05/14/08)
Liouville–Green approximants
When dealing with irregular singular points, we have already seen the use of the
substitution w= eS, after which we usually solve for Sas an asymptotic series.
Usually, the leading-order behavior is given by S/prime2∼ −q(it’s always best to avoid
writingS/prime2+q∼0for technical reasons). The form eSis sometimes called the
Liouville–Green approximant to the function. It is a useful approximation close to a
pointx(which could be infinity). However it does not usually do that much over the
rest of the range.
Example 0.22 Consider the Bessel equation
f/prime/prime+1
xf/prime+/parenleftbigg
k2−n2
x2/parenrightbigg
f= 0 (394)
close to the irregular singular point at infinity. This is an LG expansion, with
S/prime/prime+S/prime2+x−1S/prime+k2−n2x−2= 0. (395)
The dominant behavior comes from S/prime2∼ −k2, soS∼ ± ikx. Then the next order
term comes from writing S=±ikx+T, with|T| /lessmuchxand similar relations on the
derivatives of T. The governing equation for Tis with
T/prime/prime−k2±2ikT/prime+T/prime2±ikx−1+x−1T/prime−n2x−2= 0. (396)
Now the leading-order balance is 2T/prime∼ −x−1, soT∼ −1
2logxandy∼x−1/2e±ix.
Exercise 0.58 Work out the LG approximants for the equation
f/prime/prime+1
x2f−k2
x2f= 0. (397)
Note that we can turn any linear second-order ODE y/prime/prime+ay+b= 0into Liouville
formy/prime/prime+qy= 0by an appropriate substitution. This leaves the S/prime/primeandS/prime2terms
in the LG expansion, so a series approach is still necessary.
Exercise 0.59 Obtain the function qin the Liouville normal form in terms of aand
b.
Cheng (2007) has a nice discussion of ISPs, including some tricks to get the gov-
erning behavior quickly.
WKB(J)
The LG expansions are useful but not uniformly valid in x. If there is a small
parameter in the problem, we can aim to find asymptotic expansions using that
parameter valid everywhere (almost everywhere). Guided by the presence of the
S/prime2term above, we want the oscillatory term to be multiplied by a small coefficient.
We are hence led to the standard from
/epsilon12y/prime/prime+q(x)y= 0. (398)
A small term multiplies the highest derivative, which is usually the sign of a singular
perturbation (think of boundary layers). Here, however, setting /epsilon1= 0 cannot pro-
vide a good approximation except under unusual circumstances. Instead, if q >0,
the function oscillates over the whole interval. If q < 0, there can be exponentially
decaying or growing solutions that are more boundary-layer like. If qchanges sign,
some more care is needed.
Exercise 0.60 Work out the transformation need to turn f/prime/prime+af+b= 0 into
y/prime/prime+qy= 0.
Guided by the LG expansion, we write
y= eQ//epsilon1, Q =Q0//epsilon1+Q1+Q2/epsilon1+···. (399)
The higher terms in the expansion can be taken out of the exponential if desired.
Substituting in expanding gives
/epsilon12(Q/prime/prime+Q/prime2) +q= 0. (400)
We findQ0=±i/integraltextxq1/2dxwhereq > 0andQ0=±/integraltextx(−q)1/2dxwhereq < 0.
Subsequently Q1=−1
4log|q|.
Many high-frequency physical systems can be solved for using WKB ideas. Schr ¨odinger’s
equation contains /planckover2pi1and classical physics can be viewed as the limit as /planckover2pi1→0.
The resulting equations give the Hamilton–Jacobi equations of mechanics. The
Helmholtz equation that governs monochromatic wave propagation reduces in the
limit of small wavelength to the eikonal equation (to be discussed in what follows).
For an isotropic medium, this equation has light travelling in straight lines and we
recover geometric optics. In fact the LG approximants are sometimes called the
physical optics and geometric optics approximations to the solution, depending on
the number of terms kept (see Bender & Orszag 1978).
The nomenclature WKB(J) stands for Wentzel, Kramers and Brillouin (and Jef-
freys). These physicists worked on semi-classical limits of the quantum mechanics
and were concerned with obtaining quantization rules. In fact, the first version of
quantum mechanics was just classical mechanics with quantization rules. Their
contribution was to the problem where q(x)vanishes, a turning point. At such
points, the WKB form derived above is no longer accurate. The solution looks like
an Airy function, oscillatory on one side and exponentially decreasing or increasing
on the other. One can match this Airy function to the WKB solutions on both sides,
giving rise to a phase shift. There is a real subtlety to do with the direction in which
matching is allowed, that is still a source of contention. The phase shift is quite
real, and a beautiful and important piece of work gives quantization rules purely
from the topology of the domain. This is EBK (Einstein–Brillouin–Keller) quantiza-
tion. These ideas can be applied more general to PDEs, as in Keller & Rubinow
(1960).
The primary use of WKB in these cases is to derive eigenvalue conditions for bound
states, and excellent results are obtained. The finite case is quite simple. Take
(398) withq(x)>0on the interval (0,1)with homogeneous boundary conditions
y(0) =y(1) = 0 . This is an eigenvalue problem and the WKB solution is just
y(x) =Cq(x)−1/4sin/parenleftbigg1
/epsilon1/integraldisplayx
0q(x)1/2dx/parenrightbigg
. (401)
The condition at the origin is satisfied and that at 1leads to the eigenvalue relation
1
/epsilon1/integraldisplay1
0q(x)1/2dx=nπ (402)
from the properties of the sine function. In this sense the problem is trivial because
the integral above is just a number. Often one solves the problem
/epsilon12y/prime/prime+q(x)y=Ey, (403)
for which the dependence of the integral on Eis less trivial. Note that if the bound-
ary conditions are on the derivatives of y, one neglects the prefactor when carrying
out the derivative since it is asymptotically smaller and one ends up with cosines.
Example 0.23 Find the eigenvalues /epsilon1nof the equation
/epsilon12y/prime/prime+ 41/2
sechxy= 0 (404)
on the interval (0,1)with homogeneous boundary conditions. We solve the prob-
lem numerically using Chebyshev collocation and compare to the WKB prediction.
For this we need the numerical result/integraltext1
02 sech1/4xdx= 1.926183 .
% p141.m WBK eigenvalue problem on bounded interval SGLS 05/15/08
N = 40;
qi = inline(’2*sech(x).^0.25’);
p = quadl(qi,0,1,eps);
eas = p./((1:N)’*pi);
[x,D] = chebdif(N+2,2); x = 0.5*(x+1); D2 = 4*D(2:end-1,2:end-1,2);
A = diag(4*sech(x).^0.5); A = A(2:end-1,2:end-1);
e = sqrt(-sort(eig(A,D2)));
semilogy(1:N,e,’.’,1:N,eas,’o’)
0 5 10 15 20 25 30 35 4010−310−210−1100Eigenvalues of ( 404) from numerical calculations and WKB solution.
Ray theory: from expansions
Ray theory can be viewed as the multidimensional generalization of WKB. There
are two ways of obtaining the governing equations, which are essentially the same.
The first way is to take the governing equation and expand it in the relevant small
or large parameter. We will illustrate this with the Helmholtz equation, following
Bleistein (1984). The second way is to start with the dispersion relation for the
waves and derive it from it the ray equations directly. This procedure is carried out
in Lighthill (1979), Hinch (1991) and many other places.
Start with the Helmholtz equation
∇2u+ (ω2/c2(x))u= 0, (405)
whereωis in some sense large. Assume a solution of the form
u∼ωβeiωτ(x)∞/summationdisplay
j=0Aj(x)
(iω)2. (406)
We don’t know βat this point and in fact it can only come from matching the solution
to the prescribed data, so we ignore it for now. Now substitute and expand. we get
(∇τ)2=c−2, (407)
2∇τ· ∇A0+A0∇2τ= 0, (408)
2∇τ· ∇Aj+∇2τ=−∇2Aj−1. (409)
The first equation in the hierarchy, ( 407), is the eikonal equation. The second,
(408), is the transport equation. The rest we ignore. The function τ(x)is has the
units of time.
The eikonal equation ( 407) is a first-order nonlinear PDE. It can be solved by the
method of characteristics (in fact using Charpuit’s method – see Ockendon et al.
1999). This method solves for everything along the rays. Write p= 1/cand
pj=∂τ/∂x j; the latter is the slowness vector. Then the eikonal equation becomes/summationtext3
j=1pjpj=p2. The characteristic equations for the eikonal equation become the
ray equations
dxj
dσ=λpj,dpj
dσ=λ∂p
∂xj,∂τ
∂σ=λp2. (410)
The new variable σparameterizes the ray. Rays are directed along the gradient of
τ.
Now the transport equation. Multiply ( 408) byA0to obtain
∇ ·[A2
0∇τ] = 0. (411)
This is a conversation law. The quantity A2
0p=A2
0/cis preserved in ray tubes. We
can turn ( 408) into an ODE along characteristics by substituting ( 422) into ( 408)
and obtaining
dA2
0
dσ=−A2
0λ∇2τ. (412)
If we know a ray solution for τ, the right-hand side is known. However, the ray
equations presented so far are insufficient: we need gradients of τalong the ray.
Obtaining these requires solving 12more ODEs along the rays.
There are a number of choices possible for σ, given byλ. First,λ= 1, which is the
simplest to use in analytical solutions. Second, λ=c= 1/p, in which case σis arc
length. Third, λ=c2= 1/p2, in which case τcan be used as the parameter along
the ray.
Ray theory has many uses; the Helmholtz equation is used is seismology to model
travel times of seismic waves. There is some unpleasantness, since the different
shear and dilational modes couple at boundaries and interfaces where the wave
speeds have discontinuities.
For more general equations, it would be nice to have a rapid approach, and there
is one. However, there are time when only the expansion procedure will do. This
is particularly true when dealing with systems with background flow, where it is not
obvious what the dispersion relation is from the beginning.
Ray theory: from dispersion relations
We consider a scalar wave field that takes the form of a single wave propagating
with slowly varying amplitude a(X,t)and slow varying phase θ=/epsilon1−1Θ(X,t). We
can define a local frequency ω=−ΘTand a local wavenumber k=∂Θ/∂X. This
gives two consistency relations
∇X×k=0,∇Xω+∂k
∂T= 0. (413)
We will have a local dispersion relation ω= Ω(k,X,T), where the last two ar-
guments denote the dependence on the medium. The group velocity is given by
fg=∇kΩ. We obtain
dω
dT=∂Ω
∂T,dk
dT=−∇XΩ, (414)
where total derivatives indicate differential along ray with d/dT=∂/∂T +fg· ∇.
We see that in a time-independent medium, frequency is conserved along a ray.
In a spatially homogeneous medium, wavenumber is conserved along a ray. If
the medium properties depend only on z, the horizontal wavenumber is conserved
along a ray. These equations are the same as were obtained earlier when solving
the eikonal equation using the method of characteristics.
One finds that a scalar quantity is also conserved along ray tubes, but it is no
longer energy. Instead the quantity E/ω , called wave action, is conserved. If the
frequency is constant, one recovers conservation of energy.
Eulerian eikonal solvers
The eikonal equation is nonlinear whereas the original equation that gave rise to
it was linear. This is slightly unusual and has the consequence that one has to
be careful when talking about adding solutions. For example, there may be sev-
eral rays passing through one point, or none (shadow). These rays are separate
solutions to the eikonal equation.
One problem with ray approaches is that one cannot control in advance where the
rays go and one end up getting poor coverage in certain regions. Of course in the
shadows one gets nothing. One can get around this by integrating backward from
the observation point, but then one has a boundary-value problem since one needs
to find the ray that came in from the right direction.
The idea of Eulerian solvers is hence very tempting: one would obtain the solution
to the eikonal equation at each point on a grid. Although since the physical field is
the superposition of a number of rays, what would this mean? It turns out that one
can construct such methods, and they have the property (if one does it right) that
they pick out the first travel time solution, i.e. the first ray to reach the grid point.
These ideas, as well as a discussion of efficient implementations, can be found in
Sethian (1999).
Obtaining the full field is much more difficult, and is still to some extent an open
problem. One needs to augment the dimension of the problem to deal with shading
regions and caustics, and we are being taken too far afield.
Project 7 Implement an Eulerian ray method that produces the full physical field
for an arbitrary underlying PDE. (This is not a realistic project.)
Ray theory: example
These are notes, mostly by Joe Keller, on the problem of acoustic scattering by a
vortex.
Formulation
The Euler equations for the density ρ(x,t)and velocity u(x,t)of an isentropic flow
are
ρt+∇·(ρu) = 0, ρ [ut+ (u·∇)u] =−∇p(ρ). (415)
When the solution depends upon a parameter ε, the derivative of ( 415) yields the
acoustic equation for ˙ρand ˙u, the derivatives of the solution with respect to ε:
˙ρt+∇·(˙ρu+ρ˙u) = 0, ˙ρ[ut+(u·∇)u]+ρ[˙ut+(˙u·∇)u+(u·∇)˙u] =−∇(c2˙ρ).
(416)
Here we have introduced the sound speed cdefined byc2=pρ(ρ).
A solution of ( 415) is the axially symmetric vortex flow
ρ=constant,u= (0,car Ω(r)). (417)
The velocity uis written in cylindrical coordinates r,θandcais the vortex strength.
Using ( 417) in ( 416) yields
˙ρt+u·∇˙ρ+ρ∇·˙u= 0, ˙ut+ (u· ∇)˙u+ (˙u· ∇)u=−ρ−1c2∇˙ρ.(418)
We seek a solution of ( 418) corresponding to an incident time-harmonic plane wave
with wavenumber kand angular frequency ω=kccoming from x=−∞. With fx
denoting a unit vector in the x-direction, we can write it as
˙ρinc=ρB 0ei(kx−ωt),uinc=cB0fxei(kx−ωt). (419)
We write the solution in the following form, which is appropriate for ka/greatermuch1:
˙ρinc= ei(kϕ(x)−ωt)ρ[B(x) + (ik)−1B1(x) +O(k−2)], (420)
˙uinc= ei(kϕ(x)−ωt)c[A(x) + (ik)−1A1(x) +O(k−2)]. (421)
The solution ( 421) must tend to the incident wave ( 419) asx→ −∞ , and otherwise
must contain only outgoing waves.
To determine ϕ,BandAwe substitute ( 422) into ( 418), and retain term of order
k1andk0. Equating to zero the coefficient of k1yields
(−c+u· ∇ϕ)B+cA· ∇ϕ= 0, (−c+u· ∇ϕ)A+cB∇ϕ=0.(422)
Then equating to zero terms of order k0yields
(−c+u· ∇ϕ)B1+cA1· ∇ϕ=−u· ∇B−c∇ ·A, (423)
(−c+u· ∇ϕ)A1+cB1∇ϕ=−(u· ∇)A−(A· ∇)u−c∇B.(424)
Now we must solve ( 422) and ( 424) subject to the condition at x=−∞ corre-
sponding to the incident wave
ϕ→x=rcosθ, B →B0,A→B0fx asx→ −∞. (425)
Eikonal equation and rays
The solution of the second equation in ( 422) forAin terms ofBandϕis
A= (c−u· ∇ϕ)−1cB∇ϕ= (1−aΩϕθ)−1B∇ϕ. (426)
We use ( 426) in the first equation of ( 422) and require that B/negationslash= 0to obtain
(∇ϕ)2−(1−aΩϕθ)2= 0. (427)
This is a first-order partial differential equation for ϕcalled the eikonal equation
which can be solved by the method of rays or characteristics.
To use this method we introduce a parameter τand a curve r(τ),θ(τ),p1(τ),p2(τ)
wherep1(τ) =ϕr[r(τ),θ(τ)]andp2(τ) =ϕθ[r(τ),θ(τ)]. We define the Hamiltonian
H(p1,p2,r,θ)to be half the left side of ( 427):
H(p1,p2,r,θ) =1
2p2
1+1
2r2p2
2−1
2(1−aΩp2)2. (428)
Then Hamilton’s equations for the curves are
p1τ=−Hr=r−3p2
2−aΩ/primep2(1−aΩp2), (429)
p2τ=−Hθ= 0, (430)
rτ=Hp1=p1, (431)
θτ=Hp2=r−2p2+aΩ(1−aΩp2). (432)
From ( 430) we see that p2=constant along a ray. Then we use ( 431) to write the
left-hand side of ( 429) asp1τ=rττ, and ( 429) becomes a second-order equation
forr. We multiply it by rτand integrate to get, with Ea constant of integration,
1
2r2
τ=−1
2r2p2
2+1
2(1−aΩp2)2+E. (433)
We setE= 0and then ( 433) is just the equation H= 0obtained from ( 427) and
(428) withp1=rτ. Now we solve ( 433) for 1/rτ= dτ/drand integrate to get
τ=±/integraldisplayr
r0[(1−aΩp2)2−r−2p2
2]−1/2dr. (434)
We choose τ= 0whenr=r0. The minus sign holds for τ < 0, the plus sign for
τ > 0. The lower limit r0is the minimum value of ron the ray. At it the bracketed
expression in the integrand vanishes.
Oncer(τ)is determined from ( 434) thenθ(t)can be found by integrating ( 432). To
findϕ(τ) =ϕ[r(τ),θ(τ)], we write
ϕ(τ) =ϕrrτ+ϕθθτ=p1rτ+p2θτ=r2
τ+p2θτ. (435)
Here we have used the definitions of p1andp2as well as ( 431). We integrate ( 435)
fromτ0toτgo get
ϕ(τ)−ϕ(τ0) =p2θ(τ)−p2θ(τ0) +/integraldisplayτ
τ0(r2
τ−1) dτ+τ−τ0. (436)
Asτ0→ −∞ , (425) shows that ϕ(τ0)→x=rcosθ∼ −rsinceθ→πand ( 434)
shows thatτ0∼ −r. Then asτ0→ −∞ , (436) yields the following expression
ϕ(τ,p 2) =τ+p2[θ(τ)−π] +/integraldisplayτ
−∞[(1−aΩp2)2−r−2p2
2−1] dτ. (437)
The parameter p2is constant on a ray. By using the definition p2=ϕθwith the
asymptotic form of ϕatx=−∞, we getp2=∂θ(rcosθ) =−rsinθ=−y. Then
p2is minus the impact parameter, i.e. the distance from the origin to the asymptote
to the incident ray.
Transport equation for the amplitude
Now we consider ( 424) which is a system of inhomogeneous linear algebraic equa-
tions for A1andB1. The homogeneous form of these equations, ( 410), has a
nontrivial solution, so the coefficient matrix is singular. Therefore ( 424) will have a
solution only if the inhomogeneous terms satisfy a solvability condition. To obtain
it we solve the second equation of ( 424) forA1in terms ofB1and use the solution
in the first equation to eliminate A1. The coefficient of B1vanishes, leaving the
equation
∇ϕ·[(A·∇)c−1u+(c−1u·∇)A]+∇ϕ·∇B= (c−1u·∇ϕ−1)(c−1u·∇B+∇·A).
(438)
This is the solvability condition into which we now substitute ( 426) forAto get
(1−c−1u·ϕ)−1∇ϕ·[(∇ϕ· ∇)c−1u]B+∇ϕ· ∇B+ (1−c−1u)[] (439)
Implementation
Figure 41shows the result of tracing rays numerically through a vortex with Gaus-
sian streamfunction. Note the crowding of rays and caustics. The Mach number is
a= 0.1
% p142.m Ray tracing for Gaussian vortex SGLS 05/15/08
function p142
xmin=-100; dy=0.1; a=0.1; fn=@vel;
xt=ones(400,601)*NaN;
yt=xt; phit=xt; xgt=xt; ygt=xt; xdt=xt; ydt=xt; alphat=xt; tt=xt;
lt=zeros(1,201);
j=0;
for yy=-20:dy:20
j=j+1;
[t,h]=doray(500,xmin,yy,0,1,a,1e-6,fn);
l=size(t,1);
lt(j)=l;
tt(1:l,j)=t;
xt(1:l,j)=h(:,3);
yt(1:l,j)=h(:,4);
phit(1:l,j)=h(:,5);
xgt(1:l,j)=h(:,9);
ygt(1:l,j)=h(:,10);
[u,v,ux,vx,uy,vy,uxx,vxx,uyy,vyy,uxy,vxy]=feval(fn,h(:,3),h(:,4),a);
alphat(1:l,j)=1-u.*h(:,1)-v.*h(:,2);
for k=1:size(t,1)
hp=rayeq(0,h(k,:)’,a,fn);
xdt(k,j)=hp(3);
ydt(k,j)=hp(4);
end
[yy l]
end
lm=max(lt);
t=tt(1:lm,1:j); x=xt(1:lm,1:j); y=yt(1:lm,1:j); phi=phit(1:lm,1:j);
xg=xgt(1:lm,1:j); yg=ygt(1:lm,1:j); xd=xdt(1:lm,1:j); yd=ydt(1:lm,1:j);
alpha=alphat(1:lm,1:j);
J=(xd.*yg - yd.*xg);
alpha0=ones(lm,1)*alpha(1,:);
J0=ones(lm,1)*J(1,:);
B=alpha./alpha0.*sqrt(abs(J0./J));
clear tt xt yt phit xgt ygt xdt ydt
figure(2)
clf
contour(x,y,phi,(0:0.5:200)*pi)
hold on
contour(x,y,J,[0 0],’k’)
hold off
axis equal
function [t,h]=doray(tmax,x,y,psi,dir,a,tol,rayfn)
%DORAY Compute ray trajectory
% [T,H]=DORAY(TMAX,X,Y,PSI,DIR,A,TOL,RAYFN)
% integrates the ray equations for the velocity field
% defined by rayfn.
%
% Input:
% tmax: maximum time
% x: initial x location
% y: initial y location
% psi: angle of ray to horizontal
% dir: positive corresponds to larger p1 (e.g. towards +x)
% a: velocity amplitude (Mach number)
% tol: integration tolerance
% rayfn: function defining velocity field
%
% Output:
% t : time
% h : [p1 p2 x y phi 0 p1g p2g xg yg]
% Set up initial condition for p1 and p2
[u,v,ux,vx,uy,vy,uxx,vxx,uyy,vyy,uxy,vxy]=feval(rayfn,x,y,a);
a1=sin(psi)*(1-u^2)+u*v*cos(psi);
a2=cos(psi)*(1-v^2)+u*v*sin(psi);
be=(u*sin(psi)-v*cos(psi))/a2;
A=1-u^2+a1^2/a2^2*(1-v^2)-2*u*v*a1/a2;
B=2*(u + v*(a1/a2-u*be) + be*a1/a2*(1-v^2));
C=be^2*(1-v^2)-1+2*v*be;
if (dir>=0)
p1=max(roots([A B C]));
else
p1=min(roots([A B C]));
end
p2=a1/a2*p1+be;
%H=0.5*(p1^2+p2^2)-0.5*(1-u*p1-v*p2)^2;
% Set up initial conditon for normal derivative equations
a1y=-2*u*uy*sin(psi)+(uy*v+u*vy)*cos(psi);
a2y=-2*v*vy*cos(psi)+(uy*v+u*vy)*sin(psi);
bey=(uy*sin(psi)-vy*cos(psi))/a2 - a2y/a2^2*(u*sin(psi)-v*cos(psi));
Ay=-2*u*uy + (2*a1y*a1*a2^2-2*a2y*a2*a1^2)/a2^4*(1-v^2)* - 2*a1^2/a2^2*v*vy -2*(uy*v*+u*vy)*a1/a2 -2*u*v*(a1y*a2-a2y*a1)/a2^2;
By=2*(uy +vy*(a1/a2-u*be) +v*( (a1y*a2-a2y*a1)/a2^2 -uy*be - u*bey) + bey*a1/a2*(1-v^2) + be*(a1y*a2-a2y*a1)/a2^2*(1-v^2) -2*be*a1/a2*v*vy );
Cy=2*be*bey*(1-v^2)-2*be^2*v*vy +2*(vy*be+v*bey);
p1y=-(Ay*p1^2+By*p1+Cy)/(2*A*p1+B);
p2y=(a1y*a2-a2y*a1)/a2^2*p1+a1/a2*p1y+bey;
h0=[p1 ; p2 ; x ; y ; 0 ; 0 ; p1y ; p2y ; 0 ; 1];
options=odeset(’RelTol’,tol,’AbsTol’,tol);
[t,h]=ode45(@(t,h) rayeq(t,h,a,rayfn),[0 tmax],h0,options);
function hdot = rayeq(t,h,a,rayfn)
%RAYEQ Return derivative in ray equations
% HDOT=RAYEQ(T,H,A,RAYFN)
%
% Input:
% t: time
% h: vector [p1 p2 x y phi 0 p1g p2g xg yg]
% a: velocity amplitude (Mach number)
% rayfn: function defining velocity field
%
% Output:
% hdot: derivative of h
p1=h(1);
p2=h(2);
x=h(3);
y=h(4);
[u,v,ux,vx,uy,vy,uxx,vxx,uyy,vyy,uxy,vxy]=feval(rayfn,x,y,a);
alpha=1-u*p1-v*p2;
hdot(1)=-(ux*p1+vx*p2)*alpha;
hdot(2)=-(uy*p1+vy*p2)*alpha;
hdot(3)=p1+u*alpha;
hdot(4)=p2+v*alpha;
hdot(5)=p1*hdot(3)+p2*hdot(4);
hdot(6)=0;
Hxx=uxx*p1+vxx*p2-(uxx*v+2*ux*vx+u*vxx)*p1*p2-(ux^2+u*uxx)*p1^2-(vx^2+v*vxx)*p2^2;
Hxy=uxy*p1+vxy*p2-(uxy*v+ux*vy+uy*vx+u*vxy)*p1*p2-(ux*uy+u*uxy)*p1^2-(vx*vy+v*vxy)*p2^2;
Hxp1=ux-(ux*v+u*vx)*p2-2*u*ux*p1;
Hxp2=vx-(ux*v+u*vx)*p1-2*v*vx*p2;
Hyy=uyy*p1+vyy*p2-(uyy*v+2*uy*vy+u*vyy)*p1*p2-(uy^2+u*uyy)*p1^2-(vy^2+v*vyy)*p2^2;
Hyp1=uy-(uy*v+u*vy)*p2-2*u*uy*p1;
Hyp2=vy-(uy*v+u*vy)*p1-2*v*vy*p2;
Hp1p1=1-u^2;
Hp1p2=-u*v;
Hp2p2=1-v^2;
hdot(7)=-Hxp1*h(7)-Hxp2*h(8)-Hxx*h(9)-Hxy*h(10);
hdot(8)=-Hyp1*h(7)-Hyp2*h(8)-Hxy*h(9)-Hyy*h(10);
hdot(9)=Hp1p1*h(7)+Hp1p2*h(8)+Hxp1*h(9)+Hyp1*h(10);
hdot(10)=Hp1p2*h(7)+Hp2p2*h(8)+Hxp2*h(9)+Hyp2*h(10);
hdot=hdot’;
function [u,v,ux,vx,uy,vy,uxx,vxx,uyy,vyy,uxy,vxy]=vel(x,y,a)
%GAUSSPSI Return velocity and derivatives for Gaussian streamfunction
% [U,V,UX,VX,UY,VY,UXX,VXX,UYY,VYY,UXY,VXY]=VEL(X,Y,A)
%
% Input:
% x: x coordinate
% y: y coordinate
% a: velocity amplitude (Mach number)
%
% Output:
% u : x-component of velocity
% v : y-component of velocity
% ux : u_x
% vx : v_x
% uy : u_y
% vy : v_y
% uxx : u_xx
% vxx : v_xx
% uyy : u_yy
% vyy : v_yy
% uxy : u_xy
% vxy : v_xy
r=sqrt(x.^2+y.^2);
theta=atan2(y,x);
c=cos(theta);
s=sin(theta);
Om=a*(-2)*exp(-r.^2);
Omp=a*(4*r).*exp(-r.^2);
Ompp=a*(4-8*r.^2).*exp(-r.^2);
u=-y.*Om;
v=x.*Om;
ux=-y.*c.*Omp;
uy=-Om-y.*s.*Omp;
vx=Om+x.*c.*Omp;
vy=x.*s.*Omp;
uxx=-y.*c.^2.*Ompp-s.^3.*Omp;
−100 −50 0 50 100 150 200 250 300 350 400−200−150−100−50050100150Wave fronts for scattering by a Gaussian vortex using numerical ray tracing.
uxy=-c.*Omp-y.*c.*s.*Ompp+s.^2.*c.*Omp;
uyy=-2.*s.*Omp-y.*s.^2.*Ompp-s.*c.^2.*Omp;
vxx=2.*c.*Omp+x.*c.^2.*Ompp+s.^2.*c.*Omp;
vxy=s.*Omp+x.*c.*s.*Ompp-c.^2.*s.*Omp;
vyy=x.*s.^2.*Ompp+c.^3.*Omp;
Complex Rays
One can investigate how the ansatz ( 406) does in shadow regions. A fascinating
approach is that of Chapman et al. (1999), in which Stokes lines figure prominently.
Exercise 0.61 Read this paper. Write a two-paragraph summary.
References
Publications:
•Bender, C. M. & Orszag, S. A. Advanced mathematical methods for scientists
and engineers. McGraw-Hill, ?, 1978.
•Bleistein, N. Mathematical methods for wave phenomena. Academic Press,
Orlando, 1984.
•Chapman, S. J., Lawry, J. M. H., Ockendon, J. R. & Tew, R. H. On the theory of
complex rays. SIAM Rev. ,41, 417–509, 1999.
•Cheng, H. Advanced analytic methods in applied mathematics, science, and
engineering. LuBan, Boston, 2007.
•Hinch, E. J. Perturbation methods. Cambridge University Press, Cambridge,
1991.
•Lighthill, M. J. Waves in fluids. Cambridge University Press, Cambridge, 1978.
•Ockendon, J. R., Howison, S. D., Lacey, A. A. & Movchan, A. B Applied partial
differential equations , Oxford University Press, Oxford, 1999.
•Keller, J. B. & Rubinow, S. I. Asymptotic solution of eigenvalue problems. Ann.
Phys. , 9, 24–75, 1960.
•Sethian, J. A. Level set methods and fast marching methods. 2nd ed., Cam-
bridge University Press, Cambridge, 1999.
Laplace’s equation (05/21/08)
Introduction
From a complex variable perspective, we know that the real and imaginary parts
of an analytic function f(z) =u(x,y) + iv(x,y)satisfy Laplace’s equation and are
hence harmonic. This is simply from the Cauchy–Riemann equations
ux=vy, u y=−vx, (440)
cross-differentiating. If fis analytic, it is certainly smooth enough to allow taking
extra derivatives.
Graphically we have seen that this corresponds to no maxima or minima in a closed
domain. Every point looks (locally) like a saddle: if it increases in one direction, it
decreases perpendicular to it. In one dimension, it’s hard to do that, so the equiv-
alent of Laplace’s equation, namely fxx= 0, means that the function is linear or
constant. In three dimensions or more, various directions can be involved, provided
the total curvatures add up to zero.
It’s worth plotting an example of a solution to Laplace’s equation to remember what
this looks like. We already solved Laplace’s equation and found the Poisson inte-
gral in Chapter 34. Here we sum functions in a square.
Solve Laplace’s equation ∇2u= 0in the square 0≤x,y≤1withu= 0onx= 0,
u= 0 ony= 0,u=xony= 1 andu=y2onx= 1. Note that the boundary
conditions are compatible here: the limit of ualong one edge is the same as the
limit along another edge that meets the first. This is not always necessary, but
tends to make things converge well. The natural way to solve this problem is by
using Fourier series. It isn’t clear whether to transform in xor iny, and which form
to use, so let’s try both ways with the most general possible expansion.
Write
u=/summationdisplay
nun(y)fn(x), (441)
where we require the fnto be orthogonal and satisfy f/prime/prime
n=−a2
nfn, but do not specify
their precise form yet. Now multiply Laplace’s equation by fm(x)and integrate by
parts, giving
Im(u/prime/prime
m−a2
mum) + [fmu/prime−f/prime
mu]1
0= 0, (442)
whereIm=/integraltext1
0f2
mdxf. We do not know u/primeon the boundaries, so we take fm= 0
there. Hence fn= sinnπx,an=nπandIn=1
2. We find
u/prime/prime
n−(nπ)2un= 2f/prime
n(1)u(1,y) = 2n(−1)ny2. (443)
We can solve this using the boundary condition at y= 0to find
un=bnsinhnπy +2(−1)n+1
nπ2/bracketleftbigg
y2+2
(nπ)2(1−e−nπy)/bracketrightbigg
. (444)
The boundary condition at y= 1gives
bnsinhnπ+2(−1)n+1
nπ2/bracketleftbigg
1 +2
(nπ)2(1−e−nπ)/bracketrightbigg
= 2/integraldisplay1
0xsinnπx dx=2(−1)n+1
nπ,
(445)
which is an equation for the bn.
Alternatively we expand in y. The working is slightly simpler. Start with
u=/summationdisplay
nvn(x)fn(y). (446)
Now
v/prime/prime
n−(nπ)2vn= 2f/prime
n(1)u(x,1) = 2n(−1)nx. (447)
We can solve this using the boundary condition at x= 0to find
vn=cnsinhnπx +2(−1)n+1
nπ2x. (448)
The boundary condition at x= 1gives
cnsinhnπ+2(−1)n+1
nπ2= 2/integraldisplayπ
0y2sinnπy dy=
−2
nπforneven,
2(n2π2−4)
n3π3fornodd,(449)
which is an equation for the cn.
Figure 42shows surface plots of these two solutions. The convergence of the
Fourier series is hampered by Gibbs’ phenomenon. The series in ylooks frankly
wrong. So while expanding in Fourier series may seem natural, it does not always
give good results.
% p151.m Fourier series solution of Laplace’s equation SGLS 05/20/08
x = 0:0.01:1; y = 0:0.02:1; [x,y] = meshgrid(x,y);
u = zeros(size(x)); v = u;
for n = 1:50
b = 1/sinh(n*pi)*( 2*(-1)^(n+1)/(n*pi^2)*(pi - (1 + 2/(n*pi)^2*(1 - exp(-n*pi)))));
u = u + sin(n*pi*x).*(b*sinh(n*pi*y) + 2*(-1)^(n+1)/(n*pi^2)*(y.^2 + 2/(n*pi)^2*(1 - exp(-n*pi*y))));
if (mod(n,2)==0)
c = 1/sinh(n*pi)*( -2*(-1)^(n+1)/(n*pi^2) - 2/(n*pi) );
else
c = 1/sinh(n*pi)*( -2*(-1)^(n+1)/(n*pi^2) + 2*(n^2*pi^2-4)/(n*pi)^3 );
end
v = v + sin(n*pi*y).*(c*sinh(n*pi*x) + 2*(-1)^(n+1)/(n*pi^2)*x);
end
subplot(1,2,1)
surf(x,y,u); shading flat
xlabel(’x’); ylabel(’y’); zlabel(’u’)
00.51
00.5100.511.5
xyu
00.51
00.5100.511.5
xyuSolution to Laplace’s equation using separation of variables.
subplot(1,2,2)
surf(x,y,v); shading flat
xlabel(’x’); ylabel(’y’); zlabel(’u’)
Exercise 0.62 Why is there a difference between the two plots? Check whether
the code and algebra are correct.
This is a typical example of a solution to Laplace’s equation that was obtained
in closed form, but which requires evaluation on a computer. There are many
ways of finding solutions to Laplace’s equation: by finding an appropriate analytic
function (including using conformal maps), by separating variables, by transform
methods and by finite difference/finite element/spectral methods. We leave the
first approach to Chapter 104. The third has been investigated already, so we
concentrate on the other approaches.
Laplace’s equation is the canonical14elliptic PDE. It has no characteristics along
which information propagates, and its solutions are smooth. There are some in-
teresting twists that would take us some way beyond standard elliptic problems:
free surfaces can give waves and hyperbolic systems. The natural generalization
to∇4u= 0is the biharmonic equation, which has interesting properties in terms of
analyticity. Codimension-two problems have the position of the boundary as one of
the unknowns (Howison, Morgan & Ockendon 1997). These problems are some-
times called or free boundary problems. The latter name is more general, since
it includes problems in which an interface evolves, such as freezing and melting
problems. In codimension-one problems, it is not evolution that is important, but
the solution of some equilibrium problem, typically with one boundary condition
over the known parts of the boundary, and two boundary conditions over the re-
mainder of the boundary, which is one of the quantities to be found.
14Fancy mathematical word for typical or original.
Applications
Laplace’s equation is one of the ubiquitous and most important equations of math-
ematical physics. It occurs in potential theory whenever one has a conservative
solenoidal field. Fields satisfying Laplace’s equation include the gravitational po-
tential outside matter, the electrical potential in free space, the velocity potential in
fluid mechanics, various potentials in elasticity, the displacement of a membrane.
In all these cases, the field is trying abstractly to be as smooth as possible, in the
sense of having no maxima or minima. The membrane example provides a graph-
ical interpretation, since the actual surface displacement (e.g. of a drum) is the
solution to the equation.
Many other equations of mathematical physics such as the diffusion equation, the
wave equation of Helmholtz’s equation contain the Laplacian operator. In general,
this term dominates close to singularities and hence understanding the behavior of
the Green’s functions of the Laplace equation is particularly useful.
Pseudospectral methods
The term “pseudospectral” is potentially misleading. The approach is spectral in
the sense that the unknown function is represented as an expansion, and the word
spectral usually refers to some kind of Sturm–Liouville problem that leads to eigen-
functions. The “pseudo” refers to the fact that the governing equations are solved
at certain collocation points. Other spectral approaches, namely the Galerkin and
the tau method, don’t use physical space as part of the algorithm, although of
course to plot solutions one normally needs to return to the physical variable. Do
not confuse the pseudo here with the option of computing nonlinear terms in physi-
cal space: that can be done (trivially) using pseudospectral methods or in the other
approaches, at the cost of transforming a few times. This is historically how the
first spectral methods were devised.
Modern pseudospectral methods using Matlab have made solving Laplace’s equa-
tion in two dimensions very simple indeed. Figure 43shows a contour plot of ufor
the same boundary conditions as before. The code is simple; Neumann or mixed
boundary conditions can be incorporated easily by changing the lines correspond-
ing to L(bx0,:) and so on.
% p152.m Laplace’s equation using pseudospectral methods SGLS 05/19/08
M = 30; N = 25; MN = M*N;
[x,DM] = chebdif(M,2); x = (x+1)*0.5; D2x = DM(:,:,2)*4;
[y,DM] = chebdif(N,2); y = (y+1)*0.5; D2y = DM(:,:,2)*4;
[xx,yy] = meshgrid(x,y); xx = xx(:); yy = yy(:);
bx0 = find(xx==0); bx1 = find(xx==1);
by0 = find(yy==0); by1 = find(yy==1);
Ix = eye(M); Iy = eye(N); I = eye(MN);
L = kron(D2x,Iy) + kron(Ix,D2y);
L(bx0,:) = I(bx0,:); L(bx1,:) = I(bx1,:);
L(by0,:) = I(by0,:); L(by1,:) = I(by1,:);
b = zeros(MN,1); b(bx1) = y.^2; b(by1) = x;
u = L\b; u = reshape(u,N,M);
surf(x,y,u); colorbar
xlabel(’x’); ylabel(’y’); zlabel(’u’)
Exercise 0.63 Solve Laplace’s equation in three dimensions with the same bound-
ary conditions as previously, but with u= 0onz= 0andu= 1onz= 1.
For another approach called the method of particular solutions, see Betcke & Tre-
fethen (2005). This method has the historical feature of being the first to produce
solutions of Laplace’s equation in L-shaped domains, as in the Matlab logo. A re-
lated method can be used to deal with problems where one of the boundaries is
00.51
00.51−0.500.51
xy u
00.20.40.60.81Solution to Laplace’s equation using Chebyshev collocation.
now known in advance.
A pseudospectral approach for a mixed boundary
value problem
We look at an example due to Read (2008). The hydraulic potential φ(x,y)satisfies
Laplace’s equation with boundary conditions
φ(0,y) =h1, φ (s,y) =h2 (450)
along the vertical boundaries at x= 0 andx=s. Along the base of the aquifer,
we have∂φ
∂y(x,0) = 0. (451)
The condition at the soil surface located at y=f(x)is mixed:
φ(x,f(x)) =f(x), 0≤x<a, (452)
∂φ
∂y(x,f(x))−f/prime(x)∂φ
∂x(x,f(x)) =R(x), a<x ≤s, (453)
whereR(x)is the known vertical recharge. This condition can be rewritten in terms
of the conjugate stream function ψ(x,y), yielding
φ(x,f(x)) =f(x), 0≤x<a, (454)
ψ(x,f(x)) = −/integraldisplay
R(x) dx=r(x), a<x ≤s, (455)
We can write solutions for φandψthat satisfy side and bottom boundary condi-
tions:
φ=h1+h2−h1
sx+∞/summationdisplay
n=1Ancoshnπy
ssinnπx
s, (456)
ψ=A0+h2−h1
sy+∞/summationdisplay
n=1Ansinhnπy
scosnπx
s, (457)
The unknown constant term A0represents the mass flux through the aquifer at the
dam wall. Now define the following functions:
F(x,y) =
f(x)−h1−h2−h1
sx,0≤x<a ,
f(x)−h2−h1
sy, a<x ≤s(458)
and
Un(x,y) =
coshnπy
ssinnπx
s,0≤x<a ,
sinhnπy
scosnπx
s, a<x ≤s(459)
with
U0(x,y) =/braceleftBig0,0≤x<a ,
1, a<x ≤s.(460)
The mixed boundary condition becomes
Ft(x) =F(x,f(x)) =∞/summationdisplay
n=0AnUn(x,f(x)) =∞/summationdisplay
n=0AnUt
n(x). (461)
We truncate the sum at n=Nand enforce the condition at N+1collocation points
Ft(xi) =Ft
i=N/summationdisplay
n=0AnUt
n(xi). (462)
Read (2008) uses discrete least squares, taking more collocation points than un-
knowns.
Figure 44showsφandψon the upper boundary for the parameter values h1= 1,
h2= 1.5,s= 10 ,a= 5andf(x) = 1 + (1 −cosπx/10)/8. The value of N= 300 ,
M= 2Nused in Read (2008) failed here; these results are for N= 80 . The results
look comparable.
% p153.m Mixed Laplace bvp SGLS 05/20/08
N = 80; M = 2*N; n = 0:N;
h1 = 1; h2 = 1.5; s = 10; a = 5;
x = linspace(0,10,M+1)’; f = 1 + (1-cos(pi*x/10))/8;
F = (f-h1-(h2-h1)/s*x).*(x<a) - (h2-h1)/s*f.*(a<=x);
[n,xx] = meshgrid(n,x); ff = 1 + (1-cos(pi*xx/10))/8;
U = cosh(n*pi.*ff/s).*sin(n*pi.*xx/s).*(xx<a) + sinh(n*pi.*ff/s).*cos(n*pi.*xx/s).*(a<=xx);
U(:,1) = (a<=xx(:,1));
A = U\F;
phi = h1 + (h2-h1)/s*x + (cosh(n*pi.*ff/s).*sin(n*pi.*xx/s))*A;
psi = (h2-h1)/s*f + (sinh(n*pi.*ff/s).*cos(n*pi.*xx/s))*A;
subplot(2,1,1)
plot(x,phi)
xlabel(’x’); ylabel(’\phi’)
subplot(2,1,2)
plot(x,psi)
xlabel(’x’); ylabel(’\psi’)
Exercise 0.64 Investigate why p153.m seems to fail around N= 80 , far below
Read’s value.
0 2 4 6 8 100.811.21.41.6
xφ
0 2 4 6 8 1000.050.1
xψSolution to mixed boundary-value problem using collocation.
The Boundary Integral Method
Another approach for solving Laplace’s equation is the Boundary Integral Method
(BIM). A detailed exposition can be found in Pozrikidis (2002). This method also
works for the Helmholtz equation, Stokes flow problem, and so on. The method is
too lengthy to describe in detail. Figure 45shows some results using it.
0 5 10 15−2−1012
−1 0 1−2.5−2−1.5−1−0.500.511.522.5
0 5 10 15−4−2024
0 5 10 15−2−1012Added mass coefficients computed for a two-dimensional elliptical body using the
BIM.
References
Publications:
•Betcke, T. & Trefethen, L. N. Reviving the method of particular solutions. SIAM
Rev.,47, 469–491. 2005.
•Howison, S. D., Morgan, J. D. & Ockendon, J. R. A class of codimension-two
free boundary problems. SIAM Rev. ,39, 221–253, 1997.
•Pozrikidis, C. A practical guide to boundary element methods with the software
library BEMLIB , Chapman & Hall/CRC, Boca Raton, 2002.
•Read, W. W. An analytic series method for Laplacian problems with mixed
boundary conditions. J. Comp. Appl. Math. ,209, 22–32.
Conformal mapping (05/22/08)
Conformal maps
We can think of complex-valued functions of complex arguments as mappings from
one complex number to another: z/mapsto→f(z). The class of complex mappings is
obviously slightly more restricted than that of real mappings, since fis a function
ofz, and notxandyseparately.
Consider the origin without loss of generality. Then the angle between the images
of the two points z1andz2is the argument of the ratio
f(z2)
f(z1)=z2f/prime(0) +···
z1f/prime(0) +···=z2
z1+···, (463)
assuming that fis analytic at the origin. But this means that the angle between
f(z2)andf(z1)is the same as the angle between z2andz1unlessf/prime(0) = 0 .
Hence analytic functions give maps that preserve angle and are called conformal.
At points where f/primevanishes, the angle can change. This is crucial, since any
interesting conformal map needs to change the shape of some boundary or curve,
which can only happen at such points.
There are of course infinitely many conformal maps. The ones that are commonly
used boil down to polynomials, powers, M ¨obius maps, which are really combina-
tions of linear maps and the function z−1, exponential and logarithms, and trigono-
metric and hyperbolic functions, which are just elaborations of exponentials. To
start, remember that adding a constant is a translation, while multiplication by a
complex number ais a stretch-scaling: points are rotated about the origin by argz
and their magnitude is multiplied by |a|.
I only know one M ¨obius map, but all M ¨obius maps are basically the same
w=1−z
1 +z. (464)
One has to know that M ¨obius maps take circles to circles, lines to lines, and circles
that go through singularities to lines and vice versa. They form a group under
composition, and their effect can be determined by knowing just the images of
three points. Here 1goes to 0,0goes to −1and−1goes to infinity. It’s also
convenient to know that iand−iare mapped onto themselves. The picture is
two counter-rotating disks: the area in the first quadrant outside the unit disk gets
squeezed into the quarter-circle inside the unit disk in the first quadrant, that area
goes one hop to the left into the unit disk in the second quadrant, which goes to the
remainder of the unit disk, which finally “rotates” about iback to the first quadrant.
The lower half-plane is the symmetric image of this.
The exponential map z/mapsto→ez= ex(cosy+ i siny)is periodic in yand conformal
everywhere in the finite plane. Strips with height 2πare mapped onto the entire
plane, so the map is one-to-many. The logarithmic map z/mapsto→logz= logr+ iθ
requires choosing a cut. The entire complex plane is mapped onto a strip with
height 2π.
Anything more complicated requires practice. It is extremely useful to have Matlab
to plot the result of mappings.
% p161.m Conformal maps examples SGLS 05/21/08
clf
for j = -10:10
x = j*0.5; y = -10:.01:10; z1 = x + i*y;
y = j*0.5; x = -10:.01:10; z2 = x + i*y;
f1(1,:) = 1./z1; f2(1,:) = 1./z2;
f1(2,:) = (z1-1)./(z1+1); f2(2,:) = (z2-1)./(z2+1);
f1(3,:) = exp(z1); f2(3,:) = exp(z2);
f1(4,:) = log(z1); f2(4,:) = log(z2);
for k = 1:4
subplot(2,2,k)
hold on; plot(real(f1(k,:)),imag(f1(k,:)),real(f2(k,:)),imag(f2(k,:)),’-.’); hold off
axis([-5 5 -5 5])
end
end
Laplace’s equation is conformally invariant. This is obvious from the complex vari-
−5 0 5−505
−5 0 5−505
−5 0 5−505
−5 0 5−505Examples of complex mappings. Shown are the images of horizontal and vertical
lines in the z-plane. (a) z/mapsto→1/z; (b)z/mapsto→(1−z)/(1 +z); (c)z/mapsto→expz; (d)
z/mapsto→logz.
able framework. We can compose analytic functions as we like and construct so-
lutions to Laplace’s equation in this fashion.
Examples
Potential flow
Potential flow provides a great opportunity to use conformal maps. The typical
problem is to find the flow past an obstacle of a certain shape in an oncoming
stream with unit velocity in the x-direction. As a quick refresher, we remind our-
selves that in potential flow, the fluid velocity is irrotational, so that there exists a ve-
locity potential φwithu=∇φ. If the flow is also incompressible, ∇·u=∇2φ= 0.
Hence an analytic function f=φ+ iψgives a velocity field. The imaginary part
offis the streamfunction, which is constant along lines with no-normal flow, such
as solid boundaries. The flow is taken to be inviscid, otherwise we have an extra
boundary condition and viscosity to worry about.
This is useful if we know solutions to this problem in a simple geometry, and we
do. In the upper (or lower) half-plane, zis the analytic potential corresponding to
uniform flow from left to right. For inviscid flow we need only satisfy no normal flow,
but the velocity field is just (1,0)so this is automatic. Flow past a cylinder is also
simple. The velocity potential is w(z) =z+ 1/z. We can see this work without
any real work. At infinity, the potential looks like z– check. Along the unit circle,
w= eiθ+ e−iθ= 2 cosθ, which is real; hence the streamfunction is zero along the
unit circle, which can hence be a material surface – check.
An excellent source for conformal maps and potential flow is Milne-Thomson (1996).
Note that the definition of complex potential has a minus sign in front of it compared
to the standard modern use.
Flow through an aperture
It can be useful to consider the inverse mapping going from w=f(z)toz. For
example.z=ccoshwgives
x=ccoshφcosψ, y =csinhφsinψ. (465)
We can eliminate φand obtain
x2
c2cos2φ−y2
c2sin2φ= 1, (466)
so the streamlines are confocal hyperbolas with foci at (±c,0). Any streamline can
again be taken as a solid boundary. Figure 47illustrates the streamlines. Note that
because of Matlab’s (sensible) convention in computing inverse hyperbolic func-
tions, we only get the right half of the picture.
% p162.m aperture conformal map SGLS 05/22/08
clf
for j = 0:20
x = (j-10)*0.5; y = pi*(0:.01:1); z1 = x + i*y;
y = j*pi/20; x = -10:.01:10; z2 = x + i*y;
f1 = acosh(z1/2); f2 = acosh(z2/2);
hold on; plot(real(f1),imag(f1),real(f2),imag(f2),’-.’); hold off
end
Exercise 0.65 Obtain the flow past an elliptic cylinder using the mapping z=
ccosw.
Problems with branch cuts
At this point, one could consider Zhukovsky/Joukowski (Cyrillic transliteration is-
sues) mappings, but instead let’s look at the map w=aπU cothaπ/z . Explicitly,
w=aπU coth/parenleftbiggaπx
r2−aπiy
r2/parenrightbigg
. (467)
Wheny= 0 oraπy/r2=π/2, the argument of coth is real andwis real: these
are streamlines. They corresponds to the x-axis and to the circle of radius awith
center (0,a). For large values of |z|,w∼Uz, i.e. uniform oncoming flow. Hence
we should be seeing flow over a log so to speak.
0 0.5 1 1.5 2 2.500.511.522.533.5Streamlines and isopotentials for flow through an aperture.
Figure 48shows isopotentials and streamlines in the upper half-plane. Clearly
something is wrong since we have intersecting streamlines.
% p163.m log conformal map SGLS 05/22/08
clf
for j = -10:10
x = j; y = -0:.01:10; z1 = x + i*y;
y = j; x = -10:.01:10; z2 = x + i*y;
f1 = 2*pi*coth(2*pi./z1); f2 = 2*pi*coth(2*pi./z2);
hold on; plot(real(f1),imag(f1),real(f2),imag(f2),’-.’); hold off
axis([-10 10 0 10])
end
Exercise 0.66 Find the problem and fix it.
Free surface flows
Free surface flows are industrially important. There is an extensive literature on in-
viscid, potential, free surface flows. The standard references are Birkhoff & Zaran-
tonello (1957) and Gurevich (1965). These approaches depend crucially on confor-
mal maps. The free surface is unknown and has to be found as part of the solution.
−10 −5 0 5 100246810Streamlines and isopotentials for flow over a log.
One has a kinematic and a dynamic boundary condition on the surface. These
reduce to |dw/dz|=constant on the free boundary.
For flows bounded by flat plates and free streamlines, one can us the hodograph,
which is locus of values of the complex velocity dw/dz. On free streamlines, it must
be on the unit circle. The theory for non-flat boundaries is much more complicated.
Free streamlines are used to compute Helmholtz flows, in which there is a region
of stagnant fluid behind obstacles.
The results tend to be messy and hard to visualise, especially because they are
usually given for the hodograph.
Exercise 0.67 Take the simple solution (8) of p. 29 of Birkhoff & Zarantonello
(1957) and plot it. This may require solving some ODEs.
A classic free surface flow is the Borda mouthpiece flow. Figure 49shows the
streamlines. The relevant mapping is
F(z) = 1 +g(z) + logg(z), g (z) =z2+z√
z2+ 1 (468)
and the streamlines are given by the rays with argzconstant.
However, this is a notorious example15(see http://www-personal.umich.edu/~williams/archive/forth/complex/borda.html )
of a calculation that can be wrecked by a poor choice of branch cuts. The issue is
actually more technical than that, and involves the concepts of +0.0and−0.0that
are supposed to be supported by the IEEE754 standard.
15Notorious for those who care about such things – there may be 5or6of us.
Warning 13 This is a good opportunity to remind ourselves of the danger of poorly
programmed elementary functions, logarithms and the use of extra digits accuracy.
Go to W. Kahan’s home page and read the documents there.
% p164.m Borda mouthpiece SGLS 05/22/08
r = logspace(-3,3,61);
clf
for j = -10:10
t = pi*j*0.05;
z = r*exp(i*t);
g = z.^2 + z.*sqrt(z.^2+1);
F = 1 + g + log(g);
hold on; plot(real(F),imag(F)); hold off
end
axis([-4 8 -7 7]); axis square
Exercise 0.68 Why does this work when the website cited implies it shouldn’t?
The Schwarz formula
An interesting application of conformal maps can be found in Llewellyn Smith,
Michelin & Crowdy (2008). The classical theory of the motion of a solid through
−4 −2 0 2 4 6 8−6−4−20246Streamlines for flow into the Borda mouthpiece.
an inviscid fluid was developed by Kirchhoff and subsequently by Thomson and
Tait. The coupled fluid-body system, which in its primary formulation requires solv-
ing the Euler equations and Newton’s equations for the body, can be replaced by
a system of ordinary differential equations that take into account the forces and
couples exerted on the solid by the fluid. The flow is taken to be irrotational, which
is the case if the body starts from rest, for example. It can be shown that the nature
of the far-field motion depends crucially on an object called the virtual mass tensor.
The symmetry properties of the virtual mass tensor are discussed in Lamb (1945;
§126), where it is pointed out that “as might be anticipated from the complexity of
the question, the physical meaning of the results is not easily grasped”. In Lamb’s
Cartesian notation we can take w=p=q= 0, so that the coefficients correspond-
ing tom16andm26areGandFrespectively. All other “cross-terms” (combining
linear and angular velocity) vanish. Then, considering the two-dimensional body as
being extended indefinitely in the third dimension, FandGvanish in the following
cases (the headings are taken from Lamb):
3◦. If the body has two axes of symmetry at right angles.
4◦and 5◦. If the body is a circle or a regular polygon.
7◦. If the body is symmetric under a rotation by a right angle.
It is important to point out that these are sufficient, but not necessary, conditions.
Can we find a sufficient and necessary condition? Since this is a problem con-
cerning shapes of two-dimensional bodies, it is natural to use conformal mapping
theory.
We can reduce the problem to constructing a conformal map z=f(ζ)from the
interior of the unit disk to the outside of a simply connected body. The complex
potentialw=φ+ iψsatisfies the following boundary value problem
Re[−iW(ζ)] =ψ=−Ω
2zz−iUeiα
2z+iUeiα
2z on|ζ|= 1. (469)
SinceW(ζ)must be analytic in |ζ| ≤ 1, this is just the Schwarz problem for the
unit disk and its solution is given by the Poisson integral formula:
−iW(ζ) =1
2πi/contintegraldisplay
|ζ/prime|=1dζ/prime
ζ/prime/parenleftbiggζ/prime+ζ
ζ/prime−ζ/parenrightbigg/bracketleftbigg
−Ω
2zz−iUeiα
2z+iUeiα
2/bracketrightbigg
. (470)
The condition that there be no dipole field at infinity becomes
/contintegraldisplay
|ζ/prime|=1dζ/prime
ζ/prime2/bracketleftbigg
−Ω
2zz−iUeiα
2z+iUeiα
2/bracketrightbigg
= 0. (471)
One can construct mappings satisfying this condition, but a critical point is that the
mappings need to be univalent, which means meromorphic and single-valued, so
thatf(z1) =f(z2)impliesz1=z2. This an important problem in advanced complex
analysis.
The Bieberbach conjecture
The most famous such problem is the Bieberbach conjecture. Consider the class
Σ0of functions that are univalent and analytic in |z|<1, normalized to have Taylor
series expansions for the form
f(z)z+∞/summationdisplay
n=2anzn. (472)
The Bieberbach conjecture states that |an| ≤nforn≥2. This conjecture was
stated in 1916 by Bieberbach, and proved by de Branges in 1984.
The ideas developed to prove the conjecture are very sophisticated, but many as-
pects of the proof are fairly elementary. A good account is given in Henrici, vol. III.
The original proof used the Askey–Gasper theorem, which is a result in the theory
of orthogonal polynomials. We shall meet orthogonal polynomials in Chapter 128.
Schwarz–Christoffel mappings
Henrici, vol. III, also discusses the numerical construction of conformal maps.
There are situations where one knows a conformal map exists, but its explicit form
can only be found numerically, for example by solving an integral equation.
A very useful class of mappings is given by the Schwarz–Christoffel formula. This
gives a recipe for a conformal map from the upper half-plane to the interior of a poly-
gon with vertices w1,...,w n. The interior angles at the vertices are α1π,...,α nπ.
The pre-images of the vertices (prevertices) are along the real axis at z1< z 2<
···< z n. We can also have vertices at infinity. The Schwarz—Christoffel formula
is
f(z) =f(z0) +c/integraldisplayz
z0n−1/productdisplay
j=1(ζ−zj)αj−1dζ. (473)
The problem is that the prevertices cannot usually be computed analytically.
The Schwarz–Christoffel (SC) toolbox written by Toby Driscoll that constructs these
maps. It consists of a number of Matlab programs. The toolbox can also solve
Laplace’s equation in such domains. Figure 50shows an example of using the
toolbox.
% p165.m SC toolbox example (based on TD example) SGLS 05/22/08
p = polygon([i -1+i -1-i 1-i 1 0])
subplot(2,2,1); plot(p)
subplot(2,2,2); f = diskmap(p); f, plot(f)
subplot(2,2,3); f = center(f,-0.5-0.5i), plot(f)
subplot(2,2,4); phi = lapsolve(p,[1 -1 NaN 0 NaN 0]’);
[tri,x,y] = triangulate(p); trisurf(tri,x,y,phi(x+i*y));
−1−0.500.51−1−0.500.51
−101
−101−202−1−0.500.51−1−0.500.51
−1−0.500.51−1−0.500.51Example of use of the SC toolbox.
Fuchsian differential equation
Things can get even more complicated. See Craster (1996) for a discussion of
mapping a curvilinear quadrangle to a half-plane. One needs to solve things called
Fuchsian differential equations.
References
Publications:
•Birkhoff, G. & Zarantonello, E. H. Jets, wakes, and cavities , Academic, New
Y ork, 1957.
•Craster, R. V. Conformal mappings involving curvilinear quadrangles. IMA
J. Appl. Math. ,57, 181–191; 1996.
•Llewellyn Smith, S. G., Michelin, S. & Crowdy, D. G. The dipolar field of rotating
bodies in two dimensions. In press, J. Fluid Mech. , 2008.
•Gurevich, M. I. Theory of jets in ideal fluids , Academic, New Y ork, 1965.
•Lamb, H. Hydrodynamics , 6th ed, Dover, New Y ork, 1945.
•Milne-Thomson, L. M. Theoretical hydrodynamics , 5th ed, Dover, New Y ork,
1996.
Web sites:
•http://www.cs.berkeley.edu/˜wkahan/
•http://www.math.udel.edu/˜driscoll/software/SC/
•http://www-personal.umich.edu/˜williams/archive/forth/complex/borda.html
Elliptic functions (05/27/08) [15 min. short]
Problem 10 of the Hundred-dollar, Hundred-digit
Challenge
The last problem of the Hundred-dollar, Hundred-digit challenge was the following:
A particle at the center of a 10×1rectangle undergoes Brownian motion
(i.e., two-dimensional random walk with infinitesimal step lengths) until it hits
the boundary. What is the probability that it hits at one of the ends rather
than at one of the sides?
Here is what the team of Glenn Ierley, Stefan Llewellyn Smith and Bob Parker wrote
in their submission to Nick Trefethen :
By well-known theory, the probability is the value of a harmonic function in
the center of the rectangle with boundary conditions of zero on long edges
and unity on the short ones. There are several ways to solve this clas-
sic problem: one method, suggested by Bill Y oung, uses the analytic solu-
tion in a semi-infinite rectangle, and the method of images. Another is the
closed-form result via the Schwarz–Christoffel transformation (Morse and
Feshbach, 1953). Only one edge is at unity here, hence the initial factor of
two:
P= 2(2/π)Imln(sn[(K+iK/prime)/2,k]) =2
πarcsin(k/prime)
wherek/prime=√
1−k2,kis the modulus, and Kis the quarter-period of the
Jacobi elliptic function sn(u,k)associated with the nome q= exp( −π/10);
K/primeis the complementary quarter period. If Q= exp( −10π)we find the
explicit infinite product:
k/prime= 4/radicalbig
Q∞/productdisplay
n=1[(1 +Q2n)/(1 +Q2n−1)]4
which converges at a more than adequate rate, since Q≈2.27×10−14.
Here some old-fashioned analysis and a hand calculator are sufficient. In
any event,
P= 10−6×.383758797925122610340713318620483910079300559407
2509569030022799173436606852743276500842845647269910
Notice the reference to SC.
Let us go through a number of approaches and see how they do and then discuss
elliptic functions. Bornemann et al. (2004) have a through discussion that is well
worth reading. This chapter is more about this problem than elliptic functions.
We can find the probability uh(x,y)that a particle starting at an arbitrary lattice
point (x,y)and taking random steps of length hleft, right, up or down, reaches the
ends:
uh(x,y) =1
4[uh(x+h,y) +uh(x−h,y) +uh(x,y+h) +uh(x,y−h)] (474)
withuh= 1at the ends and uh= 0along the edges. Now we take the limit h→0
and find ∇2u= 0with boundary conditions u= 1at the ends and u= 0along the
edges. What we are looking for is then p=u(0,0).
Fourier solution
As in Chapter 97, we can solve this using Fourier series. The result is in Borne-
mann et al. (2004):
u(x,y) =4
π∞/summationdisplay
k=0(−1)k
2k+ 1cosh [(k+ 1/2)πx/b ]
cosh [(k+ 1/2)πa/b ]cos [(k+ 1/2)πy/b ], (475)
where the result is for the rectangle (−a,a)×(−b,b). At the origin this gives
p=4
π∞/summationdisplay
k=0(−1)k
2k+ 1sech [(2k+ 1)πρ/2], (476)
whereρ=a/b= 10 here. This series converges very very well:
p=4
πsech 5π−4
3πsech 15π+···= 3.837587979251258 ×10−7−2.905183386488490 ×10−21+···
(477)
We are basically done with one term, and what’s more we then have
p≈4
πsech 5π≈8
πe−5π= 3.837587979251345 ×10−7(478)
to13significant digits.
Exercise 0.69 Derive ( 475).
Pseudospectral solution
This is just a simple adaptation of the approach of Chapter 97. The size of the
matrices is limited by memory size. One can do much better by using a direct
solver for the problem and not constructing the large MN×MN matrix explicitly.
However, even with less than the largest size of matrix that fits in memory, we
can obtain essentially machine accuracy for p. The changes from the approximate
result ( 478) are of the order of machine accuracy.
% p172.m 100$100d using pseudospectral methods SGLS 05/26/08
for j = 1:10
M = 20*j+1, N = 2*j+1,; MN = M*N
[x,DM] = chebdif(M,2); x = (x+1)*5; D2x = DM(:,:,2)*0.04;
[y,DM] = chebdif(N,2); y = (y+1)*0.5; D2y = DM(:,:,2)*4;
[xx,yy] = meshgrid(x,y); xx = xx(:); yy = yy(:);
bx0 = find(xx==0); bx1 = find(xx==10);
by0 = find(yy==0); by1 = find(yy==1);
Ix = speye(M); Iy = speye(N); I = speye(MN);
L = kron(D2x,Iy) + kron(Ix,D2y);
L(bx0,:) = I(bx0,:); L(bx1,:) = I(bx1,:);
L(by0,:) = I(by0,:); L(by1,:) = I(by1,:);
b = zeros(MN,1); b(bx0) = 1; b(bx1) = 1;
u = L\b; u = reshape(u,N,M);
u((N+1)/2,(M+1)/2)
u((N+1)/2,(M+1)/2) - 8/pi*exp(-5*pi)
whos
end
surf(x,y,u); colorbar
xlabel(’x’); ylabel(’y’); zlabel(’u’)
0510
00.51−0.500.511.5
xy u
00.20.40.60.81Solution to Laplace’s equation for Problem 10 using the pseudospectral method.
Method of images
This is the solution used in our 100$100d entry. We used Maple and the Fortran
MP package. The latter has been superseded by the Arprec package, but still
works just fine. See below for the relevant web site. David H. Bailey is the person
to thank for this outstanding software. Getting both packages to work is a good test
for your Fortran 77, Fortran 90 and C++ compilers. This reflects poorly on most
compilers, not on the packages. Note that Mpfun77 requires a re-entrant Fortran
compiler, and that gfortran chokes (or at least used to choke) on Arprec; g95 does
OK.
The mathematical basis for this approach is simple. The solution in the semi-infinite
domainx > 0,0< y < 1with boundary condition u(0,y) = 1 is simple to obtain.
Probably the easiest way is to consider the analytic function
f=2
πtanh logπz (479)
This solution does not satisfy the boundary condition at x= 10 of course. But we
can addu(20−x,y)or something. Now the boundary condition at x= 10 is OK but
the boundary condition at x= 0is wrong. Fix it by adding u(−20 +x,y), so now
we’ve messed up the boundary condition at x= 10 . And so on. This is a rapidly
converging series.
Exercise 0.70 Tidy up the argument above.
The Maple program is very simple and runs quickly. The last value output by it is
f :=
0.38375879792512261034071331862048391007930055940725095690300227991734\
36606852743276500842845647269910153533872778317803831155446602429138550\
88504103441387748160875929573579676477730773292951740183984303931380164\
79100724951181200941520680531959735213809853452131398770077650782619731\
49390177574688899884444680986326264599208222786311389993223965825814541\
30470461998109019029121760645911213089021528990601490723637566978175207\
61684806801117495683049448043265035823341426946625880372826162050882606\
38809533228799904415233034465138660464604211124375197538698573260649592\
38573864775109187836260526095180903077083878240306548592522281607454310\
47322744238551542096778702385127987386942001990107441279771521662115502\
02822663804167331538693609358255390240890217619916497219471784632602586\
33775810741919241397468174515818123184320220341606389932325913053684127\
73582488453158031073181213069608951038741748249482779343966678093396072\
56835394109595081240644109257599303818887286219444623642574992600922947\
15336328556159441041323456157616843915972332384929827428642609561422820\
43685805961037208313201165051926478585352035803835503353999111323449653\
46268721159322866195315080202716531494746883969197031156638559930537711\
92223856277209887656053967387456011437414291111892700736070233622196900\
69864658361813000801044939794303793440769721963117940740020084114412672\
35470873574082940871728532497524058680105397426967852028356484411547498\
23739423827262996823761792487653750615148808404860749676681138229467202\
54241837587137907997976120960045121144868663728944434510215621910570556\
50810806509182294987342950176404947901646640978669051031078447037902302\
05032693518446663319457450232997903139697038633960336367481119788131703\
85395819008445807935353049867475384683974526681204170795535631435570447\
31000549106457796731301739100773411291577132797387505519706994891932580\
14430145287483227195680729487700371631268733090790776814446895098807450\
68007477105623051806106195043941107995057641163311789967922969044257306\
-6
963964346150118 10
# Maple solution of 100$100d problem SGLS 05/26/08
Digits:=2000;
L:=10;
f:=2*evalf(coeff(evalc(2/Pi*log(tanh(Pi*(L/2+I/2)/2))),I));
for j from 1 to 150 do
f:=f+2*(-1)^j*evalf(coeff(evalc(2/Pi*log(tanh(Pi*(L/2+j*L+I/2)/2))),I));
od;
The MP Fortran program is also simple. For interest, its MP translated version is
also included. It does not run particularly fast. The last value returned is
10 ^ -7 x 3.8375879792512261034071331862048391007930055940725095690300
227991734366068527432765008428456472699101535338727783178038311554466024291385
508850410344138774816087592957357967647773077329295174018398430393138016479100
724951181200941520680531959735213809853452131398770077650782619731493901775746
888998844446809863262645992082227863113899932239658258145413047046199810901902
912176064591121308902152899060149072363756697817520761684806801117495683049448
043265035823341426946625880372826162050882606388095332287999044152330344651386
604646042111243751975386985732606495923857386477510918783626052609518090307708
387824030654859252228160745431047322744238551542096778702385127987386942001990
107441279771521662115502028226638041673315386936093582553902408902176199164972
194717846326025863377581074191924139746817451581812318432022034160638993232591
305368412773582488453158031073181213069608951038741748249482779343966678093396
072568353941095950812406441092575993038188872862194446236425749926009229471533
632855615944104132345615761684391597233238492982742864260956142282043685805961
037208313201165051926478585352035803835503353999111323449653462687211593228661
953150802027165314947468839691970311566385599305377119222385627720988765605396
738745601143741429111189270073607023362219690069864658361813000801044939794303
793440769721963117940740020084114412672354708735740829408717285324975240586801
053974269678520283564844115474982373942382726299682376179248765375061514880840
486074967668113822946720254241837587137907997976120960045121144868663728944434
510215621910570556508108065091822949873429501764049479016466409786690510310784
470379023020503269351844666331945745023299790313969703863396033636748111978813
170385395819008445807935353049867475384683974526681204170795535631435570447310
005491064577967313017391007734112915771327973875055197069948919325801443014528
748322719568072948770037163126873309079077681444689509880745068007477105623051
806106195043941107995057641163311789967922969044257306963964346150120805998217
476701476670541036502923093501852210940168418140822882602035651566208531391370
334558163538339156109754660979557363697115004526385745379518166889224766730088
154205730047342267700923753854366429693027908127410684923240108802651929170077
113306739918926185102465407648899208924701201149302934330223944307643008815012
688616181822228780479264874023119487631530040872502895878424637255170158300952
403979044613484893079103371094875090909595257064134534402407821306807003414152
288411732207576501112904060139679932698349550604764500049234392488065243268800
784733468013593252004684515924758298312709614070186700888720057591499715746401
432566756596687895974746687517957220753455824815131559253089122634704492746285
617553445152378936707596711696463301355195193638294294652510110148909942450770
427749333000627227795204185488367788360226395732256257125831387821402491611093
444762349781949185101561045681372602514808591496827718548971567939497801684042
728148147849519424489130916843268327996492751740007360979919934620927139720530
549662378988243321529189118755089817416853617262452767887183321708267971957656
685801193265429757443006770068920791338721445048478111701323909882742624411128
333049138322336670802758597326262889201211392575137883560449652897885518631863
121276010803532580515368753395326433694160277028526748229856159514538119828754
570024074703615952991593824359913382021097730778990728343548480266477550307017
124977387023423191779237968771086749260998190318125821161106065728792489707381
868025254005420183819886918910071506421844368899340672193967319063816566526771
027564276018831174259170506026222111837343415199251634098165542777973928869922
531667523887134478590681911941646400386398701208609109799097718001232852358031
905916952081857349347995602010004369680911842563705988930570208791004552928027
203341684142831226658791845593834413893463364778075653025215404560224517044378
920469135715158935837407368039438142338962249960119782168317027359889449183961
389268287143310562767567752609593795900770831639570040851794653232696713197967
292029935640426602603710401638218705784077017233019238898980904808544582180596
568616232136851559489680780530766919364210866283443180645843971597540484224880
890184596388142055795743859527270551007874807558980641370522523000836234539567
722469464603517544775140767575126957909520613514155654777972397255117781865624
646734969332136316565488686294753197306478900144097926572075521096926096108350
837481611117776460044982575901520944085697955294156392815194835343730996192079
325351247023960686968217072294228189205503602901091214550344403839730393194505
939788430302409589849608024436632722537218225354018735008495353224842497102233
902660578161358255467364092668769038208963103079498896770410367530238807876413
176752902338423393552857988256823694979292490670911300318908818135947417831642
904191579007118618932464601597823412418524509295318927794880719201075389559814
741544435891957512005201332573332950455786206875519010098795434706738359230172
839398729498205091747665027608221089579372059716906661240870745292877246695041
685792821791951347029422095500456320247997440486760109985915983893486523487474
712918126979714253643222439345846068439608502483338521641759650135087367895565
227775670531701010610512050952318520451449897746610200236918960828278615211943
601147657922032172995884801059364503760533245769540079136430798865410589056188
013796408043764383784752833056930967597416210273116148959327991407403747165016
506717230029055599654218661602334929203352939117039448324293760852247805540546
992787525423842119910114068164112790210983163595657316260207596608041626933207
051338704454215232562324969346604296114710411699539008400173967573525593551717
225304474901068609413953754821790909442236636631991136198428210058671631343392
804179459138371156047620046142665220953238925227133041289183115388523876916613
798399566042545664465506317065265027977820444757006994563239492477610787321319
459737493390942034461152253854738223782017099102379579800069406781302102085691
841774989071361576346808622817707154364861320806240508319982008060029626644035
030045179794343581154002771275145577588743113500118199978372748043743160537434
138408502955832369297153909338705169946407425694316229890025457653413453216888
028256015004659717723461537038227959060329884183942985875415480451237171271541
220241750444378921762423204018910910394765293358088305901303452530469835893835
318688063000647761422541947265419052400574162546112972048874487367277878174253
757462662403761955994835310469056779759925426048315352166095416813711713457347
661804955313989345882361636796987070466479156964237278419130359343513794156569
204681344174783380540393351429269458347418581259182241552480428265627804456439
674910516833812214721269535047308127152277779476017032686584677165699944999159
543628779838040656567106755907351374349311683657037373511524959003610369780088
089351960979831119161145262118377181156363340800557382872954215659580576710980
56711834179711514347371358210974467317591172527980738348808448989951679277,
c p175.f 100$100d problem 10 in MP fortran SGLS 05/26/08
c transmp < p175.f >! p175mp.f
c g77 -O -o p175mp p175mp.f mpfun.o
c p175mp >! p175.out &
cmp+ precision level 7000
cmp+ mixed mode safe
cmp+ output precision 7000
cmp+ scratch space 20000
program prob10
cmp+ implicit multip real (a-h,p-z)
implicit double precision (a-h,p-z)
cmp+ multip complex c,s,ta
double complex c,s,ta,ione
xl=10.0d0+0
pi=(4.0d0+0)*atan(1.0d0+0)
s2=sqrt(2.0d0+0)
ione=(0,1)
s=sinh(pi*xl/(4.0d0+0))/s2 + ione*cosh(pi*xl/(4.0d0+0))/s2
c=cosh(pi*xl/(4.0d0+0))/s2 + ione*sinh(pi*xl/(4.0d0+0))/s2
ta=s/c
f=(4.0d0+0)/pi*atan2(dpimag(ta),dpreal(ta))
write (6,*) f
mone=-1
do j=1,150
s=sinh(pi*(1+2*j)*xl/(4.0d0+0))/s2 +
$ ione*cosh(pi*(1+2*j)*xl/(4.0d0+0))/s2
c=cosh(pi*(1+2*j)*xl/(4.0d0+0))/s2 +
$ ione*sinh(pi*(1+2*j)*xl/(4.0d0+0))/s2
ta=s/c
f=f+mone**j*(4.0d0+0)/pi*atan2(dpimag(ta),dpreal(ta))
write (6,*) f
enddo
end
function dpreal(c)
double precision dpreal
double complex c
dpreal = dble(c)
return
end
function dpimag(c)
double precision dpreal
double complex c
dpimag = dimag(c)
return
end
c p175.f 100$100d problem 10 in MP fortran SGLS 05/26/08
c transmp < p175.f >! p175mp.f
c g77 -O -o p175mp p175mp.f mpfun.o
cmp+ precision level 7000
cmp+ mixed mode safe
cmp+ output precision 7000
cmp+ scratch space 20000
program prob10
cmp+ implicit multip real (a-h,p-z)
implicit double precision (a-h,p-z)
cmp+ multip complex c,s,ta
CMP> double complex c,s,ta,ione
double complex ione
CMP<
REAL C(1946)
REAL S(1946)
REAL TA(1946)
REAL XL(973)
CHARACTER*15 MPA2
CHARACTER*1 MPA1(7101)
INTEGER MPI1
REAL MPM1(973)
REAL MPJ1(973)
REAL MPM2(973)
REAL PI(973)
REAL MPM3(973)
REAL MPM4(973)
REAL S2(973)
REAL MPZ1(1946)
DOUBLE PRECISION MPD1
DOUBLE PRECISION MPD2
REAL MPZ2(1946)
REAL MPZ3(1946)
REAL F(973)
REAL MPJ2(973)
REAL MPJ3(973)
INTEGER MPNWQ, MPNW4
REAL MPL02, MPL10, MPPIC
COMMON /MPTCON/ MPNWQ, MPNW4, MPL02(974), MPL10(974),
$ MPPIC(974)
REAL MPSS
COMMON /MPCOM3/ MPSS( 20000)
C
CALL MPSETP (’NW’, 970)
CALL MPSETP (’IMS’, 20000)
MPNWQ = 969
MPNW4 = 973
CALL MPDMC (2.D0, 0, MPM1)
CALL MPLOG (MPM1, MPL02, MPL02)
CALL MPDMC (10.D0, 0, MPM1)
CALL MPLOG (MPM1, MPL02, MPL10)
CALL MPPI (MPPIC)
CALL MPSETP (’NW’, 969)
CMP<
CMP> xl=10.0d0+0
MPA2 = ’10^0 x 10.0’
READ (MPA2, ’( 11A1)’ ) (MPA1(MPI1), MPI1 = 1, 11)
CALL MPINPC (MPA1, 11, MPM1)
MPA2 = ’10^0 x 0’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
CALL MPADD (MPM1, MPJ1, MPM2)
CALL MPEQ (MPM2, xl)
CMP<
CMP> pi=(4.0d0+0)*atan(1.0d0+0)
MPA2 = ’10^0 x 4.0’
READ (MPA2, ’( 10A1)’ ) (MPA1(MPI1), MPI1 = 1, 10)
CALL MPINPC (MPA1, 10, MPM1)
MPA2 = ’10^0 x 0’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
CALL MPADD (MPM1, MPJ1, MPM2)
MPA2 = ’10^0 x 1.0’
READ (MPA2, ’( 10A1)’ ) (MPA1(MPI1), MPI1 = 1, 10)
CALL MPINPC (MPA1, 10, MPM1)
MPA2 = ’10^0 x 0’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
CALL MPADD (MPM1, MPJ1, MPM3)
CALL MPDMC (1.D0, 0, MPM4)
CALL MPANG (MPM4, MPM3, MPPIC, MPM1)
CALL MPMUL (MPM2, MPM1, MPM3)
CALL MPEQ (MPM3, pi)
CMP<
CMP> s2=sqrt(2.0d0+0)
MPA2 = ’10^0 x 2.0’
READ (MPA2, ’( 10A1)’ ) (MPA1(MPI1), MPI1 = 1, 10)
CALL MPINPC (MPA1, 10, MPM1)
MPA2 = ’10^0 x 0’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
CALL MPADD (MPM1, MPJ1, MPM2)
CALL MPSQRT (MPM2, MPM1)
CALL MPEQ (MPM1, s2)
CMP<
ione=(0,1)
CMP> s=sinh(pi*xl/(4.0d0+0))/s2 + ione*cosh(pi*xl/(4.0d0+0))/s2
CALL MPMUL (pi, xl, MPM1)
MPA2 = ’10^0 x 4.0’
READ (MPA2, ’( 10A1)’ ) (MPA1(MPI1), MPI1 = 1, 10)
CALL MPINPC (MPA1, 10, MPM2)
MPA2 = ’10^0 x 0’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
CALL MPADD (MPM2, MPJ1, MPM3)
CALL MPDIV (MPM1, MPM3, MPM2)
CALL MPCSSH (MPM2, MPL02, MPM3, MPM1)
CALL MPDIV (MPM1, s2, MPM2)
CALL MPMUL (pi, xl, MPM1)
MPA2 = ’10^0 x 4.0’
READ (MPA2, ’( 10A1)’ ) (MPA1(MPI1), MPI1 = 1, 10)
CALL MPINPC (MPA1, 10, MPM3)
MPA2 = ’10^0 x 0’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
CALL MPADD (MPM3, MPJ1, MPM4)
CALL MPDIV (MPM1, MPM4, MPM3)
CALL MPCSSH (MPM3, MPL02, MPM1, MPM4)
MPD1 = DREAL (ione)
MPD2 = DIMAG (ione)
CALL MPMULD (MPM1, MPD1, 0, MPZ1)
CALL MPMULD (MPM1, MPD2, 0, MPZ1(MPNWQ+5))
CALL MPMPCM (MPNW4, MPZ1, MPM1, MPM3)
CALL MPDIV (MPM1, s2, MPZ2)
CALL MPDIV (MPM3, s2, MPZ2(MPNWQ+5))
CALL MPDMC (0.D0, 0, MPM1)
CALL MPMMPC (MPM2, MPM1, MPNW4, MPZ3)
CALL MPCADD (MPNW4, MPZ3, MPZ2, MPZ1)
CALL MPCEQ (MPNW4, MPZ1, s)
CMP<
CMP> c=cosh(pi*xl/(4.0d0+0))/s2 + ione*sinh(pi*xl/(4.0d0+0))/s2
CALL MPMUL (pi, xl, MPM1)
MPA2 = ’10^0 x 4.0’
READ (MPA2, ’( 10A1)’ ) (MPA1(MPI1), MPI1 = 1, 10)
CALL MPINPC (MPA1, 10, MPM2)
MPA2 = ’10^0 x 0’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
CALL MPADD (MPM2, MPJ1, MPM3)
CALL MPDIV (MPM1, MPM3, MPM2)
CALL MPCSSH (MPM2, MPL02, MPM1, MPM3)
CALL MPDIV (MPM1, s2, MPM2)
CALL MPMUL (pi, xl, MPM1)
MPA2 = ’10^0 x 4.0’
READ (MPA2, ’( 10A1)’ ) (MPA1(MPI1), MPI1 = 1, 10)
CALL MPINPC (MPA1, 10, MPM3)
MPA2 = ’10^0 x 0’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
CALL MPADD (MPM3, MPJ1, MPM4)
CALL MPDIV (MPM1, MPM4, MPM3)
CALL MPCSSH (MPM3, MPL02, MPM4, MPM1)
MPD1 = DREAL (ione)
MPD2 = DIMAG (ione)
CALL MPMULD (MPM1, MPD1, 0, MPZ1)
CALL MPMULD (MPM1, MPD2, 0, MPZ1(MPNWQ+5))
CALL MPMPCM (MPNW4, MPZ1, MPM1, MPM3)
CALL MPDIV (MPM1, s2, MPZ2)
CALL MPDIV (MPM3, s2, MPZ2(MPNWQ+5))
CALL MPDMC (0.D0, 0, MPM1)
CALL MPMMPC (MPM2, MPM1, MPNW4, MPZ3)
CALL MPCADD (MPNW4, MPZ3, MPZ2, MPZ1)
CALL MPCEQ (MPNW4, MPZ1, c)
CMP<
CMP> ta=s/c
CALL MPCDIV (MPNW4, s, c, MPZ1)
CALL MPCEQ (MPNW4, MPZ1, ta)
CMP<
CMP> f=(4.0d0+0)/pi*atan2(dpimag(ta),dpreal(ta))
MPA2 = ’10^0 x 4.0’
READ (MPA2, ’( 10A1)’ ) (MPA1(MPI1), MPI1 = 1, 10)
CALL MPINPC (MPA1, 10, MPM1)
MPA2 = ’10^0 x 0’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
CALL MPADD (MPM1, MPJ1, MPM2)
CALL MPDIV (MPM2, pi, MPM1)
CALL MPMPCM (MPNW4, ta, MPM3, MPM2)
CALL MPEQ (ta, MPM3)
CALL MPANG (MPM3, MPM2, MPPIC, MPM4)
CALL MPMUL (MPM1, MPM4, MPM2)
CALL MPEQ (MPM2, f)
CMP<
CMP> write (6,*) f
CALL MPOUT (6, f, 7000, MPA1)
CMP<
mone=-1
do j=1,150
CMP> s=sinh(pi*(1+2*j)*xl/(4.0d0+0))/s2 +
CMP> $ ione*cosh(pi*(1+2*j)*xl/(4.0d0+0))/s2
MPA2 = ’10^0 x 1’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
MPA2 = ’10^0 x 2’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ2)
MPD1 = j
CALL MPMULD (MPJ2, MPD1, 0, MPJ3)
CALL MPINFR (MPJ3, MPJ3, MPM1)
CALL MPADD (MPJ1, MPJ3, MPJ2)
CALL MPINFR (MPJ2, MPJ2, MPM1)
CALL MPMUL (pi, MPJ2, MPM1)
CALL MPMUL (MPM1, xl, MPM2)
MPA2 = ’10^0 x 4.0’
READ (MPA2, ’( 10A1)’ ) (MPA1(MPI1), MPI1 = 1, 10)
CALL MPINPC (MPA1, 10, MPM1)
MPA2 = ’10^0 x 0’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
CALL MPADD (MPM1, MPJ1, MPM3)
CALL MPDIV (MPM2, MPM3, MPM1)
CALL MPCSSH (MPM1, MPL02, MPM3, MPM2)
CALL MPDIV (MPM2, s2, MPM1)
MPA2 = ’10^0 x 1’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
MPA2 = ’10^0 x 2’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ2)
MPD1 = j
CALL MPMULD (MPJ2, MPD1, 0, MPJ3)
CALL MPINFR (MPJ3, MPJ3, MPM2)
CALL MPADD (MPJ1, MPJ3, MPJ2)
CALL MPINFR (MPJ2, MPJ2, MPM2)
CALL MPMUL (pi, MPJ2, MPM2)
CALL MPMUL (MPM2, xl, MPM3)
MPA2 = ’10^0 x 4.0’
READ (MPA2, ’( 10A1)’ ) (MPA1(MPI1), MPI1 = 1, 10)
CALL MPINPC (MPA1, 10, MPM2)
MPA2 = ’10^0 x 0’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
CALL MPADD (MPM2, MPJ1, MPM4)
CALL MPDIV (MPM3, MPM4, MPM2)
CALL MPCSSH (MPM2, MPL02, MPM3, MPM4)
MPD1 = DREAL (ione)
MPD2 = DIMAG (ione)
CALL MPMULD (MPM3, MPD1, 0, MPZ1)
CALL MPMULD (MPM3, MPD2, 0, MPZ1(MPNWQ+5))
CALL MPMPCM (MPNW4, MPZ1, MPM2, MPM3)
CALL MPDIV (MPM2, s2, MPZ2)
CALL MPDIV (MPM3, s2, MPZ2(MPNWQ+5))
CALL MPDMC (0.D0, 0, MPM2)
CALL MPMMPC (MPM1, MPM2, MPNW4, MPZ3)
CALL MPCADD (MPNW4, MPZ3, MPZ2, MPZ1)
CALL MPCEQ (MPNW4, MPZ1, s)
CMP<
CMP> c=cosh(pi*(1+2*j)*xl/(4.0d0+0))/s2 +
CMP> $ ione*sinh(pi*(1+2*j)*xl/(4.0d0+0))/s2
MPA2 = ’10^0 x 1’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
MPA2 = ’10^0 x 2’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ2)
MPD1 = j
CALL MPMULD (MPJ2, MPD1, 0, MPJ3)
CALL MPINFR (MPJ3, MPJ3, MPM1)
CALL MPADD (MPJ1, MPJ3, MPJ2)
CALL MPINFR (MPJ2, MPJ2, MPM1)
CALL MPMUL (pi, MPJ2, MPM1)
CALL MPMUL (MPM1, xl, MPM2)
MPA2 = ’10^0 x 4.0’
READ (MPA2, ’( 10A1)’ ) (MPA1(MPI1), MPI1 = 1, 10)
CALL MPINPC (MPA1, 10, MPM1)
MPA2 = ’10^0 x 0’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
CALL MPADD (MPM1, MPJ1, MPM3)
CALL MPDIV (MPM2, MPM3, MPM1)
CALL MPCSSH (MPM1, MPL02, MPM2, MPM3)
CALL MPDIV (MPM2, s2, MPM1)
MPA2 = ’10^0 x 1’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
MPA2 = ’10^0 x 2’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ2)
MPD1 = j
CALL MPMULD (MPJ2, MPD1, 0, MPJ3)
CALL MPINFR (MPJ3, MPJ3, MPM2)
CALL MPADD (MPJ1, MPJ3, MPJ2)
CALL MPINFR (MPJ2, MPJ2, MPM2)
CALL MPMUL (pi, MPJ2, MPM2)
CALL MPMUL (MPM2, xl, MPM3)
MPA2 = ’10^0 x 4.0’
READ (MPA2, ’( 10A1)’ ) (MPA1(MPI1), MPI1 = 1, 10)
CALL MPINPC (MPA1, 10, MPM2)
MPA2 = ’10^0 x 0’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ1)
CALL MPADD (MPM2, MPJ1, MPM4)
CALL MPDIV (MPM3, MPM4, MPM2)
CALL MPCSSH (MPM2, MPL02, MPM4, MPM3)
MPD1 = DREAL (ione)
MPD2 = DIMAG (ione)
CALL MPMULD (MPM3, MPD1, 0, MPZ1)
CALL MPMULD (MPM3, MPD2, 0, MPZ1(MPNWQ+5))
CALL MPMPCM (MPNW4, MPZ1, MPM2, MPM3)
CALL MPDIV (MPM2, s2, MPZ2)
CALL MPDIV (MPM3, s2, MPZ2(MPNWQ+5))
CALL MPDMC (0.D0, 0, MPM2)
CALL MPMMPC (MPM1, MPM2, MPNW4, MPZ3)
CALL MPCADD (MPNW4, MPZ3, MPZ2, MPZ1)
CALL MPCEQ (MPNW4, MPZ1, c)
CMP<
CMP> ta=s/c
CALL MPCDIV (MPNW4, s, c, MPZ1)
CALL MPCEQ (MPNW4, MPZ1, ta)
CMP<
CMP> f=f+mone**j*(4.0d0+0)/pi*atan2(dpimag(ta),dpreal(ta))
MPD1 = mone
CALL MPDMC (MPD1, 0, MPJ2)
CALL MPNPWR (MPJ2, j, MPJ1)
CALL MPINFR (MPJ1, MPJ1, MPM1)
MPA2 = ’10^0 x 4.0’
READ (MPA2, ’( 10A1)’ ) (MPA1(MPI1), MPI1 = 1, 10)
CALL MPINPC (MPA1, 10, MPM1)
MPA2 = ’10^0 x 0’
READ (MPA2, ’( 8A1)’ ) (MPA1(MPI1), MPI1 = 1, 8)
CALL MPINPC (MPA1, 8, MPJ2)
CALL MPADD (MPM1, MPJ2, MPM2)
CALL MPMUL (MPJ1, MPM2, MPM1)
CALL MPDIV (MPM1, pi, MPM2)
CALL MPMPCM (MPNW4, ta, MPM3, MPM1)
CALL MPEQ (ta, MPM3)
CALL MPANG (MPM3, MPM1, MPPIC, MPM4)
CALL MPMUL (MPM2, MPM4, MPM1)
CALL MPADD (f, MPM1, MPM2)
CALL MPEQ (MPM2, f)
CMP<
CMP> write (6,*) f
CALL MPOUT (6, f, 7000, MPA1)
CMP<
enddo
end
function dpreal(c)
double complex c
dpreal = dble(c)
return
end
function dpimag(c)
double complex c
dpimag = dimag(c)
return
end
Note that the Fourier series of Bornemann et al. (2004) is much better. I’m not
perfect.
SC Toolbox solution
One can also try and solve this using the SC Toolbox. The naive approach leads
to failure:p= 1.000000000000001 and the very unhealthy Figure 52. A smarter
approach given in Bornemann et al. (2004) gives 3.837587979011753 ×10−7and11
digits.
% p174.m 100$100d problem using SC toolbox SGLS 05/26/08
p = polygon([0 10 10+i i])
phi = lapsolve(p,[0 1 0 1]);
phi(5+0.5*i)
[tri,x,y] = triangulate(p); trisurf(tri,x,y,phi(x+i*y));
p = polygon([10+i -10+i -10-i 10-i]);
f = center(crdiskmap(p,scmapopt(’Tolerance’,1e-11)),0);
prevert = get(diskmap(f),’prevertex’); angle(prevert(1))/pi
0246810
00.51−0.500.511.5Poor solution to Laplace’s equation for Problem 10 using SC Toolbox.
Elliptic function solution
Where do elliptic functions come from? There are three kinds of elliptic functions
really: elliptic integrals, Weierstrassian elliptic functions and Jacobi elliptic func-
tions. For the problem here, we get elliptic integrals through the the Schwartz–
Christoffel mapping from the unit disk in the z-plane to the rectangle with vertices
(a+ ib,−a+ ib,−a−ib,a−ib):
f(z) = 2c/integraldisplayz
0dζ/radicalbig
(1−e−ipπζ2)(1−eipπζ2). (480)
The unknown parameter cis real and the integral can be taken along any path from
0tozin the unit disk. From this one can deduce
a+ ib= 2ceipπ/2K(eipπ) (481)
whereK(k)denotes the complete elliptic integral of the first kind with modulus k:
K(k) =/integraldisplay1
0dt/radicalbig
(1−t2)(1−k2t2). (482)
One can take the argument of both sides of ( 481) and solve the following transcen-
dental equation for p:
cot−1p=pπ
2+ argK(eipπ). (483)
This is a simple equation to solve in Matlab because it is very easy to compute
K(k).
The arithmetic-geometric mean is an algorithm due to Gauss. It computes the
quantityM(a,b)as the limit as n→ ∞ of the iteration
a0=a, b 0=b, a n+1=an+bn
2, b n+1=/radicalbig
anbn. (484)
This iteration converges quadratically. The complete elliptic integral is then given
by
K(k) =π
2M(1,√
1−k2). (485)
Using various identities about elliptic functions, we can obtain the closed form so-
lution of §112. There are a lot of formulas and results about elliptic functions.
Elliptic functions and integrals
The simplest way to see where the elliptic integrals come from is to work out the
perimeter of an ellipse with semi-major and semi-minor axes aandbrespectively.
Parameterize the ellipse using x=acosθ,y =bsinθso that ds2= (a2sin2θ+
b2cos2θ)dθ2. Then
P=/integraldisplay
ds= 4/integraldisplayπ/2
0/radicalbig
a2sin2θ+b2cos2θdθ= 4a/integraldisplay1
0(1−t2)−1/2(1−mt2)1/2dt= 4aE(m),
(486)
wherem=b2/a2and we take m < 1in this derivation. This is in fact a complete
elliptic integral of the second kind. “Complete” refers to the upper limit. If we were
computing the perimeter up to some other angle, it would just be an elliptic integral
of the first kind. For m= 0 we haveE(0) =π/2and we recover trigonometric
functions for the incomplete kind. See AS and GR for more details.
Exercise 0.71 The oscillations of a pendulum are given by
¨θ+g
lsinθ= 0. (487)
The usual approach linearizes this equation by replacing sinθbyθ. Solve the
equation exactly. Start by integral once to give
1
2˙θ2+g
lcosθ=E. (488)
The Weierstrass and Jacobi elliptic functions can also be found in GR and AS. A
clear description can be found in Whittaker & Watson (1963). Elliptic function are
the canonical functions that are periodic with respect to two numbers (whose ratio
is not real), so that
f(z+ 2ω1) =f(z), f (z+ 2ω2) =f(z). (489)
There are two kinds of functions that satisfy such relations. First, those with one
double pole in each cell: these are Weierstrass functions. Second, those with two
simple poles in each cell: these are Jacobi functions. The latter can also be viewed
as inverse functions of elliptic integrals, in the same way that the trigonometric
functions can be viewed as inverse functions of integrals of the form (1−t2)−1/2.
There are also Theta functions that are related to both; see (again) Whittaker &
Watson (1963) or Bellman (1961).16
16An unusual book on elliptic functions is Eagle (1958), who comes up with a whole new notation. It’s
touching but a little sad to think of so much effort expended for nought. Granted, the standard notation is not
that transparent.
An amazing result
Bornemann et al. (2004) show that using results due to Ramanujan one can find p
in the closed form
p=2
πsin−1[(3−2√
2)2(2 +√
5)2(√
10−3)2(51/4−√
2)4] (490)
=2
πsin−1/bracketleftbigg1
(3 + 2√
2)2(2 +√
5)2(3 +√
10)2(√
2 + 51/4)4/bracketrightbigg
. (491)
The second formula is numerically stabler. This really is an exact closed form
result.
References
Publications:
•Bellman, R. E. A brief introduction to theta functions , Rinehart and Winston,
New Y ork, 1961.
•Eagle, A. The elliptic functions as they should be , Galloway & Porter, Cam-
bridge, 1958.
•Morse P . M. & Feshbach, H. Methods of theoretical physics , Mc-Graw-Hill, New
Y ork, 1953.
•Whittaker, E. T. & Watson, G. N. A course of modern analysis , 4th ed, Cam-
bridge University Press, Cambridge, 1963.
Web sites:
•http://crd.lbl.gov/˜dhbailey/mpdist/
•http://www.math.udel.edu/˜driscoll/software/SC/
Special functions (06/04/08) [15 min. short]
Introduction
The very name “special function” is a little perplexing. Why should these functions
be any more special than polynomials, exponentials or trigonometric functions be-
yond our being used to these latter “elementary functions”? People are wont to say
that Bessel functions are just like sines and cosines in radial geometry, with a little
bit of extra decay to make it all work, but this explanation seems unsatisfactory,
frankly.
One sometimes sees the name “higher transcendental functions” in older books
(e.g. Whittaker & Watson 1963). Higher seems OK, but transcendental17seems
strange, since trigonometric and exponential functions are critically concerned with
transcendental numbers. Remember that the proofs that eandπwere not algebraic
numbers, were milestones of classical analysis.
So what is a special function? It’s not clear there is a universal definition. A tenta-
tive definition would be a function that requires the tools of analysis to define and
or describe it, and that has entered the lexicon and toolbox of working mathemati-
cians, physicists and engineers. I’m not sure this is a perfect definition and it would
be interesting to come up with a better one.
17Not algebraic, i.e. not the solution of a polynomial equations with integer coefficients.
Whittaker & Watson (1963) is a two-part book. The first half is a very detailed
introduction to real analysis, still useful today. The second half discusses transcen-
dental functions using the tools derived. So the transcendental functions are at the
same time motivation and application.
There are many excellent books on special functions. AS and GR have of course
been mentioned before as have the comprehensive books of Olver (1974), Whit-
taker & Watson (1963) and the focused books of Bellman (1961) and Artin (1964).
Other books include the Bateman Manuscript Project (1953–1955), Magnus, Ober-
hettinger & Soni (1966; the German connection), Luke (1969), Lebedev (1972),
Sneddon (1980), Temme (1996), Andrews et al. (1999) and Mathai & Haubold
(2008). There is also a journal, Integral transforms and special functions .
Good websites have also been cited previously. Note that Stephen Wolfram of
Mathematica fame is a special-functions enthusiast in his own words (see http://www.stephenwolfram.com/publications/talks/specialfunctions/ ).
However, the book on special functions that outshines all others is not even about
all special functions. It’s just about Bessel functions, but it is extraordinary and even
today one would be hard pressed to see how to improve on its scholarship. This
book is of course Watson (1944).
A brief comment on Batterman (2007) is in order. The title of this paper, published
in the British Journal for the Philosophy of Science is “On the Specialness of Spe-
cial Functions (The Nonrandom Effusions of the Divine Mathematician). The paper
discusses what, in the author’s opinion, makes special functions special.
One can argue that special functions only make sense in the context of a clear
understanding and synthesis of the singularity structure and definitions by ODEs
or sum of these functions. This makes them a late 19th century construct. In fact,
complex analysis is crucial since power series are intimately tied to the complex
plane. Many of the formulas can only be obtained using complex analysis. An in-
teresting exception is Artin (1964), which uses only real analysis. In consequence,
much use is made of functional equations and difference equations. It’s beauti-
fully done, and it works for the Gamma function, but it probably wouldn’t work for
anything else.
The history of special functions in the 20th century follows two strands. On the one
hand, a proliferation of specialized special functions in particular fields (e.g. the
Theodorson function in aerodynamics). On the other hand, efforts at greater gen-
eralizations, leading to Meier’s G-function and Heun’s equation. This brings back
the psychological aspect of the subject: the hypergeometric function due to Gauss,
with three singularities in the complex plane, seems to be about as much as most
people are prepared to consider. More general functions just seem too vague and
lack character.
Classification of special functions
There is on single classification. That of AS given in Figures 123–123 is useful
and certainly shapes my thinking of special functions, although I would put Gamma
functions before exponential integrals. Y ou can find AS online at http://www.math.sfu.ca/~cbm/aands/ ;
I’m not sure about the copyright issues.
This list is interesting. Gamma and error functions are universal: they pop up all
over mathematics. The exponential integral is fairly straightforward and turns up oc-
casionally, but doesn’t seem to have a deep meaning. Lengendre, Bessel (Struve
is an offshoot), Mathieu and Spheroidal wave functions come from separating vari-
ables in Laplace’s equation and Helmholtz’s equation. Hpergeometric functions
are a natural framework for many functions. Coulomb wave functions come from
quantum mechanics. Elliptic functions occur naturally in complex analysis and in
integrating ODEs. Parabolic cylinder functions come up in asymptotics and WKB.
Orthogonal polynomials appear naturally in Sturm–Liouville theory and have bee
applied all over mathematical physics and numerical analysis.
The heart of the subject is really the special functions of mathematical physics, and
the other functions that crop up in their asymptotic description (Gamma, parabolic
cylinder functions).
5/28/08 11:08 PMM. Abramowitz and I. A. Stegun. Handbook of mathematical functions
Page 5 of 9file:///Users/stefan/tai/Documents/abramowitz_and_stegun/intro.htm#006N. C. METROPOLISJ. B. ROSSERH. C. THACHER, Jr.JOHN TODDC. B. TOMPKINSJ. W. TUKEY.VIContentsPreface ..... IIIForeword ..... VIntroduction ..... IX1. Mathematical Constants ..... 1DAVID S. LIEPMAN2. Physical Constants and Conversion Factors ..... 5A. G. McNISH3. Elementary Analytical Methods ..... 9MILTON ABRAMOWITZ4. Elementary Transcendental Functions ..... 65Logarithmic, Exponential, Circular and Hyperbolic FunctionsRUTH ZUCKER5. Exponential Integral and Related Functions ..... 227WALTER GAUTSCHI and WILLIAM F. CAHILL6. Gamma Function and Related Functions ..... 253PHILIP J. DAVIS7. Error Function and Fresnel Integrals ..... 295WALTER GAUTSCHI8. Legendre Functions ..... 331IRENE A. STEGUN9. Bessel Functions of Integer Order ..... 355F. W. J. OLVER10. Bessel Functions of Fractional Order ..... 435H. A. ANTOSIEWICZ
5/28/08 11:08 PMM. Abramowitz and I. A. Stegun. Handbook of mathematical functions
Page 6 of 9file:///Users/stefan/tai/Documents/abramowitz_and_stegun/intro.htm#00611. Integrals of Bessel Functions ..... 479YUDELL L. LUKE12. Struve Functions and Eelated Functions ..... 495MILTON ABRAMOWITZ13. Confluent Hypergeometric Functions ..... 503LUCY JOAN SLATER14. Coulomb Wave Functions ..... 537MILTON ABRAMOWITZ15. Hypergeometric Functions ..... 555FRITZ OBERHETTINGER16. Jacobian Elliptic Functions and Theta Functions ..... 567L. M. MILNE-THOMSON17. Elliptic Integrals ..... 587L. M. MILNE-THOMSON18. Weierstrass Elliptic and Related Functions ..... 627THOMAS H. SOUTHARD19. Parabolic Cylinder Functions ..... 685J. C. P. MILLERVII20. Mathieu Functions ..... 721GERTRUDE BLANCH21. Spheroidal Wave Functions ..... 751ARNOLD N. LOWAN22. Orthogonal Polynomials ..... 771URS W. HOCHSTRASSER23. Bernoulli and Euler Polynomials, Riemann Zeta Function ..... 803EMILIE V. HAYNSWORTH and KARL GOLDBERG24. Combinatorial Analysis ..... 821K. GOLDBERG, M. NEWMAN and E. HAYNSWORTH25. Numerical Interpolation, Differentiation and Integration ..... 875PHILIP J. DAVIS and IVAN POLONSKY26. Probability Functions ..... 925MARVIN ZELEN and NORMAN C. SEVERO
5/28/08 11:08 PMM. Abramowitz and I. A. Stegun. Handbook of mathematical functions
Page 7 of 9file:///Users/stefan/tai/Documents/abramowitz_and_stegun/intro.htm#00627. Miscellaneous Functions ..... 997IRENE A. STEGUN28. Scales of Notation ..... 1011S. PEAVY and A. SCHOPF29. Laplace Transforms ..... 1019Subject Index ..... 1031Index of Notations ..... 1044VIIIHandbook of Mathematical FunctionswithFormulas, Graphs, and Mathematical TablesEdited by Milton Abramowitz and Irene A. Stegun1. IntroductionThe present Handbook has been designed to provide scientific investigators with acomprehensive and self-contained summary of the mathematical functions that arise in physicaland engineering problems. The well-known Tables of Functions by E. Jahnke and F. Emde hasbeen invaluable to workers in these fields in its many editions1 during the past half-century. Thepresent volume extends the work of these authors by giving more extensive and more accuratenumerical tables, and by giving larger collections of mathematical properties of the tabulatedfunctions. The number of functions covered has also been increased.The classification of functions and organization of the chapters in this Handbook is similar tothat of An Index of Mathematical Tables by A. Fletcher, J. C. P. Miller, and L. Rosenhead.2 Ingeneral, the chapters contain numerical tables, graphs, polynomial or rational approximationsfor automatic computers, and statements of the principal mathematical properties of thetabulated functions, particularly those of computational importance. Many numerical examplesare given to illustrate the use of the tables and also the computation of function values which lieoutside their range. At the end of the text in each chapter there is a short bibliography givingbooks and papers in which proofs of the mathematical properties stated in the chapter may befound. Also listed in the bibliographies are the more important numerical tables. Comprehensivelists of tables are given in the Index mentioned above, and current information on new tables isto be found in the National Research Council quarterly Mathematics of Computation (formerlyMathematical Tables and Other Aids to Computation).The mathematical notations used in this Handbook are those commonly adopted in standardtexts, particularly Higher Transcendental Functions, Volumes 1-3, by A. Erdélyi, W. Magnus,F. Oberhettinger and F. G. Tricomi (McGraw-Hill, 1953-55). Some alternative notations havealso been listed. The introduction of new symbols has been kept to a minimum, and an efforthas been made to avoid the use of conflicting notation.
Computation of special functions
There are naturally books specifically about computing special functions. Exam-
ples are Thompson (1997), Zhang & Jin (1996) and Gil, Segura & Temme (2007).
I mean to read them soon.
There are many different ways of getting values for special functions. We won’t go
through all of them.
Rational approximation
Many complicated functions can be represented very accurately over a certain
range using a rational approximation. Many chapters in AS include appropriate
approximations over a number of ranges. Note that this method is also extremely
useful for calculating elementary functions (see e.g. Muller 1997). The Wolfram
lecture mentioned above indicates that this method is used extensively in Mathe-
matica, with the hard work being done in advance to establish the approximations.
Summing a series
Many special functions can be defined in terms of an infinite series that converges
in a certain portion of the complex plane. The hypergeometric series is a typical
example. A natural approach is then to sum this series. This requires some care,
because convergent series can exhibit extreme cancellation between early terms
before settling down and converging. An implementation is shown in genHyper.m
in the Appendix. This is a straight translation to Matlab of a Fortran algorithm due
to Nardin & Bhalla.
Solving an ODE
Many special functions satisfy a known ODE. Solving that ODE accurately gives
the result. The functions cerfa.m andcerfb.m from Weideman & Reddy (2000)
solve the ODE defining the error function using a pseudospectral method.
function y = cerfa(t,N)
% The function y = cerfa(t,N) computes y(t) = exp(t^2) erfc(t)
% for t > 0 using an NxN Chebyshev differentiation matrix.
% The boundary condition is y = 0 at t = infty.
% The input parameter may be a scalar or vector.
% J.A.C. Weideman, S.C. Reddy 1998
c = 3.75; % Initialize parameter
[x, D] = chebdif(N+1,1); % Compute Chebyshev points,
D = D(2:N+1,2:N+1); % assemble differentiation matrix,
x = x(2:N+1); % and incorporate boundary condition
A = diag((1-x).^3)*D-diag(4*c^2*(1+x)); % Coefficient matrix
b = 4*c/sqrt(pi)*(x-1); % Right-hand side
y = A\b; % Solve system
y = chebint([0; y], (t-c)./(t+c)); % Interpolate
function y = cerfb(t,N)
% The function y = cerfb(t,N) computes y(t) = exp(t^2) erfc(t)
% for t > 0 using an NxN Chebyshev differentiation matrix.
% The boundary condition is y = 1 at t = 0.
% The input parameter may be a scalar or vector.
% J.A.C. Weideman, S.C. Reddy 1998
c = 3.75; % Initialize parameter
[x, D] = chebdif(N+1,1); % Compute Chebyshev points,
A = diag((1-x).^3)*D-diag(4*c^2*(1+x)); % Coefficient matrix
b = 4*c/sqrt(pi)*(x-1); % Right-hand side
a1 = A(1:N,N+1); b = b(1:N);
A = A(1:N,1:N);
y = A\(b-a1); % Solve system
y = chebint([y; 1], (t-c)./(t+c)); % Interpolate
NR describes a related technique. Integrate the ODE to where one wants the result
z, from some starting point z0in the complex plane. Sometimes one knows f(z0)
and we’re done. Otherwise, pick z0to be within the radius of convergence of a
power series expansion for fand sum the series to find f(z0).
Recurrence relations
This tends to apply to functions such as orthogonal polynomials that satisfy a rela-
tion, so that knowing pn−1andpn, we can compute pn+1. These are usually easy to
program, but one has to be careful with numerical stability when solving recursion
relations.
This approach is also useful for functions like Bessel functions, where there are re-
currence relations connecting functions of different orders. One still has to compute
J0andJ1to start the recurrence, however,
Matlab
Matlab has a certain number of built-in special functions.
>> help specfun
Specialized math functions.
Specialized math functions.
airy - Airy functions.
besselj - Bessel function of the first kind.
bessely - Bessel function of the second kind.
besselh - Bessel functions of the third kind (Hankel function).
besseli - Modified Bessel function of the first kind.
besselk - Modified Bessel function of the second kind.
beta - Beta function.
betainc - Incomplete beta function.
betaln - Logarithm of beta function.
ellipj - Jacobi elliptic functions.
ellipke - Complete elliptic integral.
erf - Error function.
erfc - Complementary error function.
erfcx - Scaled complementary error function.
erfinv - Inverse error function.
expint - Exponential integral function.
gamma - Gamma function.
gammainc - Incomplete gamma function.
gammaln - Logarithm of gamma function.
psi - Psi (polygamma) function.
legendre - Associated Legendre function.
and other irrelevant functions. These other functions are not really irrelevant, but
they are discrete number theoretic functions and coordinate transformations, which
are not good applications of complex analysis.
Watch out. Some of the implementations of these functions are only defined for
real arguments. They are of course also limited to double precision.
The driver program for evaluating error functions, evacuee.m , is a typical exam-
ple. Depending on the value of x, different rational approximations are used. The
argumentxhas to be real.
function result = erfcore(x,jint)
%ERFCORE Core algorithm for error functions.
% erf(x) = erfcore(x,0)
% erfc(x) = erfcore(x,1)
% erfcx(x) = exp(x^2)*erfc(x) = erfcore(x,2)
% C. Moler, 2-1-91.
% Copyright 1984-2005 The MathWorks, Inc.
% $Revision: 5.15.4.4 $ $Date: 2006/12/15 19:28:21 $
% This is a translation of a FORTRAN program by W. J. Cody,
% Argonne National Laboratory, NETLIB/SPECFUN, March 19, 1990.
% The main computation evaluates near-minimax approximations
% from "Rational Chebyshev approximations for the error function"
% by W. J. Cody, Math. Comp., 1969, PP. 631-638.
% Note: This M-file is intended to document the algorithm.
% If a MEX file for a particular architecture exists,
% it will be executed instead, but its functionality is the same.
%#mex
%{
if ~isreal(x),
error(’MATLAB:erfcore:ComplexInput’, ’Input argument must be real.’)
end
result = repmat(NaN,size(x));
%
% evaluate erf for |x| <= 0.46875
%
xbreak = 0.46875;
k = find(abs(x) <= xbreak);
if ~isempty(k)
a = [3.16112374387056560e00; 1.13864154151050156e02;
3.77485237685302021e02; 3.20937758913846947e03;
1.85777706184603153e-1];
b = [2.36012909523441209e01; 2.44024637934444173e02;
1.28261652607737228e03; 2.84423683343917062e03];
y = abs(x(k));
z = y .* y;
xnum = a(5)*z;
xden = z;
for i = 1:3
xnum = (xnum + a(i)) .* z;
xden = (xden + b(i)) .* z;
end
result(k) = x(k) .* (xnum + a(4)) ./ (xden + b(4));
if jint ~= 0, result(k) = 1 - result(k); end
if jint == 2, result(k) = exp(z) .* result(k); end
end
%
% evaluate erfc for 0.46875 <= |x| <= 4.0
%
k = find((abs(x) > xbreak) & (abs(x) <= 4.));
if ~isempty(k)
c = [5.64188496988670089e-1; 8.88314979438837594e00;
6.61191906371416295e01; 2.98635138197400131e02;
8.81952221241769090e02; 1.71204761263407058e03;
2.05107837782607147e03; 1.23033935479799725e03;
2.15311535474403846e-8];
d = [1.57449261107098347e01; 1.17693950891312499e02;
5.37181101862009858e02; 1.62138957456669019e03;
3.29079923573345963e03; 4.36261909014324716e03;
3.43936767414372164e03; 1.23033935480374942e03];
y = abs(x(k));
xnum = c(9)*y;
xden = y;
for i = 1:7
xnum = (xnum + c(i)) .* y;
xden = (xden + d(i)) .* y;
end
result(k) = (xnum + c(8)) ./ (xden + d(8));
if jint ~= 2
z = fix(y*16)/16;
del = (y-z).*(y+z);
result(k) = exp(-z.*z) .* exp(-del) .* result(k);
end
end
%
% evaluate erfc for |x| > 4.0
%
k = find(abs(x) > 4.0);
if ~isempty(k)
p = [3.05326634961232344e-1; 3.60344899949804439e-1;
1.25781726111229246e-1; 1.60837851487422766e-2;
6.58749161529837803e-4; 1.63153871373020978e-2];
q = [2.56852019228982242e00; 1.87295284992346047e00;
5.27905102951428412e-1; 6.05183413124413191e-2;
2.33520497626869185e-3];
y = abs(x(k));
z = 1 ./ (y .* y);
xnum = p(6).*z;
xden = z;
for i = 1:4
xnum = (xnum + p(i)) .* z;
xden = (xden + q(i)) .* z;
end
result(k) = z .* (xnum + p(5)) ./ (xden + q(5));
result(k) = (1/sqrt(pi) - result(k)) ./ y;
if jint ~= 2
z = fix(y*16)/16;
del = (y-z).*(y+z);
result(k) = exp(-z.*z) .* exp(-del) .* result(k);
k = find(~isfinite(result));
result(k) = 0*k;
end
end
%
% fix up for negative argument, erf, etc.
%
if jint == 0
k = find(x > xbreak);
result(k) = (0.5 - result(k)) + 0.5;
k = find(x < -xbreak);
result(k) = (-0.5 + result(k)) - 0.5;
elseif jint == 1
k = find(x < -xbreak);
result(k) = 2. - result(k);
else % jint must = 2
k = find(x < -xbreak);
z = fix(x(k)*16)/16;
del = (x(k)-z).*(x(k)+z);
y = exp(z.*z) .* exp(del);
result(k) = (y+y) - result(k);
end
%}
Matlab translations of the Zhang & Jin (1996) algorithms due to Barrowes may be
found at the Mathworks web site. Some of the comments imply there are bugs.
Matlab can also access some of Maple’s special functions.
>> mfunlist
MFUNLIST Special functions for MFUN.
The following special functions are listed in alphabetical order
according to the third column. n denotes an integer argument,
x denotes a real argument, and z denotes a complex argument. For
more detailed descriptions of the functions, including any
argument restrictions, see the Reference Manual, or use MHELP.
bernoulli n Bernoulli Numbers
bernoulli n,z Bernoulli Polynomials
BesselI x1,x Bessel Function of the First Kind
BesselJ x1,x Bessel Function of the First Kind
BesselK x1,x Bessel Function of the Second Kind
BesselY x1,x Bessel Function of the Second Kind
Beta z1,z2 Beta Function
binomial x1,x2 Binomial Coefficients
EllipticF - z,k Incomplete Elliptic Integral, First Kind
EllipticK - k Complete Elliptic Integral, First Kind
EllipticCK - k Complementary Complete Integral, First Kind
EllipticE - k Complete Elliptic Integrals, Second Kind
EllipticE - z,k Incomplete Elliptic Integrals, Second Kind
EllipticCE - k Complementary Complete Elliptic Integral, Second Kind
EllipticPi - nu,k Complete Elliptic Integrals, Third Kind
EllipticPi - z,nu,k Incomplete Elliptic Integrals, Third Kind
EllipticCPi - nu,k Complementary Complete Elliptic Integral, Third Kind
erfc z Complementary Error Function
erfc n,z Complementary Error Function’s Iterated Integrals
Ci z Cosine Integral
dawson x Dawson’s Integral
Psi z Digamma Function
dilog x Dilogarithm Integral
erf z Error Function
euler n Euler Numbers
euler n,z Euler Polynomials
Ei x Exponential Integral
Ei n,z Exponential Integral
FresnelC x Fresnel Cosine Integral
FresnelS x Fresnel Sine Integral
GAMMA z Gamma Function
harmonic n Harmonic Function
Chi z Hyperbolic Cosine Integral
Shi z Hyperbolic Sine Integral
GAMMA z1,z2 Incomplete Gamma Function
W z Lambert’s W Function
W n,z Lambert’s W Function
lnGAMMA z Logarithm of the Gamma function
Li x Logarithmic Integral
Psi n,z Polygamma Function
Ssi z Shifted Sine Integral
Si z Sine Integral
Zeta z (Riemann) Zeta Function
Zeta n,z (Riemann) Zeta Function
Zeta n,z,x (Riemann) Zeta Function
Orthogonal Polynomials (Extended Symbolic Math Toolbox only)
T n,x Chebyshev of the First Kind
U n,x Chebyshev of the Second Kind
G n,x1,x Gegenbauer
H n,x Hermite
P n,x1,x2,x Jacobi
L n,x Laguerre
L n,x1,x Generalized Laguerre
P n,x Legendre
See also MFUN, MHELP.
Maple
I’ve never checked if all of Maple’s special functions are available in Matlab. Of
course in Maple they are available with arbitrary precision.
Mathematica
If we are to believe Stephen Wolfram, Mathematica does a good job with special
functions. I still don’t like Mathematica and I don’t use it.18See also the Wolfram
Functions Site http://functions.wolfram.com/ .
Fortran libraries
I mentioned a number of these in the Introduction. Installing them can sometimes
be a pain, but most are high quality. SLATEC is probably the most useful. The
GAMS interface is also useful in linking to ACM algorithms which are not part of
libraries.
A typical routine is shown in derf.f for the error function. Once again a rational
approximation is used.
*DECK DERF
DOUBLE PRECISION FUNCTION DERF (X)
C***BEGIN PROLOGUE DERF
C***PURPOSE Compute the error function.
18I don’t think the following story is libellous. A colleague once taught a class on numerical methods and
used Mathematica to implement algorithms. He wanted to compare what he was teaching to the inbuilt routines
in Mathematica and contacted the company to ask them for information about these routines, but they wouldn’t
give him any. I view this as unhelpful.
C***LIBRARY SLATEC (FNLIB)
C***CATEGORY C8A, L5A1E
C***TYPE DOUBLE PRECISION (ERF-S, DERF-D)
C***KEYWORDS ERF, ERROR FUNCTION, FNLIB, SPECIAL FUNCTIONS
C***AUTHOR Fullerton, W., (LANL)
C***DESCRIPTION
C
C DERF(X) calculates the double precision error function for double
C precision argument X.
C
C Series for ERF on the interval 0. to 1.00000E+00
C with weighted error 1.28E-32
C log weighted error 31.89
C significant figures required 31.05
C decimal places required 32.55
C
C***REFERENCES (NONE)
C***ROUTINES CALLED D1MACH, DCSEVL, DERFC, INITDS
C***REVISION HISTORY (YYMMDD)
C 770701 DATE WRITTEN
C 890531 Changed all specific intrinsics to generic. (WRB)
C 890531 REVISION DATE from Version 3.2
C 891214 Prologue converted to Version 4.0 format. (BAB)
C 900727 Added EXTERNAL statement. (WRB)
C 920618 Removed space from variable name. (RWC, WRB)
C***END PROLOGUE DERF
DOUBLE PRECISION X, ERFCS(21), SQEPS, SQRTPI, XBIG, Y, D1MACH,
1 DCSEVL, DERFC
LOGICAL FIRST
EXTERNAL DERFC
SAVE ERFCS, SQRTPI, NTERF, XBIG, SQEPS, FIRST
DATA ERFCS( 1) / -.4904612123 4691808039 9845440333 76 D-1 /
DATA ERFCS( 2) / -.1422612051 0371364237 8247418996 31 D+0 /
DATA ERFCS( 3) / +.1003558218 7599795575 7546767129 33 D-1 /
DATA ERFCS( 4) / -.5768764699 7674847650 8270255091 67 D-3 /
DATA ERFCS( 5) / +.2741993125 2196061034 4221607914 71 D-4 /
DATA ERFCS( 6) / -.1104317550 7344507604 1353812959 05 D-5 /
DATA ERFCS( 7) / +.3848875542 0345036949 9613114981 74 D-7 /
DATA ERFCS( 8) / -.1180858253 3875466969 6317518015 81 D-8 /
DATA ERFCS( 9) / +.3233421582 6050909646 4029309533 54 D-10 /
DATA ERFCS( 10) / -.7991015947 0045487581 6073747085 95 D-12 /
DATA ERFCS( 11) / +.1799072511 3961455611 9672454866 34 D-13 /
DATA ERFCS( 12) / -.3718635487 8186926382 3168282094 93 D-15 /
DATA ERFCS( 13) / +.7103599003 7142529711 6899083946 66 D-17 /
DATA ERFCS( 14) / -.1261245511 9155225832 4954248533 33 D-18 /
DATA ERFCS( 15) / +.2091640694 1769294369 1705002666 66 D-20 /
DATA ERFCS( 16) / -.3253973102 9314072982 3641600000 00 D-22 /
DATA ERFCS( 17) / +.4766867209 7976748332 3733333333 33 D-24 /
DATA ERFCS( 18) / -.6598012078 2851343155 1999999999 99 D-26 /
DATA ERFCS( 19) / +.8655011469 9637626197 3333333333 33 D-28 /
DATA ERFCS( 20) / -.1078892517 7498064213 3333333333 33 D-29 /
DATA ERFCS( 21) / +.1281188399 3017002666 6666666666 66 D-31 /
DATA SQRTPI / 1.772453850 9055160272 9816748334 115D0 /
DATA FIRST /.TRUE./
C***FIRST EXECUTABLE STATEMENT DERF
IF (FIRST) THEN
NTERF = INITDS (ERFCS, 21, 0.1*REAL(D1MACH(3)))
XBIG = SQRT(-LOG(SQRTPI*D1MACH(3)))
SQEPS = SQRT(2.0D0*D1MACH(3))
ENDIF
FIRST = .FALSE.
C
Y = ABS(X)
IF (Y.GT.1.D0) GO TO 20
C
C ERF(X) = 1.0 - ERFC(X) FOR -1.0 .LE. X .LE. 1.0
C
IF (Y.LE.SQEPS) DERF = 2.0D0*X*X/SQRTPI
IF (Y.GT.SQEPS) DERF = X*(1.0D0 + DCSEVL (2.D0*X*X-1.D0,
1 ERFCS, NTERF))
RETURN
C
C ERF(X) = 1.0 - ERFC(X) FOR ABS(X) .GT. 1.0
C
20 IF (Y.LE.XBIG) DERF = SIGN (1.0D0-DERFC(Y), X)
IF (Y.GT.XBIG) DERF = SIGN (1.0D0, X)
C
RETURN
END
The CERNLIB notoriously had the only routine to compute modified Bessel func-
tions of imaginary order. Now it’s freely avaiable, and there are other packages, so
it isn’t so bad. Another database is http://www.cpc.cs.qub.ac.uk/ .
Multiple precision
Maple has already been mentioned. Arprec contains the following functions: I0(t),
Γ(z), erf, erfc, and multiple zeta functions. Carefully written basic algorithms can
of course be written in multiple precision.
Example: error function
Figure 53shows the difference between the error function computed to 1000 digits
in Maple and a variety of other methods. No curve corresponds to zero difference
to machine precision. The ODE method cerfa.m is not great; the rest are fine to
machine accuracy. Note that the Fortran implementation is not totally efficient: the
numerical part is fast, but it’s been implemented as a scalar function in Matlab. It
could be vectorized easily.
% p181.m Special function example SGLS 05/29/08
x = logspace(-2,2,81);
tic; e(1,:) = erf(x); t(1) = toc;
tic; e(2,:) = cerfa(x,10)’; e(2,:) = 1 - exp(-x.^2).*e(2,:); t(2) = toc;
tic; e(3,:) = cerfa(x,100)’; e(3,:) = 1 - exp(-x.^2).*e(3,:); t(3) = toc;
tic; for j = 1:length(x); e(4,j) = serf(x(j)); end; t(4) = toc;
maple restart; tic; e(5,:) = mfun(’erf’,x); t(5) = toc;
maple restart; maple(’Digits:=1000’); tic; e(6,:) = mfun(’erf’,x); t(6) = toc;
t
loglog(x,abs(e-ones(6,1)*e(6,:)))
xlabel(’x’); ylabel(’erf(x)’);
legend(’Matlab’,’cerfa, N= 10’,’cerfa, N = 100’,’SLATEC’,’Default Maple’)
C serf.f error function using Fortran SGLS 05/29/08
C mex -O -v -fortran -lslatec serf.f
C
C The gateway routine.
subroutine mexFunction(nlhs, plhs, nrhs, prhs)
C--------------------------------------------------------------
integer plhs(*), prhs(*)
integer mxGetPr, mxCreateDoubleMatrix
C--------------------------------------------------------------
real*8 x, e
C Check for proper number of arguments.
if (nrhs .ne. 1) then
call mexErrMsgTxt(’One input required.’)
elseif (nlhs .ne. 1) then
call mexErrMsgTxt(’One output required.’)
endif
10−210−110010110−1810−1610−1410−1210−1010−810−6
xerf(x)
Matlab
cerfa, N= 10
cerfa, N = 100
SLATEC
Default MapleAccuracy of error function calculations.
call mxCopyPtrToReal8(mxGetPr(prhs(1)),x,1)
e = derf(x)
plhs(1) = mxCreateDoubleMatrix(1,1,1)
call mxCopyReal8ToPtr(e,mxGetPr(plhs(1)),1)
end
A few other special functions
Special functions not in AS include polylogarithms, Lambert’s W-function (a com-
plete misnomer and really a Maple invention – see Hayes 2005), Meijer G-functions,
generalized hypergeometric functions (Slater 1966), Painlev ´e transcendents, a num-
ber of number-theoretical functions (Dirichlet), and no doubt many others.
Other functions that I would not really classify as special functions are the Ack-
ermann function (computer science) and various pathological counter-examples
(Weierstrass functions).
References
Publications:
•Andrews, G. E., Askey, R. & Roy, R. Special functions , Cambridge University
Press, Cambridge, 1999.
•Artin, E. The gamma function. Holt, Rhinehart and Winston, New Y ork, 1964.
•Bateman Manuscript Project. Higher transcendental functions , McGraw-Hill,
New Y ork, 1953–1955.
•Batterman, R. W. On the specialness of special functions (The nonrandom ef-
fusions of the divine mathematician). Brit. J. Phil. Sci. ,58, 263–286, 2007.
•Bellman, R. E. A brief introduction to theta functions , Rinehart and Winston,
New Y ork, 1961.
•Gil, A., Segura, J. & Temme, N. M. Numerical methods for special functions ,
SIAM, Philadelphia, 2007.
•Hayes, B. Why W?, Amer. Scientist ,93, 104–108, 2005.
•Lebedev, N. N. Special functions and their applications , Dover, New Y ork, 1972.
•Luke, Y . l. The special functions and their approximations , Academic, New Y ork,
1969.
•Mathai, A. Special functions for applied scientists , Springer, Berlin, 2008.
•Magnus, W., Oberhettinger, F . & Soni, R. P . Formulas and theorems for the
special functions of mathematical physics , 3rd ed., Springer, Berlin, 1966.
•Muller, J.-M. Elementary functions: algorithms and implementations , Birkh ¨auser,
Boston, 1997.
•Slater, L. J. Generalized hypergeometric functions , Cambridge University Press,
Cambridge, 1966.
•Sneddon, I. N. Special functions of mathematical physics and chemistry , Long-
man, London, 1980.
•Thompson, W. J. Atlas for computing mathematical functions: an illustrated
guide for practitioners with programs in Fortran 90 and Mathematics , Wiley,
New Y ork, 1997.
•Timme, N. M. Special functions: an introduction to the classical functions of
mathematical physics , Wiley, New Y ork, 1996.
•Watson, G. N. A treatise on the theory of Bessel functions , 2nd ed,. Cambridge
University Press, Cambridge, 1944.
•Whittaker, E. T. & Watson, G. N. A course of modern analysis , 4th ed, Cam-
bridge University Press, Cambridge, 1963.
•Zhang, S. & Jin, J. M. Computation of Special Functions , Wiley, New Y ork,
1996.
Web sites:
•http://www.cpc.cs.qub.ac.uk/
•http://en.wikipedia.org/wiki/Special functions
•http://functions.wolfram.com/
•http://jin.ece.uiuc.edu/specfun.html
•http://www.informaworld.com/smpp/title˜content=t71364368
•http://www.math.ku.dk/kurser/2006-08/blok2/klasan
•http://www.math.sfu.ca/˜cbm/aands/
•http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectid=6218
•http://www.stephenwolfram.com/publications/talks/specialfunctions/
Orthogonal polynomials (06/03/08) [10 min. short]
Introduction
Orthogonal polynomials span a wide range of applications, from the proof of the
Bieberbach conjecture through Sturm–Liouville theory to numerical analysis. We
will cover a few of these aspects. There has been a lot of recent work on orthogonal
polynomials from a pure mathematical perspective, and some of this is covered in
Andrews et al. (1999).
Three-term recurrence relations
Definition 0.4 A sequence of orthogonal polynomials {pn(x)}, wherepn(x)has
degreen, is orthogonal with respect to the weight function w(x)if
/integraldisplayb
apn(x)pn(x)w(x) dx=hnδmn. (492)
One can be more general and talk about orthogonality with respect to a distribution
dW(x). This definition implies the following
Theorem 10 A sequence of orthogonal polynomials satisfies
pn+1(x) = (Anx+Bn)pn(x)−Cnpn−1(x) = 0 (493)
forn≥0and we set p−1(x) = 0 . The real constants An,BnandCnsatisfy
An−1AnCn>0.
Favard’s theorem is the converse of this theorem: if the {pn(x)}satisfy a three-term
recurrence relation, then they are orthogonal with respect to some weight function.
From our experience with Fourier series, which satisfy a simple orthogonality con-
dition, we see that orthogonal polynomials may be useful in expanding functions
and calculating series such that the approximation is always improved by adding
more terms. In fact, we can obtain one family of orthogonal polynomials exactly
by a simple change of variable. Define the polynomials Tn(x) = cos {ncos−1(x)}.
Note thatT0(x) = 1 ,T1(x) =x,T2(x) = 2x2−1trivially. Then
/integraldisplay1
−1Tn(x)Tm(x)dz√
1−x2=/integraldisplayπ
0cosnθcosmθdθ=π/epsilon1−1
nδnm, (494)
where/epsilon1nis the Neumann symbol defined in Chapter 53. Hence these polynomials
are orthogonal with respect to the weight function (1−x2)−1/2. These are the
Chebyshev polynomials of the first kind.
One can go down the infinite-dimensional vector space road as far as one wishes,
but we shan’t bother, since we don’t learn anything new. It is not obvious19how to
go from the orthogonality condition to the recurrence relation with no extra informa-
tion. Finding the ODE satisfied by the polynomials makes this fairly clear, but one
then has to find the ODE. Luckily, AS has a list. It also contains explicit expres-
sions for the coefficients. Usually the ODE satisfied by a sequence of orthogonal
polynomials is not very enlightening in its own right. However, some orthogonal
polynomials (called special orthogonal polynomials in Andrews et al. 1999) come
from interesting problems, i.e. mathematical physics.
19Read: I don’t know.
Sturm–Liouville problems
Physically it is not surprising that one generates sequences of orthogonal functions
from separating variables in Helmholtz’s equation for example, since linear wave
systems have independent modes that do not exchange energy and are hence or-
thogonal. The functions are not always polynomials; for instance in cylindrical coor-
dinates one always finds trigonometric functions from the angular dependence and
these are not polynomials. Sturm–Liouville theory is the theory of second-order
linear eigenvalue problems and these are the underlying eigenvalue problems that
give rise to these orthogonal sequences:
−(p(x)f/prime)/prime+q(x)f=λr(x)f. (495)
In a number of cases however, the functions take the form of a polynomial multiplied
by another factor. A typical example comes from the Hermite polynomials, which
occur for instance when solving problems in the equatorial wave guide in geophys-
ical fluid dynamics (Matsuno 1966). The normal modes are then Hermite functions
Hn(x)e−x2, where the Hn(x)are Hermite polynomials satisfying the orthogonality
condition /integraldisplay∞
−∞|e−x2Hn(x)Hm(x) dx= 2nn!√πδmn. (496)
This is a case where the exact formula is simpler to write down than the recurrence
relation:
Hn(x) = (−1)nex2dne−x2
dxn. (497)
Solving Sturm–Liouville problems numerically has been touched on before. For
non-singular problems with non-periodic boundary conditions, one can happily use
pseudopectral methods as in Figure 54taken from Trefethen (2000). The accuracy
is excellent.
% p15.m - solve eigenvalue BVP u_xx = lambda*u, u(-1)=u(1)=0
N = 36; [D,x] = cheb(N); D2 = D^2; D2 = D2(2:N,2:N);
[V,Lam] = eig(D2); lam = diag(Lam);
[foo,ii] = sort(-lam); % sort eigenvalues and -vectors
lam = lam(ii); V = V(:,ii); clf
for j = 5:5:30 % plot 6 eigenvectors
u = [0;V(:,j);0]; subplot(7,1,j/5)
plot(x,u,’.’,’markersize’,12), grid on
xx = -1:.01:1; uu = polyval(polyfit(x,u,N),xx);
line(xx,uu), axis off
text(-.4,.5,sprintf(’eig %d =%20.13f*4/pi^2’,j,lam(j)*4/pi^2))
text(.7,.5,sprintf(’%4.1f ppw’, 4*N/(pi*j)))
eig 5 = −25.0000000000000*4/pi2 9.2 ppw
eig 10 = −100.0000000000229*4/pi2 4.6 ppw
eig 15 = −225.0000080022789*4/pi2 3.1 ppw
eig 20 = −400.4335180237173*4/pi2 2.3 ppw
eig 25 = −635.2304113880072*4/pi2 1.8 ppw
eig 30 = −2375.3374607793367*4/pi2 1.5 ppwend
Singular Sturm–Liouville problems are significantly more complicated. Boyd ()
gives some examples in his unmistakable style. Pryce (1993) is an excellent
account of the numerical solution of Sturm–Liouville problems, including singu-
lar problems. The emphasis is on methods designed expressly for Sturm–Liouville
problems as opposed to general methods. The most widely used algorithm is
probably SLEIGN which can be found at GAMS (SLEIGN2 is supposed to be more
recent but appears to be limited to single precision). SLEIGN is built into gsl (the
GNU scientific library). See the example below.
c p191.f SLEIGN SGLS 06/03/08
c g77 -O -o p191 p191.f sleign.f
program p191
implicit double precision (a-h,p-z)
dimension slfun(110)
a=-1d0
b=0d0
intab=1
p0ata=-1.0
qfata=1.0
p0atb=-1.0
qfatb=1.0
a1=1.0
a2=0.0
b1=1.0
b2=0.0
numeig=1
eig=0.0
tol=1d-6
islfun=101
do j=0,100
slfun(j+10)=j*.01-1.0
enddo
call sleign(a,b,intab,p0ata,qfata,p0atb,qfatb,a1,a2,b1,b2,
$ numeig,eig,tol,iflag,islfun,slfun)
write (6,*) iflag,eig
write (6,*) (slfun(j),j=10,110)
end
function p(x)
implicit double precision (a-h,p-z)
p=1d0
end
function q(x)
implicit double precision (a-h,p-z)
q=0d0
end
function r(x)
implicit double precision (a-h,p-z)
r=1.1-0.1*exp(x*10)
end
tako:~/Teaching/MAE207_2008 8:04> p191
1 8.99546276
0. 0.0424749863 0.0849079472 0.127256899 0.169480193 0.211535549
0.253381609 0.294976972 0.336280481 0.377251271 0.417849048 0.458033158
0.497764088 0.537002529 0.575709657 0.613847179 0.65137736 0.688263288
0.72446803 0.759955989 0.794692055 0.828641863 0.861771825 0.894049357
0.925442143 0.955919322 0.985450745 1.0140072 1.04156044 1.06808337
1.09354943 1.11793361 1.14121179 1.16336094 1.18435918 1.20418573
1.22282112 1.24024669 1.25644534 1.27140108 1.28509912 1.29752595
1.30866937 1.31851826 1.32706298 1.33429512 1.34020758 1.34479455
1.34805159 1.34997548 1.35056443 1.34981792 1.34773678 1.34432316
1.33958055 1.33351374 1.32612885 1.31743335 1.30743596 1.29614674
1.28357698 1.26973937 1.25464778 1.2383173 1.2207644 1.20200666
1.18206284 1.16095307 1.13869849 1.11532137 1.09084531 1.06529485
1.03869563 1.01107431 0.982458812 0.952877816 0.92236097 0.890939142
0.85864379 0.825507487 0.791563455 0.756845869 0.72138968 0.685230406
0.648404465 0.610948697 0.572900702 0.534298629 0.495180944 0.455586754
0.415555429 0.375126653 0.334340455 0.293236949 0.25185637 0.210239007
0.168425086 0.126454635 0.0843674526 0.0422029616 9.43449738E-08
Exercise 0.72 What problem is being solved in p191.f ?
Interpolation
Note the irony of p15.m : the exact solutions are sines and cosines and yet we
carefully use Chebyshev polynomials to represent our solutions, not trigonometric
functions. Why is this? We need to talk about interpolation.
The building block of polynomial interpolation is Lagrange interpolation. Given the
npointsxiat which the function to be interpolated takes the value fi, the interpo-
lating polynomial is
pn(x) =n/summationdisplay
i=1p(x)fi
p/prime(xi)(x−xi), (498)
wherep(x) = (x−x1)...(x−xn). (Watch out for the order of pn:norn−1?) There
is nothing wrong with this formula as far as reproducing the fivalues goes. How-
ever, as shown in Figure 55, the resulting polynomial can do a very poor job when
it is used with equispaced interpolation points, even inside the interval covered by
the interpolation points. This is known as Runge’s phenomenon, and should warn
us against equispaced points. Chebyshev points, also shown in Figure 55, are OK.
% p9.m - polynomial interpolation in equispaced and Chebyshev pts
N = 16;
xx = -1.01:.005:1.01; clf
for i = 1:2
if i==1, s = ’equispaced points’; x = -1 + 2*(0:N)/N; end
if i==2, s = ’Chebyshev points’; x = cos(pi*(0:N)/N); end
subplot(2,2,i)
u = 1./(1+16*x.^2);
uu = 1./(1+16*xx.^2);
p = polyfit(x,u,N); % interpolation
pp = polyval(p,xx); % evaluation of interpolant
plot(x,u,’.’,’markersize’,13)
line(xx,pp)
axis([-1.1 1.1 -1 1.5]), title(s)
error = norm(uu-pp,inf);
text(-.5,-.5,[’max error = ’ num2str(error)])
end
The reasons for the Runge phenomenon are too long to go into here. There is
a nice physical interpretation in terms of equipotential curves and the reader is
referred to Boyd (2000) and Trefethen (2000), from which Figure 56is taken.
% p10.m - polynomials and corresponding equipotential curves
−1 −0.5 0 0.5 1−1−0.500.511.5equispaced points
max error = 5.9001
−1 −0.5 0 0.5 1−1−0.500.511.5Chebyshev points
max error = 0.017523The Runge phenomenon. From Trefethen (2000).
N = 16; clf
for i = 1:2
if i==1, s = ’equispaced points’; x = -1 + 2*(0:N)/N; end
if i==2, s = ’Chebyshev points’; x = cos(pi*(0:N)/N); end
p = poly(x);
% Plot p(x) over [-1,1]:
xx = -1:.005:1; pp = polyval(p,xx);
subplot(2,2,2*i-1)
plot(x,0*x,’.’,’markersize’,13), hold on
plot(xx,pp), grid on
set(gca,’xtick’,-1:.5:1), title(s)
% Plot equipotential curves:
subplot(2,2,2*i)
plot(real(x),imag(x),’.’,’markersize’,13), hold on
axis([-1.4 1.4 -1.12 1.12])
xgrid = -1.4:.02:1.4; ygrid = -1.12:.02:1.12;
[xx,yy] = meshgrid(xgrid,ygrid); zz = xx+1i*yy;
pp = polyval(p,zz); levels = 10.^(-4:0);
contour(xx,yy,abs(pp),levels), title(s), colormap(1e-6*[1 1 1]);
end
−1 −0.5 0 0.5 1−101x 10−3equispaced points
−1−0.5 00.5 1−101equispaced points
−1 −0.5 0 0.5 1−505x 10−5Chebyshev points
−1−0.5 00.5 1−101Chebyshev pointsEquipotential curves for equispaced points and Chebyshev points.
Approximation
This is a vast subject. Essentially we are trying to find simple ways of represent-
ing a complicated function fby a simple function p, e.g. a polynomial or a rational
function (the latter case corresponding to Pad ´e approximation). A good introduc-
tory discussion for the former case (in the context of approximating what we usually
consider to be elementary functions) can be found in Muller (1997). The nature of
the error is very important. We could try and minimize the “average error” over an
interval (a,b). The typical version of this is least-squares approximation, where one
minimizes
/bardblp−f/bardbl2=/radicalBigg/integraldisplayb
aw(x)[f(x)−p(x)]2dx, (499)
wherew(x)is a continuous (positive) weight function. One can see that this prob-
lem will naturally be solved using expansions in terms of orthogonal polynomials.
We could also try and solve the maximum error
/bardblp−f/bardbl∞= max
a≤x≤b|p(x)−f(x)|. (500)
Interpolation can be viewed approximation with a weight function made up of sums
of delta functions.
Minimax approximation
Working with polynomials, we can now look for the polynomial p∗of degreenthat
satisfies ( 500); this is the minimax polynomial. Chebyshev showed that the min-
imax degree- npolynomial p∗on[a,b]is characterized by n+ 2 pointsxiin the
interval with equal values of /bardblf−p∗}. The largest approximation is reached at
n+ 2point and also alternates in sign. This is the basis of the Remez algorithm
that computes p∗for a continuous function.
The Matlab Signal Processing Toolbox includes the Remez algorithm as part of
firpm , a function that designs linear-phase FIR filters. This is out my domain of
expertise, but I put together something that I thought would use this to produce a
minimax approximation. The results is shown in Figure 57. Obviously I don’t know
what I’m doing.
% p192.m Remez algorihm for inverse Gamma function SGLS 06/03/08
x1 = 0:0.1:0.9; x2 = sin(0.5*pi*x1); ig1 = 1./gamma(x1); ig2 = 1./gamma(x2);
b1 = firpm(17,x1,ig1); b2 = firpm(3,x2,ig2);
[h1,w1] = freqz(x1,1); [h2,w2] = freqz(x2,1);
plot(w1/pi,abs(h1),x1,ig1,w2/pi,abs(h2),x2,ig2)
0 0.2 0.4 0.6 0.8 10123456
xp(x)Supposedly minimax approximation to 1/Γ(x)on(0,1).
xlabel(’x’); ylabel(’p(x)’)
One can download a more helpful algorithm and obtain Figure 58. Note that this
package attracts unjust scornful comments on the web site, since it does not pro-
duce a filter. However, it commits the faux pas of using the same names as already
existing Matlab functions.
% p193.m Remez algorithm SGLS 06/03/08
function p193
f = inline(’1./gamma(x)’);
fp = inline(’-psi(x).*gamma(x)’);
p = remez0(f,fp,[0 1],3);
p1 = p(1:end-1)
E = p(end)
x = (0:0.01:1)’;
e = err(x,f,p,0);
plot(x,f(x),x,f(x)+e)
xlabel(’x’); ylabel(’f(x) and p(x)’)
% By Sherif A. Tawfik, Faculty of Engineering, Cairo University
function A=remez0(fun, fun_der,interval,order)
powers=ones(order+2,1)*([0:order]);% the powers of the polynomial repeated in rows (order +2) times
coeff_E =(-1).^[1:order+2];
coeff_E=coeff_E(:); % the coefficients of the E as a column array
t=1:order;
t=t(:); % the powers of the polynomial starting from 1 in a column. This is used when differntiation
%the polynomial
y=linspace(interval(1),interval(2),order+2); % the first choice of the (order+2) points
for i=1:10
y=y(:); % make the points array a column array
h=(y-interval(1))*ones(1,order+1); % repeat the points column minus the start of the interval
%(order +1) times
coeff_h=h.^powers; % raise the h matrix by the power matrix elementwise
M=[coeff_h coeff_E]; % the matrix of the LHS of the linear system of equations
N= feval(fun,y); % the column vector of the RHS of the linear system of equations
A=M\N; % solution of the linear system of equations, first (order +1) element are the
% coefficients of the polynomial. Last element is the value of
% the error at these points
A1=A(1:end-1); % the coefficients only
A_der=A(2:end-1).*t; % the coeffcients of the derivative of the polynomial
z(1)=interval(1); % z(1) is the start point of the interval
z(order+3)=interval(2); % z(order+3) is the end point of the interval
% in between we fill in with the roots of the error function
for k=1: order+1
z(k+1)=findzero0(@err,y(k),y(k+1),fun,A1,interval(1));
end
% between every two points in the array z, we seek the point that
% maximizes the magnitude of the error function. If there is an extreme
% point (local maximum or local minimum) between such two points of the
% z array then the derivative of the error function is zero at this
% extreme point. We thus look for the extreme point by looking for the
% root of the derivative of the error function between these two
% points. If the extreme point doesn’t exist then we check the value of the error function
% at the two current points of z and pick the one that gives maximum
% magnitude
for k=1:order+2
if sign(err(z(k),fun_der,A_der,interval(1) ))~=sign(err(z(k+1),fun_der,A_der,interval(1))) % check for a change in sign
y1(k)=findzero0(@err,z(k),z(k+1),fun_der,A_der,interval(1)); % the extreme point that we seek
v(k)=abs(err(y1(k),fun,A1,interval(1))); % the value of the error function at the extreme point
else % if there is no change in sign therefore there is no extreme point and we compare the endpoints of the sub-interval
v1=abs(err(z(k),fun,A1,interval(1))); % magnitude of the error function at the start of the sub-interval
v2=abs(err(z(k+1),fun,A1,interval(1))); % magnitude of the error function at the end of the sub-interval
% pick the larger of the two
if v1>v2
y1(k)=z(k);
v(k)=v1;
else
y1(k)=z(k+1);
v(k)=v2;
end
end
end
[mx ind]=max(v); % search for the point in the extreme points array that gives maximum magnitude for the error function
% if the difference between this point and the corressponding point in
% the old array is less than a certain threshold then quit the loop
if abs(y(ind)-y1(ind)) <2^-30
break;
end
% compare it also with the following point if it is not the last point
if ind<length(y) & abs(y(ind+1)-y1(ind)) < 2^-30
break
end
% replace the old points with the new points
y=y1;
end
% By Sherif A. Tawfik, Faculty of Engineering, Cairo University
function e= err(x,fun, A, first)
% the polynomial coefficients array , make it a column array
A=A(:);
% the argument array , make it a column array
x=x(:);
% order of the polynomial is equal to the number of coefficients minus one
order=length(A)-1;
% the powers out in a row and repeated for each argument to form a matrix
% for example if the order is 2 and we have 3 arguments in x then
% [0 1 2]
% powers= [0 1 2]
% [0 1 2]
powers=ones(length(x),1)*[0:order];
% each argument is repeated a number of times equal to the number of
% coefficients to form a row then each element of the resulting row is
% raised with the corresponding power in the powers matrix
temp=((x-first)*ones(1,order+1)).^powers;
% multiply the resulting matrix with the coefficients table in order to
% obtain a column array. Each element of the resulting array is equal to
% the polynomial evaluated at the distance between the corresponding
% argument and the start of the interval
temp=temp*A;
% the error vector is then given as the difference between the function
% evaluated at the argument array and the polynomial evaluated at the
% argument array
e=feval(fun,x)-temp;
% By Sherif A. Tawfik, Faculty of Engineering, Cairo University
function y=findzero0(fun,x0,x1,varargin)
% fun is the function that we need to compute its root.
% x0 and x1 are two arguments to the function such that the root that we
% seek lie between them and the function has different sign at these two
% points
% varargin are the other arguments of the function
% the value of the function at the first point
f0=feval(fun,x0,varargin{:});
%the value of the function at the second point
f1=feval(fun,x1,varargin{:});
% check that the sign of the function at x0 and x1 is different. Otherwise
% report an error
if sign(f0)==sign(f1)
error(’the function at the two endpoints must be of opposite signs’);
end
%find a closer point to the root using the method of chords. In the method
%of chords we simply connect the two points (x0, f(x0)) and (x1, f(x1))
%using a straight line and compute the intersection point with this line
%and the horizontal axis. This new point is closer to the desired root
x=x0 - f0 * ((x1-x0)/(f1-f0));
%evaluate the function at this new point
f=feval(fun,x,varargin{:});
% enter this root as long as the difference between the two points that
% sandwitch the desired root is larger than a certain threshold
while abs(f)>2^-52
% we keep one of the two old points that has a different sign than the
% new point and we overwrite the other old point with the new point
if sign(f)==sign(f0)
x0=x;
f0=f;
else
x1=x;
f1=f;
end
x=x0 - f0 * ((x1-x0)/(f1-f0));
f=feval(fun,x,varargin{:});
end
% at the end of the loop we reach the root with the desired precision and
0 0.2 0.4 0.6 0.8 100.20.40.60.811.21.4
xf(x) and p(x)Good minimax approximation to 1/Γ(x)on(0,1).
% it is given by x
y=x;
Exercise 0.73 Why does p193.m need derivatives?
Moving to the complex plane
Problem 5:
Letf(z) = 1/Γ(z), where Γ(z)is the Gamma function, and let p(z)be the
cubic polynomial that best interprets f(z)on the unit disk in the supremum
norm/bardbl · /bardbl ∞. What is /bardblf−p/bardbl∞?
Here was our answer:
Here is something with which to contend. There are some mathematical
preliminaries: the coefficients of the desired cubic are purely real and the
maxima will all be attained onthe unit circle, rather than in its interior. Now
one has to decide how to cope with this complex case for the Remez al-
gorithm. The traditional idea for real-value functions of an equal ripple fit
having precisely N maxima has to be abandoned. In the present case,
while the fit is cubic, the error curve in fact attains five maxima. While
one can make a good bit of progress with na ¨ıve application of a robust
minimizer (e.g. praxis ), one tends to fall into one or another of the many
basins of attraction and settle upon a local minimum (e.g. with a quartet of
errors around 0.217). The coefficient space is finely divided: the local appar-
ently “optimal” solutions lie relatively close to each other, and in fact all lie
close to the coefficients of the traditional series expansion about the origin,
namely (0,1,γ,γ2/2−π2/12). This problem appears the most challenging
one for any significant increase in accuracy (probably followed next by prob-
lem 3). This task requires an accurate routine for the complex Psi function
(e.g. Fullerton’s). The M ATLAB routines available at http://www.math.mu-
luebeck.de/workers/modersitzki/COCA/coca5.htm lead to a result correct to
14 digits. Then a quick method is to compute all five error maxima, ek, from
the wholly symmetric error function:
E=5/summationdisplay
j=15/summationdisplay
k=j+1(ek(c)−ej(c))2,
and minimize Ewith Newton’s method. Sensitivity of the problem means
that care is needed in the choice of test increments in the coefficients if
accurate finite first and second partial derivatives of Eare to be found. It
helps to realize that one maximum occurs at θ=π, and symmetry of the
others means that really only two more must first be located as a function
ofθ. Turning the crank leads to five maxima given by:
e1=e5= 0.2143352345904596411254164
e2=e4= 0.2143352345904596411254166
e3= 0.2143352345904596411254159
with accompanying coefficient values of:
c0= 0.005541950855020788584444630869
c1= 1.019761853147270968021155097573
c2= 0.625211916596819031978857692800
c3=−0.603343220285890788584328078751 .
The Matlab output of the Coca run is given below and in Figure 59. The error is
very flat indeed. We didn’t bother enforcing symmetries, but the code do that itself.
The program takes a fair while to run because we’re obsessing about accuracy.
One can also probably use the Maple gamma function to get complex arguments.
This version shows how to interface Matlab and Fortran in what seems to be a
crude way, but which can in fact be very useful.
End COCA
t alpha r
0.360068528822733 -1.318823661558743 0.154252213355154
0.500000000000000 3.141592653589793 0.303014482965043
0.360068566101441 -1.318822407477413 0.331362413662508
0.223326071337856 0.534002050116118 0.027976460680531
0.223326086322160 0.534002489042060 0.183394429336764
lambda
0.005541952172971
1.019761855674338
0.625211919123886
-0.603343218967941
PARA =
real_coef: 1
critical_points: []
initial_extremal_points: ’random’
exchange: ’single’
stepsize: 50
relative_error_bound: 4.440892098500626e-16
iterations: 57
max_iterations: 100
initial_clustering: 0.010000000000000
clustering_tolerance: 1.000000000000000e-03
newton_tolerance: 1.000000000000000e-10
newton_stepsize: 1.000000000000000e-05
newton_iterations: 0
newton_max_iterations: 0
output: ’medium’
plot: ’always: abserror+boundary’
mywork: ’call cremez’
oldwork: ’’
as_subroutine: 0
FUN: [1x1 struct]
BASIS: [1x1 struct]
BOUNDARY: [1x1 struct]
C_dim: 4
R_dim: 4
t: [5x1 double]
alpha: [5x1 double]
r: [5x1 double]
lower_bound: 0.214335234590460
lambda: [4x1 double]
error_norm: 0.214335234590460
relative_error: 2.589921873429980e-16
ans =
0.005541952172971
1.019761855674338
0.625211919123886
-0.603343218967941
clear all
format long
% set parameters to default values
[PARA] = set_defaults;
% Approximate f(z) = 1/gamma(z)
% by phi(j,z) = z^j, j=0,1,2,3
% on the unit circle.
FUN.name = ’fgammar’; % name of approximant
BASIS.name = ’monom’; % name of basis function
BASIS.choice = [0:3]; % this is the special choice
BASIS.C_dim = length(BASIS.choice);
BOUNDARY.name= ’gcircle’; % name of boundary
% there are no points, at which the partial derivative
% does not exists
critical_points = []’;
% the function MONOM.M has no additional parameter, so the
% complex dimension can be defined by the length of the arguments
C_dim = BASIS.C_dim;
% we will assume, that the coefficients are real
real_coef = 1;
% define special parameter
% for further information on parameters see SET_PARA.M
PARA.relative_error_bound = 2*eps;
PARA.max_iterations = 100;
% for very extended output and pauses
PARA.output = ’medium’;
% plots are shown at each iteration step
PARA.plot = ’always: abserror+boundary’;
% addparameter specific parameters
PARA = set_defaults(PARA,FUN,BASIS,BOUNDARY,...
critical_points,real_coef,C_dim);
FUN
BASIS
BOUNDARY
PARA
pause
% call the COCA package
[PARA] = coca(PARA);
% do some output
disp( [ ’ t’, ’ alpha’,’ r’] )
disp([PARA.t, PARA.alpha, PARA.r]);
disp([’lambda’]);
disp([PARA.lambda]);
%===============================================================================
PARA
PARA.lambda
function [f,df]=fgammar(dummy, gamma)
n=size(gamma,1);
x=real(gamma);
y=imag(gamma);
z=zeros(2*n,1);
z(1:2:end)=x;
z(2:2:end)=y;
save dummy n z -ascii -double
!fgdo < dummy > /dev/null
load fgout
df=fgout(:,1)+i*fgout(:,2);
z=gamma;
t1=z.^2;
t2=t1.^2;
t3=t2.*z;
t4=t2.^2;
t5=t4.^2;
t10=t2.*t1;
t13=t1.*z;
t21=t2.*t13;
t30=-0.3696805618642206D-11.*t5.*t3+0.7782263439905071D-11.*t5.*t2+0.5100370287454476D-12.*t5.*t10+z+0.1043426711691101D-9.*t5.*t13-0.118127457048702D-8.*t5.*t1+0.6116095104481416D-8.*t5+0.5002007644469223D-8.*t5.*z-0.2056338416977607D-6.*t4.*t21+0.1133027231981696D-5.*t4.*t10-0.1250493482142671D-5.*t4.*t3+0.1665386113822915D0.*t3-0.9621971527876974D-2.*t21;
t33=t4.*z;
t40=t4.*t1;
t52=-0.4219773455554434D-1.*t10+0.72189432466631D-2.*t4-0.1165167591859065D-2.*t33-0.2013485478078824D-4.*t4.*t2-0.6558780715202539D0.*t13-0.4200263503409524D-1.*t2+0.5772156649015329D0.*t1-0.1181259301697459D-15.*t5.*t40+0.1280502823881162D-3.*t4.*t13-0.215241674114951D-3.*t40-0.2058326053566507D-13.*t5.*t21-0.5348122539423018D-14.*t5.*t4+0.1226778628238261D-14.*t5.*t33;
gamrecip=t30+t52;
f=gamrecip;
df=-df.*f;
program fgdo
implicit double precision (a-h,p-z)
double complex zz,zpsi,zgrp
open (10,file=’fgout’)
read (5,*) fn
do j=1,int(fn)
read (5,*) zr
read (5,*) zi
zz=zr+(0,1)*zi
zgrp=zpsi(zz)
write (10,9000) dble(zgrp),dimag(zgrp)
enddo
close(10)
−1 0 1−1−0.500.51boundary (actual points)
−0.2 0 0.2−0.2−0.100.10.2error curve (norm circle − extremal point)
0 0.2 0.4 0.6 0.8 100.10.2
lower b.=0.21434 norm=0.21434101 iter: error function (norm point(s) − actual points)Output of COCA for Problem 5.
9000 format (f60.40,1x,f60.40)
end
Quadrature
One of the important uses of orthogonal polynomials is in developing efficient
quadrature routines by playing with both weights and nodes. This is discussed
extensively in NR, as well as in Andrews et al. (1999).
References
Publications:
•Andrews, G. E., Askey, R. & Roy, R. Special functions , Cambridge University
Press, Cambridge, 1999.
•Matsuno, T. Quasigeostrophic motions in the equatorial area. J. Met. Soc.
Japan ,44, 25–43, 1966.
•Muller, J.-M. Elementary functions: algorithms and implementations , Birkh ¨auser,
Boston, 1997.
•Price, J .D. Numerical solution of Sturm–Liouville problems , Clarendon Press,
Oxford, 1993.
Web sites:
•http://www.math.mu-luebeck.de/modersitzki/COCA/coca5.html
•http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8094&objectType=FILE
Hypergeometric functions (06/04/08)
Hypergeometric series
We all know the exponential series
expz= 1 +z+z2
2+z3
3!+···, (501)
converging everywhere in the finite complex plane, and the binomial series
1
1−z= 1 +z+z2+z3+···, (502)
converging inside the unit disk |z|<1as well as on the unit circle |z|= 1 but
not atz= 1. In fact the radius of convergence is just the distance to the nearest
singularity in the complex plane.
One can think of a simple generalization to the above, with
2F1(a,b;c;z) = 1 +ab
cz+a(a+ 1)b(b+ 1)
c(c+ 1)z2
2!+···
+a(a+ 1)...(a+n−1)b(b−1)...(b+n−1)
c(c+ 1)...(c+n−1)z3
n!+···,(503)
at least in a formal sense. There are 2parameters in the numerator (symmetric
inaandb) and 1in the denominator. We can simplify notation by defining the
Pochhammer symbol
(a)n=a(a+ 1)...(a+n−1), (a)0= 1. (504)
Note that (1)n=n!, so1in the numerator parameters cancels with the factorial on
the bottom. When a=corb=c, the two parameters cancel and we obtain
2F1(a,b;b;z) = 1F0(a; ;z) = 1 +az+ (a)2z
2+···+ (a)nzn
n!+···= (1−z)−a,(505)
Then 1F0(1; ;z) = (1 −z)−1, a function we have seen before. The exponential func-
tion on the other hand is clearly 0F0(z). Call the 2F1functions Gaussian. Anything
with more than two parameters is usually called a generalized hypergeometric se-
ries.
Let us think about convergence. For 2F1, the ratio test involves
(a+n)(b+n)z
(c+n)n→zasn→ ∞, (506)
so the series converges in the disk |z|<1. Ifaorbare negative integers, the
series terminates. If cis a negative integer, the series is not defined, unless one of
the numerator parameters is also a negative integer such that the series terminates
first. Varying the number of parameters, 1F0functions have the same convergence
criteria, while 0F0functions converge everywhere in the complex plane. We can
synthesize all this.
Theorem 11 The hypergeometric function pFq(...;z)converges in the entire com-
plex plane if p<q + 1, in the unit disk if p=q+ 1and only at the origin if p>q + 1.
The behavior on the unit circle in the second case has to be looked at carefully.
From a computational perspective, we can think about summing power series for
p≤q+ 1, but we face the usual difficulties of serious cancellation during this
process. This is the approach of genHyper.m as already mentioned. It is not
entirely clear how we can compute anything sensible for the p>q + 1case, since
the series converges only at the origin. To make more progress, we will need an
ODE or integral representation.
In the mean time, though, we find that Matlab links to Maple’s implementation
of the hypergeometric function. Figure 60shows plots of the resulting complex
values, which are unilluminating. The running times are very illuminating: avoid
genHyper.m like the plague. It also works only within the radius of convergence.
Maple is fast and works everywhere.
% p201.m Hypergeometric SGLS 06/04/08
x1 = 0:.05:6; x2 = 0:0.05:0.95; p = exp(i*pi/7);
subplot(2,2,1)
maple restart; tic, f1 = hypergeom(0.2,[],x1*p); t1 = toc
tic, f2 = zeros(size(x2));
for j = 1:length(x2)
f2(j) = genHyper(0.2,[],x2(j)*p,0,0,15);
end
t2 = toc
plot(x1,real(f1),x1,imag(f1),x2,real(f2),x2,imag(f2))
xlabel(’x’); ylabel(’_1F_0’); title([’t_1 = ’,num2str(t1),’, t_2 = ’,num2str(t2)])
subplot(2,2,2)
maple restart; tic, f1 = hypergeom([],-1/3,x1*p); t1 = toc
tic, f2 = zeros(size(x2));
for j = 1:length(x1)
f2(j) = genHyper([],-1/3,x1(j)*p,0,0,15);
end
t2 = toc
plot(x1,real(f1),x1,imag(f1),x1,real(f2),x1,imag(f2))
xlabel(’x’); ylabel(’_0F_1’); title([’t_1 = ’,num2str(t1),’, t_2 = ’,num2str(t2)])
subplot(2,2,3)
maple restart; tic, f1 = hypergeom(1/3,1/7,x1*p); t1 = toc
tic, f2 = zeros(size(x1));
for j = 1:length(x1)
f2(j) = genHyper(1/3,1/7,x1(j)*p,0,0,15);
end
t2 = toc
plot(x1,real(f1),x1,imag(f1),x1,real(f2),x1,imag(f2))
xlabel(’x’); ylabel(’_1F_1’); title([’t_1 = ’,num2str(t1),’, t_2 = ’,num2str(t2)])
subplot(2,2,4)
maple restart; tic, f1 = hypergeom([-1/6,2/7],-2/3,x1*p); t1 = toc
tic, f2 = zeros(size(x2));
for j = 1:length(x2)
f2(j) = genHyper([-1/6,2/7],-2/3,x2(j)*p,0,0,15);
end
t2 = toc
plot(x1,real(f1),x1,imag(f1),x2,real(f2),x2,imag(f2))
xlabel(’x’); ylabel(’_2F_1’); title([’t_1 = ’,num2str(t1),’, t_2 = ’,num2str(t2)])
0 2 4 600.511.5
x1F0t1 = 1.2866, t2 = 11.9711
0 2 4 6−400−2000200
x0F1t1 = 6.866, t2 = 15.3438
0 2 4 6−1000−5000500
x1F1t1 = 1.9338, t2 = 32.7184
0 2 4 6−1012
x2F1t1 = 5.9696, t2 = 16.8227Evaluating hypergeometric functions using different Matlab and Maple functions.
In all cases zis along a ray making an angle of π/7radians with the x-axis; (a)
1F0(0.2; ;z), (b) 0F1(;−1/3;z), (c) 1F1(1/3; 1/7;z), (d) 2F1(−1/6,2/7;−2/3;z).
The hypergeometric equation and Riemann’s equa-
tion
The hypergeometric differential equation is
z(1−z)w/prime/prime+ [c−(a+b+ 1)z]w/prime−abw = 0. (507)
It has three regular singular points at 0,1and∞. Provided none of the numbers c,
c−a−banda−bare equal to an integer, one can write down 24different solutions.
These are related by a number of linear transformation formulae of the form
F(a,b;c;z) = (1 −z)c−a−bF(c−a,c−b;c;z). (508)
There are also quadratic transformation formulas.
The hypergeometric differential equation ( 507) is a special case of Riemann’s dif-
ferential equation with three regular points at a,b, andc:
w/prime/prime+/bracketleftbigg1−α−α/prime
z−a+1−β−β/prime
z−b+1−γ−γ/prime
z−c/bracketrightbigg
w/prime
+/bracketleftbiggαα/prime(a−b)(a−c)
z−a+ββ/prime(b−c)(b−a)
z−b+γγ/prime(c−a)(c−b)
z−c/bracketrightbiggw
(z−a)(z−b)(z−c)= 0. (509)
We have the condition
α+α/prime+β+β/prime+γ+γ/prime= 0. (510)
The complete set of solutions to ( 509) is
w=P
a b c
α β γ z
α/primeβ/primeγ/prime
. (511)
The special case of the hypergeometric function becomes
w=P
0∞ 1
0a 0z
1−c b c −a−b
. (512)
Let us try to solve ( 507) on the interval [0,1]in a non-degenerate case with a= 1/3,
b=−1/5and various c, with boundary conditions w= 1 atz= 0 andw= 2 at
z= 1. Since the endpoints are regular singular points, we need to be slightly
careful. The exponents at the singular points are 0and1−cat0,0andc−a−b
at1andaandbat infinity. The result is shown in Figure 61. Evidently something is
wrong, even when there is a solution. Some of the cases have no solution, because
the second solution is singular near singular points.
% p202.m Solve hypergeometric equation SGLS 06/05/08
a = 1/3; b = -0.2; cc = [0.5 -0.5 1.5 a+b];
for j = 1:4
c = cc(j)
N = 30; [x,D] = chebdif(N+2,2); z = diag(0.5*(x+1)); I = eye(N+2);
D1 = 2*D(:,:,1); D2 = 4*D(:,:,2);
M = z*(1-z)*D2 + (c-(a+b+1)*z)*D1 - a*b*I;
M(1,:) = [1 zeros(1,N+1)]; M(N+2,:) = [zeros(1,N+1) 1];
r = [2 ; zeros(N,1) ; 1];
w = M\r;
z = diag(z);
w0 = hypergeom([a,b],c,z);
w1 = z.^(1-c).*hypergeom([a-c+1,b-c+1],2-c,z);
C = [w0(end) w1(end) ; w0(1) w1(1)], C = C\[1 ; 2]
wex = C(1)*w0 + C(2)*w1;
subplot(2,2,j)
plot(z,w,z,wex)
xlabel(’z’); ylabel(’_2F_1’)
end
Exercise 0.74 Fixp202.m .
0 0.2 0.4 0.6 0.8 10.811.21.41.61.82
zF(1/3,−1/5;1/2;z)Numerical solution of hypergeometric ODE.
Integral representations
The standard representation, valid for Re c>Reb>0is
F(a,b;c;z) =Γ(c)
Γ(b)Γ(c−b)/integraldisplay1
0tb−1(1−t)c−b−1(1−tz)−adt. (513)
This gives an analytic function with a cut along the real z-axis from 1toinfty . This
is hence an analytic continuation of the definition ( 503).
Exercise 0.75 Show that
F(a,b;c; 1) =Γ(c)Γ(c−a−b)
Γ(c−a)Γ(c−b), (514)
cis not 0,−1,..., and Re (c−a−b)>0.
The Mellin–Barnes integral is
F(a,b;c;z) =Γ(c)
2πiΓ(a)Γ(b)/integraldisplayi∞
−i∞Γ(a+s)Γ(b+s)Γ(−s)
Γ(c+s)(−z)sds. (515)
The path of integration is chosen to go to the right of the poles of Γ(a+s)and
Γ(b+s, which are at the points s=−a−nands=−b−mfor integernandm,
and to the left of the poles of Γ(−s), namelys= 0,1, . . . . The branch of (−z)2with
π< arg (−z)<π is chosen. Cases in which −a,−b,−care negative integers are
excluded; ditto for a−binteger. This representation seems hard to swallow at first,
but is the basis for many important results, as shown in Paris & Kaminski (2001). In
particular it provides a natural way to generalize Gauss’s hypergeometric function
to arbitrary combinations of parameters (see §141below).
Confluent hypergeometric functions
Confluence means flowing together. We can make two of the singularities come
together by taking an appropriate limit of the ODE or the sum. The result is the
confluent hypergeometric equation. The standard version is to move the singularity
to infinity to make an irregular singularity at infinity. The result is
zw/prime/prime+ (b−z)w/prime−aw= 0. (516)
There are now two parameters rather than three.
There are two independent solutions to this equation. The one that is equal to one
at the origin is usually denoted
M(a,b,z ) = 1 +az
b+···+(a)nzn
(b)nn!+··· (517)
and is called Kummer’s function. The second is written U(z). The usual caveats
about integer parameters apply and are not discussed here.
Again there are integral representations
M(a,b,z ) =Γ(b)
Γ(b−z)Γ(a)/integraldisplay1
0eztta−1(1−t)b−a−1dt. (518)
and
M(a,b,z ) =Γ(b)
2πiΓ(a)/integraldisplayc+i∞
c−i∞Γ(a+s)Γ(−s)
Γ(b+s)(−z)sds. (519)
The discussion of ( 519) in AS says that now |arg (−z)<1
2πand thatcis finite. The
presence of cis probably a red herring: one can always pull the contour back to the
imaginary axis up and down the imaginary axis. The condition on the argument is
less obvious, but watch out: real positive zis a problem.
Barnes–Mellin integrals are rarely used numerically, which seems a shame since
the Gamma function decays agreeably quickly going up or down the imaginary
axis: we have
Γ(iy)Γ(−iy) =|Γ(iy)|2=π
ysinhπy. (520)
The condition on the contour is a pain if a< 0, since the contour has to wind around
poles. Let’s try a= 1/3andb=−2/5. It’s probably safer to use logarithms to avoid
unfortunate cancellations for large |y|. Figure 62shows the answer. The code is
disappointingly slow, presumably because of the calculation of gamma functions
of complex argument. Worse the results disagree, as shown in Figure 62. This
seems to be theme for this chapter.
% p203.m Kummer function via BM integral SGLS 06/04/08
function [U,Um,z] = p203
a = 1/3; b = -2/5;
ym = 20; z = 0:-0.1:-1; U = zeros(size(z)); Um = U;
for j = 1:length(z)
z(j)
U(j) = gamma(b)/(gamma(a)*2*pi*i)*quad(@(y) Uint(y,a,b,z(j)),-ym,ym);
maple(’f:=KummerU’,a,b,z(j));
Um(j) = str2num(maple(’evalf(f)’));
end
plot(z,real(U),z,imag(U),’--’,z,real(Um),z,imag(Um),’--’)
xlabel(’z’); ylabel(’U(z)’)
function f = Uint(y,a,b,z)
s = -0.1 + i*y;
f = mfun(’lnGAMMA’,-s)+mfun(’lnGAMMA’,a+s)-mfun(’lnGAMMA’,b+s);
if (z~=0)
f = f+s*log(-z);
end
f = exp(f);
Exercise 0.76 From ( 518) explain the limiting procedure to go from Gauss’s hyper-
−1 −0.8 −0.6 −0.4 −0.2 0−1.5−1−0.500.511.5
zU(z)Kummer’s function calculated using the Barnes–Mellin integral.
geometric function to Kummer’s function.
Exercise 0.77 Why do the results in Figure 62disagree?
Another pair of linearly independent solutions of the confluent hypergeometric equa-
tion come the solutions Mκ,µ(z)andWκ,µ(z)of Whittaker’s equation
w/prime/prime+/bracketleftbigg
−1
4+κ
z+1
4−µ2
z2/bracketrightbigg
w= 0. (521)
The relation between the two families is
Mκ,µ(z) = e−1
2zz1
2+µM(1
2+µ−κ,1 + 2µ,z) (522)
Wκ,µ(z) = e−1
2zz1
2+µU(1
2+µ−κ,1 + 2µ,z). (523)
MeijerG-functions
This is a very general function indeed, and related to the generalized hypergeo-
metric function. Mathai (1993) and Mathai & Haubold (2008) are quite enamored
of it and of its applications to statistics and astrophysics problems. One starts from
a Barnes–Mellin type integral
Gm,n
p,q(a1,...a p;b1,...b q;z) =1
2πi/integraldisplay
L/braceleftbig/producttextm
j=1Γ(bj+s)/bracerightbig/braceleftbig/producttextn
j=1Γ(1−aj−s)/bracerightbig
/braceleftbig/producttextq
j=m+1Γ(1−bj−s)/bracerightbig/braceleftbig/producttextp
j=n+1Γ(aj+s)/bracerightbigds,
(524)
where the contour Lseparates the poles of Γ(bj+s),j= 1,...,m (which extend off
into the left half-plane) from the poles of Γ(1−aj−s),j= 1,...,n (which extend off
into the right half-plane). The poles of the Gamma functions in the denominator are
not a problem. The conditions for existence of the function are detailed carefully in
Mathai (1993), but essentially we have existence for all non-zero zforq≥1,q>p
orp≥1,p>q , for|z|<1forq≥1,q=p, and for |z|>1forp≥1,p=q.
One can be even more general and talk about something called Fox’s H-function.
We shan’t.
Conformal mappings
Hypergeometric functions enter naturally when one seeks conformal maps from
curvilinear polygons to the upper half-plane or the unit disk. These mappings arise
naturally in free-boundary problems in porous medium flow (Polubarinova-Kochina
1962).
Suppose that we have a curvilinear polygon, that is to say a polygon bounded by
arcs of a circle
Imks+lsw
ms+nsw= 0, (525)
fors= 0,1,...,ν + 1, wherewis a complex variable. The angles at the vertices
areπα1,...,πα ν+1. we want to map this polygon to the upper half-plane ζ. The
vertices of the polygon map onto points a1,...a ν+1on the real axis with aν+1=∞.
The mapping is constructed from two linearly independent solutions to the second-
order ODE
w/prime/prime+/bracketleftbigg1−α1
ζ−a1+···+1−αν
ζ−aν/bracketrightbigg
w/prime+α/prime
ν+1α/prime/prime
ν+1(ζ−λ1)...(ζ−λν−2)
(ζ−a1)...(ζ−zν)w= 0.(526)
We haveα/prime
ν+1−α/prime/prime
ν+1=αν+1. We must also satisfy
α1+···+αν+α/prime
ν+1+α/prime/prime
ν+1=ν−1. (527)
The quantities λ1,...,λ ν−2are additional parameters that are not known in ad-
vance. For a triangle, they do not exist. This corresponds to curvilinear triangles. If
the linearly independent solutions of ( 526) are written Us(ζ)andVs(ζ), the mapping
is given by
w=AU S+BV s
CU s+DV S, (528)
whereA,B,C,D are constants.
We see that for triangles, this procedure can be carried out explicitly. For polygons
with four or more sides, there is a problem. Craster (1997) has an interesting
approach that works in certain degenerate cases using the Mellin transform. This
would lead us too far astray.
Exercise 0.78 Verify that ( 525) does in fact correspond to an arc of a circle.
References
Publications:
•Craster, R. V¿ The solution of a class of free boundary problems. Proc. R. Soc.
Lond. A,453, 607–630.
•Mathias, A. M. A handbook of generalized special functions for statistical and
physical sciences , Clarendon Press, Oxford, 1993.
•Mathai, A. M. & Haubold, H. J. Special functions for applied scientists , Springer,
Berlin, 2008.
•Paris, R. B. & Kaminski, D. Asymptotics and Mellin–Barnes integrals , Cam-
bridge University Press, Cambridge, 2001.
•Polubarinova-Kochina, P . Y . Theory of ground water movement , Princeton Uni-
versity Press, Princeton, 1962.
•Slater, L. J. Confluent hypergeometric functions , Cambridge University Press,
Cambridge, 1960.
•Slater, L. J. Generalized hypergeometric functions , Cambridge University Press,
Cambridge, 1966.
Listings (05/20/2008)
Graphical setup
% gsteup.m Graphics setup 04/08/08 SGLS
close all
clf
set(gcf,’DefaultAxesFontName’,’Palatino ’,’DefaultAxesFontSize’,16)
Programs
Kdo.f
c g77 -O -o Kdo Kdo.f talbot.f -lslatec -Wl,-framework -Wl,vecLib
program Kdo
implicit double precision (a-h,p-z)
double complex p,fun,Fc
parameter (NN=1000)
dimension g(0:NN+1),Fc(0:NN+1),zk(0:NN)
common zk,p,h,e,m,n,MM
external dbesj1,fun
read (5,*) h,e
read (5,*) MM,tmax,tstep,n
pi = 4d0*atan(1d0)
zk(0) = 0d0
do m = 1,MM
b = (m - 0.25d0)*pi
c = (m + 0.75d0)*pi
r = (m + 0.25d0)*pi
call dfzero(dbesj1,b,c,r,0d0,1d-15,iflag)
write (11,*) ’dfzero’,m,b,iflag
zk(m) = b
enddo
t = 0d0
100 if (abs(t-tmax).gt.1d-6) then
t = t + tstep
call stalbot(fun,t,n,dcmplx(0d0,0d0),0,1,0d0,MM+2,Fc,g)
write (6,1000) t,(g(j),j=0,MM+1)
goto 100
endif
1000 format (5000(1x,e32.26))
end
double complex function fun(s,Fc)
implicit double precision (a-h,p-z)
parameter (NN=1000)
double complex s,Fc(0:NN+1)
double complex p,mu,T(0:NN,0:NN),F(0:NN)
dimension ipiv(0:NN),zk(0:NN)
parameter (epsabs=1d-6,epsrel=0d0)
parameter (limit=10000,lenw=limit*4)
dimension iwork(limit),work(lenw)
common zk,p,h,e,m,n,MM
external Trint,Tiint
p = s
write (11,*) p,h,e,MM
call xsetf(0)
do m = 0,MM
if (m.eq.0) then
mu = sqrt(p)
F(m) = 0.5d0/p/e*exp(mu*(e-h))*(1d0-exp(-2d0*mu*e))/
$ (1d0-exp(-2d0*mu*h))
else
F(m) = (0d0,0d0)
endif
do n = 0,m
call dqagi(Trint,0d0,1,epsabs,epsrel,rr,abserr,
$ neval,ier,limit,lenw,last,iwork,work)
call out(m,n,rr,abserr,neval,ier,lst,iwork,1)
call dqagi(Tiint,0d0,1,epsabs,epsrel,ri,abserr,
$ neval,ier,limit,lenw,last,iwork,work)
call out(m,n,ri,abserr,neval,ier,lst,iwork,1)
T(m,n) = dbesj0(zk(m))*dbesj0(zk(n))*dcmplx(rr,ri)
enddo
write (11,*)
enddo
do m = 0,MM
do n = m+1,MM
T(m,n) = T(n,m)
enddo
enddo
do m = 0,MM
do n = 0,MM
T(m,n) = 2d0/dbesj0(zk(n))**2*T(m,n)
enddo
mu = sqrt(p + zk(m)**2)
T(m,m) = T(m,m) + 1d0/mu
$ *(1d0+exp(-2d0*mu*h))/(1d0-exp(-2d0*mu*h))
enddo
do m = 0,MM
write (11,*) ’T’,(T(m,n),n=0,MM),’ F’,F(m)
enddo
call zgesv(MM+1,1,T,NN+1,ipiv,F,NN+1,info)
write (11,*) ’zgesv’,info
write (11,*) ’F ’,(F(m),m=0,MM)
do m = 0,MM
Fc(m) = F(m)
enddo
pi = 4d0*atan(1d0)
Fc(MM+1) = pi*(1d0-2d0*F(0))/p
end
double complex function Tint(v)
implicit double precision (a-h,p-z)
parameter (NN=1000)
double complex p,mu
double precision zk(0:NN)
common zk,p,h,e,m,n,MM
external dbesj1
if (v.ne.0d0.and.v.ne.zk(m).and.v.ne.zk(n)) then
Tint = v**3/(v**2-zk(m)**2)/(v**2-zk(n)**2)
$ *dbesj1(v)**2/sqrt(p+v**2)
else
Tint = (0d0,0d0)
endif
end
subroutine out(m,n,result,abserr,neval,ier,lst,iwork,j)
implicit double precision (a-h,p-z)
dimension iwork(*)
if (j.eq.2) then
if (ier.eq.1.or.ier.eq.4.or.ier.eq.7) then
write (11,1010) m,n,result,abserr,neval,ier,lst,
$ (iwork(k),k=1,lst)
else
write (11,1000) m,n,result,abserr,neval,ier,lst
endif
else
write (11,1000) m,n,result,abserr,neval,ier
endif
1000 format(2(i2,1x),2(e24.16,1x),i6,1x,i1,1x,i4)
1010 format(2(i2,1x),2(e24.16,1x),i6,1x,i1,1x,i4,1x,100(i2,1x))
end
double precision function Trint(v)
implicit double precision (a-h,p-z)
double complex Tint
Trint = dble(Tint(v))
end
double precision function Tiint(v)
implicit double precision (a-h,p-z)
double complex Tint
Tiint = dimag(Tint(v))
end
talbot.f
double precision function talbot(fun,t,D,sj,mult,ns,aa)
implicit double precision (a-h,p-z)
double complex sj(ns),spj
dimension mult(ns)
logical rsing
integer D,Dp,Dd,Dj,c
double precision kappa,lambda,mu,nu,omega
double complex fun,sd,sstar,snu,s,ak,b1,b2,bk
parameter (c=15)
common /talvar/ lambda, sigma, nu, n0, n1, n2, n
external fun
pi = 4d0*atan(1d0)
rsing = .true.
phat = dble(sj(1))
do j = 1,ns
pj = dble(sj(j))
if (phat.le.pj) phat = pj
enddo
sigma0 = max(0d0,phat)
qd = 0d0
thetad = pi
multd = 0
rmax = 0d0
do j = 1,ns
if (dimag(sj(j)).ne.0d0) then
rsing = .false.
spj = sj(j) - phat
r = dimag(spj)/atan2(dimag(spj),dble(spj))
if (r.gt.rmax) then
sd = sj(j)
qd = abs(dimag(sd))
thetad = atan2(qd,dble(spj))
multd = mult(j)
endif
endif
enddo
v = qd*t
if (aa.eq.0d0) then
omega = min(0.4d0*(c+1d0)+v/2d0,2d0*(c+1d0)/3d0)
else
omega = 5d0*(c-1)/13d0 + aa*t/30d0
endif
if (v.le.omega*thetad/1.8d0) then
lambda = omega/t
sigma = sigma0
nu = 1d0
else
kappa = 1.6d0 + 12d0/(v+25d0)
phi = 1.05d0 + 1050d0/max(553d0,800d0-v)
mu = (omega/t + sigma0 - phat)/(kappa/phi - 1d0/tan(phi))
lambda = kappa*mu/phi
sigma = phat - mu/tan(phi)
nu = qd/mu
endif
tau = lambda*t
a = (nu-1d0)*0.5d0
sigmap = sigma - sigma0
c write (6,*) ’lambda sigma nu’,lambda,sigma,nu
c determine n
c n0
Dd = D + min(2*multd-2,2) + int(multd*0.25d0)
if (v.gt.omega*thetad/1.8d0.or.multd.eq.0.or.rsing) then
n0 = 0
else
sstar = (sd-sigma0)/lambda
p = dble(sstar)
q = dimag(sstar)
r = abs(sstar)
theta = atan2(q,p)
y = 2d0*pi-13d0/(5d0-2d0*p-q-0.45d0*exp(p))
100 ul = (y-q)/(r*sin(y-theta))
if (ul.le.0d0) then
n0 = 0
else
u = log(ul)
g = dble(sstar)*(1-exp(u)*cos(y))
$ - dimag(sstar)*exp(u)*sin(y) + u
dy = (q-y)*g/(1d0-2d0*r*exp(u)*cos(y-theta)+r**2*exp(2*u))
y = y + dy
if (abs(dy).ge.1e-4) goto 100
ppd = phat - sigma0
n0 = int((2.3d0*Dd+ppd*t)/u)
endif
endif
c n1
e = (2.3d0*D+omega)/tau
if (e.le.4.4d0) then
rho = (24.8d0-2.5d0*e)/(16d0+4.3d0*e)
elseif (e.le.10d0) then
rho = (129d0/e-4d0)/(50d0+3d0*e)
else
rho = (256d0/e+0.4d0)/(44d0+19d0*e)
endif
n1 = int(tau*(a+1d0/rho))+1
c n2
gamma = sigmap/lambda
if (rsing) then
Dp = 0
do j = 1,ns
Dj = D + min(2*mult(j)-2,2) + int(mult(j)*0.25d0)
if (Dj.gt.Dp) Dp = Dtemp
enddo
else
Dp = Dd
endif
y = 1d-3*v
eta = (1.09d0-0.92d0*y+0.8d0*y**2)*min(1.78d0,
$ 1.236d0+0.0064d0*1.78d0**Dp)
n2 = int(eta*nu*(2.3d0*Dp+omega)/(3d0+4d0*gamma+exp(-gamma)))+1
n = max(n0,max(n1,n2))
c write (6,*) ’n n0 n1 n2’,n,n0,n1,n2
c sum over paraboloid
psi = tau*nu*pi/n
u = 2d0*cos(psi)
b2 = 0d0
b1 = 0d0
do k = n-1,1,-1
theta = k*pi/n
alpha = theta/tan(theta)
snu = dcmplx(alpha,nu*theta)
s = lambda*snu+sigma
beta = theta+alpha*(alpha-1d0)/theta
ak = exp(alpha*tau)*dcmplx(nu,beta)*fun(s)
bk = ak + u*b1 - b2
b2 = b1
b1 = bk
enddo
s = lambda+sigma
ak = exp(tau)*nu*fun(s)
talbot = lambda*exp(sigma*t)/n*
$ dble( 0.5d0*(ak + u*b1) - b2
$ + dcmplx(0d0,1d0)*b1*sin(psi) )
1000 format (f30.16,1x,f30.16)
return
end
double complex function ztalbot(fun,t,D,sj,mult,ns,aa)
implicit double precision (a-h,p-z)
double complex sj(ns),spj
dimension mult(ns)
logical rsing
integer D,Dp,Dd,Dj,c
double precision kappa,lambda,mu,nu,omega
double complex fun,sd,sstar,snu,s,ak,b1,b2,bk,am,bm1,bm2,bm
parameter (c=15)
common /talvar/ lambda, sigma, nu, n0, n1, n2, n
external fun
pi = 4d0*atan(1d0)
rsing = .true.
phat = dble(sj(1))
do j = 1,ns
pj = dble(sj(j))
if (phat.le.pj) phat = pj
enddo
sigma0 = max(0d0,phat)
qd = 0d0
thetad = pi
multd = 0
rmax = 0d0
do j = 1,ns
if (dimag(sj(j)).ne.0d0) then
rsing = .false.
spj = sj(j) - phat
r = dimag(spj)/atan2(dimag(spj),dble(spj))
if (r.gt.rmax) then
sd = sj(j)
qd = abs(dimag(sd))
thetad = atan2(qd,dble(spj))
multd = mult(j)
endif
endif
enddo
v = qd*t
if (aa.eq.0d0) then
omega = min(0.4d0*(c+1d0)+v/2d0,2d0*(c+1d0)/3d0)
else
omega = 5d0*(c-1)/13d0 + aa*t/30d0
endif
if (v.le.omega*thetad/1.8d0) then
lambda = omega/t
sigma = sigma0
nu = 1d0
else
kappa = 1.6d0 + 12d0/(v+25d0)
phi = 1.05d0 + 1050d0/max(553d0,800d0-v)
mu = (omega/t + sigma0 - phat)/(kappa/phi - 1d0/tan(phi))
lambda = kappa*mu/phi
sigma = phat - mu/tan(phi)
nu = qd/mu
endif
tau = lambda*t
a = (nu-1d0)*0.5d0
sigmap = sigma - sigma0
c write (6,*) ’lambda sigma nu’,lambda,sigma,nu
c determine n
c n0
Dd = D + min(2*multd-2,2) + int(multd*0.25d0)
if (v.gt.omega*thetad/1.8d0.or.multd.eq.0.or.rsing) then
n0 = 0
else
sstar = (sd-sigma0)/lambda
p = dble(sstar)
q = dimag(sstar)
r = abs(sstar)
theta = atan2(q,p)
y = 2d0*pi-13d0/(5d0-2d0*p-q-0.45d0*exp(p))
100 ul = (y-q)/(r*sin(y-theta))
if (ul.le.0d0) then
n0 = 0
else
u = log(ul)
g = dble(sstar)*(1-exp(u)*cos(y))
$ - dimag(sstar)*exp(u)*sin(y) + u
dy = (q-y)*g/(1d0-2d0*r*exp(u)*cos(y-theta)+r**2*exp(2*u))
y = y + dy
if (abs(dy).ge.1e-4) goto 100
ppd = phat - sigma0
n0 = int((2.3d0*Dd+ppd*t)/u)
endif
endif
c n1
e = (2.3d0*D+omega)/tau
if (e.le.4.4d0) then
rho = (24.8d0-2.5d0*e)/(16d0+4.3d0*e)
elseif (e.le.10d0) then
rho = (129d0/e-4d0)/(50d0+3d0*e)
else
rho = (256d0/e+0.4d0)/(44d0+19d0*e)
endif
n1 = int(tau*(a+1d0/rho))+1
c n2
gamma = sigmap/lambda
if (rsing) then
Dp = 0
do j = 1,ns
Dj = D + min(2*mult(j)-2,2) + int(mult(j)*0.25d0)
if (Dj.gt.Dp) Dp = Dtemp
enddo
else
Dp = Dd
endif
y = 1d-3*v
eta = (1.09d0-0.92d0*y+0.8d0*y**2)*min(1.78d0,
$ 1.236d0+0.0064d0*1.78d0**Dp)
n2 = int(eta*nu*(2.3d0*Dp+omega)/(3d0+4d0*gamma+exp(-gamma)))+1
n = max(n0,max(n1,n2))
c n = 50
c write (6,*) ’n n0 n1 n2’,n,n0,n1,n2
c sum over paraboloid
psi = tau*nu*pi/n
u = 2d0*cos(psi)
b2 = 0d0
b1 = 0d0
bm2 = 0d0
bm1 = 0d0
do k = n-1,1,-1
theta = k*pi/n
alpha = theta/tan(theta)
snu = dcmplx(alpha,nu*theta)
s = lambda*snu+sigma
beta = theta+alpha*(alpha-1d0)/theta
ak = exp(alpha*tau)*dcmplx(nu,beta)*fun(s)
bk = ak + u*b1 - b2
b2 = b1
b1 = bk
am = exp(alpha*tau)*dcmplx(nu,-beta)*fun(conjg(s))
bm = am + u*bm1 - bm2
bm2 = bm1
bm1 = bm
enddo
s = lambda+sigma
ak = exp(tau)*nu*fun(s)
am = ak
ztalbot = lambda*exp(sigma*t)/n*0.5d0*
$ ( 0.5d0*(ak + am + u*(b1+bm1)) - b2 - bm2
$ + dcmplx(0d0,1d0)*b1*sin(psi)
$ - dcmplx(0d0,1d0)*bm1*sin(psi) )
1000 format (f30.16,1x,f30.16)
return
end
subroutine stalbot(fun,t,D,sj,mult,ns,aa,Nd,Fc,res)
implicit double precision (a-h,p-z)
double complex sj(ns),spj,Fc(*)
dimension mult(ns),res(*)
logical rsing
integer D,Dp,Dd,Dj,c
double precision kappa,lambda,mu,nu,omega
parameter (NN=50000)
double complex fun,sd,sstar,snu,s,ak(NN),b1(NN),b2(NN),bk(NN)
parameter (c=15)
common /talvar/ lambda, sigma, nu, n0, n1, n2, n
c common /taldat/ Nd, Fc(Nd),res(Nd)
external fun
if (Nd.gt.NN) stop
pi = 4d0*atan(1d0)
rsing = .true.
phat = dble(sj(1))
do j = 1,ns
pj = dble(sj(j))
if (phat.le.pj) phat = pj
enddo
sigma0 = max(0d0,phat)
qd = 0d0
thetad = pi
multd = 0
rmax = 0d0
do j = 1,ns
if (dimag(sj(j)).ne.0d0) then
rsing = .false.
spj = sj(j) - phat
r = dimag(spj)/atan2(dimag(spj),dble(spj))
if (r.gt.rmax) then
sd = sj(j)
qd = abs(dimag(sd))
thetad = atan2(qd,dble(spj))
multd = mult(j)
endif
endif
enddo
v = qd*t
if (aa.eq.0d0) then
omega = min(0.4d0*(c+1d0)+v/2d0,2d0*(c+1d0)/3d0)
else
omega = 5d0*(c-1)/13d0 + aa*t/30d0
endif
if (v.le.omega*thetad/1.8d0) then
lambda = omega/t
sigma = sigma0
nu = 1d0
else
kappa = 1.6d0 + 12d0/(v+25d0)
phi = 1.05d0 + 1050d0/max(553d0,800d0-v)
mu = (omega/t + sigma0 - phat)/(kappa/phi - 1d0/tan(phi))
lambda = kappa*mu/phi
sigma = phat - mu/tan(phi)
nu = qd/mu
endif
tau = lambda*t
a = (nu-1d0)*0.5d0
sigmap = sigma - sigma0
c write (6,*) ’lambda sigma nu’,lambda,sigma,nu
c determine n
c n0
Dd = D + min(2*multd-2,2) + int(multd*0.25d0)
if (v.gt.omega*thetad/1.8d0.or.multd.eq.0.or.rsing) then
n0 = 0
else
sstar = (sd-sigma0)/lambda
p = dble(sstar)
q = dimag(sstar)
r = abs(sstar)
theta = atan2(q,p)
y = 2d0*pi-13d0/(5d0-2d0*p-q-0.45d0*exp(p))
100 ul = (y-q)/(r*sin(y-theta))
if (ul.le.0d0) then
n0 = 0
else
u = log(ul)
g = dble(sstar)*(1-exp(u)*cos(y))
$ - dimag(sstar)*exp(u)*sin(y) + u
dy = (q-y)*g/(1d0-2d0*r*exp(u)*cos(y-theta)+r**2*exp(2*u))
y = y + dy
if (abs(dy).ge.1e-4) goto 100
ppd = phat - sigma0
n0 = int((2.3d0*Dd+ppd*t)/u)
endif
endif
c n1
e = (2.3d0*D+omega)/tau
if (e.le.4.4d0) then
rho = (24.8d0-2.5d0*e)/(16d0+4.3d0*e)
elseif (e.le.10d0) then
rho = (129d0/e-4d0)/(50d0+3d0*e)
else
rho = (256d0/e+0.4d0)/(44d0+19d0*e)
endif
n1 = int(tau*(a+1d0/rho))+1
c n2
gamma = sigmap/lambda
if (rsing) then
Dp = 0
do j = 1,ns
Dj = D + min(2*mult(j)-2,2) + int(mult(j)*0.25d0)
if (Dj.gt.Dp) Dp = Dtemp
enddo
else
Dp = Dd
endif
y = 1d-3*v
eta = (1.09d0-0.92d0*y+0.8d0*y**2)*min(1.78d0,
$ 1.236d0+0.0064d0*1.78d0**Dp)
n2 = int(eta*nu*(2.3d0*Dp+omega)/(3d0+4d0*gamma+exp(-gamma)))+1
n = max(n0,max(n1,n2))
c write (6,*) ’n n0 n1 n2’,n,n0,n1,n2
c sum over paraboloid
psi = tau*nu*pi/n
u = 2d0*cos(psi)
do j = 1,Nd
b2(j) = 0d0
b1(j) = 0d0
enddo
do k = n-1,1,-1
theta = k*pi/n
alpha = theta/tan(theta)
snu = dcmplx(alpha,nu*theta)
s = lambda*snu+sigma
beta = theta+alpha*(alpha-1d0)/theta
dummy = fun(s,Fc)
do j = 1,Nd
ak(j) = exp(alpha*tau)*dcmplx(nu,beta)*Fc(j)
bk(j) = ak(j) + u*b1(j) - b2(j)
b2(j) = b1(j)
b1(j) = bk(j)
enddo
enddo
s = lambda+sigma
dummy = fun(s,Fc)
do j = 1,Nd
ak(j) = exp(tau)*nu*Fc(j)
res(j) = lambda*exp(sigma*t)/n*
$ dble( 0.5d0*(ak(j) + u*b1(j)) - b2(j)
$ + dcmplx(0d0,1d0)*b1(j)*sin(psi) )
enddo
1000 format (f30.16,1x,f30.16)
return
end
subroutine sztalbot(fun,t,D,sj,mult,ns,aa,Nd,Fc,res)
implicit double precision (a-h,p-z)
double complex sj(ns),spj,Fc(*),res(*)
dimension mult(ns)
logical rsing
integer D,Dp,Dd,Dj,c
double precision kappa,lambda,mu,nu,omega
parameter (NN=50000)
double complex fun,sd,sstar,snu,s,ak(NN),b1(NN),b2(NN),bk(NN),
$ am(NN),bm1(NN),bm2(NN),bm(NN)
parameter (c=15)
common /talvar/ lambda, sigma, nu, n0, n1, n2, n
c common /taldat/ Nd, Fc(Nd),res(Nd)
external fun
if (Nd.gt.NN) stop
pi = 4d0*atan(1d0)
rsing = .true.
phat = dble(sj(1))
do j = 1,ns
pj = dble(sj(j))
if (phat.le.pj) phat = pj
enddo
sigma0 = max(0d0,phat)
qd = 0d0
thetad = pi
multd = 0
rmax = 0d0
do j = 1,ns
if (dimag(sj(j)).ne.0d0) then
rsing = .false.
spj = sj(j) - phat
r = dimag(spj)/atan2(dimag(spj),dble(spj))
if (r.gt.rmax) then
sd = sj(j)
qd = abs(dimag(sd))
thetad = atan2(qd,dble(spj))
multd = mult(j)
endif
endif
enddo
v = qd*t
if (aa.eq.0d0) then
omega = min(0.4d0*(c+1d0)+v/2d0,2d0*(c+1d0)/3d0)
else
omega = 5d0*(c-1)/13d0 + aa*t/30d0
endif
if (v.le.omega*thetad/1.8d0) then
lambda = omega/t
sigma = sigma0
nu = 1d0
else
kappa = 1.6d0 + 12d0/(v+25d0)
phi = 1.05d0 + 1050d0/max(553d0,800d0-v)
mu = (omega/t + sigma0 - phat)/(kappa/phi - 1d0/tan(phi))
lambda = kappa*mu/phi
sigma = phat - mu/tan(phi)
nu = qd/mu
endif
tau = lambda*t
a = (nu-1d0)*0.5d0
sigmap = sigma - sigma0
c write (6,*) ’lambda sigma nu’,lambda,sigma,nu
c determine n
c n0
Dd = D + min(2*multd-2,2) + int(multd*0.25d0)
if (v.gt.omega*thetad/1.8d0.or.multd.eq.0.or.rsing) then
n0 = 0
else
sstar = (sd-sigma0)/lambda
p = dble(sstar)
q = dimag(sstar)
r = abs(sstar)
theta = atan2(q,p)
y = 2d0*pi-13d0/(5d0-2d0*p-q-0.45d0*exp(p))
100 ul = (y-q)/(r*sin(y-theta))
if (ul.le.0d0) then
n0 = 0
else
u = log(ul)
g = dble(sstar)*(1-exp(u)*cos(y))
$ - dimag(sstar)*exp(u)*sin(y) + u
dy = (q-y)*g/(1d0-2d0*r*exp(u)*cos(y-theta)+r**2*exp(2*u))
y = y + dy
if (abs(dy).ge.1e-4) goto 100
ppd = phat - sigma0
n0 = int((2.3d0*Dd+ppd*t)/u)
endif
endif
c n1
e = (2.3d0*D+omega)/tau
if (e.le.4.4d0) then
rho = (24.8d0-2.5d0*e)/(16d0+4.3d0*e)
elseif (e.le.10d0) then
rho = (129d0/e-4d0)/(50d0+3d0*e)
else
rho = (256d0/e+0.4d0)/(44d0+19d0*e)
endif
n1 = int(tau*(a+1d0/rho))+1
c n2
gamma = sigmap/lambda
if (rsing) then
Dp = 0
do j = 1,ns
Dj = D + min(2*mult(j)-2,2) + int(mult(j)*0.25d0)
if (Dj.gt.Dp) Dp = Dtemp
enddo
else
Dp = Dd
endif
y = 1d-3*v
eta = (1.09d0-0.92d0*y+0.8d0*y**2)*min(1.78d0,
$ 1.236d0+0.0064d0*1.78d0**Dp)
n2 = int(eta*nu*(2.3d0*Dp+omega)/(3d0+4d0*gamma+exp(-gamma)))+1
n = max(n0,max(n1,n2))
c write (6,*) ’n n0 n1 n2’,n,n0,n1,n2
c sum over paraboloid
psi = tau*nu*pi/n
u = 2d0*cos(psi)
do j = 1,Nd
b2(j) = 0d0
b1(j) = 0d0
enddo
do k = n-1,1,-1
theta = k*pi/n
alpha = theta/tan(theta)
snu = dcmplx(alpha,nu*theta)
s = lambda*snu+sigma
beta = theta+alpha*(alpha-1d0)/theta
dummy = fun(s,Fc)
do j = 1,Nd
ak(j) = exp(alpha*tau)*dcmplx(nu,beta)*Fc(j)
bk(j) = ak(j) + u*b1(j) - b2(j)
b2(j) = b1(j)
b1(j) = bk(j)
enddo
dummy = fun(conjg(s),Fc)
do j = 1,Nd
am(j) = exp(alpha*tau)*dcmplx(nu,-beta)*Fc(j)
bm(j) = am(j) + u*bm1(j) - bm2(j)
bm2(j) = bm1(j)
bm1(j) = bm(j)
enddo
enddo
s = lambda+sigma
dummy = fun(s,Fc)
do j = 1,Nd
ak(j) = exp(tau)*nu*Fc(j)
res(j) = lambda*exp(sigma*t)/n*0.5d0*
$ ( 0.5d0*(ak(j) + am(j) + u*(b1(j)+bm1(j))) - b2(j) -bm2(j)
$ + dcmplx(0d0,1d0)*b1(j)*sin(psi)
$ - dcmplx(0d0,1d0)*bm1(j)*sin(psi) )
enddo
1000 format (f30.16,1x,f30.16)
return
end
p154.m
% p153.m BIM method SGLS 05/20/08
function p153
global h N x0 y0 nx ny
a = 1.3; b = 3;
ie = input(’-1 for exterior, 1 for interior: ’);
m = input(’resolution : ’)
s = 3;
xc = 1; yc = -0.5; xc = 0; yc = 0;
tt = linspace(0,1,m)*2*pi; tt = fliplr(tt); x = a*cos(tt’)+xc; y = b*sin(tt’)+yc;
tt = linspace(0,1,m)*2*pi; x = a*cos(tt’)+xc; y = b*sin(tt’)+yc;
[f,fp,A,B,P,S,zb,vm,fi,fpi,xfi,xfpi,I] = bem(x,y,ie,s);
P
S
zb
vm
I
figure(1)
subplot(1,2,1)
splot(x,y); hold on; quiver(x0,y0,nx,ny,0.25); hold off
th = atan2((y0-yc)/b,(x0-xc)/a);
if (ie==1)
fex = [x0-xc y0-yc (a^2-b^2)/(a^2+b^2)*(x0-xc).*(y0-yc)];
else
fex = -[b*cos(th) a*sin(th) 0.25*(a^2-b^2)*sin(2*th)];
end
s = cumsum(h);
for j = 1:3
subplot(3,2,2*j)
plot(s,f(:,j),s,fex(:,j))
end
[k,e] = ellipke(1-min(a,b)^2/max(a,b)^2); Pex = 4*max(a,b)*e
Sex = pi*a*b
if (ie==1)
vmex = [pi*a*b 0 0 ; 0 pi*a*b 0 ; 0 0 0.25*(a^2-b^2)^2/(a^2+b^2)*pi*a*b]
else
vmex = [pi*b^2 0 0 ; 0 pi*a^2 0 ; 0 0 0.125*pi*(a^2-b^2)^2]
end
Iex = vm(:,1:2) + Sex*[1 0 ; 0 1 ; -yc xc]
function [f,fp,A,B,P,S,zb,vm,fi,fpi,xfi,xfpi,I] = bem(x,y,ie,s)
global N x0 y0 nx ny
glinit
pspline(x,y,ie)
[A,B] = buildmat(x,y,ie,s);
I = eye(N);
fp = [nx ny -nx.*y0 + ny.*x0];
r = rank(B-0.5*I);
if (r<N)
f = pinv(B-0.5*I)*A*fp;
else
f = (B-0.5*I)\A*fp;
end
nx = -nx; ny = -ny; fp = -fp;
g1 = [ones(N,1) nx ny]; g2 = [ones(N,1) x0 y0];
vm = zeros(3,3); fi = vm; fpi = vm; xfi = vm; xfpi = vm;
for i = 1:3
for j = 1:3
vm(i,j) = doint(f(:,i).*fp(:,j));
fi(i,j) = doint(f(:,i).*g1(:,j));
fpi(i,j) = doint(fp(:,i).*g1(:,j));
xfi(i,j) = doint(f(:,i).*g2(:,j));
xfpi(i,j) = doint(fp(:,i).*g2(:,j));
end
end
I = fi(:,2:3)-xfpi(:,2:3);
P = doint(ones(N,1));
S = ie*[doint(x0.*nx) doint(y0.*ny)];
zb = ie*[doint(0.5*x0.^2.*nx)/S(1) doint(0.5*y0.^2.*ny)/S(2)];
function glinit
global xi w xil wl
xi = zeros(20,1);
w = zeros(20,1);
xi(1) = -0.993128599185094924786;
xi(2) = -0.963971927277913791268;
xi(3) = -0.912234428251325905868;
xi(4) = -0.839116971822218823395;
xi(5) = -0.746331906460150792614;
xi(6) = -0.636053680726515025453;
xi(7) = -0.510867001950827098004;
xi(8) = -0.373706088715419560673;
xi(9) = -0.227785851141645078080;
xi(10)= -0.076526521133497333755;
xi(11) = -xi(10);
xi(12) = -xi(9);
xi(13) = -xi(8);
xi(14) = -xi(7);
xi(15) = -xi(6);
xi(16) = -xi(5);
xi(17) = -xi(4);
xi(18) = -xi(3);
xi(19) = -xi(2);
xi(20) = -xi(1);
w(1) = 0.017614007139152118312;
w(2) = 0.040601429800386941331;
w(3) = 0.062672048334109063570;
w(4) = 0.083276741576704748725;
w(5) = 0.101930119817240435037;
w(6) = 0.118194531961518417312;
w(7) = 0.131688638449176626898;
w(8) = 0.142096109318382051329;
w(9) = 0.149172986472603746788;
w(10)= 0.152753387130725850698;
w(11) = w(10);
w(12) = w(9);
w(13) = w(8);
w(14) = w(7);
w(15) = w(6);
w(16) = w(5);
w(17) = w(4);
w(18) = w(3);
w(19) = w(2);
w(20) = w(1);
for N = 20
j = (0:2*N);
alpha = 0.5*ones(1,2*N-1);
warning off
beta = 0.25./(4-1./j.^2);
nu = (-1).^j./j./(j+1).*exp(2*gammaln(j+1)-gammaln(2*j+1));
warning on
nu(1) = 1;
sig = zeros(2*N+1,2*N+1);
sig(2,2:2*N+1) = nu(1:2*N);
a = zeros(N,1); b = zeros(N,1);
a(1) = alpha(1) + nu(2)/nu(1);
b(1) = 0;
for k = 3:N+1
for l = k:2*N-k+3
sig(k,l) = sig(k-1,l+1) + (alpha(l-1)-a(k-2))*sig(k-1,l) - ...
b(k-2)*sig(k-2,l) + beta(l-1)*sig(k-1,l-1);
end
a(k-1) = alpha(k-1) + sig(k,k+1)/sig(k,k) - sig(k-1,k)/sig(k-1, ...
k-1);
b(k-1) = sig(k,k)/sig(k-1,k-1);
end
J = diag(a) + diag(sqrt(b(2:end)),1) + diag(sqrt(b(2:end)),-1);
[v,d] = eig(J);
xil = diag(d);
wl = v(1,:).^2’;
end
function pspline(x,y,ie)
global x0 y0 nx ny a b c h N
N = length(x)-1;
x = x(:); y = y(:);
dx = diff(x); dy = diff(y);
h = sqrt(dx.^2+dy.^2);
z = [x y];
a = zeros(N,2); b = zeros(N+1,2); c = zeros(N,2);
A = diag(2/3*(h(1:N-1)+h(2:N))) + diag(h(2:N-1)/3,-1) + diag(h(2:N-1)/3,1);
for j = 1:2
xG = z(:,j);
b1 = 0;
rhs = diff(xG(2:N+1))./h(2:N) - diff(xG(1:N))./h(1:N-1);
bb = A\rhs;
F0 = 2/3*(h(1)+h(N))*b1 + 1/3*h(1)*bb(1) + 1/3*h(N)*bb(N-1) - ...
(xG(2)-xG(1))/h(1) + (xG(N+1)-xG(N))/h(N);
bb = A\(rhs - 1/3*([h(1) ; zeros(N-3,1) ; h(N)]));
b1 = 1;
F1 = 2/3*(h(1)+h(N))*b1 + 1/3*h(1)*bb(1) + 1/3*h(N)*bb(N-1) - ...
(xG(2)-xG(1))/h(1) + (xG(N+1)-xG(N))/h(N);
b1 = -F0/(F1-F0);
bb = A\(rhs - b1/3*([h(1) ; zeros(N-3,1) ; h(N)]));
b(:,j) = [b1 ; bb ; b1];
a(1:N,j) = diff(b(:,j))/3./h;
c(1:N,j) = diff(xG)./h - 1/3*h.*(b(2:N+1,j) + 2*b(1:N,j));
end
b = b(1:N,:);
hm = 0.5*h;
x0 = a(:,1).*hm.^3 + b(:,1).*hm.^2 + c(:,1).*hm + x(1:N);
y0 = a(:,2).*hm.^3 + b(:,2).*hm.^2 + c(:,2).*hm + y(1:N);
hn = sqrt( (3*a(:,1).*hm.^2 + 2*b(:,1).*hm + c(:,1)).^2 + ...
(3*a(:,2).*hm.^2 + 2*b(:,2).*hm + c(:,2)).^2 );
nx = -1./hn.*(3*a(:,2).*hm.^2 + 2*b(:,2).*hm + c(:,2))*ie;
ny = 1./hn.*(3*a(:,1).*hm.^2 + 2*b(:,1).*hm + c(:,1))*ie;
function [A,B] = buildmat(x,y,ie,s)
global xi w xil wl x0 y0 a b c h N
A = zeros(N); B = zeros(N);
for i = 1:N
hh = 0.5*(xi+1).*h(i);
hi = sqrt( (3*a(i,1)*hh.^2 + 2*b(i,1)*hh + c(i,1)).^2 + ...
(3*a(i,2)*hh.^2 + 2*b(i,2)*hh + c(i,2)).^2 );
nx = -1./hi.*(3*a(i,2)*hh.^2 + 2*b(i,2)*hh + c(i,2))*ie;
ny = 1./hi.*(3*a(i,1)*hh.^2 + 2*b(i,1)*hh + c(i,1))*ie;
xk = a(i,1).*hh.^3 + b(i,1).*hh.^2 + c(i,1).*hh + x(i);
yk = a(i,2).*hh.^3 + b(i,2).*hh.^2 + c(i,2).*hh + y(i);
for j = 1:N
[G,Gx,Gy] = Gfn(xk,yk,x0(j),y0(j));
B(j,i) = 0.5*h(i)*sum(w.*hi.*(Gx.*nx+Gy.*ny));
if (i~=j)
A(j,i) = 0.5*h(i)*sum(w.*hi.*G);
else
if (s==1)
As(1) = 0.5*h(i)*sum(w.*hi.*G);
elseif (s==2)
h0 = 0.5*h(i);
Gr = G + log(abs(hh-h0))/(2*pi);
hi0 = sqrt( (3*a(i,1)*h0.^2 + 2*b(i,1)*h0 + c(i,1)).^2 + ...
(3*a(i,2)*h0.^2 + 2*b(i,2)*h0 + c(i,2)).^2 );
As(2) = 0.5*h(i)*sum(w.*hi.*Gr) - 1/(2*pi)*( ...
0.5*h(i)*sum(w.*log(abs(hh-h0)).*(hi-hi0)) + ...
hi0*( (h(i)-h0)*(log(h(i)-h0) - 1) + h0*(log(h0) -1) ...
) );
elseif (s==3)
h0 = 0.5*h(i);
Gr = G + log(abs(hh-h0))/(2*pi);
As(3) = 0.5*h(i)*sum(w.*hi.*Gr);
dh = 0.5*h(i);
hm = h0 - 0.5*(xi+1)*0.5*h(i); hl = h0 - xil*0.5*h(i);
him = sqrt( (3*a(i,1)*hm.^2 + 2*b(i,1)*hm + c(i,1)).^2 + ...
(3*a(i,2)*hm.^2 + 2*b(i,2)*hm + c(i,2)).^2 );
hil = sqrt( (3*a(i,1)*hl.^2 + 2*b(i,1)*hl + c(i,1)).^2 + ...
(3*a(i,2)*hl.^2 + 2*b(i,2)*hl + c(i,2)).^2 );
As(3) = As(3) + (dh*sum(wl.*hil) - 0.5*dh*log(dh)*sum(w.*him))/(2*pi);
hm = h0 + 0.5*(xi+1)*0.5*h(i); hl = h0 + xil*0.5*h(i);
him = sqrt( (3*a(i,1)*hm.^2 + 2*b(i,1)*hm + c(i,1)).^2 + ...
(3*a(i,2)*hm.^2 + 2*b(i,2)*hm + c(i,2)).^2 );
hil = sqrt( (3*a(i,1)*hl.^2 + 2*b(i,1)*hl + c(i,1)).^2 + ...
(3*a(i,2)*hl.^2 + 2*b(i,2)*hl + c(i,2)).^2 );
As(3) = As(3) + (dh*sum(wl.*hil) - 0.5*dh*log(dh)*sum(w.*him))/(2*pi);
end
% As
A(j,i) = As(s);
end
end
end
function [G,Gx,Gy] = Gfn(x,y,x0,y0)
r2 = (x-x0).^2 + (y-y0).^2;
G = -1/(4*pi)*log(r2);
Gx = -1/(2*pi)*(x-x0)./r2;
Gy = -1/(2*pi)*(y-y0)./r2;
function I = doint(g)
global xi w a b c h N
I = 0;
for i = 1:N
hh = 0.5*(xi+1).*h(i);
hi = sqrt( (3*a(i,1)*hh.^2 + 2*b(i,1)*hh + c(i,1)).^2 ...
+ (3*a(i,2)*hh.^2 + 2*b(i,2)*hh + c(i,2)).^2 );
I = I + 0.5*h(i)*sum(w.*hi)*g(i);
end
function splot(x,y)
global a b c h N x0 y0
plot(x,y,x,y,’.’)
hold on
for j = 1:N
hh = h(j)*(0:0.01:1);
xs = a(j,1).*hh.^3 + b(j,1).*hh.^2 + c(j,1).*hh + x(j);
ys = a(j,2).*hh.^3 + b(j,2).*hh.^2 + c(j,2).*hh + y(j);
plot(xs,ys,’r’)
end
plot(x0,y0,’go’)
hold off
axis equal
genHyper.m
function [pfq]=genHyper(a,b,z,lnpfq,ix,nsigfig);
% function [pfq]=genHyper(a,b,z,lnpfq,ix,nsigfig)
% Description : A numerical evaluator for the generalized hypergeometric
% function for complex arguments with large magnitudes
% using a direct summation of the Gauss series.
% pFq isdefined by (borrowed from Maple):
% pFq = sum(z^k / k! * product(pochhammer(n[i], k), i=1..p) /
% product(pochhammer(d[j], k), j=1..q), k=0..infinity )
%
% INPUTS: a => array containing numerator parameters
% b => array containing denominator parameters
% z => complex argument (scalar)
% lnpfq => (optional) set to 1 if desired result is the natural
% log of pfq (default is 0)
% ix => (optional) maximum number of terms in a,b (see below)
% nsigfig => number of desired significant figures (default=10)
%
% OUPUT: pfq => result
%
% EXAMPLES: a=[1+i,1]; b=[2-i,3,3]; z=1.5;
% >> genHyper(a,b,z)
% ans =
% 1.02992154295955 + 0.106416425916656i
% or with more precision,
% >> genHyper(a,b,z,0,0,15)
% ans =
% 1.02992154295896 + 0.106416425915575i
% using the log option,
% >> genHyper(a,b,z,1,0,15)
% ans =
% 0.0347923403326305 + 0.102959427435454i
% >> exp(ans)
% ans =
% 1.02992154295896 + 0.106416425915575i
%
%
% Translated from the original fortran using f2matlab.m
% by Ben E. Barrowes - [email protected], 7/04.
%
%% Original fortran documentation
% ACPAPFQ. A NUMERICAL EVALUATOR FOR THE GENERALIZED HYPERGEOMETRIC
%
% 1 SERIES. W.F. PERGER, A. BHALLA, M. NARDIN.
%
% REF. IN COMP. PHYS. COMMUN. 77 (1993) 249
%
% ****************************************************************
% * *
% * SOLUTION TO THE GENERALIZED HYPERGEOMETRIC FUNCTION *
% * *
% * by *
% * *
% * W. F. PERGER, *
% * *
% * MARK NARDIN and ATUL BHALLA *
% * *
% * *
% * Electrical Engineering Department *
% * Michigan Technological University *
% * 1400 Townsend Drive *
% * Houghton, MI 49931-1295 USA *
% * Copyright 1993 *
% * *
% * e-mail address: [email protected] *
% * *
% * Description : A numerical evaluator for the generalized *
% * hypergeometric function for complex arguments with large *
% * magnitudes using a direct summation of the Gauss series. *
% * The method used allows an accuracy of up to thirteen *
% * decimal places through the use of large integer arrays *
% * and a single final division. *
% * (original subroutines for the confluent hypergeometric *
% * written by Mark Nardin, 1989; modifications made to cal- *
% * culate the generalized hypergeometric function were *
% * written by W.F. Perger and A. Bhalla, June, 1990) *
% * *
% * The evaluation of the pFq series is accomplished by a func- *
% * ion call to PFQ, which is a double precision complex func- *
% * tion. The required input is: *
% * 1. Double precision complex arrays A and B. These are the *
% * arrays containing the parameters in the numerator and de-*
% * nominator, respectively. *
% * 2. Integers IP and IQ. These integers indicate the number *
% * of numerator and denominator terms, respectively (these *
% * are p and q in the pFq function). *
% * 3. Double precision complex argument Z. *
% * 4. Integer LNPFQ. This integer should be set to ’1’ if the *
% * result from PFQ is to be returned as the natural logaritm*
% * of the series, or ’0’ if not. The user can generally set*
% * LNPFQ = ’0’ and change it if required. *
% * 5. Integer IX. This integer should be set to ’0’ if the *
% * user desires the program PFQ to estimate the number of *
% * array terms (in A and B) to be used, or an integer *
% * greater than zero specifying the number of integer pos- *
% * itions to be used. This input parameter is escpecially *
% * useful as a means to check the results of a given run. *
% * Specificially, if the user obtains a result for a given *
% * set of parameters, then changes IX and re-runs the eval- *
% * uator, and if the number of array positions was insuffi- *
% * cient, then the two results will likely differ. The rec-*
% * commended would be to generally set IX = ’0’ and then set*
% * it to 100 or so for a second run. Note that the LENGTH *
% * parameter currently sets the upper limit on IX to 777, *
% * but that can easily be changed (it is a single PARAMETER *
% * statement) and the program recompiled. *
% * 6. Integer NSIGFIG. This integer specifies the requested *
% * number of significant figures in the final result. If *
% * the user attempts to request more than the number of bits*
% * in the mantissa allows, the program will abort with an *
% * appropriate error message. The recommended value is 10. *
% * *
% * Note: The variable NOUT is the file to which error mess- *
% * ages are written (default is 6). This can be *
% * changed in the FUNCTION PFQ to accomodate re- *
% * of output to another file *
% * *
% * Subprograms called: HYPER. *
% * *
% ****************************************************************
%
%
%
%
if nargin<6
nsigfig=10;
elseif isempty(nsigfig)
nsigfig=10;
end
if nargin<5
ix=0;
elseif isempty(ix)
ix=0;
end
if nargin<4
lnpfq=0;
elseif isempty(lnpfq)
lnpfq=0;
end
ip=length(a);
iq=length(b);
global zero half one two ten eps;
[zero , half , one , two , ten , eps]=deal(0.0d0,0.5d0,1.0d0,2.0d0,10.0d0,1.0d-10);
global nout;
%
%
%
%
a1=zeros(2,1);b1=zeros(1,1);gam1=0;gam2=0;gam3=0;gam4=0;gam5=0;gam6=0;gam7=0;hyper1=0;hyper2=0;z1=0;
argi=0;argr=0;diff=0;dnum=0;precis=0;
%
%
i=0;
%
%
%
nout=6;
if ((lnpfq~=0) & (lnpfq~=1)) ;
’ error in input arguments: lnpfq ~= 0 or 1’,
error(’stop encountered in original fortran code’);
end;
if ((ip>iq) & (abs(z)>one)) ;
ip , iq , abs(z),
%format [,1x,’ip=’,1i2,3x,’iq=’,1i2,3x,’and abs(z)=’,1e12.5,2x,./,’ which is greater than one--series does’,’ not converge’);
error(’stop encountered in original fortran code’);
end;
if (ip==2 & iq==1 & abs(z)>0.9) ;
if (lnpfq~=1) ;
%
% Check to see if the Gamma function arguments are o.k.; if not,
%
% then the series will have to be used.
%
%
%
% PRECIS - MACHINE PRECISION
%
%
precis=one;
precis=precis./two;
dnum=precis+one;
while (dnum>one);
precis=precis./two;
dnum=precis+one;
end;
precis=two.*precis;
for i=1 : 6;
if (i==1) ;
argi=imag(b(1));
argr=real(b(1));
elseif (i==2);
argi=imag(b(1)-a(1)-a(2));
argr=real(b(1)-a(1)-a(2));
elseif (i==3);
argi=imag(b(1)-a(1));
argr=real(b(1)-a(1));
elseif (i==4);
argi=imag(a(1)+a(2)-b(1));
argr=real(a(1)+a(2)-b(1));
elseif (i==5);
argi=imag(a(1));
argr=real(a(1));
elseif (i==6);
argi=imag(a(2));
argr=real(a(2));
end;
%
% CASES WHERE THE ARGUMENT IS REAL
%
%
if (argi==0.0) ;
%
% CASES WHERE THE ARGUMENT IS REAL AND NEGATIVE
%
%
if (argr<=0.0) ;
%
% USE THE SERIES EXPANSION IF THE ARGUMENT IS TOO NEAR A POLE
%
%
diff=abs(real(round(argr))-argr);
if (diff<=two.*precis) ;
pfq=hyper(a,b,ip,iq,z,lnpfq,ix,nsigfig);
return;
end;
end;
end;
end;
gam1=cgamma(b(1),lnpfq);
gam2=cgamma(b(1)-a(1)-a(2),lnpfq);
gam3=cgamma(b(1)-a(1),lnpfq);
gam4=cgamma(b(1)-a(2),lnpfq);
gam5=cgamma(a(1)+a(2)-b(1),lnpfq);
gam6=cgamma(a(1),lnpfq);
gam7=cgamma(a(2),lnpfq);
a1(1)=a(1);
a1(2)=a(2);
b1(1)=a(1)+a(2)-b(1)+one;
z1=one-z;
hyper1=hyper(a1,b1,ip,iq,z1,lnpfq,ix,nsigfig);
a1(1)=b(1)-a(1);
a1(2)=b(1)-a(2);
b1(1)=b(1)-a(1)-a(2)+one;
hyper2=hyper(a1,b1,ip,iq,z1,lnpfq,ix,nsigfig);
pfq=gam1.*gam2.*hyper1./(gam3.*gam4)+(one-z).^(b(1)-a(1)-a(2)).*gam1.*gam5.*hyper2./(gam6.*gam7);
return;
end;
end;
pfq=hyper(a,b,ip,iq,z,lnpfq,ix,nsigfig);
return;
% ****************************************************************
% * *
% * FUNCTION BITS *
% * *
% * *
% * Description : Determines the number of significant figures *
% * of machine precision to arrive at the size of the array *
% * the numbers must be stored in to get the accuracy of the *
% * solution. *
% * *
% * Subprograms called: none *
% * *
% ****************************************************************
%
function [bits]=bits;
%
bit2=0;
%
%
%
bit=1.0;
nnz=0;
nnz=nnz+1;
bit2=bit.*2.0;
bit=bit2+1.0;
while ((bit-bit2)~=0.0);
nnz=nnz+1;
bit2=bit.*2.0;
bit=bit2+1.0;
end;
bits=nnz-3;
% ****************************************************************
% * *
% * FUNCTION HYPER *
% * *
% * *
% * Description : Function that sums the Gauss series. *
% * *
% * Subprograms called: ARMULT, ARYDIV, BITS, CMPADD, CMPMUL, *
% * IPREMAX. *
% * *
% ****************************************************************
%
function [hyper]=hyper(a,b,ip,iq,z,lnpfq,ix,nsigfig);
%
%
% PARAMETER definitions
%
sumr=[];sumi=[];denomr=[];denomi=[];final=[];l=[];rmax=[];ibit=[];temp=[];cr=[];i1=[];ci=[];qr1=[];qi1=[];wk1=[];wk2=[];wk3=[];wk4=[];wk5=[];wk6=[];cr2=[];ci2=[];qr2=[];qi2=[];foo1=[];cnt=[];foo2=[];sigfig=[];numr=[];numi=[];ar=[];ai=[];ar2=[];ai2=[];xr=[];xi=[];xr2=[];xi2=[];bar1=[];bar2=[];
length=0;
length=777;
%
%
global zero half one two ten eps;
global nout;
%
%
%
%
accy=0;ai=zeros(10,1);ai2=zeros(10,1);ar=zeros(10,1);ar2=zeros(10,1);ci=zeros(10,1);ci2=zeros(10,1);cnt=0;cr=zeros(10,1);cr2=zeros(10,1);creal=0;denomi=zeros(length+2,1);denomr=zeros(length+2,1);dum1=0;dum2=0;expon=0;log2=0;mx1=0;mx2=0;numi=zeros(length+2,1);numr=zeros(length+2,1);qi1=zeros(length+2,1);qi2=zeros(length+2,1);qr1=zeros(length+2,1);qr2=zeros(length+2,1);ri10=0;rmax=0;rr10=0;sigfig=0;sumi=zeros(length+2,1);sumr=zeros(length+2,1);wk1=zeros(length+2,1);wk2=zeros(length+2,1);wk3=zeros(length+2,1);wk4=zeros(length+2,1);wk5=zeros(length+2,1);wk6=zeros(length+2,1);x=0;xi=0;xi2=0;xl=0;xr=0;xr2=0;
%
cdum1=0;cdum2=0;final=0;oldtemp=0;temp=0;temp1=0;
%
%
%
i=0;i1=0;ibit=0;icount=0;ii10=0;ir10=0;ixcnt=0;l=0;lmax=0;nmach=0;rexp=0;
%
%
%
goon1=0;
foo1=zeros(length+2,1);foo2=zeros(length+2,1);bar1=zeros(length+2,1);bar2=zeros(length+2,1);
%
%
zero=0.0d0;
log2=log10(two);
ibit=fix(bits);
rmax=two.^(fix(ibit./2));
sigfig=two.^(fix(ibit./4));
%
for i1=1 : ip;
ar2(i1)=real(a(i1)).*sigfig;
ar(i1)=fix(ar2(i1));
ar2(i1)=round((ar2(i1)-ar(i1)).*rmax);
ai2(i1)=imag(a(i1)).*sigfig;
ai(i1)=fix(ai2(i1));
ai2(i1)=round((ai2(i1)-ai(i1)).*rmax);
end;
for i1=1 : iq;
cr2(i1)=real(b(i1)).*sigfig;
cr(i1)=fix(cr2(i1));
cr2(i1)=round((cr2(i1)-cr(i1)).*rmax);
ci2(i1)=imag(b(i1)).*sigfig;
ci(i1)=fix(ci2(i1));
ci2(i1)=round((ci2(i1)-ci(i1)).*rmax);
end;
xr2=real(z).*sigfig;
xr=fix(xr2);
xr2=round((xr2-xr).*rmax);
xi2=imag(z).*sigfig;
xi=fix(xi2);
xi2=round((xi2-xi).*rmax);
%
% WARN THE USER THAT THE INPUT VALUE WAS SO CLOSE TO ZERO THAT IT
% WAS SET EQUAL TO ZERO.
%
for i1=1 : ip;
if ((real(a(i1))~=0.0) & (ar(i1)==0.0) & (ar2(i1)==0.0));
i1,
end;
%format (1x,’warning - real part of a(’,1i2,’) was set to zero’);
if ((imag(a(i1))~=0.0) & (ai(i1)==0.0) & (ai2(i1)==0.0));
i1,
end;
%format (1x,’warning - imag part of a(’,1i2,’) was set to zero’);
end;
for i1=1 : iq;
if ((real(b(i1))~=0.0) & (cr(i1)==0.0) & (cr2(i1)==0.0));
i1,
end;
%format (1x,’warning - real part of b(’,1i2,’) was set to zero’);
if ((imag(b(i1))~=0.0) & (ci(i1)==0.0) & (ci2(i1)==0.0));
i1,
end;
%format (1x,’warning - imag part of b(’,1i2,’) was set to zero’);
end;
if ((real(z)~=0.0) & (xr==0.0) & (xr2==0.0)) ;
’ warning - real part of z was set to zero’,
z=complex(0.0,imag(z));
end;
if ((imag(z)~=0.0) & (xi==0.0) & (xi2==0.0)) ;
’ warning - imag part of z was set to zero’,
z=complex(real(z),0.0);
end;
%
%
% SCREENING OF NUMERATOR ARGUMENTS FOR NEGATIVE INTEGERS OR ZERO.
% ICOUNT WILL FORCE THE SERIES TO TERMINATE CORRECTLY.
%
nmach=fix(log10(two.^fix(bits)));
icount=-1;
for i1=1 : ip;
if ((ar2(i1)==0.0) & (ar(i1)==0.0) & (ai2(i1)==0.0) &(ai(i1)==0.0)) ;
hyper=complex(one,0.0);
return;
end;
if ((ai(i1)==0.0) & (ai2(i1)==0.0) & (real(a(i1))<0.0));
if (abs(real(a(i1))-real(round(real(a(i1)))))<ten.^(-nmach)) ;
if (icount~=-1) ;
icount=min([icount,-round(real(a(i1)))]);
else;
icount=-round(real(a(i1)));
end;
end;
end;
end;
%
% SCREENING OF DENOMINATOR ARGUMENTS FOR ZEROES OR NEGATIVE INTEGERS
% .
%
for i1=1 : iq;
if ((cr(i1)==0.0) & (cr2(i1)==0.0) & (ci(i1)==0.0) &(ci2(i1)==0.0)) ;
i1,
%format (1x,’error - argument b(’,1i2,’) was equal to zero’);
error(’stop encountered in original fortran code’);
end;
if ((ci(i1)==0.0) & (ci2(i1)==0.0) & (real(b(i1))<0.0));
if ((abs(real(b(i1))-real(round(real(b(i1)))))<ten.^(-nmach)) &(icount>=-round(real(b(i1))) | icount==-1)) ;
i1,
%format (1x,’error - argument b(’,1i2,’) was a negative’,’ integer’);
error(’stop encountered in original fortran code’);
end;
end;
end;
%
nmach=fix(log10(two.^ibit));
nsigfig=min([nsigfig,fix(log10(two.^ibit))]);
accy=ten.^(-nsigfig);
l=ipremax(a,b,ip,iq,z);
if (l~=1) ;
%
% First, estimate the exponent of the maximum term in the pFq series
% .
%
expon=0.0;
xl=real(l);
for i=1 : ip;
expon=expon+real(factor(a(i)+xl-one))-real(factor(a(i)-one));
end;
for i=1 : iq;
expon=expon-real(factor(b(i)+xl-one))+real(factor(b(i)-one));
end;
expon=expon+xl.*real(log(z))-real(factor(complex(xl,0.0)));
lmax=fix(log10(exp(one)).*expon);
l=lmax;
%
% Now, estimate the exponent of where the pFq series will terminate.
%
temp1=complex(one,0.0);
creal=one;
for i1=1 : ip;
temp1=temp1.*complex(ar(i1),ai(i1))./sigfig;
end;
for i1=1 : iq;
temp1=temp1./(complex(cr(i1),ci(i1))./sigfig);
creal=creal.*cr(i1);
end;
temp1=temp1.*complex(xr,xi);
%
% Triple it to make sure.
%
l=3.*l;
%
% Divide the number of significant figures necessary by the number
% of
% digits available per array position.
%
%
l=fix((2.*l+nsigfig)./nmach)+2;
end;
%
% Make sure there are at least 5 array positions used.
%
l=max([l,5]);
l=max([l,ix]);
% write (6,*) ’ Estimated value of L=’,L
if ((l<0) | (l>length)) ;
length,
%format (1x,[’error in fn hyper: l must be < ’],1i4);
error(’stop encountered in original fortran code’);
end;
if (nsigfig>nmach) ;
nmach,
%format (1x,’ warning--the number of significant figures requ’,’ested’,./,’is greater than the machine precision--’,’final answer’,./,’will be accurate to only’,i3,’ digits’);
end;
%
sumr(-1+2)=one;
sumi(-1+2)=one;
numr(-1+2)=one;
numi(-1+2)=one;
denomr(-1+2)=one;
denomi(-1+2)=one;
for i=0 : l+1;
sumr(i+2)=0.0;
sumi(i+2)=0.0;
numr(i+2)=0.0;
numi(i+2)=0.0;
denomr(i+2)=0.0;
denomi(i+2)=0.0;
end;
sumr(1+2)=one;
numr(1+2)=one;
denomr(1+2)=one;
cnt=sigfig;
temp=complex(0.0,0.0);
oldtemp=temp;
ixcnt=0;
rexp=fix(ibit./2);
x=rexp.*(sumr(l+1+2)-2);
rr10=x.*log2;
ir10=fix(rr10);
rr10=rr10-ir10;
x=rexp.*(sumi(l+1+2)-2);
ri10=x.*log2;
ii10=fix(ri10);
ri10=ri10-ii10;
dum1=(abs(sumr(1+2).*rmax.*rmax+sumr(2+2).*rmax+sumr(3+2)).*sign(sumr(-1+2)));
dum2=(abs(sumi(1+2).*rmax.*rmax+sumi(2+2).*rmax+sumi(3+2)).*sign(sumi(-1+2)));
dum1=dum1.*10.^rr10;
dum2=dum2.*10.^ri10;
cdum1=complex(dum1,dum2);
x=rexp.*(denomr(l+1+2)-2);
rr10=x.*log2;
ir10=fix(rr10);
rr10=rr10-ir10;
x=rexp.*(denomi(l+1+2)-2);
ri10=x.*log2;
ii10=fix(ri10);
ri10=ri10-ii10;
dum1=(abs(denomr(1+2).*rmax.*rmax+denomr(2+2).*rmax+denomr(3+2)).*sign(denomr(-1+2)));
dum2=(abs(denomi(1+2).*rmax.*rmax+denomi(2+2).*rmax+denomi(3+2)).*sign(denomi(-1+2)));
dum1=dum1.*10.^rr10;
dum2=dum2.*10.^ri10;
cdum2=complex(dum1,dum2);
temp=cdum1./cdum2;
%
% 130 IF (IP .GT. 0) THEN
goon1=1;
while (goon1==1);
goon1=0;
if (ip<0) ;
if (sumr(1+2)<half) ;
mx1=sumi(l+1+2);
elseif (sumi(1+2)<half);
mx1=sumr(l+1+2);
else;
mx1=max([sumr(l+1+2),sumi(l+1+2)]);
end;
if (numr(1+2)<half) ;
mx2=numi(l+1+2);
elseif (numi(1+2)<half);
mx2=numr(l+1+2);
else;
mx2=max([numr(l+1+2),numi(l+1+2)]);
end;
if (mx1-mx2>2.0) ;
if (creal>=0.0) ;
% write (6,*) ’ cdabs(temp1/cnt)=’,cdabs(temp1/cnt)
%
if (abs(temp1./cnt)<=one) ;
[sumr,sumi,denomr,denomi,final,l,lnpfq,rmax,ibit]=arydiv(sumr,sumi,denomr,denomi,final,l,lnpfq,rmax,ibit);
hyper=final;
return;
end;
end;
end;
else;
[sumr,sumi,denomr,denomi,temp,l,lnpfq,rmax,ibit]=arydiv(sumr,sumi,denomr,denomi,temp,l,lnpfq,rmax,ibit);
%
% First, estimate the exponent of the maximum term in the pFq
% series.
%
expon=0.0;
xl=real(ixcnt);
for i=1 : ip;
expon=expon+real(factor(a(i)+xl-one))-real(factor(a(i)-one));
end;
for i=1 : iq;
expon=expon-real(factor(b(i)+xl-one))+real(factor(b(i)-one));
end;
expon=expon+xl.*real(log(z))-real(factor(complex(xl,0.0)));
lmax=fix(log10(exp(one)).*expon);
if (abs(oldtemp-temp)<abs(temp.*accy)) ;
[sumr,sumi,denomr,denomi,final,l,lnpfq,rmax,ibit]=arydiv(sumr,sumi,denomr,denomi,final,l,lnpfq,rmax,ibit);
hyper=final;
return;
end;
oldtemp=temp;
end;
if (ixcnt~=icount) ;
ixcnt=ixcnt+1;
for i1=1 : iq;
%
% TAKE THE CURRENT SUM AND MULTIPLY BY THE DENOMINATOR OF THE NEXT
%
% TERM, FOR BOTH THE MOST SIGNIFICANT HALF (CR,CI) AND THE LEAST
%
% SIGNIFICANT HALF (CR2,CI2).
%
%
[sumr,sumi,cr(i1),ci(i1),qr1,qi1,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax]=cmpmul(sumr,sumi,cr(i1),ci(i1),qr1,qi1,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax);
[sumr,sumi,cr2(i1),ci2(i1),qr2,qi2,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax]=cmpmul(sumr,sumi,cr2(i1),ci2(i1),qr2,qi2,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax);
qr2(l+1+2)=qr2(l+1+2)-1;
qi2(l+1+2)=qi2(l+1+2)-1;
%
% STORE THIS TEMPORARILY IN THE SUM ARRAYS.
%
%
[qr1,qi1,qr2,qi2,sumr,sumi,wk1,l,rmax]=cmpadd(qr1,qi1,qr2,qi2,sumr,sumi,wk1,l,rmax);
end;
%
%
% MULTIPLY BY THE FACTORIAL TERM.
%
foo1=sumr;
foo2=sumr;
[foo1,cnt,foo2,wk6,l,rmax]=armult(foo1,cnt,foo2,wk6,l,rmax);
sumr=foo2;
foo1=sumi;
foo2=sumi;
[foo1,cnt,foo2,wk6,l,rmax]=armult(foo1,cnt,foo2,wk6,l,rmax);
sumi=foo2;
%
% MULTIPLY BY THE SCALING FACTOR, SIGFIG, TO KEEP THE SCALE CORRECT.
%
for i1=1 : ip-iq;
foo1=sumr;
foo2=sumr;
[foo1,sigfig,foo2,wk6,l,rmax]=armult(foo1,sigfig,foo2,wk6,l,rmax);
sumr=foo2;
foo1=sumi;
foo2=sumi;
[foo1,sigfig,foo2,wk6,l,rmax]=armult(foo1,sigfig,foo2,wk6,l,rmax);
sumi=foo2;
end;
for i1=1 : iq;
%
% UPDATE THE DENOMINATOR.
%
%
[denomr,denomi,cr(i1),ci(i1),qr1,qi1,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax]=cmpmul(denomr,denomi,cr(i1),ci(i1),qr1,qi1,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax);
[denomr,denomi,cr2(i1),ci2(i1),qr2,qi2,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax]=cmpmul(denomr,denomi,cr2(i1),ci2(i1),qr2,qi2,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax);
qr2(l+1+2)=qr2(l+1+2)-1;
qi2(l+1+2)=qi2(l+1+2)-1;
[qr1,qi1,qr2,qi2,denomr,denomi,wk1,l,rmax]=cmpadd(qr1,qi1,qr2,qi2,denomr,denomi,wk1,l,rmax);
end;
%
%
% MULTIPLY BY THE FACTORIAL TERM.
%
foo1=denomr;
foo2=denomr;
[foo1,cnt,foo2,wk6,l,rmax]=armult(foo1,cnt,foo2,wk6,l,rmax);
denomr=foo2;
foo1=denomi;
foo2=denomi;
[foo1,cnt,foo2,wk6,l,rmax]=armult(foo1,cnt,foo2,wk6,l,rmax);
denomi=foo2;
%
% MULTIPLY BY THE SCALING FACTOR, SIGFIG, TO KEEP THE SCALE CORRECT.
%
for i1=1 : ip-iq;
foo1=denomr;
foo2=denomr;
[foo1,sigfig,foo2,wk6,l,rmax]=armult(foo1,sigfig,foo2,wk6,l,rmax);
denomr=foo2;
foo1=denomi;
foo2=denomi;
[foo1,sigfig,foo2,wk6,l,rmax]=armult(foo1,sigfig,foo2,wk6,l,rmax);
denomi=foo2;
end;
%
% FORM THE NEXT NUMERATOR TERM BY MULTIPLYING THE CURRENT
% NUMERATOR TERM (AN ARRAY) WITH THE A ARGUMENT (A SCALAR).
%
for i1=1 : ip;
[numr,numi,ar(i1),ai(i1),qr1,qi1,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax]=cmpmul(numr,numi,ar(i1),ai(i1),qr1,qi1,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax);
[numr,numi,ar2(i1),ai2(i1),qr2,qi2,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax]=cmpmul(numr,numi,ar2(i1),ai2(i1),qr2,qi2,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax);
qr2(l+1+2)=qr2(l+1+2)-1;
qi2(l+1+2)=qi2(l+1+2)-1;
[qr1,qi1,qr2,qi2,numr,numi,wk1,l,rmax]=cmpadd(qr1,qi1,qr2,qi2,numr,numi,wk1,l,rmax);
end;
%
% FINISH THE NEW NUMERATOR TERM BY MULTIPLYING BY THE Z ARGUMENT.
%
[numr,numi,xr,xi,qr1,qi1,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax]=cmpmul(numr,numi,xr,xi,qr1,qi1,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax);
[numr,numi,xr2,xi2,qr2,qi2,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax]=cmpmul(numr,numi,xr2,xi2,qr2,qi2,wk1,wk2,wk3,wk4,wk5,wk6,l,rmax);
qr2(l+1+2)=qr2(l+1+2)-1;
qi2(l+1+2)=qi2(l+1+2)-1;
[qr1,qi1,qr2,qi2,numr,numi,wk1,l,rmax]=cmpadd(qr1,qi1,qr2,qi2,numr,numi,wk1,l,rmax);
%
% MULTIPLY BY THE SCALING FACTOR, SIGFIG, TO KEEP THE SCALE CORRECT.
%
for i1=1 : iq-ip;
foo1=numr;
foo2=numr;
[foo1,sigfig,foo2,wk6,l,rmax]=armult(foo1,sigfig,foo2,wk6,l,rmax);
numr=foo2;
foo1=numi;
foo2=numi;
[foo1,sigfig,foo2,wk6,l,rmax]=armult(foo1,sigfig,foo2,wk6,l,rmax);
numi=foo2;
end;
%
% FINALLY, ADD THE NEW NUMERATOR TERM WITH THE CURRENT RUNNING
% SUM OF THE NUMERATOR AND STORE THE NEW RUNNING SUM IN SUMR, SUMI.
%
foo1=sumr;
foo2=sumr;
bar1=sumi;
bar2=sumi;
[foo1,bar1,numr,numi,foo2,bar2,wk1,l,rmax]=cmpadd(foo1,bar1,numr,numi,foo2,bar2,wk1,l,rmax);
sumi=bar2;
sumr=foo2;
%
% BECAUSE SIGFIG REPRESENTS "ONE" ON THE NEW SCALE, ADD SIGFIG
% TO THE CURRENT COUNT AND, CONSEQUENTLY, TO THE IP ARGUMENTS
% IN THE NUMERATOR AND THE IQ ARGUMENTS IN THE DENOMINATOR.
%
cnt=cnt+sigfig;
for i1=1 : ip;
ar(i1)=ar(i1)+sigfig;
end;
for i1=1 : iq;
cr(i1)=cr(i1)+sigfig;
end;
goon1=1;
end;
end;
[sumr,sumi,denomr,denomi,final,l,lnpfq,rmax,ibit]=arydiv(sumr,sumi,denomr,denomi,final,l,lnpfq,rmax,ibit);
% write (6,*) ’Number of terms=’,ixcnt
hyper=final;
return;
%
% ****************************************************************
% * *
% * SUBROUTINE ARADD *
% * *
% * *
% * Description : Accepts two arrays of numbers and returns *
% * the sum of the array. Each array is holding the value *
% * of one number in the series. The parameter L is the *
% * size of the array representing the number and RMAX is *
% * the actual number of digits needed to give the numbers *
% * the desired accuracy. *
% * *
% * Subprograms called: none *
% * *
% ****************************************************************
%
function [a,b,c,z,l,rmax]=aradd(a,b,c,z,l,rmax);
%
%
global zero half one two ten eps;
%
%
%
ediff=0;i=0;j=0;
%
%
for i=0 : l+1;
z(i+2)=0.0;
end;
ediff=round(a(l+1+2)-b(l+1+2));
if (abs(a(1+2))<half | ediff<=-l) ;
for i=-1 : l+1;
c(i+2)=b(i+2);
end;
if (c(1+2)<half) ;
c(-1+2)=one;
c(l+1+2)=0.0;
end;
return;
else;
if (abs(b(1+2))<half | ediff>=l) ;
for i=-1 : l+1;
c(i+2)=a(i+2);
end;
if (c(1+2)<half) ;
c(-1+2)=one;
c(l+1+2)=0.0;
end;
return;
else;
z(-1+2)=a(-1+2);
goon300=1;
goon190=1;
if (abs(a(-1+2)-b(-1+2))>=half) ;
goon300=0;
if (ediff>0) ;
z(l+1+2)=a(l+1+2);
elseif (ediff<0);
z(l+1+2)=b(l+1+2);
z(-1+2)=b(-1+2);
goon190=0;
else;
for i=1 : l;
if (a(i+2)>b(i+2)) ;
z(l+1+2)=a(l+1+2);
break;
end;
if (a(i+2)<b(i+2)) ;
z(l+1+2)=b(l+1+2);
z(-1+2)=b(-1+2);
goon190=0;
end;
end;
end;
%
elseif (ediff>0);
z(l+1+2)=a(l+1+2);
for i=l : -1: 1+ediff ;
z(i+2)=a(i+2)+b(i-ediff+2)+z(i+2);
if (z(i+2)>=rmax) ;
z(i+2)=z(i+2)-rmax;
z(i-1+2)=one;
end;
end;
for i=ediff : -1: 1 ;
z(i+2)=a(i+2)+z(i+2);
if (z(i+2)>=rmax) ;
z(i+2)=z(i+2)-rmax;
z(i-1+2)=one;
end;
end;
if (z(0+2)>half) ;
for i=l : -1: 1 ;
z(i+2)=z(i-1+2);
end;
z(l+1+2)=z(l+1+2)+1;
z(0+2)=0.0;
end;
elseif (ediff<0);
z(l+1+2)=b(l+1+2);
for i=l : -1: 1-ediff ;
z(i+2)=a(i+ediff+2)+b(i+2)+z(i+2);
if (z(i+2)>=rmax) ;
z(i+2)=z(i+2)-rmax;
z(i-1+2)=one;
end;
end;
for i=0-ediff : -1: 1 ;
z(i+2)=b(i+2)+z(i+2);
if (z(i+2)>=rmax) ;
z(i+2)=z(i+2)-rmax;
z(i-1+2)=one;
end;
end;
if (z(0+2)>half) ;
for i=l : -1: 1 ;
z(i+2)=z(i-1+2);
end;
z(l+1+2)=z(l+1+2)+one;
z(0+2)=0.0;
end;
else;
z(l+1+2)=a(l+1+2);
for i=l : -1: 1 ;
z(i+2)=a(i+2)+b(i+2)+z(i+2);
if (z(i+2)>=rmax) ;
z(i+2)=z(i+2)-rmax;
z(i-1+2)=one;
end;
end;
if (z(0+2)>half) ;
for i=l : -1: 1 ;
z(i+2)=z(i-1+2);
end;
z(l+1+2)=z(l+1+2)+one;
z(0+2)=0.0;
end;
end;
if (goon300==1) ;
i=i; %here is the line that had a +1 taken from it.
while (z(i+2)<half & i<l+1);
i=i+1;
end;
if (i==l+1) ;
z(-1+2)=one;
z(l+1+2)=0.0;
for i=-1 : l+1;
c(i+2)=z(i+2);
end;
if (c(1+2)<half) ;
c(-1+2)=one;
c(l+1+2)=0.0;
end;
return;
end;
for j=1 : l+1-i;
z(j+2)=z(j+i-1+2);
end;
for j=l+2-i : l;
z(j+2)=0.0;
end;
z(l+1+2)=z(l+1+2)-i+1;
for i=-1 : l+1;
c(i+2)=z(i+2);
end;
if (c(1+2)<half) ;
c(-1+2)=one;
c(l+1+2)=0.0;
end;
return;
end;
%
if (goon190==1) ;
if (ediff>0) ;
for i=l : -1: 1+ediff ;
z(i+2)=a(i+2)-b(i-ediff+2)+z(i+2);
if (z(i+2)<0.0) ;
z(i+2)=z(i+2)+rmax;
z(i-1+2)=-one;
end;
end;
for i=ediff : -1: 1 ;
z(i+2)=a(i+2)+z(i+2);
if (z(i+2)<0.0) ;
z(i+2)=z(i+2)+rmax;
z(i-1+2)=-one;
end;
end;
else;
for i=l : -1: 1 ;
z(i+2)=a(i+2)-b(i+2)+z(i+2);
if (z(i+2)<0.0) ;
z(i+2)=z(i+2)+rmax;
z(i-1+2)=-one;
end;
end;
end;
if (z(1+2)>half) ;
for i=-1 : l+1;
c(i+2)=z(i+2);
end;
if (c(1+2)<half) ;
c(-1+2)=one;
c(l+1+2)=0.0;
end;
return;
end;
i=1;
i=i+1;
while (z(i+2)<half & i<l+1);
i=i+1;
end;
if (i==l+1) ;
z(-1+2)=one;
z(l+1+2)=0.0;
for i=-1 : l+1;
c(i+2)=z(i+2);
end;
if (c(1+2)<half) ;
c(-1+2)=one;
c(l+1+2)=0.0;
end;
return;
end;
for j=1 : l+1-i;
z(j+2)=z(j+i-1+2);
end;
for j=l+2-i : l;
z(j+2)=0.0;
end;
z(l+1+2)=z(l+1+2)-i+1;
for i=-1 : l+1;
c(i+2)=z(i+2);
end;
if (c(1+2)<half) ;
c(-1+2)=one;
c(l+1+2)=0.0;
end;
return;
end;
end;
%
if (ediff<0) ;
for i=l : -1: 1-ediff ;
z(i+2)=b(i+2)-a(i+ediff+2)+z(i+2);
if (z(i+2)<0.0) ;
z(i+2)=z(i+2)+rmax;
z(i-1+2)=-one;
end;
end;
for i=0-ediff : -1: 1 ;
z(i+2)=b(i+2)+z(i+2);
if (z(i+2)<0.0) ;
z(i+2)=z(i+2)+rmax;
z(i-1+2)=-one;
end;
end;
else;
for i=l : -1: 1 ;
z(i+2)=b(i+2)-a(i+2)+z(i+2);
if (z(i+2)<0.0) ;
z(i+2)=z(i+2)+rmax;
z(i-1+2)=-one;
end;
end;
end;
end;
%
if (z(1+2)>half) ;
for i=-1 : l+1;
c(i+2)=z(i+2);
end;
if (c(1+2)<half) ;
c(-1+2)=one;
c(l+1+2)=0.0;
end;
return;
end;
i=1;
i=i+1;
while (z(i+2)<half & i<l+1);
i=i+1;
end;
if (i==l+1) ;
z(-1+2)=one;
z(l+1+2)=0.0;
for i=-1 : l+1;
c(i+2)=z(i+2);
end;
if (c(1+2)<half) ;
c(-1+2)=one;
c(l+1+2)=0.0;
end;
return;
end;
for j=1 : l+1-i;
z(j+2)=z(j+i-1+2);
end;
for j=l+2-i : l;
z(j+2)=0.0;
end;
z(l+1+2)=z(l+1+2)-i+1;
for i=-1 : l+1;
c(i+2)=z(i+2);
end;
if (c(1+2)<half) ;
c(-1+2)=one;
c(l+1+2)=0.0;
end;
%
%
% ****************************************************************
% * *
% * SUBROUTINE ARSUB *
% * *
% * *
% * Description : Accepts two arrays and subtracts each element *
% * in the second array from the element in the first array *
% * and returns the solution. The parameters L and RMAX are *
% * the size of the array and the number of digits needed for *
% * the accuracy, respectively. *
% * *
% * Subprograms called: ARADD *
% * *
% ****************************************************************
%
function [a,b,c,wk1,wk2,l,rmax]=arsub(a,b,c,wk1,wk2,l,rmax);
%
%
global zero half one two ten eps;
%
%
%
i=0;
%
%
for i=-1 : l+1;
wk2(i+2)=b(i+2);
end;
wk2(-1+2)=(-one).*wk2(-1+2);
[a,wk2,c,wk1,l,rmax]=aradd(a,wk2,c,wk1,l,rmax);
%
%
% ****************************************************************
% * *
% * SUBROUTINE ARMULT *
% * *
% * *
% * Description : Accepts two arrays and returns the product. *
% * L and RMAX are the size of the arrays and the number of *
% * digits needed to represent the numbers with the required *
% * accuracy. *
% * *
% * Subprograms called: none *
% * *
% ****************************************************************
%
function [a,b,c,z,l,rmax]=armult(a,b,c,z,l,rmax);
%
%
global zero half one two ten eps;
%
%
%
b2=0;carry=0;
i=0;
%
%
z(-1+2)=(abs(one).*sign(b)).*a(-1+2);
b2=abs(b);
z(l+1+2)=a(l+1+2);
for i=0 : l;
z(i+2)=0.0;
end;
if (b2<=eps | a(1+2)<=eps) ;
z(-1+2)=one;
z(l+1+2)=0.0;
else;
for i=l : -1: 1 ;
z(i+2)=a(i+2).*b2+z(i+2);
if (z(i+2)>=rmax) ;
carry=fix(z(i+2)./rmax);
z(i+2)=z(i+2)-carry.*rmax;
z(i-1+2)=carry;
end;
end;
if (z(0+2)>=half) ;
for i=l : -1: 1 ;
z(i+2)=z(i-1+2);
end;
z(l+1+2)=z(l+1+2)+one;
if (z(1+2)>=rmax) ;
for i=l : -1: 1 ;
z(i+2)=z(i-1+2);
end;
carry=fix(z(1+2)./rmax);
z(2+2)=z(2+2)-carry.*rmax;
z(1+2)=carry;
z(l+1+2)=z(l+1+2)+one;
end;
z(0+2)=0.0;
end;
end;
for i=-1 : l+1;
c(i+2)=z(i+2);
end;
if (c(1+2)<half) ;
c(-1+2)=one;
c(l+1+2)=0.0;
end;
%
% ****************************************************************
% * *
% * SUBROUTINE CMPADD *
% * *
% * *
% * Description : Takes two arrays representing one real and *
% * one imaginary part, and adds two arrays representing *
% * another complex number and returns two array holding the *
% * complex sum. *
% * (CR,CI) = (AR+BR, AI+BI) *
% * *
% * Subprograms called: ARADD *
% * *
% ****************************************************************
%
function [ar,ai,br,bi,cr,ci,wk1,l,rmax]=cmpadd(ar,ai,br,bi,cr,ci,wk1,l,rmax);
%
%
%
%
%
%
[ar,br,cr,wk1,l,rmax]=aradd(ar,br,cr,wk1,l,rmax);
[ai,bi,ci,wk1,l,rmax]=aradd(ai,bi,ci,wk1,l,rmax);
%
%
% ****************************************************************
% * *
% * SUBROUTINE CMPSUB *
% * *
% * *
% * Description : Takes two arrays representing one real and *
% * one imaginary part, and subtracts two arrays representing *
% * another complex number and returns two array holding the *
% * complex sum. *
% * (CR,CI) = (AR+BR, AI+BI) *
% * *
% * Subprograms called: ARADD *
% * *
% ****************************************************************
%
function [ar,ai,br,bi,cr,ci,wk1,wk2,l,rmax]=cmpsub(ar,ai,br,bi,cr,ci,wk1,wk2,l,rmax);
%
%
%
%
%
%
[ar,br,cr,wk1,wk2,l,rmax]=arsub(ar,br,cr,wk1,wk2,l,rmax);
[ai,bi,ci,wk1,wk2,l,rmax]=arsub(ai,bi,ci,wk1,wk2,l,rmax);
%
%
% ****************************************************************
% * *
% * SUBROUTINE CMPMUL *
% * *
% * *
% * Description : Takes two arrays representing one real and *
% * one imaginary part, and multiplies it with two arrays *
% * representing another complex number and returns the *
% * complex product. *
% * *
% * Subprograms called: ARMULT, ARSUB, ARADD *
% * *
% ****************************************************************
%
function [ar,ai,br,bi,cr,ci,wk1,wk2,cr2,d1,d2,wk6,l,rmax]=cmpmul(ar,ai,br,bi,cr,ci,wk1,wk2,cr2,d1,d2,wk6,l,rmax);
%
%
%
%
i=0;
%
%
[ar,br,d1,wk6,l,rmax]=armult(ar,br,d1,wk6,l,rmax);
[ai,bi,d2,wk6,l,rmax]=armult(ai,bi,d2,wk6,l,rmax);
[d1,d2,cr2,wk1,wk2,l,rmax]=arsub(d1,d2,cr2,wk1,wk2,l,rmax);
[ar,bi,d1,wk6,l,rmax]=armult(ar,bi,d1,wk6,l,rmax);
[ai,br,d2,wk6,l,rmax]=armult(ai,br,d2,wk6,l,rmax);
[d1,d2,ci,wk1,l,rmax]=aradd(d1,d2,ci,wk1,l,rmax);
for i=-1 : l+1;
cr(i+2)=cr2(i+2);
end;
%
%
% ****************************************************************
% * *
% * SUBROUTINE ARYDIV *
% * *
% * *
% * Description : Returns the double precision complex number *
% * resulting from the division of four arrays, representing *
% * two complex numbers. The number returned will be in one *
% * of two different forms: either standard scientific or as *
% * the log (base 10) of the number. *
% * *
% * Subprograms called: CONV21, CONV12, EADD, ECPDIV, EMULT. *
% * *
% ****************************************************************
%
function [ar,ai,br,bi,c,l,lnpfq,rmax,ibit]=arydiv(ar,ai,br,bi,c,l,lnpfq,rmax,ibit);
%
%
cdum=[];ae=[];be=[];ce=[];n1=[];e1=[];n2=[];e2=[];n3=[];e3=[];
global zero half one two ten eps;
%
%
%
%
ae=zeros(2,2);be=zeros(2,2);ce=zeros(2,2);dum1=0;dum2=0;e1=0;e2=0;e3=0;n1=0;n2=0;n3=0;phi=0;ri10=0;rr10=0;tenmax=0;x=0;x1=0;x2=0;
cdum=0;
%
dnum=0;
ii10=0;ir10=0;itnmax=0;rexp=0;
%
%
%
rexp=fix(ibit./2);
x=rexp.*(ar(l+1+2)-2);
rr10=x.*log10(two)./log10(ten);
ir10=fix(rr10);
rr10=rr10-ir10;
x=rexp.*(ai(l+1+2)-2);
ri10=x.*log10(two)./log10(ten);
ii10=fix(ri10);
ri10=ri10-ii10;
dum1=(abs(ar(1+2).*rmax.*rmax+ar(2+2).*rmax+ar(3+2)).*sign(ar(-1+2)));
dum2=(abs(ai(1+2).*rmax.*rmax+ai(2+2).*rmax+ai(3+2)).*sign(ai(-1+2)));
dum1=dum1.*10.^rr10;
dum2=dum2.*10.^ri10;
cdum=complex(dum1,dum2);
[cdum,ae]=conv12(cdum,ae);
ae(1,2)=ae(1,2)+ir10;
ae(2,2)=ae(2,2)+ii10;
x=rexp.*(br(l+1+2)-2);
rr10=x.*log10(two)./log10(ten);
ir10=fix(rr10);
rr10=rr10-ir10;
x=rexp.*(bi(l+1+2)-2);
ri10=x.*log10(two)./log10(ten);
ii10=fix(ri10);
ri10=ri10-ii10;
dum1=(abs(br(1+2).*rmax.*rmax+br(2+2).*rmax+br(3+2)).*sign(br(-1+2)));
dum2=(abs(bi(1+2).*rmax.*rmax+bi(2+2).*rmax+bi(3+2)).*sign(bi(-1+2)));
dum1=dum1.*10.^rr10;
dum2=dum2.*10.^ri10;
cdum=complex(dum1,dum2);
[cdum,be]=conv12(cdum,be);
be(1,2)=be(1,2)+ir10;
be(2,2)=be(2,2)+ii10;
[ae,be,ce]=ecpdiv(ae,be,ce);
if (lnpfq==0) ;
[ce,c]=conv21(ce,c);
else;
[ce(1,1),ce(1,2),ce(1,1),ce(1,2),n1,e1]=emult(ce(1,1),ce(1,2),ce(1,1),ce(1,2),n1,e1);
[ce(2,1),ce(2,2),ce(2,1),ce(2,2),n2,e2]=emult(ce(2,1),ce(2,2),ce(2,1),ce(2,2),n2,e2);
[n1,e1,n2,e2,n3,e3]=eadd(n1,e1,n2,e2,n3,e3);
n1=ce(1,1);
e1=ce(1,2)-ce(2,2);
x2=ce(2,1);
%
% TENMAX - MAXIMUM SIZE OF EXPONENT OF 10
%
% THE FOLLOWING CODE CAN BE USED TO DETERMINE TENMAX, BUT IT
%
% WILL LIKELY GENERATE AN IEEE FLOATING POINT UNDERFLOW ERROR
%
% ON A SUN WORKSTATION. REPLACE TENMAX WITH THE VALUE APPROPRIATE
%
% FOR YOUR MACHINE.
%
%
tenmax=320;
itnmax=1;
dnum=0.1d0;
itnmax=itnmax+1;
dnum=dnum.*0.1d0;
while (dnum>0.0);
itnmax=itnmax+1;
dnum=dnum.*0.1d0;
end;
itnmax=itnmax-1;
tenmax=real(itnmax);
%
if (e1>tenmax) ;
x1=tenmax;
elseif (e1<-tenmax);
x1=0.0;
else;
x1=n1.*(ten.^e1);
end;
if (x2~=0.0) ;
phi=atan2(x2,x1);
else;
phi=0.0;
end;
c=complex(half.*(log(n3)+e3.*log(ten)),phi);
end;
%
% ****************************************************************
% * *
% * SUBROUTINE EMULT *
% * *
% * *
% * Description : Takes one base and exponent and multiplies it *
% * by another numbers base and exponent to give the product *
% * in the form of base and exponent. *
% * *
% * Subprograms called: none *
% * *
% ****************************************************************
%
function [n1,e1,n2,e2,nf,ef]=emult(n1,e1,n2,e2,nf,ef);
%
%
global zero half one two ten eps;
%
%
%
nf=n1.*n2;
ef=e1+e2;
if (abs(nf)>=ten) ;
nf=nf./ten;
ef=ef+one;
end;
%
%
% ****************************************************************
% * *
% * SUBROUTINE EDIV *
% * *
% * *
% * Description : returns the solution in the form of base and *
% * exponent of the division of two exponential numbers. *
% * *
% * Subprograms called: none *
% * *
% ****************************************************************
%
function [n1,e1,n2,e2,nf,ef]=ediv(n1,e1,n2,e2,nf,ef);
%
%
global zero half one two ten eps;
%
%
%
nf=n1./n2;
ef=e1-e2;
if ((abs(nf)<one) & (nf~=zero)) ;
nf=nf.*ten;
ef=ef-one;
end;
%
%
% ****************************************************************
% * *
% * SUBROUTINE EADD *
% * *
% * *
% * Description : Returns the sum of two numbers in the form *
% * of a base and an exponent. *
% * *
% * Subprograms called: none *
% * *
% ****************************************************************
%
function [n1,e1,n2,e2,nf,ef]=eadd(n1,e1,n2,e2,nf,ef);
%
%
global zero half one two ten eps;
%
ediff=0;
%
%
ediff=e1-e2;
if (ediff>36.0d0) ;
nf=n1;
ef=e1;
elseif (ediff<-36.0d0);
nf=n2;
ef=e2;
else;
nf=n1.*(ten.^ediff)+n2;
ef=e2;
while (1);
if (abs(nf)<ten) ;
while ((abs(nf)<one) & (nf~=0.0));
nf=nf.*ten;
ef=ef-one;
end;
break;
else;
nf=nf./ten;
ef=ef+one;
end;
end;
end;
%
% ****************************************************************
% * *
% * SUBROUTINE ESUB *
% * *
% * *
% * Description : Returns the solution to the subtraction of *
% * two numbers in the form of base and exponent. *
% * *
% * Subprograms called: EADD *
% * *
% ****************************************************************
%
function [n1,e1,n2,e2,nf,ef]=esub(n1,e1,n2,e2,nf,ef);
%
%
global zero half one two ten eps;
%
%
%
[n1,e1,dumvar3,e2,nf,ef]=eadd(n1,e1,n2.*(-one),e2,nf,ef);
%
%
% ****************************************************************
% * *
% * SUBROUTINE CONV12 *
% * *
% * *
% * Description : Converts a number from complex notation to a *
% * form of a 2x2 real array. *
% * *
% * Subprograms called: none *
% * *
% ****************************************************************
%
function [cn,cae]=conv12(cn,cae);
%
%
global zero half one two ten eps;
%
%
%
%
%
cae(1,1)=real(cn);
cae(1,2)=0.0;
while (1);
if (abs(cae(1,1))<ten) ;
while (1);
if ((abs(cae(1,1))>=one) | (cae(1,1)==0.0)) ;
cae(2,1)=imag(cn);
cae(2,2)=0.0;
while (1);
if (abs(cae(2,1))<ten) ;
while ((abs(cae(2,1))<one) & (cae(2,1)~=0.0));
cae(2,1)=cae(2,1).*ten;
cae(2,2)=cae(2,2)-one;
end;
break;
else;
cae(2,1)=cae(2,1)./ten;
cae(2,2)=cae(2,2)+one;
end;
end;
break;
else;
cae(1,1)=cae(1,1).*ten;
cae(1,2)=cae(1,2)-one;
end;
end;
break;
else;
cae(1,1)=cae(1,1)./ten;
cae(1,2)=cae(1,2)+one;
end;
end;
%
% ****************************************************************
% * *
% * SUBROUTINE CONV21 *
% * *
% * *
% * Description : Converts a number represented in a 2x2 real *
% * array to the form of a complex number. *
% * *
% * Subprograms called: none *
% * *
% ****************************************************************
%
function [cae,cn]=conv21(cae,cn);
%
%
%
global zero half one two ten eps;
global nout;
%
%
%
dnum=0;tenmax=0;
itnmax=0;
%
%
% TENMAX - MAXIMUM SIZE OF EXPONENT OF 10
%
itnmax=1;
dnum=0.1d0;
itnmax=itnmax+1;
dnum=dnum.*0.1d0;
while (dnum>0.0);
itnmax=itnmax+1;
dnum=dnum.*0.1d0;
end;
itnmax=itnmax-2;
tenmax=real(itnmax);
%
if (cae(1,2)>tenmax | cae(2,2)>tenmax) ;
% CN=CMPLX(TENMAX,TENMAX)
%
itnmax,
%format (’ error - value of exponent required for summation’,’ was larger’,./,’ than the maximum machine exponent ’,1i3,./,[’ suggestions:’],./,’ 1) re-run using lnpfq=1.’,./,’ 2) if you are using a vax, try using the’,’ fortran./g_floating option’);
error(’stop encountered in original fortran code’);
elseif (cae(2,2)<-tenmax);
cn=complex(cae(1,1).*(10.^cae(1,2)),0.0);
else;
cn=complex(cae(1,1).*(10.^cae(1,2)),cae(2,1).*(10.^cae(2,2)));
end;
return;
%
%
% ****************************************************************
% * *
% * SUBROUTINE ECPMUL *
% * *
% * *
% * Description : Multiplies two numbers which are each *
% * represented in the form of a two by two array and returns *
% * the solution in the same form. *
% * *
% * Subprograms called: EMULT, ESUB, EADD *
% * *
% ****************************************************************
%
function [a,b,c]=ecpmul(a,b,c);
%
%
n1=[];e1=[];n2=[];e2=[];c2=[];
c2=zeros(2,2);e1=0;e2=0;n1=0;n2=0;
%
%
[a(1,1),a(1,2),b(1,1),b(1,2),n1,e1]=emult(a(1,1),a(1,2),b(1,1),b(1,2),n1,e1);
[a(2,1),a(2,2),b(2,1),b(2,2),n2,e2]=emult(a(2,1),a(2,2),b(2,1),b(2,2),n2,e2);
[n1,e1,n2,e2,c2(1,1),c2(1,2)]=esub(n1,e1,n2,e2,c2(1,1),c2(1,2));
[a(1,1),a(1,2),b(2,1),b(2,2),n1,e1]=emult(a(1,1),a(1,2),b(2,1),b(2,2),n1,e1);
[a(2,1),a(2,2),b(1,1),b(1,2),n2,e2]=emult(a(2,1),a(2,2),b(1,1),b(1,2),n2,e2);
[n1,e1,n2,e2,c(2,1),c(2,2)]=eadd(n1,e1,n2,e2,c(2,1),c(2,2));
c(1,1)=c2(1,1);
c(1,2)=c2(1,2);
%
%
% ****************************************************************
% * *
% * SUBROUTINE ECPDIV *
% * *
% * *
% * Description : Divides two numbers and returns the solution. *
% * All numbers are represented by a 2x2 array. *
% * *
% * Subprograms called: EADD, ECPMUL, EDIV, EMULT *
% * *
% ****************************************************************
%
function [a,b,c]=ecpdiv(a,b,c);
%
%
b2=[];c2=[];n1=[];e1=[];n2=[];e2=[];n3=[];e3=[];
global zero half one two ten eps;
%
b2=zeros(2,2);c2=zeros(2,2);e1=0;e2=0;e3=0;n1=0;n2=0;n3=0;
%
%
b2(1,1)=b(1,1);
b2(1,2)=b(1,2);
b2(2,1)=-one.*b(2,1);
b2(2,2)=b(2,2);
[a,b2,c2]=ecpmul(a,b2,c2);
[b(1,1),b(1,2),b(1,1),b(1,2),n1,e1]=emult(b(1,1),b(1,2),b(1,1),b(1,2),n1,e1);
[b(2,1),b(2,2),b(2,1),b(2,2),n2,e2]=emult(b(2,1),b(2,2),b(2,1),b(2,2),n2,e2);
[n1,e1,n2,e2,n3,e3]=eadd(n1,e1,n2,e2,n3,e3);
[c2(1,1),c2(1,2),n3,e3,c(1,1),c(1,2)]=ediv(c2(1,1),c2(1,2),n3,e3,c(1,1),c(1,2));
[c2(2,1),c2(2,2),n3,e3,c(2,1),c(2,2)]=ediv(c2(2,1),c2(2,2),n3,e3,c(2,1),c(2,2));
% ****************************************************************
% * *
% * FUNCTION IPREMAX *
% * *
% * *
% * Description : Predicts the maximum term in the pFq series *
% * via a simple scanning of arguments. *
% * *
% * Subprograms called: none. *
% * *
% ****************************************************************
%
function [ipremax]=ipremax(a,b,ip,iq,z);
%
%
%
global zero half one two ten eps;
global nout;
%
%
%
%
%
expon=0;xl=0;xmax=0;xterm=0;
%
i=0;j=0;
%
xterm=0;
for j=1 : 100000;
%
% Estimate the exponent of the maximum term in the pFq series.
%
%
expon=zero;
xl=real(j);
for i=1 : ip;
expon=expon+real(factor(a(i)+xl-one))-real(factor(a(i)-one));
end;
for i=1 : iq;
expon=expon-real(factor(b(i)+xl-one))+real(factor(b(i)-one));
end;
expon=expon+xl.*real(log(z))-real(factor(complex(xl,zero)));
xmax=log10(exp(one)).*expon;
if ((xmax<xterm) & (j>2)) ;
ipremax=j;
return;
end;
xterm=max([xmax,xterm]);
end;
’ error in ipremax--did not find maximum exponent’,
error(’stop encountered in original fortran code’);
% ****************************************************************
% * *
% * FUNCTION FACTOR *
% * *
% * *
% * Description : This function is the log of the factorial. *
% * *
% * Subprograms called: none. *
% * *
% ****************************************************************
%
function [factor]=factor(z);
%
%
global zero half one two ten eps;
%
%
%
pi=0;
%
if (((real(z)==one) & (imag(z)==zero)) | (abs(z)==zero)) ;
factor=complex(zero,zero);
return;
end;
pi=two.*two.*atan(one);
factor=half.*log(two.*pi)+(z+half).*log(z)-z+(one./(12.0d0.*z)).*(one-(one./(30.d0.*z.*z)).*(one-(two./(7.0d0.*z.*z))));
% ****************************************************************
% * *
% * FUNCTION CGAMMA *
% * *
% * *
% * Description : Calculates the complex gamma function. Based *
% * on a program written by F.A. Parpia published in Computer*
% * Physics Communications as the ‘GRASP2’ program (public *
% * domain). *
% * *
% * *
% * Subprograms called: none. *
% * *
% ****************************************************************
function [cgamma]=cgamma(arg,lnpfq);
%
%
%
%
%
global zero half one two ten eps;
global nout;
%
%
%
argi=0;argr=0;argui=0;argui2=0;argum=0;argur=0;argur2=0;clngi=0;clngr=0;diff=0;dnum=0;expmax=0;fac=0;facneg=0;fd=zeros(7,1);fn=zeros(7,1);hlntpi=0;obasq=0;obasqi=0;obasqr=0;ovlfac=0;ovlfi=0;ovlfr=0;pi=0;precis=0;resi=0;resr=0;tenmax=0;tenth=0;termi=0;termr=0;twoi=0;zfaci=0;zfacr=0;
%
first=0;negarg=0;cgamma=0;
i=0;itnmax=0;
%
%
%
%----------------------------------------------------------------------*
% *
% THESE ARE THE BERNOULLI NUMBERS B02, B04, ..., B14, EXPRESSED AS *
% RATIONAL NUMBERS. FROM ABRAMOWITZ AND STEGUN, P. 810. *
% *
fn=[1.0d00,-1.0d00,1.0d00,-1.0d00,5.0d00,-691.0d00,7.0d00];
fd=[6.0d00,30.0d00,42.0d00,30.0d00,66.0d00,2730.0d00,6.0d00];
%
%----------------------------------------------------------------------*
%
hlntpi=[1.0d00];
%
first=[true];
%
tenth=[0.1d00];
%
argr=real(arg);
argi=imag(arg);
%
% ON THE FIRST ENTRY TO THIS ROUTINE, SET UP THE CONSTANTS REQUIRED
% FOR THE REFLECTION FORMULA (CF. ABRAMOWITZ AND STEGUN 6.1.17) AND
% STIRLING’S APPROXIMATION (CF. ABRAMOWITZ AND STEGUN 6.1.40).
%
if (first) ;
pi=4.0d0.*atan(one);
%
% SET THE MACHINE-DEPENDENT PARAMETERS:
%
%
% TENMAX - MAXIMUM SIZE OF EXPONENT OF 10
%
%
itnmax=1;
dnum=tenth;
itnmax=itnmax+1;
dnum=dnum.*tenth;
while (dnum>0.0);
itnmax=itnmax+1;
dnum=dnum.*tenth;
end;
itnmax=itnmax-1;
tenmax=real(itnmax);
%
% EXPMAX - MAXIMUM SIZE OF EXPONENT OF E
%
%
dnum=tenth.^itnmax;
expmax=-log(dnum);
%
% PRECIS - MACHINE PRECISION
%
%
precis=one;
precis=precis./two;
dnum=precis+one;
while (dnum>one);
precis=precis./two;
dnum=precis+one;
end;
precis=two.*precis;
%
hlntpi=half.*log(two.*pi);
%
for i=1 : 7;
fn(i)=fn(i)./fd(i);
twoi=two.*real(i);
fn(i)=fn(i)./(twoi.*(twoi-one));
end;
%
first=false;
%
end;
%
% CASES WHERE THE ARGUMENT IS REAL
%
if (argi==0.0) ;
%
% CASES WHERE THE ARGUMENT IS REAL AND NEGATIVE
%
%
if (argr<=0.0) ;
%
% STOP WITH AN ERROR MESSAGE IF THE ARGUMENT IS TOO NEAR A POLE
%
%
diff=abs(real(round(argr))-argr);
if (diff<=two.*precis) ;
,
argr , argi,
%format (’ argument (’,1p,1d14.7,’,’,1d14.7,’) too close to a’,’ pole.’);
error(’stop encountered in original fortran code’);
else;
%
% OTHERWISE USE THE REFLECTION FORMULA (ABRAMOWITZ AND STEGUN 6.1
% .17)
% TO ENSURE THAT THE ARGUMENT IS SUITABLE FOR STIRLING’S
%
% FORMULA
%
%
argum=pi./(-argr.*sin(pi.*argr));
if (argum<0.0) ;
argum=-argum;
clngi=pi;
else;
clngi=0.0;
end;
facneg=log(argum);
argur=-argr;
negarg=true;
%
end;
%
% CASES WHERE THE ARGUMENT IS REAL AND POSITIVE
%
%
else;
%
clngi=0.0;
argur=argr;
negarg=false;
%
end;
%
% USE ABRAMOWITZ AND STEGUN FORMULA 6.1.15 TO ENSURE THAT
%
% THE ARGUMENT IN STIRLING’S FORMULA IS GREATER THAN 10
%
%
ovlfac=one;
while (argur<ten);
ovlfac=ovlfac.*argur;
argur=argur+one;
end;
%
% NOW USE STIRLING’S FORMULA TO COMPUTE LOG (GAMMA (ARGUM))
%
%
clngr=(argur-half).*log(argur)-argur+hlntpi;
fac=argur;
obasq=one./(argur.*argur);
for i=1 : 7;
fac=fac.*obasq;
clngr=clngr+fn(i).*fac;
end;
%
% INCLUDE THE CONTRIBUTIONS FROM THE RECURRENCE AND REFLECTION
%
% FORMULAE
%
%
clngr=clngr-log(ovlfac);
if (negarg) ;
clngr=facneg-clngr;
end;
%
else;
%
% CASES WHERE THE ARGUMENT IS COMPLEX
%
%
argur=argr;
argui=argi;
argui2=argui.*argui;
%
% USE THE RECURRENCE FORMULA (ABRAMOWITZ AND STEGUN 6.1.15)
%
% TO ENSURE THAT THE MAGNITUDE OF THE ARGUMENT IN STIRLING’S
%
% FORMULA IS GREATER THAN 10
%
%
ovlfr=one;
ovlfi=0.0;
argum=sqrt(argur.*argur+argui2);
while (argum<ten);
termr=ovlfr.*argur-ovlfi.*argui;
termi=ovlfr.*argui+ovlfi.*argur;
ovlfr=termr;
ovlfi=termi;
argur=argur+one;
argum=sqrt(argur.*argur+argui2);
end;
%
% NOW USE STIRLING’S FORMULA TO COMPUTE LOG (GAMMA (ARGUM))
%
%
argur2=argur.*argur;
termr=half.*log(argur2+argui2);
termi=atan2(argui,argur);
clngr=(argur-half).*termr-argui.*termi-argur+hlntpi;
clngi=(argur-half).*termi+argui.*termr-argui;
fac=(argur2+argui2).^(-2);
obasqr=(argur2-argui2).*fac;
obasqi=-two.*argur.*argui.*fac;
zfacr=argur;
zfaci=argui;
for i=1 : 7;
termr=zfacr.*obasqr-zfaci.*obasqi;
termi=zfacr.*obasqi+zfaci.*obasqr;
fac=fn(i);
clngr=clngr+termr.*fac;
clngi=clngi+termi.*fac;
zfacr=termr;
zfaci=termi;
end;
%
% ADD IN THE RELEVANT PIECES FROM THE RECURRENCE FORMULA
%
%
clngr=clngr-half.*log(ovlfr.*ovlfr+ovlfi.*ovlfi);
clngi=clngi-atan2(ovlfi,ovlfr);
%
end;
if (lnpfq==1) ;
cgamma=complex(clngr,clngi);
return;
end;
%
% NOW EXPONENTIATE THE COMPLEX LOG GAMMA FUNCTION TO GET
% THE COMPLEX GAMMA FUNCTION
%
if ((clngr<=expmax) & (clngr>=-expmax)) ;
fac=exp(clngr);
else;
,
clngr,
%format (’ argument to exponential function (’,1p,1d14.7,’) out of range.’);
error(’stop encountered in original fortran code’);
end;
resr=fac.*cos(clngi);
resi=fac.*sin(clngi);
cgamma=complex(resr,resi);
%
return;