A Practical Relativistic Model for Microarcsecond Astrometry in Space
Sergei A. Klioner
This paper is devoted to a practical model for relativistic reduction of positional observations with an accuracy of 1 \muas\ which is expected to be attained in the future space astrometry missions. All relativistic effects which are caused by the gravitational field of the Solar system and which are of practical importance for this accuracy level are thoroughly calculated and discussed. The model includes relativistic modeling of the motion of observer, modeling of relativistic aberration and gravitational light deflection as well as a relativistic treatment of parallax and proper motion suitable for the accuracy of 1 \muas. The model is formulated both for remote sources (stars, quasars, etc.) and for Solar system objects (asteroids, etc.). The suggested model is formulated within the framework of Parametrized Post-Newtonian Formalism with parameters $\beta$ and $\gamma$. However, for general relativity ($\beta=\gamma=1$) the model is fully compatible with the IAU Resolutions (2000) on relativity in celestial mechanics, astrometry and metrology. The model is presented in a form suitable for implementation in a software system for data processing or simulation. The changes which should be applied to the model to attain the accuracy of 0.1 \muas\ are reviewed. Potentially important relativistic effects caused by additional gravitational fields which are generated outside of the Solar system are also briefly discussed.
muas.tex
\documentclass[preprint]{aastex}
%\documentclass{aastex}
\singlespace

\usepackage{natbib}

% a comment for title page
\slugcomment{to appear in Astronomical Journal, 2002}

% local commands
\arraycolsep=1pt

\newcommand{\OO}[1]{{\cal O}(c^{-#1})}
\newcommand{\vecg}[1]{\mbox{\boldmath$#1$}}
\newcommand{\ve}[1]{\vecg{#1}}
\newcommand{\muas}[0]{\hbox{\rm $\mu$as}}
%\newcommand{\degr}[0]{\hbox{$^\circ$}}
%\newcommand{\arcmin}[0]{\hbox{$^\prime$}}
%\newcommand{\arcsec}[0]{\hbox{$^{\prime\prime}$}}

\def\TCG{{\hbox{\rm TCG}}}
\def\TCB{{\hbox{\rm TCB}}}
\def\TDB{{\hbox{\rm TDB}}}
\def\TT{{\hbox{\rm TT}}}

\shorttitle{A Practical Relativistic Model for Microarcsecond Astrometry in Space}
\shortauthors{S.A. Klioner}

\begin{document}


\title{A Practical Relativistic Model for Microarcsecond Astrometry
in Space}

\author{Sergei A. Klioner}
\affil{Lohrmann Observatory, Dresden Technical University, \\
Mommsenstr. 13, 01062 Dresden, Germany}
\email{klioner@rcs.urz.tu-dresden.de}

\begin{abstract}
This paper is devoted to a practical model for relativistic reduction
of positional observations with an accuracy of 1 \muas\ which is
expected to be attained in the future space astrometry missions. All
relativistic effects which are caused by the gravitational field of the
Solar system and which are of practical importance for this accuracy
level are thoroughly calculated and discussed. The model includes
relativistic modeling of the motion of observer, modeling of
relativistic aberration and gravitational light deflection as well as a
relativistic treatment of parallax and proper motion suitable for the
accuracy of 1 \muas. The model is formulated both for remote sources
(stars, quasars, etc.) and for Solar system objects (asteroids, etc.).
The suggested model is formulated within the framework of Parametrized
Post-Newtonian Formalism with parameters $\beta$ and $\gamma$. However,
for general relativity ($\beta=\gamma=1$) the model is fully compatible
with the IAU Resolutions (2000) on relativity in celestial mechanics,
astrometry and metrology. The model is presented in a form suitable for
implementation in a software system for data processing or simulation.
The changes which should be applied to the model to attain the accuracy
of 0.1 \muas\ are reviewed. Potentially important relativistic effects
caused by additional gravitational fields which are generated outside
of the Solar system are also briefly discussed.
\end{abstract}

\keywords{astrometry, reference systems, relativity}

\section{Introduction}

Within the next decade the accuracy of space-based astrometric
positional observations is expected to attain a level of 1
microarcsecond (\muas). The problem of relativistic modeling of
positional observations with a microarcsecond accuracy has become quite
practical in the recent years when a number of astrometric space
projects have been approved by NASA, ESA and other boards and selected
for launch in the next several years (GAIA
\citep{GAIA:2000,Perryman:et:al:2001,Bienayme:Turon:2002}, SIM
\citep{SIM:1998}, etc.). Following this practical trend the present
paper describes a practical relativistic model of space-based
positional observations which is valid at a level of 1 \muas\ and which
can be readily implemented in the corresponding software.

%FAME \citep{FAME:2000}
%DIVA \citep{DIVA:1996}

%%% history

Relativistic effects in positional observations have been studied by
many authors in many different aspects. Needless to say that the
gravitational light deflection in the gravitational field of the Sun
being one of the most important constituents of the relativistic model
of positional observations was one of the first experimental tests of
general relativity. Already in the time of Hipparcos it was realized
that relativity must play an important role in the formulation of
the transformation between the observed positions of a star and what should
be included in the resulting catalogue \citep{Walter:et:al:1986}.
However, it was a relatively uncomplicated task to formulate such a
transformation for Hipparcos which was aimed at the final accuracy of 1 mas. A
model of positional observations suitable for an accuracy of 1 \muas\
is much more intricate. It is clear since in this case typical
relativistic effects exceed the required accuracy by several
orders of magnitude. The whole concept of the modeling should be
re-formulated in the framework of general relativity. Besides that at
such a high level of accuracy many additional, more subtle relativistic
effects should be taken into account.

%%%  Klioner, Kopeikin

The first complete general-relativistic model of positional
observations at the microarcsecond level of accuracy was formulated by
\citet{Klioner:Kopeikin:1992}. That work was stimulated by
the early project for microarcsecond astrometry in space POINTS
\citep{Reasenberg:et:al:1988}. The model was formulated in a rather
general form and was primarily intended for a satellite on a geocentric
orbit (geostationary or lower). The model described in this paper is
based on the same general post-Newtonian approximation scheme used in
the model of \citet{Klioner:Kopeikin:1992}, but differs from the latter
in several important aspects: (1) the Geocentric Celestial Reference
System (see below) is used only as an intermediate reference system to
model Earth-based observations of the satellite itself (orbit
determination) and not to process the astrometric observations produced
by the satellite; (2) the model contains a refined treatment of several
relativistic effects (primarily aberration and some subtle effects in
the gravitational light deflection); (3) the model is formulated in the
framework of the so-called Parametrized Post-Newtonian (PPN) formalism
\citep{Will:1993} which makes it possible to use the positional
observations to test general theory of relativity; (4) the present
model is suitable both for remote sources located outside of the Solar
system and for Solar system objects, the coupling between the finite
distance to the object and the gravitational light deflection being
properly treated; (5) the model is supplemented with a set of simple
formulas allowing one to judge if a particular gravitational light
deflection effect due to a particular gravitating body must be taken
into account or can be neglected for a particular mutual disposition of
the source, the observer and the gravitating body; (6) the model is
optimized and simplified as much as possible for the goal accuracy of 1
\muas, which makes it straightforward to implement the model in the
corresponding software.

%%%  de Felice and co-workers

Since the practical interest in microarcsecond astrometry was revived
in the last years, a number of numerical simulations of astrometric
missions has appeared.
\citet{deFelice:Lattanzi:Vecchiato:Bernacca:1998,
deFelice:Vecchiato:Bucciarelli:Lattanzi:Crosta:2000,
deFelice:Bucciarelli:Lattanzi:Vecchiato:2001} have used a simplified
relativistic model (Schwarzschild field of the Sun) in an end-to-end
simulation of the GAIA mission to demonstrate its capability and
investigate various statistical properties of the solution in different
cases. Simulations based on more realistic models are in progress
\citep{Kopeikin:Shuygina:Vasiliev:Yagudina:Yagudin:2000,
deFelice:Bucciarelli:Lattanzi:Vecchiato:2001}. The model represented in
this paper can be used to facilitate further investigations of this
kind.

It is clear that the model given below is not all what is needed for
practical processing of the data produced by an astrometric satellite such
as GAIA (or for corresponding data simulations). The full model of
observables should contain not only the idealized relativistic part
given below, but also a detailed instrumental model describing
observables from the ``technical'' point of view. The ``technical''
model heavily depends on the particular design of the satellite and
should relate theoretical ``observable direction'' toward a source to
the technical observational data provided by the particular satellite
design. This ``technical'' model may contain parameters of the
satellite's hardware, various calibration parameters, parameters
describing the attitude of the satellite, etc. Besides that, the
mathematical and statistical details of the data processing of the
future astrometric missions represent an important research topic in
itself. All these aspects of practical data processing are beyond the
scope of the present paper.

%%% notations

Let us summarize the most important notations used throughout the
paper:

\begin{itemize}

\item $G$ is the Newtonian constant of gravitation;

\item $c$ is the velocity of light;

\item $\beta$ and $\gamma$ are the parameters of the Parametrized Post-Newtonian
(PPN) formalism which characterize possible deviation of the physical
reality from general relativity theory ($\beta=\gamma=1$ in general
relativity);

\item the lower case latin indices $i$, $j$, $k$, \dots take values 1,
2, 3;

\item the lower case latin indices are lowered and raised by means of
the unit matrix $\delta_{ij}=\delta^{ij}={\rm diag}(1,1,1)$.
Therefore, the disposition of such indices plays no
role: $a^i=a_i$;

\item repeated indices imply the Einsteinian summation irrespective of
their positions (e.g. $a^i\,b^i=a^1\,b^1+a^2\,b^2+a^3\,b^3$);

\item a dot over any quantity designates the total derivative with
respect to the coordinate time of the corresponding reference system:
e.g. $\dot a=\displaystyle{da\over dt}$;

\item the 3-dimensional coordinate quantities (``3-vectors'') referred to
the spatial axes of the corresponding reference system are set in
boldface: $\ve{a}=a^i$;

\item the absolute value (Euclidean norm) of a ``3-vector'' $\ve{a}$ is
denoted as $|\ve{a}|$ and can be computed as
$|\ve{a}|=(a^1\,a^1+a^2\,a^2+a^3\,a^3)^{1/2}$;

\item the scalar product of any two ``3-vectors'' $\ve{a}$ and $\ve{b}$
with respect to the Euclidean metric $\delta_{ij}$ is denoted by
$\ve{a}\,\cdot\,\ve{b}$ and can be computed as
$\ve{a}\,\cdot\,\ve{b}=\delta_{ij}\,a^i\,b^j=a^i\,b^i$;

\item the vector product of any two ``3-vectors'' $\ve{a}$ and $\ve{b}$
is designated by $\ve{a}\times\ve{b}$ and can be computed as
$\left(\ve{a}\times\ve{b}\right)^i=\varepsilon_{ijk}\,a^j\,b^k$, where
$\varepsilon_{ijk}=(i-j)(j-k)(k-i)/2$ is the fully antisymmetric
Levi-Civita symbol;

\item the capital italic subscripts $A,B,C,\dots = 1 \dots N$ refer to
the gravitating bodies of the Solar system; as a special case
subscript $E$ designates quantities related to the Earth;

\item the subscript '$o$' denotes quantities related to the observer
(satellite): e.g. $\ve{x}_o$ denotes the position of the observer and
$t_o$ is the coordinate time of observation with respect to the
Barycentric Celestial Reference System (BCRS) of the IAU (see below);

\item the subscript '$p$' denotes quantities related to the light ray
(photon): e.g. $\ve{x}_p(t)$ denotes the BCRS position of the light ray
at some moment of time $t$;

\item the subscript '$s$' denotes quantities related to the source:
e.g. $\ve{x}_s$ denotes the BCRS position of the source;

\item the subscript '$e$' denotes quantities related to the moment of
emission of the light ray by the source: e.g. $t_e$ is the BCRS
coordinate time of emission of the signal by the source;

\end{itemize}

%%%  table-of-content

Section \ref{Section-general-scheme} is devoted to a general scheme of
relativistic modeling of astronomical observations of any kind in the
framework of general relativity or PPN formalism. The overall structure
of the specific modeling scheme for positional observations made from a
space station is described in Section
\ref{Section-general-scheme-positional}. Modeling of the motion of the
observer (satellite) and that of its proper time are discussed in Section
\ref{Section-motion}. Section \ref{Section-aberration} deals with the
relativistic description of aberration. Gravitational light deflection
is discussed in Section \ref{Section-gravitational-deflection}.
Parallax and proper motion are analyzed in Sections
\ref{Section-parallax} and \ref{Section-proper-motion}, respectively.
Section \ref{Section-summary} summarizes the suggested relativistic
model. Section \ref{Section-0.1-muas} contains a short discussion of
the changes which should be applied to the model to attain the accuracy
of 0.1~\muas. In Section \ref{Section-beyond-the-model} several known
relativistic effects beyond the given model are described.

\section{General scheme of relativistic modeling of astronomical
observations}
\label{Section-general-scheme}

\begin{figure}
\unitlength=1.0mm
\def\betweenlines{0mm}
\linethickness{0.5pt}
\font\rs=cmss10 scaled \magstephalf
\font\rrs=cmss10 scaled \magstep1
\begin{center}
\begin{picture}(155.00,180.00)(5.00,-15.00)
\baselineskip=0pt
\parskip=0pt
\put(40.00,143.00){\framebox(70.00,15.00)[cc]{\parbox{60mm}{\begin{center}\rs METRIC THEORY\\[\betweenlines] OF GRAVITY\vbox to 3mm{} \end{center}}}}
\put(115.00,150.00){\parbox{80mm}{\rrs {General relativity or}\\[\betweenlines] {PPN formalism}}}
\put(40.00,115.00){\framebox(70.00,17.00)[cc]{\parbox{60mm}{\begin{center}\rs A SET OF ASTRONOMICAL\\[\betweenlines] REFERENCE SYSTEMS\end{center}}}}
\put(102.00,76.00){\framebox(45.00,26.00)[cc]{\parbox{40mm}{\begin{center}\rs RELATIVISTIC\\[\betweenlines] DESCRIPTION\\[\betweenlines] OF THE PROCESS\\[\betweenlines] OF OBSERVATION\end{center}}}}
\put(2.00,76.00){\framebox(45.00,26.00)[cc]{\parbox{40mm}{\begin{center}\rs RELATIVISTIC\\[\betweenlines] EQUATIONS\\[\betweenlines] OF MOTION\end{center}}}}
\put(52.00,76.00){\framebox(45.00,26.00)[cc]{\parbox{40mm}{\begin{center}\rs EQUATIONS OF\\[\betweenlines] SIGNAL\\[\betweenlines] PROPAGATION\end{center}}}}
\put(75.00,113.00){\vector(0,-1){9.00}}
\put(52.00,38.00){\framebox(45.00,25.00)[cc]{\parbox{40mm}{\begin{center}\rs RELATIVISTIC\\[\betweenlines] MODELS\\[\betweenlines] OF OBSERVABLES\end{center}}}}
\put(75.00,74.00){\vector(0,-1){9.00}}
\put(25.00,74.00){\vector(4,-1){36.00}}
\put(125.00,74.00){\vector(-4,-1){34.00}}
\put(61.00,113.00){\vector(-4,-1){36.00}}
\put(91.00,113.00){\vector(4,-1){34.00}}
\put(75.00,141.5){\vector(0,-1){8.00}}
\put(75.00,36.00){\vector(0,-1){9.00}}
\put(113.00,0.00){\framebox(40.00,25.00)[cc]{\parbox{40mm}{\begin{center}\rs OBSERVATIONAL\\[\betweenlines] DATA\end{center}}}}
\put(50.00,0.00){\framebox(50.00,25.00)[cc]{\parbox{40mm}{\begin{center}\rs ASTRONOMICAL\\[\betweenlines] REFERENCE\\[\betweenlines] FRAMES\end{center}}}}
%\put(35.00,-10.00){\parbox{80mm}{\begin{center}\rrs {Relativistically meaningful}\\ {astronomical parameters}\end{center}}}
%\put(35.50,-10.00){\parbox{80mm}{\begin{center}\rrs {Relativistically meaningful}\\[\betweenlines] {astronomical parameters}\end{center}}}
\put(10.00,30.00){\parbox{40mm}{\rrs {Coordinate-}\\[\betweenlines]\hbox to 5mm{} {dependent}\\[\betweenlines] {parameters}}}
\put(40.00,33.00){{\vector(+1,+3){5.00}}}
\put(40.00,29.00){{\vector(+1,-3){5.00}}}
\put(111.00,12.00){\vector(-1,0){9.00}}
\end{picture}
\end{center}
\caption{General principles of relativistic modeling of astronomical observations
(see text for further explanations).
\label{Figure-general-principles}
}
\end{figure}

\begin{figure}
\epsscale{0.8}
\plotone{astrobsg.eps}
%\plotfiddle{astrobsg.eps}{6.9cm}{0}{60}{60}{-190}{-100}
%\plotfiddle{astrobsf.eps}{7cm}{0}{60}{60}{-190}{-100}
\caption{Four constituents of an astronomical event: 1) motion of
the observed object, 2) motion of the observer, 3) propagation of an
electromagnetic signal from the observed object to the observer, 4)
the process of observation.
\label{Figure-observation}
}
\end{figure}

Let us first outline general principles of relativistic modeling of
astronomical observations. General scheme is represented on Fig.
\ref{Figure-general-principles}. Starting from general theory of
relativity, any other metric theory of gravity or PPN formalism one
should define at least one relativistic 4-dimensional reference system
covering the region of space-time where all the processes constituting
particular kind of astronomical observations are located. Typical
astronomical observation depicted on Fig. \ref{Figure-observation}
consists of four constituents: motion of an observer, motion of an
observed object, light progagation and the process of observation. Each
of these four constituents should be modeled in the relativistic
framework. The equations of motion of both the observed object and the
observer relative to the chosen reference system should be derived and
a method to solve these equations should be found. Typically the
equations of motion are second-order ordinary differential
equations and numerical integration with suitable initial or boundary
conditions can be used to solve them. Astrometric information on the
object can be read off the electromagnetic signals propagating from the
object to the observer. Therefore, the corresponding equations of light
propagation relative to the chosen reference system should be derived
and solved.  The equations of motion of the object and the observer and
the equations of light propagation enable one to compute positions and
velocities of the object, observer and the photon (light ray) with
respect to the particular reference system at a given moment of
its coordinate time, provided that the positions and velocities at some
initial epoch are known. However, these positions and velocities
obviously depend on the used reference system. On the other hand, the
results of observations cannot depend on the reference system used to
theoretically model the observations. Therefore, it is clear that one
more step of the modeling is needed: a relativistic description of the
process of observation. This part of the model allows one to compute a
coordinate-independent theoretical prediction of the observables
starting from the coordinate-dependent position and velocity of the
observer and, in some cases, the coordinate velocity of the
electromagnetic signal at the point of observation.

Mathematical techniques to derive the equations of motion of the
observed object and the observer, to formulate the equations of light
propagation and to find the description of the process of observation
in the relativistic framework are well known and will be discussed
below. These three parts can now be combined into relativistic models
of observables. The models give an expression for each observable under
consideration as a function of a set of parameters. These parameters
can then be fitted to observational data using some kind of
parameter estimation scheme (e.g. least squares or other estimators).
The sets of certain estimated parameters appearing in the relativistic
models of observables represent astronomical reference frames.

Note that {\sl reference system} is a purely mathematical construction
(a chart) giving ``names'' to space-time events. In contrast to this a
{\sl reference frame} is some materialization of a reference system. In
astronomy usually the materialization is realized in a form of a
catalogue (or ephemeris) containing positions of some celestial objects
relative to the reference system under consideration. Any reference
frame (a catalogue, an ephemeris, etc) is defined only through the
reference system(s) used to construct physical models of observations.

It is very important to understand at this point that the relativistic
models contain parameters which are defined only in the chosen
reference system(s) and are thus coordinate-dependent. A good example of
such coordinate-dependent parameters are the coordinates and velocities
of various objects (e.g. major planets or the satellite) at some
epoch. On the other hand, from the physical point of view any reference
system covering the region of space-time under consideration can be used
to describe physical phenomena within that region, and we are free to
choose the reference system to be used to model the observations.
However, reference systems, in which mathematical description of
physical laws is simpler than in others, are more convenient for
practical calculations. Therefore, one can use the freedom to choose
the reference system to make the parametrization as convenient and
reasonable as possible (e.g. one prefers the parameters to have
a simpler time dependence).

For modeling of physical phenomena localized in some sufficiently small
region of space (e.g. in the vicinity of a massless observer or a
gravitating body) one can construct a so-called local reference system
where the gravitational influence of the outer world is effaced as much
as possible in accordance with the Einstein equivalence principle. In
the local reference system of a material system the gravitational field
of the outer matter manifests itself in the form of tidal gravitational
potential. First, the Solar system as a whole can be considered as one
single body, and a reference system can be constructed where the
gravitational influence of the matter situated outside of the Solar
system can be described by a tidal potential. That tidal potential
(mainly due to the influence of the Galaxy) is utterly small and can be
then neglected for most purposes. Such a reference system is often
called barycentric reference system of the Solar system. It can be used
far beyond the Solar system and is suitable to describe the dynamics of
the Solar system (motion of planets and spacecraft relative to the
barycenter of the Solar system) as well as to model the influence of
the gravitational field of the Solar system on the light rays
propagating from remote sources to an observer. Second, the
corresponding local reference system can be constructed for the Earth.
Such a geocentric reference system is convenient to model the
geocentric motion of Earth satellites, the rotational motion of the
Earth itself, etc. Underlying theory and technical details concerning
local reference systems have been discussed in a series of papers by
Brumberg and Kopeikin \citep[see also
\citet{Klioner:Voinov:1993}]{Kopeikin:1988,Brumberg:Kopeikin:1989a,Brumberg:Kopeikin:1989b,Brumberg:1991}
and by \citet{Damour:Soffel:Xu:1991,Damour:Soffel:Xu:1992,Damour:Soffel:Xu:1993,Damour:Soffel:Xu:1994}.
\citet{IAU:2001} has recently recommended the use of a particular form of
the barycentric and local geocentric reference systems for modeling of
astronomical observations. These two standard relativistic reference
systems are called Barycentric Celestial Reference System (BCRS) and
Geocentric Celestial Reference System (GCRS). Coordinate time $t$ of
the BCRS is called Barycentric Coordinate Time (\TCB). Coordinate time
$T$ of the GCRS is called Geocentric Coordinate Time (\TCG). According
to the IAU notations, throughout this paper the spatial coordinates of
the BCRS will be designated as $\ve{x}$ while those of the GCRS as
$\ve{X}$.

%%%  PPN parameters

Both Brumberg-Kopeikin and Damour-Soffel-Xu theories are based on
Einstein's general relativity theory. It is clear, however, that one
of the important goals of the future astrometric missions is to test
general relativity. The model presented in this paper will be given in
the framework of the PPN formalism \citep[see, e.g.][]{Will:1993}
including two main parameters $\beta$ and $\gamma$ which characterize
possible devitations of the physical reality from general relativity. Both
parameters are equal to unity in general relativity. The theory of
local reference systems with parameters $\beta$ and $\gamma$ has been
constructed by \citet{Klioner:Soffel:1998b,Klioner:Soffel:2000}. Both
that theory of local PPN reference systems and the model given in the
present paper are constructed in such a way that for $\beta=\gamma=1$
all the formulas coincide with those which can be derived directly from
the general-relativistic versions of the BCRS and GCRS recommended by
\citet{IAU:2001}.

%%% astrometric model

\section{General structure of the relativistic model of positional
observation}
\label{Section-general-scheme-positional}

The relativistic model of positional observations relates the observed
direction of the light coming from a source to the coordinates of that
source at the moment of emission. A set of the coordinate directions
toward the source for different moments of time can be then used to
obtain further parameters of the source describing its spatial position
and spatial motion with respect to the BCRS (parallax and proper motion
or barycentric orbital elements). It is convenient to divide the
conversion of the observed directions into the coordinate ones into
several steps. Let us introduce five vectors which will be used below:
$\ve{s}$ is the unit observed direction (the word ``unit'' means here
and below that the formally Euclidean scalar product
$\ve{s}\,\cdot\,\ve{s}= s^i\,s^i$\ is equal to unity), $\ve{n}$ is the
unit tangent vector to the light ray at the moment of observation,
$\vecg{\sigma}$ is the unit tangent vector to the light ray at
$t=-\infty$, $\ve{k}$ is the unit coordinate vector from the source to
the observer, $\ve{l}$ is the unit vector from the barycenter of the
Solar system to the source (see Fig. \ref{Figure-principal-vectors}).
Note that the last four vectors are defined formally in the coordinate
space of the BCRS and should not be interpreted as ``Euclidean''
vectors in some ``Newtonian physical space''. For the same physical
situation these vectors are different if different reference systems
are used instead of the BCRS. The word ``vector'' is used here to refer
to a set of three real numbers defined in the coordinate space of the
BCRS, rather than to a geometric object. A slightly different meaning
of $\ve{s}$ is discussed in Section~\ref{Section-aberration} below.


\begin{figure}
\font\fiverm=cmr5
\input prepicte.tex
\input pictex.tex
\input postpict.tex
\LARGE
\sf
\beginpicture
\setcoordinatesystem units <1mm, 1mm>
\setplotarea x from 0 to 200, y from 0 to 200
\put {$\bullet$} at 120 30
\put {$\bullet$} at 150 80
\put {$\bullet$} at 50  150
\arrow <5mm> [.15,.4] from 150 80 to 125.423 97.2039  %50 150
\put {$\ve{l}$} at 132 101
\setdashpattern <3mm, 3mm>
\setlinear
\plot 150 80  50 150 /
\plot 120 30  50 150 /
\setsolid
\setquadratic
\plot 20 110 50 150 90 180 /
\plot 100 30 120 30 120 50 /
\plot 120 30 75 90 50 150 /
\setdashpattern <1mm, 1mm>
%\setlinear
\plot 50 150 48 175 50 200 /
\setsolid
\setlinear
\arrow <5mm> [.15,.4] from 50 200 to 45 170.42
\put {.} at  50.0 200
\put {$\vecg{\sigma}$} at 40 174
\put {source} at 35 152
\put {source path} at 110 180
\put {barycenter} at 150 70
\put {observer's path} at 144 50
\put {observer} at 135 32
\arrow <5mm> [.15,.4] from 120 30 to 92.745 42.537
\put {$\ve{s}$} at 91 39
\arrow <5mm> [.15,.4] from 120 30 to 135.1161308 4.08663298 %50 150
\put {$\ve{k}$} at  127 5
\arrow <5mm> [.15,.4] from 120 30 to 139.6853614 7.361834335 %140 7
\put {$\ve{n}$} at  144 6
\put {light path} at 50 90
\setdashpattern <1mm, 1mm>
\setquadratic
\plot 120 30 136 15 160 0 /
\endpicture
%\plotone{5vectors.eps}
\caption{Five principal vectors used in the model: $\ve{s}$, $\ve{n}$,
$\vecg{\sigma}$, $\ve{k}$, $\ve{l}$. See text for further details.
\label{Figure-principal-vectors}
}
\end{figure}

Apart from the modeling of the motion of the observer which will be
considered in the next Section, the model consists in subsequent
transformations of these five vectors. Namely, the following effects
should be subsequently considered:

\begin{itemize}

\item aberration (the effects related to the motion of the observer
with respect to the barycenter of the Solar system): this converts the
observed direction to the source $\ve{s}$ into the unit BCRS coordinate
direction of the light ray $\ve{n}$ at the point of observation;

\item gravitational light deflection for the source at infinity:  this
step converts $\ve{n}$ into the unit direction of propagation
$\vecg{\sigma}$ of the light ray infinitely far from the Solar system
for $t\to-\infty$;

\item coupling of the finite distance to the source and the
gravitational light deflection in the gravitational field of the Solar
system:  this step converts $\vecg{\sigma}$ into the unit BCRS vector
$\ve{k}$ going from the source to the observer (note that as discussed
below this step should be combined with the previous one for the
sources situated within the Solar system);

\item parallax: this step converts $\ve{k}$ into the unit vector $\ve{l}$
going from the barycenter of the Solar system to the source;

\item proper motion: this step provides a reasonable parametrization of
the time dependence of $\ve{l}$ caused by the motion of the source with
respect to the BCRS.

\end{itemize}

\noindent
All these steps will be specified in detail in the following Sections.
However, let us first clarify the question of time scales which should
be used in the model. There are four time scales appearing in the model:

\begin{itemize}
\item proper time of the observer (satellite): $\tau_o$.

\item proper time of the $i$th tracking station:
$\tau^{(i)}_{\rm station}$.

\item coordinate time $t=\TCB$ of the BCRS (alternatively a scaled
version of \TCB\ called \TDB\ can be used: $\TDB=(1-L_B)\,\TCB$ with
the current best estimate of the scaling constant $L_B\approx
1.55051976772\cdot10^{-8}\pm2\cdot10^{-17}$
\citep{Irwin:Fukushima:1999,IAU:2001}).

\item coordinate time $T=\TCG$ of the GCRS (alternatively a scaled
version of \TCG\ called \TT\ can be used: $\TT=(1-L_G)\,\TCG$,
$L_G\equiv6.969290134\cdot10^{-10}$ being a defining constant
\citep{IAU:2001}).

\end{itemize}

\noindent
It is clear that the observational data (e.g. in the case of the scanning
satellites like HIPPARCOS, GAIA and DIVA these are the projections of
the vector $\ve{s}$ on a local reference system of the satellite
which rotates together
with the satellite) are parametrized by the proper time of the satellite
$\tau_o$. It is also clear that the final catalog containing positions,
parallaxes and proper motions of the sources relative to the BCRS
should be parametrized by \TCB. The other two time scales (proper times
of the tracking station(s) $\tau^{(i)}_{\rm station}$ and \TCG) are used
exclusively for orbit determination.

The transformation between the proper time of the satellite $\tau_o$ and
\TCB\ can be done by integrating the equation

\begin{equation}\label{tau-s-TCB}
{d\,\tau_o\over dt}=
1-{1\over c^2}\left(
{1\over2}\,\dot{\ve{x}}_o^2+w(\ve{x}_o)
\right)+\OO4,
\end{equation}

\noindent
where $\ve{x}_o$ and $\dot{\ve{x}}_o$ are the BCRS position and
velocity of the satellite and $w(\ve{x}_o)$ is the gravitational
potential of the Solar system which can be approximated by

\begin{equation}\label{w(x-s)}
w(\ve{x}_o)\approx\sum_A {GM_A\over |\ve{r}_{oA}|},
\end{equation}

\noindent
where $\ve{r}_{oA}=\ve{x}_o-\ve{x}_A$, $M_A$ is the mass of body $A$,
and $\ve{x}_A=\ve{x}_A(t)$ is its barycentric position. Both
higher-order multipole moments of all the bodies and additional
relativistic terms are neglected in (\ref{w(x-s)}). The transformation
between the proper time of a tracking station and \TCG\ can be performed
in a similar way. The transformation between \TCG\ and \TCB\ is given in
the IAU Resolutions B1.3 (general post-Newtonian expression) and B1.5
(an expression for the accuracy of $5\cdot10^{-18}$ in rate and 0.2 ps
in amplitude of periodic effects) of \citet{IAU:2001}. There are
several analytical and numerical formulas for the position-independent
part of the transformation \citep[see, e.g.][and reference cited
therein]{Fukushima:1995,Irwin:Fukushima:1999}.

Although the use of the relativistic time scales described above is
indispensable from the theoretical and conceptual points of view, from
a purely practical point of view considerations of accuracy can be used
here to simplify the model. However, this depends on the particular
parameters of the mission and will be not analyzed here. In the
following it is assumed that the observed directions $\ve{s}$ are given
together with the corresponding epochs of observation $t_o$ in \TCB\
scale.

\section{Motion of the satellite}
\label{Section-motion}

It is well known that in order to compute the Newtonian aberration with
an accuracy of 1 \muas\ one needs to know the velocity of the observer
with an accuracy of $\sim 10^{-3}$ m/s \citep[see, e.g.][]{GAIA:2000}.
This is a rather stringent requirement and special care must be taken
to attain such an accuracy. Modeling of the satellite motion with such
an accuracy is a difficult task involving complicated equations of
motion which take into account various non-relativistic (Newtonian
$N$-body force, radiation pressure, active satellite thrusters, etc.)
as well as relativistic effects. Here some general recipe concerning
the relativistic part of the modeling will be given. Both the
non-relativistic parts of the model and a detailed study of the
relativistic effects in the satellite motion are beyond the scope of
the present paper.

In the relativistic model of positional observations developed in the
following Sections it is assumed that the observations are performed
from a space station or an Earth satellite whose position $\ve{x}_o$
relative to the BCRS is known for any moment of barycentric coordinate
time $t$. For those satellites the orbits of which are not located in
the vicinity of the Earth (this is the case for both GAIA and SIM) it
is advantageous to model their motion directly in the BCRS. Since the
mass of the satellite is too small to noticeably affect the motion of
other bodies of the Solar system, the equations of geodetic motion in
the BCRS can be used as equations of motion of the satellite. It is
sufficient (at least in the relativistic part of the equations) to
neglect here the multipole structure of the gravitating bodies as well
as the gravitational field produced by the rotational motion of these
bodies. Therefore, considering a system of $N$ bodies, each of which
can be characterized by position $\ve{x}_A$, velocity $\dot{\ve{x}}_A$
and mass $M_A$, the equations of motion of the satellite read
\citep{Will:1993,Klioner:Soffel:2000}

\begin{eqnarray}\label{mono-aEi}
{d^2\over dt^2}\, \ve{x}_o&=&-\sum_{A} G\,{\cal M}_A\,
{\ve{r}_{oA}\over |\ve{r}_{oA}|^3}
\nonumber\\
&&+{1\over c^2}\,\sum_{A} G\,{\cal M}_A\,
{\ve{r}_{oA}\over |\ve{r}_{oA}|^3}\,
\Biggl\{
(2\beta-1) \sum_{B\ne A} {G\,{\cal M}_B\over |\ve{r}_{AB}|}
\nonumber\\
&&\phantom{+{1\over c^2}\,\sum_{A} G\,{\cal M}_A\,
{\ve{r}_{oA}\over |\ve{r}_{oA}|^3}\,
\Biggl\{ }
+2(\gamma+\beta) \sum_{B} {G\,{\cal M}_B\over |\ve{r}_{oB}|}
\nonumber \\
&&
\phantom{
+{1\over c^2}\,\sum_{A} G\,{\cal M}_A\,
{\ve{r}_{oA}\over |\ve{r}_{oA}|^3}\,
\Biggl\{ }
+{3\over 2} {{\left(\ve{r}_{oA}\cdot \dot{\ve{x}}_A\right)}^2\over |\ve{r}_{oA}|^2}
\nonumber\\
&&
\phantom{
+{1\over c^2}\,\sum_{A} G\,{\cal M}_A\,
{\ve{r}_{oA}\over |\ve{r}_{oA}|^3}\,
\Biggl\{ }
-{1\over 2}\sum_{B\ne A} G\,{\cal M}_B\,
{\ve{r}_{oA}\,\cdot\,\ve{r}_{AB}\over |\ve{r}_{AB}|^3}
\nonumber\\
&&
\phantom{
+{1\over c^2}\,\sum_{A} G\,{\cal M}_A\,
{\ve{r}_{oA}\over |\ve{r}_{oA}|^3}\,
\Biggl\{ }
-(1+\gamma)\,\dot{\ve{x}}_A\,\cdot\,\dot{\ve{x}}_A
-\gamma\,\dot{\ve{x}}_o\,\cdot\,\dot{\ve{x}}_o
\nonumber \\
&&
\phantom{
+{1\over c^2}\,\sum_{A} G\,{\cal M}_A\,
{\ve{r}_{oA}\over |\ve{r}_{oA}|^3}\,
\Biggl\{ }
+2(1+\gamma)\,\dot{\ve{x}}_o\,\cdot\,\dot{\ve{x}}_A
\Biggr\}
\nonumber\\
&&+{1\over c^2}\,\sum_{A} G\,{\cal M}_A\,
{\dot{\ve{x}}_o-\dot{\ve{x}}_A
\over |\ve{r}_{oA}|^3}\,
\biggl\{
 2(1+\gamma)\,\dot{\ve{x}}_o\,\cdot\,\ve{r}_{oA}
-(2\gamma+1)\,\dot{\ve{x}}_A\,\cdot\,\ve{r}_{oA}\biggr\}\,
\nonumber\\
&&-{1\over c^2}\,\left(2\gamma+{3\over 2}\right)\,
\sum_{A}{G\,{\cal M}_A\over |\ve{r}_{oA}|}\,
\sum_{B\ne A} G\,{\cal M}_B\,{\ve{r}_{AB} \over |\ve{r}_{AB}|^3}+\OO4,
\end{eqnarray}

\noindent
where $\ve{r}_{oA}=\ve{x}_o-\ve{x}_A$, $\ve{r}_{AB}=\ve{x}_A-\ve{x}_B$,
and a dot denotes the total time derivative with respect to $t=\TCB$:
e.g. $\dot{\ve{x}}_o={d\over dt}\,\ve{x}_o(t)$.

The observations of the satellite itself performed to determine its
orbit (typically range and Doppler tracking) should be also modeled in
the relativistic framework: (1) the positions of the observing stations
should be defined in the GCRS and then transformed into the BCRS, (2)
the description of the signal propagation between the satellite and the
observing stations must take into account the corresponding
relativistic effects in the BCRS (the Shapiro effect, the relativistic
Doppler effects, etc.), (3) the difference between the proper time
scales of the satellite and the observing sites and the coordinate time
of the BCRS must also be taken into account. A detailed description of
these steps is beyond the scope of the present paper. The final result
of the orbit determination procedure is the BCRS position $\ve{x}_o$
and velocity $\dot{\ve{x}}_o$ of the satellite as a function of
$t=\TCB$.

If the satellite is close enough to the Earth (geostationary or lower)
it is advantageous to model its motion in the GCRS. The structure of
the equations of motion of a satellite with respect to the GCRS can be
written as

\begin{eqnarray}\label{ppN-eqm-struct}
{d^2\over dT^2}\,\ve{X}_o&=&\ve{\Phi}_{\rm E}+\ve{\Phi}_{\rm el}
+{1\over c^2}\left(
\ve{\Phi}_{\rm coup}+
\ve{\Phi}_{\rm mg}+
\ve{\Phi}_{\rm SEP}
\right)+\OO4,
\end{eqnarray}

\noindent
where $\ve{\Phi}_{\rm E}$ is the acceleration due to the gravitational
field of the Earth, $\ve{\Phi}_{\rm coup}$ is the Earth-third body
coupling term, $\ve{\Phi}_{\rm el}$ is the ``gravito-electric'' part
(independent of the velocity of the satellite) of the tidal influence
of external bodies (this formally includes the Newtonian tidal force),
$\ve{\Phi}_{\rm mg}$ is the purely relativistic ``gravito-magnetic''
part (depending on the velocity of the satellite) of the tidal
influence of external bodies, and, finally, $\ve{\Phi}_{\rm SEP}$ is
the additional acceleration due to possible violation of the strong
equivalence principle in alternative theories of gravity
($\ve{\Phi}_{\rm SEP}\equiv0$ in general relativity where the PPN
parameters $\beta=\gamma=1$). The main relativistic terms in
$\ve{\Phi}_{\rm E}$ come from the spherically symmetric part of the
Earth's gravitational field and can be formally derived in the
framework of the Schwarzschild solution for the Earth considered to be
isolated. This main relativistic effect is recommended to be taken into
account in the IERS Conventions \citep[][, Chapter 11]{IERS:1996}.
Explicit formulas
for the right-hand side of (\ref{ppN-eqm-struct}) can be found in
Section VIII of \citet{Klioner:Soffel:2000} in the framework of the PPN
formalism with parameters $\beta$ and $\gamma$. The same equations in
the framework of general relativity were derived by
\citet{Klioner:Voinov:1993}, \citet{Damour:Soffel:Xu:1994} and by
\citet{Brumberg:Kopeikin:1989b}.

If Eq. (\ref{ppN-eqm-struct}) is used to represent the motion of the
satellite, the whole process of the orbit determination can be
performed directly in the GCRS. Again the orbit determination
observations should be consistently modeled in the relativistic
framework: both the coordinates of the stations and the position of the
satellite should be described in the GCRS, the propagation of the
electromagnetic signals should be adequately modeled in the GCRS, the
proper time of the satellite, that of the tracking stations and \TCG\
should be properly converted into each other when needed. The result of
the orbit determination process is the GCRS coordinates of the
satellite $\ve{X}_o$ and its velocity ${d\over dT}\,\ve{X}_o$ as a
function of $T=\TCG$. In order to be used in the model of positional
observations given below these coordinates must be transformed into the
corresponding BCRS coordinates
\citep[see][]{IAU:2001,Klioner:Soffel:2000}:

\begin{equation}\label{Xa-xi}
\ve{X}_o=\ve{r}_{oE}+{1\over c^2}\left(
{1\over 2}\,\ve{v}_E\,(\ve{v}_E\cdot\ve{r}_{oE})+\gamma\,w_{\rm ext}(\ve{x}_E)\,
\ve{r}_{oE}+
\gamma\,\ve{r}_{oE}\,(\ve{a}_E\cdot\ve{r}_{oE})
-{1\over2}\,\gamma\,\ve{a}_E\,|\ve{r}_{oE}|^2
\right)+\OO4,
\end{equation}

\noindent
where $\ve{r}_{oE}=\ve{x}_o-\ve{x}_E$, and $\ve{x}_E$, $\ve{v}_E$ and
$\ve{a}_E$ are the BCRS position, velocity and acceleration of the
Earth, and $w_{\rm ext}(\ve{x}_E)$ is the gravitational potential of
the Solar system except for that of the Earth evaluated at the
geocenter. It is easy to estimate that the relativistic effects in
(\ref{Xa-xi}) may amount to $\sim 1$ m for $|\ve{r}_{oE}|\sim50000$ km. The
GCRS velocity of the satellite can be transformed into the
corresponding BCRS velocity as (this formula can be derived by taking
time derivative of (\ref{Xa-xi}) and using the \TCG-\TCB\
transformation \citep{IAU:2001,Klioner:Soffel:2000})

\begin{eqnarray}\label{Va-deltavi}
{d\over dT}\,\ve{X}_o=\delta \ve{v}_o+{1\over c^2}\biggl(
&&\delta \ve{v}_o\,\left({1\over 2}\,|\ve{v}_E|^2
+(1+\gamma)\,(w_{\rm ext}(\ve{x}_E)+\ve{a}_E\cdot\ve{r}_{oE})
+\ve{v}_E\cdot\delta\ve{v}_o\right)
\nonumber\\
&&
+{1\over2}\,\ve{v}_E\,(\ve{v}_E\cdot\delta\ve{v}_o)
+\gamma\,\ve{r}_{oE}\,(\ve{a}_E\cdot\delta\ve{v}_o)
-\gamma\,\ve{a}_E\,(\ve{r}_{oE}\cdot\delta\ve{v}_o)
\nonumber\\
&&
+{1\over2}\,\ve{a}_E\,(\ve{v}_E\cdot\ve{r}_{oE})
+{1\over2}\,\ve{v}_E\,(\ve{a}_E\cdot\ve{r}_{oE})
+\gamma\,{\dot w}_{\rm ext}(\ve{x}_E)\,\ve{r}_{oE}
\nonumber\\
&&
+\gamma\,\ve{r}_{oE}\,(\dot{\ve{a}}_E\cdot\ve{r}_{oE})
-{1\over2}\,\gamma\,\dot{\ve{a}}_E\,|\ve{r}_{oE}|^2
\biggr)
+\OO4,
\end{eqnarray}

\noindent
where $\delta \ve{v}_o=\dot{\ve{x}}_o-\ve{v}_E$ and
$\dot{\ve{a}}_E={d\over dt}\ve{a}_E$. It is easy to see from
(\ref{Va-deltavi}) that for a geostationary satellite numerical
difference between ${d\over dT}\,\ve{X}_o$ and $\delta \ve{v}_o$ is
less than $10^{-4}$ m/s. Therefore, for the model with a final accuracy
of $\sim 1$ \muas\ the relativistic terms in (\ref{Va-deltavi}) can be
neglected, and one can use ${d\over dT}\,\ve{X}_o=\delta \ve{v}_o$.

Note that probably even for the goal accuracy of $10^{-3}$ m/s in the velocity
of the satellite one can significantly simplify both the BCRS equations
of motion (\ref{mono-aEi}) and those in the GCRS
(\ref{ppN-eqm-struct}). However, this crucially depends on the
particular orbit of the satellite and such an analysis will not be
given here.

Let us also note that the rotational motion of the satellite should
also be carefully modeled (for some missions the attitude of the
satellite will be determined from the observational data produced by
the satellite, but nevertheless a kind of theoretical modeling is still
necessary). From the theoretical point of view in order to model the
rotational motion of the satellite it is convenient to introduce a
local kinematically-nonrotating reference system for the satellite with
coordinates $(\tau_o,\ve{\xi})$, where $\tau_o$ is the proper time of
the satellite related to $t$ by (\ref{tau-s-TCB}) and $\ve{\xi}$ are
the spatial coordinates of the reference system related to those of
BCRS by a transformation analogous to (\ref{Xa-xi}) \citep[see][for
details on the local reference system of the satellite]
{Brumberg:Kopeikin:1989a,Klioner:1993,Klioner:Soffel:1998a}. The
rotational motion of the satellite with respect to the axes $\ve{\xi}$
is described by the post-Newtonian rotational equations of motion
discussed by \citet{Damour:Soffel:Xu:1993} for the case of general
relativity and by \citet{Klioner:Soffel:1998b,Klioner:Soffel:2000} in
the framework of the PPN formalism. From the practical point of view,
it is, however, clear that the largest relativistic effect in the
rotational motion of the satellite with respect to remote stars is due
to the geodetic (de Sitter) precession which amounts to $\sim 2$ \muas\
per hour ($\sim2\arcsec$ per century) for the satellites on a
heliocentric orbit with the semi-major axis close to 1 AU (like GAIA
and SIM) and $\sim140$ \muas\ per hour ($\sim 1.2\arcsec$ per year) for
the satellites on a geostationary orbit (like HIPPARCOS or DIVA). Taking
into account that the satellites will typically monitor and verify
their attitude with the help of onboard gyroscopes {\it and}
observations of specially selected stars, and that the precise attitude
with respect to remote stars will be determined aposteriori from the
processing of observational data, it is unlikely that such small
relativistic effects could be of practical importance.

The rest of the relativistic model of positional observations is
totally independent of the GCRS. It is only the orbit determination
process (or at least a part of that process) which involves the use of
the GCRS coordinates and concepts.

\section{Aberration}
\label{Section-aberration}

The first step of the model is to get rid of the aberrational effects
induced by the barycentric velocity of the observer. Let $\ve{s}$
denote the unit direction ($\ve{s}\,\cdot\,\ve{s}=1$) {\sl toward} the
source as observed by the observer (satellite). Let $\ve{p}$ be the
BCRS coordinate velocity of the photon at the point of observation.
Note that $\ve{p}$ is directed roughly from the source to the observer. The
unit BCRS coordinate velocity of the light ray $\ve{n}=\ve{p}/|\ve{p}|$
(this implies $\ve{n}\,\cdot\,\ve{n}=1$) can be then computed as
\citep{Klioner:1991b,Klioner:Kopeikin:1992}

\begin{eqnarray}\label{aberration}
\ve{s}=-\ve{n}&+&\,{1\over c}\,\ve{n}\,\times\,(\dot{\ve{x}}_o\,\times\,\ve{n})
\nonumber\\
&+&{1\over c^2}\,\Biggl\{\,(\ve{n}\,\cdot\,\dot{\ve{x}}_o)\
\ve{n}\,\times\,(\dot{\ve{x}}_o\,\times\,\ve{n})
+{1\over 2}\,\dot{\ve{x}}_o\,\times\,(\ve{n}\,\times\,\dot{\ve{x}}_o)
\,\Biggr\}
\nonumber\\
&+&{1\over c^3}\,\Biggl\{
\left({(\ve{n}\,\cdot\,\dot{\ve{x}}_o)}^2+(1+\gamma)\,w(\ve{x}_o)\right)\
\ve{n}\,\times\,(\dot{\ve{x}}_o\,\times\,\ve{n})
+{1\over 2}\,(\ve{n}\,\cdot\,\dot{\ve{x}}_o)\
\dot{\ve{x}}_o\,\times\,(\ve{n}\,\times\,\dot{\ve{x}}_o)
\Biggr\}
\nonumber\\
&+&\OO4,
\end{eqnarray}

\noindent
where $w(\ve{x}_o)$ is the gravitational potential of the Solar system
at the point of observation.  This formula contains relativistic
aberrational effects up to the third order with respect to $1/c$. One
can check from (\ref{aberration}) that condition
$\ve{n}\,\cdot\,\ve{n}=1$ implies $\ve{s}\,\cdot\,\ve{s}=\OO4$. Because
of the first-order aberrational terms (classical aberration) in order
to attain the accuracy of 1 $\mu$as the BCRS coordinate velocity of the
satellite must be known to an accuracy of $\sim10^{-3}$ m/s. For a
satellite with the BCRS velocity $|\dot{\ve{x}}_o|\sim40$ km/s, the
first-order aberration is of the order of 28\arcsec, the second-order
one may amount to 3.6 mas, and the third-order effects are $\sim 1$
\muas. Note also that the higher-order aberrational effects are
nonlinear with respect to the velocity of the satellite and cannot be
divided into additive pieces like ``annual" and ``diurnal'' aberrations
as it could be done with the first-order aberration for an Earth-bound
observer. This is the reason why it is advantageous to use directly the
BCRS velocity of the satellite.

Vector $\ve{s}$ is defined in the kinematically non-rotating local
satellite reference system $(\tau_o,\ve{\xi})$ which is mentioned in
the previous Section. As it was discussed in Section 7.1 of
\citet{Klioner:Kopeikin:1992} this point of view is equivalent to the
standard tetrad approach discussed, e.g. by \citet{Brumberg:1986}. The
same form of Eq. (\ref{aberration}) can be derived both from the
standard tetrad formalism \citep[see,
e.g.][]{Brumberg:1986,Klioner:1991b} and from the considerations
related to the local reference system of the satellite
\citep{Klioner:Kopeikin:1992}. Actual observations of a scanning
astrometric satellite are referred to a reference system, spatial axes
of which rigidly rotate with respect to $\ve{\xi}$ so that the
satellite's attitude remains fixed in the rotating axes. The rotating
axes $\overline{\ve{\xi}}$ are related to the kinematically
non-rotating axes $\ve{\xi}$ as

\begin{equation}\label{rotating-vs-nonrotating-SRS}
\overline{\xi}^a=P^{ab}(\tau_o)\,\xi^b,
\end{equation}

\noindent
where $P^{ab}$ is a time-dependent orthogonal matrix, which can be
parametrized, e.g. by three Euler angles. These Euler angles define
the attitude of the satellite with respect to the kinematically
non-rotating axis and should be determined from observations and
the corresponding modeling. Depending on the particular optical scheme
of the scanning satellite rotational motion of the satellite can
produce an additional measurable aberrational effect. A detailed
analysis of this additional effect will be published
elsewhere.

To clarify the origin of the terms in (\ref{aberration}) proportional
to the gravitational potential $w$ let us consider a fictitious
observer, whose position coincides with that of the satellite at the
moment of observation and whose velocity with respect to the BCRS is
zero. The direction toward the source observed by this fictitious
observer

\begin{equation}\label{s-prim}
\ve{s}^\prime=-\ve{n}+\OO4
\end{equation}

\noindent
as can be calculated from
(\ref{aberration}) for $\dot{\ve{x}}_o=0$.  On the other hand, the
transformation between the directions toward the source observed by the
two observers located at the same point of space-time can be derived
from the usual Lorentz transformation which can be used in its closed
form to speed up the practical calculations (F.~Mignard 2000, private
communication). The Lorentz transformation depends only on the velocity
of one observer as seen by the other one $\ve{v}$. Hence, using the
Lorentz transformation in its closed form one gets

\begin{eqnarray}\label{aberration-Lorentz}
\ve{s}&=&\left(\ve{s}^\prime+
\left\{\,{\Gamma\over c\,}+
\left[\,\Gamma-1\,\right]\,
{\ve{v}\cdot\ve{s}^\prime\over |\ve{v}|^2}\,\right\}\,\ve{v}\,
\right)\,
{1\over \Gamma\,\left(1+\ve{v}\cdot\ve{s}^\prime/c\right)},
\\ \label{Gamma}
\Gamma&=&{1\over \sqrt{1-|\ve{v}|^2/c^2}}.
\end{eqnarray}

\noindent
It is easy to show from (\ref{aberration-Lorentz}) that
$\ve{s}^\prime\,\cdot\,\ve{s}^\prime=1$ implies $\ve{s}\,\cdot\,\ve{s}=1$. The
velocity of the satellite as measured by the fictitious observer
$\ve{v}$ can again be calculated either with the help of the tetrad
formalism \citep[e.g.][]{Brumberg:1986} or by considering the local
reference system for the fictitious observer
\citep{Klioner:Kopeikin:1992,Klioner:1993}. The latter line of
arguments leads to an equation similar to (\ref{Va-deltavi}) where one
should put to zero the BCRS velocity of the fictitious observer (this
corresponds to $\ve{v}_E=0$ in (\ref{Va-deltavi})), its BCRS
acceleration ($\ve{a}_E=0$ in (\ref{Va-deltavi})) as well as the
position of the satellite relative to the local reference system
($\ve{r}_{oE}=0$ in (\ref{Va-deltavi})). Therefore, one gets

\begin{equation}\label{velocity-renormalization}
\ve{v} = \dot{\ve{x}}_o\,
\left(\,1+{1\over c^2}\,(1+\gamma)\,w(\ve{x}_o)\,\right)+\OO4.
\end{equation}

\noindent
It is this renormalization of the velocity of the satellite which leads
to the $w$-dependent terms in (\ref{aberration}). It is easy to check
that formulas
(\ref{s-prim})--(\ref{velocity-renormalization}) are
equivalent to (\ref{aberration}).

Alternatively, it is easy to calculate a formula relating the observed
angular distance $\varphi_{12}^{\rm obs}$ ($\cos\varphi_{12}^{\rm
obs}=\ve{s}_1\cdot\ve{s}_2$) between two given sources to the
coordinate angular distance $\varphi_{12}^{\rm coord}$ between them
($\cos\varphi_{12}^{\rm coord}=\ve{n}_1\cdot\ve{n}_2$):

\begin{eqnarray}\label{aberration-cos}
\cos\varphi_{12}^{\rm obs}=
\cos\varphi_{12}^{\rm coord}
+\left(\cos\varphi_{12}^{\rm coord}-1\right)&
\Biggl[&
-\left(1+{1\over c^2}\,(1+\gamma)\,w(\ve{x}_o)\right)\,{|\dot{\ve{x}}_o|\over c}\,
(\cos\theta_1+\cos\theta_2)
\nonumber\\
&&
+{|\dot{\ve{x}}_o|^2\over c^2}\,
(\cos^2\theta_1+\cos^2\theta_2+\cos\theta_1\,\cos\theta_2-1)
\nonumber\\
&&
-{|\dot{\ve{x}}_o|^3\over c^3}\,
(\cos\theta_1+\cos\theta_2)\,
(\cos^2\theta_1+\cos^2\theta_2-1)
\Biggr]
\nonumber\\
&&
+\OO4,
\end{eqnarray}

\noindent
where $\theta_i$ are the angles between the direction toward the $i$th
source and the direction of the velocity $\dot{\ve{x}}_o$:

\begin{eqnarray}\label{psi-i}
\cos\theta_i&=&-{1\over |\dot{\ve{x}}_o|}\ve{n}_i\,\cdot\,\dot{\ve{x}}_o,\qquad i=1,2.
\end{eqnarray}

The terms in (\ref{aberration}) and
(\ref{aberration-cos}) proportional to $w$ are the largest terms of the
third order. The third-order terms are of order 1 \muas\
and, therefore, the potential $w$ can be approximated here by the
potential of the spherically symmetric Sun

\begin{eqnarray}\label{U-sun}
w(\ve{x}_o)\approx{GM_{\rm sun}\over |\ve{x}_o-\ve{x}_{\rm Sun}|}.
\end{eqnarray}

%\noindent
%and the PPN parameter $\gamma$ may be replaced by its value in General
%Relativity ($\gamma=1$).

\noindent
A closed-form expression equivalent to (\ref{aberration-cos}) can be
derived from (\ref{aberration-Lorentz}):

\begin{eqnarray}\label{aberration-cos-Lorenz}
1-\cos\varphi_{12}^{\rm obs}&=&
\left(1-\cos\varphi_{12}^{\rm coord}\right)\,
{1-\displaystyle{\left|\ve{v}\right|^2\over c^2} \over
\displaystyle\left(1+{\left|\ve{v}\right|\over c}\,\cos\theta_1\right)
\displaystyle\left(1+{\left|\ve{v}\right|\over c}\,\cos\theta_2\right)},
\end{eqnarray}

\noindent
where $\ve{v}$ is defined by (\ref{velocity-renormalization}).

For order-of-magnitude estimations it is also useful to derive a
formula for the angular shift $\delta\theta$ of the source toward the
apex of the satellite's motion:

\begin{eqnarray}\label{aberation-angle}
\delta\theta&=&{1\over c}\,|\dot{\ve{x}}_o|\,\sin\theta\
\left(1+{1\over c^2}\,(1+\gamma)\,w(\ve{x}_o)+{1\over 4}\,{|\dot{\ve{x}}_o|^2\over c^2}
\right)
\nonumber\\
&&
-{1\over 4}\,{|\dot{\ve{x}}_o|^2\over c^2}\,\sin2\theta
+{1\over 12}\,{|\dot{\ve{x}}_o|^3\over c^3}\,\sin3\theta
+\OO4
\end{eqnarray}

\noindent
or in the closed form

\begin{eqnarray}\label{aberation-angle-Lorenz}
\cos(\theta-\delta\theta)=
{{\cos\theta+\displaystyle{\left|\ve{v}\right|\over c}}
\over
{1+\displaystyle{\left|\ve{v}\right|\over c}\,\cos\theta}}.
\end{eqnarray}

\noindent
Here $\theta$ is the angle between the direction toward the source and
the direction of the satellite's velocity
$\cos\theta=-\ve{n}\,\cdot\,\ve{v}\,/\,|\ve{v}|=-\ve{n}\,\cdot\,\dot{\ve{x}}_o\,/\,|\dot{\ve{x}}_o|$.

\section{Gravitational light deflection}
\label{Section-gravitational-deflection}

The next step is to account for the gravitational
light defection, that is to convert $\ve{n}$  into the corresponding
unit coordinate direction $\ve{k}$ from the observed source at the
moment of emission to the observer at the moment of observation. Here
two different cases should be distinguished: (1) objects outside of the
Solar system for which their finite distance from the origin of the
BCRS plays [almost] no role for this step of the reduction scheme, and
(2) Solar system objects, the finite distance of which must be taken
into account. Let us first relate $\ve{n}$ to the unit coordinate
direction $\vecg{\sigma}$ of the light propagation infinitely far from
the gravitating sources for $t\to-\infty$ and then consider the
influence of the finite distance to the objects on the gravitational
light deflection separately for these two classes of objects (Sections
\ref{Subsection-coupling-solar-system} and
\ref{Subsection-coupling-stars} below).

The Solar system is assumed here to be isolated. This means that the
gravitational field produced by the matter outside of the Solar system
is neglected.  This assumption is well founded if the time dependence of
the gravitational field produced outside of the Solar system is
negligible. Otherwise the external gravitational field must be
explicitly taken into account (e.g. for observations of edge-on binary
stars, where the gravitational field of the companion can cause an
additional time-dependent light deflection, or for astrometric
microlensing events). Some of such cases will be discussed below in
Section \ref{Section-beyond-the-model}.

The equations of light propagation can be derived from the
general-relativistic Maxwell equations \citep{Misner:Thorne:Wheeler:1973}.
It is sufficient, however, to
consider only the limit of geometric optics. The relativistic effects
depending on wavelength (and therefore representing deviations from
geometric optics) are much smaller than 1 \muas\ in the Solar system
\citep[see, e.g.][]{Mashhoon:1974b}. In the limit of geometric optics
the relativistic equations of light propagation can be written in the
form

\begin{eqnarray}\label{x-p}
\ve{x}_p(t)=\ve{x}_p(t_o)+c\,\vecg{\sigma}\,(t-t_o)+\Delta\ve{x}_p(t),
\end{eqnarray}

\noindent
where $t_o$ is the moment of observation, $\ve{x}_p(t_o)$ is the
position of the photon at the moment of observation (this position
obviously coincides with the position of the satellite at that moment
$\ve{x}_p(t_o)=\ve{x}_o(t_o)$), $\vecg{\sigma}$ is the unit coordinate
direction of the light propagation at the past null infinity
($\vecg{\sigma}\cdot\vecg{\sigma}=1$)

\begin{eqnarray}\label{sigma}
\vecg{\sigma}=\lim_{t\to-\infty} {1\over c}\,\dot{\ve{x}}_p(t),
\end{eqnarray}

\noindent
and $\Delta\ve{x}_p$ is the sum of all gravitational effects in the
light propagation which satisfies the conditions

\begin{eqnarray}\label{condition1}
\Delta\ve{x}_p(t_o)&=&0,
\\
\label{condition2}
\lim\limits_{t\to-\infty}\Delta\dot{\ve{x}}_p(t)&=&0.
\end{eqnarray}

\noindent
From the BCRS metric \citep{IAU:2001} one can easily see that
$\Delta\ve{x}_p(t)\sim{\cal O}(c^{-2})$ and ${1\over
c}\,\Delta\dot{\ve{x}}_p(t)\sim{\cal O}(c^{-2})$.

Several effects in $\Delta\ve{x}_p$ should be apriori considered at the
level of 1 \muas: (1) the effects of the spherically symmetric part of
the gravitational field of each sufficiently large gravitating body,
(2) the effects due to the non-sphericity (mainly due to the quadrupole
moments) of the bodies, (3) the effects caused by the gravitomagnetic
field due to the translational motion of the bodies, (4) the effects
caused by the gravitomagnetic field due to the rotational motion of the
bodies. The reduction formulas for all there effects have been derived
and discussed in detail by
\citet{Brumberg:Klioner:Kopejkin:1990,Klioner:1991a,Klioner:1991b,Klioner:Kopeikin:1992}.

Table \ref{Table-gravitational-deflection} illustrates the maximal
magnitudes of the various gravitational effects due to the Solar system
bodies and the maximal angular distances between the source and the
body at which the gravitational light deflection from that body should
still be accounted for to attain the final accuracy of 1 \muas. Note
that the values in Table \ref{Table-gravitational-deflection} are
slightly different from those published by
\citet{Brumberg:Klioner:Kopejkin:1990,Klioner:2000}. The reason for
this discrepancy is that for Table \ref{Table-gravitational-deflection}
the best current estimates for the physical parameters of the Solar
system bodies were taken from \citet{Weissman:et:al:1999}, whereas the
IAU (1976) system of astronomical constants was used for the previous
publications.

%%%   the effects one by one?

One can see that the post-post-Newtonian terms attain 1 \muas\ only
within 53\arcmin\ from the Sun and can be currently neglected in the
case of space astrometry since none of the proposed satellites could
observe so close to the Sun. For the same reason the effect due to the
rotational motion of the Sun amounting to 0.7 \muas\ for a grazing ray
is unobservable. The largest observable effect due to the rotational
motion is 0.2 \muas\ for a light ray grazing Jupiter. Therefore, the
effects due to the rotational motion of the bodies are also too small
to be taken into account.

The largest contribution in $\Delta\ve{x}_p$ for Solar system
applications comes from the spherically symmetric components of the
gravitational fields of the massive bodies and can be calculated as

\begin{eqnarray}\label{delta-x-p-schwarzschild}
\Delta_{pN}\ve{x}_p(t)&=&-\sum_A\,{(1+\gamma)GM_A\over c^2}\,
\biggl(\,\ve{d}_A\,{\cal I}_A\, +\vecg{\sigma}\, {\cal J}_A\biggr),
\\
\label{vector-d-A}
\ve{d}_A&=&\vecg{\sigma}\,\times\,(\ve{r}_{oA}\,\times\,\vecg{\sigma}),
\\
\label{I}
{\cal I}_A&=&{1\over |\ve{r}_A|-\vecg{\sigma}\cdot\ve{r}_A}-
  {1\over |\ve{r}_{oA}|-\vecg{\sigma}\cdot\ve{r}_{oA}},
\\
\label{J}
{\cal J}_A&=&\log { |\ve{r}_A|+\vecg{\sigma}\cdot\ve{r}_A\over
|\ve{r}_{oA}|+\vecg{\sigma}\cdot\ve{r}_{oA}},
\\
\label{R-A}
\ve{r}_A&=&\ve{x}_p(t)-\ve{x}_A,
\\
\label{R-A0}
\ve{r}_{oA}&=&\ve{x}_p(t_o)-\ve{x}_A=\ve{x}_o(t_o)-\ve{x}_A,
\end{eqnarray}

\noindent
so that

\begin{eqnarray}\label{delta-dot-x-p-schwarzschild}
{1\over c}\,\Delta_{pN}\dot{\ve{x}}_p(t)&=&-\sum_A\,{(1+\gamma)GM_A\over c^2}\,
\biggl(\,\ve{d}_A\,{1\over c}\,
\dot{\cal I}_A\,+\vecg{\sigma}\,{1\over c}\,\dot{\cal J}_A\biggr),
\\
\label{I-dot}
{1\over c}\,\dot{\cal I}_A&=&{1\over |\ve{r}_A|\,(|\ve{r}_A|-\vecg{\sigma}\cdot\ve{r}_A)},
\\
\label{J-dot}
{1\over c}\,\dot{\cal J}_A&=&{1\over |\ve{r}_A|},
\end{eqnarray}

\noindent
where $\ve{x}_A$ is the position and $M_A$ is the mass of body A.

The positions of the bodies $\ve{x}_A$ are supposed to be constant in
(\ref{delta-x-p-schwarzschild})--(\ref{J-dot}). In reality, however,
the bodies are moving and this motion cannot be neglected in the
calculation of light deflection. It is hardly possible to calculate
analytically the light path in the gravitational field of an
arbitrarily moving body without resorting to some approximations
\citep[see, however,][]{Kopeikin:Schaefer:1999}. On the other hand,
numerical integration of the equations of light propagation which could
be used here as a remedy is too impractical for massive calculations
necessary in astrometry. Let us, therefore, consider a Taylor expansion
of $\ve{x}_A$:

\begin{equation}\label{x-A-expansion}
\ve{x}_A(t)=\ve{x}^{\rm eph}_A(t_{A0}) +\dot{\ve{x}}^{\rm eph}_A(t_{A0})\,(t-t_{A0})
+{\cal O}(\ddot{\ve{x}}^{\rm eph}_A).
\end{equation}

\noindent
Note that here $\ve{x}^{\rm eph}_A(t_{A0})$ and $\dot{\ve{x}}^{\rm
eph}_A(t_{A0})$ are the actual position and velocity of body $A$ taken
from an ephemeris for some moment $t_{A0}$, while $\ve{x}_A(t)$ is the model
for the position of body $A$ to be used for the approximate calculation
of the light propagation. One can integrate the equations of motion for
a light ray using (\ref{x-A-expansion}) for the coordinates of the
gravitating body. The solution was first derived by
\citet{Klioner:1989} and describes the light propagation in the
post-Newtonian approximation under the assumption that the gravitating
bodies move with a constant velocity (only the effects linear with
respect to velocity $\dot{\ve{x}}_A$ were taken into account, since
formally the terms quadratic in $\dot{\ve{x}}_A$ are of
post-post-Newtonian order $\OO4$). However, expansion
(\ref{x-A-expansion}) has a free parameter $t_{A0}$ which can be used
to minimize the error in the light propagation equations caused by the
higher-order terms neglected in (\ref{x-A-expansion}).
From an analysis of the residual terms in
the equations of light propagation proportional to the accelerations of
the bodies
\citet{Klioner:Kopeikin:1992}
have shown that one reasonable choice which guarantee the
residual effects to be negligible within the chosen approximation
scheme is to set $t_{A0}$ equal to the moment of the closest approach
$t^{\rm ca}_{A0}$ of the body and the photon

\begin{eqnarray}\label{moment-of-closest-approach}
t^{\rm ca}_{A0}&=&\max\left(t_e,t_o-
\max\left(0,{\ve{g}\cdot (\ve{x}_o(t_o)-\ve{x}^{\rm eph}_A(t_o))
             \over c\,|\ve{g}|^2}\right)
\right),
\\
\label{vector-g}
\ve{g}&=&\vecg{\sigma}-{1\over c}\,\dot{\ve{x}}^{\rm eph}_{A}(t_o),
\end{eqnarray}

\noindent
where $t_e$ is the time of emission of the light ray by the source (for
sources located outside of the Solar system one can put $t_e=-\infty$
so that the outer '$\max$' in (\ref{moment-of-closest-approach}) can be
omitted).

Recently an advanced formalism to integrate the equations of light
propagation in the field of arbitrarily moving gravitating bodies has
been developed by \citet{Kopeikin:Schaefer:1999}
and \citet{Kopeikin:Mashhoon:2002}. The authors suggest
to use the solution of the Einstein field equations in the form of retarded
potentials so that the positions of the gravitating bodies are computed
for the retarded moment of time

\begin{equation}\label{retarded-moment}
t^{\rm r}_{A0}=t_o-{1\over c}\,|\ve{x}_o(t_o)-\ve{x}^{\rm eph}_A(t^r_{A0})|,
\end{equation}

\noindent
and derive rigorous laws of the light propagation in the gravitational
field of arbitrarily moving point masses in the first post-Minkowskian
approximation (i.e. all the terms of order ${\cal O}(G^2)$ are
neglected). Using their rigorous approach the authors prove, however,
that if the positions and velocities of the bodies are calculated at
$t^{\rm r}_{A0}$ the effects due to the accelerations of the
gravitating bodies as well as those proportional to the second and
higher orders of velocities $\dot{\ve{x}}_{A}$ are much smaller than 1
\muas\ for Solar system applications and thereby completely negligible
for our model. On the other hand, if the effects due to the
accelerations and those of the second and higher orders with respect to
the velocities are neglected, so that each body is supposed to move with
a constant velocity the formulas for $\Delta\ve{x}_p(t)$
derived by \citep{Klioner:1989,Klioner:Kopeikin:1992} and those derived
by \citep{Kopeikin:Schaefer:1999} coincide. If the bodies are supposed
to move uniformly and rectilinearly and only the first-order terms with
respect of the velocities are taken into account, the resulting
solution for the light propagation can be considered as a numerical
approximation to the rigorous solution derived by
\citet{Kopeikin:Schaefer:1999}. The parameter $t_{A0}$ remains a free
parameter of this approximate solution. The approach due to
\citet{Kopeikin:Schaefer:1999} does not prove that the choice
$t_{A0}=t^{\rm r}_{A0}$ gives minimal residual terms in such an
approximate solution. It is not clear which moment $t^{\rm r}_{A0}$ or
$t^{\rm ca}_{A0}$ is numerically more advantageous to use in
(\ref{x-A-expansion}). However, if the effects explicitly proportional
to $\dot{\ve{x}}_A$ are taken into account to compute the light path,
the difference between the solutions for $t_{A0}=t^{\rm ca}_{A0}$ and
for $t_{A0}=t^{\rm r}_{A0}$ in the gravitational field of the Solar
system is several orders of magnitude lower than 1~\muas.

The effect explicitly proportional to $\dot{\ve{x}}_A$ has been
investigated in detail by
\citet{Klioner:1989}, \citet{Klioner:Kopeikin:1992} and
\citet{Kopeikin:Schaefer:1999}. If
the position of the body is taken for $t_{A0}=t^{\rm ca}_{A0}$ or
$t_{A0}=t^{\rm r}_{A0}$ this effect in the light deflection can be
estimated as $\delta_{T^\star}\sim {1\over
c}\,|\dot{\ve{x}}_A|\,\delta_{pN}$, where $\delta_{pN}$ is the
deflection induced by the spherically symmetric field of the body.
According to Table~\ref{Table-gravitational-deflection},
$\delta_{T^\star}$ may amount to 0.8 \muas\ for a light ray grazing Jupiter
and only 0.1 \muas\ in the case of the Sun. However, $\delta_{pN}$
attains its maximal value when the impact parameter of the light ray is
much smaller than the distances between the gravitating body and the
points of emission and observation. For this case one can prove that
$\delta_{T^\star}\sim {1\over c}\,
\left(\ve{\sigma}\cdot\dot{\ve{x}}_A\right)\,\delta_{pN}$. For the
special case of an observer situated near the Earth orbit the cosine
factor in $\ve{\sigma}\cdot\dot{\ve{x}}_A$ reduces the effects produced
by Jupiter and Saturn in their orbital motion by a factor of at least 4
and 6, respectively. Therefore, the effects explicitly proportional to
the velocities of the bodies can be neglected in our model.

If the effects due to the velocity of the body are completely
neglected, we effectively use a constant value

\begin{equation}\label{x-A-expansion-0}
\ve{x}_A(t)=\ve{x}_A(t_{A0})
\end{equation}

\noindent
for the coordinates of the bodies. Numerical simulations show that
in the gravitational field of the Solar system the
difference of the light deflection angle calculated using
$t_{A0}=t^{\rm ca}_{A0}$ and that using $t_{A0}=t^{\rm r}_{A0}$ in
(\ref{x-A-expansion-0}) does not exceed 0.01~\muas. Therefore, for
practical purposes both $t^{\rm ca}_{A0}$ and $t^{\rm r}_{A0}$ can be
used and $\ve{x}_A$ should be taken to be $\ve{x}_A(t^{\rm ca}_{A0})$
or $\ve{x}_A(t^{\rm r}_{A0})$ in (\ref{R-A})--(\ref{R-A0}) and all
related formulas. Note, however, that, e.g. the use of the moment of
reception $t_o$ instead of $t^{\rm ca}_{A0}$ or $t^{\rm r}_{A0}$ in
(\ref{x-A-expansion-0}) may lead to a significant error in the
calculated gravitational light deflection. This maximal error of this kind
can be roughly estimated as
$|\ve{r}_{oA}|/L\,\cdot\,|\dot{\ve{x}}_A|/c\,\cdot\,\delta_{pN}$, where
$L$ is the radius of the body and may amount to $\sim10$~mas in the
case of Jupiter.

%%%   other smaller bodies

It is to note that a number of smaller bodies should be also taken into
account. For a spherical body with the mean density $\rho$, the light
deflection is larger than $\delta$ if its radius

\begin{equation}\label{L-rho-delta}
L\ge \left(\rho\over 1\,{\rm g/cm^3}\right)^{-1/2}\,
     \left(\delta\over 1\,\muas\right)^{1/2}\,
     624\,{\rm km}.
\end{equation}

\noindent
Therefore, at the level of 1 \muas\ (and even 10 \muas) one should
additionally account for several largest satellites of the giant planets,
Pluto and
Charon, and also Ceres. The maximal values of the effects produced by
these bodies are evaluated in Table
\ref{Table-gravitational-deflection}. It is clear, however, that the
gravitational light deflection due to these small bodies could be
larger than 1 \muas\ only if a source is observed very close to the
corresponding body. The maximal angular distances at which this additional
gravitational deflection should be taken into account are also given in
Table \ref{Table-gravitational-deflection}.

Finally, the effects of the quadrupole fields of the giant planets should be
taken into account if the angular distance between the planet and the
object is smaller than the values given in the sixth column of Table
\ref{Table-gravitational-deflection}. The corresponding reduction
formulas for $\Delta_{Q}\ve{x}_p(t)$ and $\Delta_{Q}\dot{\ve{x}}_p(t)$
derived by \citet{Klioner:1991a} and \citet{Klioner:Kopeikin:1992} read

\begin{eqnarray}\label{delta-x-p-Q}
\Delta_{Q}\ve{x}_p(t)&=&
{1\over 2\,c^2}\,(1+\gamma)\,G\,\sum_A\,
\left(
\vecg{\alpha}_A\,{\cal U}_A
+\vecg{\beta}_A\,{\cal E}_A
+\vecg{\gamma}_A\,{\cal F}_A
+\vecg{\delta}_A\,{\cal V}_A
\right),
\\
\label{U}
{\cal U}_A&=&
{1\over |\ve{d}_A|}\,\left(
{1\over |\ve{r}_A|}\,
{|\ve{r}_A|+\vecg{\sigma}\cdot\ve{r}_A\over
 |\ve{r}_A|-\vecg{\sigma}\cdot\ve{r}_A}
-{1\over |\ve{r}_{oA}|}\,
{|\ve{r}_{oA}|+\vecg{\sigma}\cdot\ve{r}_{oA}\over
 |\ve{r}_{oA}|-\vecg{\sigma}\cdot\ve{r}_{oA}}
\right),
\\
\label{E}
{\cal E}_A&=&{\vecg{\sigma}\cdot\ve{r}_A\over |\ve{r}_A|^3}
-{\vecg{\sigma}\cdot\ve{r}_{oA}\over |\ve{r}_{oA}|^3},
\\
\label{F}
{\cal F}_A&=&|\ve{d}_A|\,\left({1\over |\ve{r}_A|^3}
-{1\over |\ve{r}_{oA}|^3}\right),
\\
\label{V}
{\cal V}_A&=&
-{1\over |\ve{d}_A|^2}\,\left(
{\vecg{\sigma}\cdot\ve{r}_A\over |\ve{r}_A|}
-{\vecg{\sigma}\cdot\ve{r}_{oA}\over |\ve{r}_{oA}|}\right),
\\
\label{ve-alpha}
\vecg{\alpha}_A&=&2\,\ve{f}_A-2\,(\ve{f}_A\cdot\vecg{\sigma})\,\vecg{\sigma}
-(\ve{g}_A\cdot\vecg{\sigma}+4\,\ve{f}_A\cdot\ve{h}_A)\,\ve{h}_A,
\\
\label{ve-beta}
\vecg{\beta}_A&=&2\,(\ve{f}_A\cdot\vecg{\sigma})\,\ve{h}_A
+(\ve{g}_A\cdot\vecg{\sigma}-\ve{f}_A\cdot\ve{h}_A)\,\vecg{\sigma},
\\
\label{ve-gamma}
\vecg{\gamma}_A&=&2\,(\ve{f}_A\cdot\vecg{\sigma})\,\vecg{\sigma}
-(\ve{g}_A\cdot\vecg{\sigma}-\ve{f}_A\cdot\ve{h}_A)\,\ve{h}_A,
\\
\label{ve-delta}
\vecg{\delta}_A&=&2\,\ve{g}_A-4\,(\ve{f}_A\cdot\vecg{\sigma})\,\ve{h}_A
-(\ve{g}_A\cdot\vecg{\sigma}-2\,\ve{f}_A\cdot\ve{h}_A)\,\vecg{\sigma},
\end{eqnarray}


\begin{eqnarray}\label{delta-dot-x-p-Q}
{1\over c}\,\Delta_{Q}\dot x^i_p(t)&=&
{1\over 2\,c^2}\,(1+\gamma)\,G\,\sum_A\,
\left(
\vecg{\alpha}_A\,{1\over c}\,\dot{\cal U}_A
+\vecg{\beta}_A\,{1\over c}\,\dot{\cal E}_A
+\vecg{\gamma}_A\,{1\over c}\,\dot{\cal F}_A
+\vecg{\delta}_A\,{1\over c}\,\dot{\cal V}_A
\right),
\\
\label{dot-U}
{1\over c}\,\dot{\cal U}_A&=&|\ve{d}_A|\,
{2|\ve{r}_A|-\vecg{\sigma}\cdot\ve{r}_A\over
 |\ve{r}_A|^3\,(|\ve{r}_A|-\vecg{\sigma}\cdot\ve{r}_A)^2},
\\
\label{dot-E}
{1\over c}\,\dot{\cal E}_A&=&
{|\ve{r}_A|^2-3(\vecg{\sigma}\cdot\ve{r}_A)^2\over|\ve{r}_A|^5},
\\
\label{dot-F}
{1\over c}\,\dot{\cal F}_A&=&-3\,|\ve{d}_A|\,
{\vecg{\sigma}\cdot\ve{r}_A\over|\ve{r}_A|^5},
\\
\label{dot-V}
{1\over c}\,\dot{\cal V}_A&=&-{1\over|\ve{r}_A|^3},
\end{eqnarray}

\noindent
where $\ve{h}_A=\ve{d}_A/|\ve{d}_A|$, $f^i_A=M_{ij}^A\,h^j_A$,
$g^i_A=M_{ij}^A\,\sigma^j$, and $M_{ij}^A$ is the symmetric trace-free
quadrupole moment of body A. From the point of view of the theory of
relativistic local reference systems, the multipole structure of the
gravitational field of a body is defined in the corresponding local
reference system of that body. However, for the calculation of the
gravitational light deflection due to the quadrupole field the
relativistic effects in $M^A_{ij}$ can be neglected. Matrix $M^A_{ij}$
is symmetric and trace-free and has, therefore, five independent
components which can be calculated from the second zonal harmonic
coefficient $J^A_2$ (in the case of the giant planets other
coefficients of the second order are negligible), the mass $M_A$ and
the equatorial radius $L_A$ of the planet, and the equatorial
coordinates $(\alpha^A_{\rm pole},\delta^A_{\rm pole})$ of the north
pole of its figure axis:

\begin{equation}\label{MAij-matrix}
M^A_{ij}=M_A\,L_A^2\,J_2^A\,\pmatrix{A&B&C\cr B&D&E\cr C&E&-A-D},
\end{equation}

\begin{eqnarray}
\label{A}
A&=&{1\over 3}-\cos^2\!\alpha^A_{\rm pole}\,\cos^2\!\delta^A_{\rm pole},
\\
\label{B}
B&=&-{1\over 2}\sin2\alpha^A_{\rm pole}\,\cos^2\!\delta^A_{\rm pole},
\\
\label{C}
C&=&-{1\over 2}\cos\alpha^A_{\rm pole}\,\sin2\delta^A_{\rm pole},
\\
\label{D}
D&=&{1\over 3}-\sin^2\!\alpha^A_{\rm pole}\,\cos^2\!\delta^A_{\rm pole},
\\
\label{EE}
E&=&-{1\over 2}\sin\alpha^A_{\rm pole}\,\sin2\delta^A_{\rm pole}.
\end{eqnarray}

Various post-Newtonian gravitational effects in the light propagation
(e.g. $\Delta_{pN}\ve{x}_p$ and $\Delta_{Q}\ve{x}_p$) are additive and
one can put

\begin{equation}\label{delta-x-p-additive}
\Delta\ve{x}_p=\Delta_{pN}\ve{x}_p+\Delta_{Q}\ve{x}_p.
\end{equation}

\noindent
Note that any additional post-Newtonian effects can be added in
(\ref{delta-x-p-additive}) if needed (e.g. the effects of the
rotational and/or translational motion of the gravitating bodies).

%%%  higher multipoles

As first discussed by \citet{Klioner:1991a}, the higher-order multipole
moments of Jupiter and Saturn may produce a deflection larger than
1~\muas, provided that the source is observed very close to the
surfaces of the planets. It is easy to see that the maximal
gravitational light deflection produced by the zonal spherical
harmonics $J_n$ (all other harmonics are utterly small for the giant
planets) can be estimated as $\delta_{J_n}\sim J_n\,\delta_{pN}$. Using
modern values for $J_n$ of Jupiter and Saturn \citep[p.
342]{Weissman:et:al:1999} one can check that it is only the effects of
$J_4$ of Jupiter and Saturn which may exceed 1~\muas. Namely, the
effect of $J_4$ of Jupiter may amount to 10~\muas\ and that of Saturn
is not greater than 6~\muas. The effect of $J_n$ decreases as
$\cot^{n+1}\psi$ with the angular distance $\psi$ between the
gravitating body and the source. Therefore, the effect of $J_4$ of
Jupiter exceeds 1~\muas\ only if the angular distance $\psi$ between
the center of Jupiter and the source is smaller than 1.6 of the
apparent angular radius of Jupiter (i.e. smaller than 24 -- 39\arcsec\
depending on the mutual configuration of Jupiter and the observer).
For $J_4$ of Saturn $\psi$ should be less than 1.4 of the apparent
radius (i.e. less than 10 -- 14\arcsec\ depending on the
configuration). The influence of $J_6$ of Jupiter and Saturn also may
exceed 1~\muas\ if the real values of $J_6$ (which are known with a
large uncertainty for both planets) are larger than the values given by
\citet{Weissman:et:al:1999}. If the observations so close to Jupiter
and Saturn are to be processed, the reduction formulas for the effect
of $J_4$ can be derived from formulas given by \citet{Kopeikin:1997}.

Let us note also that, generally speaking, the standard expansion of
the gravitational potential of a body in terms of spherical functions
(with harmonic coefficients like $J_n$) converges only outside of the
sphere encompassing the body. Therefore, in general case the
calculation of the gravitational light deflection for a light ray
passing between the encompassing sphere and the surface of a body
requires some other representation of the body's gravitational
potential. As discussed above for the accuracy level of 1~\muas\ the
non-sphericity of the gravitational field must be taken into account
for the giant planets only. Since the polar radii of the giant planets
are significantly smaller than their equatorial radii, impact parameter
may be smaller than the equatorial radius of the body and, therefore,
smaller than the radius of the encompassing sphere. However, the
gravitational fields of the giant planets are close to that of a
homogeneous axisymmetrical ellipsoid $(x^2+y^2)/a^2+z^2/c^2\le1$ with
$c<a$, for which the gravitational potential can be expanded as
\citep[][p. 187]{Antonov:Timoshkova:Kholshevnikov:1988}

\begin{eqnarray}\label{ellipsoid:U}
U(r,\vartheta)
%&=&{G\,M\over r}\,\sum_{n=0}^\infty\,
%(-1)^n\,
%{3\over (2n+1)\,(2n+3)}\,
%\left({\sqrt{a^2-c^2}\over r}\right)^{2n}\,P_{2n}(\cos\theta)
%\nonumber\\
&=&{G\,M\over r}\,\left(1-\sum_{n=1}^\infty\,
\left({a\over r}\right)^{2n}\,J^{\rm el}_{2n}\,P_{2n}(\cos\vartheta)\right),
\\
\label{J_2n_ellipsoid}
J^{\rm el}_{2n}&=&(-1)^{n+1}\,{3\over (2n+1)\,(2n+3)}\,\left(1-{c^2\over a^2}\right)^n,
\end{eqnarray}

\noindent
where $M$ is the mass of the ellipsoid, $P_{n}(x)$ is the Legendre
polynomial of order $n$, and $r$ and $\vartheta$ are the radial
distance and the co-latitude, respectively. It is easy to see that
expansion (\ref{ellipsoid:U})--(\ref{J_2n_ellipsoid}) converges for
$r\ge \sqrt{a^2-c^2}$. Therefore, this expansion converges  everywhere
outside the ellipsoid (i.e. for $r\ge c$) if $c\ge a/\sqrt{2}$.
Inequality $c\ge a/\sqrt{2}$ is true for all the giant planets of the
Solar system. Moreover, since the density of the giant planets is not
constant, but gets larger for smaller $r$ one should expect that the
actual values of $J_{2n}$ are smaller than those ``predicted'' by
(\ref{J_2n_ellipsoid}). For a few first coefficients $J_{2n}$ it can be
explicitly seen: the actual values of $J_2$, $J_4$ and $J_6$ given by
\citet{Weissman:et:al:1999} are a factor 1.7--3.3 smaller than the
corresponding coefficients from (\ref{J_2n_ellipsoid}). This means that
the expansion (\ref{ellipsoid:U}) with the actual zonal harmonics
$J_{2n}$ of a giant planet converges everywhere outside of that planet.
Therefore, for the giant planets for any impact parameter of the light
ray it is sufficient to consider the standard expansion of the
gravitational potential in terms of spherical harmonics (or,
equivalently, multipole moments) and take into account the first few
coefficients as discussed above.

%%%   vector n from vector p

Coordinate velocity of the photon can be obtained by taking time
derivative of (\ref{x-p}):

\begin{equation}\label{vector-p}
\ve{p}\equiv{1\over c}\,\dot{\ve{x}}_p(t_o)=\vecg{\sigma}
+{1\over c}\,\Delta\dot{\ve{x}}_p(t_o).
\end{equation}

\noindent
The unit coordinate direction of the light propagation at the moment of
observation reads

\begin{equation}\label{vector-n-via-vector-p}
\ve{n}={\ve{p}\over|\ve{p}|}.
\end{equation}

\noindent
Eqs. (\ref{vector-p})--(\ref{vector-n-via-vector-p}) are more
convenient for numerical calculations than an analytical expansion of
$\ve{n}$ in terms of $\vecg{\sigma}$ and $\Delta\dot{\ve{x}}_p$ which
can be derived by substituting (\ref{vector-p}) into
(\ref{vector-n-via-vector-p}) and expanding in powers of $c^{-1}$.
However, the accuracy of 1 \muas\ can be attained with the simplified
first-order expansion of
(\ref{vector-p})--(\ref{vector-n-via-vector-p})

\begin{equation}\label{ve-n}
\ve{n}=\vecg{\sigma}
+{1\over c}\,\vecg{\sigma}\,\times\,(\Delta\dot{\ve{x}}_p(t_o)\,\times\,
\vecg{\sigma})
\end{equation}

\noindent
if the distance from the observer to the Sun (all other bodies play no
role here) is larger than 0.035~AU which is the case for all
currently proposed astrometrical missions. Therefore,

\begin{eqnarray}\label{ve-p-additive}
\ve{n}&=&\vecg{\sigma}+\delta\vecg{\sigma}_{pN}+\delta\vecg{\sigma}_{Q},
\\
\label{delta-pN-n}
\delta\vecg{\sigma}_{pN}&=&
{1\over c}\,\vecg{\sigma}\,\times\,(\Delta_{pN}\dot{\ve{x}}_p(t_o)\,\times\,
\vecg{\sigma}),
\\
\label{delta-Q-n}
\delta\vecg{\sigma}_{Q}&=&
{1\over c}\,\vecg{\sigma}\,\times\,(\Delta_{Q}\dot{\ve{x}}_p(t_o)\,\times\,
\vecg{\sigma}).
\end{eqnarray}

\noindent
Using (\ref{delta-dot-x-p-schwarzschild}) one gets

\begin{equation}\label{delta-pN-n-explicit}
\delta\vecg{\sigma}_{pN}=-\sum_A\,{(1+\gamma)GM_A\over c^2}\,
\,{\ve{d}_A\over |\ve{d}_A|^2}\,\left(1+\vecg{\sigma}\cdot{\ve{r}_{oA}\over|\ve{r}_{oA}|}\right).
\end{equation}

\noindent
Hence the post-Newtonian deflection angle due to the spherically
symmetric part of the gravitational field of body $A$ reads

\begin{equation}\label{delta-pN}
\delta_{pN}=
{(1+\gamma)GM_A\over c^2\,|\ve{r}_{oA}|}\,\cot {\psi_A\over2},
\end{equation}

\noindent
where $\psi_A$ is the angular distance between body $A$ and the source.
It is this formula which was used to compute the data in the third
column of Table \ref{Table-gravitational-deflection}. The effect of the
quadrupole field $\delta\vecg{\sigma}_{Q}$ can be calculated by
substituting (\ref{delta-dot-x-p-Q})--(\ref{dot-V}) and
(\ref{ve-alpha})--(\ref{ve-delta}) with (\ref{MAij-matrix})--(\ref{EE})
into (\ref{delta-Q-n}).

\begin{table}
\begin{tabular}{lrrrrrrrrr}
body    & $\delta_{pN}$&  $\psi_{\rm max}(1\muas)$
                                            &$\psi_{\rm max}(10\muas)$
                                                                & $\delta_{Q}$
                                                                          & $\psi_{\rm max}(1\muas)$
                                                                                       &$\delta_{R}$
                                                                                                & $\delta_{T^*}$
                                                                                                        & $\delta_{ppN}$
                                                                                                              & $\psi_{\rm max}(1\muas)$ \\
        &             &                     &                   &          &           &        &       &     &             \\
\hline
        &             &                     &                   &          &           &        &       &     &             \\
Sun     &$1.75\cdot10^6$&  180\degr         &180\degr           & $\sim$1  &           & 0.7    & 0.1   & 11  & 53\arcmin   \\
Mercury
        & 83          &  9\arcmin           &54\arcsec          & ---      &           & ---    & ---   & --- &             \\
Venus   & 493         &  4.5\degr           &27\arcmin          & ---      &           & ---    & ---   & --- &             \\
Earth   & 574         &  178\degr/123\degr  &154\degr/21\degr   & 0.6      &           & ---    & ---   & --- &             \\
Moon    & 26          &  9\degr/5\degr      &49\arcmin/26\arcmin& ---      &           & ---    & ---   & --- &             \\
Mars    & 116         &  25\arcmin          &2.5\arcmin         & 0.2      &           & ---    & ---   & --- &             \\
Jupiter & 16270       &  90\degr            &11.3\degr          & 240      & 152\arcsec& 0.2    & 0.8   & --- &             \\
Saturn  & 5780        &  17\degr            &1.7\degr           &  95      & 46\arcsec & ---    & 0.2   & --- &             \\
Uranus  & 2080        &  71\arcmin          &7.1\arcmin         &   8      & 4\arcsec  & ---    & ---   & --- &             \\
Neptune & 2533        &  51\arcmin          &5\arcmin           &  10      & 3\arcsec  & ---    & ---   & --- &             \\
        &             &                     &                   &          &           &        &       &     &             \\
\hline
        &             &                     &                   &          &           &        &       &     &             \\
Ganymede& 35          &  32\arcsec          & 4\arcsec          &          &           &        &       &     &             \\
Titan   & 32          &  14\arcsec          & 2\arcsec          &          &           &        &       &     &             \\
Io      & 31          &  19\arcsec          & 2\arcsec          &          &           &        &       &     &             \\
Callisto& 28          &  23\arcsec          & 3\arcsec          &          &           &        &       &     &             \\
Europe  & 19          &  11\arcsec          & 1\arcsec          &          &           &        &       &     &             \\
Triton  & 10          &  0.7\arcsec         &                   &          &           &        &       &     &             \\
Pluto   &  7          &  0.4\arcsec         &                   &          &           &        &       &     &             \\
Titania &  2.8        &  0.2\arcsec         &                   &          &           &        &       &     &             \\
Oberon  &  2.4        &  0.2\arcsec         &                   &          &           &        &       &     &             \\
Rhea    &  1.9        &  0.3\arcsec         &                   &          &           &        &       &     &             \\
Charon  &  1.7        &  0.05\arcsec        &                   &          &           &        &       &     &             \\
Iapetus &  1.6        &  0.2\arcsec         &                   &          &           &        &       &     &             \\
Ariel   &  1.4        &  0.1\arcsec         &                   &          &           &        &       &     &             \\
Ceres   &  1.2        &  0.3\arcsec         &                   &          &           &        &       &     &             \\
Dione   &  1.2        &  0.2\arcsec         &                   &          &           &        &       &     &             \\
Umbriel &  1.2        &  0.1\arcsec         &                   &          &           &        &       &     &             \\
\end{tabular}
\caption{Various gravitational effects in the light propagation in
\muas: $\delta_{pN}$ and $\delta_{ppN}$ are the post-Newtonian and
post-post-Newtonian effects due to the spherically symmetric field of
each body, $\delta_{Q}$ are the effects due to the quadrupole
gravitational fields, $\delta_{R}$ and $\delta_{T^*}$ are the effects
due to the gravitomagnetic fields caused by the rotational and
translational motions of the bodies, respectively. The estimations of
$\delta_{T^*}$ are given for the case when the coordinates of the
gravitating bodies are taken at the moment of the closest approach of
the body and the photon (see text). Symbol ``---'' means that the
corresponding effect is smaller than 0.1 \muas. Physical parameters of
the bodies are taken from \citet{Weissman:et:al:1999}. Because of the
minimal Sun avoidance angle the influence of some bodies can neglected
for certain missions (for GAIA, e.g. Mercury is too close to the Sun
and can be neglected). The angle $\psi_{\rm max}(\delta)$ is the
maximal angular distance between the body and the source at which the
corresponding effect still attains $\delta$ (the smallest possible
distance between the observer and each body is taken here; $\psi_{\rm
max}(\delta)$ is smaller for larger distances). For these estimates the
observer is supposed to be within a few million kilometers from the
Earth orbit. For the Earth and the Moon two estimates are given: for a
geostationary satellite and for a satellite at a distance of $10^6$ km
from the Earth.
\label{Table-gravitational-deflection}
}
\end{table}

\subsection{Coupling of the finite distance to the source
and the gravitational deflection: Solar system objects}
\label{Subsection-coupling-solar-system}

The next step is to convert $\vecg{\sigma}$ into the unit vector
$\ve{k}$ directed from the point of emission to the point of
observation. Let $\ve{x}_o(t_o)$ be the coordinate of the observer
(satellite) at the moment of observation $t_o$ and $\ve{x}_s(t_e)$ be
the position of the source at the moment of emission $t_e$ of the
signal which was observed at $\ve{x}_o(t_o)$. The moment of emission
$t_e$ is considered as a function of the moment of observation $t_o$
(see Section \ref{Section-proper-motion} for further discussion). Let
us denote

\begin{equation}\label{ve-R}
\ve{R}=\ve{x}_o(t_o)-\ve{x}_s(t_e),
\end{equation}

\begin{eqnarray}\label{ve-k}
\ve{k}(t_o)={\ve{R}\over |\ve{R}|},
\end{eqnarray}

\noindent
It is easy to see that vector $\ve{k}$ is
related to $\vecg{\sigma}$ as \citep{Klioner:1991a}:

\begin{eqnarray}\label{sigma-k}
\vecg{\sigma}=\ve{k}+{1\over |\ve{R}|}\,\ve{k}\,\times\,
(\Delta\ve{x}_p(t_e)\,\times\,\ve{k})+\OO4.
\end{eqnarray}

\noindent
In the case of a Solar system object (\ref{sigma-k}) can be combined with
(\ref{ve-n}) to get

\begin{eqnarray}\label{n-k}
\ve{n}&=&\ve{k}+\delta\ve{k}_{pN}+\delta\ve{k}_{Q},
\\
\label{delta-k-pN}
\delta\ve{k}_{pN}&=&
\ve{k}\,\times\,
\left(\left({1\over |\ve{R}|}\,\Delta_{pN}\ve{x}_p(t_e)+
{1\over c}\,\Delta_{pN}\dot{\ve{x}}_p(t_o)\right)
\,\times\,\ve{k}\right),
\\
\label{delta-k-Q}
\delta\ve{k}_{Q}&=&
\ve{k}\,\times\,
\left(\left({1\over |\ve{R}|}\,\Delta_{Q}\ve{x}_p(t_e)+
{1\over c}\,\Delta_{Q}\dot{\ve{x}}_p(t_o)\right)
\,\times\,\ve{k}\right).
\end{eqnarray}

\noindent
Hence,

\begin{eqnarray}\label{delta-k-pN-explicit}
\delta\ve{k}_{pN}&=&-\sum_A\,{(1+\gamma)GM_A\over c^2}\,
{\ve{R}\times(\ve{r}_{eA}\times\ve{r}_{oA})\over |\ve{R}|\,|\ve{r}_{oA}|
\,(|\ve{r}_{eA}|\,|\ve{r}_{oA}|+\ve{r}_{oA}\cdot\ve{r}_{eA})},
\\
\label{ve-r-Ae}
\ve{r}_{eA}&=&\ve{x}_s(t_e)-\ve{x}_A.
\end{eqnarray}

\noindent
The angle between vectors $\ve{k}$ and $\ve{n}$ due to $\delta\ve{k}_{pN}$
can be calculated as

\begin{equation}\label{angle-k-n}
{(1+\gamma)GM_A\over c^2\,|\ve{r}_{oA}|}\,\tan{\phi\over2},
\end{equation}

\noindent
where $\phi$ is the angle between vectors $\ve{r}_{eA}$ and
$\ve{r}_{oA}$. Note that the angle (\ref{angle-k-n}) depends on the
distance $|\ve{r}_{oA}|$ between the gravitating body and the point of
observation and on $\phi$, but does not depend on the distance
$|\ve{r}_{eA}|$ between the point of emission and the gravitating body.
For a remote source $|\ve{r}_{eA}|\to\infty$ and one has
$\phi=\pi-\psi_A$ so that (\ref{angle-k-n}) coincides with
(\ref{delta-pN}).

The effect of the quadrupole field $\delta\ve{k}_{Q}$ can be calculated by
substituting (\ref{delta-x-p-Q})--(\ref{EE}) into (\ref{delta-k-Q}).

For an object located in the Solar system a set of vectors $\ve{k}$
calculated from the observed directions $\ve{s}$ for several different
moments of time $t_o$ allows one to determine the barycentric orbit of
that object. Therefore, vector $\ve{k}$ is the final result of the
model for the Solar system objects.

\subsection{Coupling of the finite distance to the source
and the gravitational deflection: objects outside the Solar system}
\label{Subsection-coupling-stars}

The only effect in $\Delta\ve{x}_p$ which should be taken into
account here for the objects located outside of the Solar system (with
$|\ve{x}_s|>1000$ AU) is the post-Newtonian gravitational deflection
from the spherically symmetric part of the gravitational field of the
Sun. In this case from (\ref{sigma-k}) one gets

\begin{eqnarray}\label{sigma-k-Schwarzschild}
\vecg{\sigma}&=&\ve{k}-{(1+\gamma)\,GM_{\rm Sun}\over c^2 |\ve{R}|}\,
{|\ve{R}|+|\ve{r}_{oS}|-|\ve{r}_{eS}|\over|\ve{r}_{oS}\times\ve{r}_{eS}|^2}\,
\ve{R}\times(\ve{r}_{oS}\times\ve{r}_{eS})
+\OO4,
\\
\label{ve-r}
\ve{r}_{eS}&=&\ve{x}_s(t_e)-\ve{x}_{\rm Sun},
\\
\label{ve-r-0}
\ve{r}_{oS}&=&\ve{x}_o(t_o)-\ve{x}_{\rm Sun}.
\end{eqnarray}

\noindent
The angle between $\vecg{\sigma}$ and $\ve{k}$ can be calculated as

\begin{equation}
{(1+\gamma)GM_{\rm Sun}\over c^2\,|\ve{r}_{oS}|\,\sin\psi_{\rm Sun}}\,
\left(1+a-\sqrt{1-2a\cos\psi_{\rm Sun}+a^2}\right)\approx
{(1+\gamma)\,GM_{\rm Sun}\over c^2\,|\ve{R}|}\,
\left(\cot{\psi_{\rm Sun}\over2}
+{\cal O}(a)
\right),
\end{equation}

\noindent
where $a=|\ve{r}_{oS}|/|\ve{R}|$ and $\psi_{\rm Sun}$ is the angular
distance between the source and the Sun. The effect attains 8.5 \muas\
for a source situated at a distance of 1 pc and observed at the limb of
the Sun.  One can check that the angle between $\ve{k}$ and
$\vecg{\sigma}$ is larger than 1 \muas\ if $|\ve{x}_s|\le 8.5 \,{\rm
pc}$ and the source is observed within 2.3\degr\ from the Sun.  If at
least one of these conditions is violated (which is really the case for
all currently proposed astrometric missions since no observations can
be done so close to the Sun) one can put

\begin{equation}\label{sigma=k}
\vecg{\sigma}=\ve{k}.
\end{equation}

\bigskip

Let us note that the requirement to calculate the gravitational effects
with an accuracy of 1~\muas\ puts a constrain on the accuracy
of the planetary ephemerides (roughly speaking, one has to be able to
calculate the impact parameter of the light ray with respect to each
gravitating body with a sufficient accuracy). The required accuracy of
the ephemerides depends also on the minimal allowed angular distance between
the source and the gravitating body. For a grazing ray the barycentric
position of Jupiter should be known with an accuracy of 4 km and those
for the other planets with slightly lower accuracy. The barycentric
position of the Sun should be known with an accuracy of about 400 m for
a grazing ray, and with an accuracy of $\sim6000$ km for the minimal
allowed angular distance of $35\degr$ as adopted for GAIA. Note that
since the model involves relative positions of the satellite and the
gravitating bodies,
the barycentric position of the satellite must be known with at least
the same accuracy, i.e. $\sim 4$ km
(see Section 5.4 of \citet{GAIA:2000} for other
accuracy constrains).

\section{Parallax}
\label{Section-parallax}

Only the sources situated outside of the Solar system will considered
below. For the objects situated outside of the Solar system the next
step of the model is to get rid of the parallax, that is to transform
$\ve{k}$ into the unit vector $\ve{l}$ directed from the barycenter of
the Solar system to the source

\begin{equation}\label{ve-l}
\ve{l}(t)={\ve{x}_s(t_e)\over |\ve{x}_s(t_e)|}.
\end{equation}

\noindent
Note that starting from this point further parametrization of vectors
$\ve{k}$ and $\ve{l}$ formally coincides with what one could expect in
the Newtonian framework. From the formal mathematical point of view
these vectors may be considered as ``Euclidean vectors'' in 3-dimensional
coordinate space formed by the spatial coordinates of the BCRS. It is
important to understand, however, that this interpretation is only
formal and that those vectors are not Euclidean vectors in some
``underlying Euclidean physical space'', but rather integration
constants for the equations of light propagations in the BCRS. These
vectors are defined by the whole previous model of relativistic
reduction and would change if the model is changed (e.g. if another
relativistic reference system is used instead of the BCRS).

Here, the definitions of parallax, proper motion and radial velocity
compatible with general relativity at a level of 1 \muas\ (or better)
are suggested. Although the definitions are quite simple and
straightforward, their interpretation at such a high level of accuracy
is rather unusual from the point of view of classical Newtonian
astrometry. As it will be clear below parallax and proper motion are no
longer two separate effects which can be considered independently of
each other. The second-order parallaxes and proper motions as well as
the effects resulting from the interaction between these two effects
are important. Moreover, parallax, proper motion and other astrometric
parameters are coordinate-dependent parameters defined in the BCRS,
which is used as the relativistic reference system where the position
and motion of the sources are described. Therefore, these parameters have
some meaning only within a particular chosen model of relativistic
reductions. That is why the whole relativistic model of positional
observations must be considered to define these parameters and clarify
their meaning.

Let us define several parameters. The parallax of the source is
defined as

\begin{equation}\label{pi}
\pi(t_o)={1\,{\rm AU}\over |\ve{x}_s(t_e)|},
\end{equation}

\noindent
the parallactic parameter $\vecg{\Pi}$ is given by

\begin{equation}\label{ve-Pi}
\vecg{\Pi}(t_o) = \pi(t_o)\ {\ve{x}_o(t_o)\over 1\,{\rm AU}},
\end{equation}

\noindent
and finally the observed parallactic shift of the source is defined as

\begin{equation}\label{ve-pi}
\vecg{\pi}(t_o)=\ve{l}(t_o)\,\times\,
(\vecg{\Pi}(t_o)\,\times\,\ve{l}(t_o)).
\end{equation}

\noindent
With these definitions to sufficient accuracy one has

\begin{equation}\label{ve-k-l}
\ve{k}=-\ve{l}\,\left(1-{1\over 2}\,|\vecg{\pi}|^2\right)+
\vecg{\pi}\,\left(1+\ve{l}\,\cdot\,\vecg{\Pi}\right)+{\cal O}(\pi^3).
\end{equation}

\noindent
The second-order effects in (\ref{ve-k-l}) proportional to $\pi^2$ are
less 3 \muas\ if $|\ve{x}_s|\ge 1$ pc. For the accuracy of 1 \muas\ the
second-order terms can be safely neglected if $|\ve{x}_s|\ge 2$ pc.


\section{Proper motion}
\label{Section-proper-motion}

The last step of the algorithm is to provide a reasonable
parametrization of the time dependence of $\ve{l}$ and $\pi$ caused by
the motion of the source relative to the barycenter of the Solar
system.

It is commonly known that in order to convert the observed proper
motion and the observed radial velocity into true tangential and radial
velocities of the observed object additional information is required.
Since that information is not always available, the concepts of
``apparent proper motion'', ``apparent tangential velocity'' and
``apparent radial velocity'' are suggested below. These concepts
represent useful information about the observed object and should be
distinguished from the ``true tangential velocity'' and ``true radial
velocity''.  Definitions of all these concepts are discussed below.

In the present paper the following simple model for the coordinates of
the source is adopted:

\begin{equation}\label{ve-X(t)}
\ve{x}_s(t_e)=\ve{x}_s(t_e^{\ 0})+\ve{V}\,\Delta t_e
+{1\over 2}\,\ve{A}\,\Delta t_e^{\ 2}+
{\cal O}(\Delta t_e^{\ 3}),
\end{equation}

\noindent
Here, $\Delta t_e = t_e - t_e^{\ 0}$, and $\ve{V}$ and $\ve{A}$ are the
BCRS velocity and acceleration of the source evaluated at the moment of
emission $t_e^{\ 0}$ corresponding the initial epoch of observation
$t_o^{\ 0}$. This model allows one to consider single stars or
components of gravitationally bounded systems, periods of which are
much larger than the time span covered by observations. Depending on
particular properties of the source and on the time span of
observations higher-order terms in (\ref{ve-X(t)}) can also be
considered. It is also clear that in more complicated cases special
solutions for binary stars, etc. should be considered. For objects in
double or multiple systems for which it is possible to determine the
orbit, Eq. (\ref{ve-X(t)}) gives the coordinates of the center of mass
of such a system. The obvious correction should be added to the
right-hand side of (\ref{ve-X(t)}) in order to account for the orbital
motion of the object. This case will not be considered here. In this
paper we confine ourselves to Eq. (\ref{ve-X(t)}) only.


Substituting (\ref{ve-X(t)}) into the definitions of $\ve{l}$ and $\pi$ one
gets

\begin{eqnarray}\label{pi(t)-series}
\pi(t_o)&=&\pi_0
+{\dot\pi}_0\,\Delta t_e
+{1\over 2}\,{\ddot\pi}_0\,\Delta t_e^{\ 2}
+{\cal O}(\Delta t_e^{\ 3}),
\\
\label{dot-pi-0}
\dot\pi_0&=&-\pi_0\,{\ve{l}_0\cdot\ve{V}\over |\ve{x}_s(t_e^{\ 0})|},
\\
\label{ddot-pi-0}
\ddot\pi_0&=&
-\pi_0\,{\ve{l}_0\cdot\ve{A}\over |\ve{x}_s(t_e^{\ 0})|}
-\pi_0\,|\dot{\ve{l}}_0|^2
+2\,{\dot{\pi}_0^{\ 2}\over\pi_0},
\end{eqnarray}

\begin{eqnarray}\label{l(t)-series}
\ve{l}(t_o)&=&\ve{l}_0+\dot{\ve{l}}_0\,\Delta t_e
+{1\over 2}\,\ddot{\ve{l}}_0\,\Delta t_e^{\ 2}
+{\cal O}(\Delta t_e^{\ 3}),
\\
\label{dot-l-0}
\dot{\ve{l}}_0&=&
{1\over |\ve{x}_s(t_e^{\ 0})|}\,\ve{l}_0\times(\ve{V}\times\ve{l}_0),
\\
\label{ddot-l-0}
\ddot{\ve{l}}_0&=&
{1\over |\ve{x}_s(t_e^{\ 0})|}\,\ve{l}_0\times(\ve{A}\times\ve{l}_0)
-|\dot{\ve{l}}_0|^2\,\ve{l}_0
+2\,{\dot{\pi}_0\over\pi_0}\,\dot{\ve{l}}_0,
%-2\,{\ve{l}_0\cdot\ve{V}\over|\ve{x}_s(t_e^{\ 0})|}\,\dot{\ve{l}}_0,
\end{eqnarray}

\noindent
where $\pi_0=\pi(t_o^{\ 0})=1\ {\rm AU}/|\ve{x}_s(t_e^{\ 0})|$ and
$\ve{l}_0=\ve{l}(t_o^{\ 0})=\ve{x}_s(t_e^{\ 0})/|\ve{x}_s(t_e^{\ 0})|$
are the parameters at the initial epoch of observation $t_o^{\ 0}$.

The signals emitted at moments $t_e^{\ 0}$ and $t_e$ are received by
the observer at moments $t_o^{\ 0}$ and $t_o$, respectively. The
corresponding moments of emission and reception are related by

\begin{equation}\label{t-T}
c\,(t_o-t_e)=|\ve{x}_o(t_o)-\ve{x}_s(t_e)|-\ve{k}(t_o)\cdot\Delta\ve{x}_p(t_o),
\end{equation}

\noindent
and by a similar equation for the moments $t_o^{\ 0}$ and $t_e^{\ 0}$.
The term proportional to $\Delta\ve{x}_p$ represents the gravitational
signal retardation (the Shapiro effect) due to the gravitational field
of the Solar system. For any source in the observed part of the
universe the Shapiro effect due to the gravitational field of the
Solar system is less than $10^{-3}$ s and can be safely neglected here.  Let
us denote $\Delta t_o = t_o - t_o^{\ 0}$ the time span of observations
corresponding the time span $\Delta t_e=t_e-t_e^{\ 0}$ of emission.
These two time intervals are related as

\begin{eqnarray}\label{DT-Dt}
\Delta t_e &=&
\left(1+{1\over c}\,\ve{l}_0\,\cdot\,\ve{V}\right)^{-1}\,
\Delta t_o
+{1\over c}\,\ve{l}_0\,\cdot\,\left(\ve{x}_o(t_o)-\ve{x}_o(t_o^{\ 0})\right)
\,\left(1+{1\over c}\,\ve{l}_0\,\cdot\,\ve{V}\right)^{-1}
\nonumber\\
&&-{1\over 2c}\,
\left(\ve{l}_0\cdot\ve{A}
+{|\ve{l}_0\times\ve{V}|^2\over |\ve{x}_s(t_e^{\ 0})|}
\right)\,\Delta t_o^{\ 2}+\dots
\end{eqnarray}

\noindent
Eq.  (\ref{DT-Dt}) results from a double Taylor expansion of the first
term on the right-hand side of (\ref{t-T}) in powers of parallax $\pi$
and $\Delta t_e$. Many terms have been neglected here since they were
estimated to produce negligible observable effects. Which terms of such
an expansion are important depends on many factors. The constrains used
here to derive (\ref{DT-Dt}) are: $\pi_0\le1\arcsec$, proper motion
$|\dot{\ve{l}}_0|\le 1\ \muas/{\rm s}\approx 32\arcsec/{\rm yr}$,
accuracy of position determination for a single observation is not
better than 1~\muas, lifetime of the mission is not longer than 5 yr,
the effects of acceleration $\ve{A}$ of the object were supposed to be
smaller than those of velocity $\ve{V}$ (i.e. $\ve{A}<2\ve{V}/\Delta t_e$).
For other constrains other terms in the expansion may become important.

The second term in (\ref{DT-Dt}) represents a quasi-periodic effect
with an amplitude $\ \sim |\ve{x}_o|/c \approx 500$~s for a satellite
located not too far from the Earth orbit. Below it will be shown that
this term gives a significant periodic term in the apparent proper
motion of the sources with sufficiently large proper motions.

It is easy to see from (\ref{pi(t)-series})--(\ref{ddot-l-0}) that the
time dependence of parallax and proper motion characterized by the
parameters $\dot\pi_0$ and $\ddot{\ve{l}}_0$ can be used to determine
the radial velocity of the source. This question has been recently
investigated in full detail and applied to Hipparcos data by
\citet{Dravins:Lindegren:Madsen:1999}. The tangential and radial
components of the barycentric velocity $\ve{V}$ of the source can be
defined by

\begin{equation}\label{tangential-real}
\ve{V}_{\rm tan}=\ve{l}_0\times(\ve{V}\times\ve{l}_0),
\end{equation}

\begin{equation}\label{radial-real}
V_{\rm rad}=\ve{l}_0\cdot\ve{V}.
\end{equation}

\noindent

Eqs. (\ref{pi(t)-series})--(\ref{ddot-l-0}) can be combined with
(\ref{DT-Dt}) to get the time dependence of $\ve{l}$ and $\pi$.
Collecting the terms linear with respect to $\Delta t_o$ we get the
definition of the apparent proper motion $\vecg{\mu}_{\rm ap}$ and the
corresponding apparent tangential velocity $\ve{V}^{\rm ap}_{\rm tan}$
as appeared in the linear term in $\ve{l}(t_o)$, and the definition of
the apparent radial velocity $V^{\rm ap}_{\rm rad}$ as appeared in the
linear term in $\pi(t_o)$:

\begin{eqnarray}\label{tangential-visual}
\ve{V}^{\rm ap}_{\rm tan}&=&\ve{l}_0\times(\ve{V}\times\ve{l}_0)\,
                      \left(1+{1\over c}\,\ve{l}_0\,\cdot\,\ve{V}\right)^{-1}
%\nonumber\\
=\ve{V}_{\rm tan}\,\left(1+{1\over c}\,V_{\rm rad}\right)^{-1},
\end{eqnarray}

\begin{eqnarray}\label{proper-visual}
\vecg{\mu}_{\rm ap}&=&{1\over |\ve{x}_s(t_e^{\ 0})|}\,
                    \ve{l}_0\times(\ve{V}\times\ve{l}_0)\,
                    \left(1+{1\over c}\,\ve{l}_0\,\cdot\,\ve{V}\right)^{-1}
=\pi_0\ {\ve{V}^{\rm ap}_{\rm tan}\over 1\ {\rm AU}},
\end{eqnarray}

\begin{eqnarray}\label{radial-visual}
V^{\rm ap}_{\rm rad}&=&\ve{l}_0\cdot\ve{V}\,
                          \left(1+{1\over c}\,\ve{l}_0\,\cdot\,\ve{V}\right)^{-1}
%\nonumber\\
=V_{\rm rad}\,\left(1+{1\over c}\,V_{\rm rad}\right)^{-1}.
\end{eqnarray}

\noindent
With these definitions the simplest possible models for $\pi(t_o)$ and
$\ve{l}(t_o)$ read (the higher-order terms are neglected here in order
to make this example more transparent):

\begin{eqnarray}\label{pi-Delta-t}
\pi(t_o)=\pi_0
-\pi_0^2\,{V^{\rm ap}_{\rm rad}\over 1\ {\rm AU}}\,\Delta t_o
%+\pi_0^2\,{V^{\rm ap}_{\rm rad}\over 1\ {\rm AU}}\,
% {1\over c}\,[\ve{x}_o(t)-\ve{x}_o(t_0)]\,\cdot\,\ve{l}_0
+\dots,
\end{eqnarray}

\begin{eqnarray}\label{l-Delta-t}
\ve{l}(t_o)=\ve{l}_0 + \vecg{\mu}_{\rm ap}\,\Delta t_o
+\vecg{\mu}_{\rm ap}\,
 {1\over c}\,\biggl([\ve{x}_o(t)-\ve{x}_o(t_0)]\,\cdot\,\ve{l}_0\biggr)
+\dots.
\end{eqnarray}

Factor $\left(1+c^{-1}\,\ve{l}_0\,\cdot\,\ve{V}\right)^{-1}$ in
(\ref{tangential-visual})--(\ref{radial-visual}) has been discussed by,
e.g. \citet{Stumpff:1985} and \citet{Klioner:Kopeikin:1992}. If vectors
$\ve{l}_0$ and $\ve{V}$ are nearly antiparallel and $|\ve{V}|$ is
large, this factor may become large so that the apparent tangential and
radial velocities may even exceed light velocity. This phenomenon is
one of the well-known possible explanations of apparent superluminal
motions.

The amplitude of the third term in (\ref{l-Delta-t}) is about 170
\muas\ for the Barnard's star with its proper motion of
$10.4\arcsec$ per year
\citep[see][]{Brumberg:Klioner:Kopejkin:1990,Klioner:Kopeikin:1992}. In
general the amplitude of this effect is approximately equal to the
proper motion of the source during the time interval $\sim
|\ve{x}_o|/c$ required for the light to propagate from the observer to
the barycenter of the Solar system multiplied by cosine of the
ecliptical latitude of the source. Therefore, for a satellite not too
far from the Earth orbit where $|\ve{x}_o|/c\sim500$ s,
this effect exceeds 1~\muas\ for all stars with
the proper motion larger than $\sim63$ mas/yr. This effect is closely
related to the Roemer effect used in the 17th century to measure the
light velocity. Its potential importance for astrometry was recognized
by \citet{Schwarzschild:1894} and later discussed in detail by
\citet{Stumpff:1985}. The Roemer effect is a standard part of typical
relativistic models for pulsar timing \citep[see,
e.g.][]{Doroshenko:Kopeikin:1990}.

The apparent radial velocity $V^{\rm ap}_{\rm rad}$ can be immediately
used to calculate the true radial velocity $V_{\rm rad}$. Therefore, if
both the apparent tangential and apparent radial velocities are
determined from observations one can immediately restore the true
tangential velocity $\ve{V}_{\rm tan}$. However, even if it is not the
case the apparent velocity $\ve{V}^{\rm ap}_{\rm tan}$ can be useful by
itself. Note that the radial velocities measured by Doppler (spectral)
observations are neither true nor apparent radial velocity in our
terminology. The shift of spectral lines is affected by a number of
factors not appearing in positional observations (various gravitational
red shifts and Doppler effects; see, a detailed discussion e.g. by
\citet{Kopeikin:Ozernoy:1999}). The relativistic
effects induced by the motion of the satellite and by the gravitational
field of the Solar system in the Doppler measurements are typically of
the order of a few cm/s which is probably too small to be detectable by
space astrometry missions (for example, GAIA will measure the Doppler
shift of spectral lines with an accuracy of about 1 km/s). Therefore,
it is only the intrinsic red shift due to local physics of the object
which should be considered \citep[see, e.g.][]{Neill:1996}.

\section{Summary of the model}
\label{Section-summary}

Practical implementation of the model can be summarized as follows:

\begin{enumerate}

\item[A.] determine the orbit (the position $\ve{x}_o$ and the velocity
$\dot{\ve{x}}_o$) of the satellite with respect to the BCRS (Section
\ref{Section-motion});

\item[B.] re-parametrize the observed directions $\ve{s}$ by the
coordinate time $t$ of the BCRS (to this end Eq. (\ref{tau-s-TCB})
should be numerically integrated along the orbit of the satellite);

\item[C.] use Eqs. (\ref{s-prim})--(\ref{velocity-renormalization})
to convert the observed direction $\ve{s}$ to the source into
the unit BCRS direction $\ve{n}$ of the light ray at the point of
observation;

\item[D$_1$.] for the objects situated outside of the Solar system
use Eqs. (\ref{ve-p-additive}), (\ref{delta-pN-n-explicit}),
(\ref{delta-Q-n}) with (\ref{delta-dot-x-p-Q})--(\ref{dot-V}),
(\ref{ve-alpha})--(\ref{ve-delta}) and
(\ref{MAij-matrix})--(\ref{EE}), and (\ref{sigma=k})
to convert $\ve{n}$ into the unit BCRS direction $\ve{k}$ from the
source to the observer at the moment of observation; in order to judge
if the light deflection due to a particular gravitating body should be
considered here one can use Eq. (\ref{delta-pN}) and/or the maximal
angular distances given in Table \ref{Table-gravitational-deflection};

\item[D$_2$.] for the Solar system objects use Eqs. (\ref{n-k}),
(\ref{delta-k-pN-explicit}) and (\ref{delta-k-Q}) with
(\ref{delta-x-p-Q})--(\ref{EE}) to convert $\ve{n}$ into $\ve{k}$ (a
set of vectors $\ve{k}$ for several moments of time can be used to
determine the BCRS orbit of the object which represents the final
outcome for a Solar system body); Eqs. (\ref{delta-pN}),
(\ref{angle-k-n}) and/or the maximal angular distances given in Table
\ref{Table-gravitational-deflection} can be again used to judge if a
particular gravitating body should be taken into account here;

\item[E.] use Eqs. (\ref{ve-k-l}) with (\ref{pi})--(\ref{ve-pi}) to
take into account the parallax of the object and to convert $\ve{k}$
into the unit BCRS direction $\ve{l}$ from the barycenter of the Solar
system to the source;

\item[F.] use an appropriate model for the time dependence of $\ve{l}$ and
possibly of the parallactic parameter $\pi$ to account for the
proper motion of the source (a reasonable model for single sources is
given in Section \ref{Section-proper-motion}).

\end{enumerate}

\begin{figure}
\unitlength=1.0mm
\font\rs=cmss10 scaled \magstephalf
\font\rrs=cmss10 scaled \magstep1
\begin{picture}(100.00,30.00)
\put(1,1){\makebox(0,0){\rm A}}
\put(4,1){\vector(1,0){8}}
\put(15,1){\makebox(0,0){\rm B}}
\put(18,1){\vector(1,0){8}}
\put(29,1){\makebox(0,0){\rm C}}
\put(32,1.5){\vector(1,1){6}}
\put(32,0.5){\vector(1,-1){6}}
\put(42,7.5){\makebox(0,0){\rm D$_1$}}
\put(42,-6){\makebox(0,0){\rm D$_2$}}
\put(45,7.5){\vector(1,0){8}}
\put(56,7.5){\makebox(0,0){\rm E}}
\put(59,7.5){\vector(1,0){8}}
\put(70,7.5){\makebox(0,0){\rm F}}
\put(80,7.5){\makebox(0,0)[l]{\rm (objects outside of the Solar system)}}
\put(80,-6){\makebox(0,0)[l]{\rm (Solar system objects)}}
\end{picture}
\vskip 1cm
\caption{The structure of the model for different kinds of objects (see text).
\label{Figure-structure}
}
\end{figure}

The sequence of the steps of the model is depicted on Fig.
\ref{Figure-structure}.

%Let us also note that the model can be in principle further simplified
%for scanning satellites since they normally deliver high-precision
%information only in one dimension (along the scan).

\section{The model for 0.1 \muas}
\label{Section-0.1-muas}

Since the technical accuracy of GAIA is expected to attain 4 \muas\ for
the stars with the magnitude of 12 mag and brighter, and the technical
accuracy of SIM is also expected to attain the level of 3-4 \muas, it
is interesting to look at the relativistic model having an accuracy of
0.1 \muas\ which guarantees that all systematic effects of the level of 1
\muas\ are properly taken into account. The relativistic effects
related to the gravitational potential of the Solar system bodies and
to the motion of the observer with respect the barycenter of the Solar
system can be modeled with the accuracy of 0.1 \muas\ within the same
scheme discussed above and summarized in the previous Section. The necessary
changes to attain the accuracy of 0.1 \muas\ are:

\begin{enumerate}

\item[Step A:] The barycentric velocity of the satellite should be known with
an accuracy of $10^{-4}$ m/s. This also requires the use of Eq. (\ref{Va-deltavi})
if the GCRS is used for orbit determination.

\item[Step D:] Some additional effects should be taken into
account in the gravitational light deflection (see also Table
\ref{Table-gravitational-deflection}):

\begin{enumerate}

\item The effect explicitly proportional to the velocity of the bodies
should be taken into account when observing within 8 angular radii of
Jupiter or 2 angular radii of Saturn. As discussed in Section
\ref{Section-gravitational-deflection} the difference between $t^{\rm
r}_{A0}$ and $t^{\rm ca}_{A0}$ still plays no role at this level of
accuracy. The explicit formulas has been published by
\citet{Klioner:1989}, \citet{Klioner:Kopeikin:1992} and
\citet{Kopeikin:Schaefer:1999}.

\item The effect of the rotational motion of Jupiter should be taken
into account when observing within 1.4 of its apparent radius
(i.e. within 42--69\arcsec\ from the Jupiter's center). The explicit
formulas for this effect have been published by \citet{Klioner:1991a}
and \citet{Klioner:Kopeikin:1992}.

\item The effect of $J_4$ of Jupiter exceeds 0.1 \muas\ within 2.5 of
its apparent radius (37--61\arcsec\ from the Jupiter's center); the
same effect for Saturn exceeds 0.1 \muas\ within 2.2 of its apparent
radius (15--22\arcsec\ from the Saturn's center). The effect of $J_6$
\citep[][p. 342]{Weissman:et:al:1999} of both Jupiter and Saturn may
exceed 0.1 \muas\ within 1.3 of the apparent radii of each planet. The
explicit formulas for the influence of $J_4$ and $J_6$ have been
published by \citet{Kopeikin:1997}.

\item All the bodies, the radius $L$ of which

\begin{equation}\label{L-rho-delta-0.1}
L\ge \left(\rho\over 1\,{\rm g/cm^3}\right)^{-1/2}\,197\,{\rm km},
\end{equation}

\noindent
where $\rho$ is the mean density of the body, can produce light
deflection of order 0.1 \muas\ and should be taken into account.
This makes it quite difficult to reduce the observations near the
ecliptic where a large number of small bodies satisfying this condition
can be expected.

\item The maximal angular distances at which the influence of a
gravitating body should be taken into account should be increased as
compared to Table \ref{Table-gravitational-deflection} to meet the goal
accuracy of 0.1 \muas. The post-post-Newtonian light deflection attains
0.1 \muas\ only for observations within 2.3\degr\ from the Sun and,
therefore, can be neglected for the planned space missions.

\item Coupling of the finite distance to the source and the gravitational
deflection for sources located outside of the Solar system (Section
\ref{Subsection-coupling-stars}) should be taken into account if
$|\ve{x}_s|\le85$~pc and the source is observed within 22.7\degr\
from the Sun. Although for the current technical specifications of the
planned space missions the effect can be neglected, it may become
important since the Sun avoidance angle of $\sim 23\degr$ is not
technically impossible.

\end{enumerate}

\item[Step E:] The second-order parallactic effects (Section \ref{Section-parallax})
should be taken into account if $|\ve{x}_s|\le5.5$ pc.

\item[Step F:] The model for the proper motion (Section \ref{Section-proper-motion})
should be correspondingly refined. In particular the third term
in (\ref{l-Delta-t}) becomes important for all the stars
with the proper motion larger than $\sim0.62$\arcsec/yr.

\end{enumerate}

Note also that additional relativistic effects due to various
gravitational fields generated outside of the Solar system (see Section
\ref{Section-beyond-the-model} below and \citet{Kopeikin:Gwinn:2000})
become even more important at the level of 0.1 \muas\ and should be
thoroughly taken into account.

\section{What is beyond the model}
\label{Section-beyond-the-model}


The relativistic model proposed above can be considered as a
``standard'' model suitable for all sources. This model allows one to
reduce the observational data with an accuracy of 1 \muas\ and restore
positions and other parameters of the objects (e.g. their velocities)
defined in the BCRS. The model properly takes into account the
gravitational field of the Solar system, but ignores a number of
possible effects which may be caused by the gravitational fields
produced outside of the Solar system. Let us review some of these
effects \citep[see also][]{Kopeikin:Gwinn:2000}.

The first additional effect to mention here is the so-called weak
microlensing which is simply an additional gravitational deflection of
the light coming from a distant source which is produced by the
gravitational field of a visible or invisible object situated near the
light path between the observed source and the observer. For
applications in high-precision astrometry one should distinguish
between microlensing events and microlensing noise. Microlensing event
is a time dependent change of source's position (and possibly its
brightness) which is large and clear enough to be identified as such.
Microlensing events can be used to determine physical properties of the
lens so that the unperturbed path of the source can be restored at the
end
\citep[e.g.][]{Hosokawa:et:al:1993,Hosokawa:et:al:1995,Hoeg:Novikov:Polnarev:1995,Belokurov:Evans:2002}.
In this sense microlensing events represent no fundamental problem for
the future astrometric missions. On the other hand, microlensing noise
comes from unidentified microlensing events (which are too weak or too
fast to be detected as such). The number of such unidentified
microlensing events will be clearly much higher than the number of
identified ones. The microlensing noise results in stochastic changes
of positions of the observed sources with unpredictable (but generally
small) amplitude and to unpredictable moments of time. Therefore,
microlensing noise can spoil the determination of positions, parallaxes
and proper motions of the objects
\citep{Zhdanov:1995,Zhdanov:Zhdanova:1995,
Hosokawa:Ohnishi:Fukushima:1997,Sazhin:Zharov:Volynkin:Kalinina:1998,
Sazhin:Zharov:Kalinina:2001,Belokurov:Evans:2002}. It is currently not
quite clear to what extent the microlensing noise produced by the
objects of the Galaxy can deteriorate the resulting catalogs of the
future astrometric missions. To clarify this question data simulations
similar to those described by
\citet{deFelice:Vecchiato:Bucciarelli:Lattanzi:Crosta:2000}, but
involving a model for microlensing with a realistic model for the
Galaxy would be of much help. The first simulation of this kind has
been performed by \citet{Belokurov:Evans:2002} who conclude that
the microlensing noise presents no problem for GAIA.
On the other hand, the accuracy level of
$\sim1$ \muas\ seems to be close to a fundamental limit of astrometric
accuracy, since at much higher accuracies the stochastic influence of
microlensing noise becomes too strong so that in too many cases measurable
relativistic deflection effects cannot be property taken into account
\citep{Sazhin:Zharov:Volynkin:Kalinina:1998,Sazhin:Zharov:Kalinina:2001}.

In edge-on binary (or multiple) systems the gravitational light
deflection due to the gravitational field of the companion may be
observable. In the case of pulsar timing observations of binary pulsars
this question has been thoroughly investigated by
\citet{Doroshenko:Kopeikin:1995}. It is clear that for companions with
stellar masses the inclination of the orbit should be very close to
90\degr\ for the effect to be observable at the level of 1 \muas. The
formulas of Section \ref{Subsection-coupling-solar-system} can be
directly used here to calculate the effect in the first post-Newtonian
approximation. If the lensing companion is a neutron star or a black
hole it is necessary to investigate the lensing effect in the strong
field regime and also consider secondary images (a detailed study of
the strong-field-regime appearance of a star orbiting a Kerr black hole
is given by \citet{Cunningham:Bardeen:1972,Cunningham:Bardeen:1973}).
Further investigation is necessary to estimate the probability to
observe a binary system for which the gravitational lensing of the
companion is important at the level of 1 \muas.

Gravitational waves can in principle produce gravitational light
deflection. Two cases should be distinguished here: 1) gravitational
waves from binary stars and other compact sources and 2) stochastic
primordial gravitational waves from the early universe. Gravitational
waves from a single compact source were shown to produce an utterly
small deflection which is hardly observable at the level of 1 \muas\
\citep{Kopeikin:Schaefer:Gwinn:Eubanks:1999}. However, the ensemble of
compact sources of gravitational waves in the Galaxy (e.g. binary
stars) may produce a larger cumulative effect which should be
thoroughly estimated (see, e.g. \citep{Kopeikin:1999} for an attempt of such an
estimation in pulsar timing measurements). The influence
of primordial gravitational waves was analyzed by
\citet{Pyne:Gwinn:Birkinshaw:Eubanks:Matsakis:1996} and
\citet{Gwinn:et:al:1997}. Although initially applied for VLBI, the
method of these authors can be directly used for optical astrometry.

Finally, cosmological effects should be accounted for to interpret the
derived parameters of the objects (e.g. the accuracy of parallaxes
$\sigma_\pi = 1$ \muas\ allows one to measure the distance to the
objects as far as $\sim1$ Mpc away from the Solar system; see, e.g.
\citet{Kristian:Sachs:1965} for a discussion of astrometric
consequences of cosmology). It may be interesting here to construct
the metric tensor of the BCRS with a cosmological solution as a background
and analyze the effects of the background cosmology in such a reference
system.

Last but not least, the observational accuracy of 1 \muas\ together
with the mission lifetime of at  least 5 years allow one to see the
apparent proper motions of quasars and other remote sources due to the
acceleration of the Solar system barycenter relative to the center of
the Galaxy \citep[][Section 1.8.10]{GAIA:2000}. These proper motions
should be of order of $\sim 4$ \muas/yr, if one assumes the Solar
system to be on a circular orbit around the Galactic center.

\acknowledgements

The author is grateful to F. Mignard, M. Soffel, S. Kopeikin and
M. Lattanzi for fruitful discussions and suggestions.

\begin{thebibliography}{}

\bibitem[Antonov, Timoshkova \& Kholshevnikov (1988)]{Antonov:Timoshkova:Kholshevnikov:1988}
Antonov, V.A., Timoshkova, E.I., \& Kholshevnikov, K.V. 1988,
Introduction to the theory of the Newtonian Potential
(Moscow: Nauka), in Russian

%\bibitem[Bastian et al. (1996)]{DIVA:1996}
%Bastian, U., et al. 1996, Astr. Nachr., 317, 281

\bibitem[Bienayme \& Turon (2002)]{Bienayme:Turon:2002}
Bienayme, O., \& Turon, C.  2002, GAIA: A European Space Project
(Les Ulis: EDP Sciences)

\bibitem[Belokurov \& Evans (2002)]{Belokurov:Evans:2002}
Belokurov, V.A., \& Evans, N.W. 2002, \mnras, 331, 649

\bibitem[Brumberg (1986)]{Brumberg:1986}
Brumberg, V.A. 1986, in Astrometric Techniques,
ed. H.K. Eichhorn, \& R.J. Leacock (Dordrecht: Reidel), 19

\bibitem[Brumberg (1991)]{Brumberg:1991}
Brumberg, V.A. 1991, Essential Relativistic Celestial Mechanics
(Bristol: Hilger)

\bibitem[Brumberg, Klioner, \& Kopejkin (1990)]{Brumberg:Klioner:Kopejkin:1990}
Brumberg, V.A., Klioner, S.A., \& Kopejkin, S.M. 1990,
in Inertial Coordinate System on the Sky, ed. J.H. Lieske \& V.K. Abalakin
(Dordrecht: Kluwer), 229

\bibitem[Brumberg \& Kopeikin (1989a)]{Brumberg:Kopeikin:1989a}
Brumberg, V.A., \& Kopejkin, S.M. 1989a, in: Reference Frames, ed. J.
Kovalevsky, I.I. Mueller, \& B. Ko\l{}aczek (Dordrecht:Kluwer), 115

\bibitem[Brumberg \& Kopeikin (1989b)]{Brumberg:Kopeikin:1989b}
Brumberg, V.A., \& Kopejkin, S.M. 1989b, Nuovo Cimento, 103B, 63

\bibitem[Cunningham \& Bardeen (1972)]{Cunningham:Bardeen:1972}
Cunningham, C.T., \& Bardeen, J.M. 1972, \apj, 173, L137

\bibitem[Cunningham \& Bardeen (1973)]{Cunningham:Bardeen:1973}
Cunningham, C.T., \& Bardeen, J.M. 1973,
\apj, 183, 237

\bibitem[Damour, Soffel, \& Xu (1991)]{Damour:Soffel:Xu:1991}
Damour, T., Soffel, M., \& Xu, C. 1991, \prd, 43, 3273

\bibitem[Damour, Soffel, \& Xu (1992)]{Damour:Soffel:Xu:1992}
Damour, T., Soffel, M., \& Xu, C. 1992, \prd, 45, 1017

\bibitem[Damour, Soffel, \& Xu (1993)]{Damour:Soffel:Xu:1993}
Damour, T., Soffel, M., \& Xu, C. 1993,
\prd, 47, 3124

\bibitem[Damour, Soffel, \& Xu (1994)]{Damour:Soffel:Xu:1994}
    Damour, T., Soffel, M., \& Xu, C. 1994, \prd, 49, 618

\bibitem[Dravins, Lindegren, \& Madsen (1999)]{Dravins:Lindegren:Madsen:1999}
Dravins, D., Lindegren, L., \& Madsen, S. 1999, \aap, 348, 1040

\bibitem[de Felice et al. (2001)]{deFelice:Bucciarelli:Lattanzi:Vecchiato:2001}
de Felice, F., Bucciarelli, B., Lattanzi, M.G., \&  Vecchiato, A. 2001,
\aap, 373, 336

\bibitem[de Felice et al. (1998)]{deFelice:Lattanzi:Vecchiato:Bernacca:1998}
de Felice, F., Lattanzi, M.G., Vecchiato, A., \& Bernacca, P.L. 1998,
\aap, 332, 1133

\bibitem[de Felice et al. (2000)]{deFelice:Vecchiato:Bucciarelli:Lattanzi:Crosta:2000}
de Felice, F., Vecchiato, A., Bucciarelli, B., Lattanzi, M.G., \& Crosta,
M. 2000, in Towards Models and Constants for Sub-Microarcsecond Astrometry,
ed. K.J. Johnston, D.D. McCarthy, B.J. Luzum, \& G.H. Kaplan
(Washington: US Naval Observatory), 314

\bibitem[Doroshenko \& Kopeikin (1990)]{Doroshenko:Kopeikin:1990}
Doroshenko, O.V., \& Kopeikin, S.M. 1990,
\azh, 67, 986, in Russian

\bibitem[Doroshenko \& Kopeikin (1995)]{Doroshenko:Kopeikin:1995}
Doroshenko, O.V., \& Kopeikin, S.M. 1995, \mnras, 274, 1029

\bibitem[ESA (2000)]{GAIA:2000}
ESA, 2000, GAIA: Composition, Formation and Evolution of the Galaxy,
Concept and Technology Study Report, Document ESA-SCI(2000)4, European
Space Agency, Noordwijk

\bibitem[Fukushima (1995)]{Fukushima:1995}
Fukushima, T. 1995, \aap, 294, 895

\bibitem[Gwinn et al. (1997)]{Gwinn:et:al:1997}
Gwinn, C.R., Eubanks, T.M., Pyne, T., Birkinshaw, M., \& Matsakis, D.N.
1997, \apj, 485, 87

\bibitem[H\o{}g, Novikov \& Polnarev (1995)]{Hoeg:Novikov:Polnarev:1995}
H\o{}g, E., Novikov, I.D., \& Polnarev, A.G. 1995, \aap, 294, 287

%\bibitem[Horner et al. (2000)]{FAME:2000}
%Horner, S.D., et al. 2000,
%in ASP Conf. Ser. 203 (also IAU Colloquium 176),
%The Impact of Large-Scale Surveys on Pulsating Star Research,
%ed. L. Szabados, \& D. Kurtz (San Francisco: ASP), 76

\bibitem[Hosokawa et al. (1993)]{Hosokawa:et:al:1993}
Hosokawa, M., Ohnishi, K., Fukushima, T., \& Takeuti, M. 1993,
\aap, 278, L27

\bibitem[Hosokawa et al. (1995)]{Hosokawa:et:al:1995}
Hosokawa, M., Ohnishi, K., Fukushima, T., \& Takeuti, M. 1995,
in Astronomical and Astrophysical
Objectivities of Sub-Milliarcsecond Optical Astrometry,
ed. E. H\o{}g, \& P.K. Seidelmann (Dordrecht: Kluwer), 305

\bibitem[Hosokawa et al. (1997)]{Hosokawa:Ohnishi:Fukushima:1997}
Hosokawa, M., Ohnishi, K., \& Fukushima, T. 1997,
\aj, 114, 1508

\bibitem[IAU (2001)]{IAU:2001}
IAU 2001, Information Bulletin, 88 (errata in IAU Information Bulletin, 89)

\bibitem[IERS (1996)]{IERS:1996}
IERS 1996, IERS Conventions, International Earth Rotation
Service Technical Note 21, ed. D.D. McCarthy
(Paris: Observatoire de Paris)

\bibitem[Irwin \& Fukushima (1999)]{Irwin:Fukushima:1999}
Irwin, A.W. \& Fukushima, T. 1999, \aap, 348, 642

\bibitem[Klioner (1989)]{Klioner:1989}
Klioner, S.A. 1989,
Institute of Applied Astronomy, preprint No 6, in Russian

\bibitem[Klioner (1991a)]{Klioner:1991a}
Klioner, S.A. 1991a, \azh, 68, 1046, in Russian
(translated into English:  \sovast, 35, 523)

\bibitem[Klioner (1991b)]{Klioner:1991b}
Klioner, S.A. 1991b, Ph.D. thesis,
Institute of Applied Astronomy \& St.Petersburg State University,
in Russian

\bibitem[Klioner (1993)]{Klioner:1993}
Klioner, S.A. 1993, \aap, 279, 273

\bibitem[Klioner (2000)]{Klioner:2000}
Klioner, S.A. 2000,
in Towards Models and Constants for Sub-Microarcsecond Astrometry,
ed. K.J. Johnston, D.D. McCarthy, B.J. Luzum, \& G.H. Kaplan
(Washington: US Naval Observatory), 308

\bibitem[Klioner \& Kopeikin (1992)]{Klioner:Kopeikin:1992}
Klioner S.A., \& Kopeikin, S.M. 1992,
\aj, 104, 897

\bibitem[Klioner \& Soffel (1998a)]{Klioner:Soffel:1998a}
Klioner, S.A., \& Soffel, M. 1998a, \aap, 334, 1123

\bibitem[Klioner \& Soffel (1998b)]{Klioner:Soffel:1998b}
 Klioner, S.A., \& Soffel, M.H. 1998b, \prd, 58, ID 084023

\bibitem[Klioner \& Soffel (2000)]{Klioner:Soffel:2000}
Klioner, S.A., \& Soffel, M.H. 2000,
\prd, 62, ID 024019

\bibitem[Klioner \& Voinov (1993)]{Klioner:Voinov:1993}
Klioner, S.A., \& Voinov, A.V. 1993, \prd, 48, 1451

\bibitem[Kopeikin (1988)]{Kopeikin:1988}
Kopejkin, S.M. 1988, Celestial Mechanics, 44, 87

%\bibitem[Kopeikin (1989)]{Kopeikin:1989}
%Kopeikin, S.M. 1989, \azh, 66, 1289, in Russian
%(translated into English:  \sovast, 33, 665)

\bibitem[Kopeikin (1997)]{Kopeikin:1997}
Kopeikin, S.M. 1997, J. Math. Phys., 38, 2587

\bibitem[Kopeikin (1999)]{Kopeikin:1999}
Kopeikin, S.M. 1999, available as {\tt http://xxx.lanl.gov/abs/gr-qc/9903070}

\bibitem[Kopeikin \& Ozernoy (1999)]{Kopeikin:Ozernoy:1999}
Kopeikin, S.M., \& Ozernoy, L.M., 1999, \apj, 523, 771

\bibitem[Kopeikin et al. (1999)]{Kopeikin:Schaefer:Gwinn:Eubanks:1999}
Kopeikin, S.M., Sch\"afer, G., Gwinn, C.R., \& Eubanks, T.M. 1999,
\prd, 59, ID 084023

\bibitem[Kopeikin \& Gwinn (2000)]{Kopeikin:Gwinn:2000}
Kopeikin, S.M., \& Gwinn, C. 2000,
in Towards Models and Constants for Sub-Microarcsecond Astrometry,
ed. K.J. Johnston, D.D. McCarthy, B.J. Luzum, \& G.H. Kaplan
(Washington: US Naval Observatory), 303

\bibitem[Kopeikin \& Sch\"afer (1999)]{Kopeikin:Schaefer:1999}
Kopeikin, S.M., \& Sch\"afer, G. 1999, \prd, {\bf 60}, ID 124002

\bibitem[Kopeikin \& Mashhoon (2002)]{Kopeikin:Mashhoon:2002}
Kopeikin, S.M., \& Mashhoon, B. 2002, \prd, {\bf 65}, ID 064025

\bibitem[Kopeikin et al. (2000)]{Kopeikin:Shuygina:Vasiliev:Yagudina:Yagudin:2000}
Kopeikin, S.M., Shuygina, N., Vasiliev, M., Yagudina, E., \& Yagudin, L.
2000,
in Towards Models and Constants for Sub-Microarcsecond Astrometry,
ed. K.J. Johnston, D.D. McCarthy, B.J. Luzum, \& G.H. Kaplan
(Washington: US Naval Observatory), 320

\bibitem[Kristian \& Sachs (1965)]{Kristian:Sachs:1965}
Kristian, J., \& Sachs, R.K. 1965,
\apj, 143, 379

\bibitem[Mashhoon (1974)]{Mashhoon:1974b}
Mashhoon, B. 1974, \nat, 250, 316

\bibitem[Misner, Thorne, \& Wheeler (1973)]{Misner:Thorne:Wheeler:1973}
Misner, C.W., Thorne, K.S., Wheeler, J.A. 1973,
Gravitation (San Francisco: Freeman)

\bibitem[Neill (1996)]{Neill:1996}
Neill, R.I. 1996, \aj, 111, 2000

\bibitem[Perryman et al. (2001)]{Perryman:et:al:2001}
Perryman, M. A. C., et al. 2001, \aap, 369, 339

\bibitem[Pyne et al. (1996)]{Pyne:Gwinn:Birkinshaw:Eubanks:Matsakis:1996}
Pyne, T., Gwinn, C.R, Birkinshaw, M., Eubanks, T.M., \& Matsakis, D.N.
1996, \apj, 465, 566

\bibitem[Reasenberg et al. (1988)]{Reasenberg:et:al:1988}
Reasenberg, R.D., et al. 1988, \aj, 96, 1731

\bibitem[Sazhin et al. (1998)]{Sazhin:Zharov:Volynkin:Kalinina:1998}
Sazhin, M.V., Zharov, V.E., Volynkin, A.V., \& Kalinina, T.A. 1998,
\mnras, 300, 287

\bibitem[Sazhin et al. (2001)]{Sazhin:Zharov:Kalinina:2001}
Sazhin, M.V., Zharov, V.E., \& Kalinina, T.A. 2001, \mnras, 323, 952

\bibitem[Schwarzschild (1894)]{Schwarzschild:1894}
Schwarzschild, K. 1894, Astr. Nachr., 136, No. 3246, 81

\bibitem[Shao (1998)]{SIM:1998}
Shao, M. 1998, in Astronomical Interferometry,
ed. R.D. Reasenberg, \procspie, 3350,  536

%\bibitem[Soffel (1989)]{Soffel:1989}
%Soffel, M. 1989,
%Relativity in Astrometry, Celestial Mechanics and Geodesy
%(Berlin: Springer)

\bibitem[Stumpff (1985)]{Stumpff:1985}
Stumpff, P. 1985, \aap, 144, 232

\bibitem[Walter et al. (1986)]{Walter:et:al:1986}
Walter, H. G., Mignard, F., Hering, R., Froeschl\'e, M., \&
Falin, J. L. 1986, Manuscripta Geodaetica, 11, 103

\bibitem[Weissman, McFadden \& Johnson (1999)]{Weissman:et:al:1999}
Weissman, P.R., McFadden, L.-A., Johnson, T.V. (eds.) 1999,
Encyclopedia of the Solar System
(San Diego: Academic Press)

\bibitem[Will (1993)]{Will:1993}
Will, C. M. 1993,
Theory and experiment in gravitational physics
(Cambridge: Cambridge University Press)

\bibitem[Zhdanov (1995)]{Zhdanov:1995}
Zhdanov, V.I. 1995, in Astronomical and Astrophysical Objectivities of
Sub-Milliarcsecond Optical Astrometry, ed. E. H\o{}g, \& P.K.
Seidelmann (Dordrecht: Kluwer), 295

\bibitem[Zhdanov \& Zhdanova (1995)]{Zhdanov:Zhdanova:1995}
Zhdanov, V.I., \& Zhdanova, V.V. 1995, \aap, 299, 321

\end{thebibliography}

\end{document}

pictex.tex
%auto-ignore
% This is PiCTeX, Version 1.1   9/21/87
 
% CAVEAT: The PiCTeX manual often has a more lucid explanation
%   of any given topic than you will find in the internal documentation
%   of the macros.
 
% PiCTeX's commands can be classified into two groups: (1) public (or
%   external), and (2) private (or internal). The public macros are
%   discussed at length in the manual. The only discussion of the private
%   macros is the internal documentation. The private macros all have
%   names beginning with an exclamation point (!) of category code 11. 
%   Since in normal usage "!" has category code 12, these macros can't
%   be accessed or modified by the general user.
 
% The macros are organized into thematically related groups. For example,
%   the macros dealing with dots & dashes are all in the DASHPATTERN group.
%   The table below shows which macros are in which groups. The table
%   covers all public macros, and many (but not all) of PiCTeX's upper level
%   private macros. Following the table, the various groups are listed
%   in the order in which they appear in the table.
 
% *********************** TABLE OF GROUPS OF MACROS **********************
 
% HACKS:  Utility macros
%    \PiC
%    \PiCTeX
%    \placevalueinpts 
%    \!!loop 
%    \!cfor
%    \!copylist
%    \!ecfor
%    \!etfor
%    \!getnext
%    \!getnextvalueof
%    \!ifempty
%    \!ifnextchar
%    \!leftappend
%    \!listaddon 
%    \!loop
%    \!lop
%    \!mlap
%    \!not
%    \!removept
%    \!rightappend
%    \!tfor 
%    \!vmlap
%    \!wlet
 
% ALLOCATION:  Allocates registers
 
% AREAS: Deals with plot areas 
%    \axis
%    \grid 
%    \invisibleaxes
%    \normalgraphs 
%    \plotheading 
%    \setplotarea
%    \visibleaxes
 
% ARROWS:  Draws arrows
%    \arrow
%    \betweenarrows
 
% BARS:  Draws bars
%    \putbar 
%    \setbars
 
% BOXES:  Draws rectangles
%    \frame
%    \putrectangle 
%    \rectangle
%    \shaderectangleson
%    \shaderectanglesoff
 
% CURVES:  Upper level plot commands
%    \hshade 
%    \plot 
%    \sethistograms
%    \setlinear
%    \setquadratic
%    \vshade
 
% DASHPATTERNS:  Sets up dash patterns
%    \findlength 
%    \setdashes 
%    \setdashesnear
%    \setdashpattern
%    \setdots 
%    \setdotsnear 
%    \setsolid
%    \!dashingoff
%    \!dashingon
 
% DIVISION:  Does long division of dimension registers
%    \Divide 
%    \!divide
 
% ELLIPSES:  Draws ellipses and circles
%    \circulararc 
%    \ellipticalarc 
 
% RULES:  Draws rules, i.e., horizontal & vertical lines
%    \putrule 
%    \!putdashedhline
%    \!putdashedvline
%    \!puthline 
%    \!putsolidhline  
%    \!putsolidvline  
%    \!putvline
 
% LINEAR ARC:  Draws straight lines -- solid and dashed
%    \inboundscheckoff
%    \inboundscheckon
%    \!advancedashing 
%    \!drawlinearsegment
%    \!initinboundscheck
%    \!linearsolid
%    \!lineardashed
%    \!ljoin
%    \!plotifinbounds     
%    \!start 
 
% LOGTEN:  Log_10 function
%    \!logten
 
% PICTURES:  Basic setups for PiCtures; \put commands
%    \accountingoff
%    \accountingon
%    \beginpicture
%    \endpicture    
%    \endpicturesave 
%    \lines
%    \multiput
%    \put 
%    \setcoordinatemode
%    \setcoordinatesystem
%    \setdimensionmode
%    \stack 
%    \Lines
%    \Xdistance
%    \Ydistance
%    \!dimenput
%    \!ifcoordmode
%    \!ifdimenmode
%    \!setcoordmode
%    \!setdimenmode
%    \!setputobject
   
% PLOTTING:  Things to do with plotting
%    \dontsavelinesandcurves
%    \replot
%    \savelinesandcurves 
%    \setplotsymbol
%    \writesavefile 
%    \!plot
 
% PYTHAGORAS:  Euclidean distance function
%    \placehypotenuse 
%    \!Pythag
 
% QUADRATIC ARC:  Draws a quadratic arc
%    \!qjoin 
 
% ROTATIONS:  Handles rotations
%    \startrotation 
%    \stoprotation
%    \!rotateaboutpivot
%    \!rotateonly
 
% SHADING:  Handles shading
%    \setshadegrid 
%    \setshadesymbol
%    \!lshade
%    \!qshade
%    \!starthshade
%    \!startvshade  
 
% TICKS:  Draws ticks on graphs
%    \gridlines
%    \loggedticks
%    \nogridlines
%    \ticksin
%    \ticksout
%    \unloggesticks
 
% ***************** END OF TABLE OF GROUPS OF MACROS ********************


\catcode`!=11 %  ***** THIS MUST NEVER BE OMITTED
% *******************************
% *** HACKS  (Utility macros) ***
% *******************************
 
% ** User commands
% **   \PiC{P\kern-.12em\lower.5ex\hbox{I}\kern-.075emC}
% **   \PiCTeX{\PiC\kern-.11em\TeX}
% **   \placevalueinpts of <DIMENSION REGISTER> in {CONTROL SEQUENCE}
  
% ** Internal commands
% **   \!ifnextchar{CHARACTER}{TRUE ACTION}{FALSE ACTION}
% **   \!tfor NAME := LIST \do {BODY}
% **   \!etfor NAME:= LIST \do {BODY}
% **   \!cfor NAME := LIST \do {BODY}
% **   \!ecfor NAME:= LIST \do {BODY}
% **   \!ifempty{MACRO}{TRUE ACTION}{FALSE ACTION}
% **   \!getnext\\ITEMfrom\LIST
% **   \!getnextvalueof\DIMEN\from\LIST
% **   \!copylist\LISTMACRO_A\to\LISTMACRO_B
% **   \!wlet\CONTROL_SEQUENCE_A=\CONTROL_SEQUENCE_B
% **   \!listaddon ITEM LIST
% **   \!rightappendITEM\withCS\to\LISTMACRO
% **   \!leftappendITEM\withCS\to\LISTMACRO
% **   \!lop\LISTMACRO\to\ITEM
% **   \!loop ... repeat
% **   \!!loop ... repeat
% **   \!removept{DIMENSION REGISTER}{CONTROL SEQUENCE}
% **   \!mlap{...}  
% **   \!vmlap{...}
% **   \!not{TEK if-CONDITION}

% ** First, here are the the PiCTeX logo, and the syllable PiC:
\def\PiC{P\kern-.12em\lower.5ex\hbox{I}\kern-.075emC}
\def\PiCTeX{\PiC\kern-.11em\TeX}

% ** The following macro expands to parameter #2 or parameter #3 according to
% ** whether the next non-blank character following the macro is or is not #1. 
% ** Blanks following the macro are gobbled.
\def\!ifnextchar#1#2#3{%
  \let\!testchar=#1%
  \def\!first{#2}%
  \def\!second{#3}%
  \futurelet\!nextchar\!testnext}
\def\!testnext{%
  \ifx \!nextchar \!spacetoken 
    \let\!next=\!skipspacetestagain
  \else
    \ifx \!nextchar \!testchar
      \let\!next=\!first
    \else 
      \let\!next=\!second 
    \fi 
  \fi
  \!next}
\def\\{\!skipspacetestagain} 
  \expandafter\def\\ {\futurelet\!nextchar\!testnext} 
\def\\{\let\!spacetoken= } \\  %  ** set \spacetoken to a space token
 
 
% ** Borrow the "tfor" macro from Latex:
% **   \!tfor NAME := LIST \do {BODY}
% **   if, before expansion, LIST = T1 ... Tn,  where each  Ti  is a token
% **   or  {...},  then executes  BODY  n  times, with  NAME = Ti  on the
% **   i-th iteration.  Works for  n=0.
\def\!tfor#1:=#2\do#3{%
  \edef\!fortemp{#2}%
  \ifx\!fortemp\!empty 
    \else
    \!tforloop#2\!nil\!nil\!!#1{#3}%
  \fi}
\def\!tforloop#1#2\!!#3#4{%
  \def#3{#1}%
  \ifx #3\!nnil
    \let\!nextwhile=\!fornoop
  \else
    #4\relax
    \let\!nextwhile=\!tforloop
  \fi 
  \!nextwhile#2\!!#3{#4}}
 
 
% **   \!etfor NAME:= LIST\do {BODY}
% **   This is like \!cfor, but LIST is any balanced token list whose complete
% **     expansion has the form  T1 ... Tn
\def\!etfor#1:=#2\do#3{%
  \def\!!tfor{\!tfor#1:=}%
  \edef\!!!tfor{#2}%
  \expandafter\!!tfor\!!!tfor\do{#3}}
 
 
% **   modify the Latex \tfor (token-for) loop to a \cfor (comma-for) loop.
% **   \!cfor NAME := LIST \do {BODY}
% **     if, before expansion, LIST = a1,a2,...an, then executes  BODY n times,
% **     with  NAME = ai  on the i-th iteration.  Works for  n=0.
\def\!cfor#1:=#2\do#3{%
  \edef\!fortemp{#2}%
  \ifx\!fortemp\!empty 
  \else
    \!cforloop#2,\!nil,\!nil\!!#1{#3}%
  \fi}
\def\!cforloop#1,#2\!!#3#4{%
  \def#3{#1}%
  \ifx #3\!nnil
    \let\!nextwhile=\!fornoop 
  \else
    #4\relax
    \let\!nextwhile=\!cforloop
  \fi
  \!nextwhile#2\!!#3{#4}}
 
 
% **   \!ecfor NAME:= LIST\do {BODY}
% **   This is like \!cfor, but LIST is any balanced token list whose complete
% **     expansion has the form  a1,a2,...,an.
\def\!ecfor#1:=#2\do#3{%
  \def\!!cfor{\!cfor#1:=}%
  \edef\!!!cfor{#2}%
  \expandafter\!!cfor\!!!cfor\do{#3}}
 
 
\def\!empty{}
\def\!nnil{\!nil}
\def\!fornoop#1\!!#2#3{}
 
 
% **  \!ifempty{ARG}{TRUE ACTION}{FALSE ACTION}
\def\!ifempty#1#2#3{%
  \edef\!emptyarg{#1}%
  \ifx\!emptyarg\!empty
    #2%
  \else
    #3%
  \fi}
 
% **  \!getnext\\ITEMfrom\LIST
% **    \LIST has the form \\{item1}\\{item2}\\{item3}...\\{itemk}
% **    This routine sets \ITEM to item1, and cycles \LIST to
% **    \\{item2}\\{item3}...\\{itemk}\\{item1}
\def\!getnext#1\from#2{%
  \expandafter\!gnext#2\!#1#2}%
\def\!gnext\\#1#2\!#3#4{%
  \def#3{#1}%
  \def#4{#2\\{#1}}%
  \ignorespaces}
 
 
% ** \!getnextvalueof\DIMEN\from\LIST
% **   Similar to !getnext.  
% **   \LIST has the form \\{dimen1}\\{dimen2}\\{dimen3} ... 
% **   \DIMEN is a dimension register
% **   Works also for counts
%
\def\!getnextvalueof#1\from#2{%
  \expandafter\!gnextv#2\!#1#2}%
\def\!gnextv\\#1#2\!#3#4{%
  #3=#1%
  \def#4{#2\\{#1}}%
  \ignorespaces}
 
 
% ** \!copylist\LISTMACROA\to\LISTMACROB
% **   makes the replacement text of LISTMACRO B identical to that of
% **   list macro A.
\def\!copylist#1\to#2{%
  \expandafter\!!copylist#1\!#2}
\def\!!copylist#1\!#2{%
  \def#2{#1}\ignorespaces}
 
 
% **  \!wlet\CSA=\CSB
% **  lets control sequence \CSB = control sequence \CSA, and writes a
% **    message to that effect in the log file using plain TEK's \wlog
\def\!wlet#1=#2{%
  \let#1=#2 
  \wlog{\string#1=\string#2}}
 
% ** \!listaddon ITEM LIST
% ** LIST <-- LIST \\ ITEM
\def\!listaddon#1#2{%
  \expandafter\!!listaddon#2\!{#1}#2}
\def\!!listaddon#1\!#2#3{%
  \def#3{#1\\#2}}
 
% **  \!rightappendITEM\to\LISTMACRO
% **    \LISTMACRO --> \LISTMACRO\\{ITEM}
%\def\!rightappend#1\to#2{\expandafter\!!rightappend#2\!{#1}#2}
%\def\!!rightappend#1\!#2#3{\def#3{#1\\{#2}}}
 
 
% **  \!rightappendITEM\withCS\to\LISTMACRO
% **    \LISTMACRO --> \LISTMACRO||CS||{ITEM}
\def\!rightappend#1\withCS#2\to#3{\expandafter\!!rightappend#3\!#2{#1}#3}
\def\!!rightappend#1\!#2#3#4{\def#4{#1#2{#3}}}
 
 
% **  \!leftappendITEM\withCS\to\LISTMACRO
% **    \LISTMACRO --> CS||{ITEM}||\LISTMACRO
\def\!leftappend#1\withCS#2\to#3{\expandafter\!!leftappend#3\!#2{#1}#3}
\def\!!leftappend#1\!#2#3#4{\def#4{#2{#3}#1}}
 
 
% **  \!lop\LISTMACRO\to\ITEM
% **    \\{item1}\\{item2}\\{item3} ... --> \\{item2}\\{item3} ...
% **    item1 --> \ITEM
\def\!lop#1\to#2{\expandafter\!!lop#1\!#1#2}
\def\!!lop\\#1#2\!#3#4{\def#4{#1}\def#3{#2}}
 
 
% **  \!placeNUMBER\of\LISTMACRO\in\ITEM
% **    the NUMBERth item of \LISTMACRO --> replacement text of \ITEM
%\def\!place#1\of#2\in#3{\def#3{\outofrange}%
%{\count0=#1\def\\##1{\advance\count0-1 \ifnum\count0=0 \gdef#3{##1}\fi}#2}}
 
 
% **  Following code converts a commalist to a list macro, with all items 
% **    fully expanded.
%\!ecfor\item:=\commalist\do{\expandafter\!rightappend\item\to\list}
 
 
% ** \!loop ... repeat
% ** This is exactly like TEX's \loop ... repeat.  It can be used in nesting
% ** two loops, without puting the inner one inside a group.
\def\!loop#1\repeat{\def\!body{#1}\!iterate}
\def\!iterate{\!body\let\!next=\!iterate\else\let\!next=\relax\fi\!next}
 
% ** \!!loop ... repeat
% ** This is exactly like TEX's \loop ... repeat.  It can be used in nesting
% ** two loops, without puting the inner one inside a group.
\def\!!loop#1\repeat{\def\!!body{#1}\!!iterate}
\def\!!iterate{\!!body\let\!!next=\!!iterate\else\let\!!next=\relax\fi\!!next}
%  (\multiput uses \!!loop)
 
% ** \!removept{DIMENREG}{\CS}
% ** Defines the control sequence CS to be the value (in points) in the
% ** dimension register DIMENREG (but without the "pt" TEK usually adds)
% ** E.g., after  \dimen0=12.3pt \!removept\dimen0\A, \A expands to 12.3
\def\!removept#1#2{\edef#2{\expandafter\!!removePT\the#1}}
{\catcode`p=12 \catcode`t=12 \gdef\!!removePT#1pt{#1}}

% ** \pladevalueinpts of <DIMENSION REGISTER> in {CONTROL SEQUENCE}
\def\placevalueinpts of <#1> in #2 {%
  \!removept{#1}{#2}}
 
% ** \!mlap{...}  \!vmlap{...}
% ** Center  ...  in a box of width 0.
\def\!mlap#1{\hbox to 0pt{\hss#1\hss}}
\def\!vmlap#1{\vbox to 0pt{\vss#1\vss}}
 
% ** \!not{TEK if-CONDITION}
% ** By a TEK if-CONDITION is meant something like 
% **     \ifnum\N<0,   or   \ifdim\A>\B
% ** \!not produces an if-condition which is false if the original condition
% ** is true, and true if the original condition is false.
\def\!not#1{%
  #1\relax
    \!switchfalse
  \else
    \!switchtrue
  \fi
  \if!switch
  \ignorespaces}
 

% *******************
% *** ALLOCATIONS ***
% *******************

% This section allocates all the registers PiCTeX uses. Following
% each allocation is a string of the form  ....N.D...L......... ;
% the various letters show which sections of PiCTeX make explicit
% reference to that register, according to the following code:
 
%   H Hacks
%   A Areas
%   W arroWs
%   B Bars
%   X boXes
%   C Curves
%   D Dashpattterns
%   V diVision
%   E Ellipses
%   U rUles
%   L Linear arc
%   G loGten
%   P Pictures
%   O plOtting
%   Y pYthagoras
%   Q Quadratic arc
%   R Rotations
%   S Shading
%   T Ticks

% Turn off messages from TeX's allocation macros
\let\!!!wlog=\wlog              % "\wlog" is defined in plain TeX
\def\wlog#1{}    

\newdimen\headingtoplotskip     %.A.................
\newdimen\linethickness         %.A..X....U........T
\newdimen\longticklength        %.A................T
\newdimen\plotsymbolspacing     %......D...L....Q...
\newdimen\shortticklength       %.A................T
\newdimen\stackleading          %.A..........P......
\newdimen\tickstovaluesleading  %.A................T
\newdimen\totalarclength        %......D...L....Q...
\newdimen\valuestolabelleading  %.A.................

\newbox\!boxA                   %.AW...............T
\newbox\!boxB                   %..W................
\newbox\!picbox                 %............P......
\newbox\!plotsymbol             %..........L..O.....
\newbox\!putobject              %............PO...S.
\newbox\!shadesymbol            %.................S.

\newcount\!countA               %.A....D..UL....Q.ST
\newcount\!countB               %......D..U.....Q.ST
\newcount\!countC               %...............Q..T
\newcount\!countD               %...................
\newcount\!countE               %.............O....T
\newcount\!countF               %.............O....T
\newcount\!countG               %..................T
\newcount\!fiftypt              %.........U.........
\newcount\!intervalno           %..........L....Q...
\newcount\!npoints              %..........L........
\newcount\!nsegments            %.........U.........
\newcount\!ntemp                %............P......
\newcount\!parity               %.................S.
\newcount\!scalefactor          %..................T
\newcount\!tfs                  %.......V...........
\newcount\!tickcase             %..................T

\newdimen\!Xleft                %............P......
\newdimen\!Xright               %............P......
\newdimen\!Xsave                %.A................T
\newdimen\!Ybot                 %............P......
\newdimen\!Ysave                %.A................T
\newdimen\!Ytop                 %............P......
\newdimen\!angle                %........E..........
\newdimen\!arclength            %..W......UL....Q...
\newdimen\!areabloc             %.A........L........
\newdimen\!arealloc             %.A........L........
\newdimen\!arearloc             %.A........L........
\newdimen\!areatloc             %.A........L........
\newdimen\!bshrinkage           %.................S.
\newdimen\!checkbot             %..........L........
\newdimen\!checkleft            %..........L........
\newdimen\!checkright           %..........L........
\newdimen\!checktop             %..........L........
\newdimen\!dimenA               %.AW.X.DVEUL..OYQRST
\newdimen\!dimenB               %....X.DVEU...O.QRS.
\newdimen\!dimenC               %..W.X.DVEU......RS.
\newdimen\!dimenD               %..W.X.DVEU....Y.RS.
\newdimen\!dimenE               %..W........G..YQ.S.
\newdimen\!dimenF               %...........G..YQ.S.
\newdimen\!dimenG               %...........G..YQ.S.
\newdimen\!dimenH               %...........G..Y..S.
\newdimen\!dimenI               %...BX.........Y....
\newdimen\!distacross           %..........L....Q...
\newdimen\!downlength           %..........L........
\newdimen\!dp                   %.A..X.......P....S.
\newdimen\!dshade               %.................S.
\newdimen\!dxpos                %..W......U..P....S.
\newdimen\!dxprime              %...............Q...
\newdimen\!dypos                %..WB.....U..P......
\newdimen\!dyprime              %...............Q...
\newdimen\!ht                   %.A..X.......P....S.
\newdimen\!leaderlength         %......D..U.........
\newdimen\!lshrinkage           %.................S.
\newdimen\!midarclength         %...............Q...
\newdimen\!offset               %.A................T
\newdimen\!plotheadingoffset    %.A.................
\newdimen\!plotsymbolxshift     %..........L..O.....
\newdimen\!plotsymbolyshift     %..........L..O.....
\newdimen\!plotxorigin          %..........L..O.....
\newdimen\!plotyorigin          %..........L..O.....
\newdimen\!rootten              %...........G.......
\newdimen\!rshrinkage           %.................S.
\newdimen\!shadesymbolxshift    %.................S.
\newdimen\!shadesymbolyshift    %.................S.
\newdimen\!tenAa                %...........G.......
\newdimen\!tenAc                %...........G.......
\newdimen\!tenAe                %...........G.......
\newdimen\!tshrinkage           %.................S.
\newdimen\!uplength             %..........L........
\newdimen\!wd                   %....X.......P....S.
\newdimen\!wmax                 %...............Q...
\newdimen\!wmin                 %...............Q...
\newdimen\!xB                   %...............Q...
\newdimen\!xC                   %...............Q...
\newdimen\!xE                   %..W.....E.L....Q.S.
\newdimen\!xM                   %..W.....E......Q.S.
\newdimen\!xS                   %..W.....E.L....Q.S.
\newdimen\!xaxislength          %.A................T
\newdimen\!xdiff                %..........L........
\newdimen\!xleft                %............P......
\newdimen\!xloc                 %..WB.....U.......S.
\newdimen\!xorigin              %.A........L.P....S.
\newdimen\!xpivot               %................R..
\newdimen\!xpos                 %..........L.P..Q.ST
\newdimen\!xprime               %...............Q...
\newdimen\!xright               %............P......
\newdimen\!xshade               %.................S.
\newdimen\!xshift               %..W.........PO...S.
\newdimen\!xtemp                %............P......
\newdimen\!xunit                %.AWBX...EUL.P..QRS.
\newdimen\!xxE                  %........E..........
\newdimen\!xxM                  %........E..........
\newdimen\!xxS                  %........E..........
\newdimen\!xxloc                %..WB....EU.........
\newdimen\!yB                   %...............Q...
\newdimen\!yC                   %...............Q...
\newdimen\!yE                   %..W.....E.L....Q...
\newdimen\!yM                   %..W.....E......Q...
\newdimen\!yS                   %..W.....E.L....Q...
\newdimen\!yaxislength          %.A................T
\newdimen\!ybot                 %............P......
\newdimen\!ydiff                %..........L........
\newdimen\!yloc                 %..WB.....U.......S.
\newdimen\!yorigin              %.A........L.P....S.
\newdimen\!ypivot               %................R..
\newdimen\!ypos                 %..........L.P..Q.ST
\newdimen\!yprime               %...............Q...
\newdimen\!yshade               %.................S.
\newdimen\!yshift               %..W.........PO...S.
\newdimen\!ytemp                %............P......
\newdimen\!ytop                 %............P......
\newdimen\!yunit                %.AWBX...EUL.P..QRS.
\newdimen\!yyE                  %........E..........
\newdimen\!yyM                  %........E..........
\newdimen\!yyS                  %........E..........
\newdimen\!yyloc                %..WB....EU.........
\newdimen\!zpt                  %.AWBX.DVEULGP.YQ.ST

\newif\if!axisvisible           %.A.................
\newif\if!gridlinestoo          %..................T
\newif\if!keepPO                %...................
\newif\if!placeaxislabel        %.A.................
\newif\if!switch                %H..................
\newif\if!xswitch               %.A................T

\newtoks\!axisLaBeL             %.A.................
\newtoks\!keywordtoks           %.A.................

\newwrite\!replotfile           %.............O.....

\newhelp\!keywordhelp{The keyword mentioned in the error message in unknown. 
Replace NEW KEYWORD in the indicated response by the keyword that 
should have been specified.}    %.A.................

% The following commands assign alternate names to some of the 
% above registers.  "\!wlet"  is defined in  Hacks.
\!wlet\!!origin=\!xM                   %.A................T
\!wlet\!!unit=\!uplength               %.A................T
\!wlet\!Lresiduallength=\!dimenG       %.........U.........
\!wlet\!Rresiduallength=\!dimenF       %.........U.........
\!wlet\!axisLength=\!distacross        %.A................T
\!wlet\!axisend=\!ydiff                %.A................T
\!wlet\!axisstart=\!xdiff              %.A................T
\!wlet\!axisxlevel=\!arclength         %.A................T
\!wlet\!axisylevel=\!downlength        %.A................T
\!wlet\!beta=\!dimenE                  %...............Q...
\!wlet\!gamma=\!dimenF                 %...............Q...
\!wlet\!shadexorigin=\!plotxorigin     %.................S.
\!wlet\!shadeyorigin=\!plotyorigin     %.................S.
\!wlet\!ticklength=\!xS                %..................T
\!wlet\!ticklocation=\!xE              %..................T
\!wlet\!ticklocationincr=\!yE          %..................T
\!wlet\!tickwidth=\!yS                 %..................T
\!wlet\!totalleaderlength=\!dimenE     %.........U.........
\!wlet\!xone=\!xprime                  %....X..............
\!wlet\!xtwo=\!dxprime                 %....X..............
\!wlet\!ySsave=\!yM                    %...................
\!wlet\!ybB=\!yB                       %.................S.
\!wlet\!ybC=\!yC                       %.................S.
\!wlet\!ybE=\!yE                       %.................S.
\!wlet\!ybM=\!yM                       %.................S.
\!wlet\!ybS=\!yS                       %.................S.
\!wlet\!ybpos=\!yyloc                  %.................S.
\!wlet\!yone=\!yprime                  %....X..............
\!wlet\!ytB=\!xB                       %.................S.
\!wlet\!ytC=\!xC                       %.................S.
\!wlet\!ytE=\!downlength               %.................S.
\!wlet\!ytM=\!arclength                %.................S.
\!wlet\!ytS=\!distacross               %.................S.
\!wlet\!ytpos=\!xxloc                  %.................S.
\!wlet\!ytwo=\!dyprime                 %....X..............


% Initial values for registers
\!zpt=0pt                              % static
\!xunit=1pt
\!yunit=1pt
\!arearloc=\!xunit
\!areatloc=\!yunit
\!dshade=5pt
\!leaderlength=24in
\!tfs=256                              % static
\!wmax=5.3pt                           % static
\!wmin=2.7pt                           % static
\!xaxislength=\!xunit
\!xpivot=\!zpt
\!yaxislength=\!yunit 
\!ypivot=\!zpt
\plotsymbolspacing=.4pt
  \!dimenA=50pt \!fiftypt=\!dimenA     % static

\!rootten=3.162278pt                   % static
\!tenAa=8.690286pt                     % static  (A5)
\!tenAc=2.773839pt                     % static  (A3)
\!tenAe=2.543275pt                     % static  (A1)

% Initial values for control sequences
\def\!cosrotationangle{1}      %................R..
\def\!sinrotationangle{0}      %................R..
\def\!xpivotcoord{0}           %................R..
\def\!xref{0}                  %............P......
\def\!xshadesave{0}            %.................S.
\def\!ypivotcoord{0}           %................R..
\def\!yref{0}                  %............P......
\def\!yshadesave{0}            %.................S.
\def\!zero{0}                  %..................T

% Reset TeX to report allocations
\let\wlog=\!!!wlog
%  *************************************
%  ***  AREAS: Deals with plot areas ***
%  *************************************
%
%  ** User commands
%  **   \setplotarea x from LEFT XCOORD to RIGTH XCOORD, y from BOTTOM YCOORD
%  **      to TOP YCOORD
%  **   \axis BOTTOM-LEFT-TOP-RIGHT  [SHIFTEDTO xy=COORD] [VISIBLE-INVISIBLE]
%  **      [LABEL {label}] [TICKS] /
%  **   \visibleaxes
%  **   \invisibleaxes
%  **   \plotheading {HEADING}
%  **   \grid {# of columns} {# of rows}
%  **   \normalgraphs 
  
%  **  \normalgraphs
%  **    Sets defaults for graph setup. See Subsection 3.4 of manual.
\def\normalgraphs{%
  \longticklength=.4\baselineskip
  \shortticklength=.25\baselineskip
  \tickstovaluesleading=.25\baselineskip
  \valuestolabelleading=.8\baselineskip
  \linethickness=.4pt
  \stackleading=.17\baselineskip
  \headingtoplotskip=1.5\baselineskip
  \visibleaxes
  \ticksout
  \nogridlines
  \unloggedticks}
%
% **  \setplotarea x from LEFT XCOORD to RIGTH XCOORD, y from BOTTOM YCOORD
% **    to TOP YCOORD
% **  Reserves space in PICBOX for a rectangular box with the indicated
% **   coordinates.  Must be specified before calls to  \axis, 
% **   \grid, \plotheading.
% **  See Subsection 3.1 of the manual.
\def\setplotarea x from #1 to #2, y from #3 to #4 {%
  \!arealloc=\!M{#1}\!xunit \advance \!arealloc -\!xorigin
  \!areabloc=\!M{#3}\!yunit \advance \!areabloc -\!yorigin
  \!arearloc=\!M{#2}\!xunit \advance \!arearloc -\!xorigin
  \!areatloc=\!M{#4}\!yunit \advance \!areatloc -\!yorigin
  \!initinboundscheck
  \!xaxislength=\!arearloc  \advance\!xaxislength -\!arealloc
  \!yaxislength=\!areatloc  \advance\!yaxislength -\!areabloc
  \!plotheadingoffset=\!zpt
  \!dimenput {{\setbox0=\hbox{}\wd0=\!xaxislength\ht0=\!yaxislength\box0}}
     [bl] (\!arealloc,\!areabloc)}
%
% ** \visibleaxes, \invisibleaxes 
% ** Switches for setting visibility of subsequent axes.
% ** See Subsection 3.2 of the manual.
\def\visibleaxes{%
  \def\!axisvisibility{\!axisvisibletrue}}
\def\invisibleaxes{%
  \def\!axisvisibility{\!axisvisiblefalse}}
%
% ** The next few macros enable the user to fix up an erroneous keyword
% **   in the \axis command.
%  \newhelp is in ALLOCATIONS
%  \newhelp\!keywordhelp{The keyword mentioned in the error message in unknown. 
%  Replace NEW KEYWORD in the indicated response by the keyword that 
%  should have been specified.}

\def\!fixkeyword#1{%
  \errhelp=\!keywordhelp
  \errmessage{Unrecognized keyword `#1': \the\!keywordtoks{NEW KEYWORD}'}}

%  \newtoks\!keywordtoks    In ALLOCATIONS.
\!keywordtoks={enter `i\fixkeyword}

\def\fixkeyword#1{%
  \!nextkeyword#1 }

% ** \axis BOTTOM-LEFT-TOP-RIGHT  [SHIFTEDTO xy=COORD] [VISIBLE-INVISIBLE]
% **   [LABEL {label}] [TICKS] /
% ** Exactly one of the keywords BOTTOM, LEFT, TOP, RIGHT must be
% ** specified. Axis is drawn along the indicated edge of the current
% ** plot area, shifted if the SHIFTEDTO option is used, visible or
% ** invisible according the selected option, with an optional LABEL,
% ** and optional TICKS (see ticks.tex for the options avialabel with
% ** TICKS). The TICKS option must be the last one specified. The \axis
% ** MUST be terminated with a / followed by a space.
% ** See Subsection 3.2 of the manual for more information.

% ** The various options of the \axis command are processed by the
% ** \!nextkeyword macro defined below. For example, 
% ** `\!nextkeyword shiftedto ' expands to `\!axisshiftedto'.
\def\axis {%
  \def\!nextkeyword##1 {%
    \expandafter\ifx\csname !axis##1\endcsname \relax
      \def\!next{\!fixkeyword{##1}}%
    \else
      \def\!next{\csname !axis##1\endcsname}%
    \fi
    \!next}%
  \!offset=\!zpt
  \!axisvisibility
  \!placeaxislabelfalse
  \!nextkeyword}

% ** This and the various macros that follow handle the keyword
% ** specifications on the \axis command
% ** See Subsection 3.2 of the manual.
\def\!axisbottom{%
  \!axisylevel=\!areabloc
  \def\!tickxsign{0}%
  \def\!tickysign{-}%
  \def\!axissetup{\!axisxsetup}%
  \def\!axislabeltbrl{t}%
  \!nextkeyword}

\def\!axistop{%
  \!axisylevel=\!areatloc
  \def\!tickxsign{0}%
  \def\!tickysign{+}%
  \def\!axissetup{\!axisxsetup}%
  \def\!axislabeltbrl{b}%
  \!nextkeyword}

\def\!axisleft{%
  \!axisxlevel=\!arealloc
  \def\!tickxsign{-}%
  \def\!tickysign{0}%
  \def\!axissetup{\!axisysetup}%
  \def\!axislabeltbrl{r}%
  \!nextkeyword}

\def\!axisright{%
  \!axisxlevel=\!arearloc
  \def\!tickxsign{+}%
  \def\!tickysign{0}%
  \def\!axissetup{\!axisysetup}%
  \def\!axislabeltbrl{l}%
  \!nextkeyword}

\def\!axisshiftedto#1=#2 {%
  \if 0\!tickxsign
    \!axisylevel=\!M{#2}\!yunit
    \advance\!axisylevel -\!yorigin
  \else
    \!axisxlevel=\!M{#2}\!xunit
    \advance\!axisxlevel -\!xorigin
  \fi
  \!nextkeyword}

\def\!axisvisible{%
  \!axisvisibletrue  
  \!nextkeyword}

\def\!axisinvisible{%
  \!axisvisiblefalse
  \!nextkeyword}

\def\!axislabel#1 {%
  \!axisLaBeL={#1}%
  \!placeaxislabeltrue
  \!nextkeyword}

\expandafter\def\csname !axis/\endcsname{%
  \!axissetup % This could done already by "ticks"; if so, now \relax
  \if!placeaxislabel
    \!placeaxislabel
  \fi
  \if +\!tickysign %                 ** (A "top" axis)
    \!dimenA=\!axisylevel
    \advance\!dimenA \!offset %      ** dimA = top of the axis structure
    \advance\!dimenA -\!areatloc %   ** dimA = excess over the plot area
    \ifdim \!dimenA>\!plotheadingoffset
      \!plotheadingoffset=\!dimenA % ** Greatest excess over the plot area
    \fi
  \fi}

% ** \grid {c} {r} 
% ** Partitions the plot area into c columns and r rows; see Subsection 3.3
% ** of the manual.
% ** (Other grid patterns can be drawn with the TICKS option of the \axis 
% ** command.
\def\grid #1 #2 {%
  \!countA=#1\advance\!countA 1
  \axis bottom invisible ticks length <\!zpt> andacross quantity {\!countA} /
  \!countA=#2\advance\!countA 1
  \axis left   invisible ticks length <\!zpt> andacross quantity {\!countA} / }

% ** \plotheading{HEADING}
% ** Places HEADING centered above the top of the plotarea (and above
% ** any top axis ticks marks, tick labels, and axis label); see
% ** Subsection 3.3 of the manual.
\def\plotheading#1 {%
  \advance\!plotheadingoffset \headingtoplotskip
  \!dimenput {#1} [B] <.5\!xaxislength,\!plotheadingoffset>
    (\!arealloc,\!areatloc)}

% ** From here on, the routines are internal.
\def\!axisxsetup{%
  \!axisxlevel=\!arealloc
  \!axisstart=\!arealloc
  \!axisend=\!arearloc
  \!axisLength=\!xaxislength
  \!!origin=\!xorigin
  \!!unit=\!xunit
  \!xswitchtrue
  \if!axisvisible 
    \!makeaxis
  \fi}

\def\!axisysetup{%
  \!axisylevel=\!areabloc
  \!axisstart=\!areabloc
  \!axisend=\!areatloc
  \!axisLength=\!yaxislength
  \!!origin=\!yorigin
  \!!unit=\!yunit
  \!xswitchfalse
  \if!axisvisible
    \!makeaxis
  \fi}

\def\!makeaxis{%
  \setbox\!boxA=\hbox{% (Make a pseudo-y[x] tick for an x[y]-axis)
    \beginpicture
      \!setdimenmode
      \setcoordinatesystem point at {\!zpt} {\!zpt}   
      \putrule from {\!zpt} {\!zpt} to
        {\!tickysign\!tickysign\!axisLength} 
        {\!tickxsign\!tickxsign\!axisLength}
    \endpicturesave <\!Xsave,\!Ysave>}%
    \wd\!boxA=\!zpt
    \!placetick\!axisstart}

\def\!placeaxislabel{%
  \advance\!offset \valuestolabelleading
  \if!xswitch
    \!dimenput {\the\!axisLaBeL} [\!axislabeltbrl]
      <.5\!axisLength,\!tickysign\!offset> (\!axisxlevel,\!axisylevel)
    \advance\!offset \!dp  % ** advance offset by the "tallness"
    \advance\!offset \!ht  % ** of the label
  \else
    \!dimenput {\the\!axisLaBeL} [\!axislabeltbrl]
      <\!tickxsign\!offset,.5\!axisLength> (\!axisxlevel,\!axisylevel)
  \fi
  \!axisLaBeL={}}


% *******************************
% *** ARROWS  (Draws arrows)  ***
% *******************************
%
% ** User commands
% **  \arrow <ARROW HEAD LENGTH> [MID FRACTION, BASE FRACTION]
% **    [<XSHIFT,YSHIFT>] from XFROM YFROM to XTO YTO
% **  \betweenarrows {TEXT} [orientation & shift] from XFROM YFROM to XTO YTO

% ** \arrow <ARROW HEAD LENGTH> [MID FRACTION, BASE FRACTION]
% **    [<XSHIFT,YSHIFT>] from XFROM YFROM to XTO YTO
% ** Draws an arrow from (XFROM,YFROM) to (XTO,YTO).  The arrow head
% ** is constructed two quadratic arcs, which extend back a distance
% ** ARROW HEAD LENGTH (a dimension) on both sides of the arrow shaft.
% ** All the way back the arcs are a distance BASE FRACTION*ARROW HEAD
% ** LENGTH apart, while half-way back they are a distance MID FRACTION*
% ** ARROW HEAD LENGTH apart. <XSHIFT,YSHIFT> is optional, and has
% ** its usual interpreation. See Subsection 5.4 of the manual.

\def\arrow <#1> [#2,#3]{%
  \!ifnextchar<{\!arrow{#1}{#2}{#3}}{\!arrow{#1}{#2}{#3}<\!zpt,\!zpt> }}

\def\!arrow#1#2#3<#4,#5> from #6 #7 to #8 #9 {%
%
% ** convert to dimensions
  \!xloc=\!M{#8}\!xunit   
  \!yloc=\!M{#9}\!yunit
  \!dxpos=\!xloc  \!dimenA=\!M{#6}\!xunit  \advance \!dxpos -\!dimenA
  \!dypos=\!yloc  \!dimenA=\!M{#7}\!yunit  \advance \!dypos -\!dimenA
  \let\!MAH=\!M%                         ** save current c/d mode
  \!setdimenmode%                        ** go into dimension mode
%
  \!xshift=#4\relax  \!yshift=#5\relax%  ** pick up shift
  \!reverserotateonly\!xshift\!yshift%   ** back rotate shift
  \advance\!xshift\!xloc  \advance\!yshift\!yloc
%
% **  draw shaft of arrow
  \!xS=-\!dxpos  \advance\!xS\!xshift
  \!yS=-\!dypos  \advance\!yS\!yshift
  \!start (\!xS,\!yS)
  \!ljoin (\!xshift,\!yshift)
%
% ** find 32*cosine and 32*sine of angle of rotation
  \!Pythag\!dxpos\!dypos\!arclength
  \!divide\!dxpos\!arclength\!dxpos  
  \!dxpos=32\!dxpos  \!removept\!dxpos\!!cos
  \!divide\!dypos\!arclength\!dypos  
  \!dypos=32\!dypos  \!removept\!dypos\!!sin
% 
% ** construct arrowhead
  \!halfhead{#1}{#2}{#3}%                ** draw half of arrow head
  \!halfhead{#1}{-#2}{-#3}%              ** draw other half
%
  \let\!M=\!MAH%                         ** restore old c/d mode
  \ignorespaces}
%
% ** draw half of arrow head
  \def\!halfhead#1#2#3{%
    \!dimenC=-#1%                
    \divide \!dimenC 2 %                 ** half way back
    \!dimenD=#2\!dimenC%                 ** half the mid width
    \!rotate(\!dimenC,\!dimenD)by(\!!cos,\!!sin)to(\!xM,\!yM)
    \!dimenC=-#1%                        ** all the way back
    \!dimenD=#3\!dimenC
    \!dimenD=.5\!dimenD%                 ** half the full width
    \!rotate(\!dimenC,\!dimenD)by(\!!cos,\!!sin)to(\!xE,\!yE)
    \!start (\!xshift,\!yshift)
    \advance\!xM\!xshift  \advance\!yM\!yshift
    \advance\!xE\!xshift  \advance\!yE\!yshift
    \!qjoin (\!xM,\!yM) (\!xE,\!yE) 
    \ignorespaces}


% ** \betweenarrows {TEXT} [orientation & shift] from XFROM YFROM to XTO YTO
% **   Makes things like <--- text --->, using arrow heads from TeX's fonts.
% **   See Subsection 5.4 of the manual.
\def\betweenarrows #1#2 from #3 #4 to #5 #6 {%
  \!xloc=\!M{#3}\!xunit  \!xxloc=\!M{#5}\!xunit%   
  \!yloc=\!M{#4}\!yunit  \!yyloc=\!M{#6}\!yunit%           
  \!dxpos=\!xxloc  \advance\!dxpos by -\!xloc
  \!dypos=\!yyloc  \advance\!dypos by -\!yloc
  \advance\!xloc .5\!dxpos
  \advance\!yloc .5\!dypos
%
  \let\!MBA=\!M%           ** save current coord\dimen mode
  \!setdimenmode%          ** express locations in dimens
  \ifdim\!dypos=\!zpt
    \ifdim\!dxpos<\!zpt \!dxpos=-\!dxpos \fi
    \put {\!lrarrows{\!dxpos}{#1}}#2{} at {\!xloc} {\!yloc}
  \else
    \ifdim\!dxpos=\!zpt
      \ifdim\!dypos<\!zpt \!dypos=-\!zpt \fi
      \put {\!udarrows{\!dypos}{#1}}#2{} at {\!xloc} {\!yloc}
    \fi
  \fi
  \let\!M=\!MBA%           ** restore previous c/d mode
  \ignorespaces}

% ** Subroutine for left-right between arrows 
\def\!lrarrows#1#2{% #1=width, #2=text
  {\setbox\!boxA=\hbox{$\mkern-2mu\mathord-\mkern-2mu$}%
   \setbox\!boxB=\hbox{$\leftarrow$}\!dimenE=\ht\!boxB
   \setbox\!boxB=\hbox{}\ht\!boxB=2\!dimenE
   \hbox to #1{$\mathord\leftarrow\mkern-6mu
     \cleaders\copy\!boxA\hfil
     \mkern-6mu\mathord-$%
     \kern.4em $\vcenter{\box\!boxB}$$\vcenter{\hbox{#2}}$\kern.4em
     $\mathord-\mkern-6mu
     \cleaders\copy\!boxA\hfil
     \mkern-6mu\mathord\rightarrow$}}}

% ** Subroutine for up-down between arrows 
\def\!udarrows#1#2{% #1=width, #2=text
  {\setbox\!boxB=\hbox{#2}%
   \setbox\!boxA=\hbox to \wd\!boxB{\hss$\vert$\hss}%
   \!dimenE=\ht\!boxA \advance\!dimenE \dp\!boxA \divide\!dimenE 2
   \vbox to #1{\offinterlineskip
      \vskip .05556\!dimenE
      \hbox to \wd\!boxB{\hss$\mkern.4mu\uparrow$\hss}\vskip-\!dimenE
      \cleaders\copy\!boxA\vfil
      \vskip-\!dimenE\copy\!boxA
      \vskip\!dimenE\copy\!boxB\vskip.4em
      \copy\!boxA\vskip-\!dimenE
      \cleaders\copy\!boxA\vfil
      \vskip-\!dimenE \hbox to \wd\!boxB{\hss$\mkern.4mu\downarrow$\hss}
      \vskip .05556\!dimenE}}}


% ***************************
% *** BARS  (Draws bars)  ***
% ***************************
%
% ** User commands:
% ** \putbar [<XSHIFT,YSHIFT>] breadth <BREADTH> from XSTART YSTART
% **   to XEND YEND
% ** \setbars [<XSHIFT,YSHIFT>] breadth <BREADTH> baseline at XY = COORD
% **   [baselabels ([B_ORIENTATION_x,B_ORIENTATION_y] <B_XSHIFT,B_YSHIFT>)]
% **   [endlabels  ([E_ORIENTATION_x,E_ORIENTATION_y] <E_XSHIFT,E_YSHIFT>)]


% ** \putbar [<XSHIFT,YSHIFT>] breadth <BREADTH> from XSTART YSTART
% **   to XEND YEND
% ** Either XSTART=XEND or YSTART=YEND. Draws a rectangle between
% **   (XSTART,YSTART) & (XEND,YEND). The "depth" of the rectangle
% **   is determined by those two plot positions; its other
% **   dimension "breadth" is specified by the dimension BREADTH.
% ** See Subsection 4.2 of the manual.
\def\putbar#1breadth <#2> from #3 #4 to #5 #6 {%
  \!xloc=\!M{#3}\!xunit  \!xxloc=\!M{#5}\!xunit%   
  \!yloc=\!M{#4}\!yunit  \!yyloc=\!M{#6}\!yunit%           
  \!dypos=\!yyloc  \advance\!dypos by -\!yloc
  \!dimenI=#2  
% 
  \ifdim \!dimenI=\!zpt %            ** If 0 breadth
    \putrule#1from {#3} {#4} to {#5} {#6} % ** Then draw line
  \else %                            ** Else, put in a rectangle
    \let\!MBar=\!M%                  ** save current c/d mode
    \!setdimenmode %                 ** go into dimension mode
    \divide\!dimenI 2
    \ifdim \!dypos=\!zpt             
      \advance \!yloc -\!dimenI %    ** Equal y coordinates
      \advance \!yyloc \!dimenI
    \else
      \advance \!xloc -\!dimenI %    ** Equal x coordinates
      \advance \!xxloc \!dimenI
    \fi
    \putrectangle#1corners at {\!xloc} {\!yloc} and {\!xxloc} {\!yyloc}
    \let\!M=\!MBar %                 ** restore c/d mode
  \fi
  \ignorespaces}


% ** \setbars [<XSHIFT,YSHIFT>] breadth <BREADTH> baseline at XY = COORD
% **   [baselabels ([B_ORIENTATION_x,B_ORIENTATION_y] <B_XSHIFT,B_YSHIFT>)]
% **   [endlabels  ([E_ORIENTATION_x,E_ORIENTATION_y] <E_XSHIFT,E_YSHIFT>)]
% ** This command puts PiCTeX into the bar graph drawing mode described
% **   in Subsection 4.4 of the manual.
\def\setbars#1breadth <#2> baseline at #3 = #4 {%
  \edef\!barshift{#1}%
  \edef\!barbreadth{#2}%
  \edef\!barorientation{#3}%
  \edef\!barbaseline{#4}%
  \def\!bardobaselabel{\!bardoendlabel}%
  \def\!bardoendlabel{\!barfinish}%
  \let\!drawcurve=\!barcurve
  \!setbars}
\def\!setbars{%
  \futurelet\!nextchar\!!setbars}
\def\!!setbars{%
  \if b\!nextchar
    \def\!!!setbars{\!setbarsbget}%
  \else 
    \if e\!nextchar
      \def\!!!setbars{\!setbarseget}%
    \else
      \def\!!!setbars{\relax}%
    \fi
  \fi
  \!!!setbars}
\def\!setbarsbget baselabels (#1) {%
  \def\!barbaselabelorientation{#1}%
  \def\!bardobaselabel{\!!bardobaselabel}%
  \!setbars}
\def\!setbarseget endlabels (#1) {%
  \edef\!barendlabelorientation{#1}%
  \def\!bardoendlabel{\!!bardoendlabel}%
  \!setbars}

% ** \!barcurve
% ** Draws a bargraph with preset values of barshift, barbreadth,
% ** barorientation (x or y) and barbaseline (coordinate)
\def\!barcurve #1 #2 {%
  \if y\!barorientation
    \def\!basexarg{#1}%
    \def\!baseyarg{\!barbaseline}%
  \else
    \def\!basexarg{\!barbaseline}%
    \def\!baseyarg{#2}%
  \fi
  \expandafter\putbar\!barshift breadth <\!barbreadth> from {\!basexarg}
    {\!baseyarg} to {#1} {#2}
  \def\!endxarg{#1}%
  \def\!endyarg{#2}%
  \!bardobaselabel}

\def\!!bardobaselabel "#1" {%
  \put {#1}\!barbaselabelorientation{} at {\!basexarg} {\!baseyarg}
  \!bardoendlabel}
 
\def\!!bardoendlabel "#1" {%
  \put {#1}\!barendlabelorientation{} at {\!endxarg} {\!endyarg}
  \!barfinish}

\def\!barfinish{%
  \!ifnextchar/{\!finish}{\!barcurve}}
 

% ********************************
% *** BOXES (Draws rectangles) ***
% ********************************
%
% ** User commands:
% **   \putrectangle [<XSHIFT,YSHIFT>] corners at  XCOORD1 YCOORD1
% **     and  XCOORD2 YCOORD2 
% **   \shaderectangleson
% **   \shaderectanglesoff
% **   \frame [<SEPARATION>] {TEXT}
% **   \rectangle <WIDTH> <HEIGHT>
%
%
% **  \putrectangle [<XSHIFT,YSHIFT>] corners at XCOORD1 YCOORD1 
% **    and  XCOORD2 YCOORD2 
% **  Draws a rectangle with corners at (X1,Y1), (X2,Y1), (X1,Y2), (X2,Y2)
% **  Lines have thickness \linethickness, and overlap at the corners.
% **  The optional field  <XSHIFT,YSHIFT>  functions as with a \put command.
% **  See Subsection 4.2 of the manual.
\def\putrectangle{%
  \!ifnextchar<{\!putrectangle}{\!putrectangle<\!zpt,\!zpt> }}
\def\!putrectangle<#1,#2> corners at #3 #4 and #5 #6 {%
%
% ** get locations
  \!xone=\!M{#3}\!xunit  \!xtwo=\!M{#5}\!xunit%   
  \!yone=\!M{#4}\!yunit  \!ytwo=\!M{#6}\!yunit%           
  \ifdim \!xtwo<\!xone
    \!dimenI=\!xone  \!xone=\!xtwo  \!xtwo=\!dimenI
  \fi
  \ifdim \!ytwo<\!yone
    \!dimenI=\!yone  \!yone=\!ytwo  \!ytwo=\!dimenI
  \fi
  \!dimenI=#1\relax  \advance\!xone\!dimenI  \advance\!xtwo\!dimenI
  \!dimenI=#2\relax  \advance\!yone\!dimenI  \advance\!ytwo\!dimenI
  \let\!MRect=\!M%                  ** save current coord/dimen mode
  \!setdimenmode
%
% ** shade rectangle if appropriate
  \!shaderectangle
%
% ** draw horizontal edges
  \!dimenI=.5\linethickness
  \advance \!xone  -\!dimenI%       ** adjust x-location to overlap corners
  \advance \!xtwo   \!dimenI%       ** ditto
  \putrule from {\!xone} {\!yone} to {\!xtwo} {\!yone} 
  \putrule from {\!xone} {\!ytwo} to {\!xtwo} {\!ytwo} 
%
% ** draw vertical edges
  \advance \!xone   \!dimenI%       ** restore original x-values
  \advance \!xtwo  -\!dimenI% 
  \advance \!yone  -\!dimenI%       ** adjust y-location to overlap corners
  \advance \!ytwo   \!dimenI%       ** ditto
  \putrule from {\!xone} {\!yone} to {\!xone} {\!ytwo} 
  \putrule from {\!xtwo} {\!yone} to {\!xtwo} {\!ytwo} 
%
  \let\!M=\!MRect%                  ** restore coord/dimen mode
  \ignorespaces}
 
% ** \shaderectangleson 
% **   Subsequent rectangles will be shaded according to 
% **   the current shading pattern.  Affects \putrectangle, \putbar,
% **   \frame, \sethistograms, and \setbars. See Subsection 7.5 of the manual.
\def\shaderectangleson{%     
  \def\!shaderectangle{\!!shaderectangle}%
  \ignorespaces}
% ** \shaderectanglesoff 
% **    Suppresses  \shaderectangleson.  The default.
\def\shaderectanglesoff{%
  \def\!shaderectangle{}%
  \ignorespaces}

\shaderectanglesoff
 
% ** The following internal routine shades the current rectangle, when
% **   \!shaderectangle = \!!shaderectangle . 
\def\!!shaderectangle{%
  \!dimenA=\!xtwo  \advance \!dimenA -\!xone
  \!dimenB=\!ytwo  \advance \!dimenB -\!yone
  \ifdim \!dimenA<\!dimenB
    \!startvshade (\!xone,\!yone,\!ytwo)
    \!lshade      (\!xtwo,\!yone,\!ytwo)
  \else
    \!starthshade (\!yone,\!xone,\!xtwo)
    \!lshade      (\!ytwo,\!xone,\!xtwo)
  \fi
  \ignorespaces}
  
% ** \frame [<SEPARATION>] {TEXT}
% ** Draws a frame of thickness linethickness about the box enclosing
% **   TEXT; the frame is separated from the box by a distance of
% **   SEPARATION.  The result is an hbox with the same baseline as TEXT.
% **   If <SEPARATION> is omitted, you get the effect of <0pt>.
% ** See Subsection 4.2 of the manual.
\def\frame{%
  \!ifnextchar<{\!frame}{\!frame<\!zpt> }}
\long\def\!frame<#1> #2{%
  \beginpicture
    \setcoordinatesystem units <1pt,1pt> point at 0 0 
    \put {#2} [Bl] at 0 0 
    \!dimenA=#1\relax
    \!dimenB=\!wd \advance \!dimenB \!dimenA
    \!dimenC=\!ht \advance \!dimenC \!dimenA
    \!dimenD=\!dp \advance \!dimenD \!dimenA
    \let\!MFr=\!M
    \!setdimenmode
    \putrectangle corners at {-\!dimenA} {-\!dimenD} and {\!dimenB} {\!dimenC}
    \!setcoordmode
    \let\!M=\!MFr
  \endpicture
  \ignorespaces}
 
% ** \rectangle <WIDTH> <HEIGHT>
% ** Constructs a rectangle of width WIDTH and heigth HEIGHT. 
% ** See Subsection 4.2 of the manual.
\def\rectangle <#1> <#2> {%
  \setbox0=\hbox{}\wd0=#1\ht0=#2\frame {\box0}}


% *********************************************
% ***  CURVES  (Upper level \plot commands) ***
% *********************************************
%
% ** User commands
% **   \plot  DATA  /
% **   \plot  "FILE NAME"
% **   \setquadratic
% **   \setlinear
% **   \sethistograms
% **   \vshade  ...
% **   \hshade  ...

% \plot: multi-purpose command. Draws histograms, bar graphs, piecewise-linear
% or piecewise quadratic curves, depending on the setting of \!drawcurve.
% See Subsections 4.3-4.5, 5.1, 5.2 of the manual.
\def\plot{%
  \!ifnextchar"{\!plotfromfile}{\!drawcurve}}
\def\!plotfromfile"#1"{%
  \expandafter\!drawcurve \input #1 /}

% Command to set piecewise quadratic mode
% See Subsections 5.1, 7.3, and 7.4 of the manual.
\def\setquadratic{%
  \let\!drawcurve=\!qcurve
  \let\!!Shade=\!!qShade
  \let\!!!Shade=\!!!qShade}

% Command to set piecewise linear mode
% See Subsections 5.1, 7.3, and 7.4 of the manual.
\def\setlinear{%
  \let\!drawcurve=\!lcurve
  \let\!!Shade=\!!lShade
  \let\!!!Shade=\!!!lShade}

% Command to set histogram mode
% See Subsection 4.3 of the manual.
\def\sethistograms{%
  \let\!drawcurve=\!hcurve}

% Commands to cycle through list of coordinates in piecewise quadratic 
% interpolation mode
\def\!qcurve #1 #2 {%
  \!start (#1,#2)
  \!Qjoin}
\def\!Qjoin#1 #2 #3 #4 {%
  \!qjoin (#1,#2) (#3,#4)             % \!qjoin  is defined in QUADRATIC
  \!ifnextchar/{\!finish}{\!Qjoin}}

% Commands to cycle through list of coordinates in piecewise linear 
% interpolation mode
\def\!lcurve #1 #2 {%
  \!start (#1,#2)
  \!Ljoin}
\def\!Ljoin#1 #2 {%
  \!ljoin (#1,#2)                    % \!ljoin  is defined in LINEAR
  \!ifnextchar/{\!finish}{\!Ljoin}}

\def\!finish/{\ignorespaces}

% Command to cycle through list of coordinates in histogram mode
\def\!hcurve #1 #2 {%
  \edef\!hxS{#1}%
  \edef\!hyS{#2}%
  \!hjoin}
\def\!hjoin#1 #2 {%
  \putrectangle corners at {\!hxS} {\!hyS} and {#1} {#2}
  \edef\!hxS{#1}%
  \!ifnextchar/{\!finish}{\!hjoin}}


% \vshade: See Subsection 7.3 of the manual.
\def\vshade #1 #2 #3 {%
  \!startvshade (#1,#2,#3)
  \!Shadewhat}

% \hshade: See Subsection 7.4 of the manual.
\def\hshade #1 #2 #3 {%
  \!starthshade (#1,#2,#3)
  \!Shadewhat}

% Commands to cycle through coordinates and optional "edge effect"
% fields while shading.
\def\!Shadewhat{%
  \futurelet\!nextchar\!Shade}
\def\!Shade{%
  \if <\!nextchar
    \def\!nextShade{\!!Shade}%
  \else
    \if /\!nextchar
      \def\!nextShade{\!finish}%
    \else
      \def\!nextShade{\!!!Shade}%
    \fi
  \fi
  \!nextShade}
\def\!!lShade<#1> #2 #3 #4 {%
  \!lshade <#1> (#2,#3,#4)                 % \!lshade is defined in SHADING
  \!Shadewhat}
\def\!!!lShade#1 #2 #3 {%
  \!lshade (#1,#2,#3)
  \!Shadewhat} 
\def\!!qShade<#1> #2 #3 #4 #5 #6 #7 {%
  \!qshade <#1> (#2,#3,#4) (#5,#6,#7)      % \!qshade is defined in SHADING
  \!Shadewhat}
\def\!!!qShade#1 #2 #3 #4 #5 #6 {%
  \!qshade (#1,#2,#3) (#4,#5,#6)
  \!Shadewhat} 

% ** Set default interpolation mode
\setlinear


%  ********************************************
%  *** DASHPATTERNS (Sets up dash patterns) ***
%  ********************************************

%  **  User commands:
%  **    \setdashpattern <DIMEN1,DIMEN2,DIMEN3,...>
%  **    \setdots <INTRADOT_DISTANCE>
%  **    \setdotsnear <INTRADOT_DISTANCE> for <ARC LENGTH>
%  **    \setdashes <DASH/SKIP_DISTANCE>
%  **    \setdashesnear <DASH/SKIP_DISTANCE> for <ARC LENGTH>
%  **    \setsolid
%  **    \findlength {CURVE CMDS}
 
%  **  Internal commands:
%  **    \!dashingon
%  **    \!dashingoff
 
%  **  Dash patterns are specified by a balanced token list whose complete
%  **    expansion has the form: DIMEN1,DIMEN2,DIMEN3,DIMEN4,... ; this produces
%  **    an arc of length DIMEN1, a skip of length DIMEN2, an arc of length
%  **    DIMEN3, a skip of length DIMEN4, ... .  Any number of DIMEN values may
%  **    be given. The pattern is repeated as many times (perhaps fractional)
%  **    as necessary to draw the curve. 
%  **  A dash pattern remains in effect until it is overridden by a call to
%  **    \setdashpattern, or to \setdots, \setdotsnear ... , \setdashes, 
%  **    \setdashesnear ... , or \setsolid.
%  **  Solid lines are the default.
 
 
%  **  \def\setdashpattern <DIMEN1,DIMEN2,DIMEN3,...>
%  **  The following routine converts a balanced list of tokens whose
%  **  complete expansion has the form  DIMEN1,DIMEN2, ... , DIMENk  into 
%  **  three list macros that are used in drawing dashed rules and curves:
%  **    !Flist:   \!Rule{DIMEN1}\!Skip{DIMEN2}\!Rule{DIMEN3}\!Skip{DIMEN4} ...
%  **    !Blist:   ...\!Skip{DIMEN4}\!Rule{DIMEN3}\!Skip{DIMEN2}\!Rule{DIMEN1}
%  **    !UDlist:  \\{DIMEN1}\\{DIMEN2}\\{DIMEN3}\\{DIMEN4} ...;
%  **  calculates \!leaderlength := DIMEN1 + ... + DIMENk; and
%  **  sets the curve drawing routines to dash mode.
%  **  Those lists are used by the curve drawing routines.
%  **  Dimenj ... may be given as an explicit dimension (e.g., 5pt), or
%  **  as an expression involving a dimension register (e.g., -2.5\dimen0).
%  **  See Subsection 6.2 of the manual
\def\setdashpattern <#1>{%
  \def\!Flist{}\def\!Blist{}\def\!UDlist{}%
  \!countA=0
  \!ecfor\!item:=#1\do{%
    \!dimenA=\!item\relax
    \expandafter\!rightappend\the\!dimenA\withCS{\\}\to\!UDlist%
    \advance\!countA  1
    \ifodd\!countA
      \expandafter\!rightappend\the\!dimenA\withCS{\!Rule}\to\!Flist%
      \expandafter\!leftappend\the\!dimenA\withCS{\!Rule}\to\!Blist%
    \else 
      \expandafter\!rightappend\the\!dimenA\withCS{\!Skip}\to\!Flist%
      \expandafter\!leftappend\the\!dimenA\withCS{\!Skip}\to\!Blist%
    \fi}%
  \!leaderlength=\!zpt
  \def\!Rule##1{\advance\!leaderlength  ##1}%
  \def\!Skip##1{\advance\!leaderlength  ##1}%
  \!Flist%
  \ifdim\!leaderlength>\!zpt 
  \else
    \def\!Flist{\!Skip{24in}}\def\!Blist{\!Skip{24in}}\ignorespaces
    \def\!UDlist{\\{\!zpt}\\{24in}}\ignorespaces
    \!leaderlength=24in
  \fi
  \!dashingon}   
 
 
%  **  \!dashingon  -- puts the curve drawing routines into dash mode
%  **  \!dashingoff -- puts the curve drawing routines into solid mode
%  **  These are internal commands, invoked by \setdashpattern and \setsolid
\def\!dashingon{%
  \def\!advancedashing{\!!advancedashing}%
  \def\!drawlinearsegment{\!lineardashed}%
  \def\!puthline{\!putdashedhline}%
  \def\!putvline{\!putdashedvline}%
%  \def\!putsline{\!putdashedsline}%
  \ignorespaces}% 
\def\!dashingoff{%
  \def\!advancedashing{\relax}%
  \def\!drawlinearsegment{\!linearsolid}%
  \def\!puthline{\!putsolidhline}%
  \def\!putvline{\!putsolidvline}%
%  \def\!putsline{\!putsolidsline}%
  \ignorespaces}
 
 
%  **  \setdots <LENGTH>  --  sets up a dot/skip pattern where dot (actually
%  **    the current plotsymbol) is plunked down once for every LENGTH 
%  **    traveled along the curve.  LENGTH defaults to 5pt.
%  **    See Subsection 6.1 of the manual.
\def\setdots{%
  \!ifnextchar<{\!setdots}{\!setdots<5pt>}}
\def\!setdots<#1>{%
  \!dimenB=#1\advance\!dimenB -\plotsymbolspacing
  \ifdim\!dimenB<\!zpt
    \!dimenB=\!zpt
  \fi
\setdashpattern <\plotsymbolspacing,\!dimenB>}
 
% ** \setdotsnear <LENGTH> for <ARC LENGTH>
% ** sets up a dot pattern where the dots are approximately LENGTH apart,
% ** the total length of the pattern is ARC LENGTH, and the pattern
% ** begins and ends with a dot. See Subsection 6.3 of the manual.
\def\setdotsnear <#1> for <#2>{%
  \!dimenB=#2\relax  \advance\!dimenB -.05pt  
  \!dimenC=#1\relax  \!countA=\!dimenC 
  \!dimenD=\!dimenB  \advance\!dimenD .5\!dimenC  \!countB=\!dimenD
  \divide \!countB  \!countA
  \ifnum 1>\!countB 
    \!countB=1
  \fi
  \divide\!dimenB  \!countB
  \setdots <\!dimenB>}
 
%  **  \setdashes <LENGTH>  --  sets up a dash/skip pattern where the dash
%  **    and the skip are each of length LENGTH (the dash is formed by
%  **    plunking down the current plotsymbol over an arc of length LENGTH
%  **    and so may actually be longer than LENGTH.  LENGTH defaults to 5pt.
%  **    See Subsection 6.1 of the manual.
\def\setdashes{%
  \!ifnextchar<{\!setdashes}{\!setdashes<5pt>}}
\def\!setdashes<#1>{\setdashpattern <#1,#1>}
 
% ** \setdashesnear ...
% ** Like \setdotsnear; the pattern begins and ends with a dash.
% ** See Subsection 6.3 of the manual.
\def\setdashesnear <#1> for <#2>{%
  \!dimenB=#2\relax  
  \!dimenC=#1\relax  \!countA=\!dimenC 
  \!dimenD=\!dimenB  \advance\!dimenD .5\!dimenC  \!countB=\!dimenD
  \divide \!countB  \!countA
  \ifodd \!countB 
  \else 
    \advance \!countB  1
  \fi
  \divide\!dimenB  \!countB
  \setdashes <\!dimenB>}
 
%  **  \setsolid  --  puts the curve drawing routines in "solid line" mode,
%  **    the default mode.  See Subsection 6.1 of the manual.
\def\setsolid{%
  \def\!Flist{\!Rule{24in}}\def\!Blist{\!Rule{24in}}%  
  \def\!UDlist{\\{24in}\\{\!zpt}}%
  \!dashingoff}  
\setsolid

%  **  \findlength {CURVE CMDS}
%  **  PiCTeX executes the \start, \ljoin, and \qjoin cmds comprising
%  **  CURVE CMDS without plotting anything, but stashes the length
%  **  of the phantom curve away in \totalarclength.
%  **  See Subsection 6.3 of the manual.
\def\findlength#1{%
  \begingroup
    \setdashpattern <0pt, \maxdimen>
    \setplotsymbol ({})  
    \dontsavelinesandcurves
    #1%
  \endgroup
  \ignorespaces}


% *************************************************************
% *** DIVISION  (Does long division of dimension registers) ***
% *************************************************************
 
% ** User command:
% **   \Divide {DIVIDEND} by {DIVISOR} forming {RESULT}
  
% ** Internal command
% **   \!divide{DIVIDEND}{DIVISOR}{RESULT}
 
% **  \!divide DIVIDEND [by] DIVISOR [to get] ANSWER
% **  Divides the dimension DIVIDEND by the dimension DIVISOR, placing the 
% **  quotient in the dimension register ANSWER.  Values are understood to 
% **  be in points.  E.g.  12.5pt/1.4pt=8.92857pt.
% **  Quotient is accurate to 1/65536pt=2**[-16]pt
% **  |DIVISOR| should be < 2048pt (about 28 inches).
\def\!divide#1#2#3{%
  \!dimenB=#1%                      **  dimB  holds current remainder (r)
  \!dimenC=#2%                      **  dimC  holds divisor (d)
  \!dimenD=\!dimenB%                **  dimD  holds quotient q=r/d for this 
  \divide \!dimenD \!dimenC%        **    step, in units of scaled pts
  \!dimenA=\!dimenD%                **  dimA  eventually holds answer (a)
  \multiply\!dimenD \!dimenC%       **  r <-- r - dq
  \advance\!dimenB -\!dimenD%       **  First step complete. Have integer part
%                                   **  of a, and corresponding remainder.
  \!dimenD=\!dimenC%                **  Temporarily use dimD to hold |d|
    \ifdim\!dimenD<\!zpt \!dimenD=-\!dimenD 
  \fi
  \ifdim\!dimenD<64pt%              **  Branch on the magnitude of |d|
    \!divstep[\!tfs]\!divstep[\!tfs]%
  \else 
    \!!divide
  \fi
  #3=\!dimenA\ignorespaces}

% **  The following code handles divisors  d  with 
% **    (1)  .88in =  64pt <= d <  256pt =  3.54in
% **    (2) 3.54in = 256pt <= d < 2048pt = 28.34in
% **  Anything bigger than that may result in an overflow condition.
% **  For our purposes, we should never even see case (2).
\def\!!divide{%
  \ifdim\!dimenD<256pt
    \!divstep[64]\!divstep[32]\!divstep[32]%
  \else 
    \!divstep[8]\!divstep[8]\!divstep[8]\!divstep[8]\!divstep[8]%
    \!dimenA=2\!dimenA
  \fi}
 
 
% **  The following macro does the real long division work.
\def\!divstep[#1]{%                 **  #1 = "B"
  \!dimenB=#1\!dimenB%              **  r <-- B*r
  \!dimenD=\!dimenB%                **  dimD  holds quotient q=r/d for this 
    \divide \!dimenD by \!dimenC%   **    step, in units of scaled pts
  \!dimenA=#1\!dimenA%              **  a <-- B*a + q
    \advance\!dimenA by \!dimenD%
  \multiply\!dimenD by \!dimenC%    **  r <-- r - dq
    \advance\!dimenB by -\!dimenD}
 
% **  \Divide:  See Subsection 9.3 of the manual.
\def\Divide <#1> by <#2> forming <#3> {%
  \!divide{#1}{#2}{#3}}


% *********************************************
% *** ELLIPSES (Draws ellipses and circles) ***
% *********************************************
 
% ** User commands
% **   \ellipticalarc  axes ratio A:B  DEGREES degrees from XSTART YSTART 
% **      center at XCENTER YCENTER 
% **   \circulararc DEGREES degrees from XSTART YSTART 
% **      center at XCENTER YCENTER 
 
% ** Internal command
% **   \!sinandcos{32*ANGLE in radians}{32*SIN}{32*COS}
 
 
% **   \ellipticalarc  axes ratio A:B  DEGREES degrees from XSTART YSTART 
% **      center at XCENTER YCENTER 
% **    Draws a elliptical arc starting at the coordinate point (XSTART,YSTART).
% **    The center of the ellipse of which the arc is a segment is at 
% **      (XCENTER,YCENTER).
% **    The arc extends through an angle of DEGREES degrees (may be + or -).
% **    A:B is the ratio of the length of the xaxis to the length of
% **      the yaxis of the ellipse
% **    Sqrt{[(XSTART-XCENTER)/A]**2 + [(YSTART-YCENTER)/B]**2}
% **      must be < 512pt (about 7in).
% **    Doesn't modify the dimensions (ht, dp, wd) of the PiCture under
% **      construction.
 
% ** \circulararc  --  See Subsection 5.3 of the manual.
\def\circulararc{%
  \ellipticalarc axes ratio 1:1 }

% ** \ellipticalarc  --  See Subsection 5.3 of the manual.
\def\ellipticalarc axes ratio #1:#2 #3 degrees from #4 #5 center at #6 #7 {%
  \!angle=#3pt\relax%                    ** get angle
  \ifdim\!angle>\!zpt 
    \def\!sign{}%                        ** counterclockwise
  \else 
    \def\!sign{-}\!angle=-\!angle%       ** clockwise
  \fi
  \!xxloc=\!M{#6}\!xunit%                ** convert CENTER to dimension
  \!yyloc=\!M{#7}\!yunit     
  \!xxS=\!M{#4}\!xunit%                  ** get STARTing point on rim of ellipse
  \!yyS=\!M{#5}\!yunit
  \advance\!xxS -\!xxloc%                ** make center of ellipse (0,0)
  \advance\!yyS -\!yyloc
  \!divide\!xxS{#1pt}\!xxS %             ** scale point on ellipse to point on 
  \!divide\!yyS{#2pt}\!yyS %                 corresponding circle
%
  \let\!MC=\!M%                          ** save current c/d mode
  \!setdimenmode%                        ** go into dimension mode
%
  \!xS=#1\!xxS  \advance\!xS\!xxloc
  \!yS=#2\!yyS  \advance\!yS\!yyloc
  \!start (\!xS,\!yS)%
  \!loop\ifdim\!angle>14.9999pt%         ** draw in major portion of ellipse 
    \!rotate(\!xxS,\!yyS)by(\!cos,\!sign\!sin)to(\!xxM,\!yyM) 
    \!rotate(\!xxM,\!yyM)by(\!cos,\!sign\!sin)to(\!xxE,\!yyE)
    \!xM=#1\!xxM  \advance\!xM\!xxloc  \!yM=#2\!yyM  \advance\!yM\!yyloc
    \!xE=#1\!xxE  \advance\!xE\!xxloc  \!yE=#2\!yyE  \advance\!yE\!yyloc
    \!qjoin (\!xM,\!yM) (\!xE,\!yE)
    \!xxS=\!xxE  \!yyS=\!yyE 
    \advance \!angle -15pt
  \repeat
  \ifdim\!angle>\!zpt%                   ** complete remaining arc, if any
    \!angle=100.53096\!angle%            ** convert angle to radians, divide
    \divide \!angle 360 %                **   by 2, and multiply by 32
    \!sinandcos\!angle\!!sin\!!cos%      ** get 32*sin & 32*cos
    \!rotate(\!xxS,\!yyS)by(\!!cos,\!sign\!!sin)to(\!xxM,\!yyM) 
    \!rotate(\!xxM,\!yyM)by(\!!cos,\!sign\!!sin)to(\!xxE,\!yyE)
    \!xM=#1\!xxM  \advance\!xM\!xxloc  \!yM=#2\!yyM  \advance\!yM\!yyloc
    \!xE=#1\!xxE  \advance\!xE\!xxloc  \!yE=#2\!yyE  \advance\!yE\!yyloc
    \!qjoin (\!xM,\!yM) (\!xE,\!yE)
  \fi
%
  \let\!M=\!MC%                          ** restore c/d mode
  \ignorespaces}%                        **   if appropriate
 
 
%  ** \!rotate(XREG,YREG)by(32cos,32sin)to(XXREG,YYREG)
%  ** rotates (XREG,YREG) by angle with specfied scaled cos & sin to
%  ** (XXREG,YYREG).  Uses \!dimenA & \!dimenB as scratch registers.
\def\!rotate(#1,#2)by(#3,#4)to(#5,#6){% 
  \!dimenA=#3#1\advance \!dimenA -#4#2%   ** Rcos(x+t)=Rcosx*cost - Rsinx*sint
  \!dimenB=#3#2\advance \!dimenB  #4#1%   ** Rsin(x+t)=Rsinx*cost + Rcosx*sint
  \divide \!dimenA 32  \divide \!dimenB 32 
  #5=\!dimenA  #6=\!dimenB
  \ignorespaces}
\def\!sin{4.17684}%                       ** 32*sin(pi/24) (pi/24=7.5deg)
\def\!cos{31.72624}%                      ** 32*cos(pi/24)
 
 
%  ** \!sinandcos{32*ANGLE in radians}{\SINCS}{\COSCS}
%  **   Computes the 32*sine and 32*cosine of a small ANGLE expressed in 
%  **   radians/32 and puts these values in the replacement texts of 
%  **   \SINCS and \COSCS
\def\!sinandcos#1#2#3{%
 \!dimenD=#1%                **  angle is expressed in radians/32: 1pt = 1/32rad
 \!dimenA=\!dimenD%          **  dimA will eventually contain 32sin(angle)in pts
 \!dimenB=32pt%              **  dimB will eventually contain 32cos(angle)in pts
 \!removept\!dimenD\!value%  **  get value of 32*angle, without "pt"
 \!dimenC=\!dimenD%          **  holds 32*angle**i/i! in pts
 \!dimenC=\!value\!dimenC \divide\!dimenC by 64 %   ** now 32*angle**2/2
 \advance\!dimenB by -\!dimenC%                     ** 32-32*angle**2/2
 \!dimenC=\!value\!dimenC \divide\!dimenC by 96 %   ** now 32*angle**3/3!
 \advance\!dimenA by -\!dimenC%                     ** now 32*(angle-angle**3/6)
 \!dimenC=\!value\!dimenC \divide\!dimenC by 128 %  ** now 32*angle**4/4!
 \advance\!dimenB by \!dimenC%
 \!removept\!dimenA#2%                              ** set 32*sin(angle)
 \!removept\!dimenB#3%                              ** set 32*cos(angle)
 \ignorespaces}


% *****************************************************************
% ***  RULES  (Draws rules, i.e., horizontal & vertical lines)  ***
% *****************************************************************

% **  User command:
% **    \putrule [<XDIMEN,YDIMEN>] from  XCOORD1 YCOORD1 
% **      to  XCOORD2 YCOORD2 

% **  Internal commands:
% **    \!puthline [<XDIMEN,YDIMEN>]    (h = horizontal)
% **      Set by dashpat to either: \!putsolidhline  or \!putdashedhline
% **    \!putvline [<XDIMEN,YDIMEN>]    (v = vertical)
% **      Either:  \!putsolidvline  or  \!putdashedvline


% **  \putrule [<XDIMEN,YDIMEN>] from XCOORD1 YCOORD1
% **    to XCOORD2 YCOORD2
% **  Draws a rule -- dashed or solid depending on the current dash pattern --
% **    from (X1,Y1) to (X2,Y2).  Uses TEK's  \hrule & \vrule & \leaders  
% **    constructions to handle horizontal & vertical lines efficiently both
% **    in terms of execution time and space in the DVI file.  
% **  See Subsection 4.1 of the manual.
\def\putrule#1from #2 #3 to #4 #5 {%
  \!xloc=\!M{#2}\!xunit  \!xxloc=\!M{#4}\!xunit%   
  \!yloc=\!M{#3}\!yunit  \!yyloc=\!M{#5}\!yunit%           
  \!dxpos=\!xxloc  \advance\!dxpos by -\!xloc
  \!dypos=\!yyloc  \advance\!dypos by -\!yloc
%
  \ifdim\!dypos=\!zpt
    \def\!!Line{\!puthline{#1}}\ignorespaces
  \else
    \ifdim\!dxpos=\!zpt
      \def\!!Line{\!putvline{#1}}\ignorespaces
    \else 
       \def\!!Line{}
    \fi
  \fi
  \let\!ML=\!M%           ** save current coord\dimen mode
  \!setdimenmode%         ** express locations in dimens
  \!!Line%
  \let\!M=\!ML%           ** restore previous c/d mode
  \ignorespaces}
 
 
% **  \!putsolidhline [<XDIMEN,YDIMEN>]
% **  Place horizontal solid line
\def\!putsolidhline#1{%
  \ifdim\!dxpos>\!zpt 
    \put{\!hline\!dxpos}#1[l] at {\!xloc} {\!yloc}
  \else 
    \put{\!hline{-\!dxpos}}#1[l] at {\!xxloc} {\!yyloc}
  \fi
  \ignorespaces}
 
% **  \!putsolidvline [shifted <XDIMEN,YDIMEN>]
% **  Place vertical solid line
\def\!putsolidvline#1{%
  \ifdim\!dypos>\!zpt 
    \put{\!vline\!dypos}#1[b] at {\!xloc} {\!yloc}
  \else 
    \put{\!vline{-\!dypos}}#1[b] at {\!xxloc} {\!yyloc}
  \fi
  \ignorespaces}
 
\def\!hline#1{\hbox to #1{\leaders \hrule height\linethickness\hfill}}
\def\!vline#1{\vbox to #1{\leaders \vrule width\linethickness\vfill}}
 
 
% **  \!putdashedhline [<XDIMEN,YDIMEN>]
% **  Place dashed horizontal line
\def\!putdashedhline#1{%
  \ifdim\!dxpos>\!zpt 
    \!DLsetup\!Flist\!dxpos
    \put{\hbox to \!totalleaderlength{\!hleaders}\!hpartialpattern\!Rtrunc}
      #1[l] at {\!xloc} {\!yloc} 
  \else 
    \!DLsetup\!Blist{-\!dxpos}
    \put{\!hpartialpattern\!Ltrunc\hbox to \!totalleaderlength{\!hleaders}}
      #1[r] at {\!xloc} {\!yloc} 
  \fi
  \ignorespaces}
 
% **  \!putdashedhline [<XDIMEN,YDIMEN>]
% **  Place dashed vertical line
\def\!putdashedvline#1{%
  \!dypos=-\!dypos%            ** vertical leaders go from top to bottom
  \ifdim\!dypos>\!zpt 
    \!DLsetup\!Flist\!dypos 
    \put{\vbox{\vbox to \!totalleaderlength{\!vleaders}
      \!vpartialpattern\!Rtrunc}}#1[t] at {\!xloc} {\!yloc} 
  \else 
    \!DLsetup\!Blist{-\!dypos}
    \put{\vbox{\!vpartialpattern\!Ltrunc
      \vbox to \!totalleaderlength{\!vleaders}}}#1[b] at {\!xloc} {\!yloc} 
  \fi
  \ignorespaces}
 

% **  The rest of the macros in this section are subroutines used by 
% **  \!putdashedhline and \!putdashedvline.
\def\!DLsetup#1#2{%            ** Dashed-Line set up
  \let\!RSlist=#1%             ** set !Rule-Skip list
  \!countB=#2%                 ** convert rule length to integer (number of sps)
  \!countA=\!leaderlength%     ** ditto, leaderlength
  \divide\!countB by \!countA% ** number of complete leader units
  \!totalleaderlength=\!countB\!leaderlength
  \!Rresiduallength=#2%
  \advance \!Rresiduallength by -\!totalleaderlength%  \** excess length
  \!Lresiduallength=\!leaderlength
  \advance \!Lresiduallength by -\!Rresiduallength
  \ignorespaces}
 
\def\!hleaders{%
  \def\!Rule##1{\vrule height\linethickness width##1}%
  \def\!Skip##1{\hskip##1}%
  \leaders\hbox{\!RSlist}\hfill}
 
\def\!hpartialpattern#1{%
  \!dimenA=\!zpt \!dimenB=\!zpt 
  \def\!Rule##1{#1{##1}\vrule height\linethickness width\!dimenD}%
  \def\!Skip##1{#1{##1}\hskip\!dimenD}%
  \!RSlist}
 
\def\!vleaders{%
  \def\!Rule##1{\hrule width\linethickness height##1}%
  \def\!Skip##1{\vskip##1}%
  \leaders\vbox{\!RSlist}\vfill}
 
\def\!vpartialpattern#1{%
  \!dimenA=\!zpt \!dimenB=\!zpt 
  \def\!Rule##1{#1{##1}\hrule width\linethickness height\!dimenD}%
  \def\!Skip##1{#1{##1}\vskip\!dimenD}%
  \!RSlist}
 
\def\!Rtrunc#1{\!trunc{#1}>\!Rresiduallength}
\def\!Ltrunc#1{\!trunc{#1}<\!Lresiduallength}
 
\def\!trunc#1#2#3{%          
  \!dimenA=\!dimenB         
  \advance\!dimenB by #1%
  \!dimenD=\!dimenB  \ifdim\!dimenD#2#3\!dimenD=#3\fi
  \!dimenC=\!dimenA  \ifdim\!dimenC#2#3\!dimenC=#3\fi
  \advance \!dimenD by -\!dimenC}
 

%  ****************************************************************
%  ***  LINEAR ARC  (Draws straight lines -- solid and dashed)  ***
%  ****************************************************************
 
%  **  User commands
%  **    \inboundscheckoff
%  **    \inboundscheckon
   
%  **  Internal commands 
%  **    \!start (XCOORD,YCOORD)
%  **    \!ljoin (XCOORD,YCOORD)
%  **    \!drawlinearsegment  --  set by \dashpat to either
%  **      \!linearsolid  or  \!lineardashed
%  **    \!advancedashing     --  set by \dashpat to either
%  **       \relax  or  \!!advancedashing
%  **    \!plotifinbounds     --  set by \inboundscheck off/on to either
%  **       \!plot  or  \!!plotifinbounds
%  **    \!initinboundscheck  --  set by \inboundscheck off/on to either
%  **       \relax  or  \!!initinboundscheck
 
 
%  \plotsymbolspacing  ** distance between consecutive plot positions
%  \!xS                ** starting x
%  \!yS                ** starting y
%  \!xE                ** ending   x
%  \!yE                ** ending   y
%  \!xdiff             ** x_end - x_start
%  \!ydiff             ** y_end - y_start
%  \!distacross        ** how far along curve next point to be plotted is
%  \!arclength         ** approximate length of arc for current interval
%  \!downlength        ** remaining length for "pen" to be down    
%  \!uplength          ** length for "pen" to be down    
%  \!intervalno        ** counts segments to curve
%  \totalarclength     ** cumulative distance along curve
%  \!npoints           ** approximately  (arc length / plotsymbolspacing)
 
%  **  Calls -- \!Pythag, \!divide, \!plot
 
 
%  **  \!start (XCOORD,YCOORD)
%  **  Sets initial point for linearly (or quadratically) interpolated curve
\def\!start (#1,#2){%
  \!plotxorigin=\!xorigin  \advance \!plotxorigin by \!plotsymbolxshift
  \!plotyorigin=\!yorigin  \advance \!plotyorigin by \!plotsymbolyshift
  \!xS=\!M{#1}\!xunit \!yS=\!M{#2}\!yunit
  \!rotateaboutpivot\!xS\!yS
  \!copylist\!UDlist\to\!!UDlist% **\!UDlist has the form \\{dimen1}\\{dimen2}..
%                                 ** Routine will draw dashed line with pen
%                                 ** down for dimen1, up for dimen2, ...
  \!getnextvalueof\!downlength\from\!!UDlist
  \!distacross=\!zpt%             ** 1st point goes at start of curve
  \!intervalno=0 %                ** initialize interval counter
  \global\totalarclength=\!zpt%   ** initialize distance traveled along curve
  \ignorespaces}
 

%  **  \!ljoin (XCOORD,YCOORD) 
%  **  Draws a straight line starting at the last point specified
%  **    by the most recent \!start, \!ljoin, or \!qjoin, and
%  **    ending at (XCOORD,YCOORD).
\def\!ljoin (#1,#2){%
  \advance\!intervalno by 1
  \!xE=\!M{#1}\!xunit \!yE=\!M{#2}\!yunit
  \!rotateaboutpivot\!xE\!yE
  \!xdiff=\!xE \advance \!xdiff by -\!xS%**  xdiff = xE - xS
  \!ydiff=\!yE \advance \!ydiff by -\!yS%**  ydiff = yE - yS
  \!Pythag\!xdiff\!ydiff\!arclength%     **  arclength = sqrt(xdiff**2+ydiff**2) 
  \global\advance \totalarclength by \!arclength%
  \!drawlinearsegment%   ** set by dashpat to \!linearsolid or \!lineardashed
  \!xS=\!xE \!yS=\!yE%   ** shift ending points to starting points
  \ignorespaces}
 
 
% **  The following routine is used to draw a "solid" line between (xS,yS)
% **  and (xE,yE).  Points are spaced nearly every  \plotsymbolspacing length
% **  along the line.  
\def\!linearsolid{%
  \!npoints=\!arclength
  \!countA=\plotsymbolspacing
  \divide\!npoints by \!countA%      ** now #pts =. arclength/plotsymbolspacing
  \ifnum \!npoints<1 
    \!npoints=1 
  \fi
  \divide\!xdiff by \!npoints
  \divide\!ydiff by \!npoints
  \!xpos=\!xS \!ypos=\!yS
%
  \loop\ifnum\!npoints>-1
    \!plotifinbounds
    \advance \!xpos by \!xdiff
    \advance \!ypos by \!ydiff
    \advance \!npoints by -1
  \repeat
  \ignorespaces}
 
 
% ** The following routine is used to draw a dashed line between (xS,yS)
% ** and (xE,yE). The dash pattern continues from the previous segment.
\def\!lineardashed{%
% **
  \ifdim\!distacross>\!arclength
    \advance \!distacross by -\!arclength  %nothing to plot in this interval
%
  \else
%
    \loop\ifdim\!distacross<\!arclength
%     ** plot point, interpolating linearly in x and y
      \!divide\!distacross\!arclength\!dimenA%  ** dimA = across/arclength
      \!removept\!dimenA\!t%  ** \!t holds value in dimA, without the "pt"
      \!xpos=\!t\!xdiff \advance \!xpos by \!xS
      \!ypos=\!t\!ydiff \advance \!ypos by \!yS
      \!plotifinbounds
      \advance\!distacross by \plotsymbolspacing
      \!advancedashing
    \repeat  
%
    \advance \!distacross by -\!arclength%    ** prepare for next interval 
  \fi
  \ignorespaces}
 
 
\def\!!advancedashing{%
  \advance\!downlength by -\plotsymbolspacing
  \ifdim \!downlength>\!zpt
  \else
    \advance\!distacross by \!downlength
    \!getnextvalueof\!uplength\from\!!UDlist
    \advance\!distacross by \!uplength
    \!getnextvalueof\!downlength\from\!!UDlist
  \fi}
 
 
% ** \inboundscheckoff & \inboundscheckon: See Subsection 5.5 of the manual.
\def\inboundscheckoff{%
  \def\!plotifinbounds{\!plot(\!xpos,\!ypos)}%
  \def\!initinboundscheck{\relax}\ignorespaces}
\def\inboundscheckon{%
  \def\!plotifinbounds{\!!plotifinbounds}%
  \def\!initinboundscheck{\!!initinboundscheck}%
  \!initinboundscheck\ignorespaces} 
\inboundscheckoff
 
% ** The following code plots the current point only if it falls in the
% ** current plotarea.  It doesn't matter if the coordinate system has
% ** changed since the plotarea was set up.  However, shifts of the plot
% ** are ignored (how the plotsymbol stands relative to its plot position is
% ** unknown anyway).
\def\!!plotifinbounds{%
  \ifdim \!xpos<\!checkleft
  \else
    \ifdim \!xpos>\!checkright
    \else
      \ifdim \!ypos<\!checkbot
      \else
         \ifdim \!ypos>\!checktop
         \else
           \!plot(\!xpos,\!ypos)
         \fi 
      \fi
    \fi
  \fi}
 
 
\def\!!initinboundscheck{%
  \!checkleft=\!arealloc     \advance\!checkleft by \!xorigin
  \!checkright=\!arearloc    \advance\!checkright by \!xorigin
  \!checkbot=\!areabloc      \advance\!checkbot by \!yorigin
  \!checktop=\!areatloc      \advance\!checktop by \!yorigin}
 

% *********************************
% *** LOGTEN  (Log_10 function) ***
% *********************************
%
% ** \!logten{X}
% ** Calculates log_10 of X.  X and LOG10(X) are in fixed point notation.
% **  X must be positive; it may have an optional `+' sign; any number
% **  of digits may be specified for X.  The absolute error in LOG10(X) is
% **  less than .0001 (probably < .00006).  That's about as good as you
% **  hope for, since TEX only operates to 5 figures after the decimal
% **  point anyway.

%  \!rootten=3.162278pt       **** These are values are set in ALLOCATIONS
%  \!tenAe=2.543275pt  (=A5)
%  \!tenAc=2.773839pt  (=A3)
%  \!tenAa=8.690286pt  (=A1)

\def\!logten#1#2{%
  \expandafter\!!logten#1\!nil
  \!removept\!dimenF#2%
  \ignorespaces}

\def\!!logten#1#2\!nil{%
  \if -#1%
    \!dimenF=\!zpt
    \def\!next{\ignorespaces}%
  \else
    \if +#1%
      \def\!next{\!!logten#2\!nil}%
    \else
      \if .#1%
        \def\!next{\!!logten0.#2\!nil}%
      \else
        \def\!next{\!!!logten#1#2..\!nil}%
      \fi
    \fi
  \fi
  \!next}

\def\!!!logten#1#2.#3.#4\!nil{%
  \!dimenF=1pt %                 ** DimF holds log10 original argument
  \if 0#1%                      
    \!!logshift#3pt %            ** Argument < 1
  \else %                        ** Argument >= 1
    \!logshift#2/%               ** Shift decimal pt as many places
    \!dimenE=#1.#2#3pt %         **   as there are figures in #2
  \fi %                          ** Now dimE holds revised X want log10 of
  \ifdim \!dimenE<\!rootten%          ** Transform X to XX between sqrt(10) 
    \multiply \!dimenE 10 %           **   and 10*sqrt(10)
    \advance  \!dimenF -1pt
  \fi
  \!dimenG=\!dimenE%                  ** dimG <- (XX + 10)
    \advance\!dimenG 10pt
  \advance\!dimenE -10pt %            ** dimE <- (XX - 10)
  \multiply\!dimenE 10 %              ** dimE = 10*(XX-10)
  \!divide\!dimenE\!dimenG\!dimenE%   ** Now dimE=10t==10*(XX-10)/(XX+10)
  \!removept\!dimenE\!t%              ** !t=10t, with "pt" removed
  \!dimenG=\!t\!dimenE%               ** dimG=100t**2
  \!removept\!dimenG\!tt%             ** !tt=100t**2, with "pt" removed
  \!dimenH=\!tt\!tenAe%               ** dimH=10*a5*(10t)**2 /100
    \divide\!dimenH 100
  \advance\!dimenH \!tenAc%           ** ditto + 10*a3
  \!dimenH=\!tt\!dimenH%              ** ditto * (10t)**2 /100
    \divide\!dimenH 100   
  \advance\!dimenH \!tenAa%           ** ditto + 10*a1
  \!dimenH=\!t\!dimenH%               ** ditto * 10t / 100
    \divide\!dimenH 100 %             ** Now dimH = log10(XX) - 1
  \advance\!dimenF \!dimenH}%         ** dimF = log10(X)

\def\!logshift#1{%
  \if #1/%
    \def\!next{\ignorespaces}%
  \else
    \advance\!dimenF 1pt 
    \def\!next{\!logshift}%
  \fi 
  \!next}
 
 \def\!!logshift#1{%
   \advance\!dimenF -1pt
   \if 0#1%
     \def\!next{\!!logshift}%
   \else
     \if p#1%
       \!dimenF=1pt
       \def\!next{\!dimenE=1p}%
     \else
       \def\!next{\!dimenE=#1.}%
     \fi
   \fi
   \!next}


% ***********************************************************
% *** PICTURES (Basic setups for PiCtures; \put commands) ***
% ***********************************************************
 
% **  User Commands:
% **    \beginpicture
% **    \endpicture    
% **    \endpicturesave <XREG,YREG>
% **    \setcoordinatesystem units <XUNIT,YUNIT> point at XREF YREF
% **    \put {OBJECT} [ORIENTATION] <XSHIFT,YSHIFT> at XCOORD YCOORD
% **    \multiput {OJBECT} [ORIENTATION] <XSHIFT,YSHIFT>) at
% **      XCOORD YCOORD
% **      *NUMBER_OF_TIMES DXCOORD DYCOORD  /
% **    \accountingon
% **    \accountingoff
% **    \stack [ORIENTATION] <LEADING> {LIST OF ITEMS}
% **    \lines [ORIENTATION] {LINES}
% **    \Lines [ORIENTATION] {LINES}
% **    \setdimensionmode
% **    \setcoordinatemode
% **    \Xdistance
% **    \Ydistance
  
% **  Internal commands:
% **    \!setputobject{OBJECT}{[ORIENTATION]<XSHIFT,YSHIFT>}
% **    \!dimenput{OBJECT}[ORIENTATION]<XSHIFT,YSHIFT>(XDIMEN,YDIMEN)
% **    \!setdimenmode
% **    \!setcoordmode
% **    \!ifdimenmode
% **    \!ifcoordmode
  
 
% **  \beginpicture
% **  \endpicture
% **  \endpicturesave <XREG,YREG>
% **    \beginpicture ... \endpicture  creates an hbox.  Objects are
% **    placed in this box using the \put command and the like (see below).
% **    The location of an object is specified in terms of coordinate system(s)
% **    established by \setcoordinatesystem.  Each coordinate system (there
% **    might be just one) specifies the length of 1 horizontal unit, the length
% **    of 1 vertical unit, and the coordinates of a "reference point".  The
% **    reference points of various coordinate systems will be in the same
% **    physical location.  The macros keep track of the size of the objects
% **    and their locations. The resulting hbox is the smallest hbox which
% **    encloses all the objects, and whose TEK reference point is the point
% **    on the left edge of the box closest vertically to the PICTEX reference
% **    point. Using \endpicturesave, you can (globally) save the distance TEK's
% **    reference point is to the right (respectively, up from) PICTEX's 
% **    reference point in the dimension register \XREG (respectively \YREG). 
% **    You can then \put the picture OBJECT into a larger picture so that its
% **    reference point is at (XCOORD,YCOORD) with the command
% **      \put {picture OBJECT} [Bl] <\XREG, \YREG> at  XCOORD YCOORD 

% **  \beginpicture : See Subsection 1.1 of the manual.
\def\beginpicture{%
  \setbox\!picbox=\hbox\bgroup%
  \!xleft=\maxdimen  
  \!xright=-\maxdimen
  \!ybot=\maxdimen
  \!ytop=-\maxdimen}
 
% **  \endpicture : See Subsection 1.1 of the manual.
\def\endpicture{%
  \ifdim\!xleft=\maxdimen%  ** check if nothing was put in picbox
    \!xleft=\!zpt \!xright=\!zpt \!ybot=\!zpt \!ytop=\!zpt 
  \fi
  \global\!Xleft=\!xleft \global\!Xright=\!xright
  \global\!Ybot=\!ybot \global\!Ytop=\!ytop
  \egroup%
  \ht\!picbox=\!Ytop  \dp\!picbox=-\!Ybot
  \ifdim\!Ybot>\!zpt
  \else 
    \ifdim\!Ytop<\!zpt
      \!Ybot=\!Ytop
    \else
      \!Ybot=\!zpt
    \fi
  \fi
  \hbox{\kern-\!Xleft\lower\!Ybot\box\!picbox\kern\!Xright}}
 
% **  \endpicturesave : See Subsection 8.4 of the manual.
\def\endpicturesave <#1,#2>{%
  \endpicture \global #1=\!Xleft \global #2=\!Ybot \ignorespaces}
 
 
% **   \setcoordinatesystem units <XUNIT,YUNIT> 
% **     point at XREF YREF  
% **   Each of `units <XUNIT,YUNIT>' and `point at XREF YREF' 
% **     are optional.
% **   Unit lengths must be given in dimensions (e.g., <10pt,1in>).
% **     Default unit lengths are 1pt, 1pt, or previous unit lengths.
% **   Reference point is specified in current units (e.g., 3 5 ). 
% **     Default reference point is 0 0 , or previous reference point.
% **   Unit lengths and reference points obey TEX's scoping rules.
% **   See Subsection 1.2 of the manual.
\def\setcoordinatesystem{%
  \!ifnextchar{u}{\!getlengths }
    {\!getlengths units <\!xunit,\!yunit>}}
\def\!getlengths units <#1,#2>{%
  \!xunit=#1\relax
  \!yunit=#2\relax
  \!ifcoordmode 
    \let\!SCnext=\!SCccheckforRP
  \else
    \let\!SCnext=\!SCdcheckforRP
  \fi
  \!SCnext}
\def\!SCccheckforRP{%
  \!ifnextchar{p}{\!cgetreference }
    {\!cgetreference point at {\!xref} {\!yref} }}
\def\!cgetreference point at #1 #2 {%
  \edef\!xref{#1}\edef\!yref{#2}%
  \!xorigin=\!xref\!xunit  \!yorigin=\!yref\!yunit  
  \!initinboundscheck % ** See linear.tex
  \ignorespaces}
\def\!SCdcheckforRP{%
  \!ifnextchar{p}{\!dgetreference}%
    {\ignorespaces}}
\def\!dgetreference point at #1 #2 {%
  \!xorigin=#1\relax  \!yorigin=#2\relax
  \ignorespaces}

 
%  ** \put {OBJECT} [XY] <XDIMEN,YDIMEN> at (XCOORD,YCOORD)
%  **   `[XY]' and `<XDIMEN,YDIMEN>' are optional.
%  **   First OBJECT is placed in an hbox (the "objectbox") and then a
%  **     "reference point" is assigned to the objectbox as follows:
%  **     [1] first, the reference point is taken to be the center of the box;
%  **     [2] next, centering is overridden by the specifications
%  **           X=l -- reference point along the left edge of the objectbox
%  **           X=r -- reference point along the right edge of the objectbox
%  **           Y=b -- reference point along the bottom edge of the objectbox
%  **           Y=B -- reference point along the Baseline of the objectbox
%  **           Y=t -- reference point along the top edge of the objectbox;
%  **     [3] finally the reference point is shifted left by XDIMEN, down
%  **           by YDIMEN  (both default to 0pt).
%  **   The objectbox is placed within PICBOX with its reference point at  
%  **     (XCOORD,YCOORD). 
%  **   If OBJECT is a saved box, say  box0, you have to write
%  **     \put{\box0}...   or  \put{\copy0}...
%  **   The objectbox is void after the put.
%  **   See Subsection 2.1 of the manual.
\long\def\put#1#2 at #3 #4 {%
  \!setputobject{#1}{#2}%
  \!xpos=\!M{#3}\!xunit  \!ypos=\!M{#4}\!yunit  
  \!rotateaboutpivot\!xpos\!ypos%
  \advance\!xpos -\!xorigin  \advance\!xpos -\!xshift
  \advance\!ypos -\!yorigin  \advance\!ypos -\!yshift
  \kern\!xpos\raise\!ypos\box\!putobject\kern-\!xpos%
  \!doaccounting\ignorespaces}
 
%  **   \multiput etc.  Like  \put.  The objectbox is not voided until the
%  **     termininating /, and is placed repeatedly with:
%  **     XCOORD YCOORD -- the objectbox is put down with its reference point
%  **       at (XCOORD,YCOORD);
%  **     *N DXCOORD DYCOORD -- each of N times the current
%  **       (xcoord,ycoord) is incremented by (DXCOORD,DYCOORD), and the
%  **       objectbox is put down with its reference point at (xcoord,ycoord)
%  **       (This specification has to follow an XCOORD YCOORD pair)
%  **     See Subsection 2.2 of the manual.
\long\def\multiput #1#2 at {%
  \!setputobject{#1}{#2}%
  \!ifnextchar"{\!putfromfile}{\!multiput}}
\def\!putfromfile"#1"{%
  \expandafter\!multiput \input #1 /}
\def\!multiput{%
  \futurelet\!nextchar\!!multiput}
\def\!!multiput{%
  \if *\!nextchar
    \def\!nextput{\!alsoby}%
  \else
    \if /\!nextchar
      \def\!nextput{\!finishmultiput}%
    \else
      \def\!nextput{\!alsoat}%
    \fi
  \fi
  \!nextput}
\def\!finishmultiput/{%
  \setbox\!putobject=\hbox{}%
  \ignorespaces}
 
%  **   \!alsoat XCOORD YCOORD 
%  **     The objectbox is put down with reference point at XCOORD,YCOORD
\def\!alsoat#1 #2 {%
  \!xpos=\!M{#1}\!xunit  \!ypos=\!M{#2}\!yunit  
  \!rotateaboutpivot\!xpos\!ypos%
  \advance\!xpos -\!xorigin  \advance\!xpos -\!xshift
  \advance\!ypos -\!yorigin  \advance\!ypos -\!yshift
  \kern\!xpos\raise\!ypos\copy\!putobject\kern-\!xpos%
  \!doaccounting
  \!multiput}
 
% **   \!alsoby*N DXCOORD DYCOORD
% **     N times, the current (XCOORD,YCOORD) is advanced by (DXCOORD,DYCOORD),
% **     and the current (shifted, oriented) OBJECT is put down.
\def\!alsoby*#1 #2 #3 {%
  \!dxpos=\!M{#2}\!xunit \!dypos=\!M{#3}\!yunit 
  \!rotateonly\!dxpos\!dypos
  \!ntemp=#1%
  \!!loop\ifnum\!ntemp>0
    \advance\!xpos by \!dxpos  \advance\!ypos by \!dypos
    \kern\!xpos\raise\!ypos\copy\!putobject\kern-\!xpos%
    \advance\!ntemp by -1
  \repeat
  \!doaccounting 
  \!multiput}
 
% **  \accountingoff : Suspends PiCTeX's accounting of the aggregate
% **    size of the picture box.
% **  \accounting on : Reinstates accounting.
% **  See Subsection 8.2 of the manual.
\def\accountingon{\def\!doaccounting{\!!doaccounting}\ignorespaces}
\def\accountingoff{\def\!doaccounting{}\ignorespaces}
\accountingon
\def\!!doaccounting{%
  \!xtemp=\!xpos  
  \!ytemp=\!ypos
  \ifdim\!xtemp<\!xleft 
     \!xleft=\!xtemp 
  \fi
  \advance\!xtemp by  \!wd 
  \ifdim\!xright<\!xtemp 
    \!xright=\!xtemp
  \fi
  \advance\!ytemp by -\!dp
  \ifdim\!ytemp<\!ybot  
    \!ybot=\!ytemp
  \fi
  \advance\!ytemp by  \!dp
  \advance\!ytemp by  \!ht 
  \ifdim\!ytemp>\!ytop  
    \!ytop=\!ytemp  
  \fi}
 
\long\def\!setputobject#1#2{%
  \setbox\!putobject=\hbox{#1}%
  \!ht=\ht\!putobject  \!dp=\dp\!putobject  \!wd=\wd\!putobject
  \wd\!putobject=\!zpt
  \!xshift=.5\!wd   \!yshift=.5\!ht   \advance\!yshift by -.5\!dp
  \edef\!putorientation{#2}%
  \expandafter\!SPOreadA\!putorientation[]\!nil%
  \expandafter\!SPOreadB\!putorientation<\!zpt,\!zpt>\!nil\ignorespaces}
 
\def\!SPOreadA#1[#2]#3\!nil{\!etfor\!orientation:=#2\do\!SPOreviseshift}
 
\def\!SPOreadB#1<#2,#3>#4\!nil{\advance\!xshift by -#2\advance\!yshift by -#3}
 
\def\!SPOreviseshift{%
  \if l\!orientation 
    \!xshift=\!zpt
  \else 
    \if r\!orientation 
      \!xshift=\!wd
    \else 
      \if b\!orientation
        \!yshift=-\!dp
      \else 
        \if B\!orientation 
          \!yshift=\!zpt
        \else 
          \if t\!orientation 
            \!yshift=\!ht
          \fi 
        \fi
      \fi
    \fi
  \fi}
 
 
%  **  \!dimenput{OBJECT} <XDIMEN,YDIMEN> [XY] (XLOC,YLOC)
%  **    This is an internal put routine, similar to \put, except that
%  **    XLOC=distance right from reference point, YLOC=distance up from
%  **    reference point. XLOC and YLOC are dimensions, so this routine
%  **    is completely independent of the current coordinate system. 
%  **    This routine does NOT do ROTATIONS.
\long\def\!dimenput#1#2(#3,#4){%
  \!setputobject{#1}{#2}%
  \!xpos=#3\advance\!xpos by -\!xshift
  \!ypos=#4\advance\!ypos by -\!yshift
  \kern\!xpos\raise\!ypos\box\!putobject\kern-\!xpos%
  \!doaccounting\ignorespaces}
 
 
%  ** The following macros permit the picture drawing routines to be used 
%  ** either in the default "coordinate mode", or in "dimension mode".
%  **   In coordinate mode  \!M(1.5,\!xunit)    expands to  1.5\!xunit
%  **   In dimension  mode  \!M(1.5pt,\!xunit)  expands to  1.5pt
%  ** Dimension mode is useful in coding macros.
%  ** Any special purpose picture macro that sets dimension mode should 
%  ** reset coordinate mode before completion.
%  ** See Subsection 9.2 of the manual.
\def\!setdimenmode{%
  \let\!M=\!M!!\ignorespaces}
\def\!setcoordmode{%
  \let\!M=\!M!\ignorespaces}
\def\!ifcoordmode{%
  \ifx \!M \!M!}
\def\!ifdimenmode{%
  \ifx \!M \!M!!}
\def\!M!#1#2{#1#2} 
\def\!M!!#1#2{#1}
\!setcoordmode
\let\setdimensionmode=\!setdimenmode
\let\setcoordinatemode=\!setcoordmode

%  ** \Xdistance{XCOORD}, \Ydistance{YCOORD}  are the horizontal and
%  **   vertical distances from the origin (0,0) to the point
%  **   (XCOORD,YCOORD)  in the current coordinate system.
%  ** See Subsection 9.2 of the manual.
\def\Xdistance#1{%
  \!M{#1}\!xunit
  \ignorespaces}
\def\Ydistance#1{%
  \!M{#1}\!yunit
  \ignorespaces}

% ** The following macros -- \stack, \line, and \Lines -- are useful for
% **   annotating PiCtures. They can be used outside the \beginpicture ...
% **   \endpicture environment.

% ** \stack [POSITIONING] <LEADING> {VALUESLIST}
% ** Builds a vertical stack of the values in VALUESLIST. Values in
% ** VALUESLIST are separated by commas.  In the resulting stack, values are
% ** centered by default, and positioned flush left (right) if 
% ** POSITIONING = l (r).  Values are separated vertically by LEADING,
% ** which defaults to \stackleading.
% ** See Subsection 2.3 of the manual.
\def\stack{%
  \!ifnextchar[{\!stack}{\!stack[c]}}
\def\!stack[#1]{%
  \let\!lglue=\hfill \let\!rglue=\hfill
  \expandafter\let\csname !#1glue\endcsname=\relax
  \!ifnextchar<{\!!stack}{\!!stack<\stackleading>}}
\def\!!stack<#1>#2{%
  \vbox{\def\!valueslist{}\!ecfor\!value:=#2\do{%
    \expandafter\!rightappend\!value\withCS{\\}\to\!valueslist}%
    \!lop\!valueslist\to\!value
    \let\\=\cr\lineskiplimit=\maxdimen\lineskip=#1%
    \baselineskip=-1000pt\halign{\!lglue##\!rglue\cr \!value\!valueslist\cr}}%
  \ignorespaces}

% ** \lines [POSITIONING] {LINES}
% ** Builds a vertical array of the lines in LINES. Each line in LINES
% ** is terminated by a \cr.  In the resulting array, lines are
% ** centered by default, and positioned flush left (right) if 
% ** POSITIONING = l (r).  The lines in the array are subject to TeX's
% ** usual spacing rules: in particular the baselines are ordinarily an equal
% ** distance apart. The baseline of the array is the baseline of the
% ** the bottom line.
% ** See Subsection 2.3 of the manual.
\def\lines{%
  \!ifnextchar[{\!lines}{\!lines[c]}}
\def\!lines[#1]#2{%
  \let\!lglue=\hfill \let\!rglue=\hfill
  \expandafter\let\csname !#1glue\endcsname=\relax
  \vbox{\halign{\!lglue##\!rglue\cr #2\crcr}}%
  \ignorespaces}

% ** \Lines [POSITIONING] {LINES}
% ** Like \lines, but the baseline of the array is the baseline of the
% ** top line.  See Subsection 2.3 of the manual.
\def\Lines{%
  \!ifnextchar[{\!Lines}{\!Lines[c]}}
\def\!Lines[#1]#2{%
  \let\!lglue=\hfill \let\!rglue=\hfill
  \expandafter\let\csname !#1glue\endcsname=\relax
  \vtop{\halign{\!lglue##\!rglue\cr #2\crcr}}%
  \ignorespaces}


% *********************************************
% *** PLOTTING (Things to do with plotting) ***
% *********************************************
 
% **  User commands
% **    \setplotsymbol ({PLOTSYMBOL} [ORIENTATION] <XSHIFT,YSHIFT>)
% **    \savelinesandcurves on "FILE_NAME"
% **    \dontsavelinesandcurves
% **    \writesavefile {MESSAGE}
% **    \replot {FILE_NAME}
 
% **  Internal command
% **    \!plot(XDIMEN,YDIMEN)
 
% **  \setplotsymbol ({PLOTSYMBOL} [ ] < , >)
% **  Save PLOTSYMBOL away in an hbox for use with curve plotting routines
% **  See Subsection 5.2 of the manual.
\def\setplotsymbol(#1#2){%
  \!setputobject{#1}{#2}
  \setbox\!plotsymbol=\box\!putobject%
  \!plotsymbolxshift=\!xshift 
  \!plotsymbolyshift=\!yshift 
  \ignorespaces}
 
\setplotsymbol({\fiverm .})%       ** initialize plotsymbol
 
 
% **  \!plot is either \!!plot (when no lines and curves are being saved) or
% **                   \!!!plot (when   lines and curves are being saved)
 
% **  \!!plot(XDIMEN,YDIMEN)
% **  Places the current plotsymbol a horizontal distance=XDIMEN-xorigin 
% **    and a vertical distance=YDIMEN-yorigin from the current
% **    reference point.  
\def\!!plot(#1,#2){%
  \!dimenA=-\!plotxorigin \advance \!dimenA by #1%    ** over
  \!dimenB=-\!plotyorigin \advance \!dimenB by #2%    ** up
  \kern\!dimenA\raise\!dimenB\copy\!plotsymbol\kern-\!dimenA%
  \ignorespaces}
 
% **  \!!!plot(XDIMEN,YDIMEN)
% **  Like \!!plot, but also saves the plot location in units of 
% **    scaled point, on file `replotfile'
\def\!!!plot(#1,#2){%
  \!dimenA=-\!plotxorigin \advance \!dimenA by #1%    ** over
  \!dimenB=-\!plotyorigin \advance \!dimenB by #2%    ** up
  \kern\!dimenA\raise\!dimenB\copy\!plotsymbol\kern-\!dimenA%
  \!countE=\!dimenA
  \!countF=\!dimenB
  \immediate\write\!replotfile{\the\!countE,\the\!countF.}%
  \ignorespaces}


% ** \savelinesandcurves on "FILE_NAME"
% **   Switch to save locations used for plotting lines and curves
% **   (No advantage in saving locations for solid lines; however
% **   replotting curve locations speeds things up by a factor of about 4. 
% ** \dontsavelinesandcurves
% **   Terminates \savelinesandcurves. The default.
% ** See Subsection 5.6 of the manual.
\def\savelinesandcurves on "#1" {%
  \immediate\closeout\!replotfile
  \immediate\openout\!replotfile=#1%
  \let\!plot=\!!!plot}

\def\dontsavelinesandcurves {%
  \let\!plot=\!!plot}
\dontsavelinesandcurves

% ** \writesavefile {MESSAGE}
% ** The message is preceded by a "%", so that it won't interfere
% ** with replotting.
% ** See Subsection 5.6 of the manual.
{\catcode`\%=11\xdef\!Commentsignal{%}}
\def\writesavefile#1 {%
  \immediate\write\!replotfile{\!Commentsignal #1}%
  \ignorespaces}

% ** \replot "FILE_NAME"
% **   Replots the locations saved earlier under \savelinesandcurves
% **   on "FILE_NAME"
% ** See Subsection 5.6 of the manual.
\def\replot"#1" {%
  \expandafter\!replot\input #1 /}
\def\!replot#1,#2. {%
  \!dimenA=#1sp
  \kern\!dimenA\raise#2sp\copy\!plotsymbol\kern-\!dimenA
  \futurelet\!nextchar\!!replot}
\def\!!replot{%
  \if /\!nextchar 
    \def\!next{\!finish}%
  \else
    \def\!next{\!replot}%
  \fi
  \!next}
% **************************************************
% ***  PYTHAGORAS  (Euclidean distance function) ***
% **************************************************

% ** User command:
% **   \placehypotenuse for <dimension1> and <dimension2> in <register> 

% ** Internal command:
% **   \!Pythag{X}{Y}{Z}
% **     Input X,Y are dimensions, or dimension registers.
% **     Output Z == sqrt(X**2+Y**2) must be a dimension register.
% **     Assumes that |X|+|Y| < 2048pt (about 28in).
 
% ** Without loss of generality, suppose  x>0, y>0.  Put s = x+y,
% **   z = sqrt(x**2+y**2). Then  z = s*f,  where  f = sqrt(t**2 + (1-t)**2)
% **   = sqrt((1+tau**2)/2), where  t = x/s  and  tau = 2(t-1/2) .
 
% ** Uses the \!divide macro (which uses registers \!dimenA--\!dimenD.
% ** Uses the \!removept macro   (e.g., 123.45pt --> 123.45)
% ** Uses registers \!dimenE--\!dimenI.
\def\!Pythag#1#2#3{%
  \!dimenE=#1\relax                                     
  \ifdim\!dimenE<\!zpt 
    \!dimenE=-\!dimenE 
  \fi%                                            ** dimE = |x|
  \!dimenF=#2\relax
  \ifdim\!dimenF<\!zpt 
    \!dimenF=-\!dimenF 
  \fi%                                            ** dimF = |y|
  \advance \!dimenF by \!dimenE%                  ** dimF = s = |x|+|y|
  \ifdim\!dimenF=\!zpt 
    \!dimenG=\!zpt%                               ** dimG = z = sqrt(x**2+y**2)
  \else 
    \!divide{8\!dimenE}\!dimenF\!dimenE%          ** now dimE = 8t = (8|x|)/s
    \advance\!dimenE by -4pt%                     ** 8tau = (8t-4)*2
      \!dimenE=2\!dimenE%                         **   (tau = 2*t - 1)
    \!removept\!dimenE\!!t%                       ** 8tau, without "pt"
    \!dimenE=\!!t\!dimenE%                        ** (8tau)**2, in pts
    \advance\!dimenE by 64pt%                     ** u = [64 + (8tau)**2]/2
    \divide \!dimenE by 2%                        **   [u = (8f)**2]
    \!dimenH=7pt%                                 ** initial guess g at sqrt(u)
    \!!Pythag\!!Pythag\!!Pythag%                  ** 3 iterations give sqrt(u)
    \!removept\!dimenH\!!t%                       ** 8f=sqrt(u), without "pt"
    \!dimenG=\!!t\!dimenF%                        ** z = (8f)*s/8
    \divide\!dimenG by 8
  \fi
  #3=\!dimenG
  \ignorespaces}

\def\!!Pythag{%                                   ** Newton-Raphson for sqrt
  \!divide\!dimenE\!dimenH\!dimenI%               ** v = u/g
  \advance\!dimenH by \!dimenI%                   ** g <-- (g + u/g)/2
    \divide\!dimenH by 2}

% **  \placehypotenuse for <XI> and <ETA> in <ZETA>
% **  See Subsection 9.3 of the manual.
\def\placehypotenuse for <#1> and <#2> in <#3> {%
  \!Pythag{#1}{#2}{#3}}


% **********************************************
% *** QUADRATIC ARC  (Draws a quadratic arc) ***
% **********************************************
 
% **  Internal command
% **    \!qjoin (XCOORD1,YCOORD1) (XCOORD2,YCOORD2)
 
% **  \!qjoin (XCOORD1,YCOORD1) (XCOORD2,YCOORD2)
% **  Draws an arc starting at the (last) point specified by the most recent
% **  \!qjoin, or \!ljoin, or \!start  and passing through (X_1,Y_1), (X_2,Y_2).
% **  Uses quadratic interpolation in both  x  and  y:  
% **    x(t), 0 <= t <= 1, interpolates  x_0, x_1, x_2  at  t=0, .5, 1
% **    y(t), 0 <= t <= 1, interpolates  y_0, y_1, y_2  at  t=0, .5, 1
 
\def\!qjoin (#1,#2) (#3,#4){%
  \advance\!intervalno by 1
  \!ifcoordmode
    \edef\!xmidpt{#1}\edef\!ymidpt{#2}%
  \else
    \!dimenA=#1\relax \edef\!xmidpt{\the\!dimenA}%
    \!dimenA=#2\relax \edef\!ymidpt{\the\!dimenA}%
  \fi
  \!xM=\!M{#1}\!xunit  \!yM=\!M{#2}\!yunit   \!rotateaboutpivot\!xM\!yM
  \!xE=\!M{#3}\!xunit  \!yE=\!M{#4}\!yunit   \!rotateaboutpivot\!xE\!yE
%
% ** Find coefficients for x(t)=a_x + b_x*t + c_x*t**2
  \!dimenA=\!xM  \advance \!dimenA by -\!xS%   ** dimA = I = xM - xS
  \!dimenB=\!xE  \advance \!dimenB by -\!xM%   ** dimB = II = xE-xM
  \!xB=3\!dimenA \advance \!xB by -\!dimenB%   ** b=3I-II
  \!xC=2\!dimenB \advance \!xC by -2\!dimenA%  ** c=2(II-I)
%
% ** Find coefficients for y(t)=y_x + b_y*t + c_y*t**2
  \!dimenA=\!yM  \advance \!dimenA by -\!yS%   
  \!dimenB=\!yE  \advance \!dimenB by -\!yM%  
  \!yB=3\!dimenA \advance \!yB by -\!dimenB%  
  \!yC=2\!dimenB \advance \!yC by -2\!dimenA% 
%
% ** Use Simpson's rule to calculate arc length over [0,1/2]:
% **   arc length = 1/2[1/6 f(0) + 4/6 f(1/4) + 1/6 f(1/2)]
% ** with f(t) = sqrt(x'(t)**2 + y'(t)**2).
  \!xprime=\!xB  \!yprime=\!yB%          ** x'(t) = b + 2ct
  \!dxprime=.5\!xC  \!dyprime=.5\!yC%    ** dt=1/4 ==> dx'(t) = c/2
  \!getf \!midarclength=\!dimenA
  \!getf \advance \!midarclength by 4\!dimenA
  \!getf \advance \!midarclength by \!dimenA
  \divide \!midarclength by 12
%
% ** Get arc length over [0,1].
  \!arclength=\!dimenA
  \!getf \advance \!arclength by 4\!dimenA
  \!getf \advance \!arclength by \!dimenA
  \divide \!arclength by 12%             ** Now have arc length over [1/2,1]
  \advance \!arclength by \!midarclength
  \global\advance \totalarclength by \!arclength
%
%
% ** Check to see if there's anything to plot in this interval
  \ifdim\!distacross>\!arclength 
    \advance \!distacross by -\!arclength%   ** nothing 
%
  \else
    \!initinverseinterp%  ** initialize for inverse interpolation on arc length
    \loop\ifdim\!distacross<\!arclength%     ** loop over points on arc 
      \!inverseinterp%    ** find  t  such that arc length[0,t] = distacross,
%                         **   using inverse quadratic interpolation
%                         ** now evaluate x(t)=(c*t + b)*t + a
      \!xpos=\!t\!xC \advance\!xpos by \!xB
        \!xpos=\!t\!xpos \advance \!xpos by \!xS
%                                             ** evaluate y(t)
      \!ypos=\!t\!yC \advance\!ypos by \!yB
        \!ypos=\!t\!ypos \advance \!ypos by \!yS
      \!plotifinbounds%                       ** plot point if in bounds
      \advance\!distacross \plotsymbolspacing%** advance arc length for next pt
      \!advancedashing%                       ** see "linear"
    \repeat  
%
    \advance \!distacross by -\!arclength%    ** prepare for next interval 
  \fi
%
  \!xS=\!xE%              ** shift ending points to starting points
  \!yS=\!yE
  \ignorespaces}
 
 
% ** \!getf -- Calculates sqrt(x'(t)**2 + y'(t)**2) and advances
% **   x'(t) and y'(t)
\def\!getf{\!Pythag\!xprime\!yprime\!dimenA%
  \advance\!xprime by \!dxprime
  \advance\!yprime by \!dyprime}
 
 
% ** \!initinverseinterp -- initializes for inverse quadratic interpolation
% ** of arc length provided  1/3 < midarclength/arclength < 2/3; otherwise
% ** initializes for inverse linear interpolation.
\def\!initinverseinterp{%
  \ifdim\!arclength>\!zpt
    \!divide{8\!midarclength}\!arclength\!dimenE% ** dimE=8w=8r/s, where  r 
%                                               **  = midarclength, s=arclength
% **  Test for  w  out of range:  w<1/3  or w>2/3
    \ifdim\!dimenE<\!wmin \!setinverselinear
    \else 
      \ifdim\!dimenE>\!wmax \!setinverselinear
      \else%                                    ** w  in range: initialize
        \def\!inverseinterp{\!inversequad}\ignorespaces
%
% **     Calculate the coefficients  \!beta  and  \!gamma  of the quadratic
% **                    t = \!beta*v + \!gamma*v**2
% **     taking the values  t=0, 1/2, 1  at  v=0, w==r/s, 1  respectively:
% **        \!beta = (1/2 - w**2)/[w(1-w)] 
% **        \!gamma = 1 - beta.
%
         \!removept\!dimenE\!Ew%           **  8w, without "pt"
         \!dimenF=-\!Ew\!dimenE%           **  -(8w)**2
         \advance\!dimenF by 32pt%         **  32 - (8w)**2
         \!dimenG=8pt 
         \advance\!dimenG by -\!dimenE%    **  8 - 8w
         \!dimenG=\!Ew\!dimenG%            **  (8w)*(8-8w)
         \!divide\!dimenF\!dimenG\!beta%   **  beta = (32-(8w)**2)/(8w(8-8w))
%                                          **       = (1/2 - w**2)/(w(1-w))
         \!gamma=1pt
         \advance \!gamma by -\!beta%      **  gamma = 1-beta
      \fi%       ** end of the \ifdim\!dimenE>\!wmax
    \fi%         ** end of the \ifdim\!dimenE<\!wmin
  \fi%           ** end of the \ifdim\!arclength>\!zpt
  \ignorespaces}
 
 
% ** For 0 <= t <= 1, let AL(t) = arclength[0,t]/arclength[0,1]; note
% ** AL(0)=0, AL(1/2)=midarclength/arclength, AL(1)=1.  This routine
% ** calculates an approximation to AL^{-1}(distance across/arclength),
% ** using the assumption that AL^{-1} is quadratic.  Specifically, 
% ** it finds  t  such that
% **    AL^{-1}(v) =. t = v*(\!beta + \!gamma*v)
% ** where  \!beta  and  \!gamma  are set by \!initinv, and where
% ** v=distance across/arclength
\def\!inversequad{%
  \!divide\!distacross\!arclength\!dimenG%   ** dimG = v = distacross/arclength
  \!removept\!dimenG\!v%                     ** v, without "pt"
  \!dimenG=\!v\!gamma%                       ** gamma*v
  \advance\!dimenG by \!beta%                ** beta + gamma*v
  \!dimenG=\!v\!dimenG%                      ** t = v*(beta + gamma*v)
  \!removept\!dimenG\!t}%                    ** t, without "pt"
 
 
% ** When  w <= 1/3  or  w >= 2/3, the following routine writes (using
% ** plain TEK's \wlog command) a warning message on the user's log file,
% ** and initializes for inverse linear interpolation on arc length.
\def\!setinverselinear{%
  \def\!inverseinterp{\!inverselinear}%
  \divide\!dimenE by 8 \!removept\!dimenE\!t
  \!countC=\!intervalno \multiply \!countC 2
  \!countB=\!countC     \advance \!countB -1
  \!countA=\!countB     \advance \!countA -1
  \wlog{\the\!countB th point (\!xmidpt,\!ymidpt) being plotted 
    doesn't lie in the}%
  \wlog{ middle third of the arc between the \the\!countA th 
    and \the\!countC th points:}%
  \wlog{ [arc length \the\!countA\space to \the\!countB]/[arc length 
    \the \!countA\space to \the\!countC]=\!t.}%
  \ignorespaces}
 
% **  Inverse linear interpolation
\def\!inverselinear{% 
  \!divide\!distacross\!arclength\!dimenG
  \!removept\!dimenG\!t}


% **************************************
% **  ROTATIONS  (Handles rotations) ***
% **************************************
 
% ** User commands
% **   \startrotation [by COS_OF_ANGLE SIN_OF_ANGLE] [about XPIVOT YPIVOT]
% **   \stoprotation

% **   \startrotation [by COS_OF_ANGLE SIN_OF_ANGLE] [about XPIVOT YPIVOT]
% ** Future (XCOORD,YCOORD)'s will be rotated about (XPIVOT,YPIVOT) 
% ** by the angle with the give COS and SIN. Both fields are optional.
% ** [COS,SIN] defaults to previous value, or (1,0).
% ** (XPIVOT,YPIVOT) defaults to previous value, or (0,0)
% ** You can't change the coordinate system in the scope of a rotation.
% ** See Subsection 9.1 of the manual.
\def\startrotation{%
  \let\!rotateaboutpivot=\!!rotateaboutpivot
  \let\!rotateonly=\!!rotateonly
  \!ifnextchar{b}{\!getsincos }%
    {\!getsincos by {\!cosrotationangle} {\!sinrotationangle} }}
\def\!getsincos by #1 #2 {%
  \edef\!cosrotationangle{#1}%
  \edef\!sinrotationangle{#2}%
  \!ifcoordmode 
    \let\!ROnext=\!ccheckforpivot
  \else
    \let\!ROnext=\!dcheckforpivot
  \fi
  \!ROnext}
\def\!ccheckforpivot{%
  \!ifnextchar{a}{\!cgetpivot}%
    {\!cgetpivot about {\!xpivotcoord} {\!ypivotcoord} }}
\def\!cgetpivot about #1 #2 {%
  \edef\!xpivotcoord{#1}%
  \edef\!ypivotcoord{#2}%
  \!xpivot=#1\!xunit  \!ypivot=#2\!yunit
  \ignorespaces}
\def\!dcheckforpivot{%
  \!ifnextchar{a}{\!dgetpivot}{\ignorespaces}}
\def\!dgetpivot about #1 #2 {%
  \!xpivot=#1\relax  \!ypivot=#2\relax
  \ignorespaces}
  

% ** Following terminates rotation.
% ** See Subsection 9.1 of the manual.
\def\stoprotation{%
  \let\!rotateaboutpivot=\!!!rotateaboutpivot
  \let\!rotateonly=\!!!rotateonly
  \ignorespaces}
 
% ** !!rotateaboutpivot{XREG}{YREG}
% ** XREG <-- xpvt + cos(angle)*(XREG-xpvt) - sin(angle)*(YREG-ypvt)
% ** YREG <-- ypvt + cos(angle)*(YREG-ypvt) + sin(angle)*(XREG-xpvt)
% ** XREG,YREG are dimension registers. Can't be \!dimenA to \!dimenD
\def\!!rotateaboutpivot#1#2{%
  \!dimenA=#1\relax  \advance\!dimenA -\!xpivot
  \!dimenB=#2\relax  \advance\!dimenB -\!ypivot
  \!dimenC=\!cosrotationangle\!dimenA
    \advance \!dimenC -\!sinrotationangle\!dimenB
  \!dimenD=\!cosrotationangle\!dimenB
    \advance \!dimenD  \!sinrotationangle\!dimenA
  \advance\!dimenC \!xpivot  \advance\!dimenD \!ypivot
  #1=\!dimenC  #2=\!dimenD
  \ignorespaces}

% ** \!!rotateonly{XREG}{YREG}
% ** Like \!!rotateaboutpivot, but with a pivot of  (0,0)
\def\!!rotateonly#1#2{%
  \!dimenA=#1\relax  \!dimenB=#2\relax 
  \!dimenC=\!cosrotationangle\!dimenA
    \advance \!dimenC -\!rotsign\!sinrotationangle\!dimenB
  \!dimenD=\!cosrotationangle\!dimenB
    \advance \!dimenD  \!rotsign\!sinrotationangle\!dimenA
  #1=\!dimenC  #2=\!dimenD
  \ignorespaces}
\def\!rotsign{}
\def\!!!rotateaboutpivot#1#2{\relax}
\def\!!!rotateonly#1#2{\relax}
\stoprotation

\def\!reverserotateonly#1#2{%
  \def\!rotsign{-}%
  \!rotateonly{#1}{#2}%
  \def\!rotsign{}%
  \ignorespaces}


% **********************************
% *** SHADING  (Handles shading) ***
% **********************************

% **  User commands
% **    \setshadegrid [span <SPAN>] [point at XSHADE YSHADE] 
% **    \setshadesymbol [<LS, RS, BS, TS>] ({SHADESYMBOL}
% **      <XDIMEN,YDIMEN> [ORIENTATION])

% **  Internal commands:
% **    \!startvshade  (xS,ybS,ytS)
% **    \!starthshade  (yS,xlS,xrS)
% **    \!lshade [<LS,RS,BS,TS>]
% **       ** when shading vertically:
% **       [the region from (xS,ybS,ytS) to] (xE,ybE,ytE)
% **       ** when shading horizontally:
% **       [the region from (yS,xlS,xrS) to] (yE,xlE,xrE)
% **    \!qshade [<LS,RS,BS,TS>]
% **       ** when shading vertically:
% **       [the region from (xS,ybS,ytS) to] (xM,ybM,ytM)  (xE,ybE,ytE)
% **       ** when shading horizontally:
% **       [the region from (yS,xlS,xrS) to] (yM,xlM,xrM)  (yE,xlE,xrE)
% **    \!lattice{ANCHOR}{SPAN}{LOCATION}{INDEX}{LATTICE LOCATION}
% **    \!override{NOMINAL DIMEN}{REPLACEMENT DIMEN}{DIMEN}


% **  The shading routine can operate either in a "vertical mode" or a
% **  "horizontal mode".  In vertical mode, the region to be shaded is specified
% **  in the form
% **                 {(x,y): xl <= x <= xr  &  yb(x) <= y <= yt(x)}
% **  where  yb  and  yt  are functions of  x.  In horizontal mode, the region
% **  is specified in the form
% **                 {(x,y): yb <= y <= yt  &  xl(y) <= x <= xr(y)}.
% **  The functions  yb  and  yt  may be either both linear or both quadratic;
% **  similarly for  xl  and  xr.  A region with say, piecewise quadratic bottom
% **  and top boundaries, can be shaded by consecutive (vertical) \!qshades,
% **  proceeding from left to right.  Similarly, a region with piecewise     
% **  quadratic left and right boundaries can be shaded by consecutive
% **  (horizontal) \!qshades, proceeding from bottom to top.  More complex
% **  regions can be shaded by partitioning them into appropriate subregions,
% **  and shading those.
    
% **  Shading is accomplished by placing a user-selected shading symbol at
% **  those points of a regular grid which fall within the region to be
% **  shaded.  This region can be "shrunk" so that a largish shading symbol
% **  will not extend outside it.  Shrinking is accomplished by specifying
% **  shrinkages for the left, right, bottom, and top boundaries, in a manner
% **  discussed further below.

% **  \shades and \!joins MUST NOT be intermingled.  Finish drawing a curve
% **  before starting to shade a region, and finish shading a region before
% **  starting to draw a curve.


% **  \setshadegrid [span <SPAN>] [point at XSHADE YSHADE] 
% **  The shading symbol is placed down on the points of a grid centered
% **  at the coordinate point (XSHADE,YSHADE).  The grid points are of the
% **  form (j*SPAN,k*SPAN), with  j+k  even.  SPAN is specified
% **  as a dimension.
% **  (XSHADE,YSHADE) defaults to previous (XSHADE,YSHADE) (or (0,0) if none)
% **  SPAN defaults to previous span (or 5pt if none)
% **  See Subsection 7.2 of the manual.
\def\setshadegrid{%
  \!ifnextchar{s}{\!getspan }
    {\!getspan span <\!dshade>}}
\def\!getspan span <#1>{%
  \!dshade=#1\relax
  \!ifcoordmode 
    \let\!GRnext=\!GRccheckforAP
  \else
    \let\!GRnext=\!GRdcheckforAP
  \fi
  \!GRnext}
\def\!GRccheckforAP{%
  \!ifnextchar{p}{\!cgetanchor }
    {\!cgetanchor point at {\!xshadesave} {\!yshadesave} }}
\def\!cgetanchor point at #1 #2 {%
  \edef\!xshadesave{#1}\edef\!yshadesave{#2}%
  \!xshade=\!xshadesave\!xunit  \!yshade=\!yshadesave\!yunit
  \ignorespaces}
\def\!GRdcheckforAP{%
  \!ifnextchar{p}{\!dgetanchor}%
    {\ignorespaces}}
\def\!dgetanchor point at #1 #2 {%
  \!xshade=#1\relax  \!yshade=#2\relax
  \ignorespaces}

% **  \setshadesymbol  [<LS, RS, BS, TS>] ({SHADESYMBOL}
% **    <XDIMEN,YDIMEN> [ORIENTATION])
% **  Saves SHADESYMBOL away in an hbox for use with shading routines.
% **  A shade symbol will not be plotted if its plot position comes within
% **    distance LS of the left boundary,  RS of the right boundary,  TS of the
% **    top boundary,  BS of the bottom boundary.  These parameters have 
% **    default values that should work in most cases (see below).
% **    To override a default value, specify the replacement value
% **    in the appropriate subfield of the shrinkages field.
% **    0pt may be coded as  "z" (without the quotes).  To accept a
% **    default value, leave the field empty.  Thus
% **      [,z,,5pt]  sets  LS=default, RS=0pt, BS=default, TS=5pt .
% **    Skipping the shrinkages field accepts all the defaults.
% **  See Subsection 7.1 of the manual.
\def\setshadesymbol{%
  \!ifnextchar<{\!setshadesymbol}{\!setshadesymbol<,,,> }}

\def\!setshadesymbol <#1,#2,#3,#4> (#5#6){%
% **  set the shadesymbol
  \!setputobject{#5}{#6}%                        
  \setbox\!shadesymbol=\box\!putobject%
  \!shadesymbolxshift=\!xshift \!shadesymbolyshift=\!yshift
%
% **  set the shrinkages
  \!dimenA=\!xshift \advance\!dimenA \!smidge% ** default LS = xshift - smidge
  \!override\!dimenA{#1}\!lshrinkage%         
  \!dimenA=\!wd \advance \!dimenA -\!xshift%   ** default RS = width - xshift
    \advance\!dimenA \!smidge%                                  - smidge
    \!override\!dimenA{#2}\!rshrinkage
  \!dimenA=\!dp \advance \!dimenA \!yshift%    ** default BS = depth + yshift
    \advance\!dimenA \!smidge%                                  - smidge
    \!override\!dimenA{#3}\!bshrinkage
  \!dimenA=\!ht \advance \!dimenA -\!yshift%   ** default TS = height - yshift
    \advance\!dimenA \!smidge%                                  - smidge
    \!override\!dimenA{#4}\!tshrinkage
  \ignorespaces}
\def\!smidge{-.2pt}%

% ** \!override{NOMINAL DIMEN}{REPLACEMENT DIMEN}{DIMEN}
% ** Overrides the NOMINAL DIMEN by the REPLACEMENT DIMEN to produce DIMEN,
% ** according to the following rules:
% **   REPLACEMENT DIMEN empty: DIMEN <-- NOMINAL DIMEN
% **   REPLACEMENT DIMEN z:     DIMEN <-- 0pt
% **   otherwise:               DIMEN <-- REPLACEMENT DIMEN
% ** DIMEN must be a dimension register
\def\!override#1#2#3{%
  \edef\!!override{#2}% 
  \ifx \!!override\empty
    #3=#1\relax
  \else
    \if z\!!override
      #3=\!zpt
    \else
      \ifx \!!override\!blankz
        #3=\!zpt
      \else
        #3=#2\relax
      \fi
    \fi
  \fi
  \ignorespaces}
\def\!blankz{ z}

\setshadesymbol ({\fiverm .})%       ** initialize plotsymbol
%                                    ** \fivesy ^^B  is a small cross


% ** \!startvshade [at] (xS,ybS,ytS)
% ** Initiates vertical shading mode
\def\!startvshade#1(#2,#3,#4){%
  \let\!!xunit=\!xunit%
  \let\!!yunit=\!yunit%
  \let\!!xshade=\!xshade%
  \let\!!yshade=\!yshade%
  \def\!getshrinkages{\!vgetshrinkages}%
  \let\!setshadelocation=\!vsetshadelocation%
  \!xS=\!M{#2}\!!xunit
  \!ybS=\!M{#3}\!!yunit
  \!ytS=\!M{#4}\!!yunit
  \!shadexorigin=\!xorigin  \advance \!shadexorigin \!shadesymbolxshift
  \!shadeyorigin=\!yorigin  \advance \!shadeyorigin \!shadesymbolyshift
  \ignorespaces}
 
% ** \!starthshade [at] (yS,xlS,xrS)
% ** Initiates horizontal shading mode
\def\!starthshade#1(#2,#3,#4){%
  \let\!!xunit=\!yunit%
  \let\!!yunit=\!xunit%
  \let\!!xshade=\!yshade%
  \let\!!yshade=\!xshade%
  \def\!getshrinkages{\!hgetshrinkages}%
  \let\!setshadelocation=\!hsetshadelocation%
  \!xS=\!M{#2}\!!xunit
  \!ybS=\!M{#3}\!!yunit
  \!ytS=\!M{#4}\!!yunit
  \!shadexorigin=\!xorigin  \advance \!shadexorigin \!shadesymbolxshift
  \!shadeyorigin=\!yorigin  \advance \!shadeyorigin \!shadesymbolyshift
  \ignorespaces}


% **  \!lattice{ANCHOR}{SPAN}{LOCATION}{INDEX}{LATTICE LOCATION}
% **  Consider the lattice with points  ANCHOR + j*SPAN. This routine determines
% **  the index  k  of the smallest lattice point >= LOCATION, and sets
% **  LATTICE LOCATION = ANCHOR + k*SPAN.
% **  INDEX is assumed to be a count register, LATTICE LOCATION a dimen reg.
\def\!lattice#1#2#3#4#5{%
  \!dimenA=#1%                        ** dimA = ANCHOR
  \!dimenB=#2%                        ** dimB = SPAN  (assumed > 0pt)
  \!countB=\!dimenB%                  ** ctB  = SPAN, as a count
%
% ** Determine index of smallest lattice point >= LOCATION
  \!dimenC=#3%                        ** dimC = LOCATION
  \advance\!dimenC -\!dimenA%         ** now dimC = LOCATION-ANCHOR
  \!countA=\!dimenC%                  ** ctA = above, as a count
  \divide\!countA \!countB%           ** now ctA = desired index, if dimC <= 0
  \ifdim\!dimenC>\!zpt
    \!dimenD=\!countA\!dimenB%        ** (tentative k)*span
    \ifdim\!dimenD<\!dimenC%          ** if this is false, ctA = desired index
      \advance\!countA 1 %            ** if true, have to add 1
    \fi
  \fi
%
  \!dimenC=\!countA\!dimenB%          ** lattice location = anchor + ctA*span
    \advance\!dimenC \!dimenA
  #4=\!countA%                        ** the desired index
  #5=\!dimenC%                        ** corresponding lattice location
  \ignorespaces}


% ** \!qshade [with shrinkages] [[LS,RS,BS,TS]]
% ***** during vertical shading:
% **    [the region from (xS,ybS,ytS) to] (xM,ybM,ytM) [and] (xE,ybE,ytE)
% ** Shades the region {(x,y): xS <= x <= xE, yb(x) <= y <= yt(x)}, where 
% **   yb is the quadratic thru (xS,ybS) & (xM,ybM) & (xE,ybE)
% **   yt is the quadratic thru (xS,ytS) & (xM,ybM) & (xE,ytE)
% ** xS,ybS,ytS are either given by \!startvshade or carried over
% **   as the ending values of the immediately preceding \!qshade.
% ** For the interpretation of LS, RS, BS, & TS, see \setshadesymbol. The
% **   values set there can be overridden, for the course of this \!qshade
% **   only, in the same manner as overrides are specified for
% **   \setshadesymbol.
% ***** during horizontal shading:
% **    [the region from (yS,xlS,xrS) to] (yM,xlM,xrM) [and] (yE,xlE,xrE)
\def\!qshade#1(#2,#3,#4)#5(#6,#7,#8){%
  \!xM=\!M{#2}\!!xunit
  \!ybM=\!M{#3}\!!yunit
  \!ytM=\!M{#4}\!!yunit
  \!xE=\!M{#6}\!!xunit
  \!ybE=\!M{#7}\!!yunit
  \!ytE=\!M{#8}\!!yunit
  \!getcoeffs\!xS\!ybS\!xM\!ybM\!xE\!ybE\!ybB\!ybC%**Get coefficients B & C for
  \!getcoeffs\!xS\!ytS\!xM\!ytM\!xE\!ytE\!ytB\!ytC%**y=y0 + B(x-X0) + C(x-X0)**2
  \def\!getylimits{\!qgetylimits}%
  \!shade{#1}\ignorespaces}
 
% ** \!lshade ... (xE,ybE,ytE)
% ** This is like \!qshade, but the top and bottom boundaries are linear,
% ** rather than quadratic.
\def\!lshade#1(#2,#3,#4){%
  \!xE=\!M{#2}\!!xunit
  \!ybE=\!M{#3}\!!yunit
  \!ytE=\!M{#4}\!!yunit
  \!dimenE=\!xE  \advance \!dimenE -\!xS%   ** xE-xS
  \!dimenC=\!ytE \advance \!dimenC -\!ytS%  ** ytE-ytS
  \!divide\!dimenC\!dimenE\!ytB%            ** ytB = (ytE-ytS)/(xE-xS)
  \!dimenC=\!ybE \advance \!dimenC -\!ybS%  ** ybE-ybS
  \!divide\!dimenC\!dimenE\!ybB%            ** ybB = (ybE-ybS)/(xE-xS)
  \def\!getylimits{\!lgetylimits}%
  \!shade{#1}\ignorespaces}
 
% **  \!getcoeffs{X0}{Y0}{X1}{Y1}{X2}{Y2}{B}{C}
% **  Finds  B  and  C  such that the quadratic  y = Y0 + B(x-X0) + C(x-X0)**2
% **  passes through (X1,Y1) and (X2,Y2):  when X0=0=Y0, the formulas are:
% **                   B = S1 - X1*C,   C = (S2-S1)/X2
% **  with
% **                 S1 = Y1/X1,   S2 = (Y2-Y1)/(X2-X1).
\def\!getcoeffs#1#2#3#4#5#6#7#8{% 
  \!dimenC=#4\advance \!dimenC -#2%            ** dimC=Y1-Y0
  \!dimenE=#3\advance \!dimenE -#1%            ** dimE=X1-X0
  \!divide\!dimenC\!dimenE\!dimenF%            ** dimF=S1
  \!dimenC=#6\advance \!dimenC -#4%            ** dimC=Y2-Y1
  \!dimenH=#5\advance \!dimenH -#3%            ** dimH=X2-X1
  \!divide\!dimenC\!dimenH\!dimenG%            ** dimG=S2
  \advance\!dimenG -\!dimenF%                  ** dimG=S2-S1
  \advance \!dimenH \!dimenE%                  ** dimH=X2-X0
  \!divide\!dimenG\!dimenH#8%                  ** C=(S2-S1)/(X2-X0)
  \!removept#8\!t%                             ** C, without "pt"
  #7=-\!t\!dimenE%                             ** -C*(X1-X0)
  \advance #7\!dimenF%                         ** B=S1-C*(X1-X0)
  \ignorespaces}
 
 
\def\!shade#1{%
% ** Get LS,RS,BS,TS for this panel
  \!getshrinkages#1<,,,>\!nil% %       ** now effective LS=dimE, RS=dimF,
%                                      **   BS=dimG, TS=dimH
  \advance \!dimenE \!xS%              ** now dimE=xS+LS
  \!lattice\!!xshade\!dshade\!dimenE%  ** set parity=index of left-mst x-lattice
    \!parity\!xpos%                    **   point >= xS+LS, xpos=its location
  \!dimenF=-\!dimenF%                  ** set dimF=xE-RS
    \advance\!dimenF \!xE
%               
  \!loop\!not{\ifdim\!xpos>\!dimenF}%  ** loop over x-lattice points <= xE-RS
    \!shadecolumn%                 
    \advance\!xpos \!dshade%           ** move over to next column
    \advance\!parity 1%                ** increase index of x-point
  \repeat
%
  \!xS=\!xE%                           ** shift ending values to starting values
  \!ybS=\!ybE
  \!ytS=\!ytE
  \ignorespaces}
 
 
\def\!vgetshrinkages#1<#2,#3,#4,#5>#6\!nil{%
  \!override\!lshrinkage{#2}\!dimenE
  \!override\!rshrinkage{#3}\!dimenF
  \!override\!bshrinkage{#4}\!dimenG
  \!override\!tshrinkage{#5}\!dimenH
  \ignorespaces}
\def\!hgetshrinkages#1<#2,#3,#4,#5>#6\!nil{%
  \!override\!lshrinkage{#2}\!dimenG
  \!override\!rshrinkage{#3}\!dimenH
  \!override\!bshrinkage{#4}\!dimenE
  \!override\!tshrinkage{#5}\!dimenF
  \ignorespaces}
 
 
\def\!shadecolumn{%
  \!dxpos=\!xpos
  \advance\!dxpos -\!xS%            ** dx = x - xS
  \!removept\!dxpos\!dx%            ** ditto, without "pt"
  \!getylimits%                     ** get top and bottom y-values
  \advance\!ytpos -\!dimenH%        ** less TS
  \advance\!ybpos \!dimenG%         ** plus BS
  \!yloc=\!!yshade%                 ** get anchor point for this column
  \ifodd\!parity 
     \advance\!yloc \!dshade
  \fi
  \!lattice\!yloc{2\!dshade}\!ybpos%
    \!countA\!ypos%                 ** ypos=smallest y point for this column
  \!dimenA=-\!shadexorigin \advance \!dimenA \!xpos%      ** over
  \loop\!not{\ifdim\!ypos>\!ytpos}% ** loop over ypos <= yt(t)
    \!setshadelocation%             ** vmode: xloc=xpos, yloc=ypos 
%                                   ** hmode: xloc=ypos, yloc=xpos 
    \!rotateaboutpivot\!xloc\!yloc%
    \!dimenA=-\!shadexorigin \advance \!dimenA \!xloc%    ** over
    \!dimenB=-\!shadeyorigin \advance \!dimenB \!yloc%    ** up
    \kern\!dimenA \raise\!dimenB\copy\!shadesymbol \kern-\!dimenA
    \advance\!ypos 2\!dshade
  \repeat
  \ignorespaces}
 
\def\!qgetylimits{%
  \!dimenA=\!dx\!ytC              
  \advance\!dimenA \!ytB%         ** yt(t)=ytS + dx*(Bt + dx*Ct)
  \!ytpos=\!dx\!dimenA
  \advance\!ytpos \!ytS
  \!dimenA=\!dx\!ybC              
  \advance\!dimenA \!ybB%         ** yb(t)=ybS + dx*(Bb + dx*Cb)
  \!ybpos=\!dx\!dimenA
  \advance\!ybpos \!ybS}
 
\def\!lgetylimits{%
  \!ytpos=\!dx\!ytB%              ** yt(t)=ytS + dx*Bt
  \advance\!ytpos \!ytS
  \!ybpos=\!dx\!ybB%              ** yb(t)=ybS + dx*Bb
  \advance\!ybpos \!ybS}
 
\def\!vsetshadelocation{%         ** vmode: xloc=xpos, yloc=ypos 
  \!xloc=\!xpos
  \!yloc=\!ypos}
\def\!hsetshadelocation{%         ** hmode: xloc=ypos, yloc=xpos 
  \!xloc=\!ypos
  \!yloc=\!xpos}


% **************************************
% *** TICKS  (Draws ticks on graphs) ***
% **************************************

% ** User commands
% **   \ticksout
% **   \ticksin
% **   \gridlines
% **   \nogridlines
% **   \loggedticks
% **   \unloggesticks
% ** See Subsection 3.4 of the manual

% ** The following is an option of the \axis command
% **   ticks 
% **     [in] [out] 
% **     [long] [short] [length <LENGTH>] 
% **     [width <WIDTH>]
% **     [andacross] [butnotacross] 
% **     [logged] [unlogged] 
% **     [unlabeled] [numbered] [withvalues VALUE1 VALUE2 ... VALUEk / ]
% **     [quantity Q] [at LOC1 LOC2 ... LOCk / ] [from LOC1 to LOC2 by
% **       LOC_INCREMENT]
% ** See Subsection 3.2 of the manual for the rules.

% ** The various options of the  tick  field are processed by the
% ** \!nextkeyword  command defined below.
% ** For example, `\!nextkeyword short '  expands to  `\!ticksshort',
% ** while `\!nextkeyword withvalues' expands to `\!tickswithvalues'.

\def\!axisticks {%
  \def\!nextkeyword##1 {%
    \expandafter\ifx\csname !ticks##1\endcsname \relax
      \def\!next{\!fixkeyword{##1}}%
    \else
      \def\!next{\csname !ticks##1\endcsname}%
    \fi
    \!next}%
  \!axissetup
    \def\!axissetup{\relax}%
  \edef\!ticksinoutsign{\!ticksinoutSign}%
  \!ticklength=\longticklength
  \!tickwidth=\linethickness
  \!gridlinestatus
  \!setticktransform
  \!maketick
  \!tickcase=0
  \def\!LTlist{}%
  \!nextkeyword}

\def\ticksout{%
  \def\!ticksinoutSign{+}}
\def\ticksin{%
  \def\!ticksinoutSign{-}}
\ticksout

\def\gridlines{%
  \def\!gridlinestatus{\!gridlinestootrue}}
\def\nogridlines{%
  \def\!gridlinestatus{\!gridlinestoofalse}}
\nogridlines

\def\loggedticks{%
  \def\!setticktransform{\let\!ticktransform=\!logten}}
\def\unloggedticks{%
  \def\!setticktransform{\let\!ticktransform=\!donothing}}
\def\!donothing#1#2{\def#2{#1}}
\unloggedticks

% ** \!ticks/ : terminates read of tick options
\expandafter\def\csname !ticks/\endcsname{%
  \!not {\ifx \!LTlist\empty}
    \!placetickvalues
  \fi
  \def\!tickvalueslist{}%
  \def\!LTlist{}%
  \expandafter\csname !axis/\endcsname}

\def\!maketick{%
  \setbox\!boxA=\hbox{%
    \beginpicture
      \!setdimenmode
      \setcoordinatesystem point at {\!zpt} {\!zpt}   
      \linethickness=\!tickwidth
      \ifdim\!ticklength>\!zpt
        \putrule from {\!zpt} {\!zpt} to
          {\!ticksinoutsign\!tickxsign\!ticklength}
          {\!ticksinoutsign\!tickysign\!ticklength}
      \fi
      \if!gridlinestoo
        \putrule from {\!zpt} {\!zpt} to
          {-\!tickxsign\!xaxislength} {-\!tickysign\!yaxislength}
      \fi
    \endpicturesave <\!Xsave,\!Ysave>}%
    \wd\!boxA=\!zpt}
  
\def\!ticksin{%
  \def\!ticksinoutsign{-}%
  \!maketick
  \!nextkeyword}

\def\!ticksout{%
  \def\!ticksinoutsign{+}%
  \!maketick
  \!nextkeyword}

\def\!tickslength<#1> {%
  \!ticklength=#1\relax
  \!maketick
  \!nextkeyword}

\def\!tickslong{%
  \!tickslength<\longticklength> }

\def\!ticksshort{%
  \!tickslength<\shortticklength> }

\def\!tickswidth<#1> {%
  \!tickwidth=#1\relax
  \!maketick
  \!nextkeyword}

\def\!ticksandacross{%
  \!gridlinestootrue
  \!maketick
  \!nextkeyword}

\def\!ticksbutnotacross{%
  \!gridlinestoofalse
  \!maketick
  \!nextkeyword}

\def\!tickslogged{%
  \let\!ticktransform=\!logten
  \!nextkeyword}

\def\!ticksunlogged{%
  \let\!ticktransform=\!donothing
  \!nextkeyword}

\def\!ticksunlabeled{%
  \!tickcase=0
  \!nextkeyword}

\def\!ticksnumbered{%
  \!tickcase=1
  \!nextkeyword}

\def\!tickswithvalues#1/ {%
  \edef\!tickvalueslist{#1! /}%
  \!tickcase=2
  \!nextkeyword}

\def\!ticksquantity#1 {%
  \ifnum #1>1
    \!updatetickoffset
    \!countA=#1\relax
    \advance \!countA -1
    \!ticklocationincr=\!axisLength
      \divide \!ticklocationincr \!countA
    \!ticklocation=\!axisstart
    \loop \!not{\ifdim \!ticklocation>\!axisend}
      \!placetick\!ticklocation
      \ifcase\!tickcase
          \relax %  Case 0: no labels
        \or
          \relax %  Case 1: numbered -- not available here
        \or
          \expandafter\!gettickvaluefrom\!tickvalueslist
          \edef\!tickfield{{\the\!ticklocation}{\!value}}%
          \expandafter\!listaddon\expandafter{\!tickfield}\!LTlist%
      \fi
      \advance \!ticklocation \!ticklocationincr
    \repeat
  \fi
  \!nextkeyword}

\def\!ticksat#1 {%
  \!updatetickoffset
  \edef\!Loc{#1}%
  \if /\!Loc
    \def\next{\!nextkeyword}%
  \else
    \!ticksincommon
    \def\next{\!ticksat}%
  \fi
  \next}    
      
\def\!ticksfrom#1 to #2 by #3 {%
  \!updatetickoffset
  \edef\!arg{#3}%
  \expandafter\!separate\!arg\!nil
  \!scalefactor=1
  \expandafter\!countfigures\!arg/
  \edef\!arg{#1}%
  \!scaleup\!arg by\!scalefactor to\!countE
  \edef\!arg{#2}%
  \!scaleup\!arg by\!scalefactor to\!countF
  \edef\!arg{#3}%
  \!scaleup\!arg by\!scalefactor to\!countG
  \loop \!not{\ifnum\!countE>\!countF}
    \ifnum\!scalefactor=1
      \edef\!Loc{\the\!countE}%
    \else
      \!scaledown\!countE by\!scalefactor to\!Loc
    \fi
    \!ticksincommon
    \advance \!countE \!countG
  \repeat
  \!nextkeyword}

\def\!updatetickoffset{%
  \!dimenA=\!ticksinoutsign\!ticklength
  \ifdim \!dimenA>\!offset
    \!offset=\!dimenA
  \fi}

\def\!placetick#1{%
  \if!xswitch
    \!xpos=#1\relax
    \!ypos=\!axisylevel
  \else
    \!xpos=\!axisxlevel
    \!ypos=#1\relax
  \fi
  \advance\!xpos \!Xsave
  \advance\!ypos \!Ysave
  \kern\!xpos\raise\!ypos\copy\!boxA\kern-\!xpos
  \ignorespaces}

\def\!gettickvaluefrom#1 #2 /{%
  \edef\!value{#1}%
  \edef\!tickvalueslist{#2 /}%
  \ifx \!tickvalueslist\!endtickvaluelist
    \!tickcase=0
  \fi}
\def\!endtickvaluelist{! /}

\def\!ticksincommon{%
  \!ticktransform\!Loc\!t
  \!ticklocation=\!t\!!unit
  \advance\!ticklocation -\!!origin
  \!placetick\!ticklocation
  \ifcase\!tickcase
    \relax % Case 0: no labels
  \or %      Case 1: numbered
    \ifdim\!ticklocation<-\!!origin
      \edef\!Loc{$\!Loc$}%
    \fi
    \edef\!tickfield{{\the\!ticklocation}{\!Loc}}%
    \expandafter\!listaddon\expandafter{\!tickfield}\!LTlist%
  \or %      Case 2: labeled
    \expandafter\!gettickvaluefrom\!tickvalueslist
    \edef\!tickfield{{\the\!ticklocation}{\!value}}%
    \expandafter\!listaddon\expandafter{\!tickfield}\!LTlist%
  \fi}

\def\!separate#1\!nil{%
  \!ifnextchar{-}{\!!separate}{\!!!separate}#1\!nil}
\def\!!separate-#1\!nil{%
  \def\!sign{-}%
  \!!!!separate#1..\!nil}
\def\!!!separate#1\!nil{%
  \def\!sign{+}%
  \!!!!separate#1..\!nil}
\def\!!!!separate#1.#2.#3\!nil{%
  \def\!arg{#1}%
  \ifx\!arg\!empty
    \!countA=0
  \else
    \!countA=\!arg
  \fi
  \def\!arg{#2}%
  \ifx\!arg\!empty
    \!countB=0
  \else
    \!countB=\!arg
  \fi}
 
\def\!countfigures#1{%
  \if #1/%
    \def\!next{\ignorespaces}%
  \else
    \multiply\!scalefactor 10
    \def\!next{\!countfigures}%
  \fi
  \!next}

\def\!scaleup#1by#2to#3{%
  \expandafter\!separate#1\!nil
  \multiply\!countA #2\relax
  \advance\!countA \!countB
  \if -\!sign
    \!countA=-\!countA
  \fi
  #3=\!countA
  \ignorespaces}

\def\!scaledown#1by#2to#3{%
  \!countA=#1\relax%                          ** get original #
  \ifnum \!countA<0 %                         ** take abs value,
    \def\!sign{-}%                            **   remember sign
    \!countA=-\!countA
  \else
    \def\!sign{}%
  \fi
  \!countB=\!countA%                          ** copy |#|
  \divide\!countB #2\relax%                   ** integer part (|#|/sf)
  \!countC=\!countB%                          ** get sf * (|#|/sf)
    \multiply\!countC #2\relax
  \advance \!countA -\!countC%                ** ctA is now remainder
  \edef#3{\!sign\the\!countB.}%               ** +- integerpart.
  \!countC=\!countA %                         ** Tack on proper number
  \ifnum\!countC=0 %                          **   of zeros after .
    \!countC=1
  \fi
  \multiply\!countC 10
  \!loop \ifnum #2>\!countC
    \edef#3{#3\!zero}%
    \multiply\!countC 10
  \repeat
  \edef#3{#3\the\!countA}%                    ** Add on rest of remainder
  \ignorespaces}

\def\!placetickvalues{%
  \advance\!offset \tickstovaluesleading
  \if!xswitch
    \setbox\!boxA=\hbox{%
      \def\\##1##2{%
        \!dimenput {##2} [B] (##1,\!axisylevel)}%
      \beginpicture 
        \!LTlist
      \endpicturesave <\!Xsave,\!Ysave>}%
    \!dimenA=\!axisylevel
      \advance\!dimenA -\!Ysave
      \advance\!dimenA \!tickysign\!offset
      \if -\!tickysign
        \advance\!dimenA -\ht\!boxA
      \else
        \advance\!dimenA  \dp\!boxA
      \fi
    \advance\!offset \ht\!boxA 
      \advance\!offset \dp\!boxA
    \!dimenput {\box\!boxA} [Bl] <\!Xsave,\!Ysave> (\!zpt,\!dimenA)
  \else
    \setbox\!boxA=\hbox{%
      \def\\##1##2{%
        \!dimenput {##2} [r] (\!axisxlevel,##1)}%
      \beginpicture 
        \!LTlist
      \endpicturesave <\!Xsave,\!Ysave>}%
    \!dimenA=\!axisxlevel
      \advance\!dimenA -\!Xsave
      \advance\!dimenA \!tickxsign\!offset
      \if -\!tickxsign
        \advance\!dimenA -\wd\!boxA
      \fi
    \advance\!offset \wd\!boxA
    \!dimenput {\box\!boxA} [Bl] <\!Xsave,\!Ysave> (\!dimenA,\!zpt)
  \fi}


\normalgraphs
\catcode`!=12 %  *****  THIS MUST NEVER BE OMITTED

postpict.tex
%auto-ignore
% ********************** START OF POSTPICTEX.TEX ********************
% This is postpictex.tex  Version 1.1  9/10/87. See section 10 of the manual.

% To use the PiCTeX macros under LaTeX, you first need to \input the
% file prepictex.tex, then the main corpus of PiCTeX macros (pictex.tex), 
% and finally this file.  Do not \input the file latexpicobjs.tex.
 
\catcode`@=11 \catcode`!=11
  
% Save meanings of PiCTeX keywords that duplicate LaTeX keywords
\let\!pictexendpicture=\endpicture 
\let\!pictexframe=\frame
\let\!pictexlinethickness=\linethickness
\let\!pictexmultiput=\multiput
\let\!pictexput=\put

% Redefine the PiCTeX \beginpicture macro
\def\beginpicture{%
  \setbox\!picbox=\hbox\bgroup%
  \let\endpicture=\!pictexendpicture
  \let\frame=\!pictexframe
  \let\linethickness=\!pictexlinethickness
  \let\multiput=\!pictexmultiput
  \let\put=\!pictexput
  \let\input=\@@input   % \@@input is LaTeX's saved version of TeX's primitive
  \!xleft=\maxdimen  
  \!xright=-\maxdimen
  \!ybot=\maxdimen
  \!ytop=-\maxdimen}

% Reestablish LaTeX's meaning of \frame. This makes
% PiCTeX's meaning of \frame available only inside a PiCture.
\let\frame=\!latexframe

% Make PiCTeX's meaning of \frame available everywhere in the
% guise of \pictexframe
\let\pictexframe=\!pictexframe

% Now do the same for \linethickness
\let\linethickness=\!latexlinethickness
\let\pictexlinethickness=\!pictexlinethickness

% Reset LaTeX's default meaning of \\
\let\\=\@normalcr
\catcode`@=12 \catcode`!=12
% ********************** END OF POSTPICTEX.TEX ********************

prepicte.tex
%auto-ignore
% **********************  START OF PREPICTEX.TEX ***********************
% This is prepictex.tex  Version 1.1  9/10/87. See section 10 of the manual.

% To use the PiCTeX macros under LaTeX, you first need to \input this
% file, then the main corpus of PiCTeX macros (pictex.tex), and then
% the file postpictex.tex. Do not \input the file latexpicobjs.tex.

\catcode`@=11 \catcode`!=11

% First of all, see if  \fiverm  is defined. If so do nothing;
% if not, let  \fiverm  take on meaning of LaTeX's  \fivrm.
\expandafter\ifx\csname fiverm\endcsname\relax
  \let\fiverm\fivrm
\fi
  
% Save meanings of LaTeX keywords that duplicate PiCTeX keywords
\let\!latexendpicture=\endpicture 
\let\!latexframe=\frame
\let\!latexlinethickness=\linethickness
\let\!latexmultiput=\multiput
\let\!latexput=\put
 
% Redefine the LaTeX \@picture macro
\def\@picture(#1,#2)(#3,#4){%
  \@picht #2\unitlength
  \setbox\@picbox\hbox to #1\unitlength\bgroup 
  \let\endpicture=\!latexendpicture
  \let\frame=\!latexframe
  \let\linethickness=\!latexlinethickness
  \let\multiput=\!latexmultiput
  \let\put=\!latexput
  \hskip -#3\unitlength \lower #4\unitlength \hbox\bgroup}

\catcode`@=12 \catcode`!=12
% **********************  END OF PREPICTEX.TEX ************************

astro-ph0107457.extracted_bib
\begin{thebibliography}{}

\bibitem[Antonov, Timoshkova \& Kholshevnikov (1988)]{Antonov:Timoshkova:Kholshevnikov:1988}
Antonov, V.A., Timoshkova, E.I., \& Kholshevnikov, K.V. 1988,
Introduction to the theory of the Newtonian Potential
(Moscow: Nauka), in Russian

%\bibitem[Bastian et al. (1996)]{DIVA:1996}
%Bastian, U., et al. 1996, Astr. Nachr., 317, 281

\bibitem[Bienayme \& Turon (2002)]{Bienayme:Turon:2002}
Bienayme, O., \& Turon, C.  2002, GAIA: A European Space Project
(Les Ulis: EDP Sciences)

\bibitem[Belokurov \& Evans (2002)]{Belokurov:Evans:2002}
Belokurov, V.A., \& Evans, N.W. 2002, \mnras, 331, 649

\bibitem[Brumberg (1986)]{Brumberg:1986}
Brumberg, V.A. 1986, in Astrometric Techniques,
ed. H.K. Eichhorn, \& R.J. Leacock (Dordrecht: Reidel), 19

\bibitem[Brumberg (1991)]{Brumberg:1991}
Brumberg, V.A. 1991, Essential Relativistic Celestial Mechanics
(Bristol: Hilger)

\bibitem[Brumberg, Klioner, \& Kopejkin (1990)]{Brumberg:Klioner:Kopejkin:1990}
Brumberg, V.A., Klioner, S.A., \& Kopejkin, S.M. 1990,
in Inertial Coordinate System on the Sky, ed. J.H. Lieske \& V.K. Abalakin
(Dordrecht: Kluwer), 229

\bibitem[Brumberg \& Kopeikin (1989a)]{Brumberg:Kopeikin:1989a}
Brumberg, V.A., \& Kopejkin, S.M. 1989a, in: Reference Frames, ed. J.
Kovalevsky, I.I. Mueller, \& B. Ko\l{}aczek (Dordrecht:Kluwer), 115

\bibitem[Brumberg \& Kopeikin (1989b)]{Brumberg:Kopeikin:1989b}
Brumberg, V.A., \& Kopejkin, S.M. 1989b, Nuovo Cimento, 103B, 63

\bibitem[Cunningham \& Bardeen (1972)]{Cunningham:Bardeen:1972}
Cunningham, C.T., \& Bardeen, J.M. 1972, \apj, 173, L137

\bibitem[Cunningham \& Bardeen (1973)]{Cunningham:Bardeen:1973}
Cunningham, C.T., \& Bardeen, J.M. 1973,
\apj, 183, 237

\bibitem[Damour, Soffel, \& Xu (1991)]{Damour:Soffel:Xu:1991}
Damour, T., Soffel, M., \& Xu, C. 1991, \prd, 43, 3273

\bibitem[Damour, Soffel, \& Xu (1992)]{Damour:Soffel:Xu:1992}
Damour, T., Soffel, M., \& Xu, C. 1992, \prd, 45, 1017

\bibitem[Damour, Soffel, \& Xu (1993)]{Damour:Soffel:Xu:1993}
Damour, T., Soffel, M., \& Xu, C. 1993,
\prd, 47, 3124

\bibitem[Damour, Soffel, \& Xu (1994)]{Damour:Soffel:Xu:1994}
    Damour, T., Soffel, M., \& Xu, C. 1994, \prd, 49, 618

\bibitem[Dravins, Lindegren, \& Madsen (1999)]{Dravins:Lindegren:Madsen:1999}
Dravins, D., Lindegren, L., \& Madsen, S. 1999, \aap, 348, 1040

\bibitem[de Felice et al. (2001)]{deFelice:Bucciarelli:Lattanzi:Vecchiato:2001}
de Felice, F., Bucciarelli, B., Lattanzi, M.G., \&  Vecchiato, A. 2001,
\aap, 373, 336

\bibitem[de Felice et al. (1998)]{deFelice:Lattanzi:Vecchiato:Bernacca:1998}
de Felice, F., Lattanzi, M.G., Vecchiato, A., \& Bernacca, P.L. 1998,
\aap, 332, 1133

\bibitem[de Felice et al. (2000)]{deFelice:Vecchiato:Bucciarelli:Lattanzi:Crosta:2000}
de Felice, F., Vecchiato, A., Bucciarelli, B., Lattanzi, M.G., \& Crosta,
M. 2000, in Towards Models and Constants for Sub-Microarcsecond Astrometry,
ed. K.J. Johnston, D.D. McCarthy, B.J. Luzum, \& G.H. Kaplan
(Washington: US Naval Observatory), 314

\bibitem[Doroshenko \& Kopeikin (1990)]{Doroshenko:Kopeikin:1990}
Doroshenko, O.V., \& Kopeikin, S.M. 1990,
\azh, 67, 986, in Russian

\bibitem[Doroshenko \& Kopeikin (1995)]{Doroshenko:Kopeikin:1995}
Doroshenko, O.V., \& Kopeikin, S.M. 1995, \mnras, 274, 1029

\bibitem[ESA (2000)]{GAIA:2000}
ESA, 2000, GAIA: Composition, Formation and Evolution of the Galaxy,
Concept and Technology Study Report, Document ESA-SCI(2000)4, European
Space Agency, Noordwijk

\bibitem[Fukushima (1995)]{Fukushima:1995}
Fukushima, T. 1995, \aap, 294, 895

\bibitem[Gwinn et al. (1997)]{Gwinn:et:al:1997}
Gwinn, C.R., Eubanks, T.M., Pyne, T., Birkinshaw, M., \& Matsakis, D.N.
1997, \apj, 485, 87

\bibitem[H\o{}g, Novikov \& Polnarev (1995)]{Hoeg:Novikov:Polnarev:1995}
H\o{}g, E., Novikov, I.D., \& Polnarev, A.G. 1995, \aap, 294, 287

%\bibitem[Horner et al. (2000)]{FAME:2000}
%Horner, S.D., et al. 2000,
%in ASP Conf. Ser. 203 (also IAU Colloquium 176),
%The Impact of Large-Scale Surveys on Pulsating Star Research,
%ed. L. Szabados, \& D. Kurtz (San Francisco: ASP), 76

\bibitem[Hosokawa et al. (1993)]{Hosokawa:et:al:1993}
Hosokawa, M., Ohnishi, K., Fukushima, T., \& Takeuti, M. 1993,
\aap, 278, L27

\bibitem[Hosokawa et al. (1995)]{Hosokawa:et:al:1995}
Hosokawa, M., Ohnishi, K., Fukushima, T., \& Takeuti, M. 1995,
in Astronomical and Astrophysical
Objectivities of Sub-Milliarcsecond Optical Astrometry,
ed. E. H\o{}g, \& P.K. Seidelmann (Dordrecht: Kluwer), 305

\bibitem[Hosokawa et al. (1997)]{Hosokawa:Ohnishi:Fukushima:1997}
Hosokawa, M., Ohnishi, K., \& Fukushima, T. 1997,
\aj, 114, 1508

\bibitem[IAU (2001)]{IAU:2001}
IAU 2001, Information Bulletin, 88 (errata in IAU Information Bulletin, 89)

\bibitem[IERS (1996)]{IERS:1996}
IERS 1996, IERS Conventions, International Earth Rotation
Service Technical Note 21, ed. D.D. McCarthy
(Paris: Observatoire de Paris)

\bibitem[Irwin \& Fukushima (1999)]{Irwin:Fukushima:1999}
Irwin, A.W. \& Fukushima, T. 1999, \aap, 348, 642

\bibitem[Klioner (1989)]{Klioner:1989}
Klioner, S.A. 1989,
Institute of Applied Astronomy, preprint No 6, in Russian

\bibitem[Klioner (1991a)]{Klioner:1991a}
Klioner, S.A. 1991a, \azh, 68, 1046, in Russian
(translated into English:  \sovast, 35, 523)

\bibitem[Klioner (1991b)]{Klioner:1991b}
Klioner, S.A. 1991b, Ph.D. thesis,
Institute of Applied Astronomy \& St.Petersburg State University,
in Russian

\bibitem[Klioner (1993)]{Klioner:1993}
Klioner, S.A. 1993, \aap, 279, 273

\bibitem[Klioner (2000)]{Klioner:2000}
Klioner, S.A. 2000,
in Towards Models and Constants for Sub-Microarcsecond Astrometry,
ed. K.J. Johnston, D.D. McCarthy, B.J. Luzum, \& G.H. Kaplan
(Washington: US Naval Observatory), 308

\bibitem[Klioner \& Kopeikin (1992)]{Klioner:Kopeikin:1992}
Klioner S.A., \& Kopeikin, S.M. 1992,
\aj, 104, 897

\bibitem[Klioner \& Soffel (1998a)]{Klioner:Soffel:1998a}
Klioner, S.A., \& Soffel, M. 1998a, \aap, 334, 1123

\bibitem[Klioner \& Soffel (1998b)]{Klioner:Soffel:1998b}
 Klioner, S.A., \& Soffel, M.H. 1998b, \prd, 58, ID 084023

\bibitem[Klioner \& Soffel (2000)]{Klioner:Soffel:2000}
Klioner, S.A., \& Soffel, M.H. 2000,
\prd, 62, ID 024019

\bibitem[Klioner \& Voinov (1993)]{Klioner:Voinov:1993}
Klioner, S.A., \& Voinov, A.V. 1993, \prd, 48, 1451

\bibitem[Kopeikin (1988)]{Kopeikin:1988}
Kopejkin, S.M. 1988, Celestial Mechanics, 44, 87

%\bibitem[Kopeikin (1989)]{Kopeikin:1989}
%Kopeikin, S.M. 1989, \azh, 66, 1289, in Russian
%(translated into English:  \sovast, 33, 665)

\bibitem[Kopeikin (1997)]{Kopeikin:1997}
Kopeikin, S.M. 1997, J. Math. Phys., 38, 2587

\bibitem[Kopeikin (1999)]{Kopeikin:1999}
Kopeikin, S.M. 1999, available as {\tt http://xxx.lanl.gov/abs/gr-qc/9903070}

\bibitem[Kopeikin \& Ozernoy (1999)]{Kopeikin:Ozernoy:1999}
Kopeikin, S.M., \& Ozernoy, L.M., 1999, \apj, 523, 771

\bibitem[Kopeikin et al. (1999)]{Kopeikin:Schaefer:Gwinn:Eubanks:1999}
Kopeikin, S.M., Sch\"afer, G., Gwinn, C.R., \& Eubanks, T.M. 1999,
\prd, 59, ID 084023

\bibitem[Kopeikin \& Gwinn (2000)]{Kopeikin:Gwinn:2000}
Kopeikin, S.M., \& Gwinn, C. 2000,
in Towards Models and Constants for Sub-Microarcsecond Astrometry,
ed. K.J. Johnston, D.D. McCarthy, B.J. Luzum, \& G.H. Kaplan
(Washington: US Naval Observatory), 303

\bibitem[Kopeikin \& Sch\"afer (1999)]{Kopeikin:Schaefer:1999}
Kopeikin, S.M., \& Sch\"afer, G. 1999, \prd, {\bf 60}, ID 124002

\bibitem[Kopeikin \& Mashhoon (2002)]{Kopeikin:Mashhoon:2002}
Kopeikin, S.M., \& Mashhoon, B. 2002, \prd, {\bf 65}, ID 064025

\bibitem[Kopeikin et al. (2000)]{Kopeikin:Shuygina:Vasiliev:Yagudina:Yagudin:2000}
Kopeikin, S.M., Shuygina, N., Vasiliev, M., Yagudina, E., \& Yagudin, L.
2000,
in Towards Models and Constants for Sub-Microarcsecond Astrometry,
ed. K.J. Johnston, D.D. McCarthy, B.J. Luzum, \& G.H. Kaplan
(Washington: US Naval Observatory), 320

\bibitem[Kristian \& Sachs (1965)]{Kristian:Sachs:1965}
Kristian, J., \& Sachs, R.K. 1965,
\apj, 143, 379

\bibitem[Mashhoon (1974)]{Mashhoon:1974b}
Mashhoon, B. 1974, \nat, 250, 316

\bibitem[Misner, Thorne, \& Wheeler (1973)]{Misner:Thorne:Wheeler:1973}
Misner, C.W., Thorne, K.S., Wheeler, J.A. 1973,
Gravitation (San Francisco: Freeman)

\bibitem[Neill (1996)]{Neill:1996}
Neill, R.I. 1996, \aj, 111, 2000

\bibitem[Perryman et al. (2001)]{Perryman:et:al:2001}
Perryman, M. A. C., et al. 2001, \aap, 369, 339

\bibitem[Pyne et al. (1996)]{Pyne:Gwinn:Birkinshaw:Eubanks:Matsakis:1996}
Pyne, T., Gwinn, C.R, Birkinshaw, M., Eubanks, T.M., \& Matsakis, D.N.
1996, \apj, 465, 566

\bibitem[Reasenberg et al. (1988)]{Reasenberg:et:al:1988}
Reasenberg, R.D., et al. 1988, \aj, 96, 1731

\bibitem[Sazhin et al. (1998)]{Sazhin:Zharov:Volynkin:Kalinina:1998}
Sazhin, M.V., Zharov, V.E., Volynkin, A.V., \& Kalinina, T.A. 1998,
\mnras, 300, 287

\bibitem[Sazhin et al. (2001)]{Sazhin:Zharov:Kalinina:2001}
Sazhin, M.V., Zharov, V.E., \& Kalinina, T.A. 2001, \mnras, 323, 952

\bibitem[Schwarzschild (1894)]{Schwarzschild:1894}
Schwarzschild, K. 1894, Astr. Nachr., 136, No. 3246, 81

\bibitem[Shao (1998)]{SIM:1998}
Shao, M. 1998, in Astronomical Interferometry,
ed. R.D. Reasenberg, \procspie, 3350,  536

%\bibitem[Soffel (1989)]{Soffel:1989}
%Soffel, M. 1989,
%Relativity in Astrometry, Celestial Mechanics and Geodesy
%(Berlin: Springer)

\bibitem[Stumpff (1985)]{Stumpff:1985}
Stumpff, P. 1985, \aap, 144, 232

\bibitem[Walter et al. (1986)]{Walter:et:al:1986}
Walter, H. G., Mignard, F., Hering, R., Froeschl\'e, M., \&
Falin, J. L. 1986, Manuscripta Geodaetica, 11, 103

\bibitem[Weissman, McFadden \& Johnson (1999)]{Weissman:et:al:1999}
Weissman, P.R., McFadden, L.-A., Johnson, T.V. (eds.) 1999,
Encyclopedia of the Solar System
(San Diego: Academic Press)

\bibitem[Will (1993)]{Will:1993}
Will, C. M. 1993,
Theory and experiment in gravitational physics
(Cambridge: Cambridge University Press)

\bibitem[Zhdanov (1995)]{Zhdanov:1995}
Zhdanov, V.I. 1995, in Astronomical and Astrophysical Objectivities of
Sub-Milliarcsecond Optical Astrometry, ed. E. H\o{}g, \& P.K.
Seidelmann (Dordrecht: Kluwer), 295

\bibitem[Zhdanov \& Zhdanova (1995)]{Zhdanov:Zhdanova:1995}
Zhdanov, V.I., \& Zhdanova, V.V. 1995, \aap, 299, 321

\end{thebibliography}