Introduction To Engineering And Scientific Computing With Python 1st Edition David E Clough instant download
Introduction To Engineering And Scientific Computing With Python 1st Edition David E Clough instant download
https://ebookbell.com/product/introduction-to-engineering-and-
scientific-computing-with-python-1st-edition-david-e-
clough-44145116
https://ebookbell.com/product/introduction-to-engineering-and-
scientific-computing-with-python-david-e-clough-steven-c-
chapra-44123852
https://ebookbell.com/product/introduction-to-computational-
engineering-with-matlab-chapman-hallcrc-numerical-analysis-and-
scientific-computing-series-1st-edition-timothy-bower-44614572
https://ebookbell.com/product/introduction-to-phase-diagrams-in-
materials-science-and-engineering-hiroyasu-saka-10920704
https://ebookbell.com/product/an-introduction-to-metabolic-and-
cellular-engineering-1st-s-cortassa-2015856
Nanoengineering In Science And Technology An Introduction To The World
Of Nanodesign Series On The Foundations Of Natural Science And
Technology Michael Rieth
https://ebookbell.com/product/nanoengineering-in-science-and-
technology-an-introduction-to-the-world-of-nanodesign-series-on-the-
foundations-of-natural-science-and-technology-michael-rieth-1296448
https://ebookbell.com/product/introduction-to-engineering-and-the-
environment-1st-edition-edward-s-rubin-cliff-i-davidson-10887630
https://ebookbell.com/product/exploring-engineering-an-introduction-
to-engineering-and-design-3rd-edition-3rd-edition-philip-
kosky-10941948
https://ebookbell.com/product/exploring-engineering-an-introduction-
to-engineering-and-design-5th-philip-kosky-11132740
https://ebookbell.com/product/exploring-engineering-an-introduction-
to-engineering-and-design-5th-edition-5th-edition-philip-
kosky-22629554
Introduction to
Engineering and Scientific
Computing with Python
As more and more engineering departments and companies choose to use Python,
this book provides an essential introduction to this open-source, free-to-use language.
Expressly designed to support first-year engineering students, this book covers engi-
neering and scientific calculations, Python basics, and structured programming.
Based on extensive teaching experience, the text uses practical problem s olving
as a vehicle to teach Python as a programming language. By learning comput-
ing fundamentals in an engaging and hands-on manner, it enables the reader to
apply engineering and scientific methods with Python, focusing this general lan-
guage to the needs of engineers and the problems they are required to solve on
a daily basis. Rather than inundating students with complex terminology, this
book is designed with a leveling approach in mind, enabling students at all levels
to gain experience and understanding of Python. It covers such topics as struc-
tured programming, graphics, matrix operations, algebraic equations, differential
equations, and applied statistics. A comprehensive chapter on working with data
brings this book to a close.
This book is an essential guide to Python, which will be relevant to all
engineers, particularly undergraduate students in their first year. It will also be of
interest to professionals and graduate students looking to hone their programming
skills, and apply Python to engineering and scientific contexts.
Introduction to
Engineering and Scientific
Computing with Python
David E. Clough
Steven C. Chapra
MATLAB® is a trademark of The MathWorks, Inc. and is used with permission. The MathWorks
does not warrant the accuracy of the text or exercises in this book. This book’s use or discussion
of MATLAB® software or related products does not constitute endorsement or sponsorship by
The MathWorks of a particular pedagogical approach or particular use of the MATLAB® software.
Typeset in Times
by codeMantra
This book is dedicated to the thousands of our former students
at the University of Colorado, Tufts University, and Texas A&M
University. Go Buffs, Go Jumbos, and Gig ‘Em Aggies!
Contents
List of Examples.................................................................................................xiii
Preface................................................................................................................. xv
Acknowledgments...............................................................................................xxi
Authors..............................................................................................................xxiii
vii
viii Contents
References�������������������������������������������������������������������������������������������������������� 385
Index����������������������������������������������������������������������������������������������������������������� 387
Index of Python Terminology������������������������������������������������������������������������ 393
List of Examples
Chapter 1 Engineering and Scientific Calculations
1.1 What is the Volume of the Earth?��������������������������������������������������������������� 1
1.2 Catenary Cable........................................................................................... 21
1.3 Engineering Units in Calculations............................................................. 27
1.4 Engineering and Scientific Problem Solving............................................. 29
Chapter 5 Graphics—Matplotlib
5.1 Freezing Point of Aqueous Ethylene Glycol Solutions............................ 138
5.2 Sunspot Observations............................................................................... 139
5.3 Plotting the Densities of Salt and Mag Chloride Solutions...................... 145
5.4 Plotting Weather Data—Temperature and Relative Humidity................. 148
5.5 Worldwide Wind Power Generation......................................................... 156
5.6 Plotting the Vapor Pressure of Water versus Temperature....................... 160
5.7 Creating a Pie Chart for World Energy Production by Source................ 163
5.8 Contour Plot from Data of Salt Solution Density..................................... 167
xiii
xiv List of Examples
xv
xvi Preface
TABLE P1
Organization of This Book
Vector/Matrix
Numerical & Computer- Calculations & Rate Equations
Based Calculations Introduction to Python Equation Solving & Data
Chapter 1. Engineering Chapter 3. Python Chapter 6. Array Chapter 9. Solving
and Scientific Basics and Matrix Differential
Calculations Operations Equations
Chapter 2. Computer- Chapter 4. Structured Chapter 7. Solving Chapter 10.
Based Calculations Programming with Single Algebraic Working with
Python Equations Data
Chapter 5. Graphics— Chapter 8. Solving
Matplotlib Sets of Algebraic
Equations
our experience that students often have gaps in their learning when it comes to the
content of these two chapters.
Chapters 3–5 introduce the Python language. The first of these presents the
rudiments of the language and the Spyder IDE. Instructors wishing to use another
IDE would have to substitute their own orientation here. Chapter 4 deals with
algorithm structure and completes the coverage of Python required for subsequent
chapters. Chapter 5 focuses on plotting with the Matplotlib module. Plotting is
common in problem-solving applications encountered in later chapters.
The remaining chapters are focused on applications with the Python tools put in
place in Chapter 3–5. Chapter 6 introduces arrays and vector/matrix calculations.
Chapter 7 is all about solving single, nonlinear, algebraic, and transcendental equa-
tions with common closed and open methods. Then, there is a natural transition
to Chapter 8 where systems of linear and nonlinear algebraic equations are stud-
ied. Chapter 9, which deals with solving rate equations (i.e., differential equations),
employs a simple approach using elementary methods of quadrature and integration.
The final Chapter 10 is devoted to the study of data and introduces concepts
and methods of applied statistics in what could be described as a “statistics light”
manner. This last chapter provides students with knowledge and skills that will
be relevant to their laboratory courses, both early and later on in their academic
careers. We also encourage, and strongly advocate, that all students should obtain
more in-depth education in applied statistics via a course later in their academic
career or otherwise.
In introducing concepts and methods in Chapters 6–10, we first illustrate with
basic Python scripts and then invoke built-in capabilities from the NumPy and
SciPy modules. Having students see the methods in their own code first helps
understanding of the concepts and removes some of the mystery behind the
built-in functions. Also, we illustrate that the methods can often be programmed
with very few statements.
xviii Preface
TABLE P2
Instructional Plans
Semester Plan Quarter Plan Python Module
Week Chapters Week Chapters Week Chapters
1 1&2 1 1&2 1 3, 4 & 5
2 2 2
3 3, 4 & 5 3 3, 4 & 5 3
4 4 4 6
5 5 5 7 or 10
6 6 6 6 6
7 7 7 7
8 8
9 8 9 8, 9, or 10
10 10
11 9 11
12 12 Review
13 10
14
15 Review
xxi
Authors
David E. Clough is Professor Emeritus at the University of Colorado. He has
experience in a wide array of programming languages and computing tools and
has applied his expertise through his teaching, research, and industrial applica-
tions. Over his career, Clough has taught hundreds of short courses to practicing
professionals on applied computing and problem solving.
Steven C. Chapra is the Emeritus Professor and Louis Berger Chair in Civil and
Environmental Engineering at Tufts University. Before joining Tufts, he worked
for the U.S. Environmental Protection Agency and the National Oceanic and
Atmospheric Administration, and taught at Texas A&M University, the University
of Colorado, and Imperial College London. He is a Fellow and Distinguished
Member of the American Society of Civil Engineering (ASCE) and has received
several awards for his scholarly and academic contributions, including the
Rudolph Hering Medal (ASCE), and the Meriam-Wiley Distinguished Author
Award (American Society for Engineering Education). As a strong proponent of
continuing education, he has taught more than 90 workshops around the world
for professionals on numerical methods, computer programming, and environ-
mental modeling.
xxiii
1 Engineering and
Scientific Calculations
CHAPTER OBJECTIVES
• Review numerical calculations, including significant figures, positional
and scientific notation.
• Understand the typical functions used in engineering and scientific com-
putations, including absolute value, sign, logarithmic, exponential, trigo-
nometric, and hyperbolic relations.
• Review operations with complex numbers, including rectangular and
polar representation.
• Carry out conversions of units common to engineering and scientific
calculations.
• Develop strategies for engineering and scientific problem solving.
Our Earth is known to be an oblate spheroid, a ball squashed a bit between the
north and south poles. The radius from the center to the Equator is estimated to
be 6,378 km. The common formula for the volume of a sphere is
4 3
V= πr (1.1)
3
DOI: 10.1201/9781003256861-1 1
2 Introduction to Engineering and Scientific Computing with Python
1.0867813 × 1012 km 3
1.087 × 1012 km 3
Now, we face another problem. The radius of the Earth at the poles is reported
to be 6,357 km. The Earth is squashed by 42 km. Using this radius instead, we
come up with a volume of
1.076 × 1012 km 3
where a is the major radius (or formally called semiaxis) at the Equator and b is
the minor radius at the poles. Now, our result is, as expected, the intermediate
value
1.080 × 1012 km 3
1.1 NUMERICAL QUANTITIES
We all grow up using decimal, base-10 numbers. As you will see in Chapter 2,
this is not the number system used internally in computers. In fact, we are so
accustomed to decimal numbers that we forget about the basics of their structure.
It is also important to review this structure because, when we move internally to
computers, that number base is going to change from 10 to 2.
1.23456 × 103
TABLE 1.1
Contribution of Digits
Index Digit Contribution
3 1 1 × 103 = 1,000
2 2 2 × 102 = 200
1 3 3 × 101 = 30
0 4 4 × 100 = 4
-1 5 5 × 10¯1 = 0.5
-2 6 6 × 10¯2 = 0.06
4 Introduction to Engineering and Scientific Computing with Python
The 1.23456 part is called the significand or mantissa,2 and the power 3 is
called the characteristic or exponent. It would have also been possible to express
the number as
123456. × 10¯2
but this is less common. In typical scientific notation, the number is normalized
with only one digit to the left of the decimal point. Scientific notation gives us
the ability to represent very large and small numbers conveniently. For example,
65°F 18.3333°C
2 The use of the term mantissa is common among computer scientists but has been discouraged by
some because of confusion with the description of logarithms.
Engineering and Scientific Calculations 5
The second temperature is closely equivalent to the first, since it was converted
using the formula3
°F − 32
°C =
1.8
However, there is a significant difference in the way these two quantities are repre-
sented. By writing 65°F, we understand that the temperature is certainly in the 60s,
and it is closer to 65°F than to 64 or 66. By writing 18.3333°C, we imply that the
temperature is exact to 18.333 and closer to 18.3333 than to 18.3332 or 18.3334. Of
course, it is impractical to make a temperature measurement to such precision, and
the precision implied by the two quantities is entirely different. You can see that
we should report the converted temperature as 18°C, implying a similar precision
to that of 65°F. As described next, this leads us to the concept of significant figures.
1.1.3 Significant Figures
The significant figures are the digits in the number that are reliable and
necessary to indicate the confidence or precision with which an engineer or
scientist states a quantity. Operationally, the significant figures of a number
are the digits from the first nonzero digit on the left to either
(a) the last digit on the right, zero or nonzero if there is a decimal point
expressed, or
(b) the last nonzero digit of the number if there is no decimal point
expressed.
Significant figures are almost always expressed as the “number” of significant fig-
ures; that is, the total number of digits that satisfy the definitions. Let’s elaborate
with several examples.
3 The U.S. is one of the few countries in the world where the Fahrenheit temperature scale is still
used widely, so Americans, stubborn to change, and visitors to the U.S. are often faced with
conversions to and from the Celsius scale. As a shortcut assist, it is useful to learn the counts from
32 in steps of 18°F (-4, -14, 32, 50, 68, 86, 104, 122) because they are equivalent to steps of 10°C
from 0 (-20, -10, 0, 10, 20, 30, 40, 50). Then, intermediate steps of 9°F are steps of 5°C, e.g., 59°F
= 15°C. If you live in cold regions, it is “comforting” to know that -40 is the same in both scales.
By the way, the only other countries where °F is used are Liberia and the Cayman Islands!
6 Introduction to Engineering and Scientific Computing with Python
The last two examples raise an important point. What if the number is known
exactly for the digits 4 3 5, and it is also known that the next 0 is closer than one
digit above or below it? In other words, we have four significant digits, and the
rules (a) and (b) don’t cover that possibility. What to do? As a matter of fact, even
the difference between 43,500 and 43,500. is easy to miss. The answer lies in
using scientific notation. There is no ambiguity in the following three numbers:
and rule (a) applies to all of them. Consequently, we suggest using scientific nota-
tion whenever there could be ambiguity in the number of significant figures.
One additional point related to clarity: When expressing a decimal fraction in
written work (hand-written or printed), it is important to include a leading zero
before the decimal point. That is,
because the leading decimal point in the latter is so easily missed by the reader.
1.1.4 Rounding
The concept of significant figures carries over to numerical calculations and
introduces the need to round numbers to a given digit position. With simple addi-
tion, forming the sum
12.3
14.36
26.66
is easy. But note that the sum as expressed implies that the first number is known
as 12.30. Since we don’t know that number to such resolution (to the one-hun-
dredths place), it would be better to round the second number to the precision of
the first, 14.4, and carry out the sum as
12.3
14.4
26.7
or at least round the former result, 26.66, to the 26.7 below. The same goes for
subtraction.
The standard rules for rounding are:
Engineering and Scientific Calculations 7
a. add one to the digit in the nth place if the digit in the (n-1)th place is
greater than 5, or
b. leave the digit in the nth place as is if the digit in the (n-1)th place is
less than 5, or
c. if the digit in the (n-1)th place is equal to 5, and if there are following
non-zero digits, apply Rule a; otherwise round either up or down
to make the digit in the nth place even.
Rule (c) provides that the 5’s will be rounded up about half the time and down
about half the time. Study the examples in Table 1.2.
There may be a temptation in the fourth example to round first to 0.055 and
then round again 0.06. Don’t get caught in this trap—round only once!
There are specific rules that govern the management of significant figures in
calculations:
TABLE 1.2
Rounding Examples
Round to
Original Number Placea Result Rule Applied
43,500 1,000 44,000 (c)
42,500 1,000 42,000 (c)
18.3333 0.1 18.3 (b)
0.05493 0.01 0.05 (b)
7.86 × 103 0.1 7.9 × 103 (a)
1.046 × 1011
7.64 × 1010
The result of the second form can be normalized to give the same result as the
first form.
When two numbers are multiplied, the number of digits required to represent
the product can be as many as the sum of the number of digits in each quantity.
For example,
12.3×
14.36
.738
3.69
49.2
123. _ _ _
176.628
There are six digits in the product, but there could be as many as seven or more.
However, by applying the rule of significant figures for multiplication, the least
number of significant figures is three (from 12.3); therefore, only three signif-
icant figures should be retained in the answer That is, the answer should be
expressed as 177.
Rounding for long division deserves a closer look. Note that, if the divisor goes
evenly into the dividend, the number of digits in the quotient can be no more than
the difference between the number of digits in the dividend minus the number of
digits in the divisor. Turning the above example around,
Engineering and Scientific Calculations 9
And, this quotient should be expressed as 14.4 to reflect the limiting number
of significant figures in the divisor, 12.3. When the division does not come out
even, it can be carried out as far as desired but will always have a remainder. The
remainder is expressed as a fraction. Modifying the last example slightly,
6.022 × 1023
× 6.63 × 10–34
39.92586 × 10–11 → 3.99 × 10-10
Not only is the product normalized on the right, it is expressed with the same
limiting precision of the multiplicands.
In division, the divisor’s significand can be divided into the dividend’s signifi-
cand, and the divisor’s exponent subtracted from that of the dividend. Here is an
example:
0.1369 × 101
7.65 × 10 10
)
1.046 × 1011 or 1.37 × 100
Again, the quotient has been carried out an additional place and rounded down to
the appropriate three significant figures.
1.2 MATHEMATICAL FUNCTIONS
In carrying out engineering and scientific calculations, it is frequently necessary
to use a variety of mathematical functions, commonly including
In this section, we will review certain aspects of calculating these functions that
are prone to cause errors in results. It is not our intention to repeat the exhaustive
treatment that can be found in good books and videos on college algebra and pre-
calculus mathematics. Such books and videos should be consulted if you need a
more in-depth review.
x x
Another related function is the sign (also called signum) function, abbreviated
sgn. It can be expressed in terms of the absolute value function by the formula
x
sgn ( x ) = (1.3)
x
When x is positive, sgn(x) = 1, and, when x is negative, sgn(x) = -1. This formula
gets into trouble when x = 0, yielding an indeterminate form 0/0; so, for that case,
sgn(0) is just defined to be 0.
Note that the prior example, preserving the sign with the square, can be restated
in terms of the sgn function,
x x = sgn ( x ) x 2 (1.4)
log x ( x y ) = y (1.5)
Engineering and Scientific Calculations 11
The term xy means x raised to the power y, which you probably understand. For
integer powers, raising to a power can be handled by repeated multiplication, and
perhaps division, for example
1 1
1.5−3 = = = 0.296 ⇒ 0.30
1.53 1.5 × 1.5 × 1.5
Notice how the significant figures rule for multiplication/division is applied above.
However, calculating xy when y is a real number with a fractional part is not so
straightforward. Consider the following examples:
The scheme for computing when the power has a fractional part comes from the
use of logarithms. Before doing that, it is useful to consider some specific types of
logarithmic functions. The common (or base-10) logarithm is given by4
log10 (10 y ) = y
10 0.301 = 2
1 1 1
e = 1+ + + + ≅ 2.718281828…
1! 2! 3!
and
log e ( e y ) = ln ( e y ) = y
4 It is common in the print literature and on calculator buttons to use just log to represent log10,
but we warn you that the log function in most computer programming languages is the natural or
Napierian log (base-e), and there is a separate log10 function built in.
12 Introduction to Engineering and Scientific Computing with Python
Therefore, if ln(2) = 0.693…, then e0.693… = 2. The Napierian base arises frequently
in calculus and differential equations, and the natural logarithm can be repre-
sented by another infinite series,
x − 1 1 x − 1 3 1 x − 1 5
ln ( x ) = 2 ⋅ + ⋅ + ⋅ + for x > 0 only (1.6)
x +1 3 x +1 5 x +1
ln ( x )
log a ( x ) = y =
ln ( a ) (1.7)
This useful formula provides a way to and calculate the logarithm for any other
base. For example
ln (100 ) 4.60517...
log10 (100 ) = = =2
ln (10 ) 2.30259...
Let’s get back to that x y where y is a real number with a fractional part. Represent
the result of the calculation as z, so
z = xy
and taking the natural logarithm of both sides of the equation, we get
ln ( z ) = y ln ( x )
e ( )=z=e ( )
ln z y ln x
y ln( x )
Thus, x = e
y x
. Since there is also an infinite series for e ,
x2 x3
ex = 1 + x + + +
2! 3! (1.8)
We now can compute, from first principles, xy, by calculating ln(x) approximately
y⋅ln( x )
using the infinite series for the natural logarithm, then calculating e from the
infinite series given above. You should notice that this won’t work for x less than
or equal to zero. The one example cited above
Engineering and Scientific Calculations 13
( −1.5)1.4
Appropriate significant figures are shown for each of these examples, although
more precision is carried through in the intermediate calculations. Like we wrote
above, calculating x y, when y is a real number with a fractional part, is not that
straightforward. This bears repeating.
Reviewing the key relationships from above,
log x ( x y ) = y
log a ( x y ) = y log a ( x )
(1.9)
ln ( x )
log a ( x ) =
ln ( a )
x y = e y ln( x )
Other useful relationships involving exponents and logarithms are
x
log a = log a ( x ) − log a ( y )
y (1.10)
x y+ z = x y x z
ax y = (ax )
y
We provided you with specific rules regarding significant figures and the arith-
metic operations of addition, subtraction, multiplication, and division. Matters
aren’t so easily defined when using logarithms, exponentials, and other nonlinear
14 Introduction to Engineering and Scientific Computing with Python
1.54.1
There are evidently two significant figures in both quantities, 1.5 and 4.1. How
many significant figures should be represented in the result? Let’s take a numeri-
cal approach to this called sensitivity analysis. (This can also be approached with
calculus and partial derivatives.) We will determine the effect on the result of
changing each of the two numbers by one unit in their respective least significant
digits. Table 1.3 gives us the answers to three significant digits.
Observe the dramatic effect of changing the 1.5 quantity by ±0.1! For a given
exponent value, the answer changes by about ±1.5. The effect of changing the
exponent 4.1 by ±0.1 is much milder, about ±0.2. So, if the resolution of the
1.5 value is as stated, we cannot really report the result to any more than one
significant figure, that is, 5. This demonstrates that one must be very careful in
reporting values that are results of calculations using nonlinear functions like
exponentiation.
1.2.3 Trigonometric Functions
The various trigonometric functions occur all the time in scientific and engineer-
ing calculations. One problem that students encounter frequently in calculating
formulas that include trigonometric functions is that most of these expect the
angles to be in radians, not degrees. It seems that many students are accustomed
to degrees from their previous math courses, especially those in high school. We
will start by reviewing the basis of the three common “trig” functions and use this
to understand the difference between degrees and radians.
The trigonometric functions relate the angles in a right triangle to its sides and
hypotenuse. They are often conveniently represented on a two-dimensional graph
using a unit circle, that is, a circle with a radius of 1. Compare the definitions in
Equation 1.11 to the diagram in Figure 1.2.
TABLE 1.3
Sensitivity Analysis
4.0 4.1 4.2
1.4 3.84 3.97 4.11
1.5 5.06 5.27 5.49
1.6 6.55 6.87 7.20
Engineering and Scientific Calculations 15
sin (θ ) = b
cos (θ ) = a (1.11)
b
tan (θ ) =
a
The right triangle of reference has sides of length a and b and a hypotenuse of
length 1, given by the radius of the unit circle. Note that the x-axis coordinate a
is the length of the right triangle side adjacent to the angle θ, and the y-axis coor-
dinate is the side opposite the angle θ. This gives rise to the right-triangle-based
definitions:
opposite side
sin (θ ) =
hypotenuse
adjacent side
cos (θ ) = (1.12)
hypotenuse
opposite side
tan (θ ) =
adjacent side
1
cosecant : csc (θ ) =
sin (θ )
1
secant : sec (θ ) = (1.13)
cos (θ )
1
cotangent : cot (θ ) =
tan (θ )
There are two common ways to express the angle θ.5 By dividing the circle into
360 angular increments, we get degrees. If we consider an arc of length one on
the unit circle, the angle included by that arc is defined as a radian. Since the
circumference of the unit circle is 2π, and that includes 2π radians and 360°, we
have the equivalencies
180
1 radian = degrees ≅ 57.3°
π
π
= 1 degrees ≅ 0.0175 radians
180
As with the exponential function and natural logarithm, the trigonometric func-
tions are defined in terms of infinite series, and these can be used to approximate
numerical results. For example,
x3 x5
sin ( x ) = x − + − (1.14)
3! 5!
This requires that x be expressed in radians, not degrees. Often you may use a
calculator to compute trigonometric results, and you must be very aware whether
the calculator expects the angles to be input in radians or degrees. Many calcula-
tors have a default setting for degrees and require a special action to switch them
over to radians mode.
Here are some common trigonometric facts that many engineers and scientists
have committed to memory:
5 There is another, less frequently used unit for the angle called a grad. It is defined by dividing the
right angle (90°) into 100 increments.
Engineering and Scientific Calculations 17
π π
sin ( 30° ) = sin = 0.5 cos ( 60° ) = cos = 0.5
6 3
π 3 π
cos ( 30° ) = cos = = 0.866... tan ( 45° ) = tan = 1
6 2 4
π π 3
tan ( 60° ) = tan = 3 = 1.732... tan ( 30° ) = tan = = 0.577...
3 6 3
y = sin ( x ) ⇒ sin −1 ( y ) = x
Instead of sin–1(x), the terminology arcsin(x) is sometimes used. Notice that the
result of the inverse sine formula is an angle, typically in radians. One way to think
of the inverse sine formula above (this implies a method for obtaining it) is: “Given
a value of y, what angle x will yield the sine of y?” To do that with a calculator, you
might guess an x, compute the sine function, compare the result to y and guess new
x’s until your answer is close to y. Of course, many modern calculators have the
inverse trigonometric functions built in, and, behind the scenes, they use a similar
strategy.
There are some tricky aspects to the calculation of inverse trigonometric func-
tions. You should appreciate this with the following example.
Consider the angle described on the unit-circle diagram in Figure 1.3.
The angle is clearly greater than π (180°) and less than 3π/2 (270°). Notice that
the coordinate values of a and b are both negative. By our definition,
b
tan (θ ) =
a
and, if we chose a value of θ and computed the tangent, the result would certainly
be equal to the ratio of b to a. But consider the inverse tangent function for a
moment. Say we knew b and a and wanted to compute θ (very common in engi-
neering calculations). By definition again,
b
θ = tan −1
a
but when we carry out the calculation, taking the ratio of the negative values of b
and a yields a positive result, and the inverse tangent result is an angle between 0
and π/2 (90°). You will notice that the quadrants of the unit circle are numbered with
Roman numerals in Figure 1.3. By computing the ratio of b to a and losing the sense
of their negative signs, we have failed to recognize that the answer should be an angle
in quadrant III. To get the correct answer, we have to look at the values of a and b,
recognize they are both negative and add π (180°) to the calculated result. There are
similar considerations in distinguishing calculations in quadrants II and IV.
So, you can see that just punching the buttons of a calculator without under-
standing the nature of the functions you are using can get you into trouble.
Computer software typically provides two inverse tangent functions, one return-
ing angles in quadrants I and IV only, and another that returns the correct angles
in all four quadrants.
A useful property involving the inverse trig functions comes from the common
fact noted above,
π
tan = 1
4
By applying the inverse tangent function to both sides of the equation, we get
π
= tan −1 (1) or π = 4 ⋅ tan −1 (1)
4
If we have a convenient way of computing the inverse tangent, this last formula
gives us a way of getting a value for π to as many significant digits carried by your
calculator or computer.
There are many practical scenarios where trigonometric functions arise. One
of these is in conjunction with quantities that vary periodically, like sine waves.
Application areas include:
Engineering and Scientific Calculations 19
• electronic circuits
• electrical power distribution
• communications and signal processing
• mechanical and structural vibrations
• automation and control systems
Consider the sinusoidal signal shown in Figure 1.4, which is produced by graph-
ing the function
The amplitude of the sine wave is 1.47, and you can see in the graph that the
peaks are ±1.47. The frequency of the sine wave is 0.89 radians/second, and, by
comparing with the graph, you can confirm that the period of the sine wave is, as
determined below,
radians
for ω = 0.89
second
ω cycles
and f = ≅ 0.14 or Hertz ( Hz )
2π second
1
then P = ≅ 7.1 seconds
f
The phase shift of the sine wave is 0.32 radians (or 18°). A sine function without
phase shift would have a value of zero at time = 0, ± π ω , ± 2π ω , … You can see
from the graph that the wave starts early; in fact, at time = − 0.32 π the value is
zero. The sine wave has been advanced in time by the phase shift. Of course, the
phase shift could be negative, and the sine wave would be delayed.
By employing the “sum of angles” trigonometric identity,
1.47 sin ( 0.89 t + 0.32 ) = 1.47 cos ( 0.32 ) sin ( 0.89 t ) + 1.47 sin ( 0.32 ) cos ( 0.89 t )
You can see then that a sine function with a phase shift (or cosine function with
a phase shift) can be written as a sum of sine and cosine functions of the same
frequency but differing amplitudes.
1.2.4 Hyperbolic Functions
In deriving many engineering formulas, another family of functions arises: the
hyperbolic functions. These are actually defined in terms of exponential func-
tions; so, knowing how to calculate e x gives us the capability to calculate the
hyperbolics. Many calculators have e x built in, but not the hyperbolic functions.
A variety of software products used by engineers and scientists do have these
functions available. Their definitions are
e x − e− x
hyperbolic sine : sinh ( x ) =
2
e x + e− x
hyperbolic cosine : cosh ( x ) =
2
e x − e− x
hyperbolic tangent : tanh ( x ) = (1.17)
e x + e− x
The hyperbolic functions can be derived from the angles formed between the
origin and the coordinates of a rectangular hyperbola.6 We won’t get into that
here, but you should know how to calculate the hyperbolics should they arise in
formulas.
A catenary7 is the curve that a hanging chain or cable assumes under its own
weight when supported only at its ends. Figure 1.5 depicts such a catenary
cable suspended between two points, {-1, 3} and {3, 6}, with the lowest point
at x = 0.
The general equation describing the curve of the cable is
y = a cosh − b
x
(1.18)
a
x
y1 = a cosh 1 − b
x
and y2 = a cosh 2 − b
a a
x x
L = a sinh 2 − sinh 1 (1.19)
a a
7 The name derives from the Latin word for chain: “catenaria.”
22 Introduction to Engineering and Scientific Computing with Python
1.3 COMPLEX NUMBERS
Complex numbers arise in many engineering applications, perhaps most fre-
quently in electrical engineering. You are undoubtedly familiar with them through
the solution of the quadratic equation, ax2 + bx + c = 0, by the quadratic formula
−b ± b2 − 4 a c
x=
2a (1.20)
In evaluating the quadratic formula, the term b2–4ac is called the discriminant
because, depending on its sign, very different solutions arise. When the discrimi-
nant is positive, two distinct real roots result. When it is zero, there are two equal
real roots. When b2–4ac < 0, we are faced with the awkward situation of finding
the square root of a negative number. This is handled by defining a symbol, j, to
represent the square root of −1 as
j −1
then
b2 − 4 a c = ( −1)( 4 a c − b 2 ) = j 4 a c − b 2
which gives rise to two complex roots, each one having a real part and an imagi-
nary part with coefficient j. These are called a complex, conjugate pair because
the real parts are equal and the imaginary parts are equal but opposite in sign.
b 4 a c − b2
x=− ±j
2a 2a (1.21)
A complex number is, in fact, a pair of numbers generally represented in the form
a+ jb
where j is understood to be −1, and is called the imaginary unit.8 You can see by
its definition that j2 = -1. The quantity a is called the real part, and b is called the
imaginary part. It is convenient to represent a complex number by graphing it in
8 For obvious reasons, the imaginary unit was originally represented by the letter i. However, in
certain contexts, where the use of the letter i is problematic, the letter j is often used instead.
For example, in electrical engineering, the imaginary unit is normally denoted by j instead of i,
because i is commonly used to represent electric current. We will utilize j in this text, for a variety
of reasons. For example, the symbols i, j, and k are employed for unit vectors in the directions of
the x, y, and z axes, respectively. The use of j for distance along the y axis is more consistent with
its sense in the real plane.
Engineering and Scientific Calculations 23
a plane with the horizontal axis used for the real part and the vertical axis for the
imaginary part, as shown in Figure 1.6.
It is then possible to represent the number by polar coordinates instead of rect-
angular, Cartesian, coordinates (Figure 1.7) where r = a 2 + b 2 and θ = tan–1(b/a).9
From trigonometry, we also have that
Therefore, the original representation of the complex number, a + jb, can also be
written
which leads to
a + j b = r e jθ (1.24)
The expression on the right, r e jθ, is called the polar form on the complex number.
This also leads to the following identities for the trigonometric functions:
e jθ − e − jθ e jθ + e − jθ
sin (θ ) ≡ cos (θ ) ≡
2j 2 (1.25)
1.4 ENGINEERING UNITS10
One of the more confusing aspects of making engineering and scientific calcula-
tions is units of measurement. Table 1.4 illustrates that for common units of mea-
surement for pressure as related to an SI standard unit, kPa:
Given this table, suppose you are faced with a pressure measurement in Hg
(typical units used for barometric pressure in the U.S.), and you are asked to
report the measurement in atmospheres. This shows how to make that conversion
using the table:
TABLE 1.4
Common Units for Pressure (kPa)
Atmosphere 101.325
in Hg 3.37685 kPa
in H2O 0.24884 kPa
torr (mm Hg) 0.133322 kPa
psi 6.894757 kPa
bar 100 kPa
kgf/cm2 98.0665 kPa
10 The units of measurement used by engineers are, of course, also used by scientists. So, it is a slight
to scientists to call them engineering units, but that is the common terminology. Apology due to
scientists.
Engineering and Scientific Calculations 25
TABLE 1.5
Basic Units of the SI System
Time Second s
Length Meter m
Mass Kilogram kg
Current Ampere A
Temperature Kelvin K
Amount Mole mol
Luminous intensity Candela cd
Of course, you could look for a conversion factor from in Hg to atm directly;
however, with so many pressure units in common use, just having the relationship
with a standard SI unit, kPa, is a convenient way to create the conversion.
The international standard units of measurement are those defined by the SI
system (Système internationale d’unités), which is a modern form of the metric
system. The basic SI units of measurement are given in Table 1.5.
Commonly derived quantities encountered in engineering and scientific calcu-
lations are shown in Table 1.6.
For each of these quantities, you will encounter different units used. For exam-
ple, civil engineers in the U.S. will encounter cubic feet per second (ft3/s or cfs)
used for volumetric flow rate, and U.S. chemical engineers may encounter gallons
per minute (gpm).
Scaled units are commonly used in describing quantities. For example, milli-
meters (mm) or micrometers (μm) may be used to measure dimensions of smaller
particles. There are standard prefixes for scaling units, and these are presented
in Table 1.7.
TABLE 1.6
Derived Quantities and SI Units
Area m2
Volume m3
Volumetric flow rate m3/s
Density kg/m3
Force N kg·m/s2
Pressure Pa N/m2
Energy J N·m
Power W J/s
Viscosity Pa·s N·s/m2
Another Random Document on
Scribd Without Any Related Topics
have been sold by one of the officers of the garrison. Out of
this the Opposition intend to make capital, by charging your
father with neglect, even connivance at the traitorous
dealings with France, and thereby hounding him from
office.”
“I hear it is Solaro.”
“Why purposely?”
“Why?”
“Be that how it may, your duty surely is to help your father,
not to act in a manner which would convince the public that
he had connived at the sale of the military secrets of
Tresenta.”
Her dark eyes fixed themselves upon the distant towers and
cupolas of Florence, down where the grey mists were now
rising. They were filled with tears, and her chest beneath
her laces heaved slowly and then fell again.
Her father was in peril; it was her duty to warn him. Felice
Solaro had fallen a victim of some dastardly plot, but for
what reason and how was an utter mystery.
She longed to explain to her father all that the count had
told her, but in reply to a question, her mother had said that
she did not expect him to leave Rome for at least a
fortnight. Therefore she remained thoughtful, apprehensive,
and undecided how to act. At first she had contemplated
explaining everything to her mother, but on reflection she
saw that there were certain reasons why her anxiety should
not be aroused. Her Excellency was in very delicate health,
and while in London had consulted a physician, who had
told her that she must have as little mental worry as
possible. For that reason Mary resolved to hide the serious
truth from her.
Dinner ended at last, and the little party passed through the
three great salons lit by the thousand wax candles in their
antique sconces, into the minor drawing-room beyond,
which was always used of an evening because it was cosier
and small enough to be carpeted.
As they sang, Dubard stood beside Mary and looked into her
dark eyes for some responding glance.
But there was none. She was not thinking of him, but of
that unfortunate man convicted of treason, disgraced and
languishing in gaol—and of Filoména Nodari, the woman
who had foully betrayed him.
For a long time she sat before the glass in her pale blue
dressing-gown, her pointed chin sunk upon her breast in
thought. Ruin was before her father—and if so, it meant
ruin for them all!
Her heart beat quickly as her eye was glued to the keyhole.
The thieves, whoever they were, had opened the safe with
a key and were calmly rifling it!
The man who had opened the safe, and who was
methodically examining her father’s confidential papers in
secret, was none other than Jules Dubard!
Chapter Fifteen.
The Peril of a Nation.
That was all. She had never questioned him further. She
had been witness of the wilful concealment of the key, but
the reason she knew not. There were state secrets, she
supposed, and she always regarded them as mysterious and
inexplicable.
Yet the safe had been reopened—if not by the actual key
flung into the river, then by a copy.
And this was the man who had courted and flattered her—
the man whom more than once she had believed that she
could love!
Her heart beat quickly, for she scarce dared to breathe, lest
she should betray her presence. The silence was unbroken
save that within the room was the rustle of papers as the
man carefully glanced over folio after folio.
She watched him close the safe door and place the key in
his pocket, then she rose, caught up her candle, and sped
along the corridors back to her own room.
She relit her candle, and as she did so caught the reflection
of her own face in the long mirror, and was startled to see
how ghastly pale it was.
The discovery amazed her. She realised that the man who
courted her so assiduously and who flattered her so
constantly was in search of something which he believed to
be in her father’s possession. How he had recovered that
key which had been thrown deep into the Arno at that
lonely reach of the river beneath the tall cypresses, was an
utter mystery.
Should she go to her mother and tell her of all she had
seen? Her first impulse was to reveal everything, and seek
her mother’s counsel; yet on reflection she deemed it wiser
to tell her father all she knew. The natural impulse of a
daughter was, of course, to take her mother into her
confidence, but one fact alone prevented this—only a few
days previously her mother had been so loud in praise of
the count, in order, it seemed, to recommend him to her
daughter. Madame Morini was, with her husband, equally
eager to see a formal engagement between the pair, and
was surprised and disappointed to notice the cold,
imperturbable manner in which Mary always treated him.
Mary had realised this long ago, and for that reason now
hesitated to tell her mother the truth.
Next morning, while she was puzzling over what excuse she
could make to go to Rome, her mother came to her with an
open letter in her hand, saying that her father had been
called to Naples to be present at an official reception of King
Humbert by that city, and would not return to the Ministry
for three days. This news caused Mary’s heart to sink within
her, for she saw the uselessness of going to Rome until he
returned.
“But the key! There was only one made, and you know
where it is. You saw me do away with it.”
“And you say that you put a piece of your hairpin in the
lock, and that prevented him reopening it on the second
night?”
“And to tell you the truth, dear, I cannot credit it. He can
have no key that would open the door, unless he recovered
it from the Arno—which is not likely. They never dredge that
part, for it is too deep. Besides, that portion of the river is
my own property, and before it could be dredged they
would have to give me notice.”
“Then you disbelieve me?” she said, looking into her father’s
face.
“Well?” he snapped.
She was silent, for suddenly she recollected what the count
had said, namely, that any effort on her part to prove poor
Solaro’s innocence must reflect upon her father, whose
enemies would use the fact to prove that Italy had been
betrayed with the connivance of the Minister of War.
Her father sighed, rose from his chair, and with his hands
behind his back paced anxiously up and down the room.
“Then you dare not face your enemies if they are actually in
possession of what is contained in the safe?” she said
slowly, rising and placing her hand tenderly upon her
father’s shoulder. She realised for the first time that her
father, the man whom she had trusted so implicitly since
her childhood, held some guilty secret.
But only a deep sigh ran through the lofty room, and then
she realised that her father’s kindly eyes were filled with
tears.
Chapter Seventeen.
The Sazarac Affair.
After Mary had sought him and revealed the amazing fact of
Dubard’s secret investigations, she had gone on home to
the palace with her maid Teresa, where he had joined her
about six o’clock.
Father and daughter had dined alone in the long, high, old
frescoed room. Few words they exchanged, for both felt
that a crisis was imminent, and that if the blow fell the
catastrophe must be overwhelming and complete. A true
bond of deepest sympathy had always existed between
them, for, as an only child, he had lavished upon her all his
affection, while she, in turn, regarded him with a strong
affection unusual in these decadent days. More than once
since she had returned from the Broadstairs school she had
been his assistant and adviser in the hours when she had
found him alone and agitated as he so often was. More than
once, indeed, he had confided in her, telling her of affairs
which he withheld even from his wife for fear of unduly
disturbing her in her delicate state of health. Often he had,
of his own accord, sought his daughter’s counsel. Hence she
was in possession of many confidential facts concerning
persons and politics in Rome, and with her woman’s keen
perception had already in consequence become a trained
diplomat.
“A good deal. But here the very walls have ears,” was the
answer. “I have come in search of you.”
ebookbell.com