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

latex bug with symbolics #1771

Closed
williamstein opened this issue Jan 14, 2008 · 2 comments
Closed

latex bug with symbolics #1771

williamstein opened this issue Jan 14, 2008 · 2 comments

Comments

@williamstein
Copy link
Contributor

Peter.Jipsen
Hi,

with lprint() on, I calculated

diff(1/x-1/ln(x))

followed by

factor(_)

and the displayed answer is incorrect because prefix negation is not
handled correctly in the _latex_ method.

The same error in a simpler setting can be observed with:

(-(x-1)/2)._latex_(simplify=False)

output:

'\\frac{-x - 1}{2}'

(The error is usually masked by the fact that symbolic expressions are
normalized to avoid prefix negation.)

I think the last two lines of the _latex_ method should probably
change from

       elif op is operator.neg:
           return '-%s' % s[0]

to something like:

       elif op is operator.neg:
           if ops[0]._has_op(operator.add) or
ops[0]._has_op(operator.sub):
               s[0] = r'\left( %s \right)' %s[0]
           return '-%s' % s[0]

Sorry, I haven't figured out how to turn this into a hg patch (if the
solution is even appropriate).

--Peter

Component: calculus

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

@williamstein williamstein added this to the sage-2.10.1 milestone Jan 14, 2008
@williamstein williamstein self-assigned this Jan 14, 2008
@mwhansen mwhansen changed the title latex bug with symbolics [with fix] latex bug with symbolics Jan 14, 2008
@williamstein
Copy link
Contributor Author

comment:2

Attachment: 1771.patch.gz

This looks good to me. Thanks for turning it into a patch Mike!

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Jan 14, 2008

comment:3

Merged in Sage 2.10.alpha3.

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Jan 14, 2008
@sagetrac-mabshoff sagetrac-mabshoff mannequin modified the milestones: sage-2.10.1, sage-2.10 Jan 14, 2008
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

1 participant