Mathematica: position vs time in a spring

In summary, the conversation discusses how to plot the position vs time graph of an object attached to a spring. The equations and attempt at a solution are provided, but the conversation then turns to the inclusion of friction in the problem. Different types of friction are discussed and a modified equation is provided for a damped harmonic oscillator. Mathematica is suggested as a tool for solving the equation, but it is noted that it may not be able to handle the complexity of the problem. An alternative equation is suggested to account for static friction, and the conversation ends with a final thank you.
  • #1
Fre4k
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:
 
Physics news on Phys.org
  • #2
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
It worked, but I still don't get it. I thought friction was independent of velocity, so what is this "friction"?
 
  • #4
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
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
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
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
It is a complicated problem, and Mathematica might not be able to handle it.

ehild
 
  • #9
You could try using NDSolve to get a numerical solution.
 
  • #10
Fre4k said:
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
Thanks guys, I'll just use the other equation.
 
  • #12
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
Thanks again. :)
 

Related to Mathematica: position vs time in a spring

1. What is Mathematica?

Mathematica is a powerful computational software program used for various mathematical and scientific purposes, such as data analysis, visualization, and modeling.

2. How can Mathematica be used to analyze position vs time in a spring?

Mathematica has built-in functions and tools for handling mathematical equations and data, making it useful for analyzing position vs time in a spring. Users can input the relevant equations and data to create visualizations and manipulate the data to gain insights.

3. What is the significance of studying position vs time in a spring?

Understanding the relationship between position and time in a spring can provide insights into the behavior and properties of springs, which are commonly used in various mechanical systems such as shock absorbers and suspension systems.

4. Can Mathematica be used to create simulations of spring behavior?

Yes, Mathematica has a built-in function called "Manipulate" that allows users to create interactive simulations. By inputting the relevant equations and data, users can manipulate parameters and observe the resulting changes in the spring's position over time.

5. Is Mathematica difficult to learn for analyzing position vs time in a spring?

While Mathematica has a steep learning curve, it has a user-friendly interface and a vast community of users who provide resources and support. With some practice and guidance, users can quickly become proficient in using Mathematica for analyzing position vs time in a spring.

Similar threads

  • Introductory Physics Homework Help
Replies
16
Views
481
  • Introductory Physics Homework Help
Replies
5
Views
603
  • Introductory Physics Homework Help
Replies
3
Views
1K
  • Introductory Physics Homework Help
Replies
2
Views
2K
  • Introductory Physics Homework Help
Replies
3
Views
900
  • Introductory Physics Homework Help
Replies
2
Views
977
  • Introductory Physics Homework Help
Replies
17
Views
550
  • Introductory Physics Homework Help
Replies
2
Views
1K
  • Introductory Physics Homework Help
Replies
7
Views
904
  • Introductory Physics Homework Help
Replies
24
Views
1K
Back
Top