Ask Your Question

Michael's profile - activity

2016-01-03 04:33:31 -0600 received badge  Famous Question (source)
2013-12-04 08:39:42 -0600 received badge  Notable Question (source)
2013-07-08 11:58:24 -0600 received badge  Famous Question (source)
2013-01-29 03:46:56 -0600 received badge  Popular Question (source)
2012-12-28 22:59:04 -0600 received badge  Notable Question (source)
2012-09-19 12:01:24 -0600 received badge  Popular Question (source)
2012-01-05 16:16:56 -0600 received badge  Good Question (source)
2011-12-27 06:39:26 -0600 received badge  Nice Question (source)
2011-12-26 22:40:15 -0600 commented answer Can I add mathematical formulas to a plot?

Thanks, this is the kind of solution I was hoping for.

2011-12-26 22:39:50 -0600 marked best answer Can I add mathematical formulas to a plot?

Shashank told you how to do it in matplotlib (which comes with Sage) - matplotlib allows you a lot of control over your plots (I often use it for this reason), but as you can see, it involves a fair bit of boilerplate compared to Sage's plotting.

If you want to add a formula to a Sage plot, then you can just use latex inside dollar signs, like you would in a .tex document:

text(r"Here's a formula $\frac{\sqrt{3}}{2}$ and some text",(1,2))

Here the r" is necessary due to all the slashes in the string–if you don't include the r then you'll have to escape each of the slashes (check out the python String documentation for more info on that).

2011-12-26 22:39:46 -0600 commented answer Can I add mathematical formulas to a plot?

Thanks for this example, i'll need some time though to learn what all the commands do.

2011-12-26 10:29:35 -0600 received badge  Student (source)
2011-12-26 10:11:26 -0600 asked a question Can I add mathematical formulas to a plot?

I know that using

text("Sage is really neat!!",(1,2))

one can easily add text to a plot in Sage. But searching the documentation I couldn't find a way to add a formula, say $\frac{1}{\sqrt{x^2-1}}$.

So is there a way to add a formula to a plot?

Ideally using LaTeX to enter the formula.

2011-07-01 05:40:12 -0600 marked best answer How to give latex names to generators of polynomial rings?

First of all, when you define a_ij=var('a_ij') then you define symbolic variables. But when you later do (with inject_on()) PolynomialRing(QQ,a_ij), then a_ij becomes a generator of a polynomial ring.

It is a very common mistake to confuse these two very different objects, and I recommend that you carefully decide whether you want to work with polynomials (i.e., you have a polynomial ring, ideals, want to compute Gröbner bases and those things) or with symbolic expressions (they may happen to look like a polynomial, but provide largely different features).

In particular, since a_ij has completely changed its meaning, it is no surprise that the latex name has gone.

You could do:

sage: R.<a_12,a_23> = QQ[]  # you don't need inject_on()
sage: type(a_12)  # It is not a symbolic variable!
<type 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>
sage: latex(a_12)  # This is not how you like it
a_{12}
sage: R._latex_names  # This is where the names are stored
['a_{12}', 'a_{23}']
sage: R._latex_names = ['a_{1,2}','a_{2,3}'] # Override it...
sage: latex(a_12)  # ... and enjoy
a_{1,2}

I think it is a hack, and there should be a method, say, R.set_latex_names(), but unfortunately there isn't, yet.

2011-07-01 05:40:12 -0600 received badge  Scholar (source)
2011-06-30 06:37:34 -0600 commented answer How to give latex names to generators of polynomial rings?

Thanks! That seems to work. Indeed there are several things I don't quite understand about variables and how they are handled and accessed. I knew that there was a difference between symbolic variables and generators of a polynomial ring. So in my example the symbolic variable was redefined to be a generator of a polynomial ring and got lost? Anyway I do indeed need Groebner bases so symbolic variables should not be of interest in my situation.

2011-06-30 06:26:41 -0600 received badge  Supporter (source)
2011-06-30 05:19:58 -0600 received badge  Editor (source)
2011-06-30 05:18:10 -0600 asked a question How to give latex names to generators of polynomial rings?

Apologies if I don't use the right terminology in my question. I'm fairly new to Sage and programming.

The question is basically in the title but here are more details:

Ideally I would like to create a multivariate polynomial ring with generators indexed by multiindices. As far as I understand this is not directly supported at the moment, although I've found a useful workaround here.

What I'm missing though is the ability to display these generators correctly in LaTex (say as a_{i,j}). I know that one can assign latex names to symbolic variables with the command

sage: a_ij=var('a_ij', latex_name="a_{i,j}");

sage: latex(a_ij);

a_{i,j}

And I've tried putting this before the definition of my polynomial ring. But as soon as I declare the polynomial ring the latex name I assigned seems to be forgotten:

sage: inject_on();

sage: PolynomialRing(QQ,a_ij)

sage: latex(a_ij);

a_{\mbox{ij}}

So:

Question: How can I define a multivariate polynomial ring in Sage and assign my preferred latex names to its generators?