simplification of exp(x*log(y))

38 views
Skip to first unread message

Carsten Knoll

unread,
Jul 18, 2015, 7:12:37 AM7/18/15
to sy...@googlegroups.com
Hi,

due to various substitutions I have a bulky expression of the following
structure

A + exp(B*log(C) + D)

I want sympy to simplify this to

A + C**B*exp(D)

I think it boils down to the simplification of

exp(B*log(C))


which I also can't perform:

from sympy import exp, log, expand_power_exp
from sympy.abc import B, C

term = exp(B*log(C))

print term.simplify()
print term.expand()
print expand_power_exp(term)


# results
exp(B*log(C))
exp(B*log(C))
exp(B*log(C))

I think a possible way would be the following:

exp(B*log(C) + D) = exp(B*log(C))*exp(D) = exp(log(C))**B*exp(D)
= C**B*exp(D)


But how can I tell sympy to "see" that?

Carsten


Chris Smith

unread,
Jul 18, 2015, 10:10:20 AM7/18/15
to sy...@googlegroups.com
With the right assumptions this will simplify:

>>> e=S('A + exp(B*log(C) + D) ')
>>> simplify(posify(e))
(_C**_B*exp(_D) + _A, {_A: A, _B: B, _C: C, _D: D})
>>> _[0].subs(_[1])
A + C**B*exp(D)

/c

Aaron Meurer

unread,
Jul 18, 2015, 8:19:06 PM7/18/15
to sy...@googlegroups.com
You can also use logcombine(force=True). I'd say this is better than posify() because it will work even if the argument to the log() is not a basic Symbol.

Aaron Meurer

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/7c41a10c-3d5c-4dba-aa6e-8db85a2bf12b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages