1%
2% Redistribution and use in source and binary forms, with or without
3% modification, are permitted provided that the following conditions are met:
4%
5%    * Redistributions of source code must retain the relevant copyright
6%      notice, this list of conditions and the following disclaimer.
7%    * Redistributions in binary form must reproduce the above copyright
8%      notice, this list of conditions and the following disclaimer in the
9%      documentation and/or other materials provided with the distribution.
10%
11% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
13% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
14% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNERS OR
15% CONTRIBUTORS
16% BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22% POSSIBILITY OF SUCH DAMAGE.
23%
24% 2020.02.27     M. Ito
25
26%\textbf{COEFF2 Package} \quad ( \textsf{COEFF2, NM, EVAL2, RESET} )\\[\baselineskip]
27\ttindextype{COEFF2}{operator}
28\ttindextype{NM}{operator}
29\ttindextype{EVAL2}{operator}
30\ttindextype{RESET}{operator}
31
32In \REDUCE,  we can use the \f{COEFF} operator which returns a list of coefficients of a polynomial
33with respect to  specified variables.
34On the other hand, the \f{COEFF2} operator gives a polynomial in which each coefficient is replaced by
35special variables \verb|#1,#2|,$\cdots$. It is used with the same syntax as the \f{COEFF} operator:
36\begin{syntax}
37  \texttt{COEFF2(}\meta{EXPRN:polynomial},\,\meta{VAR:kernel}\texttt{)}\,:\,\textit{algebraic}
38\end{syntax}
39\textit{Example:}
40\begin{verbatim}
41off allfac;
42f := (a+b)^2*x^2*y+(c+d)^2*x*y;
43f2 := coeff2(f,x,y);
44g := (2*c+d)*x^2+(3+a)*x*y^3;
45g2 := coeff2(g,x,y);
46\end{verbatim}
47would result in the output
48\begin{verbatim}
49      2  2            2      2  2      2                    2
50f := a *x *y + 2*a*b*x *y + b *x *y + c *x*y + 2*c*d*x*y + d *x*y
51
52          2
53f2 := #1*x *y + #2*x*y
54
55          3        2      2        3
56g := a*x*y  + 2*c*x  + d*x  + 3*x*y
57
58          2         3
59g2 := #3*x  + #4*x*y
60\end{verbatim}
61If you want to retrieve the values of  special variables \verb|#1,#2|,$\cdots$,
62we can use the command \f{NM}. The syntax for this is:
63\begin{syntax}
64  \texttt{NM(}\meta{N:integer}\texttt{)}\,:\,\textit{algebraic}
65\end{syntax}
66It returns the value of the variable \verb|#n|. For example, to get the value of
67\verb|#1| in the above, one could say:
68\begin{verbatim}
69nm(1);
70\end{verbatim}
71yields the result
72\begin{verbatim}
73 2            2
74a  + 2*a*b + b
75\end{verbatim}
76It is also possible to evaluate an expression including  special variables \verb|#1,#2,|$\cdots$
77by \f{EVAL2} operator.
78The syntax for this is:
79\begin{syntax}
80  \texttt{EVAL2(}\meta{EXPRN:rational}\texttt{)}\,:\,\textit{algebraic}
81\end{syntax}
82\textit{Example:}
83\begin{verbatim}
84coeff2(f2*g2,x,y);
85
86    4         3  4       3         2  4
87#5*x *y + #6*x *y  + #7*x *y + #8*x *y
88
89nm(8);
90
91#2*#4
92
93eval2(ws);
94
95   2                2      2              2
96a*c  + 2*a*c*d + a*d  + 3*c  + 6*c*d + 3*d
97
98\end{verbatim}
99The user may remove all values of special variables \verb|#1,#2|,$\cdots$
100by the command \f{RESET}, in the form
101\begin{verbatim}
102       RESET( );
103\end{verbatim}
104
105