Generalized coordinates and constraints
In Newtonian mechanics, one customarily uses all three Cartesian coordinates, or other 3D coordinate system, to refer to a body's position during its motion. In physical systems, however, some structure or other system usually constrains the body's motion from taking certain directions and pathways. So a full set of Cartesian coordinates is often unneeded, as the constraints determine the evolving relations among the coordinates, which relations can be modeled by equations corresponding to the constraints. In the Lagrangian and Hamiltonian formalisms, the constraints are incorporated into the motion's geometry, reducing the number of coordinates to the minimum needed to model the motion. These are known as *generalized coordinates*, denoted *q*_{i} (*i* = 1, 2, 3...).

**Difference between curvillinear and generalized coordinates**

Generalized coordinates incorporate constraints on the system. There is one generalized coordinate *q*_{i} for each degree of freedom (for convenience labelled by an index *i* = 1, 2...*N*), i.e. each way the system can change its configuration; as curvilinear lengths or angles of rotation. Generalized coordinates are not the same as curvilinear coordinates. The number of *curvilinear* coordinates equals the dimension of the position space in question (usually 3 for 3d space), while the number of *generalized* coordinates is not necessarily equal to this dimension; constraints can reduce the number of degrees of freedom (hence the number of generalized coordinates required to define the configuration of the system), following the general rule:

*[***dimension of position space** (usually 3)] × [number of **constituents** of system ("particles")] − (number of **constraints**)
*= (number of ***degrees of freedom**) = (number of **generalized coordinates**)
For a system with *N* degrees of freedom, the generalized coordinates can be collected into an *N*-tuple:

q
=
(
q
1
,
q
2
,
⋯
q
N
)
and the time derivative (here denoted by an overdot) of this tuple give the *generalized velocities*:

d
q
d
t
=
(
d
q
1
d
t
,
d
q
2
d
t
,
⋯
d
q
N
d
t
)
≡
q
˙
=
(
q
˙
1
,
q
˙
2
,
⋯
q
˙
N
)
.

D'Alembert's principle
The foundation which the subject is built on is *D'Alembert's principle*.

This principle states that infinitesimal *virtual work* done by a force across reversible displacements is zero, which is the work done by a force consistent with ideal constraints of the system. The idea of a constraint is useful - since this limits what the system can do, and can provide steps to solving for the motion of the system. The equation for D'Alembert's principle is:

δ
W
=
Q
⋅
δ
q
=
0
,
where

Q
=
(
Q
1
,
Q
2
,
⋯
Q
N
)
are the generalized forces (script Q instead of ordinary Q is used here to prevent conflict with canonical transformations below) and **q** are the generalized coordinates. This leads to the generalized form of Newton's laws in the language of analytical mechanics:

Q
=
d
d
t
(
∂
T
∂
q
˙
)
−
∂
T
∂
q
,
where *T* is the total kinetic energy of the system, and the notation

∂
∂
q
=
(
∂
∂
q
1
,
∂
∂
q
2
,
⋯
∂
∂
q
N
)
is a useful shorthand (see matrix calculus for this notation).

**Holonomic constraints**

If the curvilinear coordinate system is defined by the standard position vector **r**, and if the position vector can be written in terms of the generalized coordinates **q** and time *t* in the form:

r
=
r
(
q
(
t
)
,
t
)
and this relation holds for all times *t*, then **q** are called *Holonomic constraints*. Vector **r** is explicitly dependent on *t* in cases when the constraints vary with time, not just because of **q**(*t*). For time-independent situations, the constraints are also called **scleronomic**, for time-dependent cases they are called **rheonomic**.

**Lagrangian and Euler–Lagrange equations**

The introduction of generalized coordinates and the fundamental Lagrangian function:

L
(
q
,
q
˙
,
t
)
=
T
(
q
,
q
˙
,
t
)
−
V
(
q
,
q
˙
,
t
)
where *T* is the total kinetic energy and *V* is the total potential energy of the entire system, then either following the calculus of variations or using the above formula - lead to the Euler–Lagrange equations;

d
d
t
(
∂
L
∂
q
˙
)
=
∂
L
∂
q
,
which are a set of *N* second-order ordinary differential equations, one for each *q*_{i}(*t*).

This formulation identifies the actual path followed by the motion as a selection of the path over which the time integral of kinetic energy is least, assuming the total energy to be fixed, and imposing no conditions on the time of transit.

**Configuration space**

The Lagrangian formulation uses the configuration space of the system, the set of all possible generalized coordinates:

C
=
{
q
∈
R
N
}
,
where
R
N
is *N*-dimensional real space (see also set-builder notation). The particular solution to the Euler–Lagrange equations is called a *(configuration) path or trajectory*, i.e. one particular **q**(*t*) subject to the required initial conditions. The general solutions form a set of possible configurations as functions of time:

{
q
(
t
)
∈
R
N
:
t
≥
0
,
t
∈
R
}
⊆
C
,
The configuration space can be defined more generally, and indeed more deeply, in terms of topological manifolds and the tangent bundle.

**Hamiltonian and Hamilton's equations**

The Legendre transformation of the Lagrangian replaces the generalized coordinates and velocities (**q**, **q̇**) with (**q**, **p**); the generalized coordinates and the *generalized momenta* conjugate to the generalized coordinates:

p
=
∂
L
∂
q
˙
=
(
∂
L
∂
q
˙
1
,
∂
L
∂
q
˙
2
,
⋯
∂
L
∂
q
˙
N
)
=
(
p
1
,
p
2
⋯
p
N
)
,
and introduces the Hamiltonian (which is in terms of generalized coordinates and momenta):

H
(
q
,
p
,
t
)
=
p
⋅
q
˙
−
L
(
q
,
q
˙
,
t
)
where **•** denotes the dot product, also leading to Hamilton's equations:

p
˙
=
−
∂
H
∂
q
,
q
˙
=
+
∂
H
∂
p
,
which are now a set of 2*N* first-order ordinary differential equations, one for each *q*_{i}(*t*) and *p*_{i}(*t*). Another result from the Legendre transformation relates the time derivatives of the Lagrangian and Hamiltonian:

d
H
d
t
=
−
∂
L
∂
t
,
which is often considered one of Hamilton's equations of motion additionally to the others. The generalized momenta can be written in terms of the generalized forces in the same way as Newton's second law:

p
˙
=
Q
.
**Generalized momentum space**

Analogous to the configuration space, the set of all momenta is the *momentum space* (technically in this context; *generalized momentum space*):

M
=
{
p
∈
R
N
}
.
"Momentum space" also refers to "**k**-space"; the set of all wave vectors (given by De Broglie relations) as used in quantum mechanics and theory of waves: this is not referred to in this context.

**Phase space**

The set of all positions and momenta form the *phase space*;

P
=
C
×
M
=
{
(
q
,
p
)
∈
R
2
N
}
,
that is, the Cartesian product × of the configuration space and generalized momentum space.

A particular solution to Hamilton's equations is called a *phase path*, a particular curve (**q**(*t*),**p**(*t*)) subject to the required initial conditions. The set of all phase paths, the general solution to the differential equations, is the *phase portrait*:

{
(
q
(
t
)
,
p
(
t
)
)
∈
R
2
N
:
t
≥
0
,
t
∈
R
}
⊆
P
,
The Poisson bracket
All dynamical variables can be derived from position **r**, momentum **p**, and time *t*, and written as a function of these: *A* = *A*(**q**, **p**, *t*). If *A*(**q**, **p**, *t*) and *B*(**q**, **p**, *t*) are two scalar valued dynamical variables, the *Poisson bracket* is defined by the generalized coordinates and momenta:

{
A
,
B
}
≡
{
A
,
B
}
q
,
p
=
∂
A
∂
q
⋅
∂
B
∂
p
−
∂
A
∂
p
⋅
∂
B
∂
q
≡
∑
k
∂
A
∂
q
k
∂
B
∂
p
k
−
∂
A
∂
p
k
∂
B
∂
q
k
,
Calculating the total derivative of one of these, say *A*, and substituting Hamilton's equations into the result leads to the time evolution of *A*:

d
A
d
t
=
{
A
,
H
}
+
∂
A
∂
t
.
This equation in *A* is closely related to the equation of motion in the Heisenberg picture of quantum mechanics, in which classical dynamical variables become quantum operators (indicated by hats (^)), and the Poission bracket is replaced by the commutator of operators via Dirac's canonical quantization:

{
A
,
B
}
→
1
i
ℏ
[
A
^
,
B
^
]
.
Following are overlapping properties between the Lagrangian and Hamiltonian functions.

All the individual generalized coordinates *q*_{i}(*t*), velocities *q̇*_{i}(*t*) and momenta *p*_{i}(*t*) for every degree of freedom are mutually independent. Explicit time-dependence of a function means the function actually includes time *t* as a variable in addition to the **q**(*t*), **p**(*t*), not simply as a parameter through **q**(*t*) and **p**(*t*), which would mean explicit time-independence.
The Lagrangian is invariant under addition of the *total* time derivative of any function of **q** and *t*, that is:
so each Lagrangian

*L* and

*L'* describe

*exactly the same motion*. In other words, the Lagrangian of a system is not unique.

Analogously, the Hamiltonian is invariant under addition of the *partial* time derivative of any function of **q**, **p** and *t*, that is:
(

*K* is a frequently used letter in this case). This property is used in canonical transformations (see below).

If the Lagrangian is independent of some generalized coordinates, then the generalized momenta conjugate to those coordinates are constants of the motion, i.e. are conserved, this immediately follows from Lagrange's equations:
Such coordinates are "cyclic" or "ignorable". It can be shown that the Hamiltonian is also cyclic in exactly the same generalized coordinates.

If the Lagrangian is time-independent the Hamiltonian is also time-independent (i.e. both are constant in time).
If the kinetic energy is a homogeneous function of degree 2 of the generalized velocities, *and* the Lagrangian is explicitly time-independent, then:
where

*λ* is a constant, then the Hamiltonian will be the

*total conserved energy*, equal to the total kinetic and potential energies of the system:
This is the basis for the Schrödinger equation, inserting quantum operators directly obtains it.

Action is another quantity in analytical mechanics defined as a functional of the Lagrangian:

S
=
∫
t
1
t
2
L
(
q
,
q
˙
,
t
)
d
t
.
A general way to find the equations of motion from the action is the *principle of least action*:

δ
S
=
δ
∫
t
1
t
2
L
(
q
,
q
˙
,
t
)
d
t
=
0
,
where the departure *t*_{1} and arrival *t*_{2} times are fixed. The term "path" or "trajectory" refers to the time evolution of the system as a path through configuration space
C
, in other words **q**(*t*) tracing out a path in
C
. The path for which action is least is the path taken by the system.

From this principle, *all* equations of motion in classical mechanics can be derived. This approach can be extended to fields rather than a system of particles (see below), and underlies the path integral formulation of quantum mechanics, and is used for calculating geodesic motion in general relativity.

Canonical transformations
The invariance of the Hamiltonian (under addition of the partial time derivative of an arbitrary function of **p**, **q**, and *t*) allows the Hamiltonian in one set of coordinates **q** and momenta **p** to be transformed into a new set **Q** = **Q**(**q**, **p**, *t*) and **P** = **P**(**q**, **p**, *t*), in four possible ways:

K
(
Q
,
P
,
t
)
=
H
(
q
,
p
,
t
)
+
∂
∂
t
G
1
(
q
,
Q
,
t
)
K
(
Q
,
P
,
t
)
=
H
(
q
,
p
,
t
)
+
∂
∂
t
G
2
(
q
,
P
,
t
)
K
(
Q
,
P
,
t
)
=
H
(
q
,
p
,
t
)
+
∂
∂
t
G
3
(
p
,
Q
,
t
)
K
(
Q
,
P
,
t
)
=
H
(
q
,
p
,
t
)
+
∂
∂
t
G
4
(
p
,
P
,
t
)
With the restriction on **P** and **Q** such that the transformed Hamiltonian system is:

P
˙
=
−
∂
K
∂
Q
,
Q
˙
=
+
∂
K
∂
P
,
the above transformations are called *canonical transformations*, each function *G*_{n} is called a generating function of the "*n*th kind" or "type-*n*". The transformation of coordinates and momenta can allow simplification for solving Hamilton's equations for a given problem.

The choice of **Q** and **P** is completely arbitrary, but not every choice leads to a canonical transformation. One simple criterion for a transformation **q** → **Q** and **p** → **P** to be canonical is the Poisson bracket be unity,

{
Q
i
,
P
i
}
=
1
for all *i* = 1, 2,...*N*. If this does not hold then the transformation is not canonical.

The Hamilton–Jacobi equation
By setting the canonically transformed Hamiltonian *K* = 0, and the type-2 generating function equal to **Hamilton's principal function** (also the action
S
) plus an arbitrary constant *C*:

G
2
(
q
,
t
)
=
S
(
q
,
t
)
+
C
,
the generalized momenta become:

p
=
∂
S
∂
q
and **P** is constant, then the Hamiltonian-Jacobi equation (HJE) can be derived from the type-2 canonical transformation:

H
=
−
∂
S
∂
t
where *H* is the Hamiltonian as before:

H
=
H
(
q
,
p
,
t
)
=
H
(
q
,
∂
S
∂
q
,
t
)
Another related function is **Hamilton's characteristic function**

W
(
q
)
=
S
(
q
,
t
)
+
E
t
used to solve the HJE by additive separation of variables for a time-independent Hamiltonian *H*.

The study of the solutions of the Hamilton–Jacobi equations leads naturally to the study of symplectic manifolds and symplectic topology. In this formulation, the solutions of the Hamilton–Jacobi equations are the integral curves of Hamiltonian vector fields.

**Routhian mechanics** is a hybrid formulation of Lagrangian and Hamiltonian mechanics, not often used but especially useful for removing cyclic coordinates. If the Lagrangian of a system has *s* cyclic coordinates **q** = *q*_{1}, *q*_{2}, ... *q*_{s} with conjugate momenta **p** = *p*_{1}, *p*_{2}, ... *p*_{s}, with the rest of the coordinates non-cyclic and denoted **ζ** = *ζ*_{1}, *ζ*_{1}, ..., *ζ*_{N − s}, they can be removed by introducing the *Routhian*:

R
=
p
⋅
q
˙
−
L
(
q
,
p
,
ζ
,
ζ
˙
)
,
which leads to a set of 2*s* Hamiltonian equations for the cyclic coordinates **q**,

q
˙
=
+
∂
R
∂
p
,
p
˙
=
−
∂
R
∂
q
,
and *N* − *s* Lagrangian equations in the non cyclic coordinates **ζ**.

d
d
t
∂
R
∂
ζ
˙
=
∂
R
∂
ζ
.
Set up in this way, although the Routhian has the form of the Hamiltonian, it can be thought of a Lagrangian with *N* − *s* degrees of freedom.

The coordinates **q** do not have to be cyclic, the partition between which coordinates enter the Hamiltonian equations and those which enter the Lagrangian equations is arbitrary. It is simply convenient to let the Hamiltonian equations remove the cyclic coordinates, leaving the non cyclic coordinates to the Lagrangian equations of motion.

**Appell's equation of motion** involve generalized accelerations, the second time derivatives of the generalized coordinates:

α
r
=
q
¨
r
=
d
2
q
r
d
t
2
,
as well as generalized forces mentioned above in D'Alembert's principle. The equations are

Q
r
=
∂
S
∂
α
r
,
S
=
1
2
∑
k
=
1
N
m
k
a
k
2
,
where

a
k
=
r
¨
k
=
d
2
r
k
d
t
2
is the acceleration of the *k* particle, the second time derivative of its position vector. Each acceleration **a**_{k} is expressed in terms of the generalized accelerations *α*_{r}, likewise each **r**_{k} are expressed in terms the generalized coordinates *q*_{r}.

Lagrangian field theory
Generalized coordinates apply to discrete particles. For *N* scalar fields *φ*_{i}(**r**, *t*) where *i* = 1, 2, ... *N*, the **Lagrangian density** is a function of these fields and their space and time derivatives, and possibly the space and time coordinates themselves:

L
=
L
(
ϕ
1
,
ϕ
2
,
…
∇
ϕ
1
,
∇
ϕ
2
,
…
∂
ϕ
1
/
∂
t
,
∂
ϕ
2
/
∂
t
,
…
r
,
t
)
.

and the Euler–Lagrange equations have an analogue for fields:

∂
μ
(
∂
L
∂
(
∂
μ
ϕ
i
)
)
=
∂
L
∂
ϕ
i
,
where *∂*_{μ} denotes the 4-gradient and the summation convention has been used. For *N* scalar fields, these Lagranian field equations are a set of *N* second order partial differential equations in the fields, which in general will be coupled and nonlinear.

This scalar field formulation can be extended to vector fields, tensor fields, and spinor fields.

The Lagrangian is the volume integral of the Lagrangian density:

L
=
∫
V
L
d
V
.
Originally developed for classical fields, the above formulation is applicable to all physical fields in classical, quantum, and relativistic situations: such as Newtonian gravity, classical electromagnetism, general relativity, and quantum field theory. It is a question of determining the correct Lagrangian density to generate the correct field equation.

Hamiltonian field theory
The corresponding "momentum" field densities conjugate to the *N* scalar fields *φ*_{i}(**r**, *t*) are:

π
i
(
r
,
t
)
=
∂
L
∂
ϕ
˙
i
ϕ
˙
i
≡
∂
ϕ
i
∂
t
.
where in this context the overdot denotes a partial time derivative, not a total time derivative. The **Hamiltonian density**
H
is defined by analogy with mechanics:

H
(
ϕ
1
,
ϕ
2
,
…
,
π
1
,
π
2
,
…
,
r
,
t
)
=
∑
i
=
1
N
ϕ
˙
i
(
r
,
t
)
π
i
(
r
,
t
)
−
L
.
The equations of motion are:

ϕ
˙
i
=
+
δ
H
δ
π
i
,
π
˙
i
=
−
δ
H
δ
ϕ
i
,
where the variational derivative

δ
δ
ϕ
i
=
∂
∂
ϕ
i
−
∂
μ
∂
∂
(
∂
μ
ϕ
i
)
must be used instead of merely partial derivatives. For *N* fields, these Hamiltonian field equations are a set of 2*N* first order partial differential equations, which in general will be coupled and nonlinear.

Again, the volume integral of the Hamiltonian density is the Hamiltonian

H
=
∫
V
H
d
V
.
Symmetry transformations in classical space and time
Each transformation can be described by an operator (i.e. function acting on the position **r** or momentum **p** variables to change them). The following are the cases when the operator does not change **r** or **p**, i.e. symmetries.

where *R*(**n̂**, θ) is the rotation matrix about an axis defined by the unit vector **n̂** and angle θ.

Noether's theorem
Noether's theorem states that a continuous symmetry transformation of the action corresponds to a conservation law, i.e. the action (and hence the Lagrangian) doesn't change under a transformation parameterized by a parameter *s*:

L
[
q
(
s
,
t
)
,
q
˙
(
s
,
t
)
]
=
L
[
q
(
t
)
,
q
˙
(
t
)
]
the Lagrangian describes the same motion independent of *s*, which can be length, angle of rotation, or time. The corresponding momenta to *q* will be conserved.