EEPC102 Module I
EEPC102 Module I
INTRODUCTION
MATH122 Module I
2
MODULE I
INTRODUCTION
OBJECTIVES
MATH122 Module I
3
There are three lessons in the module. Read each lesson carefully then
answer the exercises/activities to find out how much you have benefited from
it. Work on these exercises carefully and submit your output to your
instructor.
In case you encounter difficulty, discuss this with your instructor during
the face-to-face meeting.
MATH122 Module I
4
Lesson 1
MATH122 Module I
5
MATH122 Module I
6
Bungee-Jumping
•For a body falling within the vicinity of the earth, the net force is composed
of two opposing forces
𝐹𝐹 = 𝐹𝐹𝐷𝐷 + 𝐹𝐹𝑈𝑈
- The downward pull of gravity 𝐹𝐹𝐷𝐷
•The force due to gravity can be formulated as
𝐹𝐹𝐷𝐷 = 𝑚𝑚𝑚𝑚
– 𝑔𝑔 is the acceleration due to gravity (9.81𝑚𝑚/𝑠𝑠 2 )
- The upward force of air resistance 𝐹𝐹𝑈𝑈
• A good approximation is to formulate it as
𝐹𝐹𝑈𝑈 = −𝑐𝑐𝑑𝑑 𝑣𝑣 2
»The greater the fall velocity, the greater the upward force
due to air resistance
MATH122 Module I
7
Example 1.1
A bungee jumper with a mass of 68.1 kg leaps from a stationary hot air balloon
(the drag coefficient is 0.25 kg/m)
a. Compute the velocity for the first 12s of free fall
b. Determine the terminal velocity that will attained for an infinite long
cord
𝑣𝑣 (∞) = 51.6674
𝑚𝑚𝑚𝑚 = 𝑐𝑐𝑑𝑑 𝑣𝑣 2
𝑔𝑔𝑔𝑔
𝑣𝑣 = �
𝑐𝑐𝑑𝑑
MATH122 Module I
8
A finite-difference approximation of
the derivative at time 𝑡𝑡𝑖𝑖
𝑑𝑑𝑑𝑑 ∆𝑣𝑣
Notice that = lim
𝑑𝑑𝑑𝑑 ∆𝑡𝑡→0 ∆𝑡𝑡
Solve for
𝑐𝑐𝑑𝑑
𝑣𝑣 (𝑡𝑡𝑖𝑖+1 ) = 𝑣𝑣(𝑡𝑡𝑖𝑖 ) + �𝑔𝑔 − 𝑣𝑣 (𝑡𝑡𝑖𝑖 )2 � ((𝑡𝑡𝑖𝑖+1 − 𝑡𝑡𝑖𝑖 )
𝑚𝑚
New = old + slope x step
MATH122 Module I
9
Conservation laws
Figure 1.2 A flow balance for steady incompressible fluid flow at the junction
of pipes.
–For steady-state incompressible fluid flow in pipes
Flow in = Flow out
•The flow out of the fourth pipe must be 60
2. Different fields of engineering and science apply these laws to
different paradigms within the field
Among these laws are
–Conservation of mass
MATH122 Module I
10
–Conservation of momentum
–Conservation of charge
–Conservation of energy
Table 1.1 Devices and types of balances that are commonly used in the four
major areas of engineering. For each case, the conservation law upon which
the balance is based is specified.
Learning Activity
MATH122 Module I
11
Lesson 2
Programming
and Software
MATH122 Module I
12
In the early days of computers, programmers usually did not pay much
attention to whether their programs were clear and easy to understand.
Today, it is recognized that there are many benefits to writing organized,
well-structured code. Aside from the obvious benefit of making software
much easier to share, it also helps generate much more efficient program
development. That is, well-structured algorithms are invariably easier to
debug and test, resulting in programs that take a shorter time to develop,
test, and update.
Structured programming is a set of rules that prescribe good style
habits for the programmer. Although structured programming is flexible
enough to allow considerable creativity and personal expression, its rules
impose enough constraints to render the resulting codes far superior to
unstructured versions. In particular, the finished product is more elegant and
easier to understand.
A key idea behind structured programming is that any numerical
algorithm can be composed using the three fundamental control structures:
sequence, selection, and repetition. By limiting ourselves to these structures,
the resulting computer code will be clearer and easier to follow.
An alternative approach to express an algorithm that bridges the gap
between flowcharts and computer code is called pseudocode. This technique
uses code-like statements in place of the graphical symbols of the flowchart.
One advantage of pseudocode is that it is easier to develop a program
with it than with a flowchart. The pseudocode is also easier to modify and
share with others.
MATH122 Module I
13
A. Logical Representation
Sequence. The sequence structure expresses the trivial idea that unless you
direct it otherwise, the computer code is to be implemented one instruction
at a time. As in Fig.2.1 below, the structure can be expressed generically as
a flowchart or as pseudocode.
FIGURE 2.2 Flowchart and pseudocode for simple selection constructs. (a)
Single-alternative selection (IF/THEN) and (b) double alternative selection
(IF/THEN/ELSE).
MATH122 Module I
14
MATH122 Module I
15
MATH122 Module I
16
MATH122 Module I
17
dragging down to B5). Next, go to the Formulas tab and in the Defined
Names group, click Create from Selection. This will open the Create
Names from Selection dialog box, where the Left column box should be
automatically selected. Then click OK to create the names. To verify that
this has worked properly, select cell B3 and check that the label “m”
appears in the name box (located on the left side of the sheet just below
the menu bars).
Move to cell C8 and enter the analytical solution
𝑚𝑚 𝑐𝑐𝑐𝑐
= 9.81 ∗ ∗ (1 − exp �− ∗ 𝐴𝐴8�)
𝑐𝑐𝑐𝑐 𝑚𝑚
When this formula is entered, the value 0 should appear in cell C8. Then
copy the formula down to cell C9 to give a value of 16.42175 m/s.
All the above is typical of the standard use of Excel. For example, at this
point you could change parameter values and see how the analytical
solution changes.
IV. MATLAB
MATLAB is the flagship software product of The MathWorks, Inc., which was
cofounded by the numerical analysts Cleve Moler and John N. Little. As the
name implies, MATLAB was originally developed as a matrix laboratory. To
this day, the major element of MATLAB is still the matrix. Mathematical
manipulations of matrices are very conveniently implemented in an easy-to-
use, interactive environment. To these matrix manipulations, MATLAB has
added a variety of numerical functions, symbolic computations, and
visualization tools. As a consequence, the present version represents a fairly
comprehensive technical computing environment.
For example, suppose that we wanted to determine the analytical solution
to the parachutist problem. This could be done with the following series of
MATLAB commands.
>> g=9.81;
>> m=68.1;
>> cd=12.5;
>> tf=2;
>> v=g*m/cd*(1−exp(−cd/m*tf))
v=
16.4217
MATH122 Module I
18
V. MATHCAD
Learning Activity
MATH122 Module I
19
Lesson 3
However, the problem with numerical methods is that they yield approximate
results. It is, therefore, important to develop criteria to determine if our
approximation of the solution is acceptable.
MATH122 Module I
20
Errors definition
Et is the true error since we are comparing the approximation with the true
value.
MATH122 Module I
21
𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨 𝒆𝒆𝒆𝒆𝒆𝒆𝒆𝒆𝒆𝒆
𝜺𝜺𝒂𝒂 = 𝒙𝒙 𝟏𝟏𝟏𝟏𝟏𝟏%
𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨𝑨
You can notice, from the above formulation, that the error can be negative
or positive. But in reality the most important thing for us is that the absolute
error has to be lower than a certain limit εs (this limit is very dependent upon
the application and the computational time):
A. Round-off errors
These errors originate from the fact that computers retain only a fixed
number of significant figures during calculation. These errors are, therefore,
directly related to the manner in which numbers are stored in a computer.
In fact, remember that instead of using decimal number system (or base-10)
as we do, a computer uses a binary system (or base-2). Why? Because, this
corresponds to the on/off positions of electronic components.
MATH122 Module I
22
where (m) is the mantissa; (b) is the base of the number system used and (e)
is the exponent. As an example, the number 156.76 could be represented as
0.15676. 103 in a floating point base10 system.
Usually for the storage of fractional quantities, the first bit is reserved to the
sign, then the signed exponent, and the last bits for the mantissa. Therefore,
for an optimal storage, if the mantissa has leading zero digits, they are
removed and transferred to the exponent.
Example
1/34 = 0.0294117
Would be stored as: 0.0294. 100 However, because the zero before the 2, we
lose the digit (1). A better storage is:
0.2941. 10-1
As the number of bits is limited some very large or very small numbers can
not be represented. If you try to store a number outside this range you will
generate an overflow error.
MATH122 Module I
23
𝜋𝜋 = 3.141592653558
When comparing two numbers, it is wiser to test that the difference is less
than an acceptably small tolerance rather than to test for equality:
Example
If you want to test if a=b, the best solution is to write in your program:
If
|𝑎𝑎 − 𝑏𝑏 | ≤ 𝜀𝜀
MATH122 Module I
24
- Addition
The mantissa of the number of the smaller exponent is modified so that the
exponents are the same. If we consider a computer with just 4-digit mantissa
and a 1-digit exponent, if we add 0.1557 . 101 to 0.4381 . 10-1, the following
process will occur if chopping is used:
0.4318 . 10-1 0.004318 . 101
Then,
0.1557 . 101
0.0043 . 101
---------------
0.1600 . 101
- Subtraction
Due to the presence of the zero just before the (9), the result is normalized:
0.0955 . 102 0.9550 . 101
Note that we added a zero to fill the space of the 4-digit mantissa.
- Multiplication
normalization
0.8754 . 101
MATH122 Module I
25
Example
4000 + 0.0010
Is computed as:
0.4000 . 104
0.0000001 . 104
chopping
----------------------
0.4000001 . 104 0.4000 . 104 The small
number is completely ignored
Subtractive cancellation
This error occurs when we perform the substraction of nearly equal floating-
point numbers.
Example
MATH122 Module I
26
Learning Activity
Summative Test
1. For the free-falling parachutist with linear drag, assume a first jumper
is 70 kg and has a drag coefficient of 12 kg/s. If a second jumper has a
drag coefficient of 15 kg/s and a mass of 80 kg, how long will it take
him to reach the same velocity the first jumper reached in 9 s?
2. The average daily temperature for an area can be approximated by the
following function,
𝑇𝑇 = 𝑇𝑇𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚 + (𝑇𝑇𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 − 𝑇𝑇𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚 ) 𝑐𝑐𝑐𝑐𝑐𝑐 (𝜔𝜔(𝑡𝑡 − 𝑡𝑡𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 ))
where 𝑇𝑇𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚 = the average annual temperature, 𝑇𝑇𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 = the
peak temperature, 𝜔𝜔 = the frequency of the annual variation (=
2𝜋𝜋/365), and 𝑡𝑡𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 = day of the peak temperature (≅ 205 𝑑𝑑). Develop
a program that computes the average temperature between two days
of the year for a particular city. Test it for (a) January–February (t = 0
to 59) in Miami, Florida (𝑇𝑇𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚 = 22.18C; 𝑇𝑇𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 = 28.38C), and (b) July–
August (t = 180 to 242) in Boston, Massachusetts (𝑇𝑇𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚 = 10.78C;
𝑇𝑇𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 = 22.98C).
3. (a) Evaluate the polynomial
MATH122 Module I
27
MODULE SUMMARY
Lesson 2 deals with programming and software that are widely used in
Numerical Analysis.
MATH122 Module I