16.12.2012 Views

Computer Algebra Recipes

Computer Algebra Recipes

Computer Algebra Recipes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.2. SECOND-ORDER MODELS 123<br />

Loading the plots package, we use the alias command. Entering x1, x2, m1,<br />

m2 will produce the subscripted quantities x1, x2, m1, andm2in the output.<br />

> restart: with(plots):<br />

> alias(x[1]=x1,x[2]=x2,m[1]=m1,m[2]=m2):<br />

When m2 is displaced from equilibrium by amount x2 at time t in, say, the<br />

positive x-direction, it exerts a force on m1 through the connecting spring. If<br />

m1 is displaced from equilibrium by amount x1(t), the force exerted on m1 by<br />

m2 is k (x2(t) ¡ x1(t)). The spring connected to the wall will exert a force<br />

¡kx1(t) in the opposite direction. Including damping, Newton's second law<br />

yields the ODE ode1 governing the displacement x1(t) ofm1.<br />

> ode1:=m1*diff(x1(t),t,t)<br />

=k*(x2(t)-x1(t))-k*x1(t)-a*diff(x1(t),t);<br />

μ <br />

μ 2 d d<br />

ode1 := m1 x1(t) = k (x2(t) ¡ x1(t)) ¡ k x1(t) ¡ a<br />

dt2 dt x1(t)<br />

<br />

The mass m1 will exert an equal and opposite force on m2 through the connecting<br />

spring, i.e., ¡k (x2(t) ¡ x1(t)). Including the damping and driving forces,<br />

the displacement x2(t) ofm2 is given by the ODE ode2 .<br />

> ode2:=m2*diff(x2(t),t,t)<br />

=-k*(x2(t)-x1(t))-a*diff(x2(t),t)+f*sin(omega*t);<br />

μ <br />

μ 2 d d<br />

ode2 := m2 x2(t) = ¡k (x2(t) ¡ x1(t)) ¡ a<br />

dt2 dt x2(t)<br />

<br />

+ f sin(!t)<br />

One has a system of two coupled, linear, second-order, inhomogeneous ODEs.<br />

To solve them, let's ¯rst enter the given parameter values,<br />

> m1:=2: m2:=1: k:=1: a:=1: omega:=2: f:=2:<br />

and the initial conditions.<br />

> ic:=x1(0)=1,x2(0)=0,D(x1)(0)=0,D(x2)(0)=0:<br />

The set of ODEs is analytically solved for x1(t) andx2(t), subject to the initial<br />

conditions, using the dsolve command with the Laplace transform option.<br />

The same answer could be obtained by mimicking the hand calculation in the<br />

previous example. This is left as a problem.<br />

> sol:=dsolve(fode1,ode2,icg,fx1(t),x2(t)g,method=laplace);<br />

sol := fx1(t) = 36<br />

26<br />

cos(2 t)+ sin(2 t)<br />

493 493<br />

¡ 1 X<br />

( (56380 + 339955 ® + 193087 ®<br />

194242<br />

®=%1<br />

2 + 188250 ® 3 ) e ( ®t) )g;<br />

fx2(t) =¡ 164 228<br />

cos(2 t) ¡ sin(2 t)<br />

493 493<br />

¡ 1 X<br />

( (107923 + 533529 ® + 249954 ®<br />

194242<br />

®=%1<br />

2 + 293736 ® 3 ) e ( ®t) )g<br />

%1 := RootOf(2 Z 4 +3 Z 3 +5 Z 2 +3 Z +1)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!