Ask Your Question
1

I don't know why Sage return 0 for integrate(sin(2*x).abs(),(x,0,pi)) when its value is 2

asked 2014-12-14 16:25:05 +0200

Arturo gravatar image

updated 2023-01-09 23:59:35 +0200

tmonteil gravatar image

When I try integrate(sin(x).abs(),(x,0,pi)) the program return the same thing. The numerical integration is correct, the program return (1.9999999999999998, 2.220446049250313e-14). I don't know if it is a bug or what. Any help? I have tried sage 6.2, 6.3, 6.4.1

Mathematica can do It without any problem http://www.wolframalpha.com/input/?i=...

Neither Sympy nor Maxima can't compute this.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2014-12-14 20:59:11 +0200

tmonteil gravatar image

They are indeed some issues with integrals involving absolute values, see a list here At least in your case no wrong answer is returned.

edit flag offensive delete link more

Comments

@tmonteil: The question's title suggests that a wrong answer is indeed returned, even if the text of the question counterbalances that by the fact that numerical integration is correct.

slelievre gravatar imageslelievre ( 2015-02-05 09:50:39 +0200 )edit
0

answered 2014-12-15 17:10:25 +0200

kcrisman gravatar image

Interestingly,

sage: integrate(abs(sin(x)),x)
-(2*arctan(sin(x)/(cos(x) + 1))*sin(x)/(cos(x) + 1) - log(2))*sgn(1/(cos(x) + 1))*sgn(sin(x)) - log(2*sin(x)^2/(cos(x) + 1)^2 + 2)*sgn(1/(cos(x) + 1))*sgn(sin(x)) + log(sin(x)^2/(cos(x) + 1)^2 + 1)*sgn(1/(cos(x) + 1))*sgn(sin(x)) + 2*(sin(x)/((sin(x)^2/(cos(x) + 1)^2 + 1)*(cos(x) + 1)) + arctan(sin(x)/(cos(x) + 1)))*abs(sin(x))/abs(cos(x) + 1)

Not that this is all that useful, because if we call this f then f(pi) has division by zero error, and based on comments elsewhere it is probably wrong in any case. I have to admit I am surprised this isn't doable, though. See this ticket 17511 but there are lots of places this question has recurred.

edit flag offensive delete link more
0

answered 2015-02-03 15:41:30 +0200

marguin gravatar image

With Sage-4.7, integrate(abs(sin(t)),t,0,pi) returns 2 as expected.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-12-14 16:25:05 +0200

Seen: 993 times

Last updated: Feb 03 '15