An issue with the .coefficient() function

34 views
Skip to first unread message

baliza Eyo

unread,
Jun 25, 2017, 10:51:39 AM6/25/17
to sage-devel
Dear Sage developers,

Here is a quick question about the output of the .coefficient() for an SR object.
having set up the variables as follows

sage: var('x,y')
(x, y)

Shouldn't the output of the following commands be the same:

sage: ((x^2 - 2)^2 - y^2).coefficient(x^4)
0
sage: expand(((x^2 - 2)^2 - y^2)).coefficient(x^4)
1
sage: ((x^2 - 2)^2 - y^2).diff(x,4).subs(x==0)/factorial(4)
1

The last two outputs are correct but why is 0 the intended output for  ((x^2 - 2)^2 - y^2).coefficient(x^4)   ?
Thanks in advance,
Best regards,
Eyo,

Vincent Delecroix

unread,
Jun 25, 2017, 10:57:44 AM6/25/17
to sage-s...@googlegroups.com, sage-...@googlegroups.com
Dear Eyo,

We use several mailing lists. Please ask these kind of questions on
sage-support. Now the question is forwarded and continue the discussion
there.

Best
Vincent

Kwankyu

unread,
Jun 25, 2017, 2:59:54 PM6/25/17
to sage-support, sage-...@googlegroups.com
On 25/06/2017 16:51, baliza Eyo wrote:
> Dear Sage developers,
>
> Here is a quick question about the output of the .coefficient() for an SR
> object.
> having set up the variables as follows
>
> sage: var('x,y')
> (x, y)
>
> Shouldn't the output of the following commands be the same:
>
> sage: ((x^2 - 2)^2 - y^2).coefficient(x^4)
> 0
> sage: expand(((x^2 - 2)^2 - y^2)).coefficient(x^4)
> 1
> sage: ((x^2 - 2)^2 - y^2).diff(x,4).subs(x==0)/factorial(4)
> 1
>
> The last two outputs are correct but why is 0 the intended output for
>   ((x^2 - 2)^2 - y^2).coefficient(x^4)   ?

I agree that this is unintuitive, but this is a well-documented behavior. Check this out.

sage: f=((x^2 - 2)^2 - y^2)
sage: f.coefficient? 

Reply all
Reply to author
Forward
0 new messages