Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Numerical Methods

The document provides an overview of numerical methods, emphasizing their importance in solving mathematical problems through computational techniques. It discusses the benefits of studying numerical methods, including enhanced problem-solving skills and the ability to use software like Matlab effectively. Additionally, it presents examples of mathematical modeling and numerical solutions, particularly in the context of a bungee jumper problem, along with basic programming concepts in Matlab.

Uploaded by

Wudiye Bassia
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Numerical Methods

The document provides an overview of numerical methods, emphasizing their importance in solving mathematical problems through computational techniques. It discusses the benefits of studying numerical methods, including enhanced problem-solving skills and the ability to use software like Matlab effectively. Additionally, it presents examples of mathematical modeling and numerical solutions, particularly in the context of a bungee jumper problem, along with basic programming concepts in Matlab.

Uploaded by

Wudiye Bassia
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 44

AR

D ITY f
IR S o l
AH ER o l
i c a
a l
o
B IV T ch an str g i
N IO S c h u in
U e d r
M In e e
d
n g i n
A n
A L
IC S
R
E O D e
M n l
U TH r
O c a
N E e t i d
t
M ap m a a n
h e n g .
C t h l i rs A
a de ro n
M o Er l i o
M il
M
3

Instructor information
Instructor Name: Mr.Million Asfaw

Specialization:- Thermal science and fluid

mechanics(MS.c)

Major : Mechanical Engeneering

Email: milliyardo@gmail.com

Office Location:- computer science building # 38


4

What are numerical methods and why should you study them?

• Numerical methods are techniques by which


mathematical problems are formulated so that they can be
solved with arithmetic and logical operations. Because digital
computers excel at performing such operations, numerical
methods are sometimes referred to as computer mathematics.
• Beyond contributing to your overall education, there are
several additional reasons why you should study numerical
methods:
1. Numerical methods greatly expand the types of problems you
can address. They are capable of handling large systems of
equations, nonlinearities, and complicated geometries that
are not uncommon in engineering and science and that are
often impossible to solve analytically with standard calculus. As
such, they greatly enhance your problem-solving skills
5

Continued……..
2. Numerical methods allow you to use “canned” software
with insight. Matlab, Mathcad
3. Numerical methods are an efficient vehicle for learning to
use computers. Because numerical methods are expressly
designed for computer implementation. At the same time,
you will also learn to acknowledge and control the errors of
approximation that are part and parcel of large-scale
numerical calculations.
4. Numerical methods provide a vehicle for you to
reinforce your understanding of mathematics. Because one
function of numerical methods is to reduce higher
mathematics to basic arithmetic operations, they get at the
“nuts and bolts” of some otherwise obscure topics.
6

1. A SIMPLE MATHEMATICAL MODEL


• A mathematical model can be broadly defined as a
formulation or equation that expresses the essential features
of a physical system or process in mathematical terms. In a
very general sense, it can be represented as a functional
relationship of the form

• The actual mathematical expression of above can range from


a simple algebraic relationship to large complicated sets of
differential equations.
7
8
9
10
11

Continued……..
The equation is a model that relates the acceleration of a
falling object to the forces acting on it.
 It is a differential equation because it is written in terms of
the differential rate of change (dv/dt)of the variable that we
are interested in predicting.
Rather,more advanced techniques such as those of calculus
must be applied to obtain an exact or analytical solution. For
example, if the jumper is initially at rest (v=0at t =0), calculus
can be used to solve the above Equ for
12

Continued……..
• where tanh is the hyperbolic tangent that can be
either computed directly or via the more
elementary exponential function as in

• Note that Eq. (1.9) is cast in the general form of


Eq. (1.1) wherev(t)is the dependent variable,t is
the independent variable, cd and m are
parameters, and g is the forcing function.
13

Analytical Solution to the Bungee Jumper Problem

A bungee jumper with a mass of 68.1 kg leaps from a


stationary hot air balloon. Use Eq. (1.9) to compute
velocity for the first 12 s of free fall. Also determine the
terminal velocity that will be attained for an infinitely long
cord (or alternatively, the jumpmaster is having a
particularly bad day!). Use a drag coefficient of 0.25 kg/m.
14

Continued…..
15

Plot of V vs t using Matlab


16

Continued…….

Numerical methods are those in which the mathematical


problem is reformulated so it can be solved by arithmetic
operations. This can be illustrated for Eq. (1.8) by
realizing that the time rate of change of velocity can be
approximated by

Or
17

Continued………
18

Continued………..
• Equation (1.11) is called a finite-difference approximation of
the derivative at time ti It can be substituted into Eq. (1.8) to
give

• From the above we can write the equation as


19

Continued……
• Thus, the equation can be rewritten more concisely as

• If you are given an initial value for velocity at some time ti,
you can easily compute velocity at a later time ti+1.This
new value of velocity at ti+1can in turn be employed to
extend the computation to velocity at ti+2and so on. Thus
at any time along the way,
20

NumercialSou
l to
i ntotheBungeeJumperProbe
lm

• Problem Statement. Perform the same computation as in


Example 1.1 but use Eq. (1.12) to compute velocity with
Euler's method. Employ a step size of 2 s for the calculation
• Solution. At the start of the computation (t0=0), the velocity of
the jumper is zero. Using this information and the parameter
values from Example 1.1, Eq. (1.12) can be used to compute
velocity at t1=2s:

• For the next interval (from t =2to 4 s), the computation is


repeated, with the result
21

Continued…..
22

Conclusion
• The results are plotted in Fig. 1.4 along with the exact solution.
We can see that the numerical method captures the essential
features of the exact solution. However, because we have
employed straight-line segments to approximate a continuously
curving function, there is some discrepancy between the two
results. One way to minimize such discrepancies is to use a
smaller step size. For example, applying Eq. (1.12) at 1-s
intervals results in a smaller error, as the straight-line segments
track closer to the true solution. Using hand calculations, the
effort associated with using smaller and smaller step sizes
would make such numerical solutions impractical. However,
with the aid of the computer, large numbers of calculations can
be performed easily. Thus, you can accurately model the
velocity of the jumper without having to solve the differential
equation exactly
23

Matlab Program Highlight


• Write your first Matlab program
• a = 3;
• b = 5;
• c = a+b
Output:
•8
• The semicolon at the end of a statement acts to suppress
output (to keep the program running in a "quiet mode").
The third statement, c= a+b, is not followed by a
semicolon so the content of the variable c is "dumped" as
the output.
24

The meaning of "a = b"


• In Matlab and in any programming language, the
statement "a = b" does not mean "a equals b". Instead, it
prompts the action of replacing the content of a by the
content of b.
• a = 3;
• b = a;
• b
• Output:
• 3
25

Basic math operations


• a = 3;
• b = 9;
• c = 2*a+b^2-a*b+b/a-10
• Output:
• 53
• Remark: The right hand side of the third statement includes all 4 of
the basic arithmetic operators, + (addition), - (subtraction), *
(multiplication), and / (division), in their usual meaning. It also
includes the symbol, ^, which means "to the power of", so "b^2"
means (the content of b) to the power of 2, i.e., 9 ^2 = 81. The right
hand side of that statement is first evaluated: r.h.s. = 2 x 3 + 9 ^2- 3 x
9 + 9/3 - 10 = 53. The content of r.h.s., now 53, is then assigned to
the variable c in the left hand side. Since this statement is not
followed by a semicolon, the content of c is dumped as the final
output.
26

Formatted output
• fprintf('Hello')
• Output:
• Hello
• Arrays
• a = [3 6 7];
• b = [1 9 4];
•c = a + b
• Output:
• 4 15 11
27

Continued……
• Remarks: (1) Both a and b are given as a three-
element array. In the third line, the operation of
"a+b" results in element-by-element addition
Extracting an individual element of an array
a = [3 6 7];
b = [1 9 4 5];
c = a(2) + b(4)
Output:
c = 11
Remark: If b is a one-dimensional array, b(n) is the n-
th element of that array. Since a(2) is 6 and b(4) is 5,
the 3rd statement leads to c = 6+5 = 11
28

Comment
•%
• % This program demonstrates how to "comment out"
• % a segment of code
•%
• A = 3;
• B = A*A;
•%
• % B = 2*B <--- This statement is not executed
•%
• C = A+B
• Output:
• c = 12
29

Continuation to next line


• summation1 = 1 + 3 + 5 + 7 ...
+ 9 + 11

Note: The three periods (...) allow continuation to the next


line of commands. The two lines in the above example are
essentially one line of "summation1 = 1+3+5+7+9+11".
30

Intrinsic math functions and constants


• x = pi;
• y = sin(pi/2)
• z = exp(-sin(pi/2))
• Output:
•y=1
• z = 0.367
• Remarks: "pi" (= 3.14159...) is a reserved intrinsic
constant. A function within a function is allowed. The inner
most function will be evaluated first, so the 3rd statement
leads to z = exp(-1) = 0.3679.9
31

Making a quick plot


• x = [0:0.1:20];
• y = sin(x);
• plot(x,y)
• The outcome will be the following plot:
32

Basic looping
• The for loop
• Loop: Using for command
• b = 3;
• for k = 1:5
• b
• end
• Output:
• 3
• 3
• 3
• 3
• 3
• Remark: The blue-colored segment in lines 2-4 forms a "for-
loop". The statement sandwiched between "for k = 1:5" and "end"
is repeated 5 times, with the "k" index going from 1 to 5 step 1.
33

For loop: Utility of the dummy index


• b = 3;
• for k = 1:5
• b^k
• end
• Output:
•3
•9
• 27
• 81
• 243
• Remark: The outputs are 3^1, 3^2, 3^3, 3^4, and 3^5. the
value of "k" keeps changing as we go through the loop
34

For loop: More on the dummy index

• sum1 = 0;
• for k = 1:9
• sum1 = sum1+k;
• end
• Sum1

• Output:
• 45
• Remark: this program performs the summation of
1+2+3+4+5+6+7+8+9 (= 45).
35

For loop: More on the dummy index

• sum1 = 0;
• for k = 1:2:9
• sum1 = sum1+k;
• end
• sum1
• Output:
• 25
• Remark: this program performs the summation of
1+3+5+7+9 (= 25). The command "for k = 1:2:9" means
we go through the loop only 5 times. First time with k = 1,
second time with k = 1+2 (=3), third time with k = 1+2+2
(=5), and so on. The looping stops once k reaches 9.
36

Treatment of array within a loop

• b = [3 8 9 4 7 5];
• sum1 = 0;
• for k = 1:4
• sum1 = sum1+b(k);
• end
• sum1
• Output:
• 24
• Remark: This program performs the summation of sum1
= b(1)+b(2)+b(3)+b(4) = 3+8+9+4 = 24
37

Treatment of array within a loop

• b = [3 8 9 4 7 5];
• sum1 = 0;
• for k = 1:2:5
• sum1 = sum1+b(k);
• end
• sum1
• Output:
• 19
• Remark: This program performs the summation of sum1
= b(1)+b(3)+b(5) = 3+9+7 = 19
38

Double loop

• sum1 = 0;
• for n = 1:2
• for m = 1:3
• sum1 = sum1+n*m;
• end
• end
• sum1
• Output:
• 16
• Remark: this program performs the summation of Sum1 =
1*1+1*2+1*3 +2*1+2*2+2*3 = 18
39

More complicated use of loop and index


• b = [2 5 7 4 9 8 3];
• c = [2 3 5 7];
• sum1 = 0;
• for k = 1:4
• sum1 = sum1+b(c(k));
• end
• sum1
• Output:
• 24
• Remark: This program performs the summation of
• sum1 = b(c(1))+b(c(2))+b(c(3))+b(c(4))
• = b(2)+b(3)+b(5)+b(7)
• = 5+7+9+3
• = 24
40

The if command
• num1 = 7;
• if(num1 > 5)
• fprintf('%4u is greater than 5 \r', num1)
• else
• fprintf('%4u is less than or equal to 5 \r', num1)
• end
• Output:
• 7 is greater than 5
• Same program, but change first line to "num1 = 3;"
• Output:
• 3 is less than or equal to 5
• Remark: In this program, if (num1 > 5) (num1 is greater than 5) is true, the
statement
• "fprintf('%4u is greater than 5 \r', num1)" is executed. Otherwise, the
statement
• "fprintf('%4u is less than or equal to 5 \r', num1)" is executed.
41

Continued…..
• There are 6 commonly used expressions to compare two
numbers in an if command:
• A > B A is greater than B
• A < B A is less than B
• A >= B A is greater than or equal to B
• A <= B A is less than or equal to B
• A == B A equals B
• A ~= B A does not equal B
42

Mod(a,b) is for reminder c


• The "mod(A,B)" function returns the remainder
of A divided by B. For example, mod(7,2) = 1,
mod(10,4) = 2, and mod(25,5) = 0. If A is
divisible by B, mod(A,B) = 0. This is a very
useful function in many applications related to
numerical methods.
43

Combine looping and branching


• sum1 = 0;
• sum2 = 0;
• N=9
• for k = 1:N
• sum1 = sum1+k;
• if (mod(k,3) == 0)
• sum2 = sum2+k;
• end
• end
• sum1
• sum2
• Output:
• sum1 = 45
• sum2 = 18
• Remark: Sum1 = 1+2+3+4+5+6+7+8+9, while sum2 = 3+6+9.
44

Thank U !!!!
God Bless
Ethiopia !!!

You might also like