Unable to integrate inside a summation with orthogonal functions in Sympy

38 Views Asked by At

I am trying to do an integration of orthogonal function $ \sin(m \pi y) \sin(n \pi y) $ inside a summation. A little help would be very appreciated. The link for the jupyter notebook is this. I am OK up to the input [42].

1

There are 1 best solutions below

3
Davide_sd On

First, as Oscar mentioned in the comment, you should provide the necessary code to replicate your issue, instead of hoping someone to actually go through 40+ notebook cells. This is how you do it: take the time to collect the necessary piece of code, like this:

n, m = symbols("n, m", integer=True, positive=True)
x, y = symbols("x, y", real=True)
a, b = symbols("a, b")
C = IndexedBase("C")
expr = Sum(sin(pi*m*y/a) * sin(pi*n*y/a) * cosh(pi*b*n/a) * C[n], (n, 1, oo))
# problem here: it doesn't evaluate
integrate(expr, (y, 0, a))

Now to the answer: using the linearity of sums and integrals, we can swap the order of operations. With a bit of attention, we can do it manually:

res = Sum(integrate(expr.args[0], (y, 0, a)), (n, 1, oo))

But now you would get a sum of a piecewise function. We can bring the summation into the pieces with:

piecewise_fold(res).simplify()