Mathematica Mathematica Help: Evaluating Expressions with Integers in Calculus

  • Thread starter Thread starter Dragonfall
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
The discussion centers on evaluating a specific mathematical expression in Mathematica, where the user encounters incorrect results due to the software interpreting "nx" as a single variable instead of the intended multiplication of "n" and "x." A key solution involves inserting a space between "n" and "x" to clarify the multiplication. Additionally, it is suggested that using "Integrate" instead of the symbolic integration sign may help avoid issues. The conversation highlights the importance of proper syntax in Mathematica to ensure accurate evaluations.
Dragonfall
Messages
1,023
Reaction score
5
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

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

Attachments

  • Picture 1.png
    Picture 1.png
    1.2 KB · Views: 447
Last edited:
Physics news on Phys.org
You need to put a space between your n and x. Mathematica is treating nx as a single variable, which explains the funky result.
 
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.
 
Use '*' everywhere, to avoid possible problems. Doesn't look nice, though, but nevermind.
 
The error was the missing *. Thanks for the help.
 
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.
 

Similar threads

Replies
1
Views
2K
Replies
3
Views
2K
Replies
2
Views
1K
Replies
4
Views
3K
Replies
10
Views
12K
Replies
6
Views
1K
Back
Top