Physics Forums

Physics Forums (http://www.physicsforums.com/index.php)
-   Math & Science Software (http://www.physicsforums.com/forumdisplay.php?f=189)
-   -   Mathematica Help (http://www.physicsforums.com/showthread.php?t=140481)

Dragonfall Oct29-06 11:57 AM

Mathematica Help
 
1 Attachment(s)
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]

Stephan Hoyer Oct30-06 04:38 AM

You need to put a space between your n and x. Mathematica is treating nx as a single variable, which explains the funky result.

FredGarvin Oct30-06 06:39 AM

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.

radou Oct30-06 06:44 AM

Use '*' everywhere, to avoid possible problems. Doesn't look nice, though, but nevermind.

Dragonfall Oct30-06 03:16 PM

The error was the missing *. Thanks for the help.

radou Oct30-06 03:28 PM

Quote:

Quote by Dragonfall
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.


All times are GMT -5. The time now is 05:55 PM.

Powered by vBulletin Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2014 Physics Forums