0% found this document useful (0 votes)
7 views51 pages

Slides 01 A

The document provides an overview of applied numerical methods, including root-finding, solving linear equations, optimization, integration, differentiation, and curve fitting. It discusses various examples and methods for finding roots of equations and highlights the use of software tools like Scilab, MATLAB, and Python for numerical computations. Additionally, it includes practice problems to reinforce the concepts presented.

Uploaded by

vikasanandg6264
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views51 pages

Slides 01 A

The document provides an overview of applied numerical methods, including root-finding, solving linear equations, optimization, integration, differentiation, and curve fitting. It discusses various examples and methods for finding roots of equations and highlights the use of software tools like Scilab, MATLAB, and Python for numerical computations. Additionally, it includes practice problems to reinforce the concepts presented.

Uploaded by

vikasanandg6264
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

1

ME502
Applied Numerical Methods

Course Instructor: Dr. Himanshu Tyagi


2
Numerical Methods
What are numerical methods?
Why do we need numerical methods?

Complex & higher Simple arithmetic


mathematical operations operations (+, -, ×, ÷)
2.5

20 2
1.5
1
y = f(x)

y = f(x)
10 0.5
0
-10 -5 -0.5 0 5 10
0
-1
-10 -8 -6 -4 -2 0 2 4 6 8 10 -1.5
-10 x -2
x
y = [0.1x4 + 0.04x3 – 1.296x2 – 0.36x + 3.564] × [5e–0.14(x – 0.2)^2] y = [a cos(bx) + c] × [Ae–B(x – C)^2] + D
3
Overview of Numerical Methods
4
Overview of Numerical Methods (2)
Roots of equation
y

x
5
Example: Roots of equation

QRadiation
QConvection
6
Overview of Numerical Methods (3)

y Roots of equation y Solution of linear equations

x x
7
Example: Solution of linear equations

Wall

T(x) = ?

x
8
Overview of Numerical Methods (4)

y Roots of equation y Solution of linear equations

x x
Optimization (max, min)
y

x
9
Example: Optimization (Max, Min)
Steel pipe Ambient
air

Hot
steam

Insulation
10
Overview of Numerical Methods (5)
y Integration

x
Example: Numerical 11

Differentiation, Integration, Differential equations


1   r  I     I   1   I  
    Ke I   S
r r x r 

1   T    rqrad  T
 kr    c pU
r r  r  rr x

qrad   I  , d d 
12
Overview of Numerical Methods (6)
y Integration y Curve Fitting

x x
13
Example: Curve Fitting

Annual Energy Use


(per capita) Vs. GDP

Source: U. S. Energy Information Administration, 2003.


14
Overview of Numerical Methods (7)
Roots of equation Solution of linear equations

Integration

Optimization (max, min)


Curve Fitting
Example1: Root-Finding 15

Lets try to perform a simple exercise:


For a given equation [y = f(x) = 0.5x2 – 0.32x – 4.04], find the value of y for
a given x (= 4).
y = f(x) = 0.5(4)2 – 0.32(4) – 4.04 = 8 – 1.28 – 4.04 = 2.68

Now, lets take another example in which we try to do the reverse.


For a given equation [y = f(x) = 0.5x2 – 0.32x – 4.04], we want to find that
value of x at which y is equal to a certain value (y = 0).
Example1: Root-Finding (2) 16

y = f(x) = 0.5x2 – 0.32x – 4.04 = 0


Q: What are some ways in which we can solve this problem?

“Trial-and-error”, “Brute-force”, “Guess and check”


1. Lets guess some value.
2. Substitute it in the equation, and check if it satisfied it. If not, then
selectively make the next guess. And so on.
Example1: Root-Finding (3) 17

Given equation  [y = f(x) = 0.5x2 – 0.32x – 4.04], find value of x such that
y=f(x)=0
Lets make 1st guess as x = 4, so we get: y = f(x) = 2.68
2nd guess x = 4.1 y = f(x) = 3.053
Now based on the above 2 results what can be inferred?
3rd guess x = 3.9 y = f(x) = 2.317
4th guess x = 3.5 y = f(x) = 0.965

5th guess x = 2.5 y = f(x) = -1.72

Sign has changed !!


18
y = f(x) = 0.5x2 – 0.32x – 4.04 Itr# x y=f(x)
1 4 2.68
2 4.1 3.053
3 3.9 2.317
4 3.5 0.965
5 2.5 -1.72
. . .
. . .

. 3.1805 0.00003
19
y = f(x) = 0.5x2 – 0.32x – 4.04

x = 3.1805
x = -2.5405

Graphical
Method
20
y = f(x) = 0.1x2 – 0.01x + 1 y = f(x) = 0.1x2 – 0.4x + 0.4

Complex roots Multiple roots


Example2: Root-Finding 21

Q: What is the value of π ? A: π=


22/7
3.14
3.1415

Symbol Name Approx. value


π Archimedes' constant 3.14159...
e Euler's number 2.71828...
φ Golden ratio 1.61803...
K Landau–Ramanujan constant 0.76422...
Μ Ramanujan–Soldner constant 1.45136...
Example2: Root-Finding (1) 22

Q: Is there a way we can use „Trial-and-Error‟ method to find the value of π ?

A: There could be many ways. Lets use the Euler‟s identity.

Euler‟s Identity: e iπ +1=0


Example2: Root-Finding (2) 23

Using the previous equation we can solve for π

sin (nπ) = 0 {for integer n}

For the above equation, we want to find that value of x at which y is equal to
a certain value (= 0).
Example2: Root-Finding (3) 24

Lets use the same procedure as earlier:

Lets make 1st guess as x = 3, so we get: y = f(x) = 0.1411


2nd guess x = 3.1 y = f(x) = 0.0416
Now based on the above 2 results what can be inferred?
3rd guess x = 3.2 y = f(x) = -0.0584
4th guess x = 3.15 y = f(x) = -0.0084
25

Itr# x y=f(x)
1 3 0.1411
2 3.1 0.0416
3 3.2 -0.0584
4 3.15 -0.0084
. . .

. 3.1415 9.26 × 10-5

3.14159 26535 8979 3.23 × 10-15


π = 3.14159 26535 89793 23846 26433 83279 50288 41971 69399 37510 ...
Source: On-Line Encyclopedia of Integer Sequences
https://oeis.org/A004601
Computer softwares 26

1. Numerically oriented 2. Spreadsheets


programming language
-Microsoft Excel [Proprietary]
- Scilab [Free and open source] https://www.office.com/
https://www.scilab.org/
-LibreOffice Calc [Free and
- GNU Octave [Free and open open source]
source] https://www.libreoffice.org/
https://www.gnu.org/software/octave/
-Apache OpenOffice Calc [Free
-MATLAB [Proprietary] and open source]
https://www.mathworks.com/ https://www.openoffice.org/

- Python [Free and open source]


https://www.python.org/
Scilab https://www.scilab.org/
27

Open source
software for
numerical
computation
Scilab – console screen 28
Scilab – Program 29
30

Microsoft
Excel
Python https://www.python.org/
31
Plot of 1st degree polynomial 32
6

4
y = f(x)

0
-6 -4 -2 0 2 4 6
-2

-4 x

y = 0.8x + 1.50 y = mx + c
y = 0.8 (x+1.88)
Plot of 2nd degree polynomial 33
6

4
y = f(x)

0
-6 -4 -2 0 2 4 6
-2

-4

-6
x

y = 0.5x2 – 0.32x – 4.04


y = 0.5 (x+2.54) (x-3.18)
Plot of 3rd degree polynomial 34
4
3
2
y = f(x)

1
0
-6 -4 -2 -1 0 2 4 6

-2
-3
x
y = 0.1x3 + 0.124x2 – 0.991x – 1.51
y = 0.1 (x+3.21) (x+1.15) (x-3.12)
Plot of 4th degree polynomial 35
10
8
6
y = f(x)

4
2
0
-6 -4 -2 -2 0 2 4 6
-4
-6
x
y = 0.1x4 – 0.032x3 – 1.388x2 + 0.905x + 2.49

y = 0.1 (x+3.65) (x+1.1) (x-2.05) (x-3.02)


Plot of 5th degree polynomial 36
15
10
y = f(x)

5
0
-6 -4 -2 -5 0 2 4 6

-10
-15
-20
x

y = 0.1x5 – 0.036x4 – 1.733x3 + 0.652x2 + 5.516x – 1.667

y = 0.1 (x+3.65) (x+2) (x-0.3) (x-2.12) (x-3.59)


Plot of 6th degree polynomial 37
50
40
30
y = f(x)

20
10
0
-6 -4 -2 -10 0 2 4 6

-20
x
y = 0.1x6 – 0.018x5 – 2.171x4 + 0.514x3 + 11.886x2 – 2.773x – 9.710

y = 0.1 (x+3.71) (x+2.71) (x+0.86) (x-1.15) (x-2.72) (x-3.59)


Plot of 7th degree polynomial 38
80
60
y = f(x)

40
20
0
-6 -4 -2 -20 0 2 4 6
-40
-60
-80
-100
x
y = 0.1 (x+3.71) (x+2.92) (x+1.23) (x+0.53)
(x-1.79) (x-2.76) (x-3.82)
Plot of product of polynomial with exponential 39
function
20
y = f(x)

15

10

0
-10 -8 -6 -4 -2 0 2 4 6 8 10
-5
x

y = [0.1x4 + 0.04x3 – 1.296x2 – 0.36x + 3.564] × [5e–0.14(x – 0.2)^2]


y = f(x) Plot of trigonometric functions 40

2.5

1.5

0.5

-4 -2 -0.5 0 2 4

-1.5

-2.5
x
y = 0.7 sin(1.79x) + 1.3 cos(5.32x) + 0.2
41
Practise Problem
Problem: Determine the roots of the 6th degree polynomial function given below.
It is also known that all the roots are real.

y = 0.01 × [ -80 - 26x + 145x2 + 28x3 - 26x4 - 2x5 + x6 ]


Step 1: Lets plot this function within a reasonable range (say between -6 and 6)
15

10

5 y = –0.8 – 0.26x + 1.45x2 + 0.28x3


– 0.26x4 – 0.02x5 + 0.01x6
0
-6 -4 -2 0 2 4 6
-5

-10
42
Practise Problem (Contd.)
Step 2: From this graph we can obtain the approx Root# xlower xupper
lower and upper bounds within which the roots lie.
1 -4.3 -3.5
2 -3 -2
3 -1.5 -0.3
y = 0.01 × [ -80 - 26x + 145x2 + 28x3 - 26x4 - 2x5 + x6 ]
4 0.2 1
15 5 2.2 3.8
6 4.5 5.5
10

0
-6 -4 -2 0 2 4 6
-5

-10
43
Practise Problem (Contd.)
Step 3: By using the Bisection method code we Root xlower xupper xroot
can obtained each of the 6 roots. # (± 0.00001)
1 -4.3 -3.5 -3.97823
2 -3 -2 -2.16045
3 -1.5 -0.3 -0.73931
y = 0.01 × [ -80 - 26x + 145x2 + 28x3 -
26x4 - 2x5 + x6 ] 4 0.2 1 0.82275
15 5 2.2 3.8 3.06868
10 6 4.5 5.5 4.98656
5
0
-5 -5 0 5 10

-10
44
Overall Summary
Importance of numerical methods

Scope of numerical methods

Examples of root-finding (via ‘Trial-and-Error’)

Useful computer softwares


45

Some interesting equations/curves


46
Interesting Equation (1)
sin(sin x + cos y) = cos(sin xy + cos x)

Ref: Julian Havil, "Curves for the Mathematically


Curious", Princeton University
Press, Princeton, USA, 2019.
47
Interesting Equation (2)

Ref: Julian Havil, "Curves for the Mathematically


Curious", Princeton University
Press, Princeton, USA, 2019.
48
Interesting Equation (3)

Ref: Julian Havil, "Curves for the Mathematically


Curious", Princeton University
Press, Princeton, USA, 2019.
49
Interesting Curves (1)

Ref: Keith Ball, "Strange Curves, Counting Rabbits, and Other


Mathematical Explorations", Princeton University
Press, Princeton, USA, 2003.
50
Interesting Curves (2)

Cubic curve:

y2 = x2(x + 1)

Ref: Julian Havil, "Curves for the Mathematically Curious", Princeton University Press, Princeton, USA, 2019.
Ref: https://mathshistory.st-andrews.ac.uk/Curves/ School of Mathematics and Statistics , University of St Andrews
Ref: https://en.wikipedia.org/wiki/List_of_curves
51
Interesting Curves (3)

Euler Spiral

Ref: Julian Havil, "Curves for the Mathematically


Curious", Princeton University
Press, Princeton, USA, 2019.

You might also like