ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 08 Jun 2019 09:31:28 -0500Pretty print factorizations as fractionshttp://ask.sagemath.org/question/46864/pretty-print-factorizations-as-fractions/Hi all,
If I have an object whose factorization makes sense when expressed as a fraction, how do I get Sage to pretty print its factorization as a fraction instead of a product of factors? For example,
sage: R.<x> = PolynomialRing(QQ)
sage: f = (x - 1)^2 / (x + 1)
sage: f
(x^2 - 2*x + 1)/(x + 1)
sage: f.factor()
(x + 1)^-1 * (x - 1)^2
but ideally I would like some way to pretty print `f` as `(x - 1)^2/(x + 1)`.
Thanks,
Henryliu.henry.hlSat, 08 Jun 2019 09:31:28 -0500http://ask.sagemath.org/question/46864/Pretty print output in Jupyter notebookhttp://ask.sagemath.org/question/45481/pretty-print-output-in-jupyter-notebook/ <p>In order to provide meaningful results to my students in a Jupyter notebook, I would like to pretty print some output, including text, LaTeX and things computed by Sage. I have found that I could combine either <code>show</code> (or <code>pretty_print</code>) and <code>html</code>, or <code>show</code> and <code>LatexExpr</code>. For example,
either</p>
<pre><code>limit = r"\displaystyle\lim_{x\to0}\frac{\sin x}{x}="
value = lim(sin(x)/x, x=0)
show(html("Solucion: "+"${}={}$".format(limit,value)))
</code></pre>
<p>or, instead,</p>
<pre><code>limit = r"\displaystyle\lim_{x\to0}\frac{\sin x}{x}="
value = lim(sin(x)/x, x=0)
show("Solucion: ", LatexExpr(limit), value)
</code></pre>
<p>I would ask the following questions:</p>
<ol>
<li>Is there any reason to prefer one approach to the other?</li>
<li>If I replace <code>"Solucion"</code> by <code>"Solución"</code> (please note the accented <code>ó</code>), which is the correct way to write this Spanish word, in both approaches I get meaningless letters instead of the expected output. If I use <code>u"Solución"</code>, then Sage raises the error <code>'ascii' codec can't encode character u'\xf3' in position 6: ordinal not in range(128)</code>. Is there a way to use non-English characters?</li>
</ol>
I am using SageMath 8.5 on a MacBook Pro with macOS High Sierra. JuanjoSun, 17 Feb 2019 10:00:45 -0600http://ask.sagemath.org/question/45481/pretty_print in interact labelshttp://ask.sagemath.org/question/40772/pretty_print-in-interact-labels/I have written [the following interact](https://sagecell.sagemath.org/?z=eJyNUsFqGzEQvRv8D0NYsxJe0k0glwZBoQcfAnvx0XaWiXdii2olVdKmdkP-pcfmO_xjnY3txrSmVLBazdObeU8a-UApbWsftE1inVoj8s-MEKD3Ri8xaWehcdYSGIQnNNQFaAiyeaOjN7iNaWtoHru2fraqqsuX--fqBYWVGZcIu58R8MnpAIE4eo1k0-4VVgH9Wn_tqOUYkusSRTD8Rde2_PMYkibTI_8SujsIecemsjtWNAa5YO-PGRnsfvAiu8ylHA4-8Qkp4DINBw09Qi1Qaeu7VD-4jWAEO5PU1Yfr-01h8IGMukCxkReyqMpzRMbPwTdSfhwOgEefrXC_nqrUeUNiVsKjC6BBWwhoVyRKLi8X8kibjg9EFCf4RHnH7qOYVWWx3ymWzrig8gbDl1Ugsnmx5-jvpG7KQ-IfYpxdHe296f2-ZzWd6cUYhR5fyZP9dz_v1MUJYaIm46M1Ti1OWP9nMK7dNzE5BP7vt5idb_8ocvd56ts_v1Xz21HMsnz0dkDuXqKNmM6qxaUVsh-_AGdU70E=&lang=sage).
How cant I get the labels right? For instance, I'd rather have $N_0$ rather than N0.
Can I achieve this with pretty_print?
BostonThu, 25 Jan 2018 16:31:39 -0600http://ask.sagemath.org/question/40772/Groupring element in pretty_printhttp://ask.sagemath.org/question/35136/groupring-element-in-pretty_print/ I have the following code:
G37=GroupAlgebra(SymmetricGroup(3),GF(7))
M37=MatrixSpace(G37,2,2)
S3=SymmetricGroup(3).list()
@interact
def _(a11=input_grid(1,6, default = [1,2,0,0,0,0], label='$a_{11}$'),a12=input_grid(1,6, default = [0,1,2,2,3,3], label='$a_{12}$'),a21=input_grid(1,6, default = [0,3,4,2,3,4], label='$a_{21}$'),a22=input_grid(1,6, default = [0,1,1,0,0,0], label='$a_{22}$')):
A11=sum([G37(a11[0][k])*G37(S3[k]) for k in [0..5]])
A12=sum([G37(a12[0][k])*G37(S3[k]) for k in [0..5]])
A21=sum([G37(a21[0][k])*G37(S3[k]) for k in [0..5]])
A22=sum([G37(a22[0][k])*G37(S3[k]) for k in [0..5]])
pretty_print(html('$A=%s$'%latex(M37([A11,A12,A21,A22]))))
The first element $A_{11}$ appears as $+2(1,2)$ instead of $()+2(1,2).$ Is it possible to protect the groupring element $()$ somehow? Thanks for the answers in advance.castorWed, 12 Oct 2016 10:40:53 -0500http://ask.sagemath.org/question/35136/Redirecting the output of show() to a file?http://ask.sagemath.org/question/34675/redirecting-the-output-of-show-to-a-file/Consider the tree
t = Permutation([1, 3, 2, 6, 8, 9, 5, 7, 4]).increasing_tree().as_ordered_tree()
show(t)
The output is a TeX-tikzpicture. I want to post-process this
picture at the TeX level (for a motivation see my last question).
To do so I have to manually copy and paste the output in some
editor. It would be much easier if I could redirect the output
into a text file and proceed from this file.
Is it possible to do so?Peter LuschnyThu, 01 Sep 2016 03:47:53 -0500http://ask.sagemath.org/question/34675/IPython/Jupyter extensionshttp://ask.sagemath.org/question/26586/ipythonjupyter-extensions/I would like to be able to print code objects in a markdown cell without having to completely regenerate them in markdown code or copy/paste values. Would it be possible to install the [IPython notebook extensions](https://github.com/ipython-contrib/IPython-notebook-extensions) on the Sage Math Cloud?
I've made a public notebook [here](https://cloud.sagemath.com/projects/b8cc072a-0bd7-46df-bed6-4d857c87721b/files/Pretty%20printing.html) so that anyone can see exactly what my problem is. It's a fairly thorough description, but it boils down to wanting to print values with pretty units. I would be willing to allow others to edit the notebook to fiddle around with fixing it.wlp2Sat, 18 Apr 2015 01:29:48 -0500http://ask.sagemath.org/question/26586/Missing close bracehttp://ask.sagemath.org/question/25130/missing-close-brace/hi!
Im getting "Missing close brace" when I try to prettyprint an expression on sage cloud.
the expression Im trying to prettyprint using show() is the result of using solve() on an equation system and saving it in the variable "a", I can see the contents of "a" but I can't prettyprint it.
![image description](http://s21.postimg.org/t1hmpsdj9/AAAAAAA.jpg)
thanks!
EDIT:
show (a[0]) works great for showing the first element, but I still cant get the whole thing to show.
here is the code that produces the error
- f=4*(x^3-x/4)^3+4*x-4*(x^3-x/4)
- solve (f==0,x)
- show (solve (f==0,x))
here is a pic
![image description](http://s13.postimg.org/nsvspkjd1/AAAAAAA.jpg)martovThu, 04 Dec 2014 15:56:05 -0600http://ask.sagemath.org/question/25130/