Open
Description
There is no reason why there should be different results:
sage: (x*(x*y+y^2)).coefficient(x)
y
sage: (x*(x*y+y^2)).coefficient(x,2)
0
sage: (x*(x*y+y^2)).expand().coefficient(x)
y^2
sage: (x*(x*y+y^2)).expand().coefficient(x,2)
y
This would also be unsurprising for Mma users, see #9505 comment:6
Maybe add keyword expand=True
.
Component: symbolics
Author: Ralf Stephan
Branch/Commit: u/rws/20824 @ 7ab049f
Issue created by migration from https://trac.sagemath.org/ticket/20824