This second edition introduces Python programming to readers with little or no prior experience, specifically tailored for physicists and natural sciences students. The book begins with interactive Python exercises to foster familiarity with the language. It then progresses to more complex Python scripts (programs) that readers are encouraged to run on their own computers. Each program listing is thoroughly explained, and readers are encouraged to experiment by modifying code lines or blocks to observe and understand their effects. The text introduces Matplotlib graphics for creating figures representing data, function plots, and visualizations like field lines and equipotential surfaces. It also explores 3D graphics and animated function plots. A dedicated chapter covers the numerical solution of algebraic and transcendental equations.
The underlying mathematical principles are thoroughly discussed and the available Python tools for solving these equations are presented. A further chapter is dedicated to the numerical solution of ordinary differential equations (ODEs). This is of vital importance for the physicist, since differential equations are at the base of both classical physics (Newton s equations) and quantum mechanics (Schroedinger s equation). The shooting method for the numerical solution of ordinary differential equations with boundary conditions is also presented. Python programs for the solution of two quantum-mechanics problems are discussed as examples. Two chapters are dedicated to Tkinter graphics, which gives the user more freedom than Matplotlib, and to Tkinter animation. A special chapter is dedicated to computer animation involving differential equations, with a discussion of the effect of the accumulation of truncation errors, particularly relevant for such fields as molecular dynamics or celestial mechanics, which often require integrating Newton s equations over a very long time starting from some initial conditions. Symplectic algorithms for tackling this problem are introduced. Programs displaying the animation of physical problems involving the solution of ordinary differential equations (for which in most cases there is no algebraic solution) in real time are presented and discussed. Finally, 3D animation is presented with Vpython.
The underlying mathematical principles are thoroughly discussed and the available Python tools for solving these equations are presented. A further chapter is dedicated to the numerical solution of ordinary differential equations (ODEs). This is of vital importance for the physicist, since differential equations are at the base of both classical physics (Newton s equations) and quantum mechanics (Schroedinger s equation). The shooting method for the numerical solution of ordinary differential equations with boundary conditions is also presented. Python programs for the solution of two quantum-mechanics problems are discussed as examples. Two chapters are dedicated to Tkinter graphics, which gives the user more freedom than Matplotlib, and to Tkinter animation. A special chapter is dedicated to computer animation involving differential equations, with a discussion of the effect of the accumulation of truncation errors, particularly relevant for such fields as molecular dynamics or celestial mechanics, which often require integrating Newton s equations over a very long time starting from some initial conditions. Symplectic algorithms for tackling this problem are introduced. Programs displaying the animation of physical problems involving the solution of ordinary differential equations (for which in most cases there is no algebraic solution) in real time are presented and discussed. Finally, 3D animation is presented with Vpython.