Ask Your Question

bpeacock's profile - activity

2018-09-28 10:51:31 -0500 received badge  Notable Question (source)
2017-08-09 12:02:20 -0500 received badge  Famous Question (source)
2017-08-09 12:02:20 -0500 received badge  Notable Question (source)
2017-08-09 12:02:20 -0500 received badge  Popular Question (source)
2016-12-10 06:42:14 -0500 received badge  Favorite Question (source)
2016-12-10 06:41:43 -0500 received badge  Popular Question (source)
2015-03-10 10:37:57 -0500 received badge  Student (source)
2013-07-10 21:58:42 -0500 received badge  Taxonomist
2013-01-08 19:45:27 -0500 commented answer latex Function Prevent Simplification

Thats a shame but it makes sense. I guess that would have to be added to the sage preparser. Thanks!

2013-01-08 19:41:30 -0500 marked best answer latex Function Prevent Simplification

Since you can do x.mul(1/x, hold=True), you can also do latex(x.mul(1/x, hold=True)).

I suppose you could also write the expression using LaTeX:

sage: LatexExpr(r"\frac{%s}{%s}" % (latex(x), latex(x)))
\frac{x}{x}
sage: LatexExpr(r"\frac{%s}{%s}" % (latex(factor(x^2+3*x + 2)), latex(x)))
\frac{{\left(x + 1\right)} {\left(x + 2\right)}}{x}

But in general, latex(foo) first computes foo, which means that typically it will get simplified, and then it computes its LaTeX representation. So I don't think there is a simple way to do what you want.

2013-01-08 17:42:24 -0500 asked a question latex Function Prevent Simplification

Hi, I am trying to use the latex function without the subject simplifying before it converting to LaTeX. This is similar to the hold=True for algebra functions. For example, I want latex(x/x) to return \frac{x}{x} rather than 1. Thanks so much!

2012-09-03 15:26:09 -0500 received badge  Scholar (source)
2012-09-03 15:26:09 -0500 marked best answer Difference Between var(), QQ() and PolynomialRing()

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'>
2012-09-02 20:21:54 -0500 asked a question 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!