Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica Help

  1. Oct 29, 2006 #1
    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]
     

    Attached Files:

    Last edited: Oct 29, 2006
  2. jcsd
  3. Oct 30, 2006 #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.
     
  4. Oct 30, 2006 #3

    FredGarvin

    User Avatar
    Science Advisor

    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.
     
  5. Oct 30, 2006 #4

    radou

    User Avatar
    Homework Helper

    Use '*' everywhere, to avoid possible problems. Doesn't look nice, though, but nevermind.
     
  6. Oct 30, 2006 #5
    The error was the missing *. Thanks for the help.
     
  7. Oct 30, 2006 #6

    radou

    User Avatar
    Homework Helper

    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.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook




Loading...
Similar Threads for Mathematica Help Date
Mathematica Mathetica function (help fix my equation please) Mar 15, 2016
Mathematica Undetermined gauges (Help in mathematica)() Oct 27, 2014
Mathematica Help with "Which[] in a For loop using Mathematica Sep 12, 2014
New to mathematica, some basic help needed May 10, 2014
Mathematica NDSolve conditions help Dec 22, 2013