Ask Your Question

bpeacock's profile - activity

2022-07-19 18:20:27 +0200 received badge  Famous Question (source)
2018-09-28 17:51:31 +0200 received badge  Notable Question (source)
2017-08-09 19:02:20 +0200 received badge  Famous Question (source)
2017-08-09 19:02:20 +0200 received badge  Popular Question (source)
2017-08-09 19:02:20 +0200 received badge  Notable Question (source)
2016-12-10 13:42:14 +0200 received badge  Favorite Question (source)
2016-12-10 13:41:43 +0200 received badge  Popular Question (source)
2015-03-10 16:37:57 +0200 received badge  Student (source)
2013-07-11 04:58:42 +0200 received badge  Taxonomist
2013-01-09 02:45:27 +0200 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-09 02:41:30 +0200 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)))
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-09 00:42:24 +0200 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 22:26:09 +0200 marked best answer Difference Between var(), QQ() and PolynomialRing()

var constructs symbolic ring (SR) variables:

sage: var('x')
sage: sin(x)
sage: x in SR
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')
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-03 22:26:09 +0200 received badge  Scholar (source)
2012-09-03 03:21:54 +0200 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!