Problem #1-0

Equations of Motion using Lagrangian

Clear["Global`*"]

kinE=(1/2)m1 ((x1'[t])^2)+(1/2)m2 ((x2'[t])^2)

potE=(1/2) k1 ((x1[t])^2)+(1/2) k2 (((x2[t]-x1[t]))^2)+(1/2) k3 ((x2[t])^2)

lag= kinE-potE

D[D[lag,x1'[t]],t]

D[lag,x1[t]]

Equations of Motion

eq1= D[D[lag,x1'[t]],t] - D[lag,x1[t]] //Simplify

eq2= D[D[lag,x2'[t]],t] - D[lag,x2[t]] //Simplify

M,K matrices

kmat={{k1+k2,-k2},{-k2,k2+k3}};
mmat={{m1,0},{0,m2}};
xvec={x1[t],x2[t]};
kmat //MatrixForm
mmat //MatrixForm

eq0=mmat.D[xvec,{t,2}]+ kmat.xvec;
eq0 //MatrixForm

eq0== {eq1,eq2}

Eigenvalues

det= kmat - w2 mmat;
det //MatrixForm

Det[det]

sol= Solve[Det[det]==0,w2] //Simplify

Choose Values: Set #1

rule1={k1,m1,k2,m2,k3} ->{k,m,k,m,k} //Thread

det1=det /.rule1;
det1 //MatrixForm

wsol= Solve[Det[det1]==0,w2]

Find Eigenvector #1:

det1 /.wsol[[1]] //MatrixForm

eqTmp = det1.{a1,a2}==0/.wsol[[1]]  //Thread

Solve[eqTmp,{a1,a2}]

evec1={1,1} //Normalize

Find Eigenvector #2:

det1 /.wsol[[2]] //MatrixForm

eqTmp = det1.{a1,a2}==0/.wsol[[2]]  //Thread

Solve[eqTmp,{a1,a2}]

evec2={1,-1} //Normalize

Construct Motion:

xMotion[t_,c1_,c2_]=  c1 evec1 Cos[w1 t] + c2 evec2 Cos[w2 t] /. {w1->(Sqrt[k/m]),w2->(Sqrt[3k/m])} /.{k->m}

xMotion[1.23,1,1]

Plot[ xMotion[t,1,0]+{+1,-1},{t,0,10}]

Plot[ xMotion[t,0,1]+{+1,-1},{t,0,10}]

Plot[ xMotion[t,1,1]+{+1,-1},{t,0,10}]

Diagonalize Matrices:

bmat={evec1,evec2};
bmat //MatrixForm

bmat.kmat.Transpose[bmat] /.rule1 //Simplify //MatrixForm

bmat.mmat.Transpose[bmat] /.rule1 //Simplify //MatrixForm

bmat.Transpose[bmat] //MatrixForm

Problem #1a

Equations of Motion using Lagrangian

Clear["Global`*"]

kinE=(1/2)m1 ((x1'[t])^2)+(1/2)m2 ((x2'[t])^2)

potE=(1/2) k1 ((x1[t])^2)+(1/2) k2 (((x2[t]-x1[t]))^2)+(1/2) k3 ((x2[t])^2)

lag= kinE-potE

D[D[lag,x1'[t]],t]

D[lag,x1[t]]

Equations of Motion

eq1= D[D[lag,x1'[t]],t] - D[lag,x1[t]] //Simplify

eq2= D[D[lag,x2'[t]],t] - D[lag,x2[t]] //Simplify

M,K matrices

kmat={{k1+k2,-k2},{-k2,k2+k3}};
mmat={{m1,0},{0,m2}};
xvec={x1[t],x2[t]};
kmat //MatrixForm
mmat //MatrixForm

eq0=mmat.D[xvec,{t,2}]+ kmat.xvec;
eq0 //MatrixForm

eq0== {eq1,eq2}

Eigenvalues

det= kmat - w2 mmat;
det //MatrixForm

Det[det]

sol= Solve[Det[det]==0,w2] //Simplify

Choose Values: Set #1

rule1={k1,m1,k2,m2,k3} ->{k,m,2k,m,k} //Thread

det1=det /.rule1;
det1 //MatrixForm

wsol= Solve[Det[det1]==0,w2]

Find Eigenvector #1:

det1 /.wsol[[1]] //MatrixForm

eqTmp = det1.{a1,a2}==0/.wsol[[1]]  //Thread

Solve[eqTmp,{a1,a2}]

evec1={1,1} //Normalize

Find Eigenvector #2:

det1 /.wsol[[2]] //MatrixForm

eqTmp = det1.{a1,a2}==0/.wsol[[2]]  //Thread

Solve[eqTmp,{a1,a2}]

evec2={1,-1} //Normalize

Construct Motion:

xMotion[t_,c1_,c2_]=  c1 evec1 Cos[w1 t] + c2 evec2 Cos[w2 t] /. {w1->(Sqrt[k/m]),w2->(Sqrt[5k/m])} /.{k->m}

xMotion[1.23,1,1]

Plot[ xMotion[t,1,0]+{+1,-1},{t,0,10}]

Plot[ xMotion[t,0,1]+{+1,-1},{t,0,10}]

Plot[ xMotion[t,1,1]+{+1,-1},{t,0,10}]

Diagonalize Matrices:

bmat={evec1,evec2};
bmat //MatrixForm

bmat.kmat.Transpose[bmat] /.rule1 //Simplify //MatrixForm

bmat.mmat.Transpose[bmat] /.rule1 //Simplify //MatrixForm

bmat.Transpose[bmat] //MatrixForm

Problem #1b

Equations of Motion using Lagrangian

Clear["Global`*"]

kinE=(1/2)m1 ((x1'[t])^2)+(1/2)m2 ((x2'[t])^2)

potE=(1/2) k1 ((x1[t])^2)+(1/2) k2 (((x2[t]-x1[t]))^2)+(1/2) k3 ((x2[t])^2)

lag= kinE-potE

D[D[lag,x1'[t]],t]

D[lag,x1[t]]

Equations of Motion

eq1= D[D[lag,x1'[t]],t] - D[lag,x1[t]] //Simplify

eq2= D[D[lag,x2'[t]],t] - D[lag,x2[t]] //Simplify

M,K matrices

kmat={{k1+k2,-k2},{-k2,k2+k3}};
mmat={{m1,0},{0,m2}};
xvec={x1[t],x2[t]};
kmat //MatrixForm
mmat //MatrixForm

eq0=mmat.D[xvec,{t,2}]+ kmat.xvec;
eq0 //MatrixForm

eq0== {eq1,eq2}

Eigenvalues

det= kmat - w2 mmat;
det //MatrixForm

Det[det]

sol= Solve[Det[det]==0,w2] //Simplify

Choose Values: Set #2

rule1={k1,m1,k2,m2,k3} ->{2 k,m, k,5m,10k} //Thread

det1=det /.rule1;
det1 //MatrixForm

wsol= Solve[Det[det1]==0,w2]

Find Eigenvector #1:

tmp= det1 /.wsol[[1]] //MatrixForm

Eigenvectors[(({{1, -1}, {-1, 1}}))]

eqTmp = det1.{a1,a2}==0/.wsol[[1]]  //Thread

Solve[eqTmp,{a1,a2}]

evec1={1,-1} //Normalize

Find Eigenvector #2:

det1 /.wsol[[2]] //MatrixForm

Eigenvectors[(({{-(k/5), -k}, {-k, -5 k}}))]

eqTmp = det1.{a1,a2}==0/.wsol[[2]]  //Thread

Solve[eqTmp,{a1,a2}]

evec2={((-1)/5),1} //Normalize

Construct Motion:

xMotion[t_,c1_,c2_]=  c1 evec1 Cos[w1 t] + c2 evec2 Cos[w2 t] /. {w1->(Sqrt[((2 k)/m)]),w2->(Sqrt[((16 k)/(5 m))])} /.{k->m}

xMotion[1.23,1,1]

Plot[ xMotion[t,1,0]+{+1,-1},{t,0,10}]

Plot[ xMotion[t,0,1]+{+1,-1},{t,0,10}]

Plot[ xMotion[t,1,1]+{+1,-1},{t,0,10}]

Problem #2-0

Equations of Motion using Lagrangian

Clear["Global`*"]

kinE=(1/2)m1 ((x1'[t])^2)+(1/2)m2 ((x2'[t])^2)

potE=(1/2) k1 ((x1[t])^2)+(1/2) k2 (((x2[t]-x1[t]))^2)

lag= kinE-potE

D[D[lag,x1'[t]],t]

D[lag,x1[t]]

Equations of Motion

eq1= D[D[lag,x1'[t]],t] - D[lag,x1[t]] //Simplify

eq2= D[D[lag,x2'[t]],t] - D[lag,x2[t]] //Simplify

M,K matrices

kmat={{k1+k2,-k2},{-k2,k2}};
mmat={{m1,0},{0,m2}};
xvec={x1[t],x2[t]};
kmat //MatrixForm
mmat //MatrixForm

Check against book example :

MatrixForm /@ ({ mmat ,kmat} /.{k1->3k, k2->k, m1->4m, m2->m} /.{k->1,m->1})

eq0=mmat.D[xvec,{t,2}]+ kmat.xvec;
eq0 //MatrixForm

eq0== {eq1,eq2}

Eigenvalues

det= kmat - w2 mmat;
det //MatrixForm

Det[det]

sol= Solve[Det[det]==0,w2] //Simplify

Choose Values: Set #1

rule1={k1,m1,k2,m2} ->{3k,4m,k,m}//Thread

det1=det /.rule1;
det1 //MatrixForm

wsol= Solve[Det[det1]==0,w2]

Find Eigenvector #1:

det1 /.wsol[[1]] //MatrixForm

eqTmp = det1.{a1,a2}==0/.wsol[[1]]  //Thread

Solve[eqTmp,{a1,a2}]

evec1={2,1} //Normalize

Find Eigenvector #2:

det1 /.wsol[[2]] //MatrixForm

eqTmp = det1.{a1,a2}==0/.wsol[[2]]  //Thread

Solve[eqTmp,{a1,a2}]

evec2={-2,1} //Normalize

Construct Motion:

xMotion[t_,c1_,c2_]=  c1 evec1 Cos[w1 t] + c2 evec2 Cos[w2 t] /. {w1->(Sqrt[(k/(2 m))]),w2->(Sqrt[((3 k)/(2 m))])} /.{k->m}

xMotion[1.23,1,1]

Plot[ xMotion[t,1,0]+{+1,-1},{t,0,10}]

Plot[ xMotion[t,0,1]+{+1,-1},{t,0,10}]

Plot[ xMotion[t,1,1]+{+1,-1},{t,0,10}]

Problem #2a

Equations of Motion using Lagrangian

Clear["Global`*"]

kinE=(1/2)m1 ((x1'[t])^2)+(1/2)m2 ((x2'[t])^2)

potE=(1/2) k1 ((x1[t])^2)+(1/2) k2 (((x2[t]-x1[t]))^2)

lag= kinE-potE

D[D[lag,x1'[t]],t]

D[lag,x1[t]]

eq1= D[D[lag,x1'[t]],t] - D[lag,x1[t]] //Simplify

eq2= D[D[lag,x2'[t]],t] - D[lag,x2[t]] //Simplify

M,K matrices

kmat={{k1+k2,-k2},{-k2,k2}};
mmat={{m1,0},{0,m2}};
xvec={x1[t],x2[t]};
kmat //MatrixForm
mmat //MatrixForm

Check against book example :

MatrixForm /@ ({ mmat ,kmat} /.{k1->3k, k2->k, m1->4m, m2->m} /.{k->1,m->1})

eq0=mmat.D[xvec,{t,2}]+ kmat.xvec;
eq0 //MatrixForm

eq0== {eq1,eq2}

Eigenvalues

det= kmat - w2 mmat;
det //MatrixForm

Det[det]

sol= Solve[Det[det]==0,w2] //Simplify

Choose Values: Set #1

rule1={k1,m1,k2,m2} ->{3k,m,2k,m} //Thread

det1=det /.rule1;
det1 //MatrixForm

wsol= Solve[Det[det1]==0,w2]

Find Eigenvector #1:

det1 /.wsol[[1]] //MatrixForm

eqTmp = det1.{a1,a2}==0/.wsol[[1]]  //Thread

Solve[eqTmp,{a1,a2}]

evec1={2,1} //Normalize

Find Eigenvector #2:

det1 /.wsol[[2]] //MatrixForm

eqTmp = det1.{a1,a2}==0/.wsol[[2]]  //Thread

Solve[eqTmp,{a1,a2}]

evec2={((-1)/2),1} //Normalize

Construct Motion:

xMotion[t_,c1_,c2_]=  c1 evec1 Cos[w1 t] + c2 evec2 Cos[w2 t] /. {w1->(Sqrt[(k/m)]),w2->(Sqrt[((6 k)/m)])} /.{k->m}

xMotion[1.23,1,1]

Plot[ xMotion[t,1,0]+{+1,-1},{t,0,10}]

Plot[ xMotion[t,0,1]+{+1,-1},{t,0,10}]

Plot[ xMotion[t,1,1]+{+1,-1},{t,0,10}]

Problem #2b

Equations of Motion using Lagrangian

Clear["Global`*"]

kinE=(1/2)m1 ((x1'[t])^2)+(1/2)m2 ((x2'[t])^2)

potE=(1/2) k1 ((x1[t])^2)+(1/2) k2 (((x2[t]-x1[t]))^2)

lag= kinE-potE

D[D[lag,x1'[t]],t]

D[lag,x1[t]]

Equations of Motion

eq1= D[D[lag,x1'[t]],t] - D[lag,x1[t]] //Simplify

eq2= D[D[lag,x2'[t]],t] - D[lag,x2[t]] //Simplify

M,K matrices

kmat={{k1+k2,-k2},{-k2,k2}};
mmat={{m1,0},{0,m2}};
xvec={x1[t],x2[t]};
kmat //MatrixForm
mmat //MatrixForm

Check against book example :

MatrixForm /@ ({ mmat ,kmat} /.{k1->3k, k2->k, m1->4m, m2->m} /.{k->1,m->1})

eq0=mmat.D[xvec,{t,2}]+ kmat.xvec;
eq0 //MatrixForm

eq0== {eq1,eq2}

Eigenvalues

det= kmat - w2 mmat;
det //MatrixForm

Det[det]

sol= Solve[Det[det]==0,w2] //Simplify

Choose Values: Set #1

rule1={k1,m1,k2,m2} ->{4k,3m,k,m} //Thread

det1=det /.rule1;
det1 //MatrixForm

wsol= Solve[Det[det1]==0,w2]

Find Eigenvector #1:

det1 /.wsol[[1]] //MatrixForm

eqTmp = det1.{a1,a2}==0/.wsol[[1]]  //Thread

Solve[eqTmp,{a1,a2}]

evec1={2,1} //Normalize

Find Eigenvector #2:

det1 /.wsol[[2]] //MatrixForm

eqTmp = det1.{a1,a2}==0/.wsol[[2]]  //Thread

Solve[eqTmp,{a1,a2}]

evec2={((-1)/2),1} //Normalize

Construct Motion:

xMotion[t_,c1_,c2_]=  c1 evec1 Cos[w1 t] + c2 evec2 Cos[w2 t] /. {w1->(Sqrt[((2 k)/(3 m))]),w2->(Sqrt[((2 k)/m)])} /.{k->m}

xMotion[1.23,1,1]

Plot[ xMotion[t,1,0]+{+1,-1},{t,0,10}]

Plot[ xMotion[t,0,1]+{+1,-1},{t,0,10}]

Plot[ xMotion[t,1,1]+{+1,-1},{t,0,10}]