Re: [sage-support] Re: naive question

2020-03-09 Thread Fernando Q. Gouvea
Thanks. I was wondering why declaring the polynomial ring helped, but 
this helps me understand.


Fernando

On 3/7/2020 3:00 PM, Simon King wrote:

On 2020-03-07, Eric Gourgoulhon  wrote:

You should use simplify_full() instead of simplify():

Or you should rather use *polynomials* instead of general symbolic
variables, provided of course that all your expressions are multivariate
rational functions (which is the case here):


sage: var('s t')
(s, t)

sage: R. = QQ[]


sage: thirdroot = ((s^2 - 1)*t^2 - s^2 + 1)/(s^2 + 2*s*t + t^2)

sage: thirdroot = ((s^2 - 1)*t^2 - s^2 + 1)/(s^2 + 2*s*t + t^2)


sage: factor(thirdroot + 1)
(s*t + 1)^2/(s + t)^2

sage: factor(thirdroot + 1)
(s + t)^-2 * (s*t + 1)^2


sage: a = thirdroot + 1 - (s*t + 1)^2/(s+t)^2
sage: a
((s^2 - 1)*t^2 - s^2 + 1)/(s^2 + 2*s*t + t^2) - (s*t + 1)^2/(s + t)^2 + 1
sage: a.simplify_full()
0

sage: a = thirdroot + 1 - (s*t + 1)^2/(s+t)^2; a
0

That's because thirdroot is an element of the quotient field of a
polynomial ring, which does automatic simplifications (which in the
special context of polynomials is a lot easier than in the general
context of symbolic variables).

Best regards,
Simon


--
==
Fernando Q. Gouvea
Carter Professor of Mathematics
Colby College
Mayflower Hill 5836
Waterville, ME 04901
fqgou...@colby.edu http://www.colby.edu/~fqgouvea

Don't you feel more like you do now than you did when you came in?

--
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/67cbd162-b1ea-c733-e6b4-ed1379496e33%40colby.edu.


[sage-support] Re: naive question

2020-03-07 Thread Simon King
On 2020-03-07, Eric Gourgoulhon  wrote:
> You should use simplify_full() instead of simplify():

Or you should rather use *polynomials* instead of general symbolic
variables, provided of course that all your expressions are multivariate
rational functions (which is the case here):

> sage: var('s t')
> (s, t)

sage: R. = QQ[]

> sage: thirdroot = ((s^2 - 1)*t^2 - s^2 + 1)/(s^2 + 2*s*t + t^2)

sage: thirdroot = ((s^2 - 1)*t^2 - s^2 + 1)/(s^2 + 2*s*t + t^2)

> sage: factor(thirdroot + 1)
> (s*t + 1)^2/(s + t)^2

sage: factor(thirdroot + 1)
(s + t)^-2 * (s*t + 1)^2

> sage: a = thirdroot + 1 - (s*t + 1)^2/(s+t)^2
> sage: a
> ((s^2 - 1)*t^2 - s^2 + 1)/(s^2 + 2*s*t + t^2) - (s*t + 1)^2/(s + t)^2 + 1
> sage: a.simplify_full()
> 0

sage: a = thirdroot + 1 - (s*t + 1)^2/(s+t)^2; a
0

That's because thirdroot is an element of the quotient field of a
polynomial ring, which does automatic simplifications (which in the
special context of polynomials is a lot easier than in the general
context of symbolic variables).

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/r40ug5%241rii%241%40ciao.gmane.io.


[sage-support] Re: naive question

2020-03-07 Thread Eric Gourgoulhon
You should use simplify_full() instead of simplify():

sage: var('s t')
(s, t)
sage: thirdroot = ((s^2 - 1)*t^2 - s^2 + 1)/(s^2 + 2*s*t + t^2)
sage: factor(thirdroot + 1)
(s*t + 1)^2/(s + t)^2
sage: a = thirdroot + 1 - (s*t + 1)^2/(s+t)^2
sage: a
((s^2 - 1)*t^2 - s^2 + 1)/(s^2 + 2*s*t + t^2) - (s*t + 1)^2/(s + t)^2 + 1
sage: a.simplify_full()
0




-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/fc472c89-015a-46b6-a239-6f5a5bad5288%40googlegroups.com.