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

Homework Help: Help with Mathematica?

  1. Sep 13, 2010 #1
    1. The problem statement, all variables and given/known data
    Graph in Mathematica to solve d^2theta/dt^2 + g/lsin(theta)= 0
    Show a graph of period vs. Theta not.

    2. Relevant equations

    3. The attempt at a solution

    I am not very experienced with entering information into mathematica. I am aware that the manipulate plot functions are probably necessary for graphing them, however after watching a number of help videos on mathematica I have failed miserably.

    For instance:

    Solve[{(d^2 x)/dt^2 - gsin[x] == 0}, {x, g}] is one attempt, and I realize that I mistakenly put a - instead of + sign in.

    I have tried using Solve, Plot, Integrate, Dsolve....
    I am simply lost.

    Could anybody help me with mathematica?

  2. jcsd
  3. Sep 13, 2010 #2


    User Avatar
    Science Advisor
    Homework Helper

    Solve just solves "ordinary" equations, for differential equations use DSolve:
    Code (Text):

    DSolve[x''[t] - g Sin[x[t]] == 0, x, t]
    (note that you have to write the function dependence x(t) instead of x everywhere).
  4. Sep 13, 2010 #3
    Thanks! That makes considerably more sense. But I'm still not sure how to graph the function...
  5. Sep 13, 2010 #4
    I think you need to solve an initial value problem, preferably numerically, then plot the results of that calculation. Tell you what, I'll show you how to do:

    [tex]y''+y=0,\quad y(0)=0,\quad y'(0)=1[/tex]

    and you figure how to modify it to do yours.

    Code (Text):

    mysol = NDSolve[{Derivative[2][y][t] +
               y[t] == 0, y[0] == 0,
           Derivative[1][y][0] == 1}, y,
         {t, 0, 2*Pi}]
    Plot[y[t] /. mysol, {t, 0, 2*Pi},
       PlotRange -> {{0, 2*Pi}, {-5, 5}}]
  6. Sep 14, 2010 #5
    Thanks so much everyone!

    I think I've mostly figured it out. Turns out there is a very applicable example in the mathematica database. But I rerused it and modified it sort of.

    s = NDSolve[{y''[x] + 10*Sin[y[x]] == 0, y[0] == 1, y'[0] == 0},
    y, {x, 0, 30}]

    and then

    Plot[Evaluate[{y[x]} /. s], {x, 0, 30}, PlotStyle -> Automatic].

    And you get a nice graph.

    Thanks all
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook