Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

An issue with integrals involving absolute value

I have been using SageMathCell for a while and some things that used to work some months before seem to have changed and do not work any longer. In particular, I found the following problem when computing elementary integrals.

Can anyone explain me why "a" yields a correctly computed result but "b" is not computed at all? What should I do to get "b" correctly computed?

x,n=var('x,n') assume(n,'integer') a=integral(x^2cos(nx),x,-pi,pi) b=integral(abs(x)cos(nx),x,-pi,pi) print('a=',a) print('b=',b)

An issue with integrals involving absolute value

I have been using SageMathCell for a while and some things that used to work some months before seem to have changed and do not work any longer. In particular, I found the following problem when computing elementary integrals.

Can anyone explain me why "a" yields a correctly computed result but "b" is not computed at all? What should I do to get "b" correctly computed?

x,n=var('x,n') assume(n,'integer') a=integral(x^2cos(nx),x,-pi,pi) b=integral(abs(x)cos(nx),x,-pi,pi) print('a=',a) print('b=',b)

x, n = SR.var('x, n')
assume(n, 'integer')
a = integral(x^2*cos(n*x), x, -pi, pi)
b = integral(abs(x)*cos(n*x), x, -pi, pi)
print('a=', a)
print('b=', b)