damped spring problem using mathematica

voyage200

New member
Joined
Nov 7, 2006
Messages
4
Suppose that an object with mass 3 kg is attached to a damped spring with spring constant 4 kg/sec^2 and damping force equal to 2.5 times the object's velocity. The object is initially at rest in the equilibrium position. After one second, the object experiences an applied external force of 2 kg-m/sec^2 for 1 second. I have to use mathematica to to find the position of the object at any time t > 0. Then I'm supposed to plot the applied force and the solution (called the response to the force) on the same graph.
I'm new to mathematica and need some help with this. What I got so far (not in mathematica code yet) is: 3y''(t) + 2.5y'(t) + 4y(t) = 0. Is this the right differential equation and how do I put it in mathematica?
 
i also got

using mathematica: DSolve[3y''[x] + 2.5y'[x] + 4y[x] == 0, y[x], x]
I think one condition is y[0]=0, but I don't know what others there are and how to use them with mathematica.
 
Firstly, your DE is fine, Voyage.

The other initial condition relevant is that of y'(t).

For 0 <= t <= 1: the solution corresponds to the DE with a zero right-hand side (no applied force) and with initial conditions y(0)=0 (since it is at the equilibrium position at t=0) and y'(0)=0 (since it is at rest at t=0).

For 1 <= t <= 2: the DE has 2 on the right-hand side (an applied force) and the initial conditions are the values of y(1) and y'(1) from the previous.

For 2 <= t: the DE has 0 on the right-hand side again and the initial conditions are the values of y(2) and y'(2) from the previous case.

Here is the appropriate code for Maple, which is reasonably similar to Mathematica. You can always use the Help section in the program (which I assume it has) or online.

Code:
> DE1:=3*diff(y(t),t,t)+2.5*diff(y(t),t)+4*y(t)=0:
> DE2:=3*diff(y(t),t,t)+2.5*diff(y(t),t)+4*y(t)=2:
> sol1:=dsolve({DE1,y(0)=0,D(y)(0)=0},y(t)):
> sol2:=dsolve({DE2,y(1)=plot2inity,D(y)(1)=plot2initdy},y(t)):
> sol3:=dsolve({DE1,y(2)=plot3inity,D(y)(2)=plot3initdy},y(t)):
> plot1:=plot(rhs(sol1),t=0..1):
> plot2:=plot(rhs(sol2),t=1..2):
> plot2inity:=subs(t=1,plot1):
> plot2initdy:=subs(t=1,diff(plot1,t)):
> plot3inity:=subs(t=2,plot2):
> plot3initdy:=subs(t=2,diff(plot2,t)):
> plot3:=plot(rhs(sol3),t=2..15):
> appliedforce:=plot(2,t=1..2,color=blue):
> with(plots):
> display({plot1,plot2,plot3,appliedforce});
 
Top