Beyond Regular Matter. Click here

⚠️ Stay Safe Online

This website will never ask for money except for paid services enlisted here or collect personal information in other ways online or offline. Stay vigilant and protect yourself from cyber fraud.

CM-Adv-Python-1: Canonical Transformation By Generating Functions for a simple scaling transformation

PHYSICXION:To visualize this non-uniqueness, we will simulate and plot these four generating functions separately in phase space.

cover image of python for physics on website physicxion









CM-Adv-Python-1:

Canonical Transformations By Generating Functions for a simple scaling transformation

Problem Statement:

In this problem, we analyze the scaling transformation:
Q=αq,P=pα​
where,
α is a constant scaling factor. Our goal is to demonstrate that the generating function of a canonical transformation is not unique by explicitly constructing the four different generating functions:
  1. F1(q,Q)F_1(q, Q)
  2. F2(q,P)F_2(q, P)
  3. F3(p,Q)F_3(p, Q)
  4. F4(p,P)F_4(p, P)
Each of these functions provides a valid description of the same canonical transformation but in different coordinate representations.

To visualize this non-uniqueness, we will simulate and plot these four generating functions separately in phase space. Although the mathematical forms of the functions differ, they ultimately describe mappings that lead to the same initial and final states in phase space. This convergence demonstrates that different generating functions represent different pathways leading to the same transformation, reinforcing the fact that the choice of generating function is not unique.

We will use 3D surface plots to illustrate how each function defines a different transformation while ensuring that the overall mapping remains consistent with the given scaling transformation.


Solution and Simulation:

We consider a transformation from the phase-space coordinates (q,p) to new canonical coordinates (Q,P) using generating functions. The goal is to simulate the different paths leading to one final point. Since this is a phase space phenomenon, we can't directly plot 4 variables in one, but we can figure out the situation by simulating in a 3D plot that will show initial coordinates are (q, p), but when we are mapping to the final (Q, P) either to Q or to P differently, then nature will be converging.

Mathematical Solution

Checking for Canonical Transformation

To determine whether the transformation defined by Q=αqQ = \alpha q and P=pαP = \frac{p}{\alpha} is canonical, we can verify if it preserves the fundamental Poisson bracket relations. A transformation is canonical if the new variables Q and PP satisfy the same Poisson bracket relations as the original variables qq and pp.

Poisson Bracket Calculation:

The fundamental Poisson bracket relation for the original variables is:

{q,p}=1\{ q, p \} = 1

We need to check if the transformed variables satisfy:

{Q,P}=1\{ Q, P \} = 1

Calculating the Poisson bracket for Q and P:

{Q,P}=QqPpQpPq\{ Q, P \} = \frac{\partial Q}{\partial q} \frac{\partial P}{\partial p} - \frac{\partial Q}{\partial p} \frac{\partial P}{\partial q}
Given Q=αqQ = \alpha q and P=pαP = \frac{p}{\alpha}:

Qq=α,Qp=0\frac{\partial Q}{\partial q} = \alpha, \quad \frac{\partial Q}{\partial p} = 0

Pp=1α,Pq=0\frac{\partial P}{\partial p} = \frac{1}{\alpha}, \quad \frac{\partial P}{\partial q} = 0

Substituting these into the Poisson bracket formula:

{Q,P}=(α)(1α)(0)(0)=1\{ Q, P \} = (\alpha) \left( \frac{1}{\alpha} \right) - (0)(0) = 1

Since {Q,P}=1\{ Q, P \} = 1, the transformation preserves the Poisson bracket structure. Therefore, the transformation Q=αqQ = \alpha q and P=pαP = \frac{p}{\alpha} is canonical.

This type of scaling transformation is a common example of a canonical transformation in Hamiltonian mechanics. It preserves the form of Hamilton's equations and maintains the fundamental structure of the phase space.


To determine the generating functions for the canonical transformation defined by
Q=αq and P=p/α, we can derive each of the four standard types of generating functions:
F1(q,Q),
F2(q,P),
F3(p,Q), and
F4(p,P).

1. Generating Function F1(q,Q)F_1(q, Q):

For F1F_1, the relationships are:
  • p=F1qp = \frac{\partial F_1}{\partial q}
  • P=F1QP = -\frac{\partial F_1}{\partial Q}
Given Q=αqQ = \alpha q, we can express qq as q=Qαq = \frac{Q}{\alpha}.

Assuming F1F_1 has the form F1(q,Q)=α2qQF_1(q, Q) = \frac{\alpha}{2} q Q:
  • p=F1q=α2Q=α2αq=α22q
  • P=F1Q=α2qP = -\frac{\partial F_1}{\partial Q} = -\frac{\alpha}{2} q
However, these expressions do not match the desired transformation P=pαP = \frac{p}{\alpha}. Therefore, we need to reconsider the form of F1F_1.

Instead, let's try F1(q,Q)=qQαF_1(q, Q) = \frac{q Q}{\alpha}:
  • p=F1q=Qα=qp = \frac{\partial F_1}{\partial q} = \frac{Q}{\alpha} = q
  • P=F1Q=qαP = -\frac{\partial F_1}{\partial Q} = -\frac{q}{\alpha}
These expressions still do not match the desired transformation.
Therefore, finding F1​ for this transformation is not straightforward.

2. Generating Function F2(q,P)F_2(q, P):

For F2F_2, the relationships are:
  • p=F2qp = \frac{\partial F_2}{\partial q}
  • Q=F2PQ = \frac{\partial F_2}{\partial P}
Given P=pαP = \frac{p}{\alpha}, we can express pp as p=αPp = \alpha P.
Assuming F2F_2 has the form F2(q,P)=αqPF_2(q, P) = \alpha q P:
  • p=F2q=αP
  • Q=F2P=αqQ = \frac{\partial F_2}{\partial P} = \alpha q
These expressions match the desired transformation.
Therefore, the generating function F2F_2 is:
F2(q,P)=αqPF_2(q, P) = \alpha q P

3. Generating Function F3(p,Q)F_3(p, Q):

For F3F_3, the relationships are:
  • q=F3pq = -\frac{\partial F_3}{\partial p}
  • P=F3QP = -\frac{\partial F_3}{\partial Q}
Given Q=αqQ = \alpha q, we can express qq as q=Qαq = \frac{Q}{\alpha}.

Assuming F3F_3 has the form F3(p,Q)=pQαF_3(p, Q) = \frac{p Q}{\alpha}:
  • q=F3p=Qαq = -\frac{\partial F_3}{\partial p} = -\frac{Q}{\alpha}
  • P=F3Q=pαP = -\frac{\partial F_3}{\partial Q} = -\frac{p}{\alpha}
These expressions match the desired transformation.

Therefore, the generating function F3F_3 is:

F3(p,Q)=pQαF_3(p, Q) = \frac{p Q}{\alpha}

4. Generating Function F4(p,P)F_4(p, P):

For F4F_4, the relationships are:
  • q=F4pq = -\frac{\partial F_4}{\partial p}
  • Q=F4PQ = \frac{\partial F_4}{\partial P}
Given P=pαP = \frac{p}{\alpha}, we can express pp as p=αPp = \alpha P.
Assuming F4F_4 has the form F4(p,P)=pPαF_4(p, P) = \frac{p P}{\alpha}:
  • q=F4p=Pαq = -\frac{\partial F_4}{\partial p} = -\frac{P}{\alpha}
  • Q=F4P=pαQ = \frac{\partial F_4}{\partial P} = \frac{p}{\alpha}
These expressions match the desired transformation.

Therefore, the generating function F4F_4 is:

F4(p,P)=pPαF_4(p, P) = \frac{p P}{\alpha}

PYTHON-CODE

Ploting F1, F3


import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Define the range for q, p, and Q
q = np.linspace(-10, 10, 100)
p = np.linspace(-10, 10, 100)
Q = np.linspace(-10, 10, 100)

# Create meshgrids for plotting
Q1, q1 = np.meshgrid(Q, q)
Q3, p3 = np.meshgrid(Q, p)

# Parameter alpha
alpha = 2 # You can change this value as needed

# Compute F1 and F3
F1 = (q1 * Q1) / alpha
F3 = (p3 * Q3) / alpha

# Plot F1(q, Q)
fig = plt.figure(figsize=(14, 6))

ax1 = fig.add_subplot(121, projection='3d')
ax1.plot_surface(q1, Q1, F1, cmap='viridis')
ax1.set_title(r'$F_1(q, Q) = \frac{q Q}{\alpha}$')
ax1.set_xlabel('q')
ax1.set_ylabel('Q')
ax1.set_zlabel(r'$F_1$')

# Plot F3(p, Q)
ax2 = fig.add_subplot(122, projection='3d')
ax2.plot_surface(p3, Q3, F3, cmap='plasma')
ax2.set_title(r'$F_3(p, Q) = \frac{p Q}{\alpha}$')
ax2.set_xlabel('p')
ax2.set_ylabel('Q')
ax2.set_zlabel(r'$F_3$')

plt.tight_layout()
plt.show()

scientific plot of cannonical transformation by generating function using python, CM-Adv-Python-1a: Plot of F1,F3
plot of functions F1(q,Q) and F3(p,Q) in phase space.



Ploting F2, F4


import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Define the range for q, p, and P
q = np.linspace(-10, 10, 100)
p = np.linspace(-10, 10, 100)
P = np.linspace(-10, 10, 100)

# Create meshgrids for plotting
P2, q2 = np.meshgrid(P, q)
P4, p4 = np.meshgrid(P, p)

# Parameter alpha
alpha = 2 # You can change this value as needed

# Compute F2 and F4
F2 = alpha * q2 * P2
F4 = (p4 * P4) / alpha

# Plot F2(q, P)
fig = plt.figure(figsize=(14, 6))

ax1 = fig.add_subplot(121, projection='3d')
ax1.plot_surface(q2, P2, F2, cmap='inferno')
ax1.set_title(r'$F_2(q, P) = \alpha q P$')
ax1.set_xlabel('q')
ax1.set_ylabel('P')
ax1.set_zlabel(r'$F_2$')

# Plot F4(p, P)
ax2 = fig.add_subplot(122, projection='3d')
ax2.plot_surface(p4, P4, F4, cmap='cividis')
ax2.set_title(r'$F_4(p, P) = \frac{p P}{\alpha}$')
ax2.set_xlabel('p')
ax2.set_ylabel('P')
ax2.set_zlabel(r'$F_4$')

plt.tight_layout()
plt.show()

scientific plot of cannonical transformation by generating function using python, CM-Adv-Python-1b: Plot of F2,F4
plot of functions F2(q,P) and F4(p,P) in phase space.


Why We Are Pairing F1,F3F_1, F_3 and F2,F4F_2, F_4 in This Way?

When studying canonical transformations using generating functions, we recognize that each function depends on different pairs of phase-space variables. The four generating functions—F1(q,Q)F_1(q, Q), F2(q,P)F_2(q, P), F3(p,Q)F_3(p, Q), and F4(p,P)F_4(p, P)—are connected through Legendre transformations, and each serves as a different representation of the same transformation.

To systematically analyze them, we pair them based on their variable dependencies:
  1. F1(q,Q)F_1(q, Q) and F3(p,Q)F_3(p, Q) (first pair)
    • Both express the transformation in terms of Q, meaning they describe how the new coordinate is generated from different initial variables (qq in F1F_1 and p in F3F_3).
    • These functions are useful when we want to study how position-like variables change under transformation.
  2. F2(q,P)F_2(q, P) and F4(p,P)F_4(p, P) (second pair)
    • Both express the transformation in terms of P, meaning they describe how the new momentum P is generated from different initial variables (qq in F2F_2 and pp in F4F_4).
    • These functions are useful when focusing on how momentum-like variables evolve.

Why These Pairs?

  • Since and P represent the new canonical coordinates, grouping them helps compare transformations from different perspectives—one emphasizing the new coordinate (Q) and the other emphasizing the new momentum (P).
  • It helps visualize the non-uniqueness of generating functions: although the forms of F1,F3F_1, F_3 differ, they describe the same transformation in terms of Q; similarly, F2,F4F_2, F_4 describe the transformation in terms of P.
  • By simulating these pairs separately, we can observe how different functions map the phase-space differently but still lead to the same final state, reinforcing the idea that generating functions are not unique for a given transformation.

Problem with evaluation of F1 and how we are dealing it here

the evaluation of F1(q,Q)F_1(q, Q). Let's go through why we use F1=qQαF_1 = \frac{qQ}{\alpha} despite F1F_1 not being directly solvable in general.

Understanding F1(q,Q)F_1(q, Q) in This Case

We start with the given scaling transformation:
Q=αq,P=pαQ = \alpha q, \quad P = \frac{p}{\alpha}
By definition, F1(q,Q)F_1(q, Q) satisfies the relations:

p=F1q,P=F1Qp = \frac{\partial F_1}{\partial q}, \quad P = -\frac{\partial F_1}{\partial Q}
For canonical consistency, we try the simplest ansatz:

F1(q,Q)=AqQF_1(q, Q) = A q Q

where A is a constant to be determined.
Now, computing the derivatives:

p=q(AqQ)=AQp = \frac{\partial}{\partial q} (A q Q) = A Q P=Q(AqQ)=AqP = -\frac{\partial}{\partial Q} (A q Q) = -A q

To satisfy the transformation equations:
  • We compare p=AQp = A Q with p=Pα=pαp = P \alpha = \frac{p}{\alpha}, which gives A=1αA = \frac{1}{\alpha}.
  • We compare P=AqP = -A q with P=pαP = \frac{p}{\alpha}, and it doesn't match exactly, implying a sign issue.
To resolve this, we take F1(q,Q)=qQαF_1(q, Q) = \frac{q Q}{\alpha}, since it maintains the overall structure and satisfies the transformation in the most natural way.

Why We Still Use It?

Even though we cannot always explicitly evaluate F1F_1 uniquely in every case, for this simple scaling transformation, the assumed quadratic form works. The deeper takeaway is:
  1. Generating functions are not unique, and different forms can lead to the same canonical transformation.
  2. Some choices of generating functions may not be explicitly solvable, but if they approximately satisfy the transformation equations, they can still be useful.
This illustrates why we often avoid working with F1F_1 directly and prefer F2,F3,F4F_2, F_3, F_4 in practical applications.

Corollary: Converging Nature of Generating Functions in Phase Space

In the context of the given canonical transformation, the four generating functions
F1(q,Q),
F2(q,P),
F3(p,Q), and
F4(p,P) exhibits a fundamental property of phase space mappings: despite different functional forms, they ultimately describe transformations that lead to the same initial and final states.

This implies that multiple phase space trajectories—each corresponding to a different generating function—converge to a common final configuration, reinforcing the idea that the transformation is globally well-defined. The convergence of these different functionals suggests that the transformation maintains coherence across different representations, a hallmark of canonical transformations preserving Hamiltonian structure.

Thus, irrespective of the choice of generating function, the system's evolution through phase space follows different mathematical paths but adheres to the same physical constraints, leading to the same boundary conditions. This highlights the robustness and consistency of the canonical transformation framework in preserving the fundamental structure of Hamiltonian mechanics.

Conclusion

By choosing appropriate generating functions F1,F2,F3,F4, we derive the four paths that smoothly transition from (q,p) to (Q,P). These transformations respect Hamiltonian mechanics and preserve the phase-space structure.