Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Trac #17556: Add Expression.simplify_log() to Expression.simplify_rea…
Browse files Browse the repository at this point in the history
…l().

The Expression.simplify_log() simplification is only valid over the
real numbers. It has been removed from Expression.simplify_full() for
that reason, but there's no reason it can't be performed as part of
simplify_real() where it is quite clear that the expression must be
real.

This commit performs simplify_log() as part of simplify_real(), and
updates the documentation of simplify_real().
  • Loading branch information
orlitzky committed Dec 29, 2014
1 parent 3ea1ded commit 044db1d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/sage/symbolic/expression.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8329,7 +8329,8 @@ cdef class Expression(CommutativeRingElement):
def simplify_real(self):
r"""
Simplify the given expression over the real numbers. This allows
the simplification of `\sqrt{x^{2}}` into `\left|x\right|`.
the simplification of `\sqrt{x^{2}}` into `\left|x\right|` and
the contraction of `\log(x) + \log(y)` into `\log(xy)`.
INPUT:
Expand All @@ -8346,6 +8347,13 @@ cdef class Expression(CommutativeRingElement):
sage: f.simplify_real()
abs(x)
::
sage: y = SR.var('y')
sage: f = log(x) + 2*log(y)
sage: f.simplify_real()
log(x*y^2)
TESTS:
We set the Maxima ``domain`` variable to 'real' before we call
Expand Down Expand Up @@ -8411,7 +8419,9 @@ cdef class Expression(CommutativeRingElement):
for v in self.variables():
assume(v, 'real');

result = self.simplify();
# This will round trip through Maxima, essentially performing
# self.simplify() in the process.
result = self.simplify_log()

# Set the domain back to what it was before we were called.
maxima.eval('domain: %s$' % original_domain)
Expand Down

0 comments on commit 044db1d

Please sign in to comment.