Thread: Integrating a piecewise trig function by parts

1. Integrating a piecewise trig function by parts

The initial equation to integrate is is: B(n) = 0.4k * (integral(x*sin(n*pi*x),x,0,1/2) - integral(x*sin(n*pi*x),x,1/2,1) + integral(sin(n*pi*x),x,1/2,1))

I keep getting B(n) = 0.4/(n*pi)^2 * (2*sin(n*pi)/2 - cos(n*pi) + cos(n*pi)/2)

which is nowhere near the right answer. Help, please. The integration by parts is killing me. I know how to do it, but I keep messing up on it and I'm not sure where.

2. Re: Integrating a piecewise trig function by parts

Originally Posted by phys251
The initial equation to integrate is is: B(n) = 0.4k * (integral(x*sin(n*pi*x),x,0,1/2) - integral(x*sin(n*pi*x),x,1/2,1) + integral(sin(n*pi*x),x,1/2,1))

I keep getting B(n) = 0.4/(n*pi)^2 * (2*sin(n*pi)/2 - cos(n*pi) + cos(n*pi)/2)

which is nowhere near the right answer. Help, please. The integration by parts is killing me. I know how to do it, but I keep messing up on it and I'm not sure where.
I don't know how much calculus you have taken, but if you are okay with exchanging integrals and derivatives you can do some "nifty" tricks.

Here is the first one

$B(n)=.4k \int_{0}^{.5}x\sin(n \pi x)dx$

We can rewrite the integrand as a derivative with respect to n to get

$B(n)=.4k \int_{0}^{.5}\frac{-1}{\pi} \frac{d}{dn} \left( \cos(n \pi x) \right) dx$

Now if you exchange the integral and the derivative you get (This step should be verified)

$B(n)= -\frac{0.4k}{\pi} \frac{d}{dn}\int_{0}^{.5} \left( \cos(n \pi x) \right) dx$

Now we can take the integral with respect to x to get

$-\frac{0.4k}{\pi} \frac{d}{dn}\left( \frac{\sin(n \pi x)}{\pi n}\right)\bigg|_{0}^{\frac{1}{2}}$

$\frac{0.4k}{\pi} \frac{d}{dn}\left( \frac{\sin\left(\frac{n \pi}{2} \right))}{\pi n}\right)$

$\frac{0.4k}{\pi} \left( \frac{\pi}{2}\cdot \frac{\cos\left(\frac{n \pi}{2} \right))}{\pi n}- \frac{\sin\left(\frac{n \pi}{2} \right))}{\pi n^2}\right)$

3. Re: Integrating a piecewise trig function by parts

Shouldn't this step:

$\frac{0.4k}{\pi} \frac{d}{dn}\left( \frac{\sin\left(\frac{n \pi}{2} \right))}{\pi n}\right)$

be negative?

4. Re: Integrating a piecewise trig function by parts

Also, I can't get the right answer for the - integral(x*sin(n*pi*x),x,1/2,1) term.