SlideShare a Scribd company logo
1 of 1
function [r] = ncasinmt(f,a,b,N,eps)
f = inline('x^3-9*x+1')
a=2;
b=4;
N=18;
eps=0.0001;
if(f(a)==0)
r=a;
return;
elseif(f(b)==0)
r=b;
return;
elseif(f(a)*f(b)>0)
error('f(a) and f(b) donot have opposite sign')
end
for i = 2:N
c=(a+b)/2;
if(f(c)==0)
r=c;
return;
elseif(f(a)*f(c)<0)
b=c;
else a=c;
end
if (b-a)/2<eps;
if(abs(f(a))<abs(f(b))&&abs(f(a))<eps)
r=a;
return;
elseif(abs(f(b))<eps)
r=b;
return;
end
end
end
-----------------------------
Taimoor Gondal,
COMSATS Wah Cantt
end

More Related Content

What's hot

What's hot (19)

Funciones booleanas
Funciones booleanasFunciones booleanas
Funciones booleanas
 
حساب النهايات جبرياً
حساب النهايات جبرياًحساب النهايات جبرياً
حساب النهايات جبرياً
 
Infix to-postfix examples
Infix to-postfix examplesInfix to-postfix examples
Infix to-postfix examples
 
Inversa lu
Inversa luInversa lu
Inversa lu
 
The Moore-Spiegel Oscillator
The Moore-Spiegel OscillatorThe Moore-Spiegel Oscillator
The Moore-Spiegel Oscillator
 
Jillians Potw
Jillians PotwJillians Potw
Jillians Potw
 
Jillian Fluet’S Potw Solution
Jillian Fluet’S Potw SolutionJillian Fluet’S Potw Solution
Jillian Fluet’S Potw Solution
 
Langrange method for MATLAB Code
Langrange method for MATLAB CodeLangrange method for MATLAB Code
Langrange method for MATLAB Code
 
Day 1a examples
Day 1a examplesDay 1a examples
Day 1a examples
 
متاپست (MetaPost)
متاپست (MetaPost)متاپست (MetaPost)
متاپست (MetaPost)
 
Exam 1 questions
Exam 1 questionsExam 1 questions
Exam 1 questions
 
Leyes de conjuntos (Grafos)
Leyes de conjuntos (Grafos)Leyes de conjuntos (Grafos)
Leyes de conjuntos (Grafos)
 
Newton's method for MATLAB Code
Newton's method for MATLAB CodeNewton's method for MATLAB Code
Newton's method for MATLAB Code
 
7segment scetch
7segment scetch7segment scetch
7segment scetch
 
Ninth grade 4th period study guide key
Ninth grade 4th period study guide keyNinth grade 4th period study guide key
Ninth grade 4th period study guide key
 
(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2
 
Session07 recursion
Session07 recursionSession07 recursion
Session07 recursion
 
Efoom 2018
Efoom 2018Efoom 2018
Efoom 2018
 
ML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional LanguageML: A Strongly Typed Functional Language
ML: A Strongly Typed Functional Language
 

More from Taimoor Muzaffar Gondal

Lecture 04: Errors During the Measurement Process
Lecture 04: Errors During the Measurement ProcessLecture 04: Errors During the Measurement Process
Lecture 04: Errors During the Measurement ProcessTaimoor Muzaffar Gondal
 
Effects of Currents and Type of Cells and Batteries
Effects of Currents and Type of Cells and BatteriesEffects of Currents and Type of Cells and Batteries
Effects of Currents and Type of Cells and BatteriesTaimoor Muzaffar Gondal
 

More from Taimoor Muzaffar Gondal (20)

Basics of Computer
Basics of ComputerBasics of Computer
Basics of Computer
 
Lecture 04: Errors During the Measurement Process
Lecture 04: Errors During the Measurement ProcessLecture 04: Errors During the Measurement Process
Lecture 04: Errors During the Measurement Process
 
Introduction to Measurements-Lecture 01
Introduction to Measurements-Lecture 01Introduction to Measurements-Lecture 01
Introduction to Measurements-Lecture 01
 
Updated Lecture 01- History of Atom
Updated Lecture 01- History of AtomUpdated Lecture 01- History of Atom
Updated Lecture 01- History of Atom
 
Heat and Its Transfer
Heat and Its TransferHeat and Its Transfer
Heat and Its Transfer
 
Low, Medium and High Frequency Current
Low, Medium and High Frequency CurrentLow, Medium and High Frequency Current
Low, Medium and High Frequency Current
 
Rectification and Electrotherapy
Rectification and ElectrotherapyRectification and Electrotherapy
Rectification and Electrotherapy
 
Applications of EM Waves
Applications of EM WavesApplications of EM Waves
Applications of EM Waves
 
Electromagnetism Fundamentals
Electromagnetism FundamentalsElectromagnetism Fundamentals
Electromagnetism Fundamentals
 
Effects of Currents and Type of Cells and Batteries
Effects of Currents and Type of Cells and BatteriesEffects of Currents and Type of Cells and Batteries
Effects of Currents and Type of Cells and Batteries
 
Current Electricity
Current ElectricityCurrent Electricity
Current Electricity
 
Static Electricity
Static ElectricityStatic Electricity
Static Electricity
 
Lecture 01- Atomic Structure
Lecture 01- Atomic StructureLecture 01- Atomic Structure
Lecture 01- Atomic Structure
 
An Overview of PLC
An Overview of PLCAn Overview of PLC
An Overview of PLC
 
Jacobi method for MATLAB
Jacobi method for MATLAB Jacobi method for MATLAB
Jacobi method for MATLAB
 
Gauss seidal Matlab Code
Gauss seidal Matlab CodeGauss seidal Matlab Code
Gauss seidal Matlab Code
 
Finite difference Matlab Code
Finite difference Matlab CodeFinite difference Matlab Code
Finite difference Matlab Code
 
Divided difference Matlab code
Divided difference Matlab codeDivided difference Matlab code
Divided difference Matlab code
 
Physical features of pakistan
Physical features of pakistanPhysical features of pakistan
Physical features of pakistan
 
Establishment of pakistan
Establishment of pakistanEstablishment of pakistan
Establishment of pakistan
 

Recently uploaded

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
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 

Recently uploaded (20)

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
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
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
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 

Bisection methode alternate

  • 1. function [r] = ncasinmt(f,a,b,N,eps) f = inline('x^3-9*x+1') a=2; b=4; N=18; eps=0.0001; if(f(a)==0) r=a; return; elseif(f(b)==0) r=b; return; elseif(f(a)*f(b)>0) error('f(a) and f(b) donot have opposite sign') end for i = 2:N c=(a+b)/2; if(f(c)==0) r=c; return; elseif(f(a)*f(c)<0) b=c; else a=c; end if (b-a)/2<eps; if(abs(f(a))<abs(f(b))&&abs(f(a))<eps) r=a; return; elseif(abs(f(b))<eps) r=b; return; end end end ----------------------------- Taimoor Gondal, COMSATS Wah Cantt end