# Numerical Methods in Engineering with Python 3

## Jaan Kiusalaas

Language: English

Pages: 432

ISBN: 1107033853

Format: PDF / Kindle (mobi) / ePub

This book is an introduction to numerical methods for students in engineering. It covers the usual topics found in an engineering course: solution of equations, interpolation and data fitting, solution of differential equations, eigenvalue problems, and optimization. The algorithms are implemented in Python 3, a high-level programming language that rivals MATLAB® in readability and ease of use. All methods include programs showing how the computer code is utilized in the solution of problems. The book is based on Numerical Methods in Engineering with Python, which used Python 2. This new text demonstrates the use of Python 3 and includes an introduction to the Python plotting package Matplotlib. This comprehensive book is enhanced by the addition of numerous examples and problems throughout.

can be veriﬁed that the singularity is due to the following row dependency: (row 3) = (3 × row 1) − (row 2). EXAMPLE 2.2 Solve the equations Ax = b, where 8 −6 2 A = −4 11 −7 4 −7 6 28 b = −40 33 knowing that the LU decomposition of the coefﬁcient matrix is (you should verify this) 2 0 0 4 −3 1 A = LU = −1 2 0 0 4 −3 1 −1 1 0 0 2 Solution We ﬁrst solve the equations Ly = b by forward substitution: 2y1 = 28 −y1 + 2y2 = −40 y1 − y2 + y3 = 33 y1 = 28/2 = 14

toward relevance to engineering problems. For example, there is an extensive discussion of symmetric, vii viii Preface sparsely populated coefﬁcient matrices in the solution of simultaneous equations. In the same vein, the solution of eigenvalue problems concentrates on methods that efﬁciently extract speciﬁc eigenvalues from banded matrices. An important criterion used in the selection of methods was clarity. Algorithms requiring overly complex bookkeeping were rejected regardless of their

2.11 −0.80 1.72 (b) A = −1.84 3.03 1.29 −1.57 5.25 4.30 4 3 −1 (d) A = 7 −2 3 5 −18 13 2 3 3 4 4 5 2 −1 0 (c) A = −1 2 −1 0 −1 2 2. Given the LU decomposition A = LU, determine A and |A| . 1 (a) L = 1 1 (b) 0 0 1 0 5/3 1 2 0 0 L = −1 1 0 1 −3 1 1 2 4 U = 0 3 21 0 0 0 2 −1 1 U = 0 1 −3 0 0 1 3. Utilize the results of LU decomposition 1 0 A = LU = 3/2 1 1/2 11/13 to solve Ax = b, where bT = 1 −1 0 2 −3

birthdate[2] >>> print birthYear 68 >>> name = rec[1] + ’ ’ + rec[0] >>> print name John Smith >>> print rec[0:2] (’Smith’, ’John’) Lists A list is similar to a tuple, but it is mutable, so that its elements and length can be changed. A list is identiﬁed by enclosing it in brackets. Here is a sampling of operations that can be performed on lists: >>> a = [1.0, 2.0, 3.0] # Create a list >>> a.append(4.0) # Append 4.0 to list >>> print a [1.0, 2.0, 3.0, 4.0] 6 Introduction to Python >>>

mm = radius of gyration of the cross section L = 7100 mm = length of the column E = 71 × 109 Pa = modulus of elasticity Determine the maximum load P that the column can carry if the maximum stress is not to exceed 120 × 106 Pa. 18. ho Q h H Bernoulli’s equation for ﬂuid ﬂow in an open channel with a small bump is Q2 Q2 + h0 = + h+ H 2 2 2gb2 h2 2gb h0 where Q = 1.2 m3 /s = volume rate of ﬂow g = 9.81 m/s2 = gravitational acceleration b = 1.8 m = width of channel h0 = 0.6 m = upstream water