Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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')
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
-\frac{1}{972} \, {\left(4 \, {\left(4 \, b n - 3 \, a\right)} x^{3} e^{3} + 9 \, {\left(3 \, b n - 2 \, a\right)} x^{2} e^{2} + 36 \, {\left(2 \, b n - a\right)} x e + 36 \, {\left(3 \, b n x^{3} e^{3} \log\left(x\right) + 3 \, b x^{3} e^{3} \log\left(c\right) - {\left(2 \, b n - 3 \, a\right)} x^{3} e^{3} - b n\right)} {\rm %iint}\left(x, -\frac{\log\left(-x e + 1\right)}{x}\right) - 36 \, {\left({\left(b n - a\right)} x^{3} e^{3} - b n + a\right)} \log\left(-x e + 1\right) - 6 \, {\left(2 \, b x^{3} e^{3} + 3 \, b x^{2} e^{2} + 6 \, b x e - 6 \, {\left(b x^{3} e^{3} - b\right)} \log\left(-x e + 1\right)\right)} \log\left(c\right) - 6 \, {\left(2 \, b n x^{3} e^{3} + 3 \, b n x^{2} e^{2} + 6 \, b n x e - 6 \, {\left(b n x^{3} e^{3} - b n\right)} \log\left(-x e + 1\right)\right)} \log\left(x\right) - 108 \, {\left(3 \, b n x^{3} e^{3} \log\left(x\right) + 3 \, b x^{3} e^{3} \log\left(c\right) - {\left(b n - 3 \, a\right)} x^{3} e^{3}\right)} {\rm polylog}\left(3, x e\right)\right)} e^{\left(-3\right)}
sage:

Now when compiling the above, here is the error

    (base) >cat foo1.tex
    \documentclass[12pt]{article}%
    \usepackage{amsmath}
    \begin{document}
    \[
    -\frac{1}{972} \, {\left(4 \, {\left(4 \, b n - 3 \, a\right)} x^{3} e^{3} + 9 \, {\left(3 \, b n - 2 \, a\right)} x^{2} e^{2} + 36 \, {\left(2 \, b n - a\right)} x e + 36 \, {\left(3 \, b n x^{3} e^{3} \log\left(x\right) + 3 \, b x^{3} e^{3} \log\left(c\right) - {\left(2 \, b n - 3 \, a\right)} x^{3} e^{3} - b n\right)} {\rm %iint}\left(x, -\frac{\log\left(-x e + 1\right)}{x}\right) - 36 \, {\left({\left(b n - a\right)} x^{3} e^{3} - b n + a\right)} \log\left(-x e + 1\right) - 6 \, {\left(2 \, b x^{3} e^{3} + 3 \, b x^{2} e^{2} + 6 \, b x e - 6 \, {\left(b x^{3} e^{3} - b\right)} \log\left(-x e + 1\right)\right)} \log\left(c\right) - 6 \, {\left(2 \, b n x^{3} e^{3} + 3 \, b n x^{2} e^{2} + 6 \, b n x e - 6 \, {\left(b n x^{3} e^{3} - b n\right)} \log\left(-x e + 1\right)\right)} \log\left(x\right) - 108 \, {\left(3 \, b n x^{3} e^{3} \log\left(x\right) + 3 \, b x^{3} e^{3} \log\left(c\right) - {\left(b n - 3 \, a\right)} x^{3} e^{3}\right)} {\rm polylog}\left(3, x e\right)\right)} e^{\left(-3\right)}
    \]
\end{document}(base)

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.161 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)
! Missing } inserted.
<inserted text>
}
l.8 \]

?

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? Thanks --Nasser

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')
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
-\frac{1}{972} 
sage: anti_in_latex
-\frac{4 \, {\left(4 \, {\left(4 \, b n - 3 \, a\right)} x^{3} e^{3} b e^{3} n - 3 \, a e^{3}\right)} x^{3} + 9 \, {\left(3 \, b e^{2} n - 2 \, a\right)} a e^{2}\right)} x^{2} e^{2} + 36 \, {\left(2 \, b n - a\right)} x e n - a e\right)} x + 36 \, {\left(3 \, b n x^{3} e^{3} e^{3} n x^{3} \log\left(x\right) + 3 \, b x^{3} e^{3} e^{3} x^{3} \log\left(c\right) - {\left(2 \, b n - 3 \, a\right)} x^{3} e^{3} e^{3} n - 3 \, a e^{3}\right)} x^{3} - b n\right)} {\rm %iint}\left(x, -\frac{\log\left(-x %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 + 1\right)}{x}\right) - 36 \, {\left({\left(b n - a\right)} x^{3} e^{3} - b n + a\right)} \log\left(-x e + 1\right) - 6 \, {\left(2 \, b x^{3} e^{3} + 3 \, b x^{2} e^{2} + 6 \, b x e x - 6 \, {\left(b x^{3} e^{3} e^{3} x^{3} - b\right)} \log\left(-x e \log\left(-e x + 1\right)\right)} \log\left(c\right) - 6 \, {\left(2 \, b n x^{3} e^{3} + 3 \, b e^{3} n x^{3} + 3 \, b e^{2} n x^{2} e^{2} + 6 \, b n x + 6 \, b e n x - 6 \, {\left(b n x^{3} e^{3} e^{3} n x^{3} - b n\right)} \log\left(-x e \log\left(-e x + 1\right)\right)} \log\left(x\right) - 108 \, {\left(3 \, b n x^{3} e^{3} e^{3} n x^{3} \log\left(x\right) + 3 \, b x^{3} e^{3} e^{3} x^{3} \log\left(c\right) - {\left(b n - 3 \, a\right)} x^{3} e^{3} n - 3 \, a e^{3}\right)} x^{3}\right)} {\rm polylog}\left(3, x e\right)\right)} e^{\left(-3\right)}
e x\right)}{972 \, e^{3}}
sage:

Now when compiling the above, here is the error

    (base) >cat foo1.tex
 \documentclass[12pt]{article}%
 \usepackage{amsmath}
 \begin{document}
  \[
    -\frac{1}{972} -\frac{4 \, {\left(4 \, {\left(4 \, b n - 3 \, a\right)} x^{3} e^{3} b e^{3} n - 3 \, a e^{3}\right)} x^{3} + 9 \, {\left(3 \, b e^{2} n - 2 \, a\right)} a e^{2}\right)} x^{2} e^{2} + 36 \, {\left(2 \, b n - a\right)} x e n - a e\right)} x + 36 \, {\left(3 \, b n x^{3} e^{3} e^{3} n x^{3} \log\left(x\right) + 3 \, b x^{3} e^{3} e^{3} x^{3} \log\left(c\right) - {\left(2 \, b n - 3 \, a\right)} x^{3} e^{3} e^{3} n - 3 \, a e^{3}\right)} x^{3} - b n\right)} {\rm %iint}\left(x, -\frac{\log\left(-x %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 + 1\right)}{x}\right) - 36 \, {\left({\left(b n - a\right)} x^{3} e^{3} - b n + a\right)} \log\left(-x e + 1\right) - 6 \, {\left(2 \, b x^{3} e^{3} + 3 \, b x^{2} e^{2} + 6 \, b x e x - 6 \, {\left(b x^{3} e^{3} e^{3} x^{3} - b\right)} \log\left(-x e \log\left(-e x + 1\right)\right)} \log\left(c\right) - 6 \, {\left(2 \, b n x^{3} e^{3} + 3 \, b e^{3} n x^{3} + 3 \, b e^{2} n x^{2} e^{2} + 6 \, b n x + 6 \, b e n x - 6 \, {\left(b n x^{3} e^{3} e^{3} n x^{3} - b n\right)} \log\left(-x e \log\left(-e x + 1\right)\right)} \log\left(x\right) - 108 \, {\left(3 \, b n x^{3} e^{3} e^{3} n x^{3} \log\left(x\right) + 3 \, b x^{3} e^{3} e^{3} x^{3} \log\left(c\right) - {\left(b n - 3 \, a\right)} x^{3} e^{3} n - 3 \, a e^{3}\right)} x^{3}\right)} {\rm polylog}\left(3, x e\right)\right)} e^{\left(-3\right)}
    e x\right)}{972 \, e^{3}}
\]
\end{document}(base)
\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.161 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.
! Missing } inserted.
File ended while scanning use of \frac .
<inserted text>
}
l.8 \]
\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? Thanks --Nasser

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? Thanks --Nasser

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? 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 --Nasser

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 --Nasser