• Support PF! Buy your school textbooks, materials and every day products Here!

Mathematica: position vs time in a spring

  • Thread starter Fre4k
  • Start date
  • #1
12
0

Homework Statement



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

Homework Equations



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

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:
 

Answers and Replies

  • #2
ehild
Homework Helper
15,498
1,878
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
 
  • #3
12
0
It worked, but I still don't get it. I thought friction was independent of velocity, so what is this "friction"?
 
  • #4
ehild
Homework Helper
15,498
1,878
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:
  • #5
12
0
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.
 
  • #6
ehild
Homework Helper
15,498
1,878
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
 
  • #7
12
0
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]
 
  • #8
ehild
Homework Helper
15,498
1,878
It is a complicated problem, and Mathematica might not be able to handle it.

ehild
 
  • #9
vela
Staff Emeritus
Science Advisor
Homework Helper
Education Advisor
14,640
1,278
You could try using NDSolve to get a numerical solution.
 
  • #10
gabbagabbahey
Homework Helper
Gold Member
5,002
6
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]
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).
 
  • #11
12
0
Thanks guys, I'll just use the other equation.
 
  • #12
ehild
Homework Helper
15,498
1,878
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
 
  • #13
12
0
Thanks again. :)
 

Related Threads on Mathematica: position vs time in a spring

  • Last Post
Replies
7
Views
4K
Replies
1
Views
538
  • Last Post
Replies
2
Views
1K
Replies
2
Views
40K
Replies
4
Views
113K
Replies
2
Views
7K
Replies
3
Views
2K
  • Last Post
Replies
5
Views
3K
Replies
5
Views
2K
  • Last Post
Replies
3
Views
1K
Top