1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica: position vs time in a spring

  1. May 19, 2012 #1
    1. The problem statement, all variables and given/known data

    Plot the position vs time graph of an object attached to a spring.
    m = 0.5 kg
    k = 60 N/m
    x[0] = 3 m
    v[0] = 4 m/s

    2. Relevant equations

    d²x/dt² + (k/m)*x = 0

    3. The attempt at a solution

    I solved the differential equation using DSolve and plotted the resulting function, ok. But what if there was friction? I have no idea how I'd plot that graph.

    And sorry for my bad english. D:
     
  2. jcsd
  3. May 20, 2012 #2

    ehild

    User Avatar
    Homework Helper
    Gold Member

    Friction would change the differential equation. If the object slides on a horizontal surface, the force of friction is constant in magnitude, but opposite to velocity, v=dx/dt.
    It is also possible that "friction" means some resistive force and is proportional to the velocity, and opposite to it. Then the equation will be

    d²x/dt² + (k/m)*x +γ/m dx/dt= 0, the equation of a damped harmonic oscillator.



    ehild
     
  4. May 20, 2012 #3
    It worked, but I still don't get it. I thought friction was independent of velocity, so what is this "friction"?
     
  5. May 21, 2012 #4

    ehild

    User Avatar
    Homework Helper
    Gold Member

    You did not specify the kind of friction and its value.

    Sliding friction is independent of the magnitude of velocity, but depends on its sign - it is opposite to the velocity v. Fr=-μg sgn(v).
    So you have to solve the equation

    d²x/dt² + (k/m)*x +μg/m*sgn(dx/dt)= 0

    with the condition that both x(t) and dx/dt are continuous.
    An example is shown here: http://www.wolframalpha.com/input/?i=x"+x+0.1sgn(x')=0

    ehild
     
    Last edited: May 21, 2012
  6. May 23, 2012 #5
    Thanks, I understand it now, but when I try to solve this equation using Mathematica nothing happens. The program sends back to me the same thing I typed and no error messages.
     
  7. May 24, 2012 #6

    ehild

    User Avatar
    Homework Helper
    Gold Member

    The solution is "piecewise" and the "pieces" depend very much on the parameters and initial conditions. There is no solution in a closed form.
    Wolframalpha did not work with the general equation, either.
    Try to give Mathematica the equation with numerical parameters and initial conditions and see if it does anything.


    ehild
     
  8. May 24, 2012 #7
    This is what I'm doing:

    m := 0.5(* kg *)
    k := 60(* N/m *)
    μ := 0.4
    g := 10(* m/s² *)
    DSolve[{x''[t] + (k/m)*x[t] + μ*g*Sign[x'[t]] == 0, x[0] == 3,
    x'[0] == 4}, x[t], t]
     
  9. May 24, 2012 #8

    ehild

    User Avatar
    Homework Helper
    Gold Member

    It is a complicated problem, and Mathematica might not be able to handle it.

    ehild
     
  10. May 24, 2012 #9

    vela

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Education Advisor

    You could try using NDSolve to get a numerical solution.
     
  11. May 24, 2012 #10

    gabbagabbahey

    User Avatar
    Homework Helper
    Gold Member

    Mathematica can't solve this analytically, that's why it spits out exactly what you put into it. You can probably get a numerical solution with NDSolve (It's been a while since I've used mathematica, but I think that is what it is called).

    A more typical setup (as far as nice analytical solutions go) is a velocity dependant damping (such as from air resitance).
     
  12. May 24, 2012 #11
    Thanks guys, I'll just use the other equation.
     
  13. May 25, 2012 #12

    ehild

    User Avatar
    Homework Helper
    Gold Member

    The equation d²x/dt² + (k/m)*x +μg/m*sgn(dx/dt)= 0
    I suggested in #4 is not quite correct. The sign function returns zero for v=0, but the force of friction is not zero. But it is static friction. Assuming that static and kinetic frictions are the same, the direction of friction is opposite to x(t) when v=0.

    It has to be checked at every turning point if the elastic force is enough to overcome friction, that is |x|>μg/k

    So the equation

    d²x/dt² + (k/m)*x +μg/m*sgn(dx/dt)= 0

    has to be solved according to the initial conditions, but the solution is valid for 0<t<t1, where v(t1)=0.
    Check if |x(t1)|>μg/k.
    In the next step, the initial conditions are x(t1) and v(t1)=0, with opposite sign for the friction. It goes on till v reaches zero again...

    ehild
     
  14. Jun 5, 2012 #13
    Thanks again. :)
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Mathematica: position vs time in a spring
  1. Position vs time graph (Replies: 3)

  2. Position vs Time Lab (Replies: 2)

Loading...