Professional Documents
Culture Documents
Week7 ENG1060 Lecture13
Week7 ENG1060 Lecture13
Week7 ENG1060 Lecture13
• Subject
Overview
Yogen Padayatchy
• A Warning! Department of Mechanical Engineering
• PASS Program Room 134, Building 37
• An engineering
example of root Phone: 990 51089
finding Email: Yogen.Padayatchy@eng.monash.edu.au
Dr Christopher Hutchinson
Department of Materials Engineering
Room 161, Building 19
2
Asking me questions
• Introduction
• Subject
I can answer questions you may have (on
Overview
Part 2 of the course) out of lecture hours.
• A Warning!
• PASS Program
3
Where can I be found?
• Introduction
• Subject
Overview
• A Warning!
• PASS Program
• An engineering
example of root
finding
• PASS Program
5
Subject Overview (Part 2: CRH)
• Introduction
• A Warning!
6
Subject Overview
• Introduction
Week 7-12: Numerical Methods
• Subject
Overview
7
Subject Overview
• Introduction
Week 7-12: Numerical Methods
• Subject
Overview
8
Subject Overview
• Introduction
Week 7-12: Numerical Methods
• Subject
Overview
9
A Warning!
ENG1060 is brutally cumulative
• Introduction
• Subject
Overview
• A Warning!
• PASS Program
Successful completion of Part 2 of
• An engineering
example of root
finding
ENG1060 requires a good
understanding of Part 1 of ENG1060
• Subject
Overview
• A Warning!
programming (ENG1060) is
• PASS Program practice practice practice.
• An engineering
example of root
finding
11
ENG 1060
Computing for Engineers
Lecturer: Dr Christopher Hutchinson
Lecture 13:
Root finding
An engineering example….
• Introduction
• Subject
Overview
Oil/Gas Pipelines
• A Warning!
• PASS Program
• An engineering
example of root
finding
13
An engineering example….
• Introduction
The function of an oil/gas pipeline is to safely
• Subject
Overview transport oil or gas under pressure over large
• A Warning!
distances.
• PASS Program
• An engineering
example of root
finding
14
An engineering example….
• Introduction
Pipelines are essentially huge pressure vessels.
• Subject
Overview
• A Warning!
It is of paramount importance that the pipeline is safe
• PASS Program
All real engineering structures contain
• An engineering
example of root
t cracks!
finding
15
An engineering example….
• Introduction
There are two types of cracks:
• Subject
Overview
• those that grow very slowly (and can be monitored)
• A Warning!
• PASS Program • those that grow very quickly (at the speed of sound)
• An engineering and lead to catastrophic failure
example of root
finding
16
An engineering example….
• Introduction
There are two types of cracks:
• Subject
Overview
• those that grow very slowly (and can be monitored)
• A Warning!
• PASS Program • those that grow very quickly (at the speed of sound)
• An engineering and lead to catastrophic failure
example of root
finding
f is the stress at which a crack of size ac will grow unstably and lead
to catastrophic failure
17
An engineering example….
• Introduction
We need to make sure that a crack that reaches all
• Subject
Overview the way through the wall of the pipe (ac=t/2) will still
• A Warning! not propagate unstably and lead to catastrophic
• PASS Program failure (‘leak before break’ criteria).
• An engineering
example of root The Hoop stress is given by:
finding t PR
h
t
R The catastrophic failure stress is
2ac
given by:
Pressure, P
h K IC
f aC
Cos a c
Pipe cross-section
18
An engineering example….
• Introduction
In the design of the pipeline we need to choose a pipe
• Subject
Overview wall thickness t, so that h<f, with cracks of size
• A Warning! ac=t/2, to really be sure we are safe
• PASS Program
h PR
• An engineering
example of root
finding t t
K IC
f
t / 2 Cos t / 2
R
2ac
Pressure, P
h Our design limit is:
PR K IC
Pipe cross-section
t t / 2 Cos t / 2
19
An engineering example….
• Introduction
Our design limit is: PR K IC
• Subject
Overview
t t / 2 Cos t / 2
• A Warning!
• PASS Program
PR K IC
t / 2 Cos t / 2
• An engineering
example of root t
finding
21
Root finding
• Introduction
This implicit equation can be rewritten as:
• Subject
Overview
K IC PR
g (t )
t / 2 Cos t / 2
• A Warning!
t
• PASS Program
• An engineering
example of root
finding
We would like to find the value of t for which g(t)=0
22
Root finding
• Introduction
This implicit equation can be rewritten as:
• Subject
Overview
K IC PR
g (t )
t / 2 Cos t / 2
• A Warning!
t
• PASS Program
• An engineering
example of root
finding
We would like to find the value of t for which g(t)=0
23
Function file
K IC PR
g (t )
t / 2 Cos t / 2 t
function g = pipeline(K,P,R,t)
g=inline('K./(((pi.*t/2).^0.5).*((cos(pi.*t/2)).^0.5))-P.*R./t','K','P','R','t');
24
Root finding
• Introduction
For P=30MPa, KIC=60MPa.m1/2 and R=40cm
• Subject
Overview K IC PR
g (t )
• A Warning!
t / 2 Cos t / 2 t
• PASS Program
1.50E+08
• An engineering
example of root 1.00E+08
finding
5.00E+07
0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
-5.00E+07 t
-1.00E+08
25
Root finding
• Introduction
Graphical methods are useful to see what the
• Subject
Overview
behaviour of g(t) looks like but they are not very
• A Warning!
good at accurately determining the root.
• PASS Program
K IC PR
• An engineering g (t )
example of root
finding t / 2 Cos t / 2 t
26
Root finding
• Introduction
A very common method to do this is known as the
• Subject
Overview
‘Bisection method’ (Chapra, pg 122, 2nd Ed).
• A Warning!
Step 1. Choose an upper and lower value for t (tl, tu) that ‘brackets’ the
• PASS Program
root; i.e. g(tl)*g(tu)<0.
• An engineering
example of root
finding
(this just means that g changes sign in going from tl to tu)
1.50E+08 tl tu
1.00E+08
5.00E+07
0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
-5.00E+07 t
-1.00E+08
-1.50E+08
-2.00E+08
27
Root finding
• Introduction
‘Bisection method’
• Subject
Overview Step 2: Evaluate g((tu+tl)/2) → g((tu+tl)/2)<0
• A Warning!
0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
-5.00E+07 t
-1.00E+08
-1.50E+08
-2.00E+08
If g((tu+tl)/2)*g(tu)<0, then you know that the root lies in between (tu+tl)/2
and tu.
0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
-5.00E+07 t
-1.00E+08
-1.50E+08
-2.00E+08
29
Root finding
• Introduction
‘Bisection method’
• Subject
Overview Step 2: Evaluate g((tu+tl)/2) → g((tu+tl)/2)>0
• A Warning!
0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
-5.00E+07 t
-1.00E+08
-1.50E+08
-2.00E+08
30
Root finding
• Introduction
‘Bisection method’
• Subject
Overview Step 2: Evaluate g((tu+tl)/2) → g((tu+tl)/2)>0
• A Warning!
0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
-5.00E+07 t
-1.00E+08
-1.50E+08
-2.00E+08
If g((tu+tl)/2)*g(tu)<0, then you know that the root lies in between (tu+tl)/2
and tu. Otherwise it lies between (tu+tl)/2 and tl.
0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
-5.00E+07 t
-1.00E+08
-1.50E+08
-2.00E+08
32
Root finding
• Introduction
‘Bisection method’
• Subject
Overview Step 2: Evaluate g((tu+tl)/2) → g((tu+tl)/2)>0
• A Warning!
0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
-5.00E+07 t
-1.00E+08
-1.50E+08
-2.00E+08
If g((tu+tl)/2)*g(tu)<0, then you know that the root lies in between (tu+tl)/2
and tu. Otherwise it lies between (tu+tl)/2 and tl.
0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
-5.00E+07 t
-1.00E+08
-1.50E+08
-2.00E+08
With what you have learnt in Part 1 of this course you can write a
program to find the root of an equation using the ‘Bisection Method’.
34
M-file: Bisection method
function root = bisect(func,x1,x2,acc,K,P,R)
• Introduction %Firstly we evaluate the function at the two input values of the indep
%variable
• Subject fx1=feval(func,K,P,R,x1);
Overview fx2=feval(func,K,P,R,x2);
% We will use a 'While' loop to loop through our guesses at the root of
• A Warning! % the function. Whilst the value of the function evaluated at the root
% is greater than the accuracy we have specified, 'acc' then we keep
% looping.
• PASS Program
% We are also going to count the number of loops it takes to find the %
% root in the variable, 'LoopNum'
• An engineering LoopNum=1;
example of root
fxr=1;
finding
while (abs(fxr)>acc)
% Now we need to work out whether the new guess at the root lies on the
% LHS or RHS of the true root and set new brackets accordingly
if ((fx1*fxr)<0)
x2=xr;
else
x1=xr;
end
%We will print to the window our successive guesses at the root so you
%can see well how the algorithm works
fprintf('%5d %10.4f\n',LoopNum,xr)
end
root=xr; 35
Root finding
• Introduction
The Bisection Method is known as one of the
• Subject
Overview
‘Bracketing Methods’ for root finding.
• A Warning!
• PASS Program The name arises because you must initially choose
• An engineering value of tl and tu that ‘bracket’ the root.
example of root
finding
36
False Position Method
• Introduction
The new guess is found f ( x u ) x l x u
• Subject x r xu
Overview using this equation f ( xl ) f ( xu )
• A Warning!
• PASS Program
• An engineering
example of root xl xu
finding
xr
xu xl
cf. Bisection method: xr
2
37
Bracketing Methods
• Introduction Bracketing methods are reliable and work extremely
• Subject
Overview
well so long as you can initially bracket the root
• A Warning!
It helps to know a bit about the Possible problems!
• PASS Program behaviour of the function
• An engineering
example of root
finding
38
Lecture Summary
• Introduction
• Subject
Overview • Overview of Part 2 (Numerical
• A Warning!
methods) of ENG1060
• PASS Program
• An engineering
example of root
finding
• Designing pipelines: An example
requiring root-finding
• Bracketing methods for root finding
→ Bisection method
→ False position Method
39
Next Lecture
Bracketing methods only work if your initial
• Introduction
• Subject
Overview guesses bracket the root.
• A Warning!
• PASS Program
Sometimes this is not easy to ensure!
• An engineering
example of root
finding
• ‘Open methods’ for root finding (no need to
bracket the root)
• Optimization (finding minima and maxima)
40