Python Tuples: Immutable Physical Constants & Phase Space Pairs
1. Core Principles & Theoretical Framework
r, v = update(r, v, dt).2. Mathematical Formulation & Algorithmic Pipeline
Phase space coordinate state tuple:
3. Numerical Mechanics & Implementation Logic
- Tuple Packing: Group multiple observables into single return statements:
return (x_new, v_new, energy). - Unpacking Assignment: Assign returned variables cleanly:
pos, vel, e = integrate_step(pos, vel). - Hashable Keys: Use tuples as dictionary keys for 2D/3D discrete grid lookups where lists are prohibited.
4. Relevant Computational Practice Exercises
- Hans Petter Langtangen, "A Primer on Scientific Programming with Python", Springer (2016).