Essential Python for the physicist /

Saved in:
Bibliographic Details
Author / Creator:Moruzzi, Giovanni.
Imprint:Cham : Springer, 2020.
Description:1 online resource (304 p.)
Language:English
Subject:
Format: E-Resource Book
URL for this record:http://pi.lib.uchicago.edu/1001/cat/bib/12605679
Hidden Bibliographic Details
ISBN:9783030450274
3030450279
9783030450267
3030450260
Notes:Description based upon print version of record.
6.4.1 Plotting a Hyperbola
Includes index.
Summary:This book introduces the reader with little or no previous computer-programming experience to the Python programming language of interest for a physicist or a natural-sciences student. The book starts with basic interactive Python in order to acquire an introductory familiarity with the language, than tackle Python scripts (programs) of increasing complexity, that the reader is invited to run on her/his computer. All program listings are discussed in detail, and the reader is invited to experiment on what happens if some code lines are modified. The reader is introduced to Matplotlib graphics for the generation of figures representing data and function plots and, for instance, field lines. Animated function plots are also considered. A chapter is dedicated to the numerical solution of algebraic and transcendental equations, the basic mathematical principles are discussed and the available Python tools for the solution are presented. A further chapter is dedicated to the numerical solution of ordinary differential equations. This is of vital importance for the physicist, since differential equations are at the base of both classical physics (Newtons equations) and quantum mechanics (Schroedingers equation). The shooting method for the numerical solution of ordinary differential equations with boundary conditions at two boundaries 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. 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.
Other form:Print version: Moruzzi, Giovanni Essential Python for the Physicist Cham : Springer International Publishing AG,c2020 9783030450267
Standard no.:10.1007/978-3-030-45
Table of Contents:
  • Intro
  • Preface
  • Contents
  • 1 Python Basics and the Interactive Mode
  • 1.1 Using the Command Line
  • 1.2 Installing Python
  • 1.2.1 General
  • 1.2.2 Downloading Python for Windows
  • 1.2.3 Downloading Python for macOS
  • 1.3 Using Python in Interactive Mode
  • 1.4 Variables
  • 1.4.1 Variable Types
  • 1.4.2 Variable-Type Conversion
  • 1.5 Arithmetic Operators
  • 1.6 Assignment Operators
  • 1.7 Comparison and Logical Operators
  • 1.8 Python Packages and the import Statement
  • 1.9 Conditional Statements
  • 1.10 Lists and Tuples
  • 1.11 List Methods
  • 1.12 Lists and the = Assignment Operator
  • 1.12.1 Copying Lists
  • 1.12.2 Copying the Elements of Lists and Tuples
  • 1.13 Slicing Lists and Strings
  • 1.14 Dictionaries
  • 1.15 The print() Function and Formatting
  • 1.15.1 Old Style
  • 1.15.2 New Style
  • 1.15.3 Format Types and Flags
  • 1.16 Loops
  • 1.16.1 The for Loop
  • 1.16.2 The while Loop
  • 1.16.3 Breaking a Loop
  • 1.16.4 The continue Statement
  • 1.17 Operations with Matrices and Vectors
  • 1.17.1 Lists and Arrays
  • 1.17.2 Slicing out Rows and Columns from a Matrix
  • 1.17.3 Arrays and Matrix Arithmetics
  • 1.17.4 Further Matrix Operations
  • 1.18 Exiting Interactive Mode
  • 1.19 Exercises
  • 2 Python Scripts
  • 2.1 Scripts
  • 2.1.1 Running Scripts on a Terminal
  • 2.1.2 Running Scripts on Spyder3
  • 2.1.3 A First Script
  • 2.2 Functions
  • 2.2.1 General
  • 2.2.2 Local and Global Variables
  • 2.3 Reading and Writing Files
  • 2.4 Calling External Commands from Python Scripts
  • 2.5 Exercises
  • 3 Plotting with Matplotlib
  • 3.1 Pyplot
  • 3.2 Plotting Lists of Numbers
  • 3.3 Plotting Functions
  • 3.4 Multiple Figures
  • 3.5 Logarithmic Axis Scales
  • 3.6 Plotting Field Lines
  • 3.7 Pyplot Animation
  • 3.8 Exercises
  • 4 Numerical Solution of Equations
  • 4.1 Introduction
  • 4.2 Systems of Linear Equations
  • 4.3 Nonlinear Equations
  • 4.3.1 Common Methods for the Numerical Solution
  • 4.3.2 Bisection Method
  • 4.3.3 The Secant Method
  • 4.4 Root Finding with the scipy.optimize Package
  • 4.5 Algebraic Equations
  • 4.6 Systems of Nonlinear Equations
  • 4.6.1 Equations Involving only Unknowns
  • 4.6.2 Equations Involving Unknowns and Parameters
  • 4.7 Integration of Functions
  • 4.7.1 Introduction
  • 4.7.2 Rectangular and Trapezoidal Rules
  • 4.7.3 The Simpson Rule
  • 4.7.4 The scipy.integrate.simps Function
  • 4.8 Exercises
  • Reference
  • 5 Numerical Solution of Ordinary Differential Equations (ODE)
  • 5.1 Introduction
  • 5.2 Euler and Runge-Kutta Methods
  • 5.3 The scipy.integrate.odeint Function
  • 5.4 Large-Amplitude Pendulum
  • 5.5 The Shooting Method
  • 5.5.1 The Finite Square Well
  • 5.5.2 The Shooting Method
  • 5.5.3 The Harmonic Oscillator
  • 5.6 Exercises
  • Reference
  • 6 Tkinter Graphics
  • 6.1 Tkinter
  • 6.2 The Root Window and Tkinter Color Management
  • 6.3 Drawing Geometric Shapes on the Canvas
  • 6.4 Plotting a Function with Tkinter