a compiler for algebraic manipulations with applications
TRANSCRIPT
JOURNAL OF PHYSICS OF THE EARTH, Vol. 16, Special Issue, 1968 43
A Compiler for Algebraic Manipulations
with Applications to Geophysics
By
Edo NYLAND and Leon KNOPOFF
Institute of Geophysics and Planetary Physics†
University of California, Los Angeles, U.S.A.
Abstract
It is often possible to carry out lengthy and tedious but otherwise routine algebra
involved in geophysical calculations on a computer. The technique yields confidence
in the accuracy of the analysis and allows an approach to complex algebra which
permits more attention to be paid to the broad principles of the problem and less to the details.
FORMAC is a recent approach to the problem of manipulation of algebraic ex-pressions. It is a preprocessor for PL1-like input to the IBM/360. An earlier version was a preprocessor for FORTRAN-like input to the IBM/7094. The language provides a group of commands which will manipulate symbolic expressions algebraically, differentiate these expressions and execute input and output for these expressions onto printers or direct access storage.
Applications are made of FORMAC to several complex algebraic expressions which arise in geophysics.
Some of the experience gained with FORMAC processors [Tobey et al., 1967] applied to the solution of geophysical pro-blems is reported in this paper. In order to illustrate the flexibility of the system, three specific problems are considered in whose solution FORMAC has been used. These are: 1. We desire to generate the explicit for-mulas for a complete space of linearly inde-
pendent solutions of the equations of static elasticity in spherical polar coordinates. 2. We study the behavior of a complicated criterion function for the detection of a signal in the presence of noise. 3. We wish to generate subroutines from explicit formulas the first and second deriva-tives of a function with many parameters. Explicit formulas are one way to avoid round-off errors in computing derivatives.
§1. Static Elasticity in Spherical Polar Co-
ordinates
We seek the solutions of
∇∇2u+α∇∇・u=0
in the form
u=rr2∇ φ(x)+h(x) (1)
where
and λ and μ are the Lame elastic constants
(see for example Bergman and Schiffer, [1953]
p. 231). Here the cartesian components of
the location vector r are xi.
It then follows that φ is related to h through
(2)
Let hi be the cartesian components of h.
Then solutions to ∇∇2hi=0 are
(3)
for ni〓0, -ni〓mi〓ni, with Ymini(θ,φ) a sur-
face harmonic. We write
(4)
where r1=r, r2=θ, r3=φ
The derivatives are obtained from† Publication No. 723, Institute of Geophysics
University of California, Los Angeles, U.S.A.
44 Edo NYLAND and Leon KNOPOFF
Fig. 1. Input to the FORMAC preprocessor to calculate the general solution in spherical polar
coordinates of the elastostatic equation.
A Compiler for Algebraic Manipulations with Applications to Geophysics 45
Fig. 2a. The input to the computer which calculates generalized Taylor series. This shows the
first five cards.
(5)
δ1j,δ2j,δ3j are Kronecker symbols.
Two useful results are
(6)
(see Mathews and Walker, 1965, p. 169;
Abramowitz and Stegun, 1965, p. 334). These formulas can be programmed and
the results yield a general vector formula for solutions of the elastostatic equations (1) with indices mi, ni. The program is reproduced in Fig. 1. It contains sufficient comment that reference to the FORMAC manual (Tobey et al, 1967) will elucidate the logic.
The resulting expressions are long and involved and are not reproduced here. Ad-ditional work on the FORMAC code would
probably improve the appearance of the ex-pressions. The interest in this example lies in the fact that complicated formulas such as these can be manipulated with a great deal of ease, confidence and, presumably, profit in analyzing the response of the earth to static loads.
§2. Detection of a Signal in Noise
The problem of the detection of the spectral
46 Edo NYLAND and Leon KNOPOFF
Fig. 2b. The second five cards of the Taylor series calculation.
line 0S2 of the free modes of vibration of the earth in the presence of noise is one of considerable interest in inversion problems. Splitting of the line arises when one takes into account the removal of the degeneracy by the rotation of the earth. Assuming that the noise is gaussian, it can be shown [Knopoff, unpublished] that the optimal fit of the theoretical spectral profile to the observations is the result of minimizing the function
(7)
where Ri is the observed spectral amplitude
at frequency ωi
I0 is the modified Bessel function of zero
order. The fit is a function of nine adjustable
parameters of interest: the central frequency
ωc, the frequency interval between adjacent
lines Δω, the specific attenuation factor Q,
the amplitudes Am of each of the five lines
in the fine structure line spectrum and NO,
the r.m.s. value of the background noise.
One method of performing the minimization
of a function of many variables is to compute
the center of an ellipsoid fit to the function
Φ at some point of guess of the optimal set
of parameters [Knopoff, 1968]. This procedure
requires that Φ be expanded in a Taylor
series to at least second order about this
point of guess.
One of the sample programs that is found in the FORMAC manual is a program to
perform generalized Taylor series expansions. In Fig. 2 we have the listing of an input deck for this program as it appears on a
console at a remote terminal. Figures 3 and 4, with comments, are the output.
A Compiler for Algebraic Manipulations with Applications to Geophysics 47
Fig. 3. The output for the generalized Taylor series calculation set up in Fig . 2.
48 Edo NYLAND and Leon KNOPOFF
Fig. 4. Continuation of the output from the input of Fig. 2.
A Compiler for Algebraic Manipulations with Applications to Geophysics 49
Fig. 5. The use of FORMAC in generating pro- duction programs. D1 and D2 are subprograms
to evaluate first and second derivatives.
§3. Generating a Production Program
Finally, the accurate computation of de-
rivatives is best done with explicit formulas. Using the commands DERIV and CHAREX, and the character string manipulation fa-
cilities of PL1, it is usually possible to
generate the code for the complex subroutines automatically. There is sometimes a problem
in simplifying expressions but it can usually
be surmounted with a little ingenuity. Figure 5 shows how FORMAC meshes with other
OS 360 processors to generate a production
program for estimating details of the 0S2 mode.
§4. Summary
FORMAC goes a long way towards auto-
mating the bookkeeping details of algebra. Unfortunately it produces output which is somewhat more complex than is desirable. This is probably due to a lack of agreement on what constitutes simplicity. The FORMAC language provides a means of exploring com-plex algebraic problems with some ease. It is usually essential to make numerous quali-tative judgments on the correct use of the many simplification and rearrangement op-tions in FORMAC in order to use the lan-guage effectively. As a result, the processor is not suited for coding by programmers who have no understanding of the scientific
problem. Used properly, FORMAC is a re-search tool which makes complex algebra a little less forbidding. Used improperly, and without a sound understanding of the logic of the language, it can give seemingly spurious results. The present version of FORMAC requires as a minimum configuration an IBM 360/40 which supports FORTRAN H. Such a ma-chine has at least 256K bytes of storage. A more realistic storage seems to be that of a 512K machine. Clearly conversational capa-bility will require an even bigger machine.
§5. Acknowledgments
We benefited significantly from discussions with Dr. R. G. Tobey of IBM in Boston in connection with some of the involved pro-
gramming. He made FORMAC available and supplied information on its use. We wish to acknowledge the capable assistance supplied by the staff of the UCLA Campus Computing Network in implementing a non-standard system.
This research was supported in part by National Science Foundation Grant GA-1586 and in part by a grant from the UCLA Campus Computing Network. One of us
(EN) is supported by a National Research Council of Canada post graduate scholarship.
References
ABRAMOWITZ, M. and I.A. STEGUN: 1965 Handbook of Mathematical Function, Dover
Press, New York.
50 Edo NYLAND and Leon KNOPOFF
BERGMAN, S., and M. SCHIFFER: 1953 Kernel Functions and Elliptic Differential
Equations in Mathematical Physics, Aca- demic Press, New York.
KNOPOFF, L: 1968 Nuovo Cimento, Suppl., 6, 120-123.
MATHEWS, J., and R.L. WALKER:
1965 Mathematical Methods of Physics, Benjamin Press, New York.
TOBEY, R., J. BAKER, R. CREWS, P. MARKS and K. VICTOR:
1967 PL1/FORMAC Interpreter User's Reference Manual, IBM Contributed Program Libra-
ry, 360 D 03.3004.
(Received Dec. 16, 1968)