Ask Your Question
1

latex problem using result obtained from Fricas integrate

asked 2019-12-27 20:41:42 +0100

Nasser gravatar image

updated 2019-12-27 22:12:07 +0100

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

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

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

edit retag flag offensive close merge delete

Comments

A quick workaround:

LatexExpr(latex(result).replace("log_integral","\operatorname{li}"))
Juanjo gravatar imageJuanjo ( 2019-12-28 12:15:09 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-12-27 22:45:12 +0100

Emmanuel Charpentier gravatar image

updated 2019-12-27 22:46:34 +0100

This is fixed by the definition of log_integral in the library and can't be changed but by changing this definition (i. e. a patch to Sagemath).

Therefore this can be considered as a (minor) defect. Care to report it on Trac and try to fix it yourself ? Look at the Sagemath's developer's guide to have an idea of what this would entail...

edit flag offensive delete link more

Comments

1

thank you for the suggestion. created ticked https://trac.sagemath.org/ticket/2891...

Nasser gravatar imageNasser ( 2019-12-27 23:42:34 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-12-27 20:41:42 +0100

Seen: 361 times

Last updated: Dec 27 '19