In analytical mechanics, the mass matrix is a symmetric matrix M that expresses the connection between the time derivative
q
˙
of the generalized coordinate vector q of a system and the kinetic energy T of that system, by the equation
T
=
1
2
q
˙
T
M
q
˙
where
q
˙
T
denotes the transpose of the vector
q
˙
. This equation is analogous to the formula for the kinetic energy of a particle with mass
m
and velocity v, namely
T
=
1
2
m

v

2
=
1
2
v
⋅
m
v
and can be derived from it, by expressing the position of each particle of the system in terms of q.
In general, the mass matrix M depends on the state q, and therefore varies with time.
Lagrangian mechanics yields an ordinary differential equation (actually, a system of coupled differential equations) that describes the evolution of a system in terms of an arbitrary vector of generalized coordinates that completely defines the position of every particle in the system. The kinetic energy formula above is one term of that equation, that represents the total kinetic energy of all the particles.
For example, consider a system consisting of two pointlike masses confined to a straight track. The state of that systems can be described by a vector q of two generalized coordinates, namely the positions of the two particles along the track.
q
=
[
x
1
x
2
]
T
.
Supposing the particles have masses m_{1}, m_{2}, the kinetic energy of the system is
T
=
∑
i
=
1
2
1
2
m
i
x
˙
i
2
This formula can also be written as
T
=
1
2
q
˙
T
M
q
˙
where
M
=
[
m
1
0
0
m
2
]
More generally, consider a system of N particles labelled by an index i = 1, 2,...,N, where the position of particle number i is defined by n_{i} free Cartesian coordinates (where n_{i} is 1, 2, or 3). Let q be the column vector comprising all those coordinates. The mass matrix M is the diagonal block matrix where in each block the diagonal elements are the mass of the corresponding particle:
M
=
d
i
a
g
[
m
1
I
n
1
,
m
2
I
n
2
,
⋯
,
m
N
I
n
N
]
where I_{n i} is the n_{i} × n_{i} identity matrix, or more fully:
M
=
[
m
1
⋯
0
0
⋯
0
⋯
0
⋯
0
⋮
⋱
⋮
⋮
⋱
⋮
⋱
⋮
⋱
⋮
0
⋯
m
1
0
⋯
0
⋯
0
⋯
0
0
⋯
0
m
2
⋯
0
⋯
0
⋯
0
⋮
⋱
⋮
⋮
⋱
⋮
⋱
⋮
⋱
⋮
0
⋯
0
0
⋯
m
2
⋯
0
⋯
0
⋮
⋱
⋮
⋮
⋱
⋮
⋱
⋮
⋱
⋮
0
⋯
0
0
⋯
0
⋯
m
N
⋯
0
⋮
⋱
⋮
⋮
⋱
⋮
⋱
⋮
⋱
⋮
0
⋯
0
0
⋯
0
⋯
0
⋯
m
N
]
For a less trivial example, consider two pointlike objects with masses m_{1}, m_{2}, attached to the ends of a rigid massless bar with length 2R, the assembly being free to rotate and slide over a fixed plane. The state of the system can be described by the generalized coordinate vector
q
=
[
x
,
y
,
α
]
where x, y are the Cartesian coordinates of the bar's midpoint and α is the angle of the bar from some arbitrary reference direction. The positions and velocities of the two particles are
p
1
=
(
x
,
y
)
+
R
(
cos
α
,
sin
α
)
v
1
=
(
x
˙
,
y
˙
)
+
R
α
˙
(
−
sin
α
,
cos
α
)
p
2
=
(
x
,
y
)
−
R
(
cos
α
,
sin
α
)
v
2
=
(
x
˙
,
y
˙
)
−
R
α
˙
(
−
sin
α
,
cos
α
)
and their total kinetic energy is
2
T
=
m
x
˙
2
+
m
y
˙
2
+
m
R
2
α
˙
2
+
2
R
d
cos
α
x
˙
α
˙
+
2
R
d
sin
α
y
˙
α
˙
where
m
=
m
1
+
m
2
and
d
=
m
1
−
m
2
. This formula can be written in matrix form as
T
=
1
2
q
˙
T
M
q
˙
where
M
=
[
m
0
R
d
cos
α
0
m
R
d
sin
α
R
d
cos
α
R
d
sin
α
R
2
m
]
Note that the matrix depends on the current angle α of the bar.
For discrete approximations of continuum mechanics as in the finite element method, there may be more than one way to construct the mass matrix, depending on desired computational and accuracy performance. For example, a lumpedmass method, in which the deformation of each element is ignored, creates a diagonal mass matrix and negates the need to integrate mass across the deformed element.