Mathematica Help: Evaluating Expressions with Integers in Calculus

  • Context: Mathematica 
  • Thread starter Thread starter Dragonfall
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary

Discussion Overview

The discussion revolves around evaluating a specific expression in Mathematica, particularly focusing on the integration of trigonometric functions with the assumption that n is an integer. The scope includes technical troubleshooting related to syntax and functionality within Mathematica.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant reports that Mathematica's output for the integral expression is incorrect compared to Maple, suggesting a potential issue with how Mathematica interprets the input.
  • Another participant suggests that a space between 'n' and 'x' may resolve the issue, as Mathematica might be treating 'nx' as a single variable.
  • A different participant recalls reading about issues with symbolic integration in Mathematica and recommends using "Integrate" instead of the symbolic operator if the previous suggestion does not work.
  • One participant advises using '*' to explicitly denote multiplication, although they acknowledge it may not look aesthetically pleasing.
  • One participant confirms that the missing '*' was the source of the error and expresses gratitude for the assistance received.
  • A later reply reiterates that using a space instead of '*' is also a valid solution, as it allows Mathematica to recognize the multiplication correctly.

Areas of Agreement / Disagreement

Participants generally agree that the issue stems from syntax errors related to multiplication in Mathematica. However, there are multiple suggested approaches to resolve the problem, indicating a lack of consensus on the best method.

Contextual Notes

Limitations include potential misunderstandings of Mathematica's syntax rules and the specific conditions under which the integration is performed. The discussion does not resolve the underlying mathematical properties of the expression itself.

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: 465
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 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 14 ·
Replies
14
Views
2K
Replies
5
Views
2K
  • · Replies 10 ·
Replies
10
Views
13K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K