Professional Documents
Culture Documents
• Today’s Lecture
overview
• Open methods
Designing pipelines: An example
for root-finding
• Newton-Raphson
requiring root-finding
• Secant
• Modified Secant
• Comparing
• Bracketing methods for root finding
methods
• Lecture
Summary
→ False position Method
• Next Lecture
PR K IC K IC PR
g (t )
t t / 2 Cos t / 2 t / 2 Cos t / 2 t
2
Last Lecture: Bisection Method
• Last lecture
• Modified Secant (this just means that g changes sign in going from tl to tu)
• Comparing 1.50E+08 tl tu
methods
1.00E+08
• Optimization
Problems 5.00E+07
• Lecture 0.00E+00
Summary 0 0.05 0.1 0.15 0.2
g(t)
-5.00E+07 t
• Next Lecture
-1.00E+08
-1.50E+08
-2.00E+08
3
Last Lecture: Bisection Method
• Last lecture
• Open methods
Step 2: Evaluate g((tu+tl)/2) → g((tu+tl)/2)<0
for root-finding
• Newton-Raphson 1.50E+08 tl tu
• Secant
1.00E+08
• Modified Secant
5.00E+07
• Comparing
methods 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Optimization -5.00E+07 t
Problems
-1.00E+08
• Lecture
Summary -1.50E+08
• Next Lecture
-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.
• Open methods
Step 2: Therefore reset tl= (tu+tl)/2. Repeat Step 2.
for root-finding
• Newton-Raphson 1.50E+08 tl tu
• Secant
1.00E+08
• Modified Secant
5.00E+07
• Comparing
methods 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Optimization -5.00E+07 t
Problems
-1.00E+08
• Lecture
Summary -1.50E+08
• Next Lecture
-2.00E+08
5
Last Lecture: Bisection Method
• Last lecture
• Open methods
Step 2: Evaluate g((tu+tl)/2) → g((tu+tl)/2)>0
for root-finding
• Newton-Raphson 1.50E+08
tl tu
• Secant
1.00E+08
• Modified Secant
5.00E+07
• Comparing
methods 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Optimization -5.00E+07 t
Problems
-1.00E+08
• Lecture
Summary -1.50E+08
• Next Lecture
-2.00E+08
6
Last Lecture: Bisection Method
• Last lecture
• Open methods
Step 2: Evaluate g((tu+tl)/2) → g((tu+tl)/2)>0
for root-finding
• Newton-Raphson 1.50E+08
tl tu
• Secant
1.00E+08
• Modified Secant
5.00E+07
• Comparing
methods 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Optimization -5.00E+07 t
Problems
-1.00E+08
• Lecture
Summary -1.50E+08
• Next Lecture
-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.
• Open methods
Step 2: In this case reset tu= (tu+tl)/2 and repeat Step 2.
for root-finding
• Newton-Raphson 1.50E+08
tl tu
• Secant
1.00E+08
• Modified Secant
5.00E+07
• Comparing
methods 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Optimization -5.00E+07 t
Problems
-1.00E+08
• Lecture
Summary -1.50E+08
• Next Lecture
-2.00E+08
8
Last Lecture: Bisection Method
• Last lecture
• Open methods
Step 2: Evaluate g((tu+tl)/2) → g((tu+tl)/2)>0
for root-finding
• Newton-Raphson 1.50E+08
tl tu
• Secant
1.00E+08
• Modified Secant
5.00E+07
• Comparing
methods 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Optimization -5.00E+07 t
Problems
-1.00E+08
• Lecture
Summary -1.50E+08
• Next Lecture
-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.
• Open methods
This is continued until tu-tl is within the precision with which you need
for root-finding to know the root of g(t)
• Newton-Raphson 1.50E+08
tltu
• Secant
1.00E+08
• Modified Secant
5.00E+07
• Comparing
methods 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Optimization -5.00E+07 t
Problems
-1.00E+08
• Lecture
Summary -1.50E+08
• Next Lecture
-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’.
10
Today’s Lecture Outline
• Last lecture
• Today’s Lecture What do we do if we have no idea where the root of the function lies?
overview
• Lecture
Summary
• Next Lecture
11
‘Open methods’ for root finding
• Last lecture
• Today’s Lecture
overview Open methods for root-finding do not require
• Open methods
for root-finding
you to initially bracket the root.
• Newton-Raphson They usually start with a single initial guess of
• Secant the root
• Modified Secant
• Optimization
methods such as Bisection and False-position
Problems
• Lecture
Summary
X However, sometimes they do not work.
• Next Lecture
They diverge instead of converging to the root.
12
‘Open methods’ for root finding
• Last lecture
• Today’s Lecture
overview We will consider 3 ‘Open methods’ for root finding:
• Open methods
for root-finding
• Newton-Raphson
• Newton-Raphson
• Secant
(probably the most widely used of all root-
• Modified Secant
finding techniques)
• Comparing
methods • Secant method
• Optimization
Problems
• Lecture
• Modified Secant Method
Summary
• Next Lecture
13
Newton-Raphson Method
• Last lecture
• Today’s Lecture
Let us again consider our problem of deciding the thickness, t,
overview of the pipe we are going to use to transport oil/gas.
• Open methods
K IC PR
for root-finding
g (t )
• Newton-Raphson t / 2 Cos t / 2 t
• Secant
• Lecture
-5.00E+07 t
Summary
-1.50E+08
-2.00E+08
14
Newton-Raphson Method
• Last lecture
• Today’s Lecture
Let us again consider our problem of deciding the thickness, t,
overview of the pipe we are going to use to transport oil/gas.
• Open methods
for root-finding
Step 1. Make an initial guess of t, t1
• Newton-Raphson
• Secant
t1
• Modified Secant 1.50E+08
• Comparing 1.00E+08
methods
5.00E+07
• Optimization
Problems 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Lecture
-5.00E+07 t
Summary
-1.50E+08
-2.00E+08
15
Newton-Raphson Method
• Last lecture
• Today’s Lecture
Let us again consider our problem of deciding the thickness, t,
overview of the pipe we are going to use to transport oil/gas.
• Open methods
for root-finding
Step 2. Draw the tangent to g(t) at t1.
• Newton-Raphson
• Secant
t1
• Modified Secant 1.50E+08
• Comparing 1.00E+08
methods
5.00E+07
• Optimization
Problems 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Lecture
-5.00E+07 t
Summary
-1.50E+08
-2.00E+08
16
Newton-Raphson Method
• Last lecture
• Today’s Lecture
Let us again consider our problem of deciding the thickness, t,
overview of the pipe we are going to use to transport oil/gas.
• Open methods
for root-finding
Step 2. Draw the tangent to g(t) at t1.
• Newton-Raphson
Your new guess of t is where the tangent passes through zero
• Secant
t 1 t2
• Modified Secant 1.50E+08
• Comparing 1.00E+08
methods
5.00E+07
• Optimization
Problems 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Lecture
-5.00E+07 t
Summary
-1.50E+08
-2.00E+08
17
Newton-Raphson Method
• Last lecture
• Today’s Lecture
Let us again consider our problem of deciding the thickness, t,
overview of the pipe we are going to use to transport oil/gas.
• Open methods
for root-finding
Step 3. Repeat Step 2
• Newton-Raphson
• Secant
t2
• Modified Secant 1.50E+08
• Comparing 1.00E+08
methods
5.00E+07
• Optimization
Problems 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Lecture
-5.00E+07 t
Summary
-1.50E+08
-2.00E+08
18
Newton-Raphson Method
• Last lecture
• Today’s Lecture
Let us again consider our problem of deciding the thickness, t,
overview of the pipe we are going to use to transport oil/gas.
• Open methods
for root-finding
Repeat Step 2. Draw the tangent to g(t) at t2.
• Newton-Raphson
Your new guess of t is where the tangent passes through zero
• Secant
t 2 t3
• Modified Secant 1.50E+08
• Comparing 1.00E+08
methods
5.00E+07
• Optimization
Problems 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Lecture
-5.00E+07 t
Summary
-1.50E+08
-2.00E+08
19
Newton-Raphson Method
• Last lecture
• Today’s Lecture
Let us again consider our problem of deciding the thickness, t,
overview of the pipe we are going to use to transport oil/gas.
• Open methods
for root-finding
Repeat Step 2.
• Newton-Raphson
• Secant
t3
• Modified Secant 1.50E+08
• Comparing 1.00E+08
methods
5.00E+07
• Optimization
Problems 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Lecture
-5.00E+07 t
Summary
-1.50E+08
-2.00E+08
20
Newton-Raphson Method
• Last lecture
• Today’s Lecture
Let us again consider our problem of deciding the thickness, t,
overview of the pipe we are going to use to transport oil/gas.
• Open methods
for root-finding
Repeat Step 2. Draw the tangent to g(t) at t3.
• Newton-Raphson
Your new guess of t is where the tangent passes through zero
• Secant
t3 t 4
• Modified Secant 1.50E+08
• Comparing 1.00E+08
methods
5.00E+07
• Optimization
Problems 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Lecture
-5.00E+07 t
Summary
-1.50E+08
-2.00E+08
21
Newton-Raphson Method
• Last lecture
• Today’s Lecture
Let us again consider our problem of deciding the thickness, t,
overview of the pipe we are going to use to transport oil/gas.
• Open methods
for root-finding
Repeat Step 2.
• Newton-Raphson
• Secant
t4
• Modified Secant 1.50E+08
• Comparing 1.00E+08
methods
5.00E+07
• Optimization
Problems 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Lecture
-5.00E+07 t
Summary
-1.50E+08
-2.00E+08
22
Newton-Raphson Method
• Last lecture
• Today’s Lecture
Let us again consider our problem of deciding the thickness, t,
overview of the pipe we are going to use to transport oil/gas.
• Open methods
for root-finding
Repeat Step 2. Draw the tangent to g(t) at t4.
• Newton-Raphson
Your new guess of t is where the tangent passes through zero
• Secant
t4t5
• Modified Secant 1.50E+08
• Comparing 1.00E+08
methods
5.00E+07
• Optimization
Problems 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Lecture
-5.00E+07 t
Summary
-1.50E+08
-2.00E+08
23
Newton-Raphson Method
• Last lecture
• Today’s Lecture
Let us again consider our problem of deciding the thickness, t,
overview of the pipe we are going to use to transport oil/gas.
• Open methods
for root-finding
Repeat Step 2 until the difference between your current guess and
• Newton-Raphson
the new guess is less than some specified amount
• Secant
t5
• Modified Secant 1.50E+08
• Comparing 1.00E+08
methods
5.00E+07
• Optimization
Problems 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Lecture
-5.00E+07 t
Summary
-1.50E+08
-2.00E+08
That’s it!
24
Newton-Raphson Method
• Last lecture
• Today’s Lecture
How do we do it in practice?
overview dg g t1
The tangent to the curve at t1 can be written: t1 g ' (t1 )
• Open methods dt t1 t 2
for root-finding
g t1
• Newton-Raphson The objective is to find t2: t 2 t1
g ' (t1 )
• Secant
t1 t2
• Modified Secant 1.50E+08
• Comparing 1.00E+08
methods
5.00E+07 t1-t2
• Optimization
Problems 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Lecture
-5.00E+07 t
Summary
g(t1)
• Next Lecture -1.00E+08
-1.50E+08
-2.00E+08
25
Newton-Raphson Method
• Last lecture
• Today’s Lecture
The Newton-Raphson method works quite well but…..
overview
• Open methods • you need to know the equation for g’(t), the derivative of g(t)
for root-finding
g t1
• Newton-Raphson t 2 t1
g ' (t1 )
• Secant
• Modified Secant
t1 t2 K IC PR
g (t )
t / 2 Cos t / 2
1.50E+08
• Comparing t
methods 1.00E+08
• Optimization
Problems
5.00E+07 t1-t2
• Lecture 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
Summary
-5.00E+07 t
• Next Lecture g(t1)
-1.00E+08
-1.50E+08
-2.00E+08
26
Newton-Raphson Method
• Last lecture
• Today’s Lecture
The Newton-Raphson method works quite well but…..
overview
• Open methods • you need to know the equation for g’(t), the derivative of g(t)
for root-finding
• Optimization
5.00E+07
Problems
• Lecture 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
Summary
-5.00E+07 t
• Next Lecture
-1.00E+08
-1.50E+08
-2.00E+08
27
M-file: Newton-Raphson
• Last lecture function root = newtonraphson(func,dfunc,xr,acc,K,P,R)
• Today’s Lecture %Firstly we evaluate the function and its derivative at the first guess
overview %of the root
fxr=feval(func,K,P,R,xr);
• Open methods dfxr=feval(dfunc,K,P,R,xr);
for root-finding
% We will use a 'While' loop to loop through our guesses at the root of the
• Newton-Raphson % function. Whilst the value of the function evaluated at the root is
% greater than the accuracy we have specified, 'acc' then we keep looping.
• Secant % We are also going to count the number of loops it takes to find the root
% in the variable, 'LoopNum'
• Modified Secant LoopNum=1;
• Comparing fxr=1;
%And the values of the function and its derivative at the new guess
• Lecture
fxr=feval(func,K,P,R,xr);
Summary dfxr=feval(dfunc,K,P,R,xr);
• Next Lecture %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)
% After each attempt we increment our number of guesses at the root by one.
% Note: This has no affect at all on the routine. It is just so we can
% look at how many guesses it takes before we arrive at the solution.
LoopNum=LoopNum+1;
end
28
Newton-Raphson Method
• Last lecture
• Today’s Lecture
Some examples of where the Netwon-Raphson method can
overview have problems
• Open methods
for root-finding
• Newton-Raphson
• Secant
• Modified Secant
• Comparing
methods
• Optimization
Problems
• Lecture
Summary
• Next Lecture
29
Secant Method
• Last lecture
• Today’s Lecture
Another problem with the Netwon-Raphson methods is that you
overview need to have the derivative of the function for which you are
• Open methods trying to locate the root.
for root-finding
K IC PR
• Newton-Raphson
e.g. g (t )
• Secant
t / 2 Cos t / 2 t
• Modified Secant
We also need g’(t). This is not always easy.
• Comparing
methods
• Optimization
Problems The Secant method is an approach that does not require a
• Lecture formula for g’(x)
Summary
• Next Lecture
30
Secant Method
• Last lecture
• Today’s Lecture
The Secant method is an approach that does not require a
overview formula for g’(x).
• Open methods
dg g (t1 ) g (t 2 )
for root-finding Instead we use an approx. for g’(x): g ' (t 2 )
dt t1 t 2
• Newton-Raphson
• Secant
t1 t2
• Modified Secant 1.50E+08
• Comparing 1.00E+08
methods t1-t2
5.00E+07
• Optimization
Problems 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Lecture
Summary
-5.00E+07
g(t2) t
31
Secant Method
• Last lecture
• Today’s Lecture
The Secant method is an approach that does not require a
overview formula for g’(x).
• Open methods
dg g (t1 ) g (t 2 )
for root-finding Instead we use an approx. for g’(x): g ' (t 2 )
dt t1 t 2
• Newton-Raphson
• Secant
t1 t2
• Modified Secant 1.50E+08
• Comparing 1.00E+08
methods t1-t2
5.00E+07
• Optimization
Problems 0.00E+00
0 0.05 0.1 0.15 0.2
g(t)
• Lecture
Summary
-5.00E+07
g(t2) t
• Today’s Lecture
The Secant method is an approach that does not require a
overview formula for g’(x).
• Open methods
for root-finding Two initial guesses, t1 and t2, that do not necessarily bracket the
• Newton-Raphson root allow an approximation to g’(t2) which can then be used to
• Secant obtain the new guess t3 as in the Newton-Raphson technique
• Modified Secant
t1 t2 t3
1.50E+08
• Comparing
methods g (t1 ) g (t 2 )
1.00E+08
g ' (t 2 )
• Optimization t1 t 2
Problems 5.00E+07
• Lecture 0.00E+00
Summary 0 0.05 0.1 0.15 0.2
g(t)
-5.00E+07 t
• Next Lecture
-1.00E+08
g t 2
t3 t 2
-1.50E+08 g ' (t 2 )
-2.00E+08
33
Modified Secant Method
• Last lecture
• Today’s Lecture
Instead of using two arbitrary initial guesses, t1 and t2, we can
overview make one guess, and the second is just a pertubation, , from t1
• Open methods
for root-finding
• Lecture 0.00E+00
Summary 0 0.05 0.1 0.15 0.2
g(t)
-5.00E+07 t
• Next Lecture
-1.00E+08
-1.50E+08
-2.00E+08
34
Modified Secant Method
• Last lecture
• Today’s Lecture
Instead of using two arbitrary initial guesses, t1 and t2, we can
overview make one guess, and the second is just a pertubation, , from t1
• Open methods
for root-finding
• Lecture 0.00E+00
Summary 0 0.05 0.1 0.15 0.2
g(t)
-5.00E+07 t
• Next Lecture
-1.00E+08
-1.50E+08
-2.00E+08
35
Comparing Root finding methods
• Last lecture
• Today’s Lecture
overview
• Open methods
for root-finding
• Newton-Raphson
• Secant
• Modified Secant
• Comparing
methods
• Optimization
Problems
• Lecture
Summary
• Next Lecture
36
Optimization Problems
• Last lecture
• Today’s Lecture In many areas of engineering we are interested also in maxima and
overview
minima of functions. This often happens in design problems.
• Open methods
for root-finding
How to design the front wing of a F1 car to simultaneously maximize
• Newton-Raphson downforce and minimize drag?
• Secant
• Modified Secant
• Comparing
methods
• Optimization
Problems
• Lecture
Summary
• Next Lecture
37
Optimization Problems
• Last lecture
• Today’s Lecture In many areas of engineering we are interested also in maxima and
overview
minima of functions. This often happens in design problems.
• Open methods
for root-finding
How to design the front wing of a F1 car to simultaneously maximize
• Newton-Raphson downforce and minimize drag?
• Secant
• Modified Secant
• Comparing
methods
• Optimization
Problems
• Lecture
Summary
• Next Lecture
38
Optimization Problems
• Last lecture
• Today’s Lecture In many areas of engineering we are interested also in maxima and
overview
minima of functions. This often happens in design problems.
• Open methods
for root-finding
Optimization problems can usually be re-cast in terms of finding the
• Newton-Raphson roots of the derivative.
• Secant
• Modified Secant
i.e. the maximia or minima in g(t) is the same as the root of g’(t)=0
• Comparing
methods
• Optimization
Problems
• Lecture
Summary
• Next Lecture
39
Lecture Summary
• Last lecture
• Today’s Lecture
overview
• Introduced ‘Open methods’ for root finding
• Open methods → Newton-Raphson
for root-finding
• Newton-Raphson
→ Secant
• Secant → Modified Secant
• Modified Secant
• Comparing
methods
• Compared the relative efficiency of the
• Optimization
methods
Problems
• Lecture
Summary • Shown the relationship between root finding
• Next Lecture
problems and optimization problems
40
Next Lecture
• Last lecture
• Today’s Lecture The last two lectures have looked at methods to find the root
overview
of one equation:
• Open methods
for root-finding
i.e. find t which satisfied g(t)=0
• Newton-Raphson
• Secant
What if instead of 1 equation g(t) we had n equations with n
• Modified Secant unknowns?
• Comparing
methods
f(t1, t2, t3…..tn)=0
• Optimization
Problems g(t1, t2, t3…..tn)=0 Such sets of simultaneous equations
• Lecture h(t1, t2, t3…..tn)=0 occur frequently in engineering problems.
Summary
j(t1, t2, t3…..tn)=0
• Next Lecture Next week we look at the case of
…… ‘Linear Algerbraic Equations’ (Chapra, Ch 8)
and examples of when these arise in
engineering
41