First time here? Check out the FAQ!
answered 9 years ago
You can "collect" terms for a symbolic variable, so if you temporarily replace sqrt(2) with a symbol, you're good to go:
sqrt(2)
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