You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered: