On 3/28/12 5:42 AM, Dan Drake wrote:
On Tue, 27 Mar 2012 at 11:21PM -0700, Eric Kangas wrote:
I have this long chain of terms with with many constant terms. I would like
to know if there is a way to separate the constant terms from the terms
with the variable I am trying to solve for with the solve function. So I
don't have to wait as long for the solve function to go through each
non-relevant term.
Some kind of .coeffs() call should work:
sage: x,y,z = var('x y z')
sage: foo = x*2*y + x*y*z + y*z + z + 1
sage: foo.coeffs(x)
[[y*z + z + 1, 0], [y*z + 2*y, 1]]
If y and z are constants, then the ", 0" element of the list
(coefficient of x^0) is the constant coefficient of "foo".
Or you could substitute in 0 for your variables. Then only the constant
terms are left!
Jason
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org