Up | Next | Prev | PrevTail | Tail |
Authors: Fujio Kako and Masaaki Ito
In REDUCE, we can use the coeff operator which returns a list of coefficients of a polynomial with respect to specified variables. On the other hand, the coeff2 operator gives a polynomial in which each coefficient is replaced by special variables #1,#2,\(\cdots \). It is used with the same syntax as the coeff operator:
Example:
off allfac; f := (a+b)^2*x^2*y+(c+d)^2*x*y; f2 := coeff2(f,x,y); g := (2*c+d)*x^2+(3+a)*x*y^3; g2 := coeff2(g,x,y);
would result in the output
2 2 2 2 2 2 f := a *x *y + 2*a*b*x *y + b *x *y + c *x*y 2 + 2*c*d*x*y + d *x*y 2 f2 := #1*x *y + #2*x*y 3 2 2 3 g := a*x*y + 2*c*x + d*x + 3*x*y 2 3 g2 := #3*x + #4*x*y
If you want to retrieve the values of special variables #1,#2,\(\cdots \), we can use the operator nm. The syntax for this is:
It returns the value of the variable #n. For example, to get the value of #1 in the above, one could say:
nm(1);
yields the result
2 2 a + 2*a*b + b
It is also possible to evaluate an expression including special variables #1,#2,\(\cdots \) by using the eval2 operator. The syntax for this is:
Example:
coeff2(f2*g2,x,y); 4 3 4 3 2 4 #5*x *y + #6*x *y + #7*x *y + #8*x *y nm(8); #2*#4 eval2(ws); 2 2 2 2 a*c + 2*a*c*d + a*d + 3*c + 6*c*d + 3*d
The user may remove all values of special variables #1,#2,\(\cdots \) by the operator reset, in the form
reset( );
Up | Next | Prev | PrevTail | Front |