Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I was trying to calculate this integral in Mathematica 9:

2/π Integrate[ Cosh[a x] Cos[n x], {x, 0, π}, Assumptions -> n ∈ Integers]

I got as a result :

$$\frac{2 (a \sinh (\pi a) \cos (\pi n)+n \cosh (\pi a) \sin (\pi n))}{\pi \left(a^2+n^2\right)}$$

That's the same result I obtained manually, but how can I force Mathematica to change $\sin(n \pi)$ into $0$ and $\cos(n \pi)$ into $(-1)^n$ ?

share|improve this question
3  
Did you already try Assuming[Element[n, Integers], 2/Pi Integrate[Cosh[a x] Cos[n x], {x, 0, Pi}]]? –  J. M. Jun 22 '13 at 9:34
    
Thank you, it does work indeed, what's wrong with the form I used ? (Assumptions -> ...) Maybe you could post this as an answer so I can award you the points –  Skydreamer Jun 22 '13 at 9:35
    
I'm not quite sure why one works and the other doesn't, even though they are ostensibly equivalent; the reason I left a comment is because I am not at a machine with Mathematica. Might I suggest writing your own answer to your own question instead? –  J. M. Jun 22 '13 at 9:39
    
I'm on it, thank you for the help ! –  Skydreamer Jun 22 '13 at 9:41
2  
You can do it also this way: Simplify[2/Pi Integrate[Cosh[a x] Cos[n x], {x, 0, Pi}], Element[n, Integers]], it should work in more general cases than your original problem. –  Artes Jun 22 '13 at 9:41

1 Answer 1

up vote 7 down vote accepted

Thanks to 0x4A4D and Artes, I figured out what the problem was.

I had to change

2/π Integrate[ Cosh[a x] Cos[n x], {x, 0, π}, Assumptions -> n ∈ Integers]

into

Assuming[ n ∈ Integers, 2/π Integrate[ Cosh[a x] Cos[n x], {x, 0, π}]]

or

Simplify[ 2/π Integrate[ Cosh[a x] Cos[n x], {x, 0, π}], n ∈ Integers]

I don't know what's the problem with the first form but still, it works !

share|improve this answer
    
If you set the assumptions outside the scope of Integrate[], that is inside Assuming[] or Simplify[] then Integrate[] doesn't mess with them. That is how I understand it. Check this link also. mathematica.stackexchange.com/questions/19833/… –  Zet Nov 11 '13 at 9:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.