| 1 | initial version |
You can "collect" terms for a symbolic variable, so if you temporarily replace sqrt(2) with a symbol, you're good to go:
sage: var('R')
R
sage: trm.expand().subs(sqrt(2)==R).collect(R).subs(R=sqrt(2))
sqrt(2)*(3*b + 2*c + d) + 3*a + c + 4*d
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.