SlideShare a Scribd company logo
1 of 24
NUMERICAL METHODS LAB
(MT-202L)
Instructor: Engr. Ahmed Zaheer
Batch: 2k19 (5th Semester)
Session: Fall 2022
MED, HITEC University, Taxila
Fixed Point Iteration Method
2
OVERVIEW
3
What is it?
• A method for solving NON-LINEAR EQUATIONS
• Non-linear Equations (some examples):
• 4𝑥2 − 1 = 0
• 𝑥3 −𝑥2 +10 = 0
• 𝑦 = sin(𝑥)
• 𝑦 = log(𝑥)
4
Overview
• This is also called as Methods of successive substitution
• We solve f(x) = 0 in a different way
• Actually we solve x= g (x)
• Now we can write the above as x-g(x) = 0
• x-g(x) can now be called f(x)
xn+1 = g(xn)
• g(x) is also called the iteration function
5
Overview
• Plotting 2 graphs y=x & y=g(x)
• The point where the 2 plots intersect
is called the fixed point, is the solution
• The numerical value of x (solution) is
found by the iterative process
• The initial guess is a value of x which is
near the fixed point as the first guess and substitute in g(x)
6
Explanation
• Consider the equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎
• This equation can be written as: 𝑓 𝑥 = 𝑥3 + 𝑥2 − 1
• For x = 0, f(x) = -1
• For x = 1, f(x) = 1
• Solution (ROOT) of the equation will lie between -1 & 1 (b/c of changing sign)
• INITIAL GUESS: 𝑥0 = 0.5 (some other value could also be taken)
7
Explanation
• Equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎
• Equation can be rearranged as:
1. 𝑥 =
3
1 − 𝑥2 [ g(x) =
3
1 − 𝑥2 ]
2. 𝑥 = 1 − 𝑥3 [ g(x) = 1 − 𝑥3 ]
3. 𝑥 = 1/ 𝑥 + 1 [ g(x) = 1/ 𝑥 + 1 ]
• Which one of these “g(x)” is the correct one?
8
Explanation
• Equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎
• Which one of these “g(x)” is the correct one?
• CONDITION FOR CHECKING
|
𝒅[𝒈(𝒙)]
𝒅𝒙
| = |𝒈′
𝒙 | < 𝟏
The absolute value (i.e. positive value) of 1st differential of g(x) should be less
than 1 for the g(x) to be valid.
9
Explanation
• Equation: 𝒙𝟑
+ 𝒙𝟐
− 𝟏 = 𝟎
• g(x) = 1/ 𝑥 + 1 : This is the desired g(x)
• Generalized Form: 𝒙𝒏+𝟏 =
𝟏
𝟏+ 𝒙𝒏
10
g(x) =
𝟑
𝟏 − 𝐱𝟐 g(x) = 𝟏 − 𝐱𝟑 g(x) = 𝟏/ 𝐱 + 𝟏
𝑔′
𝑥 =
−2𝑥
3(1 − 𝑥2)2/3 𝑔′
𝑥 =
−3𝑥2
(1 − 𝑥3)1/2
𝑔′
𝑥 =
−1
2(𝑥+1)3/2
g’(0.5) = -0.4038 g’(0.5) = -0.8018 g’(0.5) = -0.2722
|g’(x)| = 0.4038 (< 1) |g’(x)| = 0.8018 (< 1) |g’(x)| = 0.2722 (< 1)
Good OK Best (minimum value of
g’(x) at 𝒙𝟎)
Explanation
• Equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎
• g(x) = 𝒙𝒏+𝟏 =
𝟏
𝟏+ 𝒙𝒏
• Root of Equation: 0.75488
11
i 𝒙𝒊 𝒙𝒊+𝟏 = 𝒈(𝒙)
0 0.5 0.81650
1 0.81650 0.74196
2 0.74196 0.75767
3 0.75767 0.75428
5 0.75428 0.75501
6 0.75501 0.75485
7 0.75485 0.75488
8 0.75488 0.75488
BUILT-IN FUNCTIONS
12
fzero:
Built-in Command
• This command is built into the MATLAB specifically to solve Non-Linear Equations.
• MATLAB can only equations in which right-hand side of the equal-sign is Zero.
• Consider the equation: 𝒙𝟑
+ 𝒙𝟐
− 𝟏 = 𝟎
• Equation can be written as: 𝑓 𝑥 = 𝑥3 + 𝑥2 − 1
• f(x) can be written in MATLAB as: f=@(x)
• This equation will be written and solved in MATLAB as:
• f=@(x) (x^3 + x^2 -1)
• root = fzero(f,1)
13
fzero:
Built-in Command
• Equation: 𝑓 𝑥 = 𝑥3 + 𝑥2 − 1
• This equation will be written and solved in MATLAB as:
• f=@(x) (x^3 + x^2 -1)
• fzero (f , 1) % This command will find the root of Function “ f ”, with Initial Guess value = 1
(Guess value can be changed to get the correct answer, or to get multiple roots)
• Output will be displayed as: ans = 0.7549
14
Graphical Solution
• Graphs can be used to estimate the solution of equations
15
Graphical Solution
• Equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎
• 𝑦 = 𝑥3 + 𝑥2 − 1
• 𝑦 = 𝑥
• Graphs can be drawn in MATLAB as:
x = -10:0.1:10;
% x is an array containing elements from -10 to +10, with incremental steps of 0.1
y1 = x.^3 + x.^2 - 1;
y2 = x;
plot(x,y1,x,y2) % For plotting multiple graphs using a single line of code
hold on
grid on
legend('y1','y2')
16
Graphical Solution
• Equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎
• 𝑦 = 𝑥3 + 𝑥2 − 1
• 𝑦 = 𝑥
• This graph can be zoomed for
better clarity.
• The point where the two curves
intersect, is the solution i.e.
the required
Root of the equation.
17
CODING THE ITERATION METHOD
18
Overview
• Iterative procedure for finding the root of an equation consists of 3
parts:
1. Initial Guess of solution
2. Algorithm for finding approximate solution
3. Criteria to Stop Computations
• Equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎
• g(x) = 𝒙𝒏+𝟏 =
𝟏
𝟏+ 𝒙𝒏
19
For Loop
x0 = 1; % Intial Guess value
maxIter = 50; % No. of max. iterations
tolX = 1e-4; % Tolerance limit for Error
x = x0; % x_n+1
x_old = x0; % x_n
for i = 1:maxIter % For Loop
x = 1/sqrt(1+x); % g(x)
fprintf('x%0.0f = %fn',i,x) % Output display
err = abs(x - x_old); % Absolute (positive) value of Error (between x_n and x_n+1)
x_old = x; % Updating value of x_n
if err < tolX % Comparing Error with Tolerance Limit
break % When Error becomes less than Tolerance, the Loop will break
end % End of If
end % End of For Loop 20
Output Display
x1 = 0.707107
x2 = 0.765367
x3 = 0.752632
x4 = 0.755361
x5 = 0.754774
x6 = 0.754900
x7 = 0.754873
While Loop
x0 = 1; % Intial Guess value
maxIter = 50; % No. of max. iterations
tolX = 1e-6; % Tolerance limit for Error
err = 1; % Intial value of Error
x = x0; % x_n+1
x_old = x0; % x_n
i = 1; % Intial value of i (i=0,1,2,...)
while err > tolX % While Loop
x = 1/sqrt(1+x); % g(x)
fprintf('x%0.0f = %fn',i,x) % Output display
i = i+1; % Updating value of i
err = abs(x - x_old); % Positive value of Error (between x_n and x_n+1)
x_old = x; % Updating value of x_n
end % Loop will end when Error becomes less than Tolerance 21
CONCLUSION
22
Review
• Fixed Point Iteration Method is used for finding ROOTS of Non-Linear Equations.
• fzero command can be used to find solution of Non-linear equations directly
(Initial Guess value should be chosen carefully).
• Graphs can be used to visualize the solution of the equation.
• Loops (both For & While) are tools which can be implemented in program code to
find solution of equations, with following steps:
• Initial Guess value
• Algorithm for finding solution
• Criteria for stopping computations
23
The End
• Thank you!
• Any Questions?
24

More Related Content

What's hot

Presentation on Solution to non linear equations
Presentation on Solution to non linear equationsPresentation on Solution to non linear equations
Presentation on Solution to non linear equationsRifat Rahamatullah
 
Methods of variation of parameters- advance engineering mathe mathematics
Methods of variation of parameters- advance engineering mathe mathematicsMethods of variation of parameters- advance engineering mathe mathematics
Methods of variation of parameters- advance engineering mathe mathematicsKaushal Patel
 
Applied Calculus Chapter 3 partial derivatives
Applied Calculus Chapter  3 partial derivativesApplied Calculus Chapter  3 partial derivatives
Applied Calculus Chapter 3 partial derivativesJ C
 
functions-of-several-variables.ppt
functions-of-several-variables.pptfunctions-of-several-variables.ppt
functions-of-several-variables.pptDavidbham
 
PRESENTATION ON INTRODUCTION TO SEVERAL VARIABLES AND PARTIAL DERIVATIVES
PRESENTATION ON INTRODUCTION TO SEVERAL VARIABLES AND PARTIAL DERIVATIVES   PRESENTATION ON INTRODUCTION TO SEVERAL VARIABLES AND PARTIAL DERIVATIVES
PRESENTATION ON INTRODUCTION TO SEVERAL VARIABLES AND PARTIAL DERIVATIVES Mazharul Islam
 
Lesson 11: Limits and Continuity
Lesson 11: Limits and ContinuityLesson 11: Limits and Continuity
Lesson 11: Limits and ContinuityMatthew Leingang
 
Double integration final
Double integration finalDouble integration final
Double integration finalroypark31
 
Function transformations
Function transformationsFunction transformations
Function transformationsTerry Gastauer
 
Gaussian Numerical Integration
Gaussian Numerical IntegrationGaussian Numerical Integration
Gaussian Numerical IntegrationVARUN KUMAR
 
Cubic Spline Interpolation
Cubic Spline InterpolationCubic Spline Interpolation
Cubic Spline InterpolationVARUN KUMAR
 
03 truncation errors
03 truncation errors03 truncation errors
03 truncation errorsmaheej
 
Interpolation of Cubic Splines
Interpolation of Cubic SplinesInterpolation of Cubic Splines
Interpolation of Cubic SplinesSohaib H. Khan
 
Runge Kutta Method
Runge Kutta Method Runge Kutta Method
Runge Kutta Method Bhavik Vashi
 

What's hot (20)

Presentation on Solution to non linear equations
Presentation on Solution to non linear equationsPresentation on Solution to non linear equations
Presentation on Solution to non linear equations
 
Secant method
Secant method Secant method
Secant method
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Methods of variation of parameters- advance engineering mathe mathematics
Methods of variation of parameters- advance engineering mathe mathematicsMethods of variation of parameters- advance engineering mathe mathematics
Methods of variation of parameters- advance engineering mathe mathematics
 
Unit4
Unit4Unit4
Unit4
 
Applied Calculus Chapter 3 partial derivatives
Applied Calculus Chapter  3 partial derivativesApplied Calculus Chapter  3 partial derivatives
Applied Calculus Chapter 3 partial derivatives
 
functions-of-several-variables.ppt
functions-of-several-variables.pptfunctions-of-several-variables.ppt
functions-of-several-variables.ppt
 
PRESENTATION ON INTRODUCTION TO SEVERAL VARIABLES AND PARTIAL DERIVATIVES
PRESENTATION ON INTRODUCTION TO SEVERAL VARIABLES AND PARTIAL DERIVATIVES   PRESENTATION ON INTRODUCTION TO SEVERAL VARIABLES AND PARTIAL DERIVATIVES
PRESENTATION ON INTRODUCTION TO SEVERAL VARIABLES AND PARTIAL DERIVATIVES
 
The gamma function
The gamma functionThe gamma function
The gamma function
 
Lesson 11: Limits and Continuity
Lesson 11: Limits and ContinuityLesson 11: Limits and Continuity
Lesson 11: Limits and Continuity
 
Finite Difference Method
Finite Difference MethodFinite Difference Method
Finite Difference Method
 
Double integration final
Double integration finalDouble integration final
Double integration final
 
Function transformations
Function transformationsFunction transformations
Function transformations
 
Gaussian Numerical Integration
Gaussian Numerical IntegrationGaussian Numerical Integration
Gaussian Numerical Integration
 
DIFFERENTIATION
DIFFERENTIATIONDIFFERENTIATION
DIFFERENTIATION
 
Cubic Spline Interpolation
Cubic Spline InterpolationCubic Spline Interpolation
Cubic Spline Interpolation
 
03 truncation errors
03 truncation errors03 truncation errors
03 truncation errors
 
Interpolation of Cubic Splines
Interpolation of Cubic SplinesInterpolation of Cubic Splines
Interpolation of Cubic Splines
 
Runge Kutta Method
Runge Kutta Method Runge Kutta Method
Runge Kutta Method
 
Linear differential equation of second order
Linear differential equation of second orderLinear differential equation of second order
Linear differential equation of second order
 

Similar to 2. Fixed Point Iteration.pptx

Fixed point Iterative Method
Fixed point Iterative MethodFixed point Iterative Method
Fixed point Iterative MethodNasima Akhtar
 
3. DERIVATIVE BY INCREMENT IN CALULUS 01
3. DERIVATIVE BY INCREMENT IN CALULUS 013. DERIVATIVE BY INCREMENT IN CALULUS 01
3. DERIVATIVE BY INCREMENT IN CALULUS 01oliverosmarcial24
 
Matlab lab manual
Matlab lab manualMatlab lab manual
Matlab lab manualnmahi96
 
Introduction to Functions
Introduction to FunctionsIntroduction to Functions
Introduction to FunctionsMelanie Loslo
 
Introduction to Artificial Neural Networks
Introduction to Artificial Neural NetworksIntroduction to Artificial Neural Networks
Introduction to Artificial Neural NetworksStratio
 
Introduction to functions
Introduction to functionsIntroduction to functions
Introduction to functionsElkin Guillen
 
2 random variables notes 2p3
2 random variables notes 2p32 random variables notes 2p3
2 random variables notes 2p3MuhannadSaleh
 
Calculus - Functions Review
Calculus - Functions ReviewCalculus - Functions Review
Calculus - Functions Reviewhassaanciit
 
Differential calculus maxima minima
Differential calculus  maxima minimaDifferential calculus  maxima minima
Differential calculus maxima minimaSanthanam Krishnan
 
Introduction to comp.physics ch 3.pdf
Introduction to comp.physics ch 3.pdfIntroduction to comp.physics ch 3.pdf
Introduction to comp.physics ch 3.pdfJifarRaya
 
Trapezoidal Method IN Numerical Analysis
Trapezoidal Method IN  Numerical AnalysisTrapezoidal Method IN  Numerical Analysis
Trapezoidal Method IN Numerical AnalysisMostafijur Rahman
 
Function evaluation, termination, vertical line test etc
Function evaluation, termination, vertical line test etcFunction evaluation, termination, vertical line test etc
Function evaluation, termination, vertical line test etcsurprisesibusiso07
 
Impllicity Differentiation
Impllicity Differentiation Impllicity Differentiation
Impllicity Differentiation EmaduddinAksir
 

Similar to 2. Fixed Point Iteration.pptx (20)

Fixed point Iterative Method
Fixed point Iterative MethodFixed point Iterative Method
Fixed point Iterative Method
 
3. DERIVATIVE BY INCREMENT IN CALULUS 01
3. DERIVATIVE BY INCREMENT IN CALULUS 013. DERIVATIVE BY INCREMENT IN CALULUS 01
3. DERIVATIVE BY INCREMENT IN CALULUS 01
 
Matlab lab manual
Matlab lab manualMatlab lab manual
Matlab lab manual
 
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
Program on Quasi-Monte Carlo and High-Dimensional Sampling Methods for Applie...
 
Introduction to Functions
Introduction to FunctionsIntroduction to Functions
Introduction to Functions
 
Introduction to Artificial Neural Networks
Introduction to Artificial Neural NetworksIntroduction to Artificial Neural Networks
Introduction to Artificial Neural Networks
 
CALCULUS 2.pptx
CALCULUS 2.pptxCALCULUS 2.pptx
CALCULUS 2.pptx
 
Note introductions of functions
Note introductions of functionsNote introductions of functions
Note introductions of functions
 
Introduction to functions
Introduction to functionsIntroduction to functions
Introduction to functions
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
2 random variables notes 2p3
2 random variables notes 2p32 random variables notes 2p3
2 random variables notes 2p3
 
Calculus - Functions Review
Calculus - Functions ReviewCalculus - Functions Review
Calculus - Functions Review
 
Functions
FunctionsFunctions
Functions
 
Differential calculus maxima minima
Differential calculus  maxima minimaDifferential calculus  maxima minima
Differential calculus maxima minima
 
Introduction to comp.physics ch 3.pdf
Introduction to comp.physics ch 3.pdfIntroduction to comp.physics ch 3.pdf
Introduction to comp.physics ch 3.pdf
 
Trapezoidal Method IN Numerical Analysis
Trapezoidal Method IN  Numerical AnalysisTrapezoidal Method IN  Numerical Analysis
Trapezoidal Method IN Numerical Analysis
 
Function evaluation, termination, vertical line test etc
Function evaluation, termination, vertical line test etcFunction evaluation, termination, vertical line test etc
Function evaluation, termination, vertical line test etc
 
Impllicity Differentiation
Impllicity Differentiation Impllicity Differentiation
Impllicity Differentiation
 
EPCA_MODULE-2.pptx
EPCA_MODULE-2.pptxEPCA_MODULE-2.pptx
EPCA_MODULE-2.pptx
 
Secant Method
Secant MethodSecant Method
Secant Method
 

Recently uploaded

GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIkoyaldeepu123
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 

Recently uploaded (20)

Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AI
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 

2. Fixed Point Iteration.pptx

  • 1. NUMERICAL METHODS LAB (MT-202L) Instructor: Engr. Ahmed Zaheer Batch: 2k19 (5th Semester) Session: Fall 2022 MED, HITEC University, Taxila
  • 4. What is it? • A method for solving NON-LINEAR EQUATIONS • Non-linear Equations (some examples): • 4𝑥2 − 1 = 0 • 𝑥3 −𝑥2 +10 = 0 • 𝑦 = sin(𝑥) • 𝑦 = log(𝑥) 4
  • 5. Overview • This is also called as Methods of successive substitution • We solve f(x) = 0 in a different way • Actually we solve x= g (x) • Now we can write the above as x-g(x) = 0 • x-g(x) can now be called f(x) xn+1 = g(xn) • g(x) is also called the iteration function 5
  • 6. Overview • Plotting 2 graphs y=x & y=g(x) • The point where the 2 plots intersect is called the fixed point, is the solution • The numerical value of x (solution) is found by the iterative process • The initial guess is a value of x which is near the fixed point as the first guess and substitute in g(x) 6
  • 7. Explanation • Consider the equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎 • This equation can be written as: 𝑓 𝑥 = 𝑥3 + 𝑥2 − 1 • For x = 0, f(x) = -1 • For x = 1, f(x) = 1 • Solution (ROOT) of the equation will lie between -1 & 1 (b/c of changing sign) • INITIAL GUESS: 𝑥0 = 0.5 (some other value could also be taken) 7
  • 8. Explanation • Equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎 • Equation can be rearranged as: 1. 𝑥 = 3 1 − 𝑥2 [ g(x) = 3 1 − 𝑥2 ] 2. 𝑥 = 1 − 𝑥3 [ g(x) = 1 − 𝑥3 ] 3. 𝑥 = 1/ 𝑥 + 1 [ g(x) = 1/ 𝑥 + 1 ] • Which one of these “g(x)” is the correct one? 8
  • 9. Explanation • Equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎 • Which one of these “g(x)” is the correct one? • CONDITION FOR CHECKING | 𝒅[𝒈(𝒙)] 𝒅𝒙 | = |𝒈′ 𝒙 | < 𝟏 The absolute value (i.e. positive value) of 1st differential of g(x) should be less than 1 for the g(x) to be valid. 9
  • 10. Explanation • Equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎 • g(x) = 1/ 𝑥 + 1 : This is the desired g(x) • Generalized Form: 𝒙𝒏+𝟏 = 𝟏 𝟏+ 𝒙𝒏 10 g(x) = 𝟑 𝟏 − 𝐱𝟐 g(x) = 𝟏 − 𝐱𝟑 g(x) = 𝟏/ 𝐱 + 𝟏 𝑔′ 𝑥 = −2𝑥 3(1 − 𝑥2)2/3 𝑔′ 𝑥 = −3𝑥2 (1 − 𝑥3)1/2 𝑔′ 𝑥 = −1 2(𝑥+1)3/2 g’(0.5) = -0.4038 g’(0.5) = -0.8018 g’(0.5) = -0.2722 |g’(x)| = 0.4038 (< 1) |g’(x)| = 0.8018 (< 1) |g’(x)| = 0.2722 (< 1) Good OK Best (minimum value of g’(x) at 𝒙𝟎)
  • 11. Explanation • Equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎 • g(x) = 𝒙𝒏+𝟏 = 𝟏 𝟏+ 𝒙𝒏 • Root of Equation: 0.75488 11 i 𝒙𝒊 𝒙𝒊+𝟏 = 𝒈(𝒙) 0 0.5 0.81650 1 0.81650 0.74196 2 0.74196 0.75767 3 0.75767 0.75428 5 0.75428 0.75501 6 0.75501 0.75485 7 0.75485 0.75488 8 0.75488 0.75488
  • 13. fzero: Built-in Command • This command is built into the MATLAB specifically to solve Non-Linear Equations. • MATLAB can only equations in which right-hand side of the equal-sign is Zero. • Consider the equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎 • Equation can be written as: 𝑓 𝑥 = 𝑥3 + 𝑥2 − 1 • f(x) can be written in MATLAB as: f=@(x) • This equation will be written and solved in MATLAB as: • f=@(x) (x^3 + x^2 -1) • root = fzero(f,1) 13
  • 14. fzero: Built-in Command • Equation: 𝑓 𝑥 = 𝑥3 + 𝑥2 − 1 • This equation will be written and solved in MATLAB as: • f=@(x) (x^3 + x^2 -1) • fzero (f , 1) % This command will find the root of Function “ f ”, with Initial Guess value = 1 (Guess value can be changed to get the correct answer, or to get multiple roots) • Output will be displayed as: ans = 0.7549 14
  • 15. Graphical Solution • Graphs can be used to estimate the solution of equations 15
  • 16. Graphical Solution • Equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎 • 𝑦 = 𝑥3 + 𝑥2 − 1 • 𝑦 = 𝑥 • Graphs can be drawn in MATLAB as: x = -10:0.1:10; % x is an array containing elements from -10 to +10, with incremental steps of 0.1 y1 = x.^3 + x.^2 - 1; y2 = x; plot(x,y1,x,y2) % For plotting multiple graphs using a single line of code hold on grid on legend('y1','y2') 16
  • 17. Graphical Solution • Equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎 • 𝑦 = 𝑥3 + 𝑥2 − 1 • 𝑦 = 𝑥 • This graph can be zoomed for better clarity. • The point where the two curves intersect, is the solution i.e. the required Root of the equation. 17
  • 18. CODING THE ITERATION METHOD 18
  • 19. Overview • Iterative procedure for finding the root of an equation consists of 3 parts: 1. Initial Guess of solution 2. Algorithm for finding approximate solution 3. Criteria to Stop Computations • Equation: 𝒙𝟑 + 𝒙𝟐 − 𝟏 = 𝟎 • g(x) = 𝒙𝒏+𝟏 = 𝟏 𝟏+ 𝒙𝒏 19
  • 20. For Loop x0 = 1; % Intial Guess value maxIter = 50; % No. of max. iterations tolX = 1e-4; % Tolerance limit for Error x = x0; % x_n+1 x_old = x0; % x_n for i = 1:maxIter % For Loop x = 1/sqrt(1+x); % g(x) fprintf('x%0.0f = %fn',i,x) % Output display err = abs(x - x_old); % Absolute (positive) value of Error (between x_n and x_n+1) x_old = x; % Updating value of x_n if err < tolX % Comparing Error with Tolerance Limit break % When Error becomes less than Tolerance, the Loop will break end % End of If end % End of For Loop 20 Output Display x1 = 0.707107 x2 = 0.765367 x3 = 0.752632 x4 = 0.755361 x5 = 0.754774 x6 = 0.754900 x7 = 0.754873
  • 21. While Loop x0 = 1; % Intial Guess value maxIter = 50; % No. of max. iterations tolX = 1e-6; % Tolerance limit for Error err = 1; % Intial value of Error x = x0; % x_n+1 x_old = x0; % x_n i = 1; % Intial value of i (i=0,1,2,...) while err > tolX % While Loop x = 1/sqrt(1+x); % g(x) fprintf('x%0.0f = %fn',i,x) % Output display i = i+1; % Updating value of i err = abs(x - x_old); % Positive value of Error (between x_n and x_n+1) x_old = x; % Updating value of x_n end % Loop will end when Error becomes less than Tolerance 21
  • 23. Review • Fixed Point Iteration Method is used for finding ROOTS of Non-Linear Equations. • fzero command can be used to find solution of Non-linear equations directly (Initial Guess value should be chosen carefully). • Graphs can be used to visualize the solution of the equation. • Loops (both For & While) are tools which can be implemented in program code to find solution of equations, with following steps: • Initial Guess value • Algorithm for finding solution • Criteria for stopping computations 23
  • 24. The End • Thank you! • Any Questions? 24