Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug in conversion powers in to LaTeX #7406

Closed
robert-marik mannequin opened this issue Nov 6, 2009 · 9 comments
Closed

bug in conversion powers in to LaTeX #7406

robert-marik mannequin opened this issue Nov 6, 2009 · 9 comments

Comments

@robert-marik
Copy link
Mannequin

robert-marik mannequin commented Nov 6, 2009

The LaTeX representation of (xpi)e is not valid TeX string and is not rendered by jsmath

sage: latex((x^pi)^e)
{(x)}^{\pi}^{e}

Burcin suggested how to fix this and get output like

{{(x)}^{\pi}}^{e}
The code for printing
symbolic expressions is in pynac (C++). The fix can be as simple as
printing an extra set of braces around power objects.

If anybody wants to try fixing this, the relevant function is
power::do_print_latex() in power.cpp. To get to the file (using the
instructions I wrote in another message just now), go to your SAGE_ROOT
and do:

./sage -f -s spkg/standard/pynac-0.1.9.p0.spkg

cd spkg/build/pynac-0.1.9/src/ginac

Edit power.cpp. To compile and make your changes effective, go to your
SAGE_ROOT again, and do

./sage -sh
cd spkg/build/pynac-0.1.9/src
make install 

However a better fix would be to get

{x}^{a}

if the base is an atom (or not power) and

\left({x^a}\right)^{b}

if the base is a power. This allows to distinguish easily between

x^(a^b) 

and

(x^a)^b

A workaround is to remove powers of powers by simplification. For example radcan function from Maxima perfoms such simplifications

sage: latex(maxima((x^pi)^e).radcan().sage())
x^{\pi e}

Component: symbolics

Keywords: latex, power, jsmath, pynac

Author: Burcin Erocal

Reviewer: Karl-Dieter Crisman

Merged: sage-4.3.rc0

Issue created by migration from https://trac.sagemath.org/ticket/7406

@robert-marik robert-marik mannequin added this to the sage-4.3 milestone Nov 6, 2009
@robert-marik robert-marik mannequin added c: symbolics labels Nov 6, 2009
@robert-marik robert-marik mannequin assigned burcin Nov 6, 2009
@robert-marik

This comment has been minimized.

@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Nov 21, 2009

Changed keywords from latex, power, jsmath to latex, power, jsmath, pynac

@robert-marik
Copy link
Mannequin Author

robert-marik mannequin commented Nov 21, 2009

comment:3

Perhaps close problem is

sage: latex(x*(1/(x^2)+sqrt(x^7)))
{(\sqrt{x^{7}} + \frac{1}{x^{2}})} x

Note missing \left and \right at outside parentheses which makes the rendering of the expression far from perfect. Should look like

sage: latex(x*(1/(x^2)+sqrt(x^7)))
{\left(\sqrt{x^{7}} + \frac{1}{x^{2}}\right)} x

@burcin
Copy link

burcin commented Nov 22, 2009

add doctests

@burcin
Copy link

burcin commented Nov 22, 2009

comment:4

Attachment: trac_7406-power_latex.patch.gz

The new pynac package here

http://sage.math.washington.edu/home/burcin/pynac/pynac-0.1.10.spkg

contains fixes for both the problem in the description and the one in comment:3.

attachment: trac_7406-power_latex.patch contains doctests for the fix.

Note that the new pynac version also contains fixes for #7508 and #7264. Tests should be run with the patches from those tickets also applied in this order:

This ticket now depends on #7490, #7508 and #7264.

@burcin
Copy link

burcin commented Nov 22, 2009

Author: Burcin Erocal

@kcrisman
Copy link
Member

kcrisman commented Dec 5, 2009

comment:5

Positive review - they look great in show()! Obviously pending #7264 or a rebase.

@mwhansen
Copy link
Contributor

Reviewer: Karl-Dieter Crisman

@mwhansen
Copy link
Contributor

Merged: sage-4.3.rc0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants