Ask Your Question

Michael's profile - activity

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

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

2011-12-27 05:39:50 +0200 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-27 05:39:46 +0200 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 17:29:35 +0200 received badge  Student (source)
2011-12-26 17:11:26 +0200 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 12:40:12 +0200 received badge  Scholar (source)
2011-07-01 12:40:12 +0200 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-06-30 13:37:34 +0200 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 13:26:41 +0200 received badge  Supporter (source)
2011-06-30 12:19:58 +0200 received badge  Editor (source)
2011-06-30 12:18:10 +0200 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?