ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 03 Sep 2012 14:27:41 +0200Difference Between var(), QQ() and PolynomialRing()https://ask.sagemath.org/question/9289/difference-between-var-qq-and-polynomialring/I am rather new to Sage and am trying to understand the internals of Sage better. I encountered some confusion when reading through the reference manual as to the difference between the different ring constructs used in sage. The var() function is of course used to declare a variable for symbolic manipulation but when should one use QQ[] or PolynomialRing()? I ran into this issue with the convolution() function which requires variables within functions to be declared using QQ[] or Polynomial ring and will not work with var(). Why is this? Is QQ the default namespace? How do these namespaces relate to the symbolic ring used with var? Thank you for your help!Mon, 03 Sep 2012 03:21:54 +0200https://ask.sagemath.org/question/9289/difference-between-var-qq-and-polynomialring/Answer by Volker Braun for <p>I am rather new to Sage and am trying to understand the internals of Sage better. I encountered some confusion when reading through the reference manual as to the difference between the different ring constructs used in sage. The var() function is of course used to declare a variable for symbolic manipulation but when should one use QQ[] or PolynomialRing()? I ran into this issue with the convolution() function which requires variables within functions to be declared using QQ[] or Polynomial ring and will not work with var(). Why is this? Is QQ the default namespace? How do these namespaces relate to the symbolic ring used with var? Thank you for your help!</p>
https://ask.sagemath.org/question/9289/difference-between-var-qq-and-polynomialring/?answer=13995#post-id-13995`var` constructs symbolic ring (SR) variables:
sage: var('x')
sage: sin(x)
sin(x)
sage: x in SR
True
sage: x.parent()
Symbolic Ring
Polynomial rings are much better at working with polynomials, but nothing else:
sage: R.<x> = QQ[]
sage: x in PolynomialRing(QQ,1,'x')
True
sage: x.parent()
Univariate Polynomial Ring in x over Rational Field
Using a polynomial variable in a non-polynomial manner automatically converts it to the symbolic ring:
sage: type(x)
<type 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint'>
sage: type(sin(x))
<type 'sage.symbolic.expression.Expression'>
Mon, 03 Sep 2012 14:27:41 +0200https://ask.sagemath.org/question/9289/difference-between-var-qq-and-polynomialring/?answer=13995#post-id-13995