# Ticket #7334: trac-7344-logcontract-2.patch

File trac-7344-logcontract-2.patch, 3.0 KB (added by robert.marik, 4 years ago)
• ## sage/symbolic/expression.pyx

```# HG changeset patch
# User Robert Marik <marik@mendelu.cz>
# Date 1257631858 -3600
# Node ID 0498c15fabde58d49dc04ee291fde681082069f9
# Parent  bb1cdd11d71ca04ccf83d96a0a1edb88e33fa71c
trac #7334

diff -r bb1cdd11d71c -r 0498c15fabde sage/symbolic/expression.pyx```
 a among the components of the expression for simplifications based on factoring and partial fraction expansions of exponents." ALIAS: radical_simplify, simplify_radical, simplify_log, log_simplify, exp_simplify, simplify_exp are all the same ALIAS: radical_simplify, simplify_radical, exp_simplify, simplify_exp are all the same EXAMPLES:: maxima.eval('domain: complex\$') return res radical_simplify = simplify_log = log_simplify = simplify_radical radical_simplify = simplify_radical simplify_exp = exp_simplify = simplify_radical def simplify_log(self,coeff='integers'): r""" Simplifies this symbolic expression, which can contain logs INPUT:: self -- expression to be simplified coeff -- if 'integers' then only integers multiples are contracted as powers inside logarithm. If 'ratios', then also quotients of integers are treated this way. DETAILS: This uses the Maxima logcontract() command. From the Maxima documentation: "Recursively scans the expression expr, transforming subexpressions of the form a1*log(b1) + a2*log(b2) + c into log(ratsimp(b1^a1 * b2^a2)) + c. The user can control which coefficients are contracted by setting the option logconcoeffp to the name of a predicate function of one argument. E.g. if you like to generate SQRTs, you can do logconcoeffp:'logconfun\$ logconfun(m):=featurep(m,integer) or ratnump(m)\$ . Then logcontract(1/2*log(x)); will give log(sqrt(x))." ALIAS: log_simplify is the same EXAMPLES:: sage: x,y,t=var('x y t') :: sage: f = log(x)+2*log(y)+1/2*log(t) sage: f.simplify_log() log(x*y^2) + 1/2*log(t) sage: f.simplify_log(coeff='ratios') log(sqrt(t)*x*y^2) """ from sage.calculus.calculus import maxima maxima.eval('domain: real\$') if coeff == 'ratios': maxima.eval('logconcoeffp:\'logconfun\$') maxima.eval('logconfun(m):=featurep(m,integer) or ratnump(m)\$') res = self.parent()(self._maxima_().logcontract()) maxima.eval('domain: complex\$') if coeff == 'ratios': maxima.eval('logconcoeffp:false\$') return res log_simplify = simplify_log def factor(self, dontfactor=[]): """