Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To obtain b one can use the additivity of the integral

var('n')
assume(n, 'integer')
i1=integral(abs(n*x)*cos(n*x), x,-pi,0)
i2=integral(abs(n*x)*cos(n*x), x, 0,pi)
b=i1+i2
i1.simplify_full(), i2.simplify_full(), b.simplify_full()


(((-1)^n - 1)/abs(n), ((-1)^n - 1)/abs(n), 2*((-1)^n - 1)/abs(n))

If the integrand is even, then i1=i2, but the method should work for more general functions.