On Sat, Jan 17, 2009 at 8:22 AM, ma...@mendelu.cz <ma...@mendelu.cz> wrote:
>
> Hello all
>
> The command latex(7-(-1)^(1/3))   produces 7 - {-1}^{\frac{1}{3}}
> Is it possible to change it into 7 - \left(-1\right)^{\frac{1}{3}}
>
> Which function should be redefined to gain this behavior?
>
> I think that two minus sign, one following the other, could be
> confusing (for students of economics, for example :) )
>
> Thank you
> Robert

I would start by doing:

sage: a = (-1)^(1/3)
sage: a._latex_??
[... source code in calculus.py...]

Then I would look at the code, and be confused for about an hour,
finally probably figure out what is going on, and maybe with luck be
able to fix this.
IIRC the code to get the latex for symbolic expressions is
complicated.  I think it was written by Bobby Moretti (and undergrad
who used to be a sage developer).

I think this sort of behavior, e.g.,

sage: a = (-1)^(1/4)
sage: latex(a)
{-1}^{\frac{1}{4}}

should officially be considered a bug in fact.  It's not just
confusing, it's wrong.

By the way, one trick you can use is to convert the expression to
maxima first and use its latex.  For some things, e.g., your example
above, this works better:

sage: a = 7-(-1)^(1/3)
sage: latex(a._maxima_())
7-\left(-1\right)^{{{1}\over{3}}}

Don't use maxima(a), since then you'll get a in a session of maxima
that has different defaults than the calculus module uses, in
particular, roots are always assumed real, which may be bad (though
maybe ok for economists):

sage: a = 7-(-1)^(1/3)
sage: latex(maxima(a))
8

This bug that you reported is now

   http://trac.sagemath.org/sage_trac/ticket/5004

 -- William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to