ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 17 Oct 2020 17:00:38 -0500%display latex vs. ipywidgetshttps://ask.sagemath.org/question/53950/display-latex-vs-ipywidgets/This is part informational and part a question of style
In Sage Manifolds, `%display latex` is set to produce "pretty" output like thus
%display plain
var('a, g')
display(sqrt(a + g))
%display latex
sqrt(a + g)
which everybody knows, but a more insidious thing is that it breaks `ipywidgets.Hbox()` "display".
I did a hack in this code below; but does anybody know of a more elegant (re. automatic) means.
This is a little long but illustrates what is lost. Try changing `%display` lines at the bottom.
%display latex # Just to copy the problem in
import matplotlib.pyplot as plt
from IPython.display import display, HTML
import ipywidgets
# Save
file_name = 'rings.html'
save_desc = 'save as' + file_name
save_box = ipywidgets.Checkbox(False, description=save_desc)
# Red ring
red_ring = Horizon()
red_box=red_ring.box(desc='red ring')
red_ring.color = 'red'
red_ring.radius =2
# Black ring
black_ring = Horizon()
black_box = black_ring.box(desc='black ring')
black_ring.color = 'black'
black_ring.radius = 3
# Green ring
green_ring = Horizon()
green_box = green_ring.box(desc='green ring')
green_ring.color = 'green'
green_ring.radius = 4
ui = ipywidgets.HBox([red_box, black_box, green_box, save_box])
def f(red, black, green, save_f):
global plt_obj
plt_obj = sphere((1, 0, 0), .6)
if red:
plt_obj += red_ring.gobject()
if black:
plt_obj += black_ring.gobject()
if green:
plt_obj += green_ring.gobject()
if save_f:
save(plt_obj,file_name)
show(plt_obj, viewer='threejs')
out_show = ipywidgets.interactive_output(f, {'red': red_box,
'black': black_box,
'green': green_box,
'save_f' : save_box})
%display plain
display(ui)
display(out_show)
%display latexrrogersSat, 17 Oct 2020 17:00:38 -0500https://ask.sagemath.org/question/53950/Can attributes of sage classes be changed?https://ask.sagemath.org/question/53892/can-attributes-of-sage-classes-be-changed/ I want to change the way vectors are rendered in sagetex. For example, consider `v = vector([1, 2, 3])`. In sagetex, the command `$v=\sage{v}$` renders as
$$
v=(1, 2, 3)
$$
Instead, I want my vectors to take the form
$$
v=\left[\begin{array}{rrr}1&2&3\end{array}\right]^\intercal
$$
I thought I could do this by resetting the `_latex_` method of the `sage.modules.free_module_element.FreeModuleElement` class as follows.
def my_vector_latex(self):
return matrix(v)._latex_() + r'^\intercal'
setattr(sage.modules.free_module_element.FreeModuleElement, '_latex_', my_vector_latex)
However, this code throws the following error:
TypeError: can't set attributes of built-in/extension type 'sage.modules.free_module_element.FreeModuleElement'
So, it looks like I can't modify the methods of `FreeModuleElement` in this way. Is there anything else I could do?more_weightTue, 13 Oct 2020 12:37:51 -0500https://ask.sagemath.org/question/53892/Cocalc: change texmf.cnf filehttps://ask.sagemath.org/question/53411/cocalc-change-texmfcnf-file/ I'm trying to use `sagetex` to plot 3d graphics in LaTeX. I can get the basic plot to work but there isn't enough detail. When I try to create more points in my plot I get the message: "! Unable to read an entire line---bufsize=200000.
Please increase buf_size in texmf.cnf.". I found a texmf.cnf file on my system, made a copy of it with a modification of the bufsize to read "buf_size = 1000000" and uploaded it to my Cocalc project. Following [this](https://doc.cocalc.com/latex-faq.html?highlight=texmf#setup-texmf-in-a-project) FAQ page I created `~/texmf/tex/latex/local` and moved my `texmf.cnf` file there, When that didn't work, I tried `texhash ~/texmf` as suggested. However, I still get the message "! Unable to read an entire line---bufsize=200000. Please increase buf_size in texmf.cnf."
How do I change the bufsize on Cocalc? Are there any guidelines on a reasonable `buf_size` value to increase to?dazedANDconfusedFri, 11 Sep 2020 20:22:56 -0500https://ask.sagemath.org/question/53411/Latex (?)--Riemann tensor overflowhttps://ask.sagemath.org/question/53283/latex-riemann-tensor-overflow/While running Kerr_Schild.ipynb
- https://github.com/egourgoulhon/BHLectures/blob/master/sage/Kerr_Schild.ipynb
I get a bad output; not necessarily incorrect. I copied the TeX to a LaTeX GUI editor and it looks right.
When the last expression is evaluated it outputs TeX instead of LaTeX image. It is very long so it might just be a converter problem; that I can ignore. After the leadin the expression:
g.riemann().display()
Well I can't attach a trimmed file but I can provide a Dropbox link if needed.
The above expression was added just after the "Kerr Metric" paragraph; about line 13.
Is this my machine or LaTeX or Jupyter ?rrogersThu, 03 Sep 2020 16:45:04 -0500https://ask.sagemath.org/question/53283/Latexing, showing or viewing a held integral triggers its evaluation ???https://ask.sagemath.org/question/52922/latexing-showing-or-viewing-a-held-integral-triggers-its-evaluation/*Note : for once, this will be cross-posted on [sage-support](https://groups.google.com/forum/#!forum/sage-support) for ticket advice...*
Exploring [this question](https://ask.sagemath.org/question/52913/error-during-integration-not-of-type-unsigned-byte-15/) led me to discover what I think is a serious bug : it seems that `latex`ing an expression *containing* a held (= unevaluated) integral triggers the latter's evaluation ; ditto for `view`ing or `show`ing...
Minimal case:
sage: Ig=sin(x)
sage: It=Ig.integrate(x,-pi,pi,hold=True)
sage: Cs=1/(2*pi)
sage: latex(It)
\int_{-\pi}^{\pi} \sin\left(x\right)\,{d x}
So far, so good. But :
sage: Ex=Cs*It
sage: Ex
1/2*integrate(sin(x), x, -pi, pi)/pi
sage: latex(Ex)
\frac{0}{2 \, \pi}
Aaaarghh ! And, of course :
sage: show(Ex)
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{0}{2 \, \pi}
And `view(Ex` proudly displays this crap...
IMHO, this is a serious bug, entailing a risk of inadvertently triggering long, impossible or never ending computations.
Advice ?
**EDIT :** On [Cocalc](https://cocalc.com/projects/d9f9cc53-525c-4d92-a0a7-bc5941b8c734/files/?session=default), I have checked that the problem can be reproduced on all available Sage kernels back to 8.2.
Looks more like an error from me, rather than a bug...
Suggestions most welcome !
**EDIT :** One more data point: calling `latex` (or `show` or `view`) on such an expression containing a held integral **in a `hold` context** gives a `RecursionError`.
HTH,Emmanuel CharpentierSun, 09 Aug 2020 08:49:52 -0500https://ask.sagemath.org/question/52922/Problems with SageTex on MacOShttps://ask.sagemath.org/question/52612/problems-with-sagetex-on-macos/I have follow the instructions according with the sage tutorial guide for install SageTex and for "LaTex to know Sage", to being able to use SageTex on MacOS, but although it's recognize the sage.sty file when I compile a document on each part of sage it displays "??", I have no more ideas what to do, I have use a lot of differents versions of Sage but no one works.emaspWed, 22 Jul 2020 02:01:02 -0500https://ask.sagemath.org/question/52612/how to render a latex string in a notebook cellhttps://ask.sagemath.org/question/52357/how-to-render-a-latex-string-in-a-notebook-cell/Say we have a string variable `s = "some context: $x = 3$"`. The string s is rather simple latex, but is not just an equation. I would like to display the typeset version of `s` in a notebook cell, without having to retype the string by hand in the cell. Thanks for any help.jbaxterMon, 06 Jul 2020 10:03:24 -0500https://ask.sagemath.org/question/52357/Strange Error Message when Plotting with a LaTeX Legendhttps://ask.sagemath.org/question/52276/strange-error-message-when-plotting-with-a-latex-legend/The following code is from the 1st edition of my textbook, *Sage for Undergraduates*. It is producing some extremely unexpected errors (technically, deprication warnings). Something about an invalid escape sequence, `\i`, which I'm not using.
Can someone explain how I should change my code, so that these warnings do not appear?
Code:
`P1= text('$\int_0^2 \sqrt{x} \, dx$', (0.5, 1.1), fontsize=20)`
`P2= plot( sqrt(x), 0, 2, fill=True)`
`P= P1 + P2`
`P.show()`
Warning:
`<input>:1: DeprecationWarning: invalid escape sequence \i`
Quick Link:
https://sagecell.sagemath.org/?z=eJwVy8EKAiEURuF90Dv8i4FREtELLe87uGgptclIkLHGG0nRu-fszuI7wTMkdVHzFPMiF3cmxPZc5dt_iAbXPs0GytmjgbdeG9zqIi1_EpPT-10gxqNUUdgm1QdwBjRYLoVP6yttiBE8Dgg02rZ7fSv9B0vRIXA=&lang=sage&interacts=eJyLjgUAARUAuQ==Gregory BardTue, 30 Jun 2020 18:28:17 -0500https://ask.sagemath.org/question/52276/displaying results in latex fontshttps://ask.sagemath.org/question/51731/displaying-results-in-latex-fonts/ Is there way to display results in latex fonts? Let me explain what I mean by that. Let's say I have the following expression
(y3^3)*(y2^2)*(y1^2)
I want to see the expression above in the format $y_3^3y_2^2y_1^2$.
Is there a way to do this?slartibartfastWed, 03 Jun 2020 12:33:53 -0500https://ask.sagemath.org/question/51731/Latex and SageMathhttps://ask.sagemath.org/question/51380/latex-and-sagemath/ I donot know how to exactly state my question. I gonna give an example.
Step 1. Type in A=matrix([[1,-3,-4,3],[-4,6,-2,3],[-3,7,6,-4]])
Step 2. latex(A) gives the latex code for this matrix.
My question is that given a latex code, is there a way to converts to SageMath code?
I am new to SageMath. As an instructor of math for 5 years, I have many resources prepared in latex code.
So I really wanna converts them to SageMath instead of type it again.
Thank you in advance.tanyanlanMon, 11 May 2020 20:31:27 -0500https://ask.sagemath.org/question/51380/Escape characters for LaTeXhttps://ask.sagemath.org/question/51267/escape-characters-for-latex/I am using SageTeX and LaTeX to produce several variations of an exam, with a script that makes several iterations. I do this:
var('x, y, z')
v = vector([x, y, z])
a = vector([1, -2, -1])
These will change from one iteration to the next.
sortie = str(latex(a.dot_product(v)))
This leads to
x - 2 \\, y - z
which is correct, and I would like to turn into
\bbm{x} -2 \\, \bbm{y} - \bbm{z}
for the LaTeX processing so that `x`, `y` and `z` are shown like vectors.
Suggestions?JCMon, 04 May 2020 11:24:30 -0500https://ask.sagemath.org/question/51267/Keep getting ?? as output instead of the desried sage output in sageexamplehttps://ask.sagemath.org/question/50731/keep-getting-as-output-instead-of-the-desried-sage-output-in-sageexample/Hi!
So a total beginner in sage here so please try to refrain from suggesting too technical things here.
I'm trying to have some sage code results show in my tex file. After reading some parts of sage tutorial in example.pdf, I made another small tex file with
>
\documentclass{article}
\usepackage{sagetex}
\begin{document}
\begin{sageexample}
sage : E = EllipticCurve([0,3])
sage : E.discriminant()
\end{sageexample}
\end{document}
Ran this tex file, then associated example.sagetex.sage file in terminal, then ran tex file again but all I keep getting is ?? Instead of the desired output.
What am I missing or doing wrong?
The first eror latex suggested is - Reference '@sageinline0' on page 1 undefined on input line 6.
Package sagetex warning: there were undefined Sage formulas and/or plots.
Run Sage on example.sagetex.sage, and then run LaTeX on example.tex again.
But what should I do?
Thanks you.
Edit: Sorry for not embedding the minimal working example right, I'm on mobile and new to this site so don't know exactly how to do that yet. Would appreciate pointers on that as well if possible.ShreyaMon, 13 Apr 2020 12:27:52 -0500https://ask.sagemath.org/question/50731/How to show sage code results in LaTeX file and do other computations?https://ask.sagemath.org/question/50716/how-to-show-sage-code-results-in-latex-file-and-do-other-computations/Hi!
I am new to Sage (just installed it a few days ago) so I apologise if this question is too basic for this site. But since I'm really stuck and have no other platform to get help, I'll go ahead with my query anyway.
1. am writing a LaTeX document (on elliptic curves) and I wanted to do some related computations. Now I know how to embed the sage code in Latex file (you use sageblock) but I also want to show the results of those codes (like listing torsion points automatically as sage code output, the way we see it) in my LaTeX file. How do I do this?
2. Next, I saw someone's thesis here: 1812.10415 (can't post links yet, but googling this number gives that pdf) (page 68). They have shown the results of two descent like, computed the bounds on the ranks of quotients $E'(\mathbb{Q})/\phi(E(\mathbb{Q})$, $E(\mathbb{Q})/2E(\mathbb{Q})$, etc. and I couldn't find the codes to do the same in the Sage manual: Elliptic Curves on Rational Numbers. They have not only shown what sage codes they typed (which I didn't understand) but have also embedded their results in their latex file. How do I go on about doing the same?
I would really appreciate any kind of useful comments or answers.
Thank you.
Edit: my system is Ubuntu 14.04 and I use sage either in terminal or jypyter notebook.ShreyaMon, 13 Apr 2020 01:19:36 -0500https://ask.sagemath.org/question/50716/Getting LaTeX code from Sage when running %display latexhttps://ask.sagemath.org/question/50107/getting-latex-code-from-sage-when-running-display-latex/I typically use
%display latex
at the beginning of all of my worksheets, so that the equations are rendered in LaTeX (when using .display(), for example). However, now I want to copy some of these equations into a LaTeX document, and I can't figure out how to "revert" them back to code. All my view(eq), print(eq), latex(eq.display()) all seem to spit out the rendered tex, or sometimes information about the object, like "rank 2 tensor g".
Is there a way I can do this without removing the display command at the beginning and re-running the sheet?
EDIT: Maybe more info is needed. I'm running Jupyter notebooks, Sage 8.7 on a linux machine. I'm pretty sure I used the Ubuntu binaries in this case to install.thethinkerFri, 28 Feb 2020 11:40:02 -0600https://ask.sagemath.org/question/50107/Can I make MathJax output centered in the notebook?https://ask.sagemath.org/question/50002/can-i-make-mathjax-output-centered-in-the-notebook/ My problem is the same one described here:
[Equations in notebook jump from centered to L aligned upon rendering](https://github.com/ipython/ipython/issues/7827)
and
[Centered equations become left aligned if displayed through the markdown display hook](https://github.com/ipython/ipython/issues/11159)
When I use @interact on something that outputs latex in the notebook, the constant jumping to the left is very annoying and distracting.
E.g.:
@interact
def myfunc(n = slider(1,10)):
P = matrix([[1,2,n], [2,2,3]])
show(P)
Is there any way I can control the MathJax rendering in the notebook? Can I perhaps set it to render in the center so I don't have to deal with the jumping?
ThankseodThu, 20 Feb 2020 06:40:07 -0600https://ask.sagemath.org/question/50002/Why doesn't show() render latex properly?https://ask.sagemath.org/question/49980/why-doesnt-show-render-latex-properly/The following code:
import numpy as np
P = np.matrix('0 0 20 20; 0 20 20 0')
show(P)
Gives me the output
[[πΆπΆπΈπΆπΈπΆ]
[πΆπΈπΆπΈπΆπΆ]]
In old sage, I guess around 6.0 or something, the show() command would render a proper latex matrix. I.e like you would see in a mathematics textbook.
Is there any way I can get this functionality back?
Thanks.
Edit: I'm using Sage 9.0 v 0.6.0 on Windows.eodWed, 19 Feb 2020 06:25:25 -0600https://ask.sagemath.org/question/49980/How to print trailing spaces?https://ask.sagemath.org/question/49446/how-to-print-trailing-spaces/Pretty_Print / show seems to delete trailing spaces:
<pre>
reset()
var('x t')
Psi = function('Psi')(x, t)
V = function('V')(x)
show('Plug ', Psi, ', ', diff(Psi, t), ', ', diff(Psi, x, x), ' into ', V)
</pre>
See after "Plug" and after "into" (screenshot taken from CoCalc Jupyter Sage 8.9 Kernel):
![image description](/upfiles/15785031816932108.png)
bsoWed, 08 Jan 2020 11:07:11 -0600https://ask.sagemath.org/question/49446/SageTeX-Output: Possible simplification soughthttps://ask.sagemath.org/question/49374/sagetex-output-possible-simplification-sought/I created a minimal example for SageTeX:
x = 420 # Denominator
MyRange = 222
M = []
for n in range (1,MyRange):
if x == denominator(n/x):
M.append('$' + latex(n/x).replace(' ','') + '$')
else:
M.append('$' + '\\frac{' + "{}".format(n) + '}{' + "{}".format(x) + '}=' + latex(n/x).replace(' ','') + '$')
MyOut = ', '.join(M)
print(MyOut)
This gives:
![image description](https://matheplanet.de/matheplanet/nuke/html/uploads/b/50970_7_56555555.png)
It works! Just for interest, I wonder: does the 2nd else-output <br>
`M.append('$' + '\\frac{' + "{}".format(n) + '}{' + "{}".format(x) + '}=' + latex(n/x).replace(' ','') + '$')` <br>
really have to be so complicated or is there an easier way?
β¬dit: My SageTeX-MWE is:
\documentclass{article}
\usepackage{amsmath, amssymb, amsfonts}
\usepackage{sagetex}
\begin{document}
\section{In}
\begin{sageblock}
x = 420 # Denominator
MyRange = 222
M = []
for n in range (1,MyRange):
if x == denominator(n/x):
M.append('$' + latex(n/x).replace(' ','') + '$')
else:
M.append('$' + '\\frac{' + "{}".format(n) + '}{' + "{}".format(x) + '}=' + latex(n/x).replace(' ','') + '$')
MyOut = ', '.join(M)
#print MyOut
\end{sageblock}
\section{Out}
\baselineskip16pt \sagestr{MyOut}
\end{document}geroyxSun, 05 Jan 2020 09:32:29 -0600https://ask.sagemath.org/question/49374/LaTeX Output: How to replace Brackets and add Dollarshttps://ask.sagemath.org/question/49351/latex-output-how-to-replace-brackets-and-add-dollars/I have
x = 1
data = [x/n for n in range (1,4)]
M = latex(data)
print M
print M.replace('\left[', '$').replace(', ', '$, ').replace('\right]', '$')
Out Actual:
\left[1, \frac{1}{2}, $\frac{1}{3}$ \right]
$1$, \frac{1}{2}, $\frac{1}{3}$\right]
But I need:
Out Target:
$1$, $\frac{1}{2}$, $\frac{1}{3}$geroyxSat, 04 Jan 2020 08:58:53 -0600https://ask.sagemath.org/question/49351/The function "view(" doesn't seem to work with jupyter notebookhttps://ask.sagemath.org/question/49209/the-function-view-doesnt-seem-to-work-with-jupyter-notebook/I'm sorry if the question was already answered somewhere, but I did not find out an answer by myself:
In the "old" sagemath notebooks, there was a function "view" to display latex that MathJax cannot display. For instance the sage documentation proposes the following:
from sage.graphs.graph_latex import setup_latex_preamble
setup_latex_preamble()
latex.engine('pdflatex')
latex.add_to_mathjax_avoid_list('tikzpicture')
view(graphs.CompleteGraph(4))
* In the "old" sage notebook, this produces a png version of a graph (compiled from latex), which is inserted into the output of the cell
* In the Jupyter netbook, by contrast, it opens a pdf version of the graph into an external window.
Is there some way to obtain, in the Jupyter notebook, the same behaviour as in the "old netbook" ?
ThanksSebastienThu, 26 Dec 2019 08:54:13 -0600https://ask.sagemath.org/question/49209/latex problem using result obtained from Fricas integratehttps://ask.sagemath.org/question/49232/latex-problem-using-result-obtained-from-fricas-integrate/sagemath 8.9.
I do not remember if I mentioned this before or not. I googled and did not find anything. If this is already mentioned and known issue, I am sorry and please feel free to close this.
Fricas returns `li` in one result, which gets translated `log_integral` by sagemath. Which is OK. But the latex translation still uses `log_integral`.
since in Latex, the _ is important , it looks bad when typeset.
I asked about this in the tex forum, and they say that using underscore in math names is not recommended.
So I think the translation of `log_integral` to latex should be changed to `\li` or `\logintegral`. Then one can always make it a math operator using `\DeclareMathOperator{\li}{log\_integral}` but one can't do this, if the math name itself has `_` in it. Latex gives an error.
In non-latex, it is ok to use `log_integral`.
Here is an example.
sage: var('t')
t
sage: result=integrate(1/log(t)^2,t, algorithm="fricas")
sage: result
(log(t)*log_integral(t) - t)/log(t)
sage: latex(result)
\frac{\log\left(t\right) log_integral\left(t\right) - t}{\log\left(t\right)}
When compiling the above latex, it shows as
\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}
$\frac{\log\left(t\right) log_integral\left(t\right) - t}{\log\left(t\right)}$
\end{document}
![image description](/upfiles/15774753062062015.png)
Using Fricas directly
(3) -> result:=integrate(1/log(t)^2,t)
li(t)log(t) - t
(3) ---------------
log(t)
Type: Union(Expression(Integer),...)
(4) -> latex(result)
(4)
"{{{li \left( {t} \right)} \ {\log \left( {t} \right)}} -t} \over {\log \lef
t( {t} \right)}"
Type: String
(5) ->
Compiling the above gives
\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}
${{{li \left( {t} \right)} \ {\log \left( {t} \right)}} -t} \over {\log \left( {t} \right)}$
\end{document}
![image description](/upfiles/15774755486375178.png)
Not perfect either (since `'li` should have been `\li` and made an operator) but it looks better that latex from sagemath,
Is this a known issue? Is there a workaround?
Thank you
--NasserNasserFri, 27 Dec 2019 13:41:42 -0600https://ask.sagemath.org/question/49232/Latex multicolumn is not recognizedhttps://ask.sagemath.org/question/48614/latex-multicolumn-is-not-recognized/ HI
R0 = GF(3)
print R0.addition_table()
print R0.multiplication_table()
show(R0.addition_table())
latex(R0.addition_table())
ortolljTue, 05 Nov 2019 07:13:25 -0600https://ask.sagemath.org/question/48614/possible invalid latex translation from fricas resulthttps://ask.sagemath.org/question/48409/possible-invalid-latex-translation-from-fricas-result/Using 8.9 sagemath on Linux. Where Fricas 1.5 is installed.
After calling fricas for integration from inside sagemath, and then translating the result to latex, the latex do not compile. I get syntax error compiling the latex with latest texlive TL 2019.
>sage
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SageMath version 8.9, Release Date: 2019-09-29 β
β Using Python 2.7.16. Type "help()" for help. β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
sage: var('b c x n a e')
sage: anti=integrate((b*log(c*x^n) + a)*x^2*polylog(3, e*x),x, algorithm="fricas")
sage: anti_in_latex=latex(anti)
sage: anti_in_latex
sage: anti_in_latex
-\frac{4 \, {\left(4 \, b e^{3} n - 3 \, a e^{3}\right)} x^{3} + 9 \, {\left(3 \, b e^{2} n - 2 \, a e^{2}\right)} x^{2} + 36 \, {\left(2 \, b e n - a e\right)} x + 36 \, {\left(3 \, b e^{3} n x^{3} \log\left(x\right) + 3 \, b e^{3} x^{3} \log\left(c\right) - {\left(2 \, b e^{3} n - 3 \, a e^{3}\right)} x^{3} - b n\right)} {\rm %iint}\left(e, x, -\frac{\log\left(-e x + 1\right)}{e}, -\frac{\log\left(-e x + 1\right)}{x}\right) - 36 \, {\left({\left(b e^{3} n - a e^{3}\right)} x^{3} - b n + a\right)} \log\left(-e x + 1\right) - 6 \, {\left(2 \, b e^{3} x^{3} + 3 \, b e^{2} x^{2} + 6 \, b e x - 6 \, {\left(b e^{3} x^{3} - b\right)} \log\left(-e x + 1\right)\right)} \log\left(c\right) - 6 \, {\left(2 \, b e^{3} n x^{3} + 3 \, b e^{2} n x^{2} + 6 \, b e n x - 6 \, {\left(b e^{3} n x^{3} - b n\right)} \log\left(-e x + 1\right)\right)} \log\left(x\right) - 108 \, {\left(3 \, b e^{3} n x^{3} \log\left(x\right) + 3 \, b e^{3} x^{3} \log\left(c\right) - {\left(b e^{3} n - 3 \, a e^{3}\right)} x^{3}\right)} {\rm polylog}\left(3, e x\right)}{972 \, e^{3}}
sage:
Now when compiling the above, here is the error
>cat foo1.tex
\documentclass[12pt]{article}%
\usepackage{amsmath}
\begin{document}
\[
-\frac{4 \, {\left(4 \, b e^{3} n - 3 \, a e^{3}\right)} x^{3} + 9 \, {\left(3 \, b e^{2} n - 2 \, a e^{2}\right)} x^{2} + 36 \, {\left(2 \, b e n - a e\right)} x + 36 \, {\left(3 \, b e^{3} n x^{3} \log\left(x\right) + 3 \, b e^{3} x^{3} \log\left(c\right) - {\left(2 \, b e^{3} n - 3 \, a e^{3}\right)} x^{3} - b n\right)} {\rm %iint}\left(e, x, -\frac{\log\left(-e x + 1\right)}{e}, -\frac{\log\left(-e x + 1\right)}{x}\right) - 36 \, {\left({\left(b e^{3} n - a e^{3}\right)} x^{3} - b n + a\right)} \log\left(-e x + 1\right) - 6 \, {\left(2 \, b e^{3} x^{3} + 3 \, b e^{2} x^{2} + 6 \, b e x - 6 \, {\left(b e^{3} x^{3} - b\right)} \log\left(-e x + 1\right)\right)} \log\left(c\right) - 6 \, {\left(2 \, b e^{3} n x^{3} + 3 \, b e^{2} n x^{2} + 6 \, b e n x - 6 \, {\left(b e^{3} n x^{3} - b n\right)} \log\left(-e x + 1\right)\right)} \log\left(x\right) - 108 \, {\left(3 \, b e^{3} n x^{3} \log\left(x\right) + 3 \, b e^{3} x^{3} \log\left(c\right) - {\left(b e^{3} n - 3 \, a e^{3}\right)} x^{3}\right)} {\rm polylog}\left(3, e x\right)}{972 \, e^{3}}
\]
\end{document}
And
>lualatex foo1.tex
This is LuaTeX, Version 1.10.0 (TeX Live 2019)
restricted system commands enabled.
(./foo1.tex
LaTeX2e <2018-12-01>
luaotfload | main : initialization completed in 0.144 seconds
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size12.clo))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsopn.sty)) (./foo1.aux)
)
Runaway argument?
{4 \, {\left (4 \, b e^{3} n - 3 \, a e^{3}\right )} x^{3} + 9 \, {\left \ETC.
! File ended while scanning use of \frac .
<inserted text>
\par
<*> foo1.tex
?
This is the first time I see latex generated by sagemath not compile OK. I am usin
Any one knows what is going on and why this error is generated?
**Update**
Fyi, when running the above directly in Fricas, this is what I get
ii:=integrate((b*log(c*x^n) + a)*x^2*polylog(3, e*x),x);
unparse(ii::InputForm)
"(((-108)*b*e^3*n*x^3*log(x)+((-108)*b*e^3*x^3*log(c)+((72*b*e^3*n+(-108)*a*e
^3)*x^3+36*b*n)))*%iint(e,x,((-1)*log((-1)*e*x+1))/e,((-1)*log((-1)*e*x+1))/x
)+((324*b*e^3*n*x^3*log(x)+(324*b*e^3*x^3*log(c)+((-108)*b*e^3*n+324*a*e^3)*x
^3))*polylog(3,e*x)+((((-36)*b*e^3*n*x^3+36*b*n)*log((-1)*e*x+1)+(12*b*e^3*n*
x^3+18*b*e^2*n*x^2+36*b*e*n*x))*log(x)+((((-36)*b*e^3*x^3+36*b)*log((-1)*e*x+
1)+(12*b*e^3*x^3+18*b*e^2*x^2+36*b*e*x))*log(c)+(((36*b*e^3*n+(-36)*a*e^3)*x^
3+((-36)*b*n+36*a))*log((-1)*e*x+1)+(((-16)*b*e^3*n+12*a*e^3)*x^3+((-27)*b*e^
2*n+18*a*e^2)*x^2+((-72)*b*e*n+36*a*e)*x))))))/(972*e^3)"
But Fricas Latex is VALID, since it add `\` around `%`
(11) -> latex(ii)
(11)
"{{{\left( -{{108} \ b \ {{e} \sp {3}} \ n \ {{x} \sp {3}} \ {\log \left
( {x} \right)}} -{{108} \ b \ {{e} \sp {3}} \ {{x} \sp {3}} \ {\log \left
( {c} \right)}}+{{\left( {{72} \ b \ {{e} \sp {3}} \ n} -{{108} \ a \ {{
e} \sp {3}}} \right)} \ {{x} \sp {3}}}+{{36} \ b \ n} \right)} \ { \%iint
\left( {e, \: x, \: -{{\log \left( {{-{e \ x}+1}} \right)} \over e}, \: -{{
\log \left( {{-{e \ x}+1}} \right)} \over x}} \right)}}+{{\left( {{324} \ b
\ {{e} \sp {3}} \ n \ {{x} \sp {3}} \ {\log \left( {x} \right)}}+{{324}
\ b \ {{e} \sp {3}} \ {{x} \sp {3}} \ {\log \left( {c} \right)}}+{{\left(
-{{108} \ b \ {{e} \sp {3}} \ n}+{{324} \ a \ {{e} \sp {3}}} \right)} \
{{x} \sp {3}}} \right)} \ {polylog \left( {3, \: {e \ x}} \right)}}+{{\le
ft( {{\left( -{{36} \ b \ {{e} \sp {3}} \ n \ {{x} \sp {3}}}+{{36} \ b \
n} \right)} \ {\log \left( {{-{e \ x}+1}} \right)}}+{{12} \ b \ {{e} \s
p {3}} \ n \ {{x} \sp {3}}}+{{18} \ b \ {{e} \sp {2}} \ n \ {{x} \sp {2
}}}+{{36} \ b \ e \ n \ x} \right)} \ {\log \left( {x} \right)}}+{{\left
( {{\left( -{{36} \ b \ {{e} \sp {3}} \ {{x} \sp {3}}}+{{36} \ b} \right)
} \ {\log \left( {{-{e \ x}+1}} \right)}}+{{12} \ b \ {{e} \sp {3}} \ {{
x} \sp {3}}}+{{18} \ b \ {{e} \sp {2}} \ {{x} \sp {2}}}+{{36} \ b \ e \
x} \right)} \ {\log \left( {c} \right)}}+{{\left( {{\left( {{36} \ b \ {{
e} \sp {3}} \ n} -{{36} \ a \ {{e} \sp {3}}} \right)} \ {{x} \sp {3}}} -{
{36} \ b \ n}+{{36} \ a} \right)} \ {\log \left( {{-{e \ x}+1}} \right)}
}+{{\left( -{{16} \ b \ {{e} \sp {3}} \ n}+{{12} \ a \ {{e} \sp {3}}} \r
ight)} \ {{x} \sp {3}}}+{{\left( -{{27} \ b \ {{e} \sp {2}} \ n}+{{18} \
a \ {{e} \sp {2}}} \right)} \ {{x} \sp {2}}}+{{\left( -{{72} \ b \ e \
n}+{{36} \ a \ e} \right)} \ x}} \over {{972} \ {{e} \sp {3}}}"
So it looks like sagemath needs to do the same. Look into the result returned by Fricas, and replace `%iint` by ` \%iint` in the Latex?
Thanks
--NasserNasserFri, 18 Oct 2019 14:30:12 -0500https://ask.sagemath.org/question/48409/Problems with AMS symbols in Sage, Jupyterhttps://ask.sagemath.org/question/48303/problems-with-ams-symbols-in-sage-jupyter/ How to display the square (\square) symbol in a graph (Jupyter, maybe not only). Why \boxtimes is too large?
plot(x, (x,-1,10), axes_labels=[r'$F(G\,\square\,H)$',r'$F(G\,\times\,H)$']).show()
plot(x, (x,-1,10), axes_labels=[r'$F(G\,\square\,H)$',r'$F(G\,\times\,H)$']).show()
I tried \box \square \emptybox etc. and
from sage.misc.latex import latex_extra_preamble
latex.add_to_preamble('\\usepackage{amssymb}')
I get:
ValueError:
F(G\,\square\,H)
^
Unknown symbol: \square (at char 5), (line:1, col:6)
SYLASat, 12 Oct 2019 09:42:12 -0500https://ask.sagemath.org/question/48303/Problems with AMS symbols in Sage, Jupyterhttps://ask.sagemath.org/question/48302/problems-with-ams-symbols-in-sage-jupyter/ How to display the square (\square) symbol in a graph (Jupyter, maybe not only). Why \boxtimes is too large?
plot(x, (x,-1,10), axes_labels=[r'$F(G\,\square\,H)$',r'$F(G\,\times\,H)$']).show()
plot(x, (x,-1,10), axes_labels=[r'$F(G\,\square\,H)$',r'$F(G\,\times\,H)$']).show()
I tried \box \square \emptybox etc. and
from sage.misc.latex import latex_extra_preamble
latex.add_to_preamble('\\usepackage{amssymb}')
I get:
ValueError:
F(G\,\square\,H)
^
Unknown symbol: \square (at char 5), (line:1, col:6)
SYLASat, 12 Oct 2019 09:39:14 -0500https://ask.sagemath.org/question/48302/Latex text in notebook and return lineshttps://ask.sagemath.org/question/47202/latex-text-in-notebook-and-return-lines/Hi
is there a way to display a text in notebook with return lines out of this heavy way ?:
show(LatexExpr(r" \
\text{ Late at night, guards on the battlements of Denmark's Elsinore castle}\\ \
\text{are met by Horatio, Prince Hamlet's friend from school.}\\ \
\text{The guards describe a ghost they have seen that resembles Hamlet's father,}\\ \
\text{the recently-deceased king. At that moment, the Ghost reappears,}\\ \
\text{and the guards and Horatio decide to tell Hamlet.}\
"))
ortolljThu, 18 Jul 2019 03:35:03 -0500https://ask.sagemath.org/question/47202/How to use sagetex?https://ask.sagemath.org/question/46648/how-to-use-sagetex/ https://ask.sagemath.org/question/8915/how-run-a-sage-file/#
I have this question and I downloaded sagemath and I have three applets a console, a shell, and a notebook, and I was wondering how do I do what the person did because I tried the shell multiple times and I moved the sty file into the Latex folder anything I can do to help you help me please let me know? The error I keep getting is this error file not found. EnlightenedFunkThu, 23 May 2019 19:20:04 -0500https://ask.sagemath.org/question/46648/What could be reasons for latex() output to stop working?https://ask.sagemath.org/question/46399/what-could-be-reasons-for-latex-output-to-stop-working/In the past i used the `latex()` output to generate latex source to use in my paper. This stopped working at some point, on three independent linux systems. Even sage scripts that produced such latex source code in the past don't do so anymore.
for example
epsilon_0 = var('epsilon_0', latex_name=r'\varepsilon_0')
latex(epsilon_0)
produces no output, not on the command line nor in my emacs *Sage* output buffer.
I assume i must have broken something. Where can I look? i use debian, and the debian sage packages to install and use sage.
Edit: correction: on two of the three system the latex() command does nothing, on the third it works. I can use that third system to generate the latex source for now. But it would be swell to fix on the other systems, too. The third system where it works is an Ubuntu, where i installed sage from source.stockh0lmMon, 29 Apr 2019 06:49:14 -0500https://ask.sagemath.org/question/46399/SageMath export to latex Documenthttps://ask.sagemath.org/question/45119/sagemath-export-to-latex-document/Is there a way automatically create a latex document from within the sagemath notebook.
It is possible to push one line to latex output, but its very anoying to callect its by hand and copy and paste it into latex document.
In my opiniton its much fast to write in sagemath. thethaMon, 21 Jan 2019 07:21:20 -0600https://ask.sagemath.org/question/45119/Is it possible to remove the latex parentheses from exponential functions?https://ask.sagemath.org/question/44777/is-it-possible-to-remove-the-latex-parentheses-from-exponential-functions/Consider the block of code
sage: f = exp(x**2)
sage: latex(f)
e^{\left(x^{2}\right)}
It looks like sage is configured to include parentheses in the latex of an exponential function. Is it possible to configure sage to exclude these parentheses? done_with_fishTue, 25 Dec 2018 04:28:00 -0600https://ask.sagemath.org/question/44777/