Mathematica Help

  • Mathematica
  • Thread starter Dragonfall
  • Start date
  • #1
1,030
4
I want mathematica to evaluate a certain expression (see attached) assuming that n is an integer. The answer is far from what it produces. Maple produces the right answer but I don't have access to it.

The expression is

[tex]\frac{\int_{-\pi}^{\pi}|\sin(x)|\cos(nx)\dx}{\int_{-\pi}^{\pi}\cos^2(nx)\dx}[/tex]
 

Attachments

Last edited:

Answers and Replies

  • #2
You need to put a space between your n and x. Mathematica is treating nx as a single variable, which explains the funky result.
 
  • #3
FredGarvin
Science Advisor
5,066
8
One other thing to try...I don't have Mathematica in front of me here at work, but I do remember also reading an article about Mathematica getting into a bit of trouble in some cases when using the sybolic integration sign. If Stephan's tip doesn't help, you may try using "Integrate" instead of the symbolic operator.
 
  • #4
radou
Homework Helper
3,115
6
Use '*' everywhere, to avoid possible problems. Doesn't look nice, though, but nevermind.
 
  • #5
1,030
4
The error was the missing *. Thanks for the help.
 
  • #6
radou
Homework Helper
3,115
6
Dragonfall said:
The error was the missing *. Thanks for the help.
Yes. But note that, as someone above stated, you can simply use the space bar instead of '*'. Mathematica will produce a small space between the two object that are multiplied.
 

Related Threads on Mathematica Help

  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
11
Views
2K
  • Last Post
Replies
9
Views
7K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
2
Views
3K
Replies
5
Views
2K
  • Last Post
Replies
13
Views
6K
  • Last Post
Replies
8
Views
11K
Top