On 01/17/2012 04:54 AM, Jori Mantysalo wrote:
After saying

R.<t>  = PolynomialRing(QQ)

both of these works:

expand ( (t-(5-sqrt(7))) * (t-(5+sqrt(7))) )
expand ( (t-(5-sqrt(7))) * (t-(5+sqrt(7))) )

and I got t^2 - 10*t + 18 and t^2 - 4*t + 1 as expected. However,

expand ( (t-(2-sqrt(3))) * (t-(2+sqrt(3))) * (t-(5-sqrt(7))) * (t-(5+sqrt(7))) )

does not work in a similar way. If I put ".simplify_full()" at the end of
the expression, I got simplified answer.

What is logic behind this?


Sometimes expanding a product simplifies it, and sometimes it doesn't. This is the smallest example I could come up with.

  sage: a,b = var('a,b')
  sage: f = a*(a+b)
  sage: f.expand()
  a^2 + a*b
  sage: f.simplify()
  (a + b)*a

Furthermore, sage automatically simplifies some *really* easy expressions like,

 sage: 1*a + 2*a
 3*a

That's why you get an answer with three terms in the first two cases. It won't automatically combine square roots, though:

  sage: sqrt(2)*a + sqrt(3)*a
  sqrt(2)*a + sqrt(3)*a

So the "simplified" answer in the first two cases was just lucky. In general you have to call simplify() or full_simplify().

--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to