Ticket #1771 (closed defect: fixed)
[with patch, positive review] latex bug with symbolics
| Reported by: | was | Owned by: | was |
|---|---|---|---|
| Priority: | major | Milestone: | sage-2.10 |
| Component: | calculus | Keywords: | |
| Cc: | Work issues: | ||
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description
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
Attachments
Change History
comment:1 Changed 5 years ago by mhansen
- Summary changed from latex bug with symbolics [with fix] to [with patch] latex bug with symbolics
Note: See
TracTickets for help on using
tickets.

