>
restart:
>
with(LinearAlgebra):
with(plots):
>
#sortowanie proc
>
>
#Zad1
>
E:=1/2*m*add(v[i]^2,i=1..5):
>
U:=1/2*k*add((x[i+1]-x[i])^2,i=1..4):
>
>
#Zad2
>
n:=5:
>
K:=Matrix(n):
>
M:=Matrix(n):
>
for i to n do
for j to n do
K[i,j]:=diff(U,x[i],x[j]);
M[i,j]:=diff(E,v[i],v[j]);
end do;
end do;
>
K:
>
M:
>
>
#Zad3
>
A:=1/M.K:
>
>
#Zad4
>
m:=1: k:=100:
>
alpha,V:=evalf(Eigenvectors(A)):
>
>
#Zad5
>
alpha,V:=sortowanie(alpha,V):
>
>
#Zad6
>
for i from 1 to n do
w[i]:=V[1..n,i]/(sqrt((V[1..n,i]^%T).M.V[1..n,i])):
end do:
>
>
#Zad7
>
for i from 1 to n do
omega[i]:=sqrt(alpha[i])
end do:
>
>
#Zad8
>
x0:=Vector(5,[0,0,0,0,0]):
>
v0:=Vector(5,[10,0,0,0,0]):
>
>
#Zad9
>
x:=(Transpose(w[1]).M.(x0+v0*t))*w[1]+add((Transpose(w[1]).M.(x0*cos(om
ega[i]*t)+v0*sin(omega[i]*t)/omega[i]))*w[i], i=2..5):