Message Boards Message Boards

0
|
19716 Views
|
7 Replies
|
7 Total Likes
View groups...
Share
Share this post:

Use Assumptions and Integrate?

Posted 7 years ago

Mathematica 11.1

Can someone explain why in the following "Assumptions" does not work as expected:

Integrate[ Sin[n x]^2, {x, 0, 2 Pi},  Assumptions -> n \[Element] Integers]

This gives:

Pi - Sin[4 n Pi ]/(4 n)

The second part is clearly redundant, but not even "Simplify" or "FullSimplify" will eliminate it.

POSTED BY: Daniel Huber
7 Replies

The result is correct, because one needs to account for n = 0, for this case the integral is 0. (The limit of the Sin[4n\[Pi]]/(4*n) for n -> 0 is Pi, such that it is cancelled.

I would say that it is perhaps a bug in FullSimplify. Though sometimes solutions are given that are true for most values. Like e.g.

Integrate[x^n, x]
Integrate[x^-1, x]

The first result will not work for n = -1. When to take the solution that is 'mostly' correct, and when not, is tricky business. Perhaps @Daniel Lichtblau can comment on this...

POSTED BY: Sander Huisman

Dear Sander,

I don't think that this is a bug. In the documentation for FullSimplify under Possible Issues it says:

Some of the transformations used by FullSimplify are only generically correct:

I think that this is one of these cases.

Cheers,

Marco

POSTED BY: Marco Thiel

That was exactly my point; sometimes they simplify to things that are correct most of the time, like my example...

POSTED BY: Sander Huisman
Posted 7 years ago

Hi Sander,

unfortunately the same "singularity" shows even when you exclude the case n = 0:

Integrate[ Sin[n x]^2, {x, 0, 2 Pi}, Assumptions -> n>0]

POSTED BY: Daniel Huber

If you want to make a point you should include the other assumption as well:

Integrate[Sin[n x]^2, {x, 0, 2 Pi}, Assumptions -> n > 0 \[And] n \[Element] Integers]

And yes, I agree, for this case it could be more simplified. However, Integrate does not promise you to give the easiest possible outcome, it gives you the right result (which it does!), maybe not the simplest result. FullSimplify/Refine on the other hand (kinda) does promise you to give the simplest possible expression (which it does!), as per @Marco Thiel's answer.

So this is all correct and expected outcome. The result is ok but could be simplified. As also described in the documentation of Integrate (under possible issues)

> Specifying integer assumptions may not give a simpler result:

with nearly the same example as the OP. They propose to use refine, rather than FullSimplify, which might, indeed, be better suited for this...

POSTED BY: Sander Huisman

Dear Daniel,

FullSimplify will eliminate it. But you have to tell it the assumptions again:

FullSimplify[Integrate[Sin[n x]^2, {x, 0, 2 Pi}, Assumptions -> n[Element] Integers], Assumptions -> n \[Element] Integers]

gives just Pi. Of course, one assumption in the outer most function does the trick, too.

FullSimplify[Integrate[Sin[n x]^2, {x, 0, 2 Pi}],  Assumptions -> n \[Element] Integers]

Cheers,

Marco

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract