Re: [sympy] Targeting specific subexpression for transformations

2014-11-03 Thread Chris Smith
see also the docstring of replace for instructions on how it might be used expr=1/(1-x)+1/(1+x) i=Integral(expr,x) i.replace(lambda arg: arg.is_Add, lambda arg: arg.together().expand()) Integral(2/(-x**2 + 1), x) On Monday, October 27, 2014 9:57:49 AM UTC-5, Francesco Bonazzi wrote:

Re: [sympy] Targeting specific subexpression for transformations

2014-10-27 Thread Francesco Bonazzi
Interesting, I didn't know of epath, it looks like it supports type-matching, which current wildcards do not support. On Friday, October 24, 2014 4:50:16 PM UTC+2, Mateusz Paprocki wrote: Hi, On 24 October 2014 15:16, Francesco Bonazzi franz@gmail.com javascript: wrote: Consider

[sympy] Targeting specific subexpression for transformations

2014-10-24 Thread Francesco Bonazzi
Consider this use case In [97]: expr = 1/(1-x) + 1/(1+x) In [98]: e2 = Integral(expr, x) In [99]: e2 Out[99]: ⌠ ⎮ ⎛ 1 1 ⎞ ⎮ ⎜─ + ──⎟ dx ⎮ ⎝x + 1 -x + 1⎠ ⌡ Suppose now I want to act on the expression inside the integral by

Re: [sympy] Targeting specific subexpression for transformations

2014-10-24 Thread Mateusz Paprocki
Hi, On 24 October 2014 15:16, Francesco Bonazzi franz.bona...@gmail.com wrote: Consider this use case In [97]: expr = 1/(1-x) + 1/(1+x) In [98]: e2 = Integral(expr, x) In [99]: e2 Out[99]: ⌠ ⎮ ⎛ 1 1 ⎞ ⎮ ⎜─ + ──⎟ dx ⎮ ⎝x + 1 -x + 1⎠ ⌡ Suppose now I want to act on