The problem with this method is that looking at all combinations
becomes *very* inefficient for Muls with many terms. For example:
In [41]: %timeit integrate2(diff(x*sqrt(sin(x))), x)
1
2
1
2
1
2
1
2
1 loops, best of 3: 5.2 s per loop
At the end of the day, you'll get even worse performance than
Here I am attaching a very lazy code to integrate by parts.
from sympy import *
import itertools as it
import operator as op
def byparts(expr,x,depth=1):
print depth
hintarr=[]
if expr.is_Mul:
for part in it.combinations(expr.args,depth):
part=reduce(op.mul,part)
A very lazy code to integrate b y parts.
best,
Pallab
On Wednesday, July 11, 2012 1:23:01 PM UTC-4, pallab wrote:
>
> simple by parts integral can not be done:
>
> integrate(diff(x*f(x),x),x)
>
>
> also can not do simple integral like:
>
> integrate(diff(x*sqrt(sin(x)),x),x)
>
>
> best,
>
> Pa
from sympy import *
import itertools as it
import operator as op
def byparts(expr,x,depth=1):
print depth
hintarr=[]
if expr.is_Mul:
for part in it.combinations(expr.args,depth):
part=reduce(op.mul,part)
rest=simplify(expr/part)
part_int=int