Atjaunināt sīkdatņu piekrišanu

Primer on Scientific Programming with Python Fifth Edition 2016 [Hardback]

3.82/5 (57 ratings by Goodreads)
  • Formāts: Hardback, 922 pages, height x width: 254x178 mm, 20 Illustrations, color; 68 Illustrations, black and white; XXXI, 922 p. 88 illus., 20 illus. in color., 1 Hardback
  • Sērija : Texts in Computational Science and Engineering 6
  • Izdošanas datums: 01-Aug-2016
  • Izdevniecība: Springer-Verlag Berlin and Heidelberg GmbH & Co. K
  • ISBN-10: 3662498863
  • ISBN-13: 9783662498866
  • Hardback
  • Cena: 69,22 €*
  • * ši ir gala cena, t.i., netiek piemērotas nekādas papildus atlaides
  • Standarta cena: 81,44 €
  • Ietaupiet 15%
  • Grāmatu piegādes laiks ir 3-4 nedēļas, ja grāmata ir uz vietas izdevniecības noliktavā. Ja izdevējam nepieciešams publicēt jaunu tirāžu, grāmatas piegāde var aizkavēties.
  • Daudzums:
  • Ielikt grozā
  • Piegādes laiks - 4-6 nedēļas
  • Pievienot vēlmju sarakstam
  • Formāts: Hardback, 922 pages, height x width: 254x178 mm, 20 Illustrations, color; 68 Illustrations, black and white; XXXI, 922 p. 88 illus., 20 illus. in color., 1 Hardback
  • Sērija : Texts in Computational Science and Engineering 6
  • Izdošanas datums: 01-Aug-2016
  • Izdevniecība: Springer-Verlag Berlin and Heidelberg GmbH & Co. K
  • ISBN-10: 3662498863
  • ISBN-13: 9783662498866
The book serves as a first introduction to computer programming of scientific applications, using the high-level Python language. The exposition is example and problem-oriented, where the applications are taken from mathematics, numerical calculus, statistics, physics, biology and finance. The book teaches "Matlab-style" and procedural programming as well as object-oriented programming. High school mathematics is a required background and it is advantageous to study classical and numerical one-variable calculus in parallel with reading this book. Besides learning how to program computers, the reader will also learn how to solve mathematical problems, arising in various branches of science and engineering, with the aid of numerical methods and programming. By blending programming, mathematics and scientific applications, the book lays a solid foundation for practicing computational science.From the reviews: Langtangen ... does an excellent job of introducing programming as a set

of skills in problem solving. He guides the reader into thinking properly about producing program logic and data structures for modeling real-world problems using objects and functions and embracing the object-oriented paradigm. ... Summing Up: Highly recommended. F. H. Wild III, Choice, Vol. 47 (8), April 2010Those of us who have learned scientific programming in Python "on the streets" could be a little jealous of students who have the opportunity to take a course out of Langtangen"s Primer." John D. Cook, The Mathematical Association of America, September 2011This book goes through Python in particular, and programming in general, via tasks that scientists will likely perform. It contains valuable information for students new to scientific computing and would be the perfect bridge between an introduction to programming and an advanced course on numerical methods or computational science. Alex Small, IEEE, CiSE Vol. 14 (2), March _ /April 2012 "This fourth edition is a

wonderful, inclusive textbook that covers pretty much everything one needs toknow to go from zero to fairly sophisticated scientific programming in Python..."Joan Horvath, Computing Reviews, March2015 

Preface.- Computing withFormulas.- Loops and Lists.- Functions and Branching.- User Input and ErrorHandling.- Array Computing and Curve Plotting.- Dictionaries and Strings.-Introduction to Classes.- Random Numbers and Simple Games.- Object-Oriented Programming.-Sequences and Difference Equations.- Introduction to Discrete Calculus.-Introduction to Differential Equations.- A Complete Differential EquationProject.- Programming of Differential Equations.- Debugging.- Migrating Pythonto Compiled Code.- Technical Topics.- References.- Index.

Recenzijas

This update to previous editions continues to serve as an excellent introduction to scientific programming and the Python programming language. Each chapter has a significant collection of exercises, which reinforce the concepts contained in the chapter. this is an excellent book for any individual starting to learn scientific programming, and it will serve as a great reference book for those working in the field. Summing Up: Recommended. Lower- and upper-division undergraduates. (D. B. Mason, Choice, Vol. 54 (9), May, 2017)

The authors have made a very concerted effort to describe Python in a very easy, flowing way with many useful case studies. I have no hesitation in recommending this book for senior high school students or freshmen in college. One must certainly have access to the Python development environment, and this book will be a worthy companion in the journey to mastering programming concepts. (Naga Narayanaswamy, Computing Reviews, May, 2017)

All the concepts are illustrated using relatively simple examples that are mostly mathematical. This book gives a thorough course to learn Python, and yet it is all brought at the level of a first year at the university. The fact that each concept is introduced with an example is essential. it is a description of how the language is used, which is a very natural approach. (European Mathematical Society, euro-math-soc.eu, August, 2016)

1 Computing with Formulas
1(50)
1.1 The First Programming Encounter: a Formula
1(11)
1.1.1 Using a Program as a Calculator
2(1)
1.1.2 About Programs and Programming
2(1)
1.1.3 Tools for Writing Programs
3(1)
1.1.4 Writing and Running Your First Python Program
4(1)
1.1.5 Warning About Typing Program Text
5(1)
1.1.6 Verifying the Result
6(1)
1.1.7 Using Variables
6(1)
1.1.8 Names of Variables
6(1)
1.1.9 Reserved Words in Python
7(1)
1.1.10 Comments
8(1)
1.1.11 Formatting Text and Numbers
9(3)
1.2 Computer Science Glossary
12(4)
1.3 Another Formula: Celsius-Fahrenheit Conversion
16(4)
1.3.1 Potential Error: Integer Division
16(1)
1.3.2 Objects in Python
17(1)
1.3.3 Avoiding Integer Division
18(2)
1.3.4 Arithmetic Operators and Precedence
20(1)
1.4 Evaluating Standard Mathematical Functions
20(4)
1.4.1 Example: Using the Square Root Function
20(3)
1.4.2 Example: Computing with sinh x
23(1)
1.4.3 A First Glimpse of Rounding Errors
23(1)
1.5 Interactive Computing
24(5)
1.5.1 Using the Python Shell
25(1)
1.5.2 Type Conversion
26(1)
1.5.3 IPython
27(2)
1.6 Complex Numbers
29(4)
1.6.1 Complex Arithmetics in Python
30(1)
1.6.2 Complex Functions in Python
31(1)
1.6.3 Unified Treatment of Complex and Real Functions
31(2)
1.7 Symbolic Computing
33(2)
1.7.1 Basic Differentiation and Integration
33(1)
1.7.2 Equation Solving
34(1)
1.7.3 Taylor Series and More
35(1)
1.8 Summary
35(6)
1.8.1
Chapter Topics
35(4)
1.8.2 Example: Trajectory of a Ball
39(1)
1.8.3 About Typesetting Conventions in This Book
40(1)
1.9 Exercises
41(10)
2 Loops and Lists
51(40)
2.1 While Loops
51(6)
2.1.1 A Naive Solution
51(1)
2.1.2 While Loops
52(2)
2.1.3 Boolean Expressions
54(2)
2.1.4 Loop Implementation of a Sum
56(1)
2.2 Lists
57(5)
2.2.1 Basic List Operations
57(3)
2.2.2 For Loops
60(2)
2.3 Alternative Implementations with Lists and Loops
62(5)
2.3.1 While Loop Implementation of a for Loop
62(1)
2.3.2 The Range Construction
63(1)
2.3.3 For Loops with List Indices
64(1)
2.3.4 Changing List Elements
65(1)
2.3.5 List Comprehension
66(1)
2.3.6 Traversing Multiple Lists Simultaneously
66(1)
2.4 Nested Lists
67(7)
2.4.1 A table as a List of Rows or Columns
67(1)
2.4.2 Printing Objects
68(2)
2.4.3 Extracting Sublists
70(2)
2.4.4 Traversing Nested Lists
72(2)
2.5 Tuples
74(1)
2.6 Summary
75(7)
2.6.1
Chapter Topics
75(3)
2.6.2 Example: Analyzing List Data
78(2)
2.6.3 How to Find More Python Information
80(2)
2.7 Exercises
82(9)
3 Functions and Branching
91(58)
3.1 Functions
91(19)
3.1.1 Mathematical Functions as Python Functions
91(2)
3.1.2 Understanding the Program Flow
93(1)
3.1.3 Local and Global Variables
94(2)
3.1.4 Multiple Arguments
96(1)
3.1.5 Function Argument or Global Variable?
97(1)
3.1.6 Beyond Mathematical Functions
98(1)
3.1.7 Multiple Return Values
99(1)
3.1.8 Computing Sums
100(1)
3.1.9 Functions with No Return Values
101(2)
3.1.10 Keyword Arguments
103(2)
3.1.11 Doc Strings
105(2)
3.1.12 Functions as Arguments to Functions
107(2)
3.1.13 The Main Program
109(1)
3.1.14 Lambda Functions
110(1)
3.2 Branching
110(3)
3.2.1 If-else Blocks
111(2)
3.2.2 Inline if Tests
113(1)
3.3 Mixing Loops, Branching, and Functions in Bioinformatics Examples
113(8)
3.3.1 Counting Letters in DNA Strings
114(4)
3.3.2 Efficiency Assessment
118(2)
3.3.3 Verifying the Implementations
120(1)
3.4 Summary
121(6)
3.4.1
Chapter Topics
121(2)
3.4.2 Example: Numerical Integration
123(4)
3.5 Exercises
127(22)
4 User Input and Error Handling
149(78)
4.1 Asking Questions and Reading Answers
150(1)
4.1.1 Reading Keyboard Input
150(1)
4.2 Reading from the Command Line
151(3)
4.2.1 Providing Input on the Command Line
151(1)
4.2.2 A Variable Number of Command-Line Arguments
152(1)
4.2.3 More on Command-Line Arguments
153(1)
4.3 Turning User Text into Live Objects
154(7)
4.3.1 The Magic Eval Function
154(4)
4.3.2 The Magic Exec Function
158(2)
4.3.3 Turning String Expressions into Functions
160(1)
4.4 Option-Value Pairs on the Command Line
161(4)
4.4.1 Basic Usage of the Argparse Module
162(1)
4.4.2 Mathematical Expressions as Values
163(2)
4.5 Reading Data from File
165(6)
4.5.1 Reading a File Line by Line
166(1)
4.5.2 Alternative Ways of Reading a File
167(2)
4.5.3 Reading a Mixture of Text and Numbers
169(2)
4.6 Writing Data to File
171(8)
4.6.1 Example: Writing a Table to File
171(2)
4.6.2 Standard Input and Output as File Objects
173(3)
4.6.3 What is a File, Really?
176(3)
4.7 Handling Errors
179(6)
4.7.1 Exception Handling
180(3)
4.7.2 Raising Exceptions
183(2)
4.8 A Glimpse of Graphical User Interfaces
185(3)
4.9 Making Modules
188(13)
4.9.1 Example: Interest on Bank Deposits
188(1)
4.9.2 Collecting Functions in a Module File
189(1)
4.9.3 Test Block
190(2)
4.9.4 Verification of the Module Code
192(1)
4.9.5 Getting Input Data
193(2)
4.9.6 Doc Strings in Modules
195(1)
4.9.7 Using Modules
196(3)
4.9.8 Distributing Modules
199(1)
4.9.9 Making Software Available on the Internet
200(1)
4.10 Making Code for Python 2 and 3
201(3)
4.10.1 Basic Differences Between Python 2 and 3
201(1)
4.10.2 Turning Python 2 Code into Python 3 Code
202(2)
4.11 Summary
204(12)
4.11.1
Chapter Topics
204(4)
4.11.2 Example: Bisection Root Finding
208(8)
4.12 Exercises
216(11)
5 Array Computing and Curve Plotting
227(106)
5.1 Vectors
228(4)
5.1.1 The Vector Concept
228(1)
5.1.2 Mathematical Operations on Vectors
229(2)
5.1.3 Vector Arithmetics and Vector Functions
231(1)
5.2 Arrays in Python Programs
232(6)
5.2.1 Using Lists for Collecting Function Data
232(1)
5.2.2 Basics of Numerical Python Arrays
233(2)
5.2.3 Computing Coordinates and Function Values
235(1)
5.2.4 Vectorization
236(2)
5.3 Curve Plotting
238(18)
5.3.1 MATLAB-Style Plotting with Matplotlib
238(5)
5.3.2 Matplotlib; Pyplot Prefix
243(1)
5.3.3 SciTools and Easyviz
244(5)
5.3.4 Making Animations
249(5)
5.3.5 Making Videos
254(1)
5.3.6 Curve Plots in Pure Text
255(1)
5.4 Plotting Difficulties
256(4)
5.4.1 Piecewisely Defined Functions
256(3)
5.4.2 Rapidly Varying Functions
259(1)
5.5 More Advanced Vectorization of Functions
260(7)
5.5.1 Vectorization of StringFunction Objects
260(1)
5.5.2 Vectorization of the Heaviside Function
261(4)
5.5.3 Vectorization of a Hat Function
265(2)
5.6 More on Numerical Python Arrays
267(5)
5.6.1 Copying Arrays
267(1)
5.6.2 In-Place Arithmetics
268(1)
5.6.3 Allocating Arrays
269(1)
5.6.4 Generalized Indexing
269(1)
5.6.5 Testing for the Array Type
270(1)
5.6.6 Compact Syntax for Array Generation
271(1)
5.6.7 Shape Manipulation
271(1)
5.7 High-Performance Computing with Arrays
272(5)
5.7.1 Scalar Implementation
272(1)
5.7.2 Vectorized Implementation
273(1)
5.7.3 Memory-Saving Implementation
273(2)
5.7.4 Analysis of Memory Usage
275(1)
5.7.5 Analysis of the CPU Time
276(1)
5.8 Higher-Dimensional Arrays
277(6)
5.8.1 Matrices and Arrays
277(1)
5.8.2 Two-Dimensional Numerical Python Arrays
278(3)
5.8.3 Array Computing
281(1)
5.8.4 Matrix Objects
282(1)
5.9 Some Common Linear Algebra Operations
283(9)
5.9.1 Inverse, Determinant, and Eigenvalues
283(1)
5.9.2 Products
283(1)
5.9.3 Norms
284(1)
5.9.4 Sum and Extreme Values
284(2)
5.9.5 Indexing
286(1)
5.9.6 Transpose and Upper/Lower Triangular Parts
286(1)
5.9.7 Solving Linear Systems
287(1)
5.9.8 Matrix Row and Column Operations
287(1)
5.9.9 Computing the Rank of a Matrix
288(1)
5.9.10 Symbolic Linear Algebra
289(3)
5.10 Plotting of Scalar and Vector Fields
292(4)
5.10.1 Installation
292(1)
5.10.2 Surface Plots
293(1)
5.10.3 Parameterized Curve
293(1)
5.10.4 Contour Lines
294(1)
5.10.5 The Gradient Vector Field
294(2)
5.11 Matplotlib
296(3)
5.11.1 Surface Plots
296(1)
5.11.2 Contour Plots
297(2)
5.11.3 Vector Field Plots
299(1)
5.12 Mayavi
299(8)
5.12.1 Surface Plots
300(3)
5.12.2 Contour Plots
303(1)
5.12.3 Vector Field Plots
303(1)
5.12.4 A 3D Scalar Field and Its Gradient Field
304(2)
5.12.5 Animations
306(1)
5.13 Summary
307(6)
5.13.1
Chapter Topics
307(1)
5.13.2 Example: Animating a Function
308(5)
5.14 Exercises
313(20)
6 Dictionaries and Strings
333(76)
6.1 Dictionaries
333(18)
6.1.1 Making Dictionaries
334(1)
6.1.2 Dictionary Operations
334(2)
6.1.3 Example: Polynomials as Dictionaries
336(2)
6.1.4 Dictionaries with Default Values and Ordering
338(3)
6.1.5 Example: Storing File Data in Dictionaries
341(1)
6.1.6 Example: Storing File Data in Nested Dictionaries
342(5)
6.1.7 Example: Reading and Plotting Data Recorded at Specific Dates
347(4)
6.2 Strings
351(9)
6.2.1 Common Operations on Strings
351(4)
6.2.2 Example: Reading Pairs of Numbers
355(3)
6.2.3 Example: Reading Coordinates
358(2)
6.3 Reading Data from Web Pages
360(9)
6.3.1 About Web Pages
361(1)
6.3.2 How to Access Web Pages in Programs
362(1)
6.3.3 Example: Reading Pure Text Files
363(2)
6.3.4 Example: Extracting Data from HTML
365(1)
6.3.5 Handling Non-English Text
366(3)
6.4 Reading and Writing Spreadsheet Files
369(6)
6.4.1 CSV Files
369(1)
6.4.2 Reading CSV Files
370(1)
6.4.3 Processing Spreadsheet Data
371(1)
6.4.4 Writing CSV Files
372(1)
6.4.5 Representing Number Cells with Numerical Python Arrays
373(1)
6.4.6 Using More High-Level Numerical Python Functionality
374(1)
6.5 Examples from Analyzing DNA
375(19)
6.5.1 Computing Frequencies
375(7)
6.5.2 Analyzing the Frequency Matrix
382(3)
6.5.3 Finding Base Frequencies
385(3)
6.5.4 Translating Genes into Proteins
388(5)
6.5.5 Some Humans Can Drink Milk, While Others Cannot
393(1)
6.6 Making Code that is Compatible with Python 2 and 3
394(2)
6.6.1 More Basic Differences Between Python 2 and 3
394(2)
6.6.2 Turning Python 2 Code into Python 3 Code
396(1)
6.7 Summary
396(6)
6.7.1
Chapter Topics
396(2)
6.7.2 Example: A File Database
398(4)
6.8 Exercises
402(7)
7 Introduction to Classes
409(80)
7.1 Simple Function Classes
409(17)
7.1.1 Challenge: Functions with Parameters
410(2)
7.1.2 Representing a Function as a Class
412(5)
7.1.3 The Self Variable
417(2)
7.1.4 Another Function Class Example
419(1)
7.1.5 Alternative Function Class Implementations
420(2)
7.1.6 Making Classes Without the Class Construct
422(2)
7.1.7 Closures
424(2)
7.2 More Examples on Classes
426(6)
7.2.1 Bank Accounts
426(2)
7.2.2 Phone Book
428(2)
7.2.3 A Circle
430(2)
7.3 Special Methods
432(19)
7.3.1 The Call Special Method
432(1)
7.3.2 Example: Automagic Differentiation
433(5)
7.3.3 Example: Automagic Integration
438(2)
7.3.4 Turning an Instance into a String
440(1)
7.3.5 Example: Phone Book with Special Methods
441(2)
7.3.6 Adding Objects
443(1)
7.3.7 Example: Class for Polynomials
443(6)
7.3.8 Arithmetic Operations and Other Special Methods
449(1)
7.3.9 Special Methods for String Conversion
449(2)
7.4 Example: Class for Vectors in the Plane
451(4)
7.4.1 Some Mathematical Operations on Vectors
451(1)
7.4.2 Implementation
452(2)
7.4.3 Usage
454(1)
7.5 Example: Class for Complex Numbers
455(8)
7.5.1 Implementation
455(2)
7.5.2 Illegal Operations
457(1)
7.5.3 Mixing Complex and Real Numbers
457(2)
7.5.4 Dynamic, Static, Strong, Weak, and Duck Typing
459(1)
7.5.5 Special Methods for "Right" Operands
460(1)
7.5.6 Inspecting Instances
461(2)
7.6 Static Methods and Attributes
463(1)
7.7 Summary
464(6)
7.7.1
Chapter Topics
464(2)
7.7.2 Example: Interval Arithmetic
466(4)
7.8 Exercises
470(19)
8 Random Numbers and Simple Games
489(78)
8.1 Drawing Random Numbers
489(8)
8.1.1 The Seed
490(1)
8.1.2 Uniformly Distributed Random Numbers
491(1)
8.1.3 Visualizing the Distribution
492(1)
8.1.4 Vectorized Drawing of Random Numbers
493(1)
8.1.5 Computing the Mean and Standard Deviation
494(2)
8.1.6 The Gaussian or Normal Distribution
496(1)
8.2 Drawing Integers
497(10)
8.2.1 Random Integer Functions
498(1)
8.2.2 Example: Throwing a Die
498(3)
8.2.3 Drawing a Random Element from a List
501(1)
8.2.4 Example: Drawing Cards from a Deck
502(2)
8.2.5 Example: Class Implementation of a Deck
504(3)
8.3 Computing Probabilities
507(15)
8.3.1 Principles of Monte Carlo Simulation
507(1)
8.3.2 Example: Throwing Dice
508(3)
8.3.3 Example: Drawing Balls from a Hat
511(2)
8.3.4 Random Mutations of Genes
513(6)
8.3.5 Example: Policies for Limiting Population Growth
519(3)
8.4 Simple Games
522(4)
8.4.1 Guessing a Number
522(1)
8.4.2 Rolling Two Dice
523(3)
8.5 Monte Carlo Integration
526(8)
8.5.1 Derivation of Monte Carlo Integration
526(2)
8.5.2 Implementation of Standard Monte Carlo Integration
528(3)
8.5.3 Area Computing by Throwing Random Points
531(3)
8.6 Random Walk in One Space Dimension
534(5)
8.6.1 Basic Implementation
534(1)
8.6.2 Visualization
535(1)
8.6.3 Random Walk as a Difference Equation
536(1)
8.6.4 Computing Statistics of the Particle Positions
536(1)
8.6.5 Vectorized Implementation
537(2)
8.7 Random Walk in Two Space Dimensions
539(3)
8.7.1 Basic Implementation
539(2)
8.7.2 Vectorized Implementation
541(1)
8.8 Summary
542(7)
8.8.1
Chapter Topics
542(2)
8.8.2 Example: Random Growth
544(5)
8.9 Exercises
549(18)
9 Object-Oriented Programming
567(78)
9.1 Inheritance and Class Hierarchies
567(9)
9.1.1 A Class for Straight Lines
568(1)
9.1.2 A First Try on a Class for Parabolas
569(1)
9.1.3 A Class for Parabolas Using Inheritance
569(2)
9.1.4 Checking the Class Type
571(1)
9.1.5 Attribute vs Inheritance: has-a vs is-a Relationship
572(2)
9.1.6 Superclass for Defining an Interface
574(2)
9.2 Class Hierarchy for Numerical Differentiation
576(13)
9.2.1 Classes for Differentiation
577(2)
9.2.2 Verification
579(2)
9.2.3 A flexible Main Program
581(1)
9.2.4 Extensions
582(3)
9.2.5 Alternative Implementation via Functions
585(1)
9.2.6 Alternative Implementation via Functional Programming
586(1)
9.2.7 Alternative Implementation via a Single Class
587(2)
9.3 Class Hierarchy for Numerical Integration
589(10)
9.3.1 Numerical Integration Methods
589(1)
9.3.2 Classes for Integration
590(4)
9.3.3 Verification
594(1)
9.3.4 Using the Class Hierarchy
595(2)
9.3.5 About Object-Oriented Programming
597(2)
9.4 Class Hierarchy for Making Drawings
599(21)
9.4.1 Using the Object Collection
600(9)
9.4.2 Example of Classes for Geometric Objects
609(5)
9.4.3 Adding Functionality via Recursion
614(4)
9.4.4 Scaling, Translating, and Rotating a Figure
618(2)
9.5 Classes for DNA Analysis
620(7)
9.5.1 Class for Regions
620(1)
9.5.2 Class for Genes
621(5)
9.5.3 Subclasses
626(1)
9.6 Summary
627(8)
9.6.1
Chapter Topics
627(2)
9.6.2 Example: Input Data Reader
629(6)
9.7 Exercises
635(10)
A Sequences and Difference Equations
645(38)
A.1 Mathematical Models Based on Difference Equations
646(19)
A.1.1 Interest Rates
647(2)
A.1.2 The Factorial as a Difference Equation
649(1)
A.1.3 Fibonacci Numbers
650(1)
A.1.4 Growth of a Population
651(1)
A.1.5 Logistic Growth
652(2)
A.1.6 Payback of a Loan
654(1)
A.1.7 The Integral as a Difference Equation
655(2)
A.1.8 Taylor Series as a Difference Equation
657(1)
A.1.9 Making a Living from a Fortune
658(1)
A.1.10 Newton's Method
659(4)
A.1.11 The Inverse of a Function
663(2)
A.2 Programming with Sound
665(6)
A.2.1 Writing Sound to File
666(1)
A.2.2 Reading Sound from File
667(1)
A.2.3 Playing Many Notes
667(1)
A.2.4 Music of a Sequence
668(3)
A.3 Exercises
671(12)
B Introduction to Discrete Calculus
683(32)
B.1 Discrete Functions
683(5)
B.1.1 The Sine Function
684(1)
B.1.2 Interpolation
685(1)
B.1.3 Evaluating the Approximation
686(1)
B.1.4 Generalization
687(1)
B.2 Differentiation Becomes Finite Differences
688(5)
B.2.1 Differentiating the Sine Function
689(1)
B.2.2 Differences on a Mesh
690(2)
B.2.3 Generalization
692(1)
B.3 Integration Becomes Summation
693(6)
B.3.1 Dividing into Subintervals
693(2)
B.3.2 Integration on Subintervals
695(1)
B.3.3 Adding the Subintervals
696(1)
B.3.4 Generalization
697(2)
B.4 Taylor Series
699(10)
B.4.1 Approximating Functions Close to One Point
699(1)
B.4.2 Approximating the Exponential Function
699(1)
B.4.3 More Accurate Expansions
700(2)
B.4.4 Accuracy of the Approximation
702(2)
B.4.5 Derivatives Revisited
704(1)
B.4.6 More Accurate Difference Approximations
705(2)
B.4.7 Second-Order Derivatives
707(2)
B.5 Exercises
709(6)
C Introduction to differential equations
715(16)
C.1 The simplest case
716(2)
C.2 Exponential Growth
718(5)
C.3 Logistic Growth
723(1)
C.4 A Simple Pendulum
724(3)
C.5 A Model for the Spreading of a Disease
727(2)
C.6 Exercises
729(2)
D A Complete Differential Equation Project
731(26)
D.1 About the Problem: Motion and Forces in Physics
731(6)
D.1.1 The Physical Problem
731(2)
D.1.2 The Computational Algorithm
733(1)
D.1.3 Derivation of the Mathematical Model
734(2)
D.1.4 Derivation of the Algorithm
736(1)
D.2 Program Development and Testing
737(9)
D.2.1 Implementation
737(3)
D.2.2 Callback Functionality
740(2)
D.2.3 Making a Module
742(1)
D.2.4 Verification
743(3)
D.3 Visualization
746(9)
D.3.1 Simultaneous Computation and Plotting
746(2)
D.3.2 Some Applications
748(1)
D.3.3 Remark on Choosing At
749(1)
D.3.4 Comparing Several Quantities in Subplots
750(1)
D.3.5 Comparing Approximate and Exact Solutions
751(1)
D.3.6 Evolution of the Error as At Decreases
752(3)
D.4 Exercises
755(2)
E Programming of Differential Equations
757(78)
E.1 Scalar Ordinary Differential Equations
758(14)
E.1.1 Examples on Right-Hand-Side Functions
758(1)
E.1.2 The Forward Euler Scheme
759(1)
E.1.3 Function Implementation
760(1)
E.1.4 Verifying the Implementation
761(2)
E.1.5 From Discrete to Continuous Solution
763(1)
E.1.6 Switching Numerical Method
764(1)
E.1.7 Class Implementation
764(5)
E.1.8 Logistic Growth via a Function-Based Approach
769(1)
E.1.9 Logistic Growth via a Class-Based Approach
769(3)
E.2 Systems of Ordinary Differential Equations
772(7)
E.2.1 Mathematical Problem
773(1)
E.2.2 Example of a System of ODEs
774(1)
E.2.3 Function Implementation
775(2)
E.2.4 Class Implementation
777(2)
E.3 The ODESolver Class Hierarchy
779(23)
E.3.1 Numerical Methods
779(1)
E.3.2 Construction of a Solver Hierarchy
780(3)
E.3.3 The Backward Euler Method
783(2)
E.3.4 Verification
785(2)
E.3.5 Example: Exponential Decay
787(2)
E.3.6 Example: The Logistic Equation with Problem and Solver Classes
789(8)
E.3.7 Example: An Oscillating System
797(2)
E.3.8 Application 4: The Trajectory of a Ball
799(2)
E.3.9 Further Developments of ODESolver
801(1)
E.4 Exercises
802(33)
F Debugging
835(22)
F.1 Using a Debugger
835(3)
F.2 How to Debug
838(19)
F.2.1 A Recipe for Program Writing and Debugging
838(3)
F.2.2 Application of the Recipe
841(12)
F.2.3 Getting Help from a Code Analyzer
853(4)
G Migrating Python to Compiled Code
857(14)
G.1 Pure Python Code for Monte Carlo Simulation
857(3)
G.1.1 The Computational Problem
858(1)
G.1.2 A Scalar Python Implementation
858(1)
G.1.3 A Vectorized Python Implementation
859(1)
G.2 Migrating Scalar Python Code to Cython
860(5)
G.2.1 A Plain Cython Implementation
860(3)
G.2.2 A Better Cython Implementation
863(2)
G.3 Migrating Code to C
865(6)
G.3.1 Writing a C Program
865(1)
G.3.2 Migrating Loops to C Code via F2PY
866(1)
G.3.3 Migrating Loops to C Code via Cython
867(1)
G.3.4 Comparing Efficiency
868(3)
H Technical Topics
871(36)
H.1 Getting Access to Python
871(7)
H.1.1 Required Software
871(1)
H.1.2 Installing Software on Your Laptop: Mac OS X and Windows
872(1)
H.1.3 Anaconda and Spyder
873(1)
H.1.4 VMWare Fusion Virtual Machine
874(3)
H.1.5 Dual Boot on Windows
877(1)
H.1.6 Vagrant Virtual Machine
877(1)
H.2 How to Write and Run a Python Program
878(2)
H.2.1 The Need for a Text Editor
878(2)
H.2.2 Terminal Windows
880(1)
H.3 The SageMathCloud and Wakari Web Services
880(2)
H.3.1 Basic Intro to SageMathCloud
880(1)
H.3.2 Basic Intro to Wakari
881(1)
H.3.3 Installing Your Own Python Packages
881(1)
H.4 Writing IPython Notebooks
882(2)
H.4.1 A Simple Program in the Notebook
882(1)
H.4.2 Mixing Text, Mathematics, Code, and Graphics
882(2)
H.5 Different Ways of Running Python Programs
884(4)
H.5.1 Executing Python Programs in iPython
884(1)
H.5.2 Executing Python Programs in Unix
884(1)
H.5.3 Executing Python Programs in Windows
885(2)
H.5.4 Executing Python Programs in Mac OS X
887(1)
H.5.5 Making a Complete Stand-Alone Executable
887(1)
H.6 Doing Operating System Tasks in Python
888(3)
H.7 Variable Number of Function Arguments
891(5)
H.7.1 Variable Number of Positional Arguments
891(3)
H.7.2 Variable Number of Keyword Arguments
894(2)
H.8 Evaluating Program Efficiency
896(3)
H.8.1 Making Time Measurements
896(2)
H.8.2 Profiling Python Programs
898(1)
H.9 Software Testing
899(8)
H.9.1 Requirements of the Test Function
900(1)
H.9.2 Writing the Test Function; Precomputed Data
900(1)
H.9.3 Writing the Test Function; Exact Numerical Solution
901(1)
H.9.4 Testing of Function Robustness
902(2)
H.9.5 Automatic Execution of Tests
904(3)
References 907(2)
Index 909
Hans Petter Langtangen is a professor of computer science at the University of Oslo. He has formerly been a professor of mechanics and is now the director of a Norwegian Center of Excellence: "Center for Biomedical Computing", at Simula Research Laboratory. Langtangen has published over 100 scientific publications and written several books, including papers and the bestseller TCSE 6 "A Primer on Scientific Programming with Python", now in its 5th edition. He has also developed open source and commercial software systems for computational sciences.