\subsubsection{ General structure}

The \CompHEP~ symbolic output can be used for  further 
manipulation with the answer which was obtained by means of the 
built-in symbolic calculator. It  may be a summation of all diagrams to
the  common denominator expression, a symbolic integration of
answer, a representation of answer  as a function of special 
set of variables and so on. We have tried to present results in the form
which can be easily used for  different purposes.

All diagram contributions  for one  subprocess are stored in one 
file. The  subprocess ordering number is attached to  the file name. For
example, the {\it symb1.red} and {\it symb1.m}  files are generated  
to present the symbolic answer of the first subprocess in  the  \REDUCE~
\cite{REDUCE}  and \MATHEMATICA~ \cite{MATH}  format correspondingly. 

 The structure of the output  file way 
be described by the following scheme:
\begin{center}
{\small
\begin{tabular}{|c|} \hline
      Initial declarations; \\
      $initSum()$;\\
      Answer for the first diagram;\\
       $addToSum()$; \\
      Answer for the second diagram;\\
       $addToSum()$;\\   
      ~~~~...................\\
      ~~~~................... \\
      $finishSum()$; \\     
\hline
\end{tabular}
}
\end{center}


 {\it 'Initial declarations'} includes the  declaration of 
vector variables for momenta and the conservation law relations for them,
the declaration of independent parameters involved in calculation and
numerical values for them,
the declaration of constrained parameters and substitution rules for them,
and, at least, the  declaration of the process name.
 The momenta are named  
$p1,p2,p3,...$. They are  assigned to particles according 
to particle sequence in the process name.  The signs  of momenta are defined 
in such a way that the sum of momenta of incoming particles is equal 
to the sum of  momenta of outgoing particles. The list of substitutions
of numerical values for  independent  parameters is written in 
variable $parameters$. The list of substitutions
for the  constrained parameters   is stored in  variable $substitutions$.  
The lists of incoming and outgoing particles are stored in variables
$inParticles$ and $outParticles$ respectively.

  
\CompHEP~ writes subsequently  expressions for diagram  contributions 
and after any record it calls a  summation procedure $addToSum()$.
Just before and after summation the procedures $initSum()$ and $finishSum()$
are called.  These three procedures  must  be written  by the user and loaded in
advance. Such a construction of the output allows one  to use it for different 
purposes creating  appropriate  procedures.

Now we shall explain the structure of  diagram contribution.
It is started from a pseudo-graphic diagram image like in Fig.\ref{pseudo}.
After that  assignments for  $totFactor$, $numerator$, $denominator$
variables  follow: 
\begin{itemize}
\item[] $totFactor$ is a ration function depending on model parameters;
\item[] $numerator$ is a polynomial  of  model parameters and
momenta scalar products;
\item[] $denominator$ is presented as a  production of 
propagator denominators
$$ propDen(P,Mass,Width)\;, $$ 
where $P$,$Mass$,and $Width$ are momentum, mass, and width of corresponding
virtual particle. In the case  $Width=0$  $propDen$  must be defined as
$(Mass^2-P^2)$. The treatment of the $Width$ argument  can be arranged 
by  the user as he likes.

\end{itemize}
 In these terms the  diagram  contribution  to the squared matrix element 
may be expressed in the following way:

$$ totFactor \frac{ numerator}{  denominator}\;\;. $$

   
As it was mentioned above (Section \ref{sq_diagrams_menu}) the result obtained 
by summation of all diagrams 
must be symmetrized in the case  of identical outgoing particles. 
This work may be done by the $finishSum()$ procedure.

\subsubsection { Example: Summation of diagrams and symbolic integration 
by means of the  \REDUCE~  package}
\label{red-symb-int} 

 As an example we prepare some  summation programs for working with
\REDUCE~ output. They are: \\
\hspace*{5mm}$sum\_cd.red$ which presents squared matrix element  as a common denominator
expression;\\
\hspace*{5mm}$sum\_22.red$  which presents  squared matrix element as a sum of
pole terms;\\ 
\hspace*{5mm}$sum\_int.red$  which presents a symbolical expression for total cross
section.\\
The last two options are available  for \verb|2->2| type of processes only.
These files are stored in the $COMPHEP/test$ directory.
 
Let you  prepare the symbolic output {\it symb1.red}  for the Compton scattering
{\it A,e1 \verb|->| A,e1}  in the 
framework of QED model \footnote{In other \CompHEP models electron 
is massless.}  Launch the \REDUCE~ system from
within the {\it result} directory. The possible \REDUCE~ sessions are:\\
\begin{verbatim}
%1
  in"$COMPHEP/test/sum_cd.red"$  % loading the summation packege
  in"symb1.red"$                 % reading contributions of diagrams 
  sum;                           % writing the answer 

(32*ee**4*(2*p1.p2**4-4*p1.p2**3*p1.p3+3*p1.p2**2*p1.p3**2-2*p1.p2**2*p1.p3
*me**2-p1.p2*p1.p3**3 + 2*p1.p2*p1.p3**2*me**2 + p1.p3**2*me**4))
/(propden(-p1-p2,me,0)**2*propden(p2-p3,me,0)**2)$
\end{verbatim} 
\begin{verbatim}
%2
  in"$COMPHEP/test/sum_22.red"$  % loading the summation packege  
  in"symb1.red"$                 % reading contributions of diagrams
  sum;                           % writing the answer 
2*ee**4*(4*sp(me)**2*me**4 + 8*sp(me)*up(me)*me**4 + 4*sp(me)*me**2 +
sp(me)*t+ 4*up(me)**2*me**4 + 5*up(me)*me**2 - up(me)*s + 1)$
\end{verbatim}

Here $s=(p1+p2)^2;\; t=(p1-p3)^2;$ functions $sp,tp,up$ are defined by the 
following way
$$ sp(x)=1/(s-x^2);$$
$$ tp(x)=1/(t-x^2);$$
$$ up(x)=1/(1-u^2)\;\; where\;\; u=(p1-p4)^2 $$
\begin{verbatim}
%3
  in"$COMPHEP/test/sum_int.red"$ % loading the summation package  
  in"symb1.red"$                 % reading the contributions of diagrams
  sum;                           % writing answer for total cross section                   
(ee**4*(2*s**4*log(s/me**2) + s**4 - 12*s**3*log(s/me**2)*me**2 + 14*s**3*me**2 
- 6*s**2*log(s/me**2)*me**4 - 16*s**2*me**4 + 2*s*me**6 - me**8))/(16*s
**2*pi*(s**3 - 3*s**2*me**2 + 3*s*me**4 - me**6))$
\end{verbatim}

There are similar packages $sum\_cd.m$, $sum\_22.m$, and  $sum\_int.m$ 
for operation with the \MATHEMATICA~ output.

