axiom-developer
[Top][All Lists]

## Re: [Axiom-developer] How can I get the constant term in a polynomial

 From: Martin Rubey Subject: Re: [Axiom-developer] How can I get the constant term in a polynomial Date: 18 Dec 2006 09:38:12 +0100 User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

```Francois Maltey <address@hidden> writes:

> I want to simplify sin ((a+1)*(b+%pi)) = sin (a*b + a*%pi + b + %pi)
>                 to - sin (a*b + a*%pi + b)
>
> I can get the coefficient of %pi in the numerator of the argument of sin x.
>
> MP ==>  SparseMultivariatePolynomial(R, K)
>  K ==> Kernel F
>  Z ==> Integer
>
>     kpi : K := retract(pi())@K   -- the constant %pi
>
>     coeffPi : MP -> Z
>     coeffPi x ==
>       R has retractIfCan : R -> Union(Integer,"failed") =>
>         ccz := retractIfCan (coefficient (p, kpi, 1))@Union(Z, "failed")
>         ccz case Integer => ccz::Integer
>       0
>
> In this example this coefficient is (a+1).
>
> I don't want the all coefficient a+1, but only the constant term, 1 in R.

So you want the constant term of a SparseMultivariatePolynomial(R, K), that is,
a polynomial with variables being in K an coefficients in R.

I guess you want to use

coefficient(p,0\$IndexedExponents(Symbol))

Martin

```